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

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

Ключ

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

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

  • Индекс
  • Адрес отправки - массив адресов, для дальнейшей возможности выбора 
  • ФИО получателяполучателя 
  • Телефон получателя - массив телефонов, для дальнейшей возможности выбора 

Дополнительно необходимо предусмотреть возможность подключения справочника к полям:

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

Статус
colourYellow
titleВ РАБОТЕ

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

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

Оглавление

панель
titleРезультат

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

Включить в схеме Correspondent признак обновления свойств схемы (recalc="true"), которую использует форма диалога.

Добавить временные поля, для создания списка адресов и телефонов

Блок кода
languagexml
titleСхема
<?xml version='1.0' encoding='UTF-8'?>
<schemas xmlns="http://www.intertrust.ru/schema/palette/tn-schema">
	<schema name="schemaCorrespondent"  recalc="true" >
		<!--...-->

	  	<string 	<!-- временное поле, для списка всех адресов корреспондента -->
	  	<string name="all_address" array="true" temporal="true"/>

	 	<!--  временное поле, для списка всех телефонов -->
    	<string name="all_phone" array="true" temporal="true"/>

		</schema>!--...-->
  </schema>
</schemas>


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

В форме CorrespondentDialog в поле "Корреспондент" включить признак "Участие в вычисление секции" (recalc = "true")

Блок кода
languagexml
titleФорма
<?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

Блок кода
languagexml
titleОбработчик событий
<?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>

Код

Блок кода
languagejs
titleОбработчик событий
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") {
		
		//Обнуление полей Получение tn-объекта
		object.tuning().getValues().put("Phone", null);
		var tuning = 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()// Карта AFInstance текушего объекта
		var values = tuning.getValues();
		
		// Схема текущего объекта
		var schema = tuning.getSchema();
		
		// Обнуление полей    
		values.put("Index", null); //Индекс   
		values.put("Address", null); //Адрес
		values.put("Recipient", null); //ФИО получателя
		values.put("Phone", null); //Телефон
		
		if (values.get('Correspondent') != null && values.get('Correspondent').getValue();  != null) { //значение Поле изКорреспондент поляне Корреспондент
пустое
			var emplAddrscorrespondent = new ArrayList();
			var emplPhones = new ArrayList();values.get('Correspondent').getValue(); // Значение из поля Корреспондент     
			
			if (correspondent.getAddress() != ""null) {

				emplAddrs.add(correspondent.getAddress()); //заполняем адресПолучение изtn-объекта бородыкорреспондента
				var    }
			
			if (correspondent.originalDataappTNObject = AFSession.get().getTypegetApplication(TunableObjectApplication.class);
				var correspondentObject == SOBeard.Type.NONSYS_ORGANIZATION) { appTNObject.getEntityByUNID(AFCMDomino.ormUnidToTNUnid(correspondent.getUNID()));
				if (correspondent.originalData().getParty().addressInfo().legal().getAddress()correspondentObject != ""null) {

					emplAddrs.add(person.originalData().getParty().addressInfo().legal().getAddress());
				}
			}

// Формирование списка адресов
					var emplAddrs = new ArrayList();

					// Почтовый/физический адрес
					if (!emplAddrscorrespondent.isEmptygetAddress() != "") {
				TuningHelper		emplAddrs.processPropertyadd(object.tuning().getValues(), "all_address", emplAddrs, object.tuning().getSchema().getProperty("all_address"correspondent.getAddress());
					}

					var// fio = new ArrayList();Юридический адрес
			fio.add(person.		if (correspondent.originalData().getFullNamegetType());
 == SOBeard.Type.NONSYS_ORGANIZATION) {
						var fioValue = new AFInstanceArrayImpl(object.tuningif (correspondent.originalData().getSchemagetParty(), fio);
			object.tuning.addressInfo().getValueslegal().putgetAddress() != "Recipient",) fioValue);
{
							var appTNObject = AFSession.getemplAddrs.add(correspondent.originalData().getApplicationgetParty(TunableObjectApplication.class);
			var objectBeard = appTNObject.getEntityByUNID(AFCMDomino.ormUnidToTNUnid(person.getUNID()));
			var phoneH = objectBeard.tuning().getValues().get("phoneHouse");
			var phoneW = objectBeard.addressInfo().legal().getAddress()); //заполняем адрес для несистемных организаций
						}
					}

					// Формирование списка телефонов
					var emplPhones = new ArrayList();

					// Карта объектов AFInstance корреспондента
					var correspondentValue = correspondentObject.tuning().getValues().get("phoneWork");
					var phoneMphoneH = objectBeard.tuning().getValues()correspondentValue.get("phoneMobilphoneHouse");
					var phonephoneW = objectBeard.tuning().getValues().correspondentValue.get("phonephoneWork");
			emplPhones.add		var phoneM = correspondentValue.get("phoneMobil");
					var phone = correspondentValue.get("phone");

					emplPhones.add(phoneH);
					emplPhones.add(phoneW);
					emplPhones.add(phoneM);

					if (phone != null && phone.getValues() != null) {
						emplPhones.addAll(phone.getValues());
					}

			var phoneValue;
		// Вычисление телефона по умолчанию
					var phoneValue;
					if (phoneM != null) {
						phoneValue = TunableObjectHelper.getAFInstanceValue(objectBeard.tuning().getValues().get("phoneMobil")phoneM);
					} else if (phoneW != null) {
						phoneValue = TunableObjectHelper.getAFInstanceValue(objectBeard.tuning().getValues().get("phoneWork"));
	phoneW);
					} else if (phoneH != null) {
						phoneValue = TunableObjectHelper.getAFInstanceValue(objectBeard.tuning().getValues().get("phoneHouse"))phoneM);
					} else if (phone != null && objectBeard.tuning().getValues().get("phone").getValues() != null) {
						phoneValue = TunableObjectHelper.getAFInstanceValue(objectBeard.tuning()phone.getValues().get("phone").getValues().get(0));
0));
					}

					if (phoneValue != null) {
// Получатель
					var recipientValue = new ArrayList();
					TuningHelperrecipientValue.processPropertyadd(objectcorrespondent.tuningoriginalData().getValuesgetFullName(), "Phone", phoneValue, object.tuning);
					if (correspondent.originalData().getType().getSchematoString().getPropertyequals("PhonePRIVATE_HUMAN")); { // В качестве корреспондента выбрано 'Частное лицо'
			}
			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(correspondentObject.get("sendIndex")); // Индекс
						var countryValue = TunableObjectHelper.getAFInstanceValue(correspondentObject.get("country")); // Страна
						var regionValue = TunableObjectHelper.getAFInstanceValue(correspondentObject.get("region")); // Регион
						var indexValuedistrictValue = TunableObjectHelper.getAFInstanceValue(objectBeard.tuning().getValues().correspondentObject.get("sendIndexdistrict")); // Населенный пункт
					//	var phoneValuecityValue = TunableObjectHelper.getAFInstanceValue(objectBeard.tuning().getValues()correspondentObject.get("phoneHousecity")); // Город
						var countryValuestreetValue = TunableObjectHelper.getAFInstanceValue(objectBeard.tuning().getValues()correspondentObject.get("countrystreet")); // Улица
						var regionValuehouseValue = TunableObjectHelper.getAFInstanceValue(objectBeard.tuning().getValues().correspondentObject.get("regionhouse")); // Дом
						var districtValuestructureValue = TunableObjectHelper.getAFInstanceValue(objectBeard.tuning().getValues()correspondentObject.get("districtstructure")); // Корпус
						var cityValuehousingValue = TunableObjectHelper.getAFInstanceValue(objectBeard.tuning().getValues().correspondentObject.get("cityhousing")); // Строение
						var streetValueroomValue = TunableObjectHelper.getAFInstanceValue(objectBeard.tuning().getValues().correspondentObject.get("streetroom")); // Комната

					var houseValue = TunableObjectHelper.getAFInstanceValue(objectBeard.tuning().getValues().get("house"));
	//Формирование адреса по умолчанию
						var structureValueaddressValue = TunableObjectHelper.getAFInstanceValue(objectBeardStringUtils.tuninghasLength().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"));
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 : "");

					} else if (person.originalData().getType().toString().equals("SYS_ORGANIZATION")) { // В качестве корреспондента выбрана 'Системная организация'

						var addressValue = correspondent.originalData().getParty().getOrganizationDescription().addressInfo().post().getAddress(); //Адрес
						var indexValue = correspondent.originalData().getParty().getOrganizationDescription().addressInfo().post().getZipCode(); //Индекс	

					} else { // В качестве корреспондента выбрана 'Не системная организация'

						var indexValue = TunableObjectHelper.getAFInstanceValue(objectBeard.tuning().getValues()correspondentObject.get("jSendIndex")); //Индекс
						var countryValue = TunableObjectHelper.getAFInstanceValue(objectBeard.tuning().getValues().correspondentObject.get("jcountryName")); //Страна
						var regionValue = TunableObjectHelper.getAFInstanceValue(objectBeard.tuning().getValues()correspondentObject.get("region")); //Регион
						var districtValue = TunableObjectHelper.getAFInstanceValue(objectBeard.tuning().getValues().correspondentObject.get("jDistrict")); //Населенный пункт
						var cityValue = TunableObjectHelper.getAFInstanceValue(objectBeard.tuning().getValues()correspondentObject.get("jCity")); //Город
						var streetValue = TunableObjectHelper.getAFInstanceValue(objectBeard.tuning().getValues().correspondentObject.get("jStreet")); //Улица
						var houseValue = TunableObjectHelper.getAFInstanceValue(objectBeard.tuning().getValues()correspondentObject.get("jHouse")); //Дом
						var structureValue = TunableObjectHelper.getAFInstanceValue(objectBeard.tuning().getValues().correspondentObject.get("jStructure")); //Корпус
						var housingValue = TunableObjectHelper.getAFInstanceValue(objectBeardcorrespondentObject.tuningget("jHousing").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 : "");
 housingValue : "");
					}

					// Запись в поле 'Список адресов'
					if (!emplAddrs.isEmpty()) {
						TuningHelperTunableObjectHelper.processPropertyputAFInstanceValue(object.tuning().getValues(), "Index", indexValue, object.tuning().getSchema().getProperty("Index"));
all_address", emplAddrs);
					}

					// Запись в поле 'Список телефонов'
					if (!emplPhones.isEmpty()) {
						TuningHelperTunableObjectHelper.processPropertyputAFInstanceValue(object.tuning().getValues(), "SendAddressall_phone", addressValue, object.tuning().getSchema().getProperty("SendAddress")emplPhones);
					}

			}
			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")));//Запись остальных полей
					TunableObjectHelper.putAFInstanceValue(tuning, "Recipient", recipientValue); //Получатель
					TunableObjectHelper.putAFInstanceValue(tuning, "Index", indexValue); //Индекс
					TunableObjectHelper.putAFInstanceValue(tuning, "Address", addressValue); //Адрес
					TunableObjectHelper.putAFInstanceValue(tuning, "Phone", phoneValue); //Телефон
				}
			}
		}
	}
}