mylist.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772
  1. <template>
  2. <div class="app-container" v-hasPermi="['user:fsUser:myList']">
  3. <!-- Search Form -->
  4. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="80px">
  5. <el-form-item label="项目" prop="projectId">
  6. <el-select v-model="queryParams.projectId" placeholder="请选择项目" clearable size="small" >
  7. <el-option
  8. v-for="item in projectOptions"
  9. :key="item.dictValue"
  10. :label="item.dictLabel"
  11. :value="item.dictValue"
  12. />
  13. </el-select>
  14. </el-form-item>
  15. <el-form-item label="会员ID" prop="userId">
  16. <el-input
  17. style="width: 200px"
  18. v-model="queryParams.userId"
  19. placeholder="请输入会员ID"
  20. clearable
  21. size="small"
  22. @keyup.enter.native="handleQuery"
  23. />
  24. </el-form-item>
  25. <el-form-item label="昵称" prop="nickname">
  26. <el-input
  27. style="width: 200px"
  28. v-model="queryParams.nickname"
  29. placeholder="请输入昵称"
  30. clearable
  31. size="small"
  32. @keyup.enter.native="handleQuery"
  33. />
  34. </el-form-item>
  35. <el-form-item label="app来源" prop="source">
  36. <el-input
  37. v-model="queryParams.source"
  38. placeholder="请输入app来源"
  39. clearable
  40. size="small"
  41. @keyup.enter.native="handleQuery"
  42. />
  43. </el-form-item>
  44. <el-form-item label="用户状态" prop="status">
  45. <el-select v-model="queryParams.status" placeholder="请选择用户状态" clearable size="small">
  46. <el-option
  47. v-for="dict in userOptions"
  48. :key="dict.dictValue"
  49. :label="dict.dictLabel"
  50. :value="dict.dictValue"
  51. />
  52. </el-select>
  53. </el-form-item>
  54. <el-form-item label="是否购药" prop="isBuy">
  55. <el-select v-model="queryParams.isBuy" placeholder="请选择是否购药" clearable size="small">
  56. <el-option
  57. v-for="dict in orOptions"
  58. :key="dict.dictValue"
  59. :label="dict.dictLabel"
  60. :value="dict.dictValue"
  61. />
  62. </el-select>
  63. </el-form-item>
  64. <el-form-item label="手机号码" prop="phone">
  65. <el-input
  66. style="width: 200px"
  67. v-model="queryParams.phone"
  68. placeholder="请输入手机号码"
  69. clearable
  70. size="small"
  71. @keyup.enter.native="handleQuery"
  72. />
  73. </el-form-item>
  74. <!-- <el-form-item label="状态" prop="status">-->
  75. <!-- <el-select style="width: 200px" v-model="queryParams.status" placeholder="请选择状态" clearable size="small">-->
  76. <!-- <el-option-->
  77. <!-- v-for="item in statusOptions"-->
  78. <!-- :key="item.dictValue"-->
  79. <!-- :label="item.dictLabel"-->
  80. <!-- :value="item.dictValue"-->
  81. <!-- />-->
  82. <!-- </el-select>-->
  83. <!-- </el-form-item>-->
  84. <!-- <el-form-item label="看课状态" prop="watchCourseType">-->
  85. <!-- <el-select style="width: 200px" v-model="queryParams.watchCourseType" placeholder="请选择看课状态" clearable size="small">-->
  86. <!-- <el-option label="全部" value="0" />-->
  87. <!-- <el-option label="未看过课" value="1" />-->
  88. <!-- <el-option label="正常看课" value="2" />-->
  89. <!-- <el-option label="停止看课" value="3" />-->
  90. <!-- </el-select>-->
  91. <!-- </el-form-item>-->
  92. <!-- <el-form-item label="缺课状态" prop="missCourseStatus">-->
  93. <!-- <el-select style="width: 200px" v-model="queryParams.missCourseStatus" placeholder="请选择缺课状态" clearable size="small">-->
  94. <!-- <el-option label="全部" value="0" />-->
  95. <!-- <el-option label="已缺课" value="1" />-->
  96. <!-- <el-option label="未缺课" value="2" />-->
  97. <!-- </el-select>-->
  98. <!-- </el-form-item>-->
  99. <!-- <el-form-item label="标签" prop="tagIds">-->
  100. <!-- <el-select style="width: 200px" v-model="queryParams.tagIds" placeholder="请选择标签" clearable size="small" multiple>-->
  101. <!-- <el-option-->
  102. <!-- v-for="item in tagOptions"-->
  103. <!-- :key="item.tagId"-->
  104. <!-- :label="item.tagName"-->
  105. <!-- :value="item.tagId"-->
  106. <!-- />-->
  107. <!-- </el-select>-->
  108. <!-- </el-form-item>-->
  109. <el-form-item label="注册时间">
  110. <el-date-picker
  111. v-model="dateRange"
  112. size="small"
  113. style="width: 240px"
  114. type="daterange"
  115. range-separator="-"
  116. start-placeholder="开始日期"
  117. end-placeholder="结束日期"
  118. value-format="yyyy-MM-dd"
  119. ></el-date-picker>
  120. </el-form-item>
  121. <el-form-item>
  122. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  123. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  124. </el-form-item>
  125. </el-form>
  126. <!-- Tab Selection -->
  127. <!-- <el-tabs v-model="queryParams.tabValue" @tab-click="handleTabChange">-->
  128. <!-- <el-tab-pane label="全部" name="0"></el-tab-pane>-->
  129. <!-- <el-tab-pane label="今日新增" name="1"></el-tab-pane>-->
  130. <!-- <el-tab-pane label="今日完播" name="2"></el-tab-pane>-->
  131. <!-- <el-tab-pane label="未看过课" name="3"></el-tab-pane>-->
  132. <!-- </el-tabs>-->
  133. <!-- Toolbar -->
  134. <el-row :gutter="10" class="mb8">
  135. <!-- <el-col :span="1.5">-->
  136. <!-- <el-button-->
  137. <!-- type="primary"-->
  138. <!-- plain-->
  139. <!-- icon="el-icon-plus"-->
  140. <!-- size="mini"-->
  141. <!-- @click="handleAdd"-->
  142. <!-- v-hasPermi="['user:fsUser:add']"-->
  143. <!-- >新增</el-button>-->
  144. <!-- </el-col>-->
  145. <!-- <el-col :span="1.5">-->
  146. <!-- <el-button-->
  147. <!-- type="success"-->
  148. <!-- plain-->
  149. <!-- icon="el-icon-edit"-->
  150. <!-- size="mini"-->
  151. <!-- :disabled="single"-->
  152. <!-- @click="handleUpdate"-->
  153. <!-- v-hasPermi="['user:fsUser:edit']"-->
  154. <!-- >编辑</el-button>-->
  155. <!-- </el-col>-->
  156. <!-- <el-col :span="1.5">-->
  157. <!-- <el-button-->
  158. <!-- type="danger"-->
  159. <!-- plain-->
  160. <!-- icon="el-icon-delete"-->
  161. <!-- size="mini"-->
  162. <!-- :disabled="multiple"-->
  163. <!-- @click="handleDelete"-->
  164. <!-- v-hasPermi="['user:fsUser:remove']"-->
  165. <!-- >删除</el-button>-->
  166. <!-- </el-col>-->
  167. <!-- <el-col :span="1.5">-->
  168. <!-- <el-button-->
  169. <!-- type="warning"-->
  170. <!-- plain-->
  171. <!-- icon="el-icon-download"-->
  172. <!-- size="mini"-->
  173. <!-- @click="handleExport"-->
  174. <!-- v-hasPermi="['user:fsUser:export']"-->
  175. <!-- >导出</el-button>-->
  176. <!-- </el-col>-->
  177. <el-col :span="1.5">
  178. <el-button
  179. type="success"
  180. plain
  181. icon="el-icon-edit"
  182. size="mini"
  183. :disabled="multiple"
  184. @click="batchSend"
  185. >批量IM发送</el-button>
  186. </el-col>
  187. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  188. </el-row>
  189. <!-- User Table -->
  190. <el-table v-loading="loading" :data="userList" @selection-change="handleSelectionChange" border>
  191. <el-table-column type="selection" width="55" align="center" />
  192. <el-table-column label="ID" align="center" prop="userId" />
  193. <el-table-column label="项目" align="center" prop="projectId">
  194. <template slot-scope="scope">
  195. <el-tag v-if="scope.row.projectId !== null">{{ getProjectLabel(scope.row.projectId) }}</el-tag>
  196. </template>
  197. </el-table-column>
  198. <el-table-column label="昵称" align="center" prop="nickname" />
  199. <el-table-column label="头像" align="center" width="80">
  200. <template slot-scope="scope">
  201. <el-popover
  202. placement="right"
  203. title=""
  204. trigger="hover"
  205. >
  206. <img slot="reference" :src="scope.row.avatar" width="50">
  207. <img :src="scope.row.avatar" style="max-width: 120px;">
  208. </el-popover>
  209. </template>
  210. </el-table-column>
  211. <el-table-column label="手机号码" align="center" prop="phone" />
  212. <el-table-column label="积分" align="center" prop="integral" v-if="false" />
  213. <el-table-column label="看课数量" align="center" prop="watchCourseCount" />
  214. <el-table-column label="缺课数量" align="center" prop="missCourseCount" />
  215. <el-table-column label="参与营期数量" align="center" prop="partCourseCount" />
  216. <el-table-column label="状态" align="center">
  217. <template slot-scope="scope">
  218. <el-tag :type="scope.row.status === 1 ? 'success' : 'danger'">
  219. {{ scope.row.status === 1 ? '正常' : '禁止' }}
  220. </el-tag>
  221. </template>
  222. </el-table-column>
  223. <el-table-column label="看课状态" align="center">
  224. <template slot-scope="scope">
  225. <el-tag :type="getCourseStatusType(scope.row.courseCountStatus)">
  226. {{ getCourseStatusText(scope.row.courseCountStatus) }}
  227. </el-tag>
  228. </template>
  229. </el-table-column>
  230. <el-table-column label="标签" align="center" prop="tag" show-overflow-tooltip />
  231. <el-table-column label="最后看课时间" align="center" prop="lastWatchDate" width="160" />
  232. <el-table-column label="停课天数" align="center" prop="stopWatchDays" />
  233. <el-table-column label="注册时间" align="center" prop="createTime" width="160" />
  234. <el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip />
  235. <el-table-column label="所属员工" align="center" prop="companyUserNickName" />
  236. <el-table-column label="会员积分" align="center" prop="integral" />
  237. <el-table-column label="是否购买" align="center" prop="isBuy">
  238. <template slot-scope="scope">
  239. <span>{{ scope.row.isBuy === 1 ? '是' : '否' }}</span>
  240. </template>
  241. </el-table-column>
  242. <el-table-column label="操作" align="center" width="120" class-name="small-padding fixed-width">
  243. <template slot-scope="scope">
  244. <el-button
  245. size="mini"
  246. type="text"
  247. icon="el-icon-check"
  248. @click="handleAudit(scope.row)"
  249. v-if="scope.row.isCurrentCompanyUser === 1 && scope.row.status === 0"
  250. >审核会员</el-button>
  251. <el-button
  252. size="mini"
  253. type="text"
  254. icon="el-icon-edit"
  255. @click="handleUpdate(scope.row)"
  256. >修改</el-button>
  257. <el-button
  258. size="mini"
  259. type="text"
  260. @click="handledetails(scope.row)"
  261. >详情</el-button>
  262. </template>
  263. </el-table-column>
  264. </el-table>
  265. <pagination
  266. v-show="total>0"
  267. :total="total"
  268. :page.sync="queryParams.pageNum"
  269. :limit.sync="queryParams.pageSize"
  270. @pagination="getList"
  271. />
  272. <!-- Edit User Dialog -->
  273. <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
  274. <el-form ref="form" :model="form" :rules="rules" label-width="120px">
  275. <el-form-item label="用户头像" prop="avatar">
  276. <el-popover
  277. placement="right"
  278. title=""
  279. trigger="hover"
  280. >
  281. <img slot="reference" :src="form.avatar" width="80">
  282. <img :src="form.avatar" style="max-width: 120px;">
  283. </el-popover>
  284. </el-form-item>
  285. <el-form-item label="昵称" prop="nickname">
  286. <el-input v-model="form.nickname" :disabled="true" placeholder="请输入昵称" />
  287. </el-form-item>
  288. <el-form-item label="手机号码" prop="phone">
  289. <el-input v-model="form.phone" disabled placeholder="请输入手机号码" />
  290. </el-form-item>
  291. <el-form-item label="最后登录IP" prop="lastIp" v-if="form.lastIp">
  292. <el-input v-model="form.lastIp" disabled placeholder="最后一次登录IP" />
  293. </el-form-item>
  294. <el-form-item label="看课数量" prop="watchCourseCount" v-if="form.watchCourseCount">
  295. <el-input v-model="form.watchCourseCount" disabled placeholder="看课数量" />
  296. </el-form-item>
  297. <el-form-item label="缺课数量" prop="missCourseCount" v-if="form.missCourseCount">
  298. <el-input v-model="form.missCourseCount" disabled placeholder="缺课数量" />
  299. </el-form-item>
  300. <!-- <el-form-item label="标签" prop="tagIds">
  301. <el-select v-model="form.tagIds" disabled placeholder="请选择标签" clearable multiple>
  302. <el-option
  303. v-for="item in tagOptions"
  304. :key="item.tagId"
  305. :label="item.tagName"
  306. :value="item.tagId"
  307. />
  308. </el-select>
  309. </el-form-item> -->
  310. <el-form-item label="标签" prop="tag">
  311. <el-input v-model="form.tag" disabled clearable >
  312. </el-input>
  313. </el-form-item>
  314. <el-form-item label="所属员工" prop="companyUserId">
  315. <el-select v-model="form.companyUserId" disabled placeholder="请选择所属员工" clearable>
  316. <el-option
  317. v-for="item in companyUserList"
  318. :key="item.userId"
  319. :label="item.nickName"
  320. :value="item.userId"
  321. />
  322. </el-select>
  323. </el-form-item>
  324. <el-form-item label="用户备注" prop="remark">
  325. <el-input v-model="form.remark" type="textarea" placeholder="请输入用户备注" />
  326. </el-form-item>
  327. <el-form-item label="状态">
  328. <el-radio-group v-model="form.status">
  329. <el-radio :label="1">正常</el-radio>
  330. <el-radio :label="0">禁止</el-radio>
  331. </el-radio-group>
  332. </el-form-item>
  333. </el-form>
  334. <div slot="footer" class="dialog-footer">
  335. <el-button type="primary" @click="submitForm">确 定</el-button>
  336. <el-button @click="cancel">取 消</el-button>
  337. </div>
  338. </el-dialog>
  339. <el-drawer
  340. :with-header="false"
  341. size="75%"
  342. :title="show.title" :visible.sync="show.open">
  343. <userDetails ref="userDetails" />
  344. </el-drawer>
  345. <el-dialog
  346. title="营期"
  347. :visible.sync="dialogVisible"
  348. width="80%"
  349. :before-close="handleClose">
  350. <userCoursePeriod :userIds="ids" :companyId="companyId" :companyUserId="companyUserId"/>
  351. </el-dialog>
  352. </div>
  353. </template>
  354. <script>
  355. import { myListUser, getUser, addUser, updateUser, delUser, exportUser, auditUser } from "@/api/user/fsUser";
  356. import {transferUser} from "@/api/users/user";
  357. import {getUserList} from "@/api/company/companyUser";
  358. import userDetails from '@/views/store/components/userDetails.vue';
  359. import userCoursePeriod from '../../components/course/userCoursePeriod.vue'
  360. export default {
  361. name: "FsUser",
  362. components: {userDetails,userCoursePeriod},
  363. dicts: ['user_status', 'sys_course_project'],
  364. data() {
  365. return {
  366. userOptions: [],
  367. orOptions:[],
  368. show:{
  369. title:"会员详情",
  370. open:false,
  371. },
  372. cusTransfer: {
  373. targetUserId: [{required: true, message: '请选择转移至销售', trigger: 'change'}],
  374. content: [{required: true, message: '请选择转移至销售', trigger: 'change'}]
  375. },
  376. dialogVisible:false,
  377. companyUserList: [],
  378. openTransferDialog: false,
  379. transferForm: {
  380. targetUserId: null,
  381. content: null
  382. },
  383. // 遮罩层
  384. loading: true,
  385. // 选中数组
  386. ids: [],
  387. companyUserId:null,
  388. companyId:null,
  389. // 非单个禁用
  390. single: true,
  391. // 非多个禁用
  392. multiple: true,
  393. // 显示搜索条件
  394. showSearch: true,
  395. // 总条数
  396. total: 0,
  397. // 用户表格数据
  398. userList: [],
  399. // 弹出层标题
  400. title: "",
  401. // 是否显示弹出层
  402. open: false,
  403. // 日期范围
  404. dateRange: [],
  405. // 状态数据字典
  406. statusOptions: [],
  407. // 标签选项
  408. tagOptions: [],
  409. // 销售员工选项
  410. salesOptions: [],
  411. // 查询参数
  412. queryParams: {
  413. userId: null,
  414. pageNum: 1,
  415. pageSize: 10,
  416. nickname: null,
  417. phone: null,
  418. // status: null,
  419. tagIds: [],
  420. tabValue: "0",
  421. watchCourseType: "0",
  422. missCourseStatus: "0",
  423. continueMissCourseSort: "0",
  424. registerStartTime: null,
  425. registerEndTime: null,
  426. projectId: null,
  427. source:null,
  428. status: null,
  429. isBuy:null,
  430. },
  431. // 表单参数
  432. form: {},
  433. // 表单校验
  434. rules: {
  435. // nickname: [
  436. // { required: true, message: "昵称不能为空", trigger: "blur" }
  437. // ],
  438. // phone: [
  439. // { required: true, message: "手机号码不能为空", trigger: "blur" },
  440. // { pattern: /^1[3-9]\d{9}$/, message: "请输入正确的手机号码", trigger: "blur" }
  441. // ],
  442. status: [
  443. { required: true, message: "状态不能为空", trigger: "change" }
  444. ]
  445. },
  446. projectOptions: []
  447. };
  448. },
  449. created() {
  450. getUserList().then(res=>{
  451. if(res.code === 200) {
  452. this.companyUserList = res.data
  453. }
  454. });
  455. this.getList();
  456. this.getDicts("sys_user_status").then(response => {
  457. this.userOptions = response.data;
  458. });
  459. this.getDicts("sys_company_or").then(response => {
  460. this.orOptions = response.data;
  461. });
  462. this.getDicts("user_status").then(response => {
  463. this.statusOptions = response.data;
  464. });
  465. this.getDicts("sys_course_project").then(response => {
  466. this.projectOptions = response.data;
  467. });
  468. this.getTagOptions();
  469. this.getSalesOptions();
  470. },
  471. methods: {
  472. handledetails(row){
  473. this.show.open=true;
  474. setTimeout(() => {
  475. this.$refs.userDetails.getDetails(row.userId);
  476. }, 1);
  477. },
  478. /** 提交转移按钮 (如果使用对话框) */
  479. submitTransfer() {
  480. this.$refs["transferForm"].validate(valid => {
  481. if (valid) {
  482. transferUser({
  483. userIds: this.ids,
  484. targetCompanyUserId: this.transferForm.targetUserId,
  485. content: this.transferForm.content
  486. }).then(response => {
  487. if (response.code === 200) {
  488. this.msgSuccess(response.msg);
  489. this.openTransferDialog = false;
  490. this.getList();
  491. } else {
  492. this.msgError(response.msg || "转移失败");
  493. }
  494. }).catch(() => {
  495. this.msgError("转移请求失败");
  496. });
  497. }
  498. });
  499. },
  500. /** 转移按钮操作 */
  501. handleTransfer(row) {
  502. const userIds = row.userId ? [row.userId] : this.ids;
  503. if (userIds.length === 0) {
  504. this.$message.warning("请至少选择一个客户进行转移");
  505. return;
  506. }
  507. this.resetTransferForm();
  508. this.openTransferDialog = true;
  509. },
  510. // 重置表单
  511. resetForm() {
  512. this.linkForm={
  513. days:null,
  514. courseId:null,
  515. videoId:null
  516. }
  517. },
  518. resetTransferForm() {
  519. this.transferForm = {
  520. targetUserId: null,
  521. content: null
  522. };
  523. this.resetForm("transferForm"); // 假设 transferForm 是 el-form 的 ref
  524. },
  525. cancelTransfer() {
  526. this.openTransferDialog = false;
  527. this.resetTransferForm();
  528. },
  529. /** 查询用户列表 */
  530. getList() {
  531. this.loading = true;
  532. // 处理日期范围
  533. if (this.dateRange && this.dateRange.length > 0) {
  534. this.queryParams.registerStartTime = this.dateRange[0];
  535. this.queryParams.registerEndTime = this.dateRange[1];
  536. } else {
  537. this.queryParams.registerStartTime = null;
  538. this.queryParams.registerEndTime = null;
  539. }
  540. myListUser(this.queryParams).then(response => {
  541. console.log('我的会员列表查询结果:', response);
  542. this.userList = response.rows;
  543. this.total = response.total;
  544. this.loading = false;
  545. }).catch(error => {
  546. console.error('我的会员列表查询失败:', error);
  547. this.$message.error('查询会员列表失败,请稍后重试');
  548. this.loading = false;
  549. });
  550. },
  551. /** 获取标签选项 */
  552. getTagOptions() {
  553. this.tagOptions = [
  554. { tagId: "1", tagName: "VIP会员" },
  555. { tagId: "2", tagName: "普通会员" },
  556. { tagId: "3", tagName: "新用户" },
  557. { tagId: "4", tagName: "高频用户" }
  558. ];
  559. },
  560. /** 获取销售员工选项 */
  561. getSalesOptions() {
  562. this.salesOptions = [
  563. { userId: 1, nickName: "销售A" },
  564. { userId: 2, nickName: "销售B" },
  565. { userId: 3, nickName: "销售C" }
  566. ];
  567. },
  568. /** 获取看课状态类型 */
  569. getCourseStatusType(status) {
  570. if (status === 1) return "success";
  571. if (status === 2) return "danger";
  572. if (status === 3) return "info";
  573. return "";
  574. },
  575. /** 获取看课状态文本 */
  576. getCourseStatusText(status) {
  577. if (status === 1) return "正常看课";
  578. if (status === 2) return "停止看课";
  579. if (status === 3) return "未看过课";
  580. return "未知状态";
  581. },
  582. // 取消按钮
  583. cancel() {
  584. this.open = false;
  585. this.reset();
  586. },
  587. // 表单重置
  588. reset() {
  589. this.form = {
  590. userId: null,
  591. nickname: null,
  592. avatar: null,
  593. phone: null,
  594. status: 1,
  595. tagIds: [],
  596. companyUserId: null,
  597. remark: null
  598. };
  599. this.resetForm("form");
  600. },
  601. /** 搜索按钮操作 */
  602. handleQuery() {
  603. this.queryParams.pageNum = 1;
  604. this.getList();
  605. },
  606. /** 重置按钮操作 */
  607. resetQuery() {
  608. this.dateRange = [];
  609. this.resetForm("queryForm");
  610. this.handleQuery();
  611. },
  612. /** Tab切换操作 */
  613. handleTabChange() {
  614. this.queryParams.pageNum = 1;
  615. this.getList();
  616. },
  617. // 多选框选中数据
  618. handleSelectionChange(selection) {
  619. this.ids = selection.map(item => item.userId);
  620. this.single = selection.length !== 1;
  621. this.multiple = !selection.length;
  622. this.companyId = selection[0].companyId;
  623. this.companyUserId = selection[0].companyUserId;
  624. },
  625. /** 新增按钮操作 */
  626. handleAdd() {
  627. this.reset();
  628. this.open = true;
  629. this.title = "添加用户";
  630. },
  631. /** 修改按钮操作 */
  632. handleUpdate(row) {
  633. this.reset();
  634. const userId = row.userId || this.ids[0];
  635. getUser(userId).then(response => {
  636. this.form = response.data;
  637. // 处理标签数据,将字符串转为数组
  638. if (this.form.tagIds && typeof this.form.tagIds === 'string') {
  639. this.form.tagIds = this.form.tagIds.split(',');
  640. }
  641. this.open = true;
  642. this.title = "修改用户";
  643. });
  644. },
  645. /** 提交按钮 */
  646. submitForm() {
  647. this.$refs["form"].validate(valid => {
  648. if (valid) {
  649. // 处理标签数据,将数组转为字符串
  650. if (this.form.tagIds && Array.isArray(this.form.tagIds)) {
  651. this.form.tagIds = this.form.tagIds.join(',');
  652. }
  653. if (this.form.userId != null) {
  654. updateUser(this.form).then(response => {
  655. if (response.code === 200) {
  656. this.$message.success("修改成功");
  657. this.open = false;
  658. this.getList();
  659. }
  660. });
  661. } else {
  662. addUser(this.form).then(response => {
  663. if (response.code === 200) {
  664. this.$message.success("新增成功");
  665. this.open = false;
  666. this.getList();
  667. }
  668. });
  669. }
  670. }
  671. });
  672. },
  673. /** 删除按钮操作 */
  674. handleDelete(row) {
  675. const userIds = row.userId || this.ids;
  676. this.$confirm('是否确认删除用户编号为"' + userIds + '"的数据项?', "警告", {
  677. confirmButtonText: "确定",
  678. cancelButtonText: "取消",
  679. type: "warning"
  680. }).then(() => {
  681. return delUser(userIds);
  682. }).then(() => {
  683. this.getList();
  684. this.$message.success("删除成功");
  685. }).catch(() => {});
  686. },
  687. /** 导出按钮操作 */
  688. handleExport() {
  689. const queryParams = this.queryParams;
  690. this.$confirm('是否确认导出所有用户数据项?', "警告", {
  691. confirmButtonText: "确定",
  692. cancelButtonText: "取消",
  693. type: "warning"
  694. }).then(() => {
  695. return exportUser(queryParams);
  696. }).then(response => {
  697. this.download(response.msg);
  698. }).catch(() => {});
  699. },
  700. /** 审核会员操作 */
  701. handleAudit(row) {
  702. this.$confirm('是否确认将其移除小黑屋?', "提示", {
  703. confirmButtonText: "确定",
  704. cancelButtonText: "取消",
  705. type: "warning"
  706. }).then(() => {
  707. auditUser([row.userId]).then(response => {
  708. if (response.code === 200) {
  709. this.msgSuccess("审核成功");
  710. this.getList();
  711. }
  712. });
  713. }).catch(() => {});
  714. },
  715. /** 获取项目对应名称 */
  716. getProjectLabel(projectId) {
  717. return this.projectOptions.find(item => parseInt(item.dictValue) === projectId)?.dictLabel;
  718. },
  719. batchSend(){
  720. this.dialogVisible = true;
  721. },
  722. handleClose(){
  723. this.dialogVisible = false;
  724. }
  725. }
  726. };
  727. </script>
  728. <style scoped>
  729. .el-tag + .el-tag {
  730. margin-left: 5px;
  731. }
  732. .mb8 {
  733. margin-bottom: 8px;
  734. }
  735. </style>