indexApp.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px">
  4. <el-form-item label="会员ID" prop="userId">
  5. <el-input
  6. v-model="queryParams.userId"
  7. placeholder="请输入会员ID"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="会员昵称" prop="nickName">
  14. <el-input
  15. v-model="queryParams.nickName"
  16. placeholder="请输入会员昵称"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item label="所属客服" prop="appCustomerId">
  23. <el-select v-model="queryParams.appCustomerId" clearable filterable remote
  24. placeholder="请输入关键词" :remote-method="loadCompanyUserOptions"
  25. v-select-load-more="loadMoreCompanyUserOptions"
  26. :loading="companyUserOptionsLoading">
  27. <el-option
  28. v-for="item in companyUserOptions"
  29. :key="item.value"
  30. :label="item.label"
  31. :value="item.value">
  32. </el-option>
  33. </el-select>
  34. </el-form-item>
  35. <el-form-item label="课程" prop="courseId">
  36. <el-select filterable v-model="queryParams.courseId" placeholder="请选择课程" clearable size="small" @change="courseChange(queryParams.courseId)">
  37. <el-option
  38. v-for="dict in courseLists"
  39. :key="dict.dictValue"
  40. :label="(dict.remark || dict.dictLabel) + '(' + dict.dictValue + ')'"
  41. :value="dict.dictValue"
  42. >
  43. </el-option>
  44. </el-select>
  45. </el-form-item>
  46. <el-form-item label="小节" prop="videoId">
  47. <el-select filterable v-model="queryParams.videoId" placeholder="请选择小节" clearable size="small">
  48. <el-option
  49. v-for="dict in videoList"
  50. :key="dict.dictValue"
  51. :label="dict.dictLabel"
  52. :value="dict.dictValue"
  53. />
  54. </el-select>
  55. </el-form-item>
  56. <!-- <el-form-item label="是否为会员" prop="isVip">
  57. <el-select
  58. filterable
  59. v-model="queryParams.isVip"
  60. placeholder="请选择是否为会员"
  61. clearable size="small">
  62. <el-option
  63. v-for="dict in isVipList"
  64. :key="dict.dictValue"
  65. :label="dict.dictLabel"
  66. :value="dict.dictValue"
  67. />
  68. </el-select>
  69. </el-form-item> -->
  70. <el-form-item label="营期时间" prop="scheduleTime">
  71. <el-date-picker
  72. v-model="scheduleTime"
  73. type="daterange"
  74. size="small"
  75. style="width: 240px"
  76. value-format="yyyy-MM-dd"
  77. range-separator="-"
  78. start-placeholder="开始日期"
  79. end-placeholder="结束日期"
  80. @change="handleScheduleTimeChange">
  81. </el-date-picker>
  82. </el-form-item>
  83. <el-form-item label="创建时间" prop="createTime">
  84. <el-date-picker v-model="createTime" size="small" style="width: 220px" value-format="yyyy-MM-dd" type="daterange"
  85. range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" @change="createChange"></el-date-picker>
  86. </el-form-item>
  87. <el-form-item label="最新更新时间" prop="updateTime">
  88. <el-date-picker v-model="updateTime" size="small" style="width: 220px" value-format="yyyy-MM-dd" type="daterange"
  89. range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" @change="updateChange"></el-date-picker>
  90. </el-form-item>
  91. <el-form-item>
  92. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  93. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  94. </el-form-item>
  95. </el-form>
  96. <el-row :gutter="10" class="mb8">
  97. <el-col :span="1.5">
  98. <el-button
  99. type="warning"
  100. plain
  101. icon="el-icon-download"
  102. size="mini"
  103. :loading="exportLoading"
  104. @click="handleExport"
  105. v-hasPermi="['course:courseWatchLog:export']"
  106. >导出</el-button>
  107. </el-col>
  108. <el-col :span="1.5">
  109. <el-button
  110. type="primary"
  111. plain
  112. size="mini"
  113. v-hasPermi="['app:user:bindTag']"
  114. @click="openBindTagPage(false, 0)"
  115. >批量添加标签
  116. </el-button>
  117. </el-col>
  118. <el-col :span="1.5">
  119. <el-button
  120. type="info"
  121. plain
  122. size="mini"
  123. v-hasPermi="['app:user:unbindTag']"
  124. @click="openUnbindTagPage(false, 1)"
  125. >批量移除标签
  126. </el-button>
  127. </el-col>
  128. <el-col :span="1.5">
  129. <el-button
  130. type="primary"
  131. plain
  132. size="mini"
  133. v-hasPermi="['app:user:batchBindTag']"
  134. @click="openBindTagPage(true, 0)"
  135. >批量添加标签(筛选条件)
  136. </el-button>
  137. </el-col>
  138. <el-col :span="1.5">
  139. <el-button
  140. type="info"
  141. plain
  142. size="mini"
  143. v-hasPermi="['app:user:batchUnbindTag']"
  144. @click="openUnbindTagPage(true, 1)"
  145. >批量移除标签(筛选条件)
  146. </el-button>
  147. </el-col>
  148. <el-col :span="1.5">
  149. <el-button
  150. type="success"
  151. plain
  152. size="mini"
  153. @click="openRemarkPage(false)"
  154. >批量修改备注
  155. </el-button>
  156. </el-col>
  157. <el-col :span="1.5">
  158. <el-button
  159. type="success"
  160. plain
  161. size="mini"
  162. @click="openRemarkPage(true)"
  163. >批量修改备注(筛选条件)
  164. </el-button>
  165. </el-col>
  166. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  167. </el-row>
  168. <el-tabs type="card" v-model="activeName" @tab-click="handleClickX">
  169. <el-tab-pane label="全部" name="00"></el-tab-pane>
  170. <el-tab-pane v-for="(item,index) in logTypeOptions" :label="item.dictLabel" :name="item.dictValue"></el-tab-pane>
  171. </el-tabs>
  172. <el-table border v-loading="loading" :data="courseWatchLogList" @selection-change="handleSelectionChange">
  173. <el-table-column type="selection" width="55" align="center" />
  174. <el-table-column label="记录编号" align="center" prop="logId" />
  175. <el-table-column label="客户备注" align="center" prop="remarkName"/>
  176. <el-table-column label="会员ID" align="center" prop="userId" />
  177. <el-table-column label="会员昵称" align="center" prop="fsNickName">
  178. <template slot-scope="scope">
  179. <div style="display: flex;white-space: nowrap">
  180. <div style="margin: auto">
  181. {{scope.row.fsNickName}}
  182. </div>
  183. <el-popover
  184. placement="right"
  185. title=""
  186. trigger="hover">
  187. <img slot="reference" :src="scope.row.fsAvatar" style="width: 30px;height: 30px">
  188. <img :src="scope.row.fsAvatar" style="max-width: 200px;max-height: 200px">
  189. </el-popover>
  190. </div>
  191. </template>
  192. </el-table-column>
  193. <el-table-column label="课程名称" align="center" prop="courseName" />
  194. <el-table-column label="小节名称" align="center" prop="videoName" />
  195. <el-table-column label="记录类型" align="center" prop="logType">
  196. <template slot-scope="scope">
  197. <dict-tag :options="logTypeOptions" :value="scope.row.logType"/>
  198. </template>
  199. </el-table-column>
  200. <el-table-column label="播放时长" align="center" prop="duration" />
  201. <el-table-column label="所属客服" align="center" prop="companyUserName" />
  202. <el-table-column label="创建时间" align="center" prop="createTime" />
  203. <el-table-column label="更新时间" align="center" prop="updateTime" />
  204. <el-table-column label="完课时间" align="center" prop="finishTime" />
  205. <el-table-column label="营期时间" align="center" prop="campPeriodTime" />
  206. </el-table>
  207. <pagination
  208. v-show="total>0"
  209. :total="total"
  210. :page.sync="queryParams.pageNum"
  211. :limit.sync="queryParams.pageSize"
  212. @pagination="getList"
  213. />
  214. <el-dialog :title="tagConfig.title" :visible.sync="tagConfig.visible" width="800px" append-to-body>
  215. <div>搜索标签:
  216. <el-input v-model="tagConfig.queryParams.groupName" placeholder="请输入标签名称" clearable size="small"
  217. style="width: 200px;margin-right: 10px"/>
  218. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleSearchTags">搜索</el-button>
  219. <el-button type="primary" icon="el-icon-refresh" size="mini" @click="cancelSearchTags">重置</el-button>
  220. </div>
  221. <div class="dialog-body">
  222. <div v-for="groupItem in tagConfig.tagGroupList" :key="groupItem.id">
  223. <div style="font-size: 20px;margin-top: 20px;margin-bottom: 20px;">
  224. <span class="name-background">{{ groupItem.name }}</span>
  225. </div>
  226. <div class="tag-container">
  227. <a
  228. v-for="tagItem in groupItem.tags"
  229. :key="tagItem.id"
  230. class="tag-box"
  231. @click="tagSelection(tagItem)"
  232. :class="{ 'tag-selected': tagItem.isSelected }"
  233. >
  234. {{ tagItem.name }}
  235. </a>
  236. </div>
  237. </div>
  238. </div>
  239. <pagination
  240. v-show="tagConfig.total > 0"
  241. :total="tagConfig.total"
  242. :page.sync="tagConfig.queryParams.pageNum"
  243. :limit.sync="tagConfig.queryParams.pageSize"
  244. @pagination="getTagGroupList"
  245. />
  246. <div slot="footer" class="dialog-footer">
  247. <el-button type="primary" @click="bindOrUnbindTagSubmit">确 定</el-button>
  248. <el-button @click="bindTagCancel">取 消</el-button>
  249. </div>
  250. </el-dialog>
  251. <el-dialog :title="remarkConfig.title" :visible.sync="remarkConfig.visible" width="600px" append-to-body>
  252. <el-form label-width="90px">
  253. <el-form-item label="备注类型">
  254. <el-radio-group v-model="remarkConfig.remarkType">
  255. <el-radio :label="1">用户名称添加在新备注前</el-radio>
  256. <el-radio :label="2">用户名称添加在新备注后</el-radio>
  257. <el-radio :label="3">不添加用户名称</el-radio>
  258. </el-radio-group>
  259. </el-form-item>
  260. <el-form-item label="备注内容">
  261. <el-input
  262. v-model="remarkConfig.remark"
  263. type="textarea"
  264. :rows="3"
  265. placeholder="请输入备注信息"
  266. maxlength="30"
  267. show-word-limit
  268. />
  269. </el-form-item>
  270. </el-form>
  271. <div slot="footer" class="dialog-footer">
  272. <el-button type="primary" :loading="remarkConfig.loading" @click="submitRemark">确 定</el-button>
  273. <el-button @click="cancelRemark">取 消</el-button>
  274. </div>
  275. </el-dialog>
  276. </div>
  277. </template>
  278. <script>
  279. import { listAppCourseWatchLog, exportAppCourseWatchLog, getCustomerListLikeName, batchUpdateFriendRemark } from "@/api/course/courseWatchLog";
  280. import { courseList,videoList } from '../../../api/course/courseRedPacketLog'
  281. import {getTask} from "@/api/common";
  282. import { listTagGroupForUserBindTag } from "@/api/app/tag/tagGroup";
  283. import {
  284. bindTagV2,
  285. unbindTagV2,
  286. } from "@/api/app/tag/bindTag";
  287. export default {
  288. name: "CourseWatchLog",
  289. data() {
  290. return {
  291. activeName:"00",
  292. createTime:null,
  293. updateTime:null,
  294. courseLists:[],
  295. videoList:[],
  296. logTypeOptions:[],
  297. // 遮罩层
  298. loading: true,
  299. // 导出遮罩层
  300. exportLoading: false,
  301. // 选中数组(会员userId)
  302. ids: [],
  303. // 非单个禁用
  304. single: true,
  305. // 非多个禁用
  306. multiple: true,
  307. // 显示搜索条件
  308. showSearch: true,
  309. // 总条数
  310. total: 0,
  311. // 短链科普学习记录表格数据
  312. courseWatchLogList: [],
  313. // 弹出层标题
  314. title: "",
  315. // 是否显示弹出层
  316. open: false,
  317. isVipList: [
  318. { dictLabel: '是', dictValue: 1 },
  319. { dictLabel: '否', dictValue: 0 }
  320. ],
  321. watchTypeList: [
  322. { dictLabel: 'app', dictValue: 1 },
  323. { dictLabel: '小程序', dictValue: 2 }
  324. ],
  325. // 查询参数
  326. queryParams: {
  327. pageNum: 1,
  328. pageSize: 10,
  329. userId: null,
  330. nickName: null,
  331. videoId: null,
  332. logType: null,
  333. qwExternalContactId: null,
  334. externalUserName:null,
  335. duration: null,
  336. qwUserId: null,
  337. qwUserName: null, //企微名称
  338. qwUserUserId: null, //企微id
  339. deptName: null, //部门名称
  340. companyUserId: null,
  341. companyId: null,
  342. courseId: null,
  343. sTime:null,
  344. eTime:null,
  345. upSTime:null,
  346. upETime:null,
  347. scheduleStartTime: null,
  348. scheduleEndTime: null,
  349. isVip: null,
  350. watchType:null,
  351. appCustomerId: null,
  352. },
  353. // 表单参数
  354. form: {},
  355. // 表单校验
  356. rules: {
  357. },
  358. scheduleTime: null,
  359. // 员工选项列表
  360. companyUserOptionsParams: {
  361. name: undefined,
  362. hasNextPage: false,
  363. pageNum: 1,
  364. pageSize: 10
  365. },
  366. companyUserOptionsLoading: false,
  367. companyUserOptions: [],
  368. tagConfig: {
  369. visible: false,
  370. enableFilter: false,
  371. title: null,
  372. opType: 0,//0-添加,1-移除
  373. queryParams: {
  374. groupName: null,
  375. pageNum: 1,
  376. pageSize: 10,
  377. },
  378. total: 0,
  379. tagGroupList: [],
  380. selected: [],
  381. },
  382. remarkConfig: {
  383. visible: false,
  384. enableFilter: false,
  385. title: '批量修改备注',
  386. remarkType: 1,
  387. remark: '',
  388. loading: false,
  389. },
  390. };
  391. },
  392. created() {
  393. courseList().then(response => {
  394. this.courseLists = response.list;
  395. });
  396. this.getList();
  397. this.getDicts("sys_course_watch_log_type").then(response => {
  398. this.logTypeOptions = response.data;
  399. });
  400. },
  401. methods: {
  402. courseChange(row){
  403. this.queryParams.videoId=null;
  404. if(row === ''){
  405. this.videoList=[];
  406. return
  407. }
  408. videoList(row).then(response => {
  409. this.videoList=response.list
  410. });
  411. },
  412. createChange() {
  413. if (this.createTime != null) {
  414. this.queryParams.sTime = this.createTime[0];
  415. this.queryParams.eTime = this.createTime[1];
  416. } else {
  417. this.queryParams.sTime = null;
  418. this.queryParams.eTime = null;
  419. }
  420. },
  421. updateChange(){
  422. if (this.updateTime != null) {
  423. this.queryParams.upSTime = this.updateTime[0];
  424. this.queryParams.upETime = this.updateTime[1];
  425. } else {
  426. this.queryParams.upSTime = null;
  427. this.queryParams.upETime = null;
  428. }
  429. },
  430. handleClickX(tab,event){
  431. this.activeName=tab.name;
  432. if(tab.name=="00"){
  433. this.queryParams.logType=null;
  434. }else{
  435. this.queryParams.logType=tab.name;
  436. }
  437. this.getList()
  438. },
  439. /** 查询短链科普学习记录列表 */
  440. getList() {
  441. this.loading = true;
  442. if(this.queryParams.logType == "10"){
  443. this.queryParams.logType = null;
  444. }
  445. listAppCourseWatchLog(this.queryParams).then(response => {
  446. this.courseWatchLogList = response.rows;
  447. this.total = response.total;
  448. this.loading = false;
  449. });
  450. },
  451. // 取消按钮
  452. cancel() {
  453. this.open = false;
  454. this.reset();
  455. },
  456. // 表单重置
  457. reset() {
  458. this.form = {
  459. logId: null,
  460. userId: null,
  461. videoId: null,
  462. logType: null,
  463. createTime: null,
  464. updateTime: null,
  465. qwExternalContactId: null,
  466. externalUserName:null,
  467. duration: null,
  468. qwUserId: null,
  469. companyUserId: null,
  470. companyId: null,
  471. courseId: null,
  472. scheduleStartTime: null,
  473. scheduleEndTime: null,
  474. };
  475. this.scheduleTime=null;
  476. this.resetForm("form");
  477. },
  478. /** 搜索按钮操作 */
  479. handleQuery() {
  480. this.queryParams.pageNum = 1;
  481. this.getList();
  482. },
  483. /** 重置按钮操作 */
  484. resetQuery() {
  485. this.resetForm("queryForm");
  486. this.createTime = null;
  487. this.scheduleTime = null;
  488. this.queryParams.sTime = null;
  489. this.queryParams.eTime = null;
  490. this.queryParams.upSTime = null;
  491. this.queryParams.upETime = null;
  492. this.queryParams.scheduleStartTime = null;
  493. this.queryParams.scheduleEndTime = null;
  494. this.scheduleTime=null;
  495. this.updateTime=null;
  496. this.handleQuery();
  497. },
  498. // 多选框选中数据(按会员userId去重,用于批量打标签)
  499. handleSelectionChange(selection) {
  500. this.ids = [...new Set(selection.map(item => item.userId).filter(id => id != null))]
  501. this.single = selection.length!==1
  502. this.multiple = !selection.length
  503. },
  504. /**
  505. * 用户绑定标签页面
  506. */
  507. openBindTagPage(enableFilter = false, opType = 0) {
  508. this.tagConfig.enableFilter = enableFilter;
  509. this.tagConfig.opType = opType;
  510. if (!enableFilter && (this.ids === null || this.ids.length === 0)) {
  511. this.$message.closeAll();
  512. return this.$message('请选择需要添加标签的用户');
  513. }
  514. this.getTagGroupList();
  515. this.tagConfig.title = '批量添加标签' + (enableFilter ? '(筛选条件)' : '');
  516. this.tagConfig.visible = true;
  517. },
  518. /**
  519. * 用户解绑标签页面
  520. */
  521. openUnbindTagPage(enableFilter = false, opType = 1) {
  522. this.tagConfig.enableFilter = enableFilter;
  523. this.tagConfig.opType = opType;
  524. if (!enableFilter && (this.ids === null || this.ids.length === 0)) {
  525. this.$message.closeAll();
  526. return this.$message('请选择需要移除标签的用户');
  527. }
  528. this.getTagGroupList();
  529. this.tagConfig.title = '批量移除标签' + (enableFilter ? '(筛选条件)' : '');
  530. this.tagConfig.visible = true;
  531. },
  532. /**
  533. * 绑定/解绑 标签页面搜索
  534. */
  535. handleSearchTags() {
  536. this.tagConfig.queryParams.pageNum = 1;
  537. this.getTagGroupList();
  538. },
  539. /**
  540. * 绑定/解绑 标签页面重置
  541. */
  542. cancelSearchTags() {
  543. this.tagConfig.queryParams = {
  544. groupName: null,
  545. pageNum: 1,
  546. pageSize: 10,
  547. }
  548. this.getTagGroupList();
  549. },
  550. /**
  551. * 切换选中状态
  552. * @param row
  553. */
  554. tagSelection(row) {
  555. row.isSelected = !row.isSelected;
  556. if (row.isSelected) {
  557. this.tagConfig.selected.push({ tagId: row.id, tagName: row.name });
  558. } else {
  559. this.tagConfig.selected = this.tagConfig.selected.filter(item => item.tagId !== row.id);
  560. }
  561. this.$forceUpdate();
  562. },
  563. /**
  564. * 重置 绑定/解绑 标签参数
  565. */
  566. resetBindTag() {
  567. this.tagConfig = {
  568. visible: false,
  569. enableFilter: false,
  570. title: null,
  571. opType: 0,
  572. queryParams: {
  573. groupName: null,
  574. pageNum: 1,
  575. pageSize: 10,
  576. },
  577. total: 0,
  578. tagGroupList: [],
  579. selected: [],
  580. }
  581. },
  582. /**
  583. * 绑定/解绑 标签-提交
  584. */
  585. bindOrUnbindTagSubmit() {
  586. let opType = this.tagConfig.opType;
  587. let tmpParam = {};
  588. if (!this.tagConfig.selected || this.tagConfig.selected.length === 0) {
  589. return this.$message('请选择标签');
  590. }
  591. tmpParam['enableFilter'] = this.tagConfig.enableFilter;
  592. tmpParam['tagId'] = this.tagConfig.selected.map(item => item.tagId);
  593. tmpParam['userId'] = this.ids;
  594. const queryParams = JSON.parse(JSON.stringify(this.queryParams));
  595. delete queryParams['startIndex'];
  596. delete queryParams['pageLimit'];
  597. tmpParam['fsUserParam'] = queryParams;
  598. //绑定标签
  599. if (opType === 0) {
  600. bindTagV2(tmpParam)
  601. .then(res => {
  602. this.tagConfig.visible = false;
  603. this.resetBindTag();
  604. this.msgSuccess("正在添加中!");
  605. setTimeout(() => {
  606. this.getList();
  607. }, 500);
  608. })
  609. .catch(err => {
  610. this.msgError("添加标签失败!");
  611. })
  612. }
  613. //解绑标签
  614. else {
  615. unbindTagV2(tmpParam)
  616. .then(res => {
  617. this.tagConfig.visible = false;
  618. this.msgSuccess("正在移除中!");
  619. this.resetBindTag();
  620. setTimeout(() => {
  621. this.getList();
  622. }, 500);
  623. })
  624. .catch(err => {
  625. this.msgError("移除标签失败!");
  626. })
  627. }
  628. },
  629. /**
  630. * 绑定/解绑 标签-取消
  631. */
  632. bindTagCancel() {
  633. this.resetBindTag();
  634. },
  635. /**
  636. * 查询标签列表
  637. */
  638. getTagGroupList() {
  639. listTagGroupForUserBindTag(this.tagConfig.queryParams).then(response => {
  640. this.tagConfig.tagGroupList = response.rows;
  641. this.tagConfig.total = response.total;
  642. });
  643. },
  644. /**
  645. * 打开批量修改备注弹窗
  646. * @param enableFilter 是否按筛选条件
  647. */
  648. openRemarkPage(enableFilter = false) {
  649. if (!enableFilter && (!this.ids || this.ids.length === 0)) {
  650. this.$message.closeAll();
  651. return this.$message('请选择需要修改备注的用户');
  652. }
  653. if (enableFilter && (!this.total || this.total <= 0)) {
  654. this.$message.closeAll();
  655. return this.$message('当前筛选条件下没有数据');
  656. }
  657. this.remarkConfig.enableFilter = enableFilter;
  658. this.remarkConfig.remarkType = 1;
  659. this.remarkConfig.remark = '';
  660. this.remarkConfig.loading = false;
  661. this.remarkConfig.title = '批量修改备注' + (enableFilter ? '(筛选条件)' : '');
  662. this.remarkConfig.visible = true;
  663. },
  664. cancelRemark() {
  665. this.remarkConfig.visible = false;
  666. this.remarkConfig.enableFilter = false;
  667. this.remarkConfig.remarkType = 1;
  668. this.remarkConfig.remark = '';
  669. this.remarkConfig.loading = false;
  670. },
  671. /**
  672. * 提交批量修改备注
  673. */
  674. async submitRemark() {
  675. const remark = (this.remarkConfig.remark || '').trim();
  676. if (!remark) {
  677. return this.$message.error('请输入备注内容');
  678. }
  679. if (remark.length > 30) {
  680. return this.$message.error('备注内容不能超过30个字符');
  681. }
  682. this.remarkConfig.loading = true;
  683. try {
  684. let userIds = [];
  685. if (this.remarkConfig.enableFilter) {
  686. // 按筛选条件拉取全部匹配记录的 userId
  687. const queryParams = JSON.parse(JSON.stringify(this.queryParams));
  688. queryParams.pageNum = 1;
  689. queryParams.pageSize = this.total > 0 ? this.total : 10000;
  690. if (queryParams.logType == "10") {
  691. queryParams.logType = null;
  692. }
  693. const response = await listAppCourseWatchLog(queryParams);
  694. const rows = response.rows || [];
  695. userIds = [...new Set(rows.map(item => item.userId).filter(id => id != null))];
  696. } else {
  697. userIds = this.ids;
  698. }
  699. if (!userIds || userIds.length === 0) {
  700. this.remarkConfig.loading = false;
  701. return this.$message.error('没有可修改备注的用户');
  702. }
  703. await batchUpdateFriendRemark({
  704. remarkType: this.remarkConfig.remarkType,
  705. remark,
  706. userId: userIds,
  707. });
  708. this.msgSuccess('正在修改备注中!');
  709. this.cancelRemark();
  710. setTimeout(() => {
  711. this.getList();
  712. }, 500);
  713. } catch (e) {
  714. this.msgError('修改备注失败!');
  715. } finally {
  716. this.remarkConfig.loading = false;
  717. }
  718. },
  719. /** 新增按钮操作 */
  720. handleAdd() {
  721. this.reset();
  722. this.open = true;
  723. this.title = "添加短链课程学习记录";
  724. },
  725. /** 提交按钮 */
  726. submitForm() {
  727. this.$refs["form"].validate(valid => {
  728. if (valid) {
  729. if (this.form.logId != null) {
  730. updateCourseWatchLog(this.form).then(response => {
  731. this.msgSuccess("修改成功");
  732. this.open = false;
  733. this.getList();
  734. });
  735. } else {
  736. addCourseWatchLog(this.form).then(response => {
  737. this.msgSuccess("新增成功");
  738. this.open = false;
  739. this.getList();
  740. });
  741. }
  742. }
  743. });
  744. },
  745. /** 导出按钮操作 */
  746. handleExport() {
  747. const that = this
  748. const queryParams = this.queryParams;
  749. this.$confirm('是否确认导出所有短链课程学习记录数据项?', "警告", {
  750. confirmButtonText: "确定",
  751. cancelButtonText: "取消",
  752. type: "warning"
  753. }).then(() => {
  754. this.exportLoading = true;
  755. return exportAppCourseWatchLog(queryParams);
  756. }).then(response => {
  757. this.download(response.msg);
  758. this.exportLoading = false;
  759. }).catch(() => {});
  760. },
  761. handleScheduleTimeChange(val) {
  762. if (val) {
  763. this.queryParams.scheduleStartTime = val[0];
  764. this.queryParams.scheduleEndTime = val[1];
  765. } else {
  766. this.queryParams.scheduleStartTime = null;
  767. this.queryParams.scheduleEndTime = null;
  768. }
  769. },
  770. /**
  771. * 根据名称模糊查询用户列表
  772. * @param query 参数
  773. */
  774. loadCompanyUserOptions(query) {
  775. this.companyUserOptions = [];
  776. if (query === '') {
  777. return;
  778. }
  779. this.companyUserOptionsParams.pageNum = 1
  780. this.companyUserOptionsParams.name = query
  781. this.companyUserOptionsLoading = true;
  782. this.getCompanyUserListLikeName()
  783. },
  784. /**
  785. * 获取员工列表
  786. */
  787. getCompanyUserListLikeName() {
  788. getCustomerListLikeName(this.companyUserOptionsParams).then(response => {
  789. this.companyUserOptions = [...this.companyUserOptions, ...response.data.list]
  790. this.companyUserOptionsParams.hasNextPage = response.data.hasNextPage
  791. this.companyUserOptionsLoading = false;
  792. });
  793. },
  794. /**
  795. * 加载更多员工选项
  796. */
  797. loadMoreCompanyUserOptions() {
  798. if (!this.companyUserOptionsParams.hasNextPage) {
  799. return;
  800. }
  801. this.companyUserOptionsParams.pageNum += 1
  802. this.getCompanyUserListLikeName()
  803. },
  804. }
  805. };
  806. </script>
  807. <style lang="scss" scoped>
  808. .dialog-body {
  809. height: 400px;
  810. overflow: auto;
  811. }
  812. .tag-container {
  813. display: flex;
  814. flex-wrap: wrap;
  815. gap: 8px;
  816. }
  817. .name-background {
  818. display: inline-block;
  819. background-color: #abece6;
  820. padding: 4px 8px;
  821. border-radius: 4px;
  822. }
  823. .tag-box {
  824. padding: 8px 12px;
  825. border: 1px solid #989797;
  826. border-radius: 4px;
  827. cursor: pointer;
  828. display: inline-block;
  829. }
  830. .tag-selected {
  831. background-color: #00bc98;
  832. color: #fff;
  833. border-color: #00bc98;
  834. }
  835. </style>