qwUserList.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <template>
  2. <div class="app-container">
  3. <el-alert v-if="type==2 && (sendType==2||sendType==4||sendType==11)"
  4. title="注意事项"
  5. type="warning"
  6. description="只显示含有【允许使用插件】的成员"
  7. :closable="false"
  8. center
  9. show-icon>
  10. </el-alert>
  11. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px" @submit.prevent="handleQuery">
  12. <el-form-item label="后台员工昵称" prop="nickName">
  13. <el-input
  14. v-model="queryParams.nickName"
  15. placeholder="请输入后台员工昵称"
  16. clearable
  17. size="small"
  18. @keydown.enter.native="handleQueryEnter"
  19. />
  20. </el-form-item>
  21. <el-form-item label="企微员工部门" prop="deptName">
  22. <el-input
  23. v-model="queryParams.deptName"
  24. placeholder="请输入企微员工部门"
  25. clearable
  26. size="small"
  27. @keydown.enter.native="handleQueryEnter"
  28. />
  29. </el-form-item>
  30. <el-form-item>
  31. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  32. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">刷新/重置</el-button>
  33. </el-form-item>
  34. </el-form>
  35. <el-table v-loading="loading" :data="userList" ref="userList" @selection-change="handleSelectionChange">
  36. <el-table-column type="selection" width="55" align="center" />
  37. <el-table-column label="企微员工账号" align="center" prop="qwUserId" />
  38. <el-table-column label="企微员工昵称" align="center" prop="qwUserName"/>
  39. <el-table-column label="企微员工部门" align="center" prop="departmentName"/>
  40. <el-table-column label="后台员工昵称" align="center" prop="nickName"/>
  41. <el-table-column label="后台员工用户名" align="center" prop="userName" />
  42. </el-table>
  43. <div style="margin-top: 30px;display: flex;justify-content: center">
  44. <el-button type="warning" icon="el-icon-search" @click="confirmSelect">确定选择</el-button>
  45. </div>
  46. <pagination
  47. v-show="total>0"
  48. :total="total"
  49. :page.sync="queryParams.pageNum"
  50. :limit.sync="queryParams.pageSize"
  51. @pagination="handlePaginationChange"
  52. />
  53. </div>
  54. </template>
  55. <script>
  56. import { listUser, getUser, delUser, addUser, updateUser, exportUser } from "@/api/qw/user";
  57. export default {
  58. name: "qwUserList",
  59. data() {
  60. return {
  61. type:null,
  62. sendType:null,
  63. // 遮罩层
  64. loading: true,
  65. // 导出遮罩层
  66. exportLoading: false,
  67. // 选中数组
  68. selectUsers: [],
  69. // 非单个禁用
  70. single: true,
  71. // 非多个禁用
  72. multiple: true,
  73. // 显示搜索条件
  74. showSearch: true,
  75. // 总条数
  76. total: 0,
  77. // 企微用户表格数据
  78. userList: [],
  79. // 弹出层标题
  80. title: "",
  81. // 是否显示弹出层
  82. open: false,
  83. // 查询参数
  84. queryParams: {
  85. pageNum: 1,
  86. pageSize: 10,
  87. qwUserId: null,
  88. companyId: null,
  89. companyUserId: null,
  90. deptName: null,
  91. corpId: null,
  92. nickName: null
  93. },
  94. // 表单参数
  95. form: {},
  96. // 表单校验
  97. rules: {
  98. }
  99. };
  100. },
  101. created() {
  102. },
  103. methods: {
  104. getDetails(corpId,type,sendType,isRemark){
  105. this.type=type;
  106. this.sendType=sendType;
  107. if (type!=null&&sendType!=null){
  108. this.queryParams.type=type;
  109. this.queryParams.sendType=sendType;
  110. }
  111. this.queryParams.corpId=corpId;
  112. this.queryParams.isRemark=isRemark;
  113. this.getList();
  114. },
  115. /** 查询企微用户列表 */
  116. getList() {
  117. this.loading = true;
  118. listUser(this.queryParams).then(response => {
  119. // 如果 companyUserId 为 null,移除列
  120. this.userList = response.rows;
  121. this.total = response.total;
  122. this.loading = false;
  123. });
  124. },
  125. handlePaginationChange(row) {
  126. this.queryParams.pageNum = row.page;
  127. this.queryParams.pageSize = row.limit;
  128. this.getList();
  129. },
  130. // 取消按钮
  131. cancel() {
  132. this.open = false;
  133. this.reset();
  134. },
  135. // 表单重置
  136. reset() {
  137. this.form = {
  138. id: null,
  139. qwUserId: null,
  140. companyId: null,
  141. companyUserId: null,
  142. corpId: null
  143. };
  144. this.resetForm("form");
  145. },
  146. //确定选择
  147. confirmSelect(){
  148. this.$emit("selectUserList",this.selectUsers);
  149. this.resetSelect();
  150. },
  151. //重置选择
  152. resetSelect(){
  153. this.$refs.userList.clearSelection();
  154. this.selectUsers=[];
  155. //重置
  156. this.queryParams={
  157. pageNum: 1,
  158. pageSize: 5,
  159. qwUserId: null,
  160. companyId: null,
  161. companyUserId: null,
  162. corpId: null,
  163. nickName: null
  164. },
  165. this.getList();
  166. },
  167. /** 搜索按钮操作 */
  168. handleQuery() {
  169. this.queryParams.pageNum = 1;
  170. this.getList();
  171. },
  172. handleQueryEnter(event){
  173. // 确保事件对象存在
  174. if (event && event.preventDefault) {
  175. event.preventDefault(); // 阻止默认提交行为
  176. }
  177. this.handleQuery();
  178. },
  179. /** 重置按钮操作 */
  180. resetQuery() {
  181. this.resetForm("queryForm");
  182. this.handleQuery();
  183. },
  184. // 多选框选中数据
  185. handleSelectionChange(selection) {
  186. // 保存当前页的选中项
  187. const currentPageSelections = selection.map(item => item.id);
  188. // 合并选中项
  189. this.selectUsers = this.selectUsers.filter(item =>
  190. this.userList.some(tag => tag.id === item.id) ? currentPageSelections.includes(item.id) : true
  191. ).concat(selection.filter(item => !this.selectUsers.some(selected => selected.id === item.id)));
  192. // 更新 single 和 multiple
  193. this.single = this.selectUsers.length !== 1;
  194. this.multiple = !this.selectUsers.length;
  195. },
  196. }
  197. };
  198. </script>