Parcourir la Source

菜单授权 角色授权页面

wangkang3 4 ans auparavant
Parent
commit
dd4467b5c3

+ 26 - 0
ebc-middle-platform/src/modules/authorization/menu-authorization.scss

@ -0,0 +1,26 @@
1
.authorization-container{
2
  display:flex;
3
  justify-content: center;
4
  margin:20px;
5
  .left-container{
6
    width:400px;
7
    height: 700px;
8
    border: 1px solid rgba(0, 0, 0, 0.09);
9
    margin-right:20px;
10
    .title{
11
      padding:0 20px;
12
      line-height: 48px;
13
      border-bottom: 1px solid rgba(0, 0, 0, 0.09);
14
    }
15
    .table-content{
16
      flex-direction: column;
17
      justify-content: space-between;
18
      height: 100%;
19
      padding:0 20px
20
    }
21
  }
22
  .transfer-list{
23
    width: 400px;
24
    height: 700px;
25
  }
26
}

+ 187 - 37
ebc-middle-platform/src/modules/authorization/menu-authorization.vue

@ -1,45 +1,44 @@
1 1
<template>
2
  <div class="authorization-container" style="display:flex;margin:20px">
3
    <div style="width:400px;border: 1px solid rgba(0, 0, 0, 0.09);margin-right:20px">
4
      <div>
2
  <div class="authorization-container">
3
    <div class="left-container">
4
      <div class="title">
5 5
        <div>角色列表</div>
6 6
      </div>
7
      <div style="flex-direction: column;
8
    justify-content: space-between;
9
    height: 100%;padding:0 20px">
7
      <div class="table-content">
10 8
        <t-table :data="table.data" highlight-current-row @current-change="handleCurrentChange">
11 9
          <t-table-column prop="name" label="角色名称"></t-table-column>
12 10
          <t-table-column prop="number" label="角色编码"></t-table-column>
13 11
        </t-table>
14
        <div>
15
          <t-pager :total="table.pager.total" :current.sync="table.pager.currentPage"
16
                   :page-size.sync="table.pager.size"
17
                   class="px-24 pt-16 float-right"
18
                   show-elevator show-sizer
19
                   @on-size-change="onSizeChange"
20
                   @on-change="onPagerChange">
21
          </t-pager>
22
        </div>
12
        <t-pager :total="table.pager.total" :current.sync="table.pager.currentPage"
13
                 :page-size.sync="table.pager.size"
14
                 class="px-24 pt-16 float-right"
15
                 show-elevator
16
                 @on-size-change="onSizeChange"
17
                 @on-change="onPagerChange">
18
        </t-pager>
23 19
      </div>
24 20
    </div>
25
    <div>
21
    <div class="transfer-container">
26 22
      <t-transfer
27 23
        ref="transfer"
28 24
        :data="dataTable"
29 25
        :selected-keys="targetKeysTable"
30
        :operations="['向左移动','向右移动']"
31
        filterable
26
        :operations="['← 绑定','解绑 →']"
27
        :titles="['已关联菜单','可关联菜单']"
28
        @change="changeTransfer"
32 29
      >
33 30
        <div slot="listBodyLeft" slot-scope="tableLeft">
34
          <t-tree :multiple="true"
31
          <t-tree ref="leftTree" :multiple="true"
35 32
                  :with-ancestors="true"
36
                  :node-data="tableLeft"
33
                  :with-descendants="true"
34
                  :node-data="tableLeft.data" @select="changeTree"
37 35
          ></t-tree>
38 36
        </div>
39 37
        <div slot="listBodyRight" slot-scope="tableRight">
40 38
          <t-tree :multiple="true"
41 39
                  :with-ancestors="true"
42
                  :node-data="tableRight.data"
40
                  :with-descendants="true"
41
                  :node-data="tableRight.data" @select="changeTree"
43 42
          ></t-tree>
44 43
        </div>
45 44
      </t-transfer>
@ -47,6 +46,7 @@
47 46
  </div>
