董国庆
19 小时以前 013c63b6a07231bb4456106e31715b0982167abd
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
<template>
  <Card>
    <div class="header-title">{{ form.roleName }}</div>
    <div class="header-remark">备注:{{ form.remark }}</div>
    <el-tabs v-model="activeName">
      <el-tab-pane label="操作权限" name="first">
        <div class="header">
          <div class="w20">模块名称</div>
          <div class="sconed">
            <div class="subpage">
              <div class="title">页面名称</div>
              <div class="btns">权限</div>
            </div>
          </div>
        </div>
        <div v-for="item in menu" :key="item.menuId">
          <div class="row">
            <div class="w20">
              <el-checkbox disabled :checked="item.selected">
                {{ item.menuName }}
              </el-checkbox>
            </div>
            <div class="sconed">
              <div class="subpage"
                v-if="(item.children.length > 0 && item.children[0].children.length > 0) || item.children[0].children.menuType != 'F'">
                <div v-for="item1 in item.children" :key="item1.menuId" class="two">
                  <div class="left">
                    <el-checkbox disabled :checked="item1.selected">
                      {{ item1.menuName }}
                    </el-checkbox>
                  </div>
 
                  <div class="right">
                    <div v-for="item2 in item1.children" :key="item2.menuId">
                      <el-checkbox disabled :checked="item2.selected">
                        {{ item2.menuName }}
                      </el-checkbox>
                    </div>
                  </div>
                </div>
              </div>
              <div class="subpage" v-else>
                <div class="two">
                  <!-- <div class="left">
                    </div> -->
                  <div class="right">
                    <div v-for="item1 in item.children" :key="item1.menuId">
                      <el-checkbox disabled :checked="item1.selected">
                        {{ item1.menuName }}
                      </el-checkbox>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div v-if="menu.length == 0" :style="{ height: height + 'px' }">
          <div class="no-data">暂无数据</div>
        </div>
      </el-tab-pane>
      <el-tab-pane label="人员列表" name="second">
 
        <el-form :inline="true" class="demo-form-inline">
          <div style="display: flex;justify-content: space-between;">
            <el-form-item label="人员搜索">
              <el-input v-model="nickNameOrPhone" placeholder="请输入姓名/联系电话"></el-input>
            </el-form-item>
            <el-form-item label="登陆状态">
              <el-select v-model="status" placeholder="请选择">
                <el-option
                  v-for="item in [{ label: '全部', value: '' }, { label: '启用', value: 0 }, { label: '禁用', value: 1 }]"
                  :key="item.value" :label="item.label" :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item>
              <el-button @click="reset">重置</el-button>
              <el-button type="primary" @click="onSubmit" style="margin-left: 10px;">查询</el-button>
            </el-form-item>
          </div>
        </el-form>
 
        <Table :data="data" :total="pagination.total" :queryForm="pagination" @currentChange="handleCurrentChange"
          @sizeChange="handleSizeChange">
          <el-table-column label="序号" type="index" width="50">
          </el-table-column>
          <el-table-column prop="nickName" label="姓名"></el-table-column>
          <el-table-column prop="phonenumber" label="联系电话">
          </el-table-column>
          <el-table-column prop="roleName" label="角色">
          </el-table-column>
          <el-table-column prop="userName" label="登陆账号">
          </el-table-column>
          <el-table-column prop="remark" label="备注">
          </el-table-column>
          <el-table-column prop="status" label="登录状态">
            <template slot-scope="{row}">
              <div class="status_class">
                <div :class="row.status == 0 ? 'green' : 'red'"></div>
                <div>{{ row.status == 0 ? '启用' : '停用' }}</div>
                <div v-if="row.status == 1" style="cursor: pointer;" @click="dialogVisibleView = true, rowView = row">
                  <i class="el-icon-warning"></i>
                </div>
              </div>
            </template>
          </el-table-column>
          <el-table-column prop="createTime" label="创建时间"></el-table-column>
        </Table>
      </el-tab-pane>
    </el-tabs>
    <ViewData v-if="dialogVisibleView" :row="rowView" :dialogVisible="dialogVisibleView"
      @close="dialogVisibleView = false, rowView = {}" />
  </Card>
</template>
 
