QwUserSelectTwo.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <template>
  2. <el-drawer size="75%" title="选择企微账号" :visible.sync="shows" append-to-body destroy-on-close class="qw-user-select-drawer">
  3. <div class="drawer-container">
  4. <!-- 搜索表单 -->
  5. <el-card shadow="never" class="search-card">
  6. <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="100px" class="search-form">
  7. <el-row :gutter="16">
  8. <el-col :span="6">
  9. <el-form-item label="销售公司" prop="companyId">
  10. <el-select v-model="queryParams.companyId" placeholder="销售公司" size="small" @change="handleCompanyChange">
  11. <el-option
  12. v-for="dict in qwCompanyList"
  13. :key="dict.companyId"
  14. :label="dict.companyName"
  15. :value="dict.companyId"
  16. />
  17. </el-select>
  18. </el-form-item>
  19. </el-col>
  20. <el-col :span="6">
  21. <el-form-item label="企微用户名" prop="qwUserName">
  22. <el-input v-model="queryParams.qwUserName" placeholder="请输入企微用户名" clearable size="small" @keyup.enter.native="handleQuery"/>
  23. </el-form-item>
  24. </el-col>
  25. <el-col :span="6">
  26. <el-form-item label="企微用户 ID" prop="qwUserId">
  27. <el-input v-model="queryParams.qwUserId" placeholder="请输入企微用户 ID" clearable size="small" @keyup.enter.native="handleQuery"/>
  28. </el-form-item>
  29. </el-col>
  30. <el-col :span="6">
  31. <el-form-item>
  32. <el-button type="primary" icon="el-icon-search" size="small" @click="handleQuery">搜索</el-button>
  33. <el-button icon="el-icon-refresh" size="small" @click="resetQuery">重置</el-button>
  34. </el-form-item>
  35. </el-col>
  36. </el-row>
  37. </el-form>
  38. </el-card>
  39. <!-- 企微账号列表 -->
  40. <el-card shadow="never" class="table-card">
  41. <div slot="header" class="card-header">
  42. <span>企微账号列表</span>
  43. <el-tag v-if="selectedRows.length" type="success">已选择 {{ selectedRows.length }} 个账号</el-tag>
  44. </div>
  45. <el-table border v-loading="loading" :data="qwUserList" :row-key="getRowKeys" @selection-change="handleSelectionChange" size="small" ref="table" height="500">
  46. <el-table-column type="selection" width="55" align="center" :reserve-selection="true" />
  47. <el-table-column label="企微用户名" align="center" prop="qwUserName"/>
  48. <el-table-column label="企微用户id" align="center" prop="qwUserId"/>
  49. <el-table-column label="vid" align="center" prop="vid"/>
  50. <el-table-column label="uid" align="center" prop="uid"/>
  51. <el-table-column label="ipad服务器id" align="center" prop="serverId"/>
  52. </el-table>
  53. <!-- 分页组件 -->
  54. <pagination
  55. v-show="total > 0"
  56. :total="total"
  57. :page.sync="queryParams.pageNum"
  58. :limit.sync="queryParams.pageSize"
  59. @pagination="getList"
  60. style="margin-top: 20px;"
  61. />
  62. </el-card>
  63. <!-- 底部按钮 -->
  64. <div class="footer-actions">
  65. <el-button @click="shows = false">取 消</el-button>
  66. <el-button type="primary" @click="submitForm">确定选择</el-button>
  67. </div>
  68. </div>
  69. </el-drawer>
  70. </template>
  71. <script>
  72. import {queryQwList} from "../../api/qw/qwUser";
  73. import {listCompany} from "../../api/company/company";
  74. export default {
  75. name: "QwUserSelectTwo",
  76. data() {
  77. return {
  78. rows: [], // 已选择的行数据
  79. selectedRows: [], // 已选择的行数据(别名)
  80. shows: false,
  81. // 遮罩层
  82. loading: true,
  83. // 选中数组
  84. ids: [],
  85. // 非单个禁用
  86. single: true,
  87. // 非多个禁用
  88. multiple: true,
  89. // 总条数
  90. total: 0,
  91. // 企微账号表格数据
  92. qwUserList: [],
  93. qwCompanyList: [],
  94. // 查询参数
  95. queryParams: {
  96. pageNum: 1,
  97. pageSize: 10,
  98. companyId: null,
  99. qwUserName: null,
  100. qwUserId: null
  101. }
  102. };
  103. },
  104. methods: {
  105. // 获取企业数据
  106. getCompanyData() {
  107. listCompany().then(response => {
  108. this.qwCompanyList = response.rows;
  109. // 默认选中第一个企业
  110. if (this.qwCompanyList && this.qwCompanyList.length > 0) {
  111. this.queryParams.companyId = this.qwCompanyList[0].companyId;
  112. // 重新加载页面数据
  113. this.handleQuery();
  114. }
  115. });
  116. },
  117. // 企业改变时触发查询
  118. handleCompanyChange() {
  119. this.queryParams.pageNum = 1;
  120. this.getList();
  121. },
  122. setRows(rows){
  123. this.shows = true;
  124. this.rows = rows || [];
  125. this.selectedRows = rows || []; // 同步更新
  126. this.getList();
  127. // 获取企业列表并默认选中第一个
  128. this.getCompanyData();
  129. },
  130. initSelect(){
  131. let row = this.rows;
  132. if(row && row.length > 0 && this.$refs.table){
  133. row.forEach(row => {
  134. this.$refs.table.toggleRowSelection(row, true);
  135. })
  136. }
  137. },
  138. getRowKeys(item){
  139. return item.id;
  140. },
  141. /** 查询企微账号列表 */
  142. getList() {
  143. this.loading = true;
  144. queryQwList(this.queryParams).then(response => {
  145. if (this.$refs.table) {
  146. this.$refs.table.clearSelection();
  147. }
  148. this.qwUserList = response.rows;
  149. this.total = response.total;
  150. this.loading = false;
  151. this.initSelect();
  152. });
  153. },
  154. /** 搜索按钮操作 */
  155. handleQuery() {
  156. this.queryParams.pageNum = 1;
  157. this.getList();
  158. },
  159. /** 重置按钮操作 */
  160. resetQuery() {
  161. this.resetForm("queryForm");
  162. this.queryParams.pageNum = 1;
  163. this.queryParams.pageSize = 10;
  164. // 重置后选中第一个企业
  165. if (this.qwCompanyList && this.qwCompanyList.length > 0) {
  166. this.queryParams.companyId = this.qwCompanyList[0].companyId;
  167. }
  168. this.getList();
  169. },
  170. // 多选框选中数据
  171. handleSelectionChange(selection) {
  172. this.rows = selection;
  173. this.selectedRows = selection; // 同步更新
  174. this.ids = selection.map(item => item.id)
  175. this.single = selection.length!==1
  176. this.multiple = !selection.length
  177. },
  178. submitForm(){
  179. this.$nextTick(() => {
  180. this.$emit("success", {ids: this.ids, rows: this.rows})
  181. this.shows = false;
  182. this.$refs.table.clearSelection();
  183. })
  184. },
  185. }
  186. };
  187. </script>
  188. <style scoped>
  189. .el-tag + .el-tag {
  190. margin-left: 10px;
  191. }
  192. .button-new-tag {
  193. margin-left: 10px;
  194. height: 32px;
  195. line-height: 30px;
  196. padding-top: 0;
  197. padding-bottom: 0;
  198. }
  199. .input-new-tag {
  200. width: 90px;
  201. margin-left: 10px;
  202. vertical-align: bottom;
  203. }
  204. .el-dialog__wrapper{
  205. z-index: 100000;
  206. }
  207. .app-container{padding: 0}
  208. .dialog-footer{
  209. position: absolute;
  210. bottom: 0;
  211. right: 20px;
  212. background: #FFF;
  213. }
  214. </style>