48 47
</template>
49 48
<script>
49
import './menu-authorization.scss'
50 50
export default {
51 51
  data() {
52 52
    return {
@ -71,38 +71,188 @@ export default {
71 71
          total: 0
72 72
        }
73 73
      },
74
      dataTable: this.getMockData(),
75
      targetKeysTable: []
74
      dataTable: [
75
        {
76
          key: '1',
77
          label: '地图监控',
78
          title: '地图监控',
79
          id: '1'
80
        },
81
        {
82
          key: '2',
83
          label: '智能报警',
84
          title: '智能报警',
85
          value: 'node_2',
86
          id: '2'
87
        },
88
        {
89
          key: '3',
90
          label: '统计报表',
91
          title: '统计报表',
92
          value: 'node_5',
93
          id: '3'
94
        },
95
        {
96
          key: '4',
97
          label: '轨迹分析',
98
          title: '轨迹分析',
99
          value: 'node_3',
100
          id: '4',
101
          pid: '3'
102
        },
103
        {
104
          key: '5',
105
          label: '作业考勤',
106
          title: '作业考勤',
107
          value: 'node_4',
108
          id: '5',
109
          pid: '3'
110
        },
111
        {
112
          key: '6',
113
          label: '系统管理',
114
          title: '系统管理',
115
          id: '6'
116
        },
117
        {
118
          key: '7',
119
          label: '终端管理',
120
          title: '终端管理',
121
          id: '7',
122
          pid: '6'
123
        },
124
        {
125
          key: '8',
126
          label: '地图标记',
127
          title: '地图标记',
128
          pid: '3',
129
          id: '8'
130
        }
131
      ],
132
      targetKeysTable: [],
133
      copyData: [],
134
      removeData: []
76 135
    }
77 136
  },
