luoyb
2021-03-03 8435ea9da0a454abc0db7f8a5402720abd680f4e
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
<template>
  <div>
    <el-input v-model="filterText" placeholder="输入关键字进行过滤" />
    <el-tree
      ref="tree"
      :data="deptTree"
      :check-strictly="true"
      show-checkbox
      accordion
      node-key="id"
      highlight-current
      default-expand-all
      :filter-node-method="filterNode"
      @node-click="nodeClick"
    />
    <el-button type="primary" @click="sureChoose">确定</el-button>
    <el-button type="danger" @click="cancleChoose">取消</el-button>
  </div>
</template>
<script>
export default {
  data() {
    return {
      filterText: '',
      headerHeight: '70px',
      advancedQueryShow: false,
      deptTree: [],
      dept: this.initDept()
    }
  },
  watch: {
    filterText(val) {
      this.$refs.tree.filter(val)
    }
  },
  mounted() {
    this.initDeptTree()
  },
  methods: {
    initDept() {
      return {
        deptId: '',
        deptName: '',
        parentId: null,
        orderNum: 0
      }
    },
    initDeptTree() {
      this.$get('system/dept').then((r) => {
        this.deptTree = r.data.data.rows
      })
    },
    filterNode(value, data) {
      if (!value) return true
      return data.label.indexOf(value) !== -1
    },
    nodeClick(data) {
      this.dept.parentId = data.parentId
      if (this.dept.parentId === '0') {
        this.dept.parentId = null
      }
      this.dept.orderNum = data.orderNum
      this.dept.deptName = data.label
      this.dept.deptId = data.id
    },
    sureChoose() {
      this.$emit('selectedDept', this.$refs.tree.getCheckedNodes())
    },
    cancleChoose() {
      this.$emit('cancleChooseDept')
    }
  }
}
</script>
<style lang="scss">
  .el-aside {
    padding: 20px;
    background: #f3f5f8;
    height: 600px;
 
    .el-tree {
      height: 100%;
    }
  }
 
  body {
    height: 600px;
  }
 
  #searchTable {
    margin-top: 10px;
    border-collapse: collapse;
    width: 100%;
  }
 
  #searchTable td,
  #searchTable th {
    border: 1px solid #cad9ea;
    color: #666;
    height: 30px;
  }
 
  #ygxq table {
    border-collapse: collapse;
    margin: 0 auto;
    text-align: center;
    width: 100%;
    margin-top: 20px;
  }
 
  #ygxq table td,
  #ygxq table th {
    border: 1px solid #DDDCDC;
    color: #666;
    height: 30px;
  }
 
  #ygxq table thead th {
    background-color: #CCE8EB;
    width: 100px;
  }
 
  #ygxq table tr:nth-child(odd) {
    background: #fff;
  }
 
  #ygxq table tr:nth-child(even) {
    background: #F5FAFA;
  }
 
  .tdTitle {
    font-size: 14px;
    font-weight: 700;
    text-align: left;
  }
 
  .link_button {
    color: #169BD5;
  }
 
  .del_button {
    color: #D9001B;
  }
</style>