Просмотр REM атрибутов заявки

Добрый день!

Данная надстройка позволяет отобразить в новой вкладке различные параметры всех REM атрибутов заявки (модель запроса + связанные коллекции)

Параметры записи UI Action

Свойство Значение
Наименование REM атрибуты заявки
Таблица Задачи (task)
Наследуемое Да
Условие ss.hasRole(‘admin’)
На существующей записи Да
Клиентское Да
Стиль формы → Ссылка внизу формы Да

Скрипт

const simpleAjax = new SimpleAjax();
await simpleAjax.runScript(`
  const current = new SimpleRecord('task');
        current.get('${s_form.getUniqueValue()}');

  let reModelID = current.getReModelId();
  let remObj = {
    'reModelID': getAttrValue(current.getReModelId())
  };
      
  const reModelCol = new SimpleRecord('sys_re_model_collection');
        reModelCol.addQuery('re_model_id', current.getReModelId());
        reModelCol.query();
        while (reModelCol.next()) {
          remObj[reModelCol.getDisplayValue('re_collection_id')] = getAttrValue(reModelCol.re_collection_id);
        }
      
  function getAttrValue(params) {
    let answer = {}
        
    const reAttribute = new SimpleRecord('sys_re_attribute');
          reAttribute.addQuery('re_container_id', params);
          reAttribute.query();
          while (reAttribute.next()) {
            let attrName = reAttribute.column_name;
            let attrType = getAttrType(reAttribute.column_type_id);
            let attrValue = current.rem_attr.getValue(attrName);

            answer[attrName] = {
              ...(attrName != reAttribute.title) && { 'name': reAttribute.title },
              'type': attrType,
              'value': attrValue,
              ...(['choice', 'reference', 'list'].includes(attrType) && attrValue) && {
                'display_value': (current.rem_attr.getDisplayValue(attrName))
              },
            };
          }

    return answer;
  }

  function getAttrType(attrID) {
    let attrType = new SimpleRecord('sys_db_column_type');
        attrType.get(attrID);

    return attrType.name
  }
      
  setResult(remObj)`,
  null,
  ({ data: { result } }) => {          
    let x = window.open();
        x.document.open();
        x.document.write(`
          <html>
            <body>
              <div>
                <pre>${JSON.stringify(result, null, 2)}</pre>
              </div>
            </body>
          </html>`);
        x.document.close();
  }
)
2 лайка