田源
2023-06-09 f7e33d69713a5145d19fde5792b422826bc14107
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<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"
             @node-click=" nodeClick"
  ></avue-tree>
</template>
 
<script>
import {getTreeList} from "@/api/MasterData/master";
import {mapMutations, mapState} from "vuex";
import {TableData,MasterTable} from "@/api/GetItem";
 
export default {
  name: "MasterTree",
  props:{
    pageSize:{
      type:String,
      default:"10"
    },
    currentPage:{
      type:String,
      default:"1"
    },
    templateOid:{
      type:String,
      default:''
    },
  },
  data(){
    return{
      tableHeadDataFateher:[],
      templateOids:"",
      tableDataArray:[],
      codeClassifyOid:"",
      coderuleoid:"",
      CloneTreeAvueform:{},
      loading:false,
      Treedata:[],
      nodeClickList: "",
      Treeoption: {
        addBtn: false,
        editBtn: false,
        delBtn: false,
        defaultExpandAll: false,
        menu: false,
        lazy: true,
        // treeLoad:function (node,resolve){
        //   console.log(node)
        //   console.log(resolve)
        // }
        treeLoad:function (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}).then(res=>{
              resolve(res.data.map(item=>{
                return {
                  ...item,
                  label:item.text
                }
              }))
            })
          }
        },
      },
    }
  },
  created() {
    this.getTreeList()
 
  },
  computed:{
   },
  methods:{
    //获取数据
    getTreeList(){
      getTreeList({'conditionMap[id]': 'wupin'}).then(res=>{
        this.Treedata=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.$emit("coderuleoid", this.coderuleoid )
        this.TableHeadRends()
      }).catch(res=>{
        console.log(res)
      })
    },
 
    //定义一个修改数据属性名的方法
    ModifyProperties(obj, oldName, newName) {
      for (let key in obj) {
        if (key === oldName) {
          obj[newName] = obj[key];
          delete obj[key];
        }
        if (typeof obj[key] === 'object') {
          this.ModifyProperties(obj[key], oldName, newName);
        }
      }
    },
    //表格刷新
    TableRend(){
      TableData({
        templateOid: this.templateOids,
        codeClassifyOid: this.nodeClickList.oid,
        page: this.currentPage,
        limit: this.pageSize,
      }).then(res => {
        // this.page.total = res.data.total;
        // this.data = res.data.data;
        this.tableDataArray=res.data.data;
        this.$emit('tableDataArray',this.tableDataArray)
        this.$emit('total',res.data.total)
      })
    },
    //表格头部
    TableHeadRend(){
      MasterTable({
        codeClassifyOid:this.nodeClickList.oid,
        functionId: 5,
      }).then(res=>{
        this.tableHeadDataFateher=res.data;
        this.templateOids=res.data.tableDefineVO.oid
        this.$emit("tableHeadDataFateher",this.tableHeadDataFateher)
        console.log("123",res)
      })
    },
    TableHeadRends(){
      MasterTable({
        codeClassifyOid:this.codeClassifyOid,
        functionId: 5,
      }).then(res=>{
        this.tableHeadDataFateher=res.data;
        this.templateOids=res.data.tableDefineVO.oid
        this.$emit("tableHeadDataFateher",this.tableHeadDataFateher)
        console.log("123",res)
      })
    },
    //树点击事件
    nodeClick(data){
      this.nodeClickList = data;
       this.TableHeadRend()
      this.TableRend()
      console.log('code',this.nodeClickList.oid)
      console.log('teoid',this.templateOids)
      console.log()
    }
  }
}
</script>
 
<style scoped>
 
</style>