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/refer/vciWebReferTree.vue | 68 ++++++++++++++++++++++++++------- 1 files changed, 53 insertions(+), 15 deletions(-) diff --git a/Source/UBCS-WEB/src/components/refer/vciWebReferTree.vue b/Source/UBCS-WEB/src/components/refer/vciWebReferTree.vue index 118ea81..fa3ea8d 100644 --- a/Source/UBCS-WEB/src/components/refer/vciWebReferTree.vue +++ b/Source/UBCS-WEB/src/components/refer/vciWebReferTree.vue @@ -1,5 +1,5 @@ <template> - <avue-input-tree ref="referTree" :props="props" :lazy="lazy" :tree-load="treeLoad" :node-click="nodeClick" :checked="checked" :leaf-only="referConfig.onlyLeaf" :multiple="isMuti" v-model="value" :placeholder="title" :dic="treeData"></avue-input-tree> + <avue-input-tree ref="referTree" :props="props" :disabled="disabled" :lazy="lazy" :tree-load="treeLoad" :node-click="nodeClick" :checked="checked" :blur="valueChange" :leaf-only="referConfig.onlyLeaf" :multiple="isMuti" v-model="value" :placeholder="title" :dic="treeData"></avue-input-tree> </template> <script> @@ -8,7 +8,7 @@ export default { name: "vciWebReferTree", - props:["referConfig","value","text","title"], + props:["referConfig","value","text","title","disabled"], data() { return { options: this.referConfig.options, @@ -25,7 +25,7 @@ }, treeUrl: this.referConfig.options.url || '/api/ubcs-code/mdmEngineController/defaultReferTree', treeData: [], - selectionList: [], + checkedData:[], currentNode:{}, params: {}, loadType: {'all': 'all', 'node': 'node'}, @@ -34,8 +34,6 @@ }, created() { this.getParams(); - console.log('referConfig:') - console.log(this.referConfig) }, mounted() { if(!this.lazy){ @@ -79,9 +77,15 @@ queryParams['loadType'] = this.options.loadType; queryParams['multipleSelect'] = this.isMuti; queryParams['isMuti'] = queryParams['multipleSelect']; - if (this.options.remoteSort && this.options.initSort) { + if (this.options.initSort) { queryParams['order'] = this.options.initSort.type;//鏂规硶 queryParams['sort'] = this.options.initSort.field;//瀛楁 + } + if(this.options.sortField){ + queryParams['sort'] = this.options.sortField;//瀛楁 + } + if(this.options.sortType){ + queryParams['order'] = this.options.sortType;//鏂规硶 } if (this.options.rootParams) { for (var key in this.options.rootParams) { @@ -122,10 +126,23 @@ this.params=queryParams; }, - getTree(){ - getTree(this.params,this.treeUrl).then(res => { - this.treeData=res.data + getTree() { + getTree(this.params, this.treeUrl).then(res => { + res.data.map(item => { + if (!item.attribute) { + item.attribute = { + data: {} + } + } else { + item.attribute.data = item.attribute.data || {} + } + return { + ...item, + leaf: !item.hasChildren + } }) + this.treeData = res.data + }) }, treeLoad: function (treeNode, resolve) { const parentOid = (treeNode.level === 0) ? 0 : treeNode.data.oid; @@ -141,6 +158,13 @@ } getLazyTree(this.params,this.treeUrl).then(res => { resolve(res.data.data.map(item => { + if(!item.attribute){ + item.attribute={ + data:{} + } + }else{ + item.attribute.data=item.attribute.data || {} + } return { ...item, leaf: !item.hasChildren @@ -152,9 +176,14 @@ if(!this.isMuti) { this.setValue({checkedNodes:[data]}) } - }, + }, checked(checkedNode, checkedData) { - this.setValue(checkedData) + this.checkedData=checkedData + }, + valueChange(){ + if(this.isMuti){ + // this.setValue(this.checkedData) + } }, setValue:function (checkedData){ var value = []; @@ -162,27 +191,36 @@ const textSep =this.config.textSep; for(var j =0;j<checkedData.checkedNodes.length;j++){ const item=checkedData.checkedNodes[j]; - var v=this.config.valueField.indexOf("attribute.")>=0?item.attributes[this.config.valueField.replace("attribute.","")]:(item.attributes[this.config.valueField] || item[this.config.valueField]) + var v=this.config.valueField.indexOf("attribute.")>=0?(item.attributes[this.config.valueField.replace("attribute.","")] || item.attributes.data[this.config.valueField.replace("attribute.","")]):(item.attributes[this.config.valueField] || item[this.config.valueField] || item.attributes.data[this.config.valueField]) value.push(v); var tempRaw = []; var textFieldArray = this.config.textField.split(","); for (var i = 0; i < textFieldArray.length; i++) {//鏄剧ず鐨勫瓧娈靛彲鑳芥湁澶氫釜 if (!validatenull(textFieldArray[i])) { - var t=textFieldArray[i].indexOf("attribute.")>=0?item.attributes[textFieldArray[i].replace("attribute.","")]:(item.attributes[textFieldArray[i]] || item[textFieldArray[i]]) + var t=textFieldArray[i].indexOf("attribute.")>=0?(item.attributes[textFieldArray[i].replace("attribute.","")] ||item.attributes.data[textFieldArray[i].replace("attribute.","")]):(item.attributes[textFieldArray[i]] || item[textFieldArray[i]] || item.attributes.data[textFieldArray[i]]) tempRaw.push(t); } } text.push(tempRaw.join(textSep)); } + let mapFields =this.referConfig.fieldMap || {}; + try { + if(!validatenull(this.options.mapFields)){ + mapFields =Object.assign(this.referConfig.fieldMap,JSON.parse(this.options.mapFields)) ; + } + }catch (e) { + + } this.value = value.join(','); - this.text = text.join(',') + this.text = text.join(','); this.$emit("setValue", { field: this.referConfig.field, showField: this.referConfig.showField, value: this.value, text: this.text || '', isTreeMuti:this.isMuti, - rawData: checkedData.checkedNodes + rawData: checkedData.checkedNodes, + fieldMap:mapFields }); } }, -- Gitblit v1.9.3