Доработать схему
Включить в схеме Correspondent признак обновления свойств схемы (recalc="true"), которую использует форма диалога
Схема
<?xml version='1.0' encoding='UTF-8'?> <schemas xmlns="http://www.intertrust.ru/schema/palette/tn-schema"> <schema name="schemaCorrespondent" recalc="true" > <!--...--> <string name="all_address" array="true" temporal="true"/> <string name="all_phone" array="true" temporal="true"/> </schema> </schemas>
Доработать форму
В форме CorrespondentDialog в поле "Корреспондент" включить признак "Участие в вычисление секции" (recalc = "true")
Форма
<?xml version='1.0' encoding='UTF-8'?> <ui xmlns="http://www.intertrust.ru/schema/palette/tn-ui"> <form id="formCorrespondentDialog" schema-ref="schemaCorrespondent" name="${ui.form.CorrespondentDialog.name:Корреспондент}"> <properties> <hide condition-union="AND"> <negative-condition-ref ref="dialog"/> </hide> </properties> <component> <field name="${ui.form.CorrespondentTableDialogForm.Correspondent.name:Корреспондент:}" attribute-ref="Correspondent" recalc="true"> <!--...--> </field> <!--...--> </component> </form> </ui>
Доработать обработчик событий
Добавить в обработчик событий recalc
Обработчик событий
<?xml version='1.0' encoding='UTF-8'?> <schemas xmlns="http://www.intertrust.ru/schema/palette/tn-schema"> <schema name="schemaCorrespondent"> <!--...--> <custom-event-handler lang="JavaScript"><![CDATA[...]]></custom-event-handler> <schema> </schemas>
Код
Обработчик событий
importPackage(Packages.java.lang); importPackage(Packages.java.util); importPackage(Packages.ru.intertrust.cmj.af.so); importPackage(Packages.ru.intertrust.cmj.rest.tuning); importPackage(Packages.ru.intertrust.cmj.af.misc); importPackage(Packages.ru.intertrust.cmj.af.utils); importPackage(Packages.ru.intertrust.cmj.af.tuning.impl); importClass(Packages.ru.intertrust.cmj.rest.tuning.TuningHelper); importClass(Packages.java.lang.System); importClass(Packages.ru.intertrust.cmj.tunable.object.common.TunableObjectHelper); importClass(Packages.ru.intertrust.cmj.af.core.AFSession); importClass(Packages.ru.intertrust.cmj.tunable.object.TunableObjectApplication); importClass(Packages.ru.intertrust.cmj.tunable.object.AnyTunableObject); importClass(Packages.ru.intertrust.cmj.af.core.AFCMDomino); importClass(Packages.org.springframework.util.StringUtils); importClass(Packages.ru.intertrust.cmj.af.so.SOApplication); function recalc(object, changedField) { if (changedField == "Correspondent") { //Обнуление полей object.tuning().getValues().put("Phone", null); object.tuning().getValues().put("SendAddress", null); if (object.tuning().getValues().get('Correspondent') != null && object.tuning().getValues().get('Correspondent').getValue() != null) { //Поле Корреспондент не пустое var correspondent = object.tuning().getValues().get('Correspondent').getValue(); //значение из поля Корреспондент var emplAddrs = new ArrayList(); var emplPhones = new ArrayList(); if (correspondent.getAddress() != "") { emplAddrs.add(correspondent.getAddress()); //заполняем адрес из бороды } if (correspondent.originalData().getType() == SOBeard.Type.NONSYS_ORGANIZATION) { if (correspondent.originalData().getParty().addressInfo().legal().getAddress() != "") { emplAddrs.add(person.originalData().getParty().addressInfo().legal().getAddress()); } } if (!emplAddrs.isEmpty()) { TuningHelper.processProperty(object.tuning().getValues(), "all_address", emplAddrs, object.tuning().getSchema().getProperty("all_address")); } var fio = new ArrayList(); fio.add(person.originalData().getFullName()); var fioValue = new AFInstanceArrayImpl(object.tuning().getSchema(), fio); object.tuning().getValues().put("Recipient", fioValue); var appTNObject = AFSession.get().getApplication(TunableObjectApplication.class); var objectBeard = appTNObject.getEntityByUNID(AFCMDomino.ormUnidToTNUnid(person.getUNID())); var phoneH = objectBeard.tuning().getValues().get("phoneHouse"); var phoneW = objectBeard.tuning().getValues().get("phoneWork"); var phoneM = objectBeard.tuning().getValues().get("phoneMobil"); var phone = objectBeard.tuning().getValues().get("phone"); emplPhones.add(phoneH); emplPhones.add(phoneW); emplPhones.add(phoneM); if (phone != null && phone.getValues() != null) { emplPhones.addAll(phone.getValues()); } var phoneValue; if (phoneM != null) { phoneValue = TunableObjectHelper.getAFInstanceValue(objectBeard.tuning().getValues().get("phoneMobil")); } else if (phoneW != null) { phoneValue = TunableObjectHelper.getAFInstanceValue(objectBeard.tuning().getValues().get("phoneWork")); } else if (phoneH != null) { phoneValue = TunableObjectHelper.getAFInstanceValue(objectBeard.tuning().getValues().get("phoneHouse")); } else if (phone != null && objectBeard.tuning().getValues().get("phone").getValues() != null) { phoneValue = TunableObjectHelper.getAFInstanceValue(objectBeard.tuning().getValues().get("phone").getValues().get(0)); } if (phoneValue != null) { TuningHelper.processProperty(object.tuning().getValues(), "Phone", phoneValue, object.tuning().getSchema().getProperty("Phone")); } if (!emplPhones.isEmpty()) { TuningHelper.processProperty(object.tuning().getValues(), "all_phone", emplPhones, object.tuning().getSchema().getProperty("all_phone")); } if (objectBeard != null) { if (person.originalData().getType().toString().equals("PRIVATE_HUMAN")) { var indexValue = TunableObjectHelper.getAFInstanceValue(objectBeard.tuning().getValues().get("sendIndex")); //var phoneValue = TunableObjectHelper.getAFInstanceValue(objectBeard.tuning().getValues().get("phoneHouse")); var countryValue = TunableObjectHelper.getAFInstanceValue(objectBeard.tuning().getValues().get("country")); var regionValue = TunableObjectHelper.getAFInstanceValue(objectBeard.tuning().getValues().get("region")); var districtValue = TunableObjectHelper.getAFInstanceValue(objectBeard.tuning().getValues().get("district")); var cityValue = TunableObjectHelper.getAFInstanceValue(objectBeard.tuning().getValues().get("city")); var streetValue = TunableObjectHelper.getAFInstanceValue(objectBeard.tuning().getValues().get("street")); var houseValue = TunableObjectHelper.getAFInstanceValue(objectBeard.tuning().getValues().get("house")); var structureValue = TunableObjectHelper.getAFInstanceValue(objectBeard.tuning().getValues().get("structure")); var housingValue = TunableObjectHelper.getAFInstanceValue(objectBeard.tuning().getValues().get("housing")); var roomValue = TunableObjectHelper.getAFInstanceValue(objectBeard.tuning().getValues().get("room")); var addressValue = (StringUtils.hasLength(countryValue) ? countryValue + ', ' : "") + (StringUtils.hasLength(regionValue) ? regionValue + ', ' : "") + (StringUtils.hasLength(districtValue) ? districtValue + ', ' : "") + (StringUtils.hasLength(cityValue) ? cityValue + ', ' : "") + (StringUtils.hasLength(streetValue) ? streetValue + ', ' : "") + (StringUtils.hasLength(houseValue) ? houseValue + ', ' : "") + (StringUtils.hasLength(structureValue) ? structureValue + ', ' : "") + (StringUtils.hasLength(housingValue) ? housingValue + ', ' : "") + (StringUtils.hasLength(roomValue) ? roomValue : ""); TuningHelper.processProperty(object.tuning().getValues(), "Index", indexValue, object.tuning().getSchema().getProperty("Index")); TuningHelper.processProperty(object.tuning().getValues(), "SendAddress", addressValue, object.tuning().getSchema().getProperty("SendAddress")); //TuningHelper.processProperty(object.tuning().getValues(), "Phone", phoneValue, object.tuning().getSchema().getProperty("Phone")); } else if (person.originalData().getType().toString().equals("SYS_ORGANIZATION")) { var addressValue = person.originalData().getParty().getOrganizationDescription().addressInfo().post().getAddress(); var indexValue = person.originalData().getParty().getOrganizationDescription().addressInfo().post().getZipCode(); TuningHelper.processProperty(object.tuning().getValues(), "SendAddress", addressValue, object.tuning().getSchema().getProperty("SendAddress")); TuningHelper.processProperty(object.tuning().getValues(), "Index", indexValue, object.tuning().getSchema().getProperty("Index")); } else { var indexValue = TunableObjectHelper.getAFInstanceValue(objectBeard.tuning().getValues().get("jSendIndex")); var countryValue = TunableObjectHelper.getAFInstanceValue(objectBeard.tuning().getValues().get("jcountryName")); var regionValue = TunableObjectHelper.getAFInstanceValue(objectBeard.tuning().getValues().get("region")); var districtValue = TunableObjectHelper.getAFInstanceValue(objectBeard.tuning().getValues().get("jDistrict")); var cityValue = TunableObjectHelper.getAFInstanceValue(objectBeard.tuning().getValues().get("jCity")); var streetValue = TunableObjectHelper.getAFInstanceValue(objectBeard.tuning().getValues().get("jStreet")); var houseValue = TunableObjectHelper.getAFInstanceValue(objectBeard.tuning().getValues().get("jHouse")); var structureValue = TunableObjectHelper.getAFInstanceValue(objectBeard.tuning().getValues().get("jStructure")); var housingValue = TunableObjectHelper.getAFInstanceValue(objectBeard.tuning().getValues().get("jHousing")); var addressValue = (StringUtils.hasLength(countryValue) ? countryValue + ', ' : "") + (StringUtils.hasLength(regionValue) ? regionValue + ', ' : "") + (StringUtils.hasLength(districtValue) ? districtValue + ', ' : "") + (StringUtils.hasLength(cityValue) ? cityValue + ', ' : "") + (StringUtils.hasLength(streetValue) ? streetValue + ', ' : "") + (StringUtils.hasLength(houseValue) ? houseValue + ', ' : "") + (StringUtils.hasLength(structureValue) ? structureValue + ', ' : "") + (StringUtils.hasLength(housingValue) ? housingValue : ""); TuningHelper.processProperty(object.tuning().getValues(), "Index", indexValue, object.tuning().getSchema().getProperty("Index")); TuningHelper.processProperty(object.tuning().getValues(), "SendAddress", addressValue, object.tuning().getSchema().getProperty("SendAddress")); } } if (person.originalData().getType().toString().equals("SYS_ORGANIZATION")) { object.tuning().put("isSysOrg", TuningHelper.createPropertyValue(true, object.tuning().getSchema().getProperty("isSysOrg"))); } if (person.originalData().getType().toString().equals("NONSYS_ORGANIZATION")) { object.tuning().put("isSysOrg", TuningHelper.createPropertyValue(false, object.tuning().getSchema().getProperty("isSysOrg"))); } } } }