From 9b4433fddf5b401edb0aace8a404ac733b122702 Mon Sep 17 00:00:00 2001
From: 田源 <tianyuan@vci-tech.com>
Date: 星期四, 03 四月 2025 14:35:02 +0800
Subject: [PATCH] 添加非密字段显示

---
 Source/UBCS-WEB/src/components/refer/vciWebReferTree.vue |  258 ++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 213 insertions(+), 45 deletions(-)

diff --git a/Source/UBCS-WEB/src/components/refer/vciWebReferTree.vue b/Source/UBCS-WEB/src/components/refer/vciWebReferTree.vue
index 1a93438..6e1cbeb 100644
--- a/Source/UBCS-WEB/src/components/refer/vciWebReferTree.vue
+++ b/Source/UBCS-WEB/src/components/refer/vciWebReferTree.vue
@@ -1,70 +1,238 @@
 <template>
-  <avue-input-tree :props="props" :lazy="lazy" :multiple="isMuti" v-model="value" :placeholder="placeholder" :dic="treeData"></avue-input-tree>
+  <avue-input-tree ref="referTree"
+                   v-model="value"
+                   :checked="checked"
+                   :dic="treeData"
+                   :disabled="disabled"
+                   :lazy="lazy"
+                   :leaf-only="referConfig.onlyLeaf"
+                   :multiple="isMuti"
+                   :node-click="nodeClick"
+                   :placeholder="title"
+                   :props="props"
+                   :tree-load="treeLoad"></avue-input-tree>
 </template>
 
 <script>
-import {getTree,getLazyTree} from "@/api/refer/tree";
-import {getDeptLazyTree} from "@/api/system/dept";
+import {getTree, getLazyTree} from "@/api/refer/tree";
+import {validatenull} from "@/util/validate";
 
 export default {
   name: "vciWebReferTree",
-  props:["options","value"],
+  props: ["referConfig", "value", "text", "title", "disabled"],
   data() {
     return {
-      lazy:this.options.loadType == 'node',
-      isMuti:true,//options.muti,
-      placeholder:'璇烽�夋嫨鍐呭',
+      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,
       props: {
-        value:this.options.valueField,
-        label:this.options.textField
-        //value:"value",
-        //label:"title"
+        value: 'oid',
+        label: "name"
       },
-      treeData:[{
-        title:'閫夐」1',
-        value:0,
-        children:[{
-          title:'閫夐」3',
-          value:2
-        },{
-          title:'閫夐」4',
-          value:3
-        }]
-      },{
-        title:'閫夐」2',
-        value:1
-      }]
-    };
+      config: {
+        valueField: this.referConfig.valueField || this.referConfig.options.valueField || 'oid',
+        textField: this.referConfig.textField || this.referConfig.options.textField || "name",
+        textSep: this.referConfig.textSep || ' '
+      },
+      treeUrl: this.referConfig.options.url || '/api/ubcs-code/mdmEngineController/defaultReferTree',
+      treeData: [],
+      checkedData: [],
+      currentNode: {},
+      params: {},
+      loadType: {'all': 'all', 'node': 'node'},
+      copyParam: ['btmType', 'lnType', 'toBtmType', 'textField', 'valueField', 'parentFieldName', 'parentValue', 'sort', 'order', 'isDirection', 'whereSql', 'isMuti', 'queryScheme', 'isQueryAllColumn', 'queryColumn', 'split', 'loadType', 'onlyLeaf', 'onlyLeafText', 'parentUsedField']
+    }
   },
   created() {
-
+    this.getParams();
   },
   mounted() {
-    this.getTree();
+    if (!this.lazy) {
+      if (this.options.data) {//濡傛灉鏄浐瀹氭暟鎹殑鎯呭喌涓�
+        this.treeData = this.options.data
+      } else {
+        this.getTree()
+      }
+    }
   },
