From df18b23b4569828d6be32fb64c80492241e1fc46 Mon Sep 17 00:00:00 2001 From: ludc Date: 星期一, 16 十月 2023 20:31:43 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- Source/UBCS-WEB/src/components/refer/vciWebReferTree.vue | 63 ++++++++++++++++++++++++------- 1 files changed, 49 insertions(+), 14 deletions(-) diff --git a/Source/UBCS-WEB/src/components/refer/vciWebReferTree.vue b/Source/UBCS-WEB/src/components/refer/vciWebReferTree.vue index 3000eba..f1a8c0d 100644 --- a/Source/UBCS-WEB/src/components/refer/vciWebReferTree.vue +++ b/Source/UBCS-WEB/src/components/refer/vciWebReferTree.vue @@ -1,5 +1,6 @@ <template> - <avue-input-tree ref="referTree" :props="props" :disabled="disabled" :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" + :leaf-only="referConfig.onlyLeaf" :multiple="isMuti" v-model="value" :placeholder="title" :dic="treeData"></avue-input-tree> </template> <script> @@ -11,6 +12,7 @@ props:["referConfig","value","text","title","disabled"], data() { return { + visible: false, options: this.referConfig.options, lazy: this.referConfig.options.loadType == 'node', isMuti:("true" == this.referConfig.options.isMuti || this.referConfig.options.isMuti == true || this.referConfig.options.muti == true) ? true : false, @@ -25,7 +27,7 @@ }, treeUrl: this.referConfig.options.url || '/api/ubcs-code/mdmEngineController/defaultReferTree', treeData: [], - selectionList: [], + checkedData:[], currentNode:{}, params: {}, loadType: {'all': 'all', 'node': 'node'}, @@ -34,8 +36,6 @@ }, created() { this.getParams(); - // console.log('referConfig:') - // console.log(this.referConfig) }, mounted() { if(!this.lazy){ @@ -79,9 +79,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) { @@ -119,16 +125,30 @@ queryParams['replaceMap["' + key + '"]'] = this.options.replaceParams[key];//鏂扮殑鏂瑰紡 } } - queryParams['parentValue']='\\IN(SELECT oid from PL_CODE_CLASSIFY where id =\'hesuanfenlei\')' 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.attributes) { + item.attributes = { + data: {} + } + } else { + item.attributes.data = item.attributes.data || {} + } + return { + ...item, + leaf: !item.hasChildren + } }) + this.treeData = res.data + }) }, treeLoad: function (treeNode, resolve) { + //閫愮骇鍔犺浇 const parentOid = (treeNode.level === 0) ? 0 : treeNode.data.oid; this.params.parentOid=parentOid.indexOf('@vcitreesep@') > -1 ? parentOid.split('@vcitreesep@')[1] : parentOid; this.params.parentValue=this.params.parentOid; @@ -142,6 +162,13 @@ } getLazyTree(this.params,this.treeUrl).then(res => { resolve(res.data.data.map(item => { + if(!item.attributes){ + item.attributes={ + data:{} + } + }else{ + item.attributes.data=item.attributes.data || {} + } return { ...item, leaf: !item.hasChildren @@ -153,11 +180,12 @@ if(!this.isMuti) { this.setValue({checkedNodes:[data]}) } - }, + }, checked(checkedNode, checkedData) { this.setValue(checkedData) }, setValue:function (checkedData){ + this.checkedData=checkedData var value = []; var text = []; const textSep =this.config.textSep; @@ -175,8 +203,16 @@ } 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, @@ -184,11 +220,10 @@ text: this.text || '', isTreeMuti:this.isMuti, rawData: checkedData.checkedNodes, - fieldMap:this.referConfig.fieldMap + fieldMap:mapFields }); } - }, - watch:{} + } } </script> -- Gitblit v1.9.3