ludc
2024-01-17 2ff8dd1f7d2f71944c25c9e116d12d9fb418ac0a
Source/UBCS-WEB/src/components/Master/MasterTree.vue
@@ -1,12 +1,17 @@
<template>
  <div class="app" style="display: flex;">
  <div class="app" style="position: relative;">
    <avue-tree ref="tree" v-model="CloneTreeAvueform" v-loading="loading" :data="Treedata" :defaultExpandAll="false"
               :option="Treeoption" style="width: fit-content;" @node-click="nodeClick">
      <template slot-scope="{ node }">
        <span v-html="node.label"></span>
        <el-tooltip :content="$createElement('div', { domProps: { innerHTML: node.label } })" class="item" effect="dark"
                    open-delay="350" placement="right-start">
          <span id="labelSize" v-html="node.label"></span>
        </el-tooltip>
      </template>
    </avue-tree>
    <div style="display: inline-block;"><el-link icon="el-icon-refresh" class="refresh-icon" @click="getTreeLists"></el-link></div>
    <div style="position: absolute; right: 3px; top: -1px;">
      <el-link class="refresh-icon" icon="el-icon-refresh" @click="getTreeLists"></el-link>
    </div>
  </div>
</template>
@@ -34,7 +39,7 @@
    return {
      TreeValue: '',
      idData: '',
      referTreeId:'',
      referTreeId: '',
      masterVrBtnList: [],
      tableHeadFindData: [],
      tableHeadDataFateher: [],
@@ -53,15 +58,15 @@
        defaultExpandAll: false,
        menu: false,
        lazy: true,
        // treeLoad:function (node,resolve){
        //   console.log(node)
        //   console.log(resolve)
        // }
        treeLoad: (node, resolve) =>{
        treeLoad: (node, resolve) => {
          if (node.data != false) {
            const parentId = (node.level === 0) ? 0 : node.data.oid;
            const parentBtmName = node.data.attributes.btmname;
            getTreeList({parentOid: parentId, parentBtmName: parentBtmName,'conditionMap[btmTypeId]': this.referTreeId }).then(res => {
            getTreeList({
              parentOid: parentId,
              parentBtmName: parentBtmName,
              'conditionMap[btmTypeId]': this.referTreeId
            }).then(res => {
              resolve(res.data.map(item => {
                return {
                  ...item,
@@ -96,18 +101,22 @@
    getTreeLists() {
      const index = this.$route.query.id.indexOf('@');
      const result = this.$route.query.id.substring(0, index);
      this.idData = result
      // console.log(this.$route)
      getTreeList({'conditionMap[id]': this.idData}).then(res => {
      this.idData = result;
      this.removeList();
      let conditionMaps = {};
      conditionMaps["conditionMap[id]"] = this.idData;
      conditionMaps["conditionMap[authType]"] = "data_auth";
      // 数据授权中是否具备查看权限
      conditionMaps["conditionMap[menuCode]"] = "data_view";
      getTreeList(conditionMaps).then(res => {
        if (res) {
          if (res.data.length === 0) {
            this.$message.error("主数据分类查询为空!");
          } else {
            this.Treedata = res.data;
            const [firstProperty] = res.data;
            this.ModifyProperties(this.Treedata, 'text', 'label');
            this.referTreeId=firstProperty.attributes.btmTypeId;
            this.referTreeId = firstProperty.attributes.btmTypeId;
            // console.log(this.referTreeId)
            this.codeClassifyOid = firstProperty.oid;
            this.coderuleoid = firstProperty.attributes.coderuleoid;
@@ -118,15 +127,19 @@
            });
            this.$emit("coderuleoid", this.coderuleoid)
            this.$emit('Treedata', this.Treedata)
            // console.log(this.Treedata)
          }
        }
      }).catch(res => {
        // console.log(res)
        this.$message.error(res)
      });
    },
    removeList() {
      this.$emit('tableHeadDataFateher', []);
      this.$emit('tableHeadFindData', []);
      this.$emit('tableHeadBttoms', []);
      this.$emit('tableDataArray', [])
      this.$emit('total', null)
    },
    //定义一个修改数据属性名的方法
    ModifyProperties(obj, oldName, newName) {
      for (let key in obj) {
@@ -141,12 +154,17 @@
    },
    //表格刷新
    TableRend() {
      this.loading = true;
      this.$emit('loading', this.loading)
      TableData({
        templateOid: this.templateOids,
        codeClassifyOid: this.nodeClickList.oid,
        page: this.currentPage,
        limit: this.pageSize,
      }).then(res => {
        // console.log('tab',res)
        this.loading = false;
        this.$emit('loading', this.loading)
        this.tableDataArray = res.data.data;
        this.$emit('tableDataArray', this.tableDataArray)
        this.$emit('total', res.data.total)
@@ -175,10 +193,11 @@
          List.forEach(item => {
            let columnItem = {
              label: item.title,
              prop: item.queryField,
              prop: item.field,
              // type: this.columnType[item.type],
              sortable: item.sort,
              width: item.minWidth
              width: item.minWidth,
              query: item.queryField
            };
            this.tableHeadFindData.push(Object.assign(item, columnItem))
          })
@@ -203,10 +222,10 @@
        this.tableHeadFindData = []
        await this.TableHeadRend(); // 先执行 TableHeadRend()
        this.TableRend(); // TableHeadRend() 方法完成后再执行 TableRend()
        this.$emit('nodeClick', this.templateOids)
        this.$emit('nodeClickTemplateOids', this.templateOids)
        this.$emit("codeClassifyOid", this.nodeClickList.oid)
        this.$emit("nodeClickList", this.nodeClickList)
      } catch (error) {
        // 处理错误
        this.$message.error(error)
      }
    }
@@ -217,7 +236,7 @@
<style lang="scss" scoped>
.app {
  overflow: auto;
  height: calc(100vh - 150px);
  height: calc(100vh - 145px);
}
.app::-webkit-scrollbar {
@@ -241,4 +260,8 @@
  margin-left: 6px;
  font-size: 18px;
}
#labelSize {
  font-size: 14px !important;
}
</style>