index.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="用户ID" prop="userId">
  5. <el-input v-model="queryParams.userId" placeholder="请输入用户ID" clearable @keyup.enter.native="handleQuery" />
  6. </el-form-item>
  7. <el-form-item label="用户姓名" prop="userName">
  8. <el-input v-model="queryParams.userName" placeholder="请输入用户姓名" clearable @keyup.enter.native="handleQuery" />
  9. </el-form-item>
  10. <el-form-item>
  11. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  12. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  13. </el-form-item>
  14. </el-form>
  15. <el-row :gutter="10" class="mb8">
  16. <el-col :span="1.5">
  17. <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
  18. v-hasPermi="['doc:groupUser:add']">分配成员</el-button>
  19. </el-col>
  20. <el-col :span="1.5">
  21. <el-button type="danger" plain icon="el-icon-circle-close" size="mini" :disabled="multiple"
  22. @click="cancelGroupUserAll" v-hasPermi="['doc:groupUser:remove']">删除成员</el-button>
  23. </el-col>
  24. <el-col :span="1.5">
  25. <el-button type="warning" plain icon="el-icon-close" size="mini" @click="handleClose">关闭</el-button>
  26. </el-col>
  27. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  28. </el-row>
  29. <el-table v-loading="loading" :data="groupUserList" @selection-change="handleSelectionChange">
  30. <el-table-column type="selection" width="55" align="center" />
  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" class-name="small-padding fixed-width">
  41. <template slot-scope="scope">
  42. <el-button size="mini" type="text" icon="el-icon-circle-close" @click="cancelGroupUser(scope.row)"
  43. v-hasPermi="['doc:groupUser:remove']">删除成员</el-button>
  44. </template>
  45. </el-table-column>
  46. </el-table>
  47. <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
  48. @pagination="getList" />
  49. <select-user ref="select" :groupId="queryParams.groupId" @ok="handleQuery" />
  50. </div>
  51. </template>
  52. <script>
  53. import {
  54. listGroupUser,
  55. getGroupUser,
  56. delGroupUser,
  57. addGroupUser,
  58. updateGroupUser,
  59. groupUserCancelAll
  60. } from "@/api/doc/groupUser";
  61. import selectUser from "./selectUser";
  62. export default {
  63. name: "GroupUser",
  64. dicts: ['sys_normal_disable'],
  65. components: {
  66. selectUser
  67. },
  68. data() {
  69. return {
  70. // 遮罩层
  71. loading: true,
  72. // 选中数组
  73. ids: [],
  74. // 非单个禁用
  75. single: true,
  76. // 非多个禁用
  77. multiple: true,
  78. // 显示搜索条件
  79. showSearch: true,
  80. // 总条数
  81. total: 0,
  82. // 分组成员表格数据
  83. groupUserList: [],
  84. // 弹出层标题
  85. title: "",
  86. // 是否显示弹出层
  87. open: false,
  88. // 查询参数
  89. queryParams: {
  90. pageNum: 1,
  91. pageSize: 10,
  92. userId: null,
  93. userName: null
  94. },
  95. // 表单参数
  96. form: {},
  97. // 表单校验
  98. rules: {}
  99. };
  100. },
  101. created() {
  102. const groupId = this.$route.params && this.$route.params.groupId;
  103. if (groupId) {
  104. this.queryParams.groupId = groupId;
  105. this.getList();
  106. }
  107. },
  108. methods: {
  109. // 返回按钮
  110. handleClose() {
  111. const obj = {
  112. path: "/group/group"
  113. };
  114. this.$tab.closeOpenPage(obj);
  115. },
  116. /** 查询分组成员列表 */
  117. getList() {
  118. this.loading = true;
  119. listGroupUser(this.queryParams).then(response => {
  120. this.groupUserList = response.rows;
  121. this.total = response.total;
  122. this.loading = false;
  123. });
  124. },
  125. // 取消按钮
  126. cancel() {
  127. this.open = false;
  128. this.reset();
  129. },
  130. // 表单重置
  131. reset() {
  132. this.form = {
  133. groupId: null,
  134. userId: null,
  135. userName: null
  136. };
  137. this.resetForm("form");
  138. },
  139. /** 搜索按钮操作 */
  140. handleQuery() {
  141. this.queryParams.pageNum = 1;
  142. this.getList();
  143. },
  144. /** 重置按钮操作 */
  145. resetQuery() {
  146. this.resetForm("queryForm");
  147. this.handleQuery();
  148. },
  149. // 多选框选中数据
  150. handleSelectionChange(selection) {
  151. this.ids = selection.map(item => item.userId)
  152. this.single = selection.length !== 1
  153. this.multiple = !selection.length
  154. },
  155. /** 新增按钮操作 */
  156. handleAdd() {
  157. this.$refs.select.show();
  158. },
  159. /** 提交按钮 */
  160. submitForm() {
  161. this.$refs["form"].validate(valid => {
  162. if (valid) {
  163. if (this.form.groupId != null) {
  164. updateGroupUser(this.form).then(response => {
  165. this.$modal.msgSuccess("修改成功");
  166. this.open = false;
  167. this.getList();
  168. });
  169. } else {
  170. addGroupUser(this.form).then(response => {
  171. this.$modal.msgSuccess("新增成功");
  172. this.open = false;
  173. this.getList();
  174. });
  175. }
  176. }
  177. });
  178. },
  179. /** 删除按钮操作 */
  180. cancelGroupUserAll(row) {
  181. const groupId = this.queryParams.groupId;
  182. const userIds = this.ids.join(",");
  183. this.$modal.confirm('是否确认删除选中的分组成员?').then(function() {
  184. return groupUserCancelAll({
  185. groupId: groupId,
  186. userIds: userIds
  187. });
  188. }).then(() => {
  189. this.getList();
  190. this.$modal.msgSuccess("删除成功");
  191. }).catch(() => {});
  192. },
  193. /** 删除按钮操作 */
  194. cancelGroupUser(row) {
  195. const groupId = this.queryParams.groupId;
  196. const userIds = row.userId
  197. this.$modal.confirm('是否确认删除分组成员"' + row.userName + '"的数据项?').then(function() {
  198. return groupUserCancelAll({
  199. groupId: groupId,
  200. userIds: userIds
  201. });
  202. }).then(() => {
  203. this.getList();
  204. this.$modal.msgSuccess("删除成功");
  205. }).catch(() => {});
  206. },
  207. },
  208. };
  209. </script>