selectUser.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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. <script>
  59. import { unallocatedUserList, groupUserSelectAll } from "@/api/doc/groupUser";
  60. export default {
  61. dicts: ['sys_normal_disable'],
  62. props: {
  63. // 角色编号
  64. groupId: {
  65. type: [String]
  66. }
  67. },
  68. data() {
  69. return {
  70. // 遮罩层
  71. visible: false,
  72. // 选中数组值
  73. userIds: [],
  74. // 总条数
  75. total: 0,
  76. // 未授权用户数据
  77. userList: [],
  78. // 查询参数
  79. queryParams: {
  80. pageNum: 1,
  81. pageSize: 10,
  82. groupId: undefined,
  83. // userName: undefined,
  84. // phonenumber: undefined
  85. }
  86. };
  87. },
  88. methods: {
  89. // 显示弹框
  90. show() {
  91. console.log(this.queryParams)
  92. this.queryParams.groupId = parseInt(this.groupId);
  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 groupId = this.queryParams.groupId;
  123. const userIds = this.userIds.join(",");
  124. if (userIds == "") {
  125. this.$modal.msgError("请选择要分配的用户");
  126. return;
  127. }
  128. authUserSelectAll({ groupId: groupId, 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>