<script>
import { getRoleInfo, roleInfoFromUserId, getUserList, getDeptList } from './service.js'
import ViewData from '../user/components/view-data'
export default {
  name: 'DetailRole',
  components: {
    ViewData
  },
  props: {},
  data() {
    return {
      form: {},//表单
      activeName: 'first',//当前选中的tab
      menu: [],//菜单
      data: [],//列表数据
      nickNameOrPhone: '',//人员搜索
      deptId: [],//部门
      deptList: [],//部门列表
      status: '',//状态
      pagination: {
        total: 10,//总条数
        pageNum: 1,//当前页
        pageSize: 10,//每页条数
      },
      rowView: {},//查看
      dialogVisibleView: false,//查看
    };
  },
  computed: {
    height() {
      return this.$baseTableHeight()
    },
  },
  watch: {},
  created() {
    roleInfoFromUserId({ userId: 1 }).then(res => {
      getRoleInfo({ roleId: this.$route.query.roleId }).then(resp => {
        this.form = {
          roleName: resp.roleName,
          remark: resp.remark,
        }
        this.menu = this.setSelectedIds(res, resp.menus);
 
      })
    })
    this.getListData()
    // getDeptList().then((res) => {
    //   this.deptList = res.data.data
    // })
  },
  mounted() { },
  methods: {
    async getListData() {
      let obj = {
        ...this.pagination,
        nickNameOrPhone: this.nickNameOrPhone,
        status: this.status,
        roleIds: [this.$route.query.roleId]
      }
      this.listLoading = true
      getUserList(obj).then(res => {
        this.data = res.records
        this.pagination.total = res.total
      })
 
    },
    setSelectedIds(arr, selectKeyList) {
      function traverse(item) {
        item.selected = selectKeyList.includes(item.menuId);
        if (item.children && item.children.length > 0) {
          item.children.forEach(traverse);
        }
      }
      arr.forEach(traverse);
      return arr;
    },
    reset() {
      this.nickNameOrPhone = ''
      this.deptId = []
      this.status = ''
      this.pagination.pageNum = 1
      this.getListData()
    },
    onSubmit() {
      this.pagination.pageNum = 1
      this.getListData()
    },
 
    handleCurrentChange(e) {
      this.pagination.pageNum = e;
      this.getListData()
    },
    handleSizeChange(e) {
      this.pagination.pageSize = e
      this.getListData()
    },
  },
};
</script>
<style lang="less" scoped>
.el-checkbox__inner {
  background-color: #009688;
  border-color: #009688;
}
 
.header-title {
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 15px;
}
 
.header-remark {
  font-size: 16px;
  color: rgba(0, 0, 0, 0.65);
  margin-bottom: 30px;
}
 
.row,
.header {
  display: flex;
  align-items: center;
  border: 1px solid #e8e8e8;
 
  .w20 {
    width: 15%;
    padding: 8px 20px;
  }
 
  .sconed {
    flex: 1;
 
    .subpage {
      .title {
        border: 1px solid #e8e8e8;
        border-top: none;
        border-bottom: none;
      }
 
      .two {
        display: flex;
        align-items: center;
        border: 1px solid #e8e8e8;
        border-top: none;
        border-right: none;
 
        .left {
          width: 200px;
          padding: 13px 20px;
          border-right: 1px solid #e8e8e8;
        }
 
        .right {
          display: flex;
          flex: 1;
 
          div {
            padding: 13px 0 13px 20px;
          }
        }
      }
 
      .two:last-child {
        border-bottom: none;
      }
 
      .btns {
        display: flex;
        align-items: center;
        padding: 0 20px;
      }
    }
  }
}
 
.header {
  border-radius: 16px 16px 0 0;
  background-color: #FAFAFA;
  color: #909399;
  font-weight: 500;
 
  .subpage {
    display: flex;
  }
 
  .title {
    width: 200px;
    padding: 8px 20px;
  }
}
 
.status_class {
  display: flex;
  align-items: center;
 
  div:nth-child(1) {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    margin-right: 5px;
  }
 
  div:nth-child(2) {
    margin-right: 8px;
  }
}
 
.no-data {
  height: 100%;
  background-color: #fff;
  border-radius: 0 0 6px 6px;
  border-left: 1px solid #e8e8e8;
  border-right: 1px solid #e8e8e8;
  border-bottom: 1px solid #e8e8e8;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #909399;
  font-size: 14px;
}
 
/* 当复选框禁用时覆盖默认样式 */
 
::v-deep .el-checkbox__input.is-disabled.is-checked .el-checkbox__inner {
  background-color: #409eff;
  border-color: #409eff;
}
 
::v-deep .el-checkbox.is-disabled .el-checkbox__inner::after {
  border-color: #fff;
}
</style>