indexApp.vue 27 KB

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