From ca420bd9c09b51a404ade3e0106257725df727be Mon Sep 17 00:00:00 2001 From: 田源 <lastanimals@163.com> Date: 星期三, 01 十一月 2023 11:32:28 +0800 Subject: [PATCH] 整合代码 --- Source/UBCS-WEB/src/components/FormTemplate/FormTemplate.vue | 236 ++++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 200 insertions(+), 36 deletions(-) diff --git a/Source/UBCS-WEB/src/components/FormTemplate/FormTemplate.vue b/Source/UBCS-WEB/src/components/FormTemplate/FormTemplate.vue index e516be0..3ff1350 100644 --- a/Source/UBCS-WEB/src/components/FormTemplate/FormTemplate.vue +++ b/Source/UBCS-WEB/src/components/FormTemplate/FormTemplate.vue @@ -26,12 +26,14 @@ </template> <template :slot="item.prop + ''" v-for="item in slotColumnList"> <vciWebRefer + :key="item.dataKey" :data-key="item.dataKey" v-if="item.type == 'refer'" :referConfig="item.referConfig || {}" :value="form[item.referConfig.field] || item.value" :text="form[item.referConfig.showField]" :disabled="item.disabled" :display="item.display" + :reloadData="item.referConfig.reloadData || false" @setReferValue="setReferValue" ></vciWebRefer> </template> @@ -60,6 +62,10 @@ type: String, default: "", }, + LoadingStatus:{ + type: String, + default : "code" + }, // 鍒楄〃鏁版嵁oid rowOid: { type: String, @@ -68,7 +74,7 @@ // 琛ㄥ崟绫诲瀷锛坅dd, edit, detail锛� type: { type: String, - default: "add", + default: "", }, // 鑷畾涔夎〃鍗曠被鍨� selfColumnType: { @@ -85,9 +91,19 @@ type: Number, default: 8, }, + TreeValue:{ + type: String, + default: "", + }, + eventList:{ + type:Array + } }, data() { return { + ValidataValue:false, + eventFlag:{}, + TreeValueForm:'', updateIndex: 0, form: {}, option: { @@ -117,6 +133,13 @@ mounted() { this.handleResize(); }, + updated() { + }, + created() { + if (this.LoadingStatus === 'code') { + this.loading = false; + } + }, computed: { localTrendsSpan() { if (this.trendsSpan) { @@ -126,11 +149,38 @@ 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) { - console.log(formItemList, "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 = []; @@ -171,12 +221,14 @@ trigger = "blur"; } let fieldMapKey='' - if( formItem.type == "refer"){ - if(!formItem.fieldMap){ - fieldMapKey=formItem.field+'Id' - } + if( formItem.type == "refer" && !formItem.fieldMap){ + fieldMapKey=formItem.field+'Id' + formItem.fieldMap={} + formItem.fieldMap[fieldMapKey]='id' + formItem.fieldMap[formItem.field+'id']='id' } let columnItem = { + dataKey:formItem.dataKey || formItem.field, label: formItem.text, labelslot: true, prop: this.$utilFunc.isValuableObj(formItem.referConfig) @@ -185,41 +237,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, - fieldMap:formItem.fieldMap || {fieldMapKey:'id'}, - placeholder: formItem.inputTip, - options: formItem.referConfig - } + title: formItem.text, + showField: formItem.showField || formItem.field, + field: formItem.field, + fieldMap:formItem.fieldMap || {}, + placeholder: formItem.inputTip, + options: formItem.referConfig + } : {}, span: formItem.span ? formItem.span : formItem.type === "textarea" - ? 24 - : this.localTrendsSpan, + ? 24 + : this.localTrendsSpan, rules: [ { required: formItem.required, - message: `璇�${message}${formItem.text}`, + message: `${message}${formItem.text}`, trigger, }, { @@ -242,7 +297,6 @@ } }); this.slotColumnList = slotColumnList; - console.log(column, "column"); this.$set(this.option, "column", column); this.$set(this.option, "group", group); this.updateIndex++; @@ -252,6 +306,122 @@ this.geDictData(dictKeys); this.getFormDetail(); + + }, + //淇敼绾ц仈椤� + changeChildItem(items,TreeValue) { + let column = this.option.column; + let group = this.option.group; + let that=this; + items.forEach((item) => { + let formItem = this.resetFormConfig(item); + if (formItem.field == "lcstatus") { + formItem.field = formItem.field + "_text"; + formItem.readOnly = true; + } + // 璁剧疆琛ㄥ崟鏍¢獙鐨勮鍒欙紝鏂囨湰 + let message = "璇烽�夋嫨"; + let trigger = "change"; + if (formItem.type === "text") { + message = "璇疯緭鍏�"; + trigger = "blur"; + } + let fieldMapKey = '' + if (formItem.type == "refer" && !formItem.fieldMap) { + fieldMapKey = formItem.field + 'Id' + formItem.fieldMap = {} + formItem.fieldMap[fieldMapKey] = 'id' + formItem.fieldMap[formItem.field + 'id'] = 'id' + } + let columnItem = { + label: formItem.text, + labelslot: true, + prop: this.$utilFunc.isValuableObj(formItem.referConfig) + ? formItem.showField || formItem.field + : formItem.field, + field: formItem.field, + type: this.columnType[formItem.type], + dicData: this.getDataList(formItem.type, formItem.data), + 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, + format: formItem.dateFormate, + keyAttr: formItem.keyAttr, + 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, + fieldMap: formItem.fieldMap || {}, + placeholder: formItem.inputTip, + options: formItem.referConfig + } + : {}, + span: formItem.span + ? formItem.span + : formItem.type === "textarea" + ? 24 + : this.localTrendsSpan, + rules: [ + { + required: formItem.required, + message: `${message}${formItem.text}`, + trigger, + }, + { + // 濡傛灉娌℃湁姝e垯鍒欏尮閰嶄换浣曞瓧绗� + pattern: formItem.verify ? formItem.verify : /[\s\S.]*/g, + message: formItem.tooltips, + trigger, + }, + ], + props: { + label: "value", + value: "key", + }, + }; + + if (group.length === 0) { + that.slotColumnList.forEach((colItem,index) => { + if (colItem.field == columnItem.field) { + that.slotColumnList[index] = columnItem; + column[index] = columnItem; + return; + } + }) + } else { + that.slotColumnList.forEach((colItem,index) => { + if (colItem.field == columnItem.field) { + that.slotColumnList[index] = columnItem; + return; + } + }) + group.forEach((groupItem,index) => { + groupItem.column.forEach((colItem,colIndex) => { + if (colItem.field == columnItem.field) { + group[index].column[colIndex] = columnItem; + return; + } + }) + }); + } + }); + that.$set(that.option, "column", column); + that.$set(that.option, "group", group); }, // 浣跨敤浼犲叆鐨勮〃鍗曟暟鎹厤缃� resetFormConfig(formItem) { @@ -343,6 +513,7 @@ if (valid) { done(); resolve(true); + this.ValidataValue=true; } else { resolve(false); } @@ -373,21 +544,24 @@ 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)]; + temp = _item['attributes'][mapField.subString("attribute.".length)] || _item['attributes']['data'][mapField.subString("attribute.".length)]; } else { - temp = _item['attributes'][mapField] || _item[mapField]; + 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)]); + mutiTemp.push(_item['attributes'][_itemField.subString("attribute.".length)] || _item['attributes']['data'][_itemField.subString("attribute.".length)]); } else { - mutiTemp.push(_item['attributes'][_itemField] || _item[_itemField]); + mutiTemp.push(_item['attributes'][_itemField] || _item['attributes']['data'][_itemField] || _item[_itemField]); } }); temp = mutiTemp.join(' '); @@ -399,19 +573,9 @@ this.form[key] = value.join(','); } } - this.$emit("getFormData", this.form); this.$emit("referConfigDataUpdate", data); + this.$emit("getFormData", this.form); } - }, - }, - watch: { - // 琛ㄥ崟鏁版嵁淇敼鍙嶉鍒扮埗缁勪欢 - form: { - deep: true, - immediate: true, - handler(newV) { - this.$emit("getFormData", newV); - }, }, }, }; -- Gitblit v1.9.3