+  computed: {},
   methods: {
-    getTree(){
-      getTree({parentId:0},this.options.url).then(res => {
-          this.treeData=res.data
+    getParams: function () {
+      var queryParams = {};
+      if (this.options.extraParams) {
+        queryParams = this.options.extraParams;
+      }
+      for (var i = 0; i < this.copyParam.length; i++) {
+        if (this.copyParam[i] == "btmType") {
+          queryParams[this.copyParam[i]] = this.options['referBo'] || this.options['referType'];
+        } else if (this.copyParam[i] in this.options) {
+          queryParams[this.copyParam[i]] = this.options[this.copyParam[i]];
+        }
+      }
+      queryParams['referBo'] = this.options['referBo'] || this.options['referType'];
+      queryParams['referType'] = queryParams['referBo']
+      queryParams['selectAllLevel'] = (this.options.loadType == this.loadType.all ? true : false);//true鏃跺悗鍙颁細鎶ラ敊
 
-          console.log(this.treeData)
-        })
+      queryParams.muti = this.isMuti;
+      if (queryParams.isQueryAllColumn == "true") {
+        queryParams.isQueryAllColumn = true;
+      }
+      if (this.options.useFormKey && this.options.formValues) {
+        //浣跨敤琛ㄥ崟涓婄殑瀛楁鏉ヨ繃婊�
+        queryParams['conditionMap["' + (this.options.paramForFormKey ? this.options.paramForFormKey : this.options.useFormKey) + '"]'] = this.options.formValues[this.options.useFormKey];
+      }
+      if (!this.options.loadType) {
+        this.options.loadType = this.loadType.node;
+      }
+      queryParams['queryAllLevel'] = this.options.loadType == this.loadType.node ? false : true;//榛樿閫愮骇灞曞紑
+      queryParams['loadType'] = this.options.loadType;
+      queryParams['multipleSelect'] = this.isMuti;
+      queryParams['isMuti'] = queryParams['multipleSelect'];
+      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) {
+          queryParams[key] = this.options.rootParams[key];
+        }
+      }
+      if (this.options.conditionParams) {
+        //璇存槑鏄墿灞曞睘鎬�
+        for (var key in this.options.conditionParams) {
+          queryParams['conditionMap["' + key + '"]'] = this.options.conditionParams[key];//鏂扮殑鏂瑰紡
+        }
+      }
+      if (this.options.where) {
+        for (var key in this.options.where) {
+          queryParams['conditionMap["' + key + '"]'] = this.options.where[key];//鏂�
+        }
+      }
+      if (this.options.treeExtandParams) {
+        //璇存槑鏄墿灞曞睘鎬�
+        for (var key in this.options.treeExtandParams) {
+          queryParams['extandParamsMap["' + key + '"]'] = this.options.treeExtandParams[key];//鏂扮殑鏂瑰紡
+        }
+      }
+      if (this.options.sourceDataParams) {
+        //璇存槑鏄墿灞曞睘鎬�
+        for (var key in this.options.sourceDataParams) {
+          if (key && key.constructor === Object) return;
+          queryParams['sourceData["' + key + '"]'] = this.options.sourceDataParams[key];//鏂扮殑鏂瑰紡
+        }
+      }
+      if (this.options.replaceParams) {
+        //璇存槑鏄墿灞曞睘鎬�
+        for (var key in this.options.replaceParams) {
+          if (key && key.constructor === Object) return;
+          queryParams['replaceMap["' + key + '"]'] = this.options.replaceParams[key];//鏂扮殑鏂瑰紡
+        }
+      }
+      this.params = queryParams;
+
     },
-    getLazyTree(){
-      getLazyTree({parentId:0},this.options.url).then(res => {
-        this.treeData=res.data.data
-
-        console.log(this.treeData)
+    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 (tree,treeNode, resolve) {
-      debugger;
-      const parentId = (treeNode.level === 0) ? 0 : treeNode.data.id;
-      /*getDeptLazyTree({parentId:parentId}).then(res => {
-        resolve(res.data.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;
+      this.params.parentBtmName = treeNode.data.attributes.btmName || treeNode.data.attributes.btmname;
+      this.params.parentBtmType = this.params.parentBtmName;
 
+      if (this.options.rootParams && treeNode.level !== 0) {
+        for (var key in this.options.rootParams) {
+          delete this.params[key]
+        }
+      }
+      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
+          }
+        }))
+      });
+    },
+    nodeClick(data, node, nodeComp) {
+      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;
+      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.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.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.$emit("setValue", {
+        field: this.referConfig.field,
+        showField: this.referConfig.showField,
+        value: this.value,
+        text: this.text || '',
+        isTreeMuti: this.isMuti,
+        rawData: checkedData.checkedNodes,
+        fieldMap: mapFields
+      });
+    }
   }
 }
 </script>

--
Gitblit v1.9.3