wangting
2023-09-22 8cc891b06558d9998723942aacd20ca3d894336e
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" :blur="valueChange" :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,
@@ -127,14 +129,15 @@
    },
    getTree() {
      //加载全部
      getTree(this.params, this.treeUrl).then(res => {
        res.data.map(item => {
          if (!item.attribute) {
            item.attribute = {
          if (!item.attributes) {
            item.attributes = {
              data: {}
            }
          } else {
            item.attribute.data = item.attribute.data || {}
            item.attributes.data = item.attributes.data || {}
          }
          return {
            ...item,
@@ -145,6 +148,7 @@
      })
    },
    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;
@@ -158,12 +162,12 @@
      }
      getLazyTree(this.params,this.treeUrl).then(res => {
        resolve(res.data.data.map(item => {
          if(!item.attribute){
            item.attribute={
          if(!item.attributes){
            item.attributes={
              data:{}
            }
          }else{
            item.attribute.data=item.attribute.data || {}
            item.attributes.data=item.attributes.data || {}
          }
          return {
            ...item,
@@ -178,17 +182,13 @@
      }
    },
    checked(checkedNode, checkedData) {
      this.checkedData=checkedData
    },
    valueChange(){
      if(this.isMuti){
        // this.setValue(this.checkedData)
      }
      this.setValue(checkedData)
    },
    setValue:function (checkedData){
      this.checkedData=checkedData
      var value = [];
      var text = [];
      const textSep =this.config.textSep;
      const textSep =this.config.textSep;debugger;
      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])