selectUser.vue 4.4 KB

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