fei
2025-11-22 749f897a11e711199c6b1677accf2f6e46895315
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
<template>
  <div class="app-container">
     <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
      <el-form-item label="用户名称" prop="userName">
        <el-input
          v-model="queryParams.userName"
          placeholder="请输入用户名称"
          clearable
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="手机号码" prop="phonenumber">
        <el-input
          v-model="queryParams.phonenumber"
          placeholder="请输入手机号码"
          clearable
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
 
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          v-if="vws"
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="openSelectUser"
          v-hasPermi="['system:role:add']"
        >给案卷分配录入员</el-button>
      </el-col>
<!--      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-circle-close"
          size="mini"
          :disabled="multiple"
          @click="cancelAuthUserAll"
          v-hasPermi="['system:role:remove']"
        >批量取消授权</el-button>
      </el-col> -->
    <!--  <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-close"
          size="mini"
          @click="handleClose"
        >关闭</el-button>
      </el-col> -->
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>
 
    <el-table v-loading="loading" :data="userList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="用户名称" prop="sysUser.userName" :show-overflow-tooltip="true" />
      <el-table-column label="用户昵称" prop="sysUser.nickName" :show-overflow-tooltip="true" >
        <template slot-scope="scope">{{scope.row.sysUser.nickName?scope.row.sysUser.nickName:'--'}}</template>
 
        </el-table-column>
      <el-table-column label="邮箱" prop="sysUser.email" :show-overflow-tooltip="true" >
            <template slot-scope="scope">{{scope.row.sysUser.email?scope.row.sysUser.email:'--'}}</template>
 
      </el-table-column>
      <el-table-column label="手机" prop="sysUser.phonenumber" :show-overflow-tooltip="true" >
        <template slot-scope="scope">{{scope.row.sysUser.phonenumber?scope.row.sysUser.phonenumber:'--'}}</template>
 
        </el-table-column>
   <!--   <el-table-column label="状态" align="center" prop="sysUser.status">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.status"/>
        </template>
      </el-table-column> -->
      <el-table-column label="创建时间" align="center" prop="createTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" prop="11" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-circle-close"
            @click="cancelAuthUser(scope.row)"
            v-hasPermi="['system:role:remove']"
          >取消授权</el-button>
        </template>
      </el-table-column>
    </el-table>
 
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <select-user ref="select" :roleId="queryParams.roleId" :recordId="queryParams.archiveRecordsId" @ok="handleQuery" />
  </div>
</template>
 
<script>
import {UserRoleIdList, allocatedUserList, authUserCancel, authUserCancelAll } from "@/api/system/role"
import selectUser from "./seleUser"
  import { listMaterials, getMaterials, delMaterials, addMaterials, updateMaterials,getArchiverecordstouserByReIdAndUid } from "@/api/system/materials"
import {listArchiverecordstouser,addArchiverecordstouser,delArchiverecordstouserByReIdAndUid,getArchiverecordstouser} from "@/api/system/archiverecordstouser"
export default {
  name: "AuthUser1",
  dicts: ['sys_normal_disable'],
   components: { selectUser },
  data() {
    return {
      vws: true,
      // 遮罩层
      loading: true,
      // 选中用户组
      userIds: [],
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 用户表格数据
      userList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        roleId: undefined,
        archiveRecordsId: undefined,
 
        // SysUser.userName: undefined,
        // phonenumber: undefined
      }
    }
  },
  created() {
    const roleId = this.$route.params && this.$route.params.roleId
    const recordId = this.$route.params && this.$route.params.archiveRecordsId
 
    if (roleId && recordId) {
      this.queryParams.roleId = roleId
      // 进行类型转换
      this.queryParams.archiveRecordsId = !isNaN(Number(recordId)) ? Number(recordId) : 0
      this.getList()
    }
  },
  methods: {
    // 修改 getList 方法
    /** 查询授权用户列表 */
    getList() {
      this.loading = true
      // 创建一个新对象,将字符串类型的archiveRecordsId转换为数字类型
      const params = {
        ...this.queryParams,
        archiveRecordsId: !isNaN(Number(this.queryParams.archiveRecordsId)) ?
                    Number(this.queryParams.archiveRecordsId) : 0
      }
      listArchiverecordstouser(params).then(response => {
        this.userList = response.data.data
        this.total = response.data.total
        this.loading = false
      })
    },
    /** 打开授权用户表弹窗 */
    openSelectUser() {
      // 确保传递给select组件的recordId是数字类型
      const recordId = !isNaN(Number(this.queryParams.archiveRecordsId)) ?
                    Number(this.queryParams.archiveRecordsId) : 0
 
      this.$refs.select.show(recordId)
    },
    // 返回按钮
    handleClose() {
      const obj = { path: "/system/role" }
      this.$tab.closeOpenPage(obj)
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm")
      this.handleQuery()
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.userIds = selection.map(item => item.userId)
      this.multiple = !selection.length
    },
    /** 打开授权用户表弹窗 */
    openSelectUser() {
      // alert(this.queryParams.roleId)
      // alert(this.queryParams.archiveRecordsId )
      this.$refs.select.show(this.queryParams.archiveRecordsId)
    },
    /** 取消授权按钮操作 */
    cancelAuthUser(row) {
      const recordId = this.queryParams.archiveRecordsId
      var userId = row.userId
      // alert(userId)
      // alert(this.queryParams.archiveRecordsId)
      // alert(row.sysUser.userName)
      this.$modal.confirm('确认要取消该用户"' + row.sysUser.userName + '"授权吗?').then(function() {
        return delArchiverecordstouserByReIdAndUid({  recordId: recordId, userId: userId   })
      }).then(() => {
        this.getList()
        this.$modal.msgSuccess("取消授权成功")
      }).catch(() => {})
    },
    /** 批量取消授权按钮操作 */
    cancelAuthUserAll(row) {
      const roleId = this.queryParams.roleId
      const userIds = this.userIds.join(",")
      this.$modal.confirm('是否取消选中用户授权数据项?').then(function() {
        return authUserCancelAll({ roleId: roleId, userIds: userIds })
      }).then(() => {
        this.getList()
        this.$modal.msgSuccess("取消授权成功")
      }).catch(() => {})
    }
  }
}
</script>
<style scoped>
/* el-table 列数据为空自动显示 -- */
.className :empty::before{
    content:'--';
    color:gray;
}
</style>