田源
2023-07-28 0bd98f8ac6eb537e618ad00c8bc3f3b40e46ab69
Source/UBCS-WEB/src/components/Master/MasterTree.vue
@@ -1,7 +1,7 @@
<template>
  <avue-tree ref="tree" v-model="CloneTreeAvueform" v-loading="loading" :data="Treedata" :defaultExpandAll="false"
             :option="Treeoption"
             style="height: 80.5vh;padding-top: 5px;padding-bottom: 30px"
             style="height: calc(100vh - 150px);"
             @node-click=" nodeClick"
  ></avue-tree>
</template>
@@ -9,7 +9,7 @@
<script>
import {getTreeList} from "@/api/MasterData/master";
import {mapMutations, mapState} from "vuex";
import {TableData} from "@/api/GetItem";
import {TableData,MasterTable} from "@/api/GetItem";
export default {
  name: "MasterTree",
@@ -29,6 +29,11 @@
  },
  data(){
    return{
      idData:'',
      masterVrBtnList:[],
      tableHeadFindData:[],
      tableHeadDataFateher:[],
      templateOids:"",
      tableDataArray:[],
      codeClassifyOid:"",
      coderuleoid:"",
@@ -65,23 +70,26 @@
    }
  },
  created() {
    this.getTreeList()
    this.getTreeLists()
  },
  computed:{
   },
  methods:{
    //获取数据
    getTreeList(){
      getTreeList({'conditionMap[id]': 'wupin'}).then(res=>{
        this.Treedata=res.data
    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.Treedata=res.data;
        const [firstProperty] = res.data;
        this.ModifyProperties(this.Treedata, 'text', 'label');
        this.codeClassifyOid=res.data[0].oid;
        this.coderuleoid=res.data[0].attributes.coderuleoid;
        this.$emit("codeClassifyOid", this.codeClassifyOid )
        this.codeClassifyOid=firstProperty.oid;
        this.coderuleoid=firstProperty.attributes.coderuleoid;
        this.$emit("coderuleoid", this.coderuleoid )
      }).catch(res=>{
        console.log(res)
        this.$message.error(res)
      })
    },
@@ -97,23 +105,71 @@
        }
      }
    },
    //树点击事件
    nodeClick(data){
      this.nodeClickList = data;
      console.log(this.currentPage,this.pageSize)
    //表格刷新
    TableRend(){
      TableData({
        templateOid: this.templateOid,
        codeClassifyOid: this.codeClassifyOid,
        page: this.pageSize,
        limit:this.currentPage,
        templateOid: this.templateOids,
        codeClassifyOid: this.nodeClickList.oid,
        page: this.currentPage,
        limit: this.pageSize,
      }).then(res => {
        console.log(res)
        // this.page.total = res.data.total;
        // this.data = res.data.data;
        this.tableDataArray=res.data.data;
        this.$emit('tableDataArray',this.tableDataArray)
        console.log(this.tableDataArray)
        this.$emit('total',res.data.total)
      })
    },
    //表格头部
    TableHeadRend() {
      const index = this.$route.query.id.indexOf('@');
      const result = this.$route.query.id.substring(0, index);
      return new Promise((resolve, reject) => {
        MasterTable({
          codeClassifyOid: this.nodeClickList.oid,
          functionId:result,
        }).then(res => {
          const flagsToDeleteBtn = ["CODEIMPORTHISTORY", "CODEEXPORT", "CODEQUERY","batchApplyCode"];
          //不同节点显示不同按钮
          if (!res.data.leaf) {
            this.masterVrBtnList = res.data.buttons.filter(obj => flagsToDeleteBtn.includes(obj.uniqueFlag));
          } else {
            this.masterVrBtnList = res.data.buttons
          }
          this.tableHeadDataFateher = res.data;
          this.templateOids = res.data.tableDefineVO.oid;
          const [List] = res.data.tableDefineVO.cols;
          List.forEach(item => {
            let columnItem = {
              label: item.title,
              prop: item.field,
              // type: this.columnType[item.type],
              sortable: item.sort,
              width: item.minWidth
            };
            this.tableHeadFindData.push(Object.assign(item, columnItem))
          })
          this.$emit('tableHeadDataFateher', this.tableHeadDataFateher);
          this.$emit('tableHeadFindData', this.tableHeadFindData);
          this.$emit('tableHeadBttoms', this.masterVrBtnList);
          resolve();
        }).catch(err => {
          reject(err)
        })
      })
    },
    //树点击事件
    async nodeClick(data) {
      try {
        this.nodeClickList = data;
        this.tableHeadDataFateher=[]
        this.tableHeadFindData=[]
        await this.TableHeadRend(); // 先执行 TableHeadRend()
        this.TableRend(); // TableHeadRend() 方法完成后再执行 TableRend()
        this.$emit('nodeClick',this.templateOids)
        this.$emit("codeClassifyOid", this.nodeClickList.oid )
      } catch (error) {
        // 处理错误
        this.$message.error(error)
      }
    }
  }
}