From 52ffefd06e59cbd56c1a919972866592379cfed2 Mon Sep 17 00:00:00 2001 From: xiejun <xj@2023> Date: 星期四, 21 九月 2023 11:27:11 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- Source/UBCS-WEB/src/components/FormTemplate/FormTemplate.vue | 166 ++++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 133 insertions(+), 33 deletions(-) diff --git a/Source/UBCS-WEB/src/components/FormTemplate/FormTemplate.vue b/Source/UBCS-WEB/src/components/FormTemplate/FormTemplate.vue index b72f827..3e341d5 100644 --- a/Source/UBCS-WEB/src/components/FormTemplate/FormTemplate.vue +++ b/Source/UBCS-WEB/src/components/FormTemplate/FormTemplate.vue @@ -26,6 +26,7 @@ </template> <template :slot="item.prop + ''" v-for="item in slotColumnList"> <vciWebRefer + :key="item.prop" :data-key="item.prop" v-if="item.type == 'refer'" :referConfig="item.referConfig || {}" :value="form[item.referConfig.field] || item.value" @@ -50,7 +51,7 @@ // 榛樿绂佺敤鍏冪礌 disabledProp: { type: Array, - default: () => ["id","lcstatus"], + default: () => ["id", "lcstatus"], }, templateOid: { type: String, @@ -80,9 +81,23 @@ type: Object, default: () => ({}), }, + // 涓�琛屾斁鍑犱釜琛ㄥ崟 + trendsSpan: { + type: Number, + default: 8, + }, + TreeValue:{ + type: String, + default: "", + }, + eventList:{ + type:Array + } }, data() { return { + eventFlag:{}, + TreeValueForm:'', updateIndex: 0, form: {}, option: { @@ -103,9 +118,6 @@ date: "date", refer: "refer", }, - // 鍋囨暟鎹� - testItems: [], - trendsSpan: 8, defaultValue: {}, // 琛ㄥ崟灞炴�� attributes: [], @@ -115,9 +127,50 @@ mounted() { this.handleResize(); }, + created() { + + }, + computed: { + localTrendsSpan() { + if (this.trendsSpan) { + return this.trendsSpan; + } else { + let windowWidth = document.body.clientWidth; + return 24 / Math.floor(windowWidth / 500); + } + }, + + }, + watch: { + // 琛ㄥ崟鏁版嵁淇敼鍙嶉鍒扮埗缁勪欢 + form: { + deep: true, + immediate: true, + handler(newV) { + this.$emit("getFormData", newV); + }, + }, + TreeValue:{ + handler(newval,oldval){ + if(newval){ + this.TreeValueForm=newval; + } + }, + deep:true, + immediate:true + } + }, methods: { // 娓叉煋琛ㄥ崟妯℃澘 - templateRender(formItemList) { + templateRender(formItemList,TreeValue) { + if (this.eventList) { + this.eventFlag= this.eventList.some(item => { + if (item.classifyInvokeEditFlag === 'true') { + this.eventObject = item; + return true; + } + }); + } // 鏃犻渶鍒嗙粍鏁版嵁 let column = []; let group = []; @@ -137,7 +190,8 @@ if ( formItem.type === "combox" && formItem.comboxKey && - (!Array.isArray(formItem.dicData) || formItem.dicData.length === 0) &&(!Array.isArray(formItem.data) || formItem.data.length === 0) + (!Array.isArray(formItem.dicData) || formItem.dicData.length === 0) && + (!Array.isArray(formItem.data) || formItem.data.length === 0) ) { dictKeys.push({ dictKey: formItem.comboxKey, field: formItem.field }); } @@ -145,9 +199,9 @@ if (this.disabledProp.includes(formItem.field)) { formItem.readOnly = true; } - if(formItem.field=='lcstatus'){ - formItem.field=formItem.field+'_text'; - formItem.readOnly=true; + if (formItem.field == "lcstatus") { + formItem.field = formItem.field + "_text"; + formItem.readOnly = true; } // 璁剧疆琛ㄥ崟鏍¢獙鐨勮鍒欙紝鏂囨湰 let message = "璇烽�夋嫨"; @@ -155,6 +209,12 @@ if (formItem.type === "text") { message = "璇疯緭鍏�"; trigger = "blur"; + } + let fieldMapKey='' + if( formItem.type == "refer"){ + if(!formItem.fieldMap){ + fieldMapKey=formItem.field+'Id' + } } let columnItem = { label: formItem.text, @@ -165,36 +225,44 @@ field: formItem.field, type: this.columnType[formItem.type], dicData: this.getDataList(formItem.type, formItem.data), - disabled: this.type === "detail" ? true : formItem.readOnly, + disabled: this.type === "detail" ? true : formItem.readOnly || (formItem.codeValueApplyStatus && formItem.codeValueApplyStatus == 2 ?true : false) , prepend: this.preOrSufFixShow("text", formItem.prefix), append: this.preOrSufFixShow("text", formItem.suffix), prefixIcon: this.preOrSufFixShow("icon", formItem.prefix), suffixIcon: this.preOrSufFixShow("icon", formItem.suffix), - valueFormat: formItem.dateFormate, + valueFormat:formItem.dateFormate, format: formItem.dateFormate, keyAttr: formItem.keyAttr, - value: formItem.defaultValue, + value: (formItem.dicData && formItem.dicData.length > 0 && formItem.secType == "codefixedsec" ? formItem.dicData[0].id : null) || + (formItem.secType == "codedatesec"?formItem.codeDateValue: null) || ( TreeValue&& formItem.secType == "codelevelsec" ? TreeValue : null) , placeholder: formItem.inputTip, comboxKey: formItem.comboxKey, tip: formItem.tooltips, + // hidden:formItem.secType && formItem.codeValueApplyStatus == 3 ? true : false, + // readonly:formItem.codeValueApplyStatus && formItem.codeValueApplyStatus == 2 ?true : false , display: !formItem.hidden, maxlength: formItem.maxlength, filterable: true, referConfig: formItem.type == "refer" ? { - title: formItem.text, - showField: formItem.showField || formItem.field, - field: formItem.field, - placeholder: formItem.inputTip, - options: formItem.referConfig, - } + title: formItem.text, + showField: formItem.showField || formItem.field, + field: formItem.field, + fieldMap:formItem.fieldMap || {fieldMapKey:'id'}, + placeholder: formItem.inputTip, + options: formItem.referConfig + } : {}, - span: formItem.span ? formItem.span : formItem.type === "textarea" ? 24 : this.trendsSpan, + span: formItem.span + ? formItem.span + : formItem.type === "textarea" + ? 24 + : this.localTrendsSpan, rules: [ { required: formItem.required, - message: `璇�${message}${formItem.text}`, + message: `${message}${formItem.text}`, trigger, }, { @@ -226,6 +294,8 @@ this.geDictData(dictKeys); this.getFormDetail(); + // console.log('selfColumnConfig',this.selfColumnConfig) + }, // 浣跨敤浼犲叆鐨勮〃鍗曟暟鎹厤缃� resetFormConfig(formItem) { @@ -260,9 +330,9 @@ }, // 鏍规嵁灞忓箷鍔ㄦ�侀厤缃〃鍗曞竷灞� handleResize() { - let windowWidth = document.body.clientWidth; - this.trendsSpan = 24 / Math.floor(windowWidth / 500); - this.updateIndex++; + // let windowWidth = document.body.clientWidth; + // this.trendsSpan = 24 / Math.floor(windowWidth / 500); + // this.updateIndex++; }, // 鍓嶅悗缂� preOrSufFixShow(type, val) { @@ -334,22 +404,52 @@ ); }, setReferValue(data) { + debugger; if (data.field) { this.form[data.field] = data.value || ""; this.form[data.showField] = data.text || ""; + if (data.fieldMap) { + //璇存槑闇�瑕佹槧灏� + for (let key in data.fieldMap) { + let mapFields = data.fieldMap[key].split(","); + let value = []; + data.rawData.forEach(_item => { + var temp; + if (!_item.attributes) { + _item.attributes = _item; + } + if (!_item.attributes.data) { + _item.attributes.data = {}; + } + if (mapFields.length == 1) { + var mapField = mapFields[0]; + if (mapField.indexOf("attribute.") > -1) { + temp = _item['attributes'][mapField.subString("attribute.".length)] || _item['attributes']['data'][mapField.subString("attribute.".length)]; + } else { + temp = _item['attributes'][mapField] ||_item['attributes']['data'][mapField] || _item[mapField]; + } + } else { + //鏈夊涓� + var mutiTemp = []; + layui.each(mapFields, function (_indexField, _itemField) { + if (_itemField.indexOf("attribute.") > -1) { + mutiTemp.push(_item['attributes'][_itemField.subString("attribute.".length)] || _item['attributes']['data'][_itemField.subString("attribute.".length)]); + } else { + mutiTemp.push(_item['attributes'][_itemField] || _item['attributes']['data'][_itemField] || _item[_itemField]); + } + }); + temp = mutiTemp.join(' '); + } + if (temp != null && temp != '') { + value.push(temp); + } + }) + this.form[key] = value.join(','); + } + } this.$emit("getFormData", this.form); this.$emit("referConfigDataUpdate", data); } - }, - }, - watch: { - // 琛ㄥ崟鏁版嵁淇敼鍙嶉鍒扮埗缁勪欢 - form: { - deep: true, - immediate: true, - handler(newV) { - this.$emit("getFormData", newV); - }, }, }, }; -- Gitblit v1.9.3