Дерево страниц

Сравнение версий

Ключ

  • Эта строка добавлена.
  • Эта строка удалена.
  • Изменено форматирование.
Информация
iconfalse
titleПостановка задачи
recalc

При выборе организации в диалоге в поле Корреспондент необходимо автоматически заполнить поля:

  • Индекс
  • Адрес отправки
  • ФИО получателя
  • Телефон получателя
Подсказка
iconfalse
Инструмент: Палитра XML
Свойства страницы
Статус

Статус
colourGreyYellow
titleЧЕРНОВИКВ РАБОТЕ

РазделФорма
Комментарий

панель
titleРеализация

Оглавление

панель
title<Сопроводительная информация>
ПримечаниеЕсли есть какие-то нюансы по реализации, указать. Если нет, то удалить данный пункт
Результат
Image Added

Доработать схему

Инициирование формы на обновление


Доработать форму

Включение поля как инициатор


Доработать обработчик событий

Блок кода
languagejs
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("all_address", null);
		object.tuning().getValues().put("all_phone", null);
		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 person = object.tuning().getValues().get('Correspondent').getValue();
			var emplAddrs = new ArrayList();
			var emplPhones = new ArrayList();
			if (person.getAddress() != "") {
				emplAddrs.add(person.getAddress());
			}
			if (person.originalData().getType() == SOBeard.Type.NONSYS_ORGANIZATION) {
				if (person.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")));
			}
		}
	}
}