mylist.vue 27 KB

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