jinlin
2024-01-15 1a7af6fff5185bb257c16b0445140c93263a3331
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
<template>
  <zt-dialog ref="dialog" title="权限内用户" :hasConfirm="false" append-to-body>
    <div>
      <zt-table-wraper ref="examineObj" :page-size="10" query-url="/sys/role/roleUsers" v-slot="{ table }">
        <el-form :inline="true" :model="queryForm" @keyup.enter.native="table.query()">
              <zt-button type="add"  @click="AddOrUpdate()"/>
        </el-form>
          <el-table v-loading="table.dataLoading" :data="table.dataList" border
                      @selection-change="table.selectionChangeHandle" @sort-change="table.sortChangeHandle">
          <el-table-column prop="username" label="用户姓名" width="200"/>
          <el-table-column prop="realName" label="真实姓名" width="200"/>
          <el-table-column prop="mobile" label="手机号" width="200"/>
          <el-table-column prop="deptName" label="部门"  />
          <zt-table-column-handle :table="table" :has-edit="false" :has-delete="false" :has-view="false" width="200">
            <template v-slot="{ row }">
              <zt-table-button @click="del(row)">移除</zt-table-button>
            </template>
          </zt-table-column-handle>
        </el-table>
        <add-or-update ref="addOrUpdate" @refreshDataList="table.query" :roleID="queryForm.roleId"/>
      </zt-table-wraper>
    </div>
  </zt-dialog>
</template>
 
<script>
  import AddOrUpdate from './role-user-deit'
 
  export default {
    props: {
      isDisplay: {
        type: Boolean,
        default: true
      }
    },
    data() {
      return {
        queryForm: {
          roleId: '',
          userId: ''
        }
      }
    },
    methods: {
      async init(roleId) {
        this.queryForm.roleId = roleId
        if (this.$refs.examineObj) {
          this.$refs.examineObj.query()
        }
      },
      async AddOrUpdate() {
        this.$refs.addOrUpdate.$refs['dialog'].init(this.queryForm.roleId)
      },
      async del(row) {
        this.queryForm.userId = row.id
        let res = await this.$http.post('/sys/role/deleteRoleUsers/', this.queryForm)
        if (res.success) {
          await this.$tip.success()
          this.$refs.examineObj.query()
          this.$refs.dialog.close()
          this.$emit('refreshDataList')
        }
      }
    },
    components: {
      AddOrUpdate
    }
  }
</script>