78 137
  methods: {
79 138
    handleCurrentChange(val) {
80 139
      this.currentRow = val
81 140
    },
82
    getMockData: function() {
83
      let mockData = []
84
      for (let i = 0; i <= 20; i++) {
85
        mockData.push({
86
          key: i.toString(),
87
          label: '内容' + i,
88
          description: '描述' + i,
89
          disabled: Math.random() * 3 < 1
141
    changeTransfer(targetKeys, direction, moveKeys) {
142
      console.log('change', targetKeys, direction, moveKeys)
143
      if (this.copyData.length > 0) {
144
        // this.dataTable = this.dataTable.concat(this.copyData)
145
        // this.targetKeysTable.push(this.copyData.id)
146
        this.copyData.forEach(element => {
147
          this.dataTable.splice(element.index, 0, element)
148
        })
149
150
        this.copyData = []
151
      }
152
      if (this.removeData.length > 0) {
153
        console.log(this.removeData)
154
        this.removeData.forEach(element => {
155
          this.dataTable.splice(element.index, 1)
90 156
        })
157
        this.removeData = []
91 158
      }
92
      return mockData
159
      console.log(this.dataTable)
93 160
    },
94
    $_onCheckboxChange(selection) {
95
      let keysArray = []
96
      selection.forEach(item => {
97
        keysArray.push(item.key)
161
    changeTree(ids) {
162
      console.log(ids)
163
      var transferId = []
164
      ids.forEach(id => {
165
        console.log(this.isContained(ids, this.$refs.leftTree.getNodeStateById(id).children))
166
        if (this.$refs.leftTree.getNodeStateById(id).children && this.isContained(ids, this.$refs.leftTree.getNodeStateById(id).children)) {
167
          // 修改子节点的pid
168
          var includeFlag = true
169
          this.$refs.leftTree.getNodeStateById(id).children.forEach(elementChild => {
170
            // 不含在选中的ids
171
            if (ids.indexOf(elementChild) === -1) {
172
              includeFlag = false
173
              this.dataTable.forEach(elementChildTable => {
174
                if (elementChildTable.id === elementChild) {
175
                  if (elementChildTable.pid.indexOf('copy') === -1) {
176
                    elementChildTable.pid = 'copy' + elementChildTable.pid
177
                  }
178
                }
179
              })
180
            } else {
181
              this.dataTable.forEach(elementChildTable => {
182
                if (elementChildTable.id === elementChild) {
183
                  if (elementChildTable.pid.indexOf('copy') !== -1) {
184
                    elementChildTable.pid = elementChildTable.pid.slice(4)
185
                  }
186
                }
187
              })
188
            }
189
          })
190
          if (id.indexOf('copy') === -1) {
191
            var flag = false
192
            this.copyData.forEach(element => {
193
              if (element.id === 'copy' + id) {
194
                flag = true
195
              }
196
            })
197
            if (!flag) {
198
              var dataIndex = 0
199
              this.dataTable.forEach((e, index) => {
200
                if (e.id === id) {
201
                  dataIndex = index
202
                }
203
              })
204
              this.copyData.push({
205
                key: 'copy' + id,
206
                label: this.$refs.leftTree.getNodeStateById(id).label,
207
                title: this.$refs.leftTree.getNodeStateById(id).title,
208
                id: 'copy' + id,
209
                index: dataIndex
210
              })
211
            }
212
          } else {
213
            if (!includeFlag) {
214
              var includeIndex = 0
215
              this.dataTable.forEach((e, index) => {
216
                if (e.id === id) {
217
                  includeIndex = index
218
                }
219
              })
220
              this.removeData.push({
221
                key: id,
222
                label: this.$refs.leftTree.getNodeStateById(id).label,
223
                title: this.$refs.leftTree.getNodeStateById(id).title,
224
                id: id,
225
                index: includeIndex
226
              })
227
            }
228
          }
229
        }
230
        if (id.indexOf('copy') === -1) {
231
          transferId.push(id)
232
        } else {
233
          console.log(this.$refs.leftTree.getNodeStateById(id).children)
234
          if (!this.$refs.leftTree.getNodeStateById(id).children) {
235
            console.log(123213, id)
236
          }
237
        }
98 238
      })
99
      this.targetKeysTable = keysArray
239
      console.log(transferId)
240
      this.targetKeysTable = transferId
100 241
    },
101 242
    onPagerChange(page) {
102 243
103 244
    },
104 245
    onSizeChange(number) {
105 246
247
    },
248
    isContained (a, b) {
249
      if (!(a instanceof Array) || !(b instanceof Array)) return false
250
      // if (a.length < b.length) return false
251
      var aStr = a.toString()
252
      for (var i = 0, len = b.length; i < len; i++) {
253
        if (aStr.indexOf(b[i]) !== -1) return true
254
      }
255
      return false
106 256
    }
107 257
  }
108 258
}

+ 159 - 0
ebc-middle-platform/src/modules/authorization/role-authorization.vue

@ -0,0 +1,159 @@
1
<template>
2
  <div class="authorization-container">
3
    <div class="left-container">
4
      <div class="title">
5
        <div>用户列表</div>
6
      </div>
7
      <div class="table-content">
8
        <t-table :data="table.data" highlight-current-row @current-change="handleCurrentChange">
9
          <t-table-column prop="name" label="姓名"></t-table-column>
10
          <t-table-column prop="number" label="员工编号"></t-table-column>
11
        </t-table>
12
        <t-pager :total="table.pager.total" :current.sync="table.pager.currentPage"
13
                 :page-size.sync="table.pager.size"
14
                 class="px-24 pt-16 float-right"
15
                 show-elevator
16
                 @on-size-change="onSizeChange"
17
                 @on-change="onPagerChange">
18
        </t-pager>
19
      </div>
20
    </div>
21
    <div class="transfer-container">
22
      <t-transfer
23
        ref="transfer"
24
        :data="dataTable"
25
        :selected-keys="targetKeysTable"
26
        :operations="['← 绑定','解绑 →']"
27
        :titles="['已关联角色','可关联角色']"
28
        @change="changeTransfer"
29
      >
30
        <div slot="listBodyLeft" slot-scope="tableLeft">
31
          <t-table :data="tableLeft.data" size="sm" @selection-change="changeTable">
32
            <t-table-column type="selection" width="50"></t-table-column>
33
            <t-table-column prop="label" width="70" label="角色名称"></t-table-column>
34
            <t-table-column prop="description" width="70" label="角色编码"></t-table-column>
35
            <div slot="empty"></div>
36
          </t-table>
37
        </div>
38
        <div slot="listBodyRight" slot-scope="tableRight">
39
          <t-table :data="tableRight.data" size="sm" @selection-change="changeTable">
40
            <t-table-column type="selection" width="50"></t-table-column>
41
            <t-table-column prop="label" width="70" label="角色名称"></t-table-column>
42
            <t-table-column prop="description" width="70" label="角色编码"></t-table-column>
43
            <div slot="empty"></div>
44
          </t-table>
45
        </div>
46
      </t-transfer>
47
    </div>
48
  </div>
49
</template>
50
<script>
51
import './menu-authorization.scss'
52
export default {
53
  data() {
54
    return {
55
      table: {
56
        data: [
57
          {
58
            name: '张三',
59
            number: '108373'
60
          },
61
          {
62
            name: '张三',
63
            number: '108373'
64
          },
65
          {
66
            name: '张三',
67
            number: '108373'
68
          }
69
        ],
70
        pager: {
71
          currentPage: 1,
72
          size: 10,
73
          total: 0
74
        }
75
      },
76
      dataTable: [
77
        {
78
          key: '1',
79
          label: '超级管理员',
80
          description: 'superadmin'
81
        },
82
        {
83
          key: '2',
84
          label: '管理员1',
85
          description: 'admin1'
86
        },
87
        {
88
          key: '3',
89
          label: '管理员2',
90
          description: 'admin2'
91
        },
92
        {
93
          key: '4',
94
          label: '管理员3',
95
          description: 'admin3'
96
        },
97
        {
98
          key: '5',
99
          label: '运维人员1',
100
          description: 'operator1'
101
        },
102
        {
103
          key: '6',
104
          label: '运维人员2',
105
          description: 'operator2'
106
        },
107
        {
108
          key: '7',
109
          label: '检修人员',
110
          description: 'maintainer'
111
        },
112
        {
113
          key: '8',
114
          label: '救援人员1',
115
          description: 'rescuer1'
116
        },
117
        {
118
          key: '9',
119
          label: '救援人员2',
120
          description: 'rescuer2'
121
        }
122
      ],
123
      targetKeysTable: [],
124
      copyData: []
125
    }
126
  },
127
  methods: {
128
    handleCurrentChange(val) {
129
      this.currentRow = val
130
    },
131
    changeTransfer(targetKeys, direction, moveKeys) {
132
      console.log(targetKeys, direction, moveKeys)
133
    },
134
    changeTable(elements) {
135
      var ids = []
136
      elements.forEach(element => {
137
        ids.push(element.key)
138
      })
139
      console.log(ids)
140
      this.targetKeysTable = ids
141
    },
142
    onPagerChange(page) {
143
144
    },
145
    onSizeChange(number) {
146
147
    },
148
    isContained (a, b) {
149
      if (!(a instanceof Array) || !(b instanceof Array)) return false
150
      if (a.length < b.length) return false
151
      var aStr = a.toString()
152
      for (var i = 0, len = b.length; i < len; i++) {
153
        if (aStr.indexOf(b[i]) == -1) return false
154
      }
155
      return true
156
    }
157
  }
158
}
159
</script>

+ 1 - 1
ebc-middle-platform/static/conf/defaultConfig.js

@ -11,7 +11,7 @@
11 11
const APP_DEFAULT_CONFIG = {
12 12
  primaryColor: '#147BD1', // primary color of ant design
13 13
  navTheme: 'dark', // theme for nav menu
14
  layout: 'sidemenu',
14
  layout: 'topmenu',
15 15
  sidebarOpen: true,
16 16
  fixedHeader: false,
17 17
  scrollHideHeader: false,