deptWatchLog.vue 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940
  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="看课方式" prop="sendType">
  5. <el-select v-model="queryParams.sendType" placeholder="选择看课方式" clearable size="small" @change="handleSendTypeChange">
  6. <el-option
  7. v-for="dict in sendTypeOptions"
  8. :key="dict.dictValue"
  9. :label="dict.dictLabel"
  10. :value="dict.dictValue"
  11. />
  12. </el-select>
  13. </el-form-item>
  14. <el-form-item label="会员ID" prop="userId">
  15. <el-input
  16. v-model="queryParams.userId"
  17. placeholder="请输入会员ID"
  18. clearable
  19. size="small"
  20. @keyup.enter.native="handleQuery"
  21. />
  22. </el-form-item>
  23. <el-form-item label="会员昵称" prop="nickName">
  24. <el-input
  25. v-model="queryParams.nickName"
  26. placeholder="请输入会员昵称"
  27. clearable
  28. size="small"
  29. @keyup.enter.native="handleQuery"
  30. />
  31. </el-form-item>
  32. <el-form-item label="企微客户昵称" prop="nickName" >
  33. <el-input
  34. v-model="queryParams.externalUserName"
  35. placeholder="请输入企微客户昵称"
  36. clearable
  37. size="small"
  38. @keyup.enter.native="handleQuery"
  39. />
  40. </el-form-item>
  41. <el-form-item label="所属销售" prop="companyUserId">
  42. <el-select v-model="queryParams.companyUserId" clearable filterable remote
  43. placeholder="请输入关键词" :remote-method="loadCompanyUserOptions"
  44. v-select-load-more="loadMoreCompanyUserOptions"
  45. :loading="companyUserOptionsLoading">
  46. <el-option
  47. v-for="item in companyUserOptions"
  48. :key="item.dictValue"
  49. :label="item.dictLabel"
  50. :value="item.dictValue">
  51. </el-option>
  52. </el-select>
  53. </el-form-item>
  54. <el-form-item label="课程" prop="courseId">
  55. <el-select filterable v-model="queryParams.courseId" placeholder="请选择课程" clearable size="small" @change="courseChange(queryParams.courseId)">
  56. <el-option
  57. v-for="dict in courseLists"
  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="videoId">
  65. <el-select filterable v-model="queryParams.videoId" placeholder="请选择小节" clearable size="small">
  66. <el-option
  67. v-for="dict in videoList"
  68. :key="dict.dictValue"
  69. :label="dict.dictLabel"
  70. :value="dict.dictValue"
  71. />
  72. </el-select>
  73. </el-form-item>
  74. <!-- sop名称 -->
  75. <el-form-item label="SOP名称" prop="sopId" v-if="queryParams.sendType == 2">
  76. <el-autocomplete
  77. v-model="sopSearchText"
  78. :fetch-suggestions="querySopAsync"
  79. placeholder="请输入SOP名称"
  80. clearable
  81. size="small"
  82. style="width: 200px"
  83. @select="handleSopSelect"
  84. @clear="handleSopClear"
  85. :trigger-on-focus="false"
  86. >
  87. <template slot-scope="{ item }">
  88. <div class="sop-item">
  89. <span class="sop-name">{{ item.name }}</span>
  90. </div>
  91. </template>
  92. </el-autocomplete>
  93. </el-form-item>
  94. <el-form-item label="企微ID" prop="qwUserUserId">
  95. <el-input
  96. v-model="queryParams.qwUserUserId"
  97. placeholder="请输入所属企微ID"
  98. clearable
  99. size="small"
  100. @keyup.enter.native="handleQuery"
  101. />
  102. </el-form-item>
  103. <el-form-item label="企微员工名称" prop="qwUserName">
  104. <el-input
  105. v-model="queryParams.qwUserName"
  106. placeholder="请输入所属企微员工名称"
  107. clearable
  108. size="small"
  109. @keyup.enter.native="handleQuery"
  110. />
  111. </el-form-item>
  112. <!-- <el-form-item label="部门名称" prop="deptName">-->
  113. <!-- <el-input-->
  114. <!-- v-model="queryParams.deptName"-->
  115. <!-- placeholder="请输入部门名称"-->
  116. <!-- clearable-->
  117. <!-- size="small"-->
  118. <!-- @keyup.enter.native="handleQuery"-->
  119. <!-- />-->
  120. <!-- </el-form-item>-->
  121. <!-- 营期时间 -->
  122. <el-form-item label="营期时间" prop="scheduleTime">
  123. <el-input
  124. v-model="scheduleTimeText"
  125. placeholder="请选择营期时间"
  126. readonly
  127. @click.native="showScheduleCalendar = true"
  128. />
  129. <calendar
  130. v-model="scheduleTime"
  131. mode="during"
  132. :show.sync="showScheduleCalendar"
  133. @change="handleScheduleTimeChange"
  134. :key="scheduleCalendarKey"
  135. />
  136. </el-form-item>
  137. <!-- 创建时间 -->
  138. <el-form-item label="创建时间" prop="createTime">
  139. <el-input
  140. v-model="createTimeText"
  141. placeholder="请选择创建时间"
  142. readonly
  143. @click.native="showCreateCalendar = true"
  144. />
  145. <calendar
  146. v-model="createTime"
  147. mode="during"
  148. :show.sync="showCreateCalendar"
  149. @change="createChange"
  150. :key="createCalendarKey"
  151. />
  152. </el-form-item>
  153. <!-- 最新更新时间 -->
  154. <el-form-item label="最新更新时间" prop="updateTime">
  155. <el-input
  156. v-model="updateTimeText"
  157. placeholder="请选择更新时间"
  158. readonly
  159. @click.native="showUpdateCalendar = true"
  160. />
  161. <calendar
  162. v-model="updateTime"
  163. mode="during"
  164. :show.sync="showUpdateCalendar"
  165. @change="updateChange"
  166. :key="updateCalendarKey"
  167. />
  168. </el-form-item>
  169. <!-- 进线时间 -->
  170. <el-form-item label="进线时间" prop="qecCreateTime">
  171. <el-input
  172. v-model="qecCreateTimeText"
  173. placeholder="请选择进线时间"
  174. readonly
  175. @click.native="showQecCalendar = true"
  176. />
  177. <calendar
  178. v-model="qecCreateTime"
  179. mode="during"
  180. :show.sync="showQecCalendar"
  181. @change="qecCreateTimeChange"
  182. :key="qecCalendarKey"
  183. />
  184. </el-form-item>
  185. <el-form-item>
  186. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  187. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  188. </el-form-item>
  189. </el-form>
  190. <!-- <el-row :gutter="10" class="mb8">-->
  191. <!-- <el-col :span="1.5">-->
  192. <!-- <el-button-->
  193. <!-- type="warning"-->
  194. <!-- plain-->
  195. <!-- icon="el-icon-download"-->
  196. <!-- size="mini"-->
  197. <!-- :loading="exportLoading"-->
  198. <!-- @click="handleExport"-->
  199. <!-- v-hasPermi="['course:courseWatchLog:export']"-->
  200. <!-- >导出</el-button>-->
  201. <!-- </el-col>-->
  202. <!-- <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>-->
  203. <!-- </el-row>-->
  204. <el-tabs type="card" v-model="activeName" @tab-click="handleClickX">
  205. <el-tab-pane label="全部" name="00"></el-tab-pane>
  206. <el-tab-pane v-for="(item,index) in logTypeOptions" :label="item.dictLabel" :name="item.dictValue"></el-tab-pane>
  207. </el-tabs>
  208. <el-table border v-loading="loading" :data="courseWatchLogList" @selection-change="handleSelectionChange">
  209. <el-table-column type="selection" width="55" align="center" />
  210. <el-table-column label="记录编号" align="center" prop="logId" />
  211. <el-table-column label="企微客户" align="center" prop="externalUserName"/>
  212. <el-table-column label="客户头像" align="center" prop="externalUserAvatar">
  213. <template slot-scope="scope">
  214. <el-popover
  215. placement="right"
  216. trigger="hover">
  217. <img slot="reference" :src="scope.row.externalUserAvatar" style="width: 40px;height: 40px">
  218. <img :src="scope.row.externalUserAvatar" style="max-width: 250px;max-height: 250px">
  219. </el-popover>
  220. </template>
  221. </el-table-column>
  222. <el-table-column label="会员ID" align="center" prop="userId" />
  223. <el-table-column label="会员昵称" align="center" prop="fsNickName">
  224. <template slot-scope="scope">
  225. <div style="display: flex;white-space: nowrap">
  226. <div style="margin: auto">
  227. {{scope.row.fsNickName}}
  228. </div>
  229. <el-popover
  230. placement="right"
  231. title=""
  232. trigger="hover">
  233. <img slot="reference" :src="scope.row.fsAvatar" style="width: 30px;height: 30px">
  234. <img :src="scope.row.fsAvatar" style="max-width: 200px;max-height: 200px">
  235. </el-popover>
  236. </div>
  237. </template>
  238. </el-table-column>
  239. <el-table-column label="课程名称" align="center" prop="courseName" />
  240. <el-table-column label="小节名称" align="center" prop="videoName" />
  241. <el-table-column label="记录类型" align="center" prop="logType">
  242. <template slot-scope="scope">
  243. <dict-tag :options="logTypeOptions" :value="scope.row.logType"/>
  244. </template>
  245. </el-table-column>
  246. <el-table-column label="播放时长" align="center" prop="duration" />
  247. <el-table-column label="所属销售" align="center" prop="companyUserName" />
  248. <!-- <el-table-column label="所属公司" align="center" prop="companyName" />-->
  249. <el-table-column label="企微员工名称" align="center" prop="qwUserName" />
  250. <!-- <el-table-column label="所属发送方式" align="center" prop="sendType" />-->
  251. <el-table-column label="创建时间" align="center" prop="createTime" />
  252. <el-table-column label="更新时间" align="center" prop="updateTime" />
  253. <el-table-column label="完课时间" align="center" prop="finishTime" />
  254. <el-table-column label="营期时间" align="center" prop="campPeriodTime" />
  255. <el-table-column label="进线时间" align="center" prop="qecCreateTime" />
  256. <el-table-column
  257. fixed="right"
  258. label="操作"
  259. width="100">
  260. <template slot-scope="scope">
  261. <el-button @click="openAnswerLogFun(scope.row)" type="text" size="small">答题记录</el-button>
  262. <el-button @click="openRedLogFun(scope.row)" type="text" size="small">红包记录</el-button>
  263. </template>
  264. </el-table-column>
  265. </el-table>
  266. <pagination
  267. v-show="total>0"
  268. :total="total"
  269. :page.sync="queryParams.pageNum"
  270. :limit.sync="queryParams.pageSize"
  271. @pagination="getList"
  272. />
  273. <el-drawer title="答题记录" :visible.sync="openAnswerLog" size="70%" append-to-body>
  274. <el-table border v-loading="" :data="answerLogsList">
  275. <el-table-column label="会员用户" align="center" prop="userName">
  276. <template slot-scope="scope">
  277. <div style="display: flex;white-space: nowrap">
  278. <div style="margin: auto">
  279. {{ scope.row.userName }}
  280. </div>
  281. <el-popover
  282. placement="right"
  283. title=""
  284. trigger="hover">
  285. <img slot="reference" :src="scope.row.fsAvatar" style="width: 30px;height: 30px">
  286. <img :src="scope.row.fsAvatar" style="max-width: 200px;max-height: 200px">
  287. </el-popover>
  288. </div>
  289. </template>
  290. </el-table-column>
  291. <el-table-column label="课程名称" align="center" prop="courseName"/>
  292. <el-table-column label="小节名称" align="center" prop="videoName"/>
  293. <el-table-column label="是否全部正确" align="center" prop="isRight">
  294. <template slot-scope="scope">
  295. <dict-tag :options="sysCompanyOr" :value="scope.row.isRight"></dict-tag>
  296. </template>
  297. </el-table-column>
  298. <el-table-column label="销售名称" align="center" prop="companyUserName"/>
  299. <el-table-column label="企微员工名称" align="center" prop="qwUserName"/>
  300. <el-table-column label="公司名称" align="center" prop="companyName"/>
  301. <el-table-column label="创建时间" align="center" prop="createTime"/>
  302. </el-table>
  303. <pagination
  304. v-show="answerLogTotal>0"
  305. :total="answerLogTotal"
  306. :page.sync="answerLogQueryParams.pageNum"
  307. :limit.sync="answerLogQueryParams.pageSize"
  308. @pagination="answerLogList"
  309. />
  310. </el-drawer>
  311. <el-drawer title="红包记录" :visible.sync="openRedLog" size="70%" append-to-body>
  312. <el-table border v-loading="" :data="redLogsList">
  313. <el-table-column type="selection" width="55" align="center" />
  314. <el-table-column label="记录编号" align="center" prop="logId" />
  315. <el-table-column label="批次单号" align="center" prop="outBatchNo" />
  316. <el-table-column label="课程名称" align="center" prop="courseId" >
  317. <template slot-scope="scope">
  318. <span prop="status" v-for="(item, index) in courseLists" v-if="scope.row.courseId==item.dictValue">{{item.dictLabel}}</span>
  319. </template>
  320. </el-table-column>
  321. <el-table-column label="小节名称" align="center" prop="title" />
  322. <!-- <el-table-column label="会员id" align="center" prop="userId" />-->
  323. <el-table-column label="会员用户" align="center" prop="fsNickName">
  324. <template slot-scope="scope">
  325. <div style="display: flex;white-space: nowrap">
  326. <div style="margin: auto">
  327. {{scope.row.fsNickName}}
  328. </div>
  329. <el-popover
  330. placement="right"
  331. title=""
  332. trigger="hover">
  333. <img slot="reference" :src="scope.row.fsAvatar" style="width: 30px;height: 30px">
  334. <img :src="scope.row.fsAvatar" style="max-width: 200px;max-height: 200px">
  335. </el-popover>
  336. </div>
  337. </template>
  338. </el-table-column>
  339. <!-- <el-table-column label="会员电话" align="center" prop="phone" />-->
  340. <!-- <el-table-column label="所属销售" align="center" prop="companyUserName" />-->
  341. <!-- <el-table-column label="所属公司" align="center" prop="companyName" />-->
  342. <el-table-column label="转帐金额" align="center" prop="amount" />
  343. <el-table-column label="状态" align="center" prop="status" >
  344. <template slot-scope="scope">
  345. <el-tag>
  346. {{
  347. scope.row.status === 0 ? "发送中" :
  348. scope.row.status === 2 ? "待补发" :
  349. "已完成"
  350. }}
  351. </el-tag>
  352. </template>
  353. </el-table-column>
  354. <el-table-column label="所属企微" align="center" prop="qwUserName" />
  355. <el-table-column label="创建时间" align="center" prop="createTime" />
  356. </el-table>
  357. <pagination
  358. v-show="redLogTotal>0"
  359. :total="redLogTotal"
  360. :page.sync="redLogQueryParams.pageNum"
  361. :limit.sync="redLogQueryParams.pageSize"
  362. @pagination="redLogList"
  363. />
  364. </el-drawer>
  365. </div>
  366. </template>
  367. <script>
  368. import { deptListCourseWatchLog, getCourseWatchLog, delCourseWatchLog, addCourseWatchLog, updateCourseWatchLog, exportCourseWatchLog } from "@/api/course/courseWatchLog";
  369. import {courseList, myListCourseRedPacketLog, videoList} from '@/api/course/courseRedPacketLog'
  370. import {myListLogs} from "@/api/course/courseAnswerlogs";
  371. import { getCompanyUserListLikeName } from "@/api/company/companyUser";
  372. import {getTask} from "@/api/common";
  373. import Vue from 'vue'
  374. import Calendar from 'vue-mobile-calendar'
  375. import {infoSop} from "@/api/qw/sop";
  376. import {getMyQwUserList} from "@/api/qw/user";
  377. Vue.use(Calendar)
  378. export default {
  379. name: "CourseWatchLog",
  380. data() {
  381. return {
  382. sopSearchText: '', // SOP搜索框显示的文本
  383. selectedSopId: null, // 选中的SOP ID
  384. sendTypeOptions:[{
  385. dictLabel:"会员",dictValue:'1'
  386. },
  387. {
  388. dictLabel:"企微",dictValue:'2'
  389. }
  390. ],
  391. // 日历 key 控制刷新
  392. scheduleCalendarKey: 0,
  393. createCalendarKey: 0,
  394. updateCalendarKey: 0,
  395. qecCalendarKey: 0,
  396. createTimeText: '',
  397. scheduleTimeText: '', // 新增
  398. updateTimeText: '', // 新增
  399. qecCreateTimeText: '', // 新增
  400. scheduleTime: [], // 改为数组
  401. createTime: [], // 改为数组
  402. updateTime: [], // 改为数组
  403. qecCreateTime: [], // 改为数组
  404. // 控制日历显隐
  405. showScheduleCalendar: false,
  406. showCreateCalendar: false,
  407. showUpdateCalendar: false,
  408. showQecCalendar: false,
  409. activeName:"00",
  410. courseLists:[],
  411. videoList:[],
  412. logTypeOptions:[],
  413. // 遮罩层
  414. loading: true,
  415. // 导出遮罩层
  416. exportLoading: false,
  417. // 选中数组
  418. ids: [],
  419. // 非单个禁用
  420. single: true,
  421. // 非多个禁用
  422. multiple: true,
  423. // 显示搜索条件
  424. showSearch: true,
  425. // 总条数
  426. total: 0,
  427. // 短链课程看课记录表格数据
  428. courseWatchLogList: [],
  429. // 弹出层标题
  430. title: "",
  431. // 是否显示弹出层
  432. open: false,
  433. //答题记录
  434. openAnswerLog: false,
  435. loadingAnswerLog: true,
  436. answerLogsList: [],
  437. answerLogTotal: 0,
  438. answerLogQueryParams: {
  439. pageNum: 1,
  440. pageSize: 10,
  441. },
  442. //红包记录
  443. openRedLog: false,
  444. loadingRedLog: true,
  445. redLogsList: [],
  446. redLogTotal: 0,
  447. redLogQueryParams: {
  448. pageNum: 1,
  449. pageSize: 10,
  450. },
  451. pickerOptions: {
  452. disabledDate(time) {
  453. // 获取6天前的日期(加上今天就是7天)
  454. const sixDaysAgo = new Date();
  455. sixDaysAgo.setDate(sixDaysAgo.getDate() - 6);
  456. sixDaysAgo.setHours(0, 0, 0, 0);
  457. // 获取明天的日期(不包括今天)
  458. const tomorrow = new Date();
  459. tomorrow.setDate(tomorrow.getDate() + 1);
  460. tomorrow.setHours(0, 0, 0, 0);
  461. return time.getTime() < sixDaysAgo.getTime() || time.getTime() >= tomorrow.getTime();
  462. }
  463. },
  464. // 查询参数
  465. queryParams: {
  466. pageNum: 1,
  467. pageSize: 10,
  468. userId: null,
  469. nickName: null,
  470. videoId: null,
  471. logType: null,
  472. qwExternalContactId: null,
  473. externalUserName:null,
  474. duration: null,
  475. qwUserId: null,
  476. qwUserName: null, //企微名称
  477. qwUserUserId: null, //企微id
  478. deptName: null, //部门名称
  479. companyUserId: null,
  480. companyId: null,
  481. courseId: null,
  482. sTime:null,
  483. eTime:null,
  484. upSTime:null,
  485. upETime:null,
  486. qecSTime:null,
  487. qecETime:null,
  488. scheduleStartTime: null,
  489. scheduleEndTime: null,
  490. sendType:process.env.VUE_APP_COURSE_DEFAULT,
  491. sopId: null, // sopId
  492. },
  493. // 表单参数
  494. form: {},
  495. // 表单校验
  496. rules: {
  497. },
  498. // 员工选项列表
  499. companyUserOptionsParams: {
  500. name: undefined,
  501. hasNextPage: false,
  502. pageNum: 1,
  503. pageSize: 10
  504. },
  505. companyUserOptionsLoading: false,
  506. companyUserOptions: [],
  507. };
  508. },
  509. created() {
  510. courseList().then(response => {
  511. this.courseLists = response.list;
  512. });
  513. this.getList();
  514. this.getDicts("sys_course_watch_log_type").then(response => {
  515. this.logTypeOptions = response.data;
  516. });
  517. },
  518. methods: {
  519. handleSendTypeChange() {
  520. this.handleQuery(); // 重新查询列表
  521. },
  522. // 重置日历组件
  523. resetCalendars() {
  524. this.scheduleTime = [];
  525. this.createTime = [];
  526. this.updateTime = [];
  527. this.qecCreateTime = [];
  528. this.scheduleTimeText = '';
  529. this.createTimeText = '';
  530. this.updateTimeText = '';
  531. this.qecCreateTimeText = '';
  532. // 强制刷新日历组件
  533. this.scheduleCalendarKey++;
  534. this.createCalendarKey++;
  535. this.updateCalendarKey++;
  536. this.qecCalendarKey++;
  537. },
  538. formatDateRange(dates) {
  539. if (!dates || dates.length < 2) return '';
  540. return dates.map(date => date.format('YYYY-MM-DD')).join(' ~ ');
  541. },
  542. courseChange(row){
  543. this.queryParams.videoId=null;
  544. if(row === ''){
  545. this.videoList=[];
  546. return
  547. }
  548. videoList(row).then(response => {
  549. this.videoList=response.list
  550. });
  551. },
  552. handleClickX(tab,event){
  553. this.activeName=tab.name;
  554. if(tab.name=="00"){
  555. this.queryParams.logType=null;
  556. }else{
  557. this.queryParams.logType=tab.name;
  558. }
  559. this.getList()
  560. },
  561. /** 查询短链课程看课记录列表 */
  562. getList() {
  563. this.loading = true;
  564. if(this.queryParams.logType == "10"){
  565. this.queryParams.logType = null;
  566. }
  567. deptListCourseWatchLog(this.queryParams).then(response => {
  568. this.courseWatchLogList = response.rows;
  569. this.total = response.total;
  570. this.loading = false;
  571. });
  572. },
  573. // 取消按钮
  574. cancel() {
  575. this.open = false;
  576. this.reset();
  577. },
  578. // 表单重置
  579. reset() {
  580. this.form = {
  581. logId: null,
  582. userId: null,
  583. videoId: null,
  584. logType: null,
  585. createTime: null,
  586. updateTime: null,
  587. qwExternalContactId: null,
  588. externalUserName:null,
  589. duration: null,
  590. qwUserId: null,
  591. companyUserId: null,
  592. companyId: null,
  593. courseId: null,
  594. scheduleStartTime: null,
  595. scheduleEndTime: null,
  596. };
  597. this.scheduleTime=null;
  598. this.resetForm("form");
  599. },
  600. /** 搜索按钮操作 */
  601. handleQuery() {
  602. this.queryParams.pageNum = 1;
  603. this.getList();
  604. },
  605. /** 重置按钮操作 */
  606. resetQuery() {
  607. this.resetForm("queryForm");
  608. this.createTime = null;
  609. this.scheduleTime = null;
  610. this.qecCreateTime=null;
  611. this.queryParams.sTime = null;
  612. this.queryParams.eTime = null;
  613. this.queryParams.upSTime = null;
  614. this.queryParams.upETime = null;
  615. this.queryParams.qecSTime = null;
  616. this.queryParams.qecETime = null;
  617. this.queryParams.scheduleStartTime = null;
  618. this.queryParams.scheduleEndTime = null;
  619. this.queryParams.sopId = null; // 重置SOP ID
  620. this.scheduleTime=null;
  621. this.updateTime=null;
  622. // 重置SOP搜索
  623. this.handleSopClear();
  624. // 统一重置日历组件
  625. this.resetCalendars();
  626. this.handleQuery();
  627. },
  628. // 多选框选中数据
  629. handleSelectionChange(selection) {
  630. this.ids = selection.map(item => item.logId)
  631. this.single = selection.length!==1
  632. this.multiple = !selection.length
  633. },
  634. /** 新增按钮操作 */
  635. handleAdd() {
  636. this.reset();
  637. this.open = true;
  638. this.title = "添加短链课程看课记录";
  639. },
  640. /** 修改按钮操作 */
  641. handleUpdate(row) {
  642. this.reset();
  643. const logId = row.logId || this.ids
  644. getCourseWatchLog(logId).then(response => {
  645. this.form = response.data;
  646. this.open = true;
  647. this.title = "修改短链课程看课记录";
  648. });
  649. },
  650. /** 提交按钮 */
  651. submitForm() {
  652. this.$refs["form"].validate(valid => {
  653. if (valid) {
  654. if (this.form.logId != null) {
  655. updateCourseWatchLog(this.form).then(response => {
  656. this.msgSuccess("修改成功");
  657. this.open = false;
  658. this.getList();
  659. });
  660. } else {
  661. addCourseWatchLog(this.form).then(response => {
  662. this.msgSuccess("新增成功");
  663. this.open = false;
  664. this.getList();
  665. });
  666. }
  667. }
  668. });
  669. },
  670. /** 删除按钮操作 */
  671. handleDelete(row) {
  672. const logIds = row.logId || this.ids;
  673. this.$confirm('是否确认删除短链课程看课记录编号为"' + logIds + '"的数据项?', "警告", {
  674. confirmButtonText: "确定",
  675. cancelButtonText: "取消",
  676. type: "warning"
  677. }).then(function() {
  678. return delCourseWatchLog(logIds);
  679. }).then(() => {
  680. this.getList();
  681. this.msgSuccess("删除成功");
  682. }).catch(() => {});
  683. },
  684. /** 导出按钮操作 */
  685. handleExport() {
  686. const that = this
  687. const queryParams = this.queryParams;
  688. this.$confirm('是否确认导出所有短链课程看课记录数据项?', "警告", {
  689. confirmButtonText: "确定",
  690. cancelButtonText: "取消",
  691. type: "warning"
  692. }).then(() => {
  693. this.exportLoading = true;
  694. return exportCourseWatchLog(queryParams);
  695. }).then(response => {
  696. if (response.code === 200){
  697. that.msgSuccess(response.msg);
  698. that.taskId = response.data;
  699. that.time = setInterval(function(){
  700. //查订单
  701. getTask(that.taskId).then(res => {
  702. if(res.data.status === 1){
  703. that.exportLoading = false;
  704. clearTimeout(that.time)
  705. that.time = null;
  706. that.download(res.data.fileUrl);
  707. }
  708. });
  709. },10000);
  710. } else {
  711. that.msgError(response.msg)
  712. that.exportLoading = false
  713. }
  714. }).catch(() => {});
  715. },
  716. openAnswerLogFun(row) {
  717. this.openAnswerLog = true;
  718. this.answerLogQueryParams.watchLogId = row.logId;
  719. this.answerLogList();
  720. },
  721. answerLogList() {
  722. this.loadingAnswerLog = true;
  723. myListLogs(this.answerLogQueryParams).then(e => {
  724. this.answerLogsList = e.rows;
  725. this.answerLogTotal = e.total;
  726. this.loadingAnswerLog = false;
  727. })
  728. },
  729. openRedLogFun(row) {
  730. this.openRedLog = true;
  731. this.redLogQueryParams.watchLogId = row.logId;
  732. this.redLogList();
  733. },
  734. redLogList() {
  735. this.loadingRedLog = true;
  736. console.info("------------dept",this.redLogQueryParams)
  737. myListCourseRedPacketLog(this.redLogQueryParams).then(e => {
  738. this.redLogsList = e.rows;
  739. this.redLogTotal = e.total;
  740. this.loadingRedLog = false;
  741. })
  742. },
  743. // 营期时间
  744. handleScheduleTimeChange(scheduleTime) {
  745. if (scheduleTime && scheduleTime.length >= 2) {
  746. this.scheduleTimeText = this.formatDateRange(scheduleTime);
  747. this.queryParams.scheduleStartTime = scheduleTime.map(date => date.format('YYYY-MM-DD'))[0] || null;
  748. this.queryParams.scheduleEndTime = scheduleTime.map(date => date.format('YYYY-MM-DD'))[1] || null;
  749. } else {
  750. this.scheduleTimeText = '';
  751. this.queryParams.scheduleStartTime = null;
  752. this.queryParams.scheduleEndTime = null;
  753. }
  754. },
  755. // 创建时间
  756. createChange(createTime) {
  757. if (createTime && createTime.length >= 2) {
  758. this.createTimeText = this.formatDateRange(createTime);
  759. this.queryParams.sTime = createTime.map(date => date.format('YYYY-MM-DD'))[0] || null;
  760. this.queryParams.eTime = createTime.map(date => date.format('YYYY-MM-DD'))[1] || null;
  761. } else {
  762. this.createTimeText = '';
  763. this.queryParams.sTime = null;
  764. this.queryParams.eTime = null;
  765. }
  766. },
  767. // 更新时间
  768. updateChange(updateTime) {
  769. if (updateTime && updateTime.length >= 2) {
  770. this.updateTimeText = this.formatDateRange(updateTime);
  771. this.queryParams.upSTime = updateTime.map(date => date.format('YYYY-MM-DD'))[0] || null;
  772. this.queryParams.upETime = updateTime.map(date => date.format('YYYY-MM-DD'))[1] || null;
  773. } else {
  774. this.updateTimeText = '';
  775. this.queryParams.upSTime = null;
  776. this.queryParams.upETime = null;
  777. }
  778. },
  779. // 进线时间
  780. qecCreateTimeChange(qecCreateTime) {
  781. if (qecCreateTime && qecCreateTime.length >= 2) {
  782. // 检查选择的日期范围是否超过7天(包括起始和结束日期)
  783. const startDate = new Date(qecCreateTime[0]);
  784. const endDate = new Date(qecCreateTime[1]);
  785. // 设置时间为当天开始,避免时间部分影响计算
  786. startDate.setHours(0, 0, 0, 0);
  787. endDate.setHours(0, 0, 0, 0);
  788. const timeDiff = Math.abs(endDate - startDate);
  789. const diffDays = Math.ceil(timeDiff / (1000 * 60 * 60 * 24));
  790. // 如果超过6天的范围(总共7天,包括起始日)
  791. if (diffDays > 6) {
  792. this.$message.error('进线时间选择范围不能超过7天');
  793. // 清空选择
  794. this.qecCreateTime = [];
  795. this.qecCreateTimeText = '';
  796. this.queryParams.qecSTime = null;
  797. this.queryParams.qecETime = null;
  798. this.qecCalendarKey++;
  799. return;
  800. }
  801. this.qecCreateTimeText = this.formatDateRange(qecCreateTime);
  802. this.queryParams.qecSTime = qecCreateTime.map(date => date.format('YYYY-MM-DD'))[0] || null;
  803. this.queryParams.qecETime = qecCreateTime.map(date => date.format('YYYY-MM-DD'))[1] || null;
  804. } else {
  805. this.qecCreateTimeText = '';
  806. this.queryParams.qecSTime = null;
  807. this.queryParams.qecETime = null;
  808. }
  809. },
  810. /**
  811. * 根据名称模糊查询用户列表
  812. * @param query 参数
  813. */
  814. loadCompanyUserOptions(query) {
  815. this.companyUserOptions = [];
  816. if (query === '') {
  817. return;
  818. }
  819. this.companyUserOptionsParams.pageNum = 1
  820. this.companyUserOptionsParams.name = query
  821. this.companyUserOptionsLoading = true;
  822. this.getCompanyUserListLikeName()
  823. },
  824. /**
  825. * 获取员工列表
  826. */
  827. getCompanyUserListLikeName() {
  828. getCompanyUserListLikeName(this.companyUserOptionsParams).then(response => {
  829. this.companyUserOptions = [...this.companyUserOptions, ...response.data.list]
  830. this.companyUserOptionsParams.hasNextPage = response.data.hasNextPage
  831. this.companyUserOptionsLoading = false;
  832. });
  833. },
  834. /**
  835. * 加载更多员工选项
  836. */
  837. loadMoreCompanyUserOptions() {
  838. if (!this.companyUserOptionsParams.hasNextPage) {
  839. return;
  840. }
  841. this.companyUserOptionsParams.pageNum += 1
  842. this.getCompanyUserListLikeName()
  843. },
  844. /**
  845. * 选择SOP
  846. * @param {object} item - 选中的SOP项
  847. */
  848. handleSopSelect(item) {
  849. this.selectedSopId = item.id;
  850. this.queryParams.sopId = item.id;
  851. this.sopSearchText = item.name;
  852. },
  853. /**
  854. * 清空SOP选择
  855. */
  856. handleSopClear() {
  857. this.selectedSopId = null;
  858. this.queryParams.sopId = null;
  859. this.sopSearchText = '';
  860. },
  861. /**
  862. * 异步查询SOP列表
  863. * @param {string} queryString - 查询字符串
  864. * @param {function} callback - 回调函数
  865. */
  866. querySopAsync(queryString, callback) {
  867. if (!queryString) {
  868. callback([]);
  869. return;
  870. }
  871. infoSop({ name: queryString }).then(response => {
  872. if (response && response.rows) {
  873. const suggestions = response.rows.map(item => ({
  874. value: item.name,
  875. id: item.id,
  876. name: item.name
  877. }));
  878. callback(suggestions);
  879. } else {
  880. callback([]);
  881. }
  882. }).catch(error => {
  883. console.error('通过sop查询失败:', error);
  884. callback([]);
  885. });
  886. },
  887. updateQwuser() {
  888. for (const user of this.myQwUserList) {
  889. if (user.dictValue == this.queryParams.qwUserId) {
  890. this.queryParams.corpId = user.corpId;
  891. break;
  892. }
  893. }
  894. this.getList();
  895. },
  896. }
  897. };
  898. </script>