Поле организации
В схему, по которой открывается основная форма, добавить свойство "addLinked<Name>organization" со ссылкой на системную схему "SelectLinkedDocDialogResource"
Блок кода |
---|
|
<schema-ref<actor name="addLinkedDoc" reforganization">
<storage-field name="SelectLinkedDocDialogResourceorganization"/> |
Конфигурация диалога выбора
Создать схему - наследник "LinkedDocSelectionParams<Name>" с системной схемы "LinkedDocSelectionParamsCommon". внутри созданной схемы переопределить свойства:
Поле с гиперссылкой на объект
Создание объекта
Схема объекта
Создать схему, которая будет описывать объект. Обязательные св-ва:
- tnUnid - идентификатор объекта
- tnName - информация об объекте
Блок кода |
---|
language | xml |
---|
title | schema name=" |
---|
|
LinkedDocSelectionParamsExampledocumentLink" | collapse | true |
---|
|
<schemas xmlns="http://www.intertrust.ru/schema/palette/tn-schema">
|
<schemaLinkedDocSelectionParamsExample" extends="LinkedDocSelectionParamsCommon" <meta>
<categoryСистема\Делопроизводство"tnUnid" temporal = "true"/>
|
<documentation>Ресурсспараметрамивыборадокумента в диалоге добавления связанного</documentation>
</meta>
<string name="title<string name="tnName" computed="true" temporal = "true">
|
<calc <script <script event="open" lang="SPEL"><![CDATA[ |
'Выберитедокументиз системы']]></script>
</calc-values>
</string>
<boolean name="allowedManual" temporal="true">
<calc-values>
<script event="open" lang="SPEL"><![CDATA[false]]></script>
</calc-values>
</boolean>
<boolean name="isManySelect" temporal="true">
<calc-values>
<script event="open" lang="SPEL"><![CDATA[true]]></script>
</calc-values>
</boolean>
<string name="modules" array="true" temporal="true">
<calc-values>
<script event="open" lang="SPEL"><![CDATA[T(java.util.Arrays).asList("OutputDocs", "InternalDocs")]]></script>
</calc-values>
</string>
<string name="submit_caption" temporal="true">
<calc-values>
<script event="open" lang="SPEL"><![CDATA['Добавить документ']]></script>
</calc-values>
</string>
</schema>
</schemas>Для созданной схемы создать форму, она не будет использоваться, но её наличие необходимо системе для вычисления свойств схемы. В ней можно сделать, например, только поле title.
Блок кода |
---|
language | xml |
---|
title | form id="LinkedDocSelectionParamsExample" |
---|
collapse | true |
---|
|
<?xml version='1.0' encoding='UTF-8'?>
<ui xmlns="http://www.intertrust.ru/schema/palette/tn-ui">
<form schema-ref="TempLinkedDocSelectionParamsExample" id="LinkedDocSelectionParamsExample" name="${ui.form.TempLinkedDocSelectionParamsExample.name:"-"}" projection="default">
<component>
null ? null :{
#document = T(ru.intertrust.cmj.af.core.AFSession).get().getApplication(T(ru.intertrust.cmj.tunable.object.TunableObjectApplication)).getEntityByUNID(tnUnid),
#document?.tuning()?.getValues()?.get('subject')?.getValue()?:''
}[1]]]></script>
</calc-values>
</string>
</schema>
</schemas> |
Отображение объекта
Примечание |
---|
Форма используется, если выбранное значение записывается в поле, в данном примере это не понадобится |
Создать форму для отображения объекта
Блок кода |
---|
language | xml |
---|
title | form id="documentLinkForm" |
---|
collapse | true |
---|
|
<?xml version='1.0' encoding='UTF-8'?>
<ui xmlns="http://www.intertrust.ru/schema/palette/tn-ui">
<form schema-ref="documentLink" id="documentLinkForm" projection="default">
<properties>
<hide condition-union="AND">
<negative-condition-ref ref="digest"/>
</hide>
</properties>
<component>
<field attribute-ref="tnName">
<properties>
<read-only condition-union="AND">
<condition>true</condition>
</read-only>
</properties>
<appearance importance="normal"/>
</field>
</component>
</form>
</ui> |
Создание схемы объекта на форме/диалоге
Создать схему, которая будет описывать объект на форме/диалоге. Обязательные св-ва:
- orgName - краткое название организации, полученное из документа
- document - информация об объекте
- id - идентификатор объекта
- description - описание объекта. Пример: Договор поставки №34 от 11.12.2023
- Link - ссылка на объект
Блок кода |
---|
language | xml |
---|
title | schema name="CMDocumentByOrg" |
---|
collapse | true |
---|
|
<?xml version='1.0' encoding='UTF-8'?>
<schemas xmlns="http://www.intertrust.ru/schema/palette/tn-schema">
<schema name="CMDocumentByOrg">
<!-- Краткое название организации выбранной организации -->
<string name="orgName" computed="true">
<storage-field name="CMDocumentOrgName" />
<calc-values>
<script event="open" lang="SPEL">
<![CDATA[!#isObjectContains(#parentnode, 'organization')? null:#parentnode.organization== null ? null:#parentnode.organization.getOrganizationName()]]>
</script>
</calc-values>
</string>
<schema-ref name="document" ref="documentLink" temporal="true"/>
<string name="id">
<storage-field name="CMDocumentID"/>
</string>
<string name="description">
<storage-field name="CMDocumentDescription"/>
</string>
<hyperlink computed="true"name="Link">
<storage-field name="CMDocumentLink"/>
<calc-values>
<script lang="SPEL" event="open">
<![CDATA[id == null ? null : T(ru.intertrust.cmj.af.misc.HyperLink).createHyperLink(description + '~#' + T(ru.intertrust.cmj.ws.base.servlet.ServletUrlHolder).getServerUrlStr() + '/ids/' + id +'~#newTab~#local')]]>
</script>
</calc-values>
</hyperlink>
</schema>
</schemas> |
Подключение поля
В схему, по которой открывается основная форма, добавить объектное свойство
Блок кода |
---|
|
<schema-ref name="CMDocumentBase" ref="CMDocumentByOrg"/> |
Создание объектных справочников
Создание кастомной коллекции
Создать коллекцию
Блок кода |
---|
|
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd"
default-lazy-init="true">
<bean id="ContractsLite_(active)Metadata"
class="ru.intertrust.cm_sochi.srv.connector.sochi.collections.CollectionMetadataNew"
p:caseSensitiveFieldNames="true" p:searchArea="ContractsLite_uicoll">
<constructor-arg>
<list value-type="ru.intertrust.cm_sochi.srv.connector.sochi.collections.Field">
<bean class="ru.intertrust.cm_sochi.srv.connector.sochi.collections.Field" p:name="self">
<property name="virtualField">
<bean class="ru.intertrust.cm_sochi.srv.connector.sochi.collections.BuildVirtualField">
<property name="realFields">
<list>
<value>self_1</value>
<value>Module</value>
<value>self_2</value>
<value>id</value>
<value>created_date</value>
<value>self_3</value>
</list>
</property>
<property name="pattern" value="<id>([0-9]{16}):([0-9A-F]{32})</>"/>
<property name="separator" value=""/>
<property name="emptySeparator" value="true"/>
</bean>
</property>
</bean>
<bean class="ru.intertrust.cm_sochi.srv.connector.sochi.collections.Field" p:name="objectLink">
<property name="virtualField">
<bean class="ru.intertrust.cm_sochi.srv.connector.sochi.collections.BuildVirtualField">
<property name="realFields">
<list>
<value>object_tag_name</value>
<value>objectName</value>
<value>object_tag_close</value>
<value>object_tag_tnunid</value>
<value>Module</value>
<value>object_tag_2</value>
<value>id</value>
<value>created_date</value>
<value>object_tag_close</value>
<value>object_tag_unid</value>
<value>Module</value>
<value>object_tag_2</value>
<value>id</value>
<value>created_date</value>
<value>object_tag_close</value>
</list>
</property>
<property name="separator" value=""/>
<property name="emptySeparator" value="true"/>
</bean>
</property>
</bean>
<bean class="ru.intertrust.cm_sochi.srv.connector.sochi.collections.Field" p:name="secondParty" p:sortOrder="ASCENDING"/>
</list>
</constructor-arg>
</bean>
</beans>
|
Создание дескриптора
Создание представления
Создание справочника
Диалог выбора объекта
Создание схемы диалога выбора объекта
Создать схему наследник с "Dialog", которая будет описывать диалог выбора объекта
- CMDocumentBase - объектное поле
- orgName - краткое название организации, полученное из объекта
Блок кода |
---|
language | xml |
---|
title | schema name="CMDocumentByOrgDialog" |
---|
|
<?xml version='1.0' encoding='UTF-8'?>
<schemas xmlns="http://www.intertrust.ru/schema/palette/tn-schema">
<schema name="CMDocumentByOrgDialog" extends="Dialog" recalc="true">
<schema-ref name="CMDocumentBase" ref="CMDocumentByOrg"/>
<string name="orgName" computed="true" temporal="true">
<calc-values>
<script event="open" lang="SPEL">
<![CDATA[#this.CMDocumentBase==null?'':#this.CMDocumentBase.orgName]]>
</script>
</calc-values>
</string>
</schema>
</schemas> |
Форма диалога выбора объекта
Создать форму на базе схемы диалога выбора объекта
Блок кода |
---|
language | xml |
---|
title | form id="CMDocumentByOrgDialogUI" |
---|
|
<?xml version='1.0' encoding='UTF-8'?>
<ui xmlns="http://www.intertrust.ru/schema/palette/tn-ui">
<form schema-ref="CMDocumentByOrgDialog" id="CMDocumentByOrgDialogUI" name="${ui.form.CMDocumentByOrgDialogUI.name:Выбор документа}" projection="default">
<appearance>
<dialog-mode width="50" unit="percent"/>
</appearance>
<properties>
<hide condition-union="AND">
<negative-condition-ref ref="dialog"/>
</hide>
</properties>
<component>
<field attribute-ref="CMDocumentBase.orgName" recalc="true">
<properties>
<hide>
<condition>true</condition>
|
<field attribute-ref="title"/>
</component>
</form>
</ui>Поле с гиперссылкой на объект
Создание схемы
Создать схему, которая будет описывать выбранный объект. Обязательные св-ва:
id - идентификатор объектаdescription - описание объекта. Пример: Входящий документ №23 от 20.05.2024Link - ссылка на объект Блок кода |
---|
language | xml |
---|
title | schema name="CMDocument" |
---|
collapse | true |
---|
|
<?xml version='1.0' encoding='UTF-8'?>
<schemas
xmlns="http://www.intertrust.ru/schema/palette/tn-schema">
<schema name="CMDocument">
<string name="id">
<storage-field name="CMDocumentID" />
</string>
<string name="description" computed="true">
<storage-field name="CMDocumentDescription" />
</string>
<hyperlink computed="true" name="Link">
<storage-field name="CMDocumentLink" />
<calc-values>
<script lang="SPEL" event="open">
<![CDATA[id == null ? null : T(ru.intertrust.cmj.af.misc.HyperLink).createHyperLink(description +'~#'+T(ru.intertrust.cmj.ws.base.servlet.ServletUrlHolder).getServerUrlStr() + '/ids/' + id +'~#newTab~#local')]]>
</script>
</calc-values>
</hyperlink>
</schema>
</schemas> |
Подключение поля
В схему, по которой открывается форма добавить свойство "CMDocumentBase" со ссылкой на cхему "CMDocument"
Блок кода |
---|
|
<schema-ref name="CMDocumentBase" ref="CMDocument" null-empty="true"/> </properties>
</field>
<field attribute-ref="CMDocumentBase.document">
<appearance open-mode="grid" digest-mode="grid" importance="normal" widget="grid"/>
<directories>
<directory-category-custom-coll ref="dirContractsByOrg" attribute-ref="orgName"/>
</directories>
</field>
<button name="${ui.form.CMDocumentByOrgDialogUI.submit:Подтвердить}">
<action>
<system name="submit"/>
</action>
</button>
</component>
</form>
</ui> |
UI-интерфейс
Подключение к форме
На форме создать группу полей:
- объектное поле CMDocumentBase
- кнопка с действием update-linked-doc и указанной схемой с параметрами "LinkedDocSelectionParams<Name>"
- скрытое поле, указывающее на свойство "addLinked<Name>". В нём указывается recalc.
Блок кода |
---|
language | xml |
---|
title | section |
---|
collapse | true |
---|
|
...
<section id="select_cm_document" group="true">
<appearance field-layout="horizontal">
<dialog-mode width="49" unit="percent"/>
</appearance>
<component>
<field attribute-ref="CMDocumentBase.Link" alias="CMDocumentBase.description" name="${ui.form.CMDocumentBase.name:Документ из системы:}">
<appearance importance="normal" multiline="false" open-form="newTab">
<limit height="1" max-size="1" max-height-scroll="1"/>
<label-style>
<style id="tunBorderedField"/>
</label-style>
</appearance>
</field>
<section id="select_cm_document_button" group="true">
<properties>
<hide>
<condition-ref ref="read"/>
</hide>
</properties>
<component>
<button attribute-ref="addLinkedDoc" name="${ui.form.button.addLinkedDoc.name:+}">
<appearance>
<label-style>
<style id="tunBtn"/>
</label-style>
</appearance>
<action>
<custom>
<update-linked-doc schema-ref="LinkedDocSelectionParamsExample"/>
</custom>
</action>
</button>
</component>
</section>
<field attribute-ref="addLinkedDoc" recalc="true">
<properties>
<hide>
<condition>true</condition>
</hide>
</properties>
</field>
</component>
</section>
... |
Доработка обработчика событий
При нажатии на кнопку будет показан диалог выбора документов с учётом заданных параметров. Web-клиент заполнит объект со структурой SelectLinkedDocDialogResource
После выбора отправится запрос на обновление, который надо обработать в custom-event-handler.
Блок кода |
---|
language | js |
---|
title | custom-event-handler |
---|
collapse | true |
---|
|
importClass(Packages.ru.intertrust.cmj.af.misc.AFDate);
importClass(Packages.ru.intertrust.cmj.rest.tuning.TuningHelper);
importClass(Packages.ru.intertrust.cmj.tunable.object.common.TunableObjectHelper);
importClass(Packages.ru.intertrust.cmj.tunable.object.history.TunableHistoryHelper);
importClass(Packages.ru.intertrust.cmj.af.core.AFCMDomino);
importClass(Packages.ru.intertrust.cmj.af.core.AFSession);
importClass(Packages.ru.intertrust.cmj.af.utils.BeansUtils);
importClass(Packages.ru.intertrust.cmj.af.utils.Utils);
importClass(Packages.ru.intertrust.cmj.af.misc.HyperLink);
importClass(Packages.ru.intertrust.cmj.dp.DPApplication);
importClass(Packages.ru.intertrust.cmj.af.tuning.impl.AFInstanceSimpleImpl);
importClass(Packages.ru.intertrust.cmj.af.tuning.impl.AFInstanceObjectImpl);
importClass(Packages.ru.intertrust.cmj.af.tuning.impl.AFInstanceArrayImpl);
importClass(Packages.ru.intertrust.cmj.af.tuning.TuningApplication);
importClass(Packages.ru.intertrust.cmj.dp.DPMContracts);
importPackage(Packages.java.util);
importPackage(Packages.java.lang);
importClass(Packages.java.util.List);
importClass(Packages.java.util.Arrays);
function recalc(object, changedField) {
var appdp = AFSession.get().getApplication(DPApplication.class);
/*Заполнение объектного поля из диалога выбора документа*/
if (changedField == 'addLinkedDoc') {
var addLinkedDoc = values.get('addLinkedDoc');
if (addLinkedDoc.getValues().get("ids") != null) {
var ids = addLinkedDoc.getValues().get("ids").getValues();
for (var i = 0; i < ids.size(); i++) {
var unid = getIdFromHref(ids.get(i).getValue());
if (!unid.equals("")) {
var rkk = appdp.getEntityByUNID(unid);
fillCMDocumentBase(object, rkk);
}
}
}
TunableObjectHelper.putAFInstanceValue(object.tuning(), "addLinkedDoc", null);
}
/*...*/
}
/*Заполнение объектного поля*/
function fillCMDocumentBase(object, rkk) {
var values = object.tuning().getValues();
var documentID = rkk.getUNID();
var regNumber = getRegNumber(object);
var reqType = document.getType();
var regDate = rkk.registration().getDate();
var regDateStr = AFDate.fromJavaDate(regDate).toString();
var description = reqType + " №" + regNumber + " от " + regDateStr;
TunableObjectHelper.putAFInstanceValue(object.tuning(), "CMDocumentBase.id", documentID);
TunableObjectHelper.putAFInstanceValue(object.tuning(), "CMDocumentBase.description", description);
}
/*Вычисление регистрационного номера*/
function getRegNumber(rkk) {
var regNumber = "";
regNumber = rkk.registration().getRegisteredInfo() != null ? rkk.registration().getRegisteredInfo().getNumber().toString() : "";
return regNumber;
}
/*Получение UNID-объекта из ссылки*/
function getIdFromHref(href) {
var index = href.lastIndexOf("/", href.length()) + 1;
if (index < 0) {
return href;
} else {
return href.substring(index);
}
} |