春风项目四线(合箱线、总装线)
wujian
2024-04-24 3946f893f84814185dfb97e89bfdb10b82eea906
提交 | 用户 | 时间
fd2207 1 <template>
2   <!-- 授权用户 -->
3   <el-dialog title="选择用户" :visible.sync="visible" width="800px" top="5vh" append-to-body>
4     <el-form :model="queryParams" ref="queryForm" size="small" :inline="true">
5       <el-form-item label="用户名称" prop="userName">
6         <el-input
7           v-model="queryParams.userName"
8           placeholder="请输入用户名称"
9           clearable
10           @keyup.enter.native="handleQuery"
11         />
12       </el-form-item>
13       <el-form-item label="手机号码" prop="phonenumber">
14         <el-input
15           v-model="queryParams.phonenumber"
16           placeholder="请输入手机号码"
17           clearable
18           @keyup.enter.native="handleQuery"
19         />
20       </el-form-item>
21       <el-form-item>
22         <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
23         <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
24       </el-form-item>
25     </el-form>
26     <el-row>
27       <el-table @row-click="clickRow" ref="table" :data="userList" @selection-change="handleSelectionChange" height="260px">
28         <el-table-column type="selection" width="55"></el-table-column>
29         <el-table-column label="用户名称" prop="userName" :show-overflow-tooltip="true" />
30         <el-table-column label="用户昵称" prop="nickName" :show-overflow-tooltip="true" />
31         <el-table-column label="邮箱" prop="email" :show-overflow-tooltip="true" />
32         <el-table-column label="手机" prop="phonenumber" :show-overflow-tooltip="true" />
33         <el-table-column label="状态" align="center" prop="status">
34           <template slot-scope="scope">
35             <dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.status"/>
36           </template>
37         </el-table-column>
38         <el-table-column label="创建时间" align="center" prop="createTime" width="180">
39           <template slot-scope="scope">
40             <span>{{ parseTime(scope.row.createTime) }}</span>
41           </template>
42         </el-table-column>
43       </el-table>
44       <pagination
45         v-show="total>0"
46         :total="total"
47         :page.sync="queryParams.pageNum"
48         :limit.sync="queryParams.pageSize"
49         @pagination="getList"
50       />
51     </el-row>
52     <div slot="footer" class="dialog-footer">
53       <el-button type="primary" @click="handleSelectUser">确 定</el-button>
54       <el-button @click="visible = false">取 消</el-button>
55     </div>
56   </el-dialog>
57 </template>
58
59 <script>
60 import { unallocatedUserList, authUserSelectAll } from "@/api/system/role";
61 export default {
62   dicts: ['sys_normal_disable'],
63   props: {
64     // 角色编号
65     roleId: {
66       type: [Number, String]
67     }
68   },
69   data() {
70     return {
71       // 遮罩层
72       visible: false,
73       // 选中数组值
74       userIds: [],
75       // 总条数
76       total: 0,
77       // 未授权用户数据
78       userList: [],
79       // 查询参数
80       queryParams: {
81         pageNum: 1,
82         pageSize: 10,
83         roleId: undefined,
84         userName: undefined,
85         phonenumber: undefined
86       }
87     };
88   },
89   methods: {
90     // 显示弹框
91     show() {
92       this.queryParams.roleId = this.roleId;
93       this.getList();
94       this.visible = true;
95     },
96     clickRow(row) {
97       this.$refs.table.toggleRowSelection(row);
98     },
99     // 多选框选中数据
100     handleSelectionChange(selection) {
101       this.userIds = selection.map(item => item.userId);
102     },
103     // 查询表数据
104     getList() {
105       unallocatedUserList(this.queryParams).then(res => {
106         this.userList = res.rows;
107         this.total = res.total;
108       });
109     },
110     /** 搜索按钮操作 */
111     handleQuery() {
112       this.queryParams.pageNum = 1;
113       this.getList();
114     },
115     /** 重置按钮操作 */
116     resetQuery() {
117       this.resetForm("queryForm");
118       this.handleQuery();
119     },
120     /** 选择授权用户操作 */
121     handleSelectUser() {
122       const roleId = this.queryParams.roleId;
123       const userIds = this.userIds.join(",");
124       if (userIds == "") {
125         this.$modal.msgError("请选择要分配的用户");
126         return;
127       }
128       authUserSelectAll({ roleId: roleId, userIds: userIds }).then(res => {
129         this.$modal.msgSuccess(res.msg);
130         if (res.code === 200) {
131           this.visible = false;
132           this.$emit("ok");
133         }
134       });
135     }
136   }
137 };
138 </script>