deptWatchLog.vue 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199
  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 v-if="companyName === undefined || companyName === 1" 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 v-if="companyName==2" label="所属销售" prop="companyUserId">
  55. <el-select v-model="queryParams.companyUserId" clearable filterable remote
  56. placeholder="请输入关键词"
  57. v-select-load-more="loadMoreCompanyUserOptions"
  58. :loading="companyUserOptionsLoading">
  59. <el-option
  60. v-for="item in companyUserOptionsByAll"
  61. :key="item.dictValue"
  62. :label="item.dictLabel"
  63. :value="item.dictValue">
  64. </el-option>
  65. </el-select>
  66. </el-form-item>
  67. <el-form-item label="课程" prop="courseId">
  68. <el-select filterable v-model="queryParams.courseId" placeholder="请选择课程" clearable size="small" @change="courseChange(queryParams.courseId)">
  69. <el-option
  70. v-for="dict in courseLists"
  71. :key="dict.dictValue"
  72. :label="dict.dictLabel"
  73. :value="dict.dictValue"
  74. />
  75. </el-select>
  76. </el-form-item>
  77. <el-form-item label="小节" prop="videoId">
  78. <el-select filterable v-model="queryParams.videoId" placeholder="请选择小节" clearable size="small">
  79. <el-option
  80. v-for="dict in videoList"
  81. :key="dict.dictValue"
  82. :label="dict.dictLabel"
  83. :value="dict.dictValue"
  84. />
  85. </el-select>
  86. </el-form-item>
  87. <!-- sop名称 -->
  88. <el-form-item label="SOP名称" prop="sopId" v-if="queryParams.sendType == 2">
  89. <el-autocomplete
  90. v-model="sopSearchText"
  91. :fetch-suggestions="querySopAsync"
  92. placeholder="请输入SOP名称"
  93. clearable
  94. size="small"
  95. style="width: 200px"
  96. @select="handleSopSelect"
  97. @clear="handleSopClear"
  98. :trigger-on-focus="false"
  99. >
  100. <template slot-scope="{ item }">
  101. <div class="sop-item">
  102. <span class="sop-name">{{ item.name }}</span>
  103. </div>
  104. </template>
  105. </el-autocomplete>
  106. </el-form-item>
  107. <el-form-item label="企微ID" prop="qwUserUserId">
  108. <el-input
  109. v-model="queryParams.qwUserUserId"
  110. placeholder="请输入所属企微ID"
  111. clearable
  112. size="small"
  113. @keyup.enter.native="handleQuery"
  114. />
  115. </el-form-item>
  116. <el-form-item label="企微员工名称" prop="qwUserName">
  117. <el-input
  118. v-model="queryParams.qwUserName"
  119. placeholder="请输入所属企微员工名称"
  120. clearable
  121. size="small"
  122. @keyup.enter.native="handleQuery"
  123. />
  124. </el-form-item>
  125. <!-- <el-form-item label="部门名称" prop="deptName">-->
  126. <!-- <el-input-->
  127. <!-- v-model="queryParams.deptName"-->
  128. <!-- placeholder="请输入部门名称"-->
  129. <!-- clearable-->
  130. <!-- size="small"-->
  131. <!-- @keyup.enter.native="handleQuery"-->
  132. <!-- />-->
  133. <!-- </el-form-item>-->
  134. <!-- 营期时间 -->
  135. <!-- <el-form-item label="营期时间" prop="scheduleTime">
  136. <el-input
  137. v-model="scheduleTimeText"
  138. placeholder="请选择营期时间"
  139. readonly
  140. @click.native="showScheduleCalendar = true"
  141. />
  142. <calendar
  143. v-model="scheduleTime"
  144. mode="during"
  145. :show.sync="showScheduleCalendar"
  146. @change="handleScheduleTimeChange"
  147. :key="scheduleCalendarKey"
  148. />
  149. </el-form-item> -->
  150. <el-form-item label="营期时间" prop="scheduleTime">
  151. <el-date-picker
  152. v-model="scheduleTimeText"
  153. type="daterange"
  154. range-separator="至"
  155. start-placeholder="开始日期"
  156. end-placeholder="结束日期"
  157. value-format="yyyy-MM-dd"
  158. style="width: 240px"
  159. @change="handleScheduleTimeChange"
  160. />
  161. </el-form-item>
  162. <!-- 创建时间 -->
  163. <!-- <el-form-item label="创建时间" prop="createTime">
  164. <el-input
  165. v-model="createTimeText"
  166. placeholder="请选择创建时间"
  167. readonly
  168. @click.native="showCreateCalendar = true"
  169. />
  170. <calendar
  171. v-model="createTime"
  172. mode="during"
  173. :show.sync="showCreateCalendar"
  174. @change="createChange"
  175. :key="createCalendarKey"
  176. />
  177. </el-form-item> -->
  178. <el-form-item label="创建时间" prop="createTime">
  179. <el-date-picker
  180. v-model="createTimeText"
  181. type="datetimerange"
  182. range-separator="至"
  183. start-placeholder="开始日期"
  184. end-placeholder="结束日期"
  185. value-format="yyyy-MM-dd HH:mm:ss"
  186. @change="createChange"
  187. :default-time="['00:00:00', '23:59:59']"
  188. />
  189. </el-form-item>
  190. <!-- 最新更新时间 -->
  191. <!-- <el-form-item label="最新更新时间" prop="updateTime">
  192. <el-input
  193. v-model="updateTimeText"
  194. placeholder="请选择更新时间"
  195. readonly
  196. @click.native="showUpdateCalendar = true"
  197. />
  198. <calendar
  199. v-model="updateTime"
  200. mode="during"
  201. :show.sync="showUpdateCalendar"
  202. @change="updateChange"
  203. :key="updateCalendarKey"
  204. />
  205. </el-form-item> -->
  206. <el-form-item label="最新更新时间" prop="updateTime">
  207. <el-date-picker
  208. v-model="updateTimeText"
  209. type="daterange"
  210. range-separator="至"
  211. start-placeholder="开始日期"
  212. end-placeholder="结束日期"
  213. value-format="yyyy-MM-dd"
  214. style="width: 240px"
  215. @change="updateChange"
  216. />
  217. </el-form-item>
  218. <!-- 进线时间 -->
  219. <!-- <el-form-item label="进线时间" prop="qecCreateTime">
  220. <el-input
  221. v-model="qecCreateTimeText"
  222. placeholder="请选择进线时间"
  223. readonly
  224. @click.native="showQecCalendar = true"
  225. />
  226. <calendar
  227. v-model="qecCreateTime"
  228. mode="during"
  229. :show.sync="showQecCalendar"
  230. @change="qecCreateTimeChange"
  231. :key="qecCalendarKey"
  232. />
  233. </el-form-item> -->
  234. <el-form-item label="进线时间" prop="qecCreateTime">
  235. <el-date-picker
  236. v-model="qecCreateTimeText"
  237. type="daterange"
  238. range-separator="至"
  239. start-placeholder="开始日期"
  240. end-placeholder="结束日期"
  241. value-format="yyyy-MM-dd"
  242. style="width: 240px"
  243. @change="qecCreateTimeChange"
  244. />
  245. </el-form-item>
  246. <el-form-item label="营期课程时间" prop="periodTime" v-if="queryParams.sendType==1">
  247. <el-date-picker
  248. v-model="periodTimeText"
  249. type="datetimerange"
  250. align="right"
  251. unlink-panels
  252. value-format="yyyy-MM-dd HH:mm:ss"
  253. range-separator="至"
  254. start-placeholder="开始日期"
  255. end-placeholder="结束日期"
  256. :picker-options="pickerOptions"
  257. @change="qecPeriodTimeChange"
  258. :default-time="['00:00:00', '23:59:59']">
  259. </el-date-picker>
  260. </el-form-item>
  261. <el-form-item>
  262. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  263. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  264. </el-form-item>
  265. </el-form>
  266. <!-- <el-row :gutter="10" class="mb8">-->
  267. <!-- <el-col :span="1.5">-->
  268. <!-- <el-button-->
  269. <!-- type="warning"-->
  270. <!-- plain-->
  271. <!-- icon="el-icon-download"-->
  272. <!-- size="mini"-->
  273. <!-- :loading="exportLoading"-->
  274. <!-- @click="handleExport"-->
  275. <!-- v-hasPermi="['course:courseWatchLog:export']"-->
  276. <!-- >导出</el-button>-->
  277. <!-- </el-col>-->
  278. <!-- <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>-->
  279. <!-- </el-row>-->
  280. <el-tabs type="card" v-model="activeName" @tab-click="handleClickX">
  281. <el-tab-pane label="全部" name="00"></el-tab-pane>
  282. <el-tab-pane v-for="(item,index) in logTypeOptions" :label="item.dictLabel" :name="item.dictValue"></el-tab-pane>
  283. </el-tabs>
  284. <el-table border v-loading="loading" :data="courseWatchLogList" @selection-change="handleSelectionChange">
  285. <el-table-column type="selection" width="55" align="center" />
  286. <el-table-column label="记录编号" align="center" prop="logId" />
  287. <el-table-column label="企微客户" align="center" prop="externalUserName"/>
  288. <el-table-column label="客户头像" align="center" prop="externalUserAvatar">
  289. <template slot-scope="scope">
  290. <el-popover
  291. placement="right"
  292. trigger="hover">
  293. <img slot="reference" :src="scope.row.externalUserAvatar" style="width: 40px;height: 40px">
  294. <img :src="scope.row.externalUserAvatar" style="max-width: 250px;max-height: 250px">
  295. </el-popover>
  296. </template>
  297. </el-table-column>
  298. <el-table-column label="会员ID" align="center" prop="userId" />
  299. <el-table-column label="会员昵称" align="center" prop="fsNickName">
  300. <template slot-scope="scope">
  301. <div style="display: flex;white-space: nowrap">
  302. <div style="margin: auto">
  303. {{scope.row.fsNickName}}
  304. </div>
  305. <el-popover
  306. placement="right"
  307. title=""
  308. trigger="hover">
  309. <img slot="reference" :src="scope.row.fsAvatar" style="width: 30px;height: 30px">
  310. <img :src="scope.row.fsAvatar" style="max-width: 200px;max-height: 200px">
  311. </el-popover>
  312. </div>
  313. </template>
  314. </el-table-column>
  315. <el-table-column label="课程名称" align="center" prop="courseName" />
  316. <el-table-column label="小节名称" align="center" prop="videoName" />
  317. <el-table-column label="记录类型" align="center" prop="logType">
  318. <template slot-scope="scope">
  319. <dict-tag :options="logTypeOptions" :value="scope.row.logType"/>
  320. </template>
  321. </el-table-column>
  322. <el-table-column label="播放时长" align="center" prop="duration" />
  323. <el-table-column label="所属销售" align="center" prop="companyUserName" />
  324. <!-- <el-table-column label="所属公司" align="center" prop="companyName" />-->
  325. <el-table-column label="企微员工名称" align="center" prop="qwUserName" />
  326. <!-- <el-table-column label="所属发送方式" align="center" prop="sendType" />-->
  327. <el-table-column label="创建时间" align="center" prop="createTime" />
  328. <el-table-column label="更新时间" align="center" prop="updateTime" />
  329. <el-table-column label="完课时间" align="center" prop="finishTime" />
  330. <el-table-column label="营期时间" align="center" prop="campPeriodTime" />
  331. <el-table-column label="进线时间" align="center" prop="qecCreateTime" />
  332. <el-table-column label="是否领奖" align="center" prop="rewardType" >
  333. <template slot-scope="scope">
  334. <el-tag
  335. :type="scope.row.rewardType ? 'success' : 'info'"
  336. effect="plain"
  337. >
  338. {{ scope.row.rewardType ? '已领取' : '未领取' }}
  339. </el-tag>
  340. </template>
  341. </el-table-column>
  342. <el-table-column
  343. fixed="right"
  344. label="操作"
  345. width="100">
  346. <template slot-scope="scope">
  347. <el-button @click="openAnswerLogFun(scope.row)" type="text" size="small">答题记录</el-button>
  348. <el-button @click="openRedLogFun(scope.row)" type="text" size="small">红包记录</el-button>
  349. </template>
  350. </el-table-column>
  351. </el-table>
  352. <pagination
  353. v-show="total>0"
  354. :total="total"
  355. :page.sync="queryParams.pageNum"
  356. :limit.sync="queryParams.pageSize"
  357. @pagination="getList"
  358. />
  359. <el-drawer title="答题记录" :visible.sync="openAnswerLog" size="70%" append-to-body>
  360. <el-table border v-loading="" :data="answerLogsList">
  361. <el-table-column label="会员用户" align="center" prop="userName">
  362. <template slot-scope="scope">
  363. <div style="display: flex;white-space: nowrap">
  364. <div style="margin: auto">
  365. {{ scope.row.userName }}
  366. </div>
  367. <el-popover
  368. placement="right"
  369. title=""
  370. trigger="hover">
  371. <img slot="reference" :src="scope.row.fsAvatar" style="width: 30px;height: 30px">
  372. <img :src="scope.row.fsAvatar" style="max-width: 200px;max-height: 200px">
  373. </el-popover>
  374. </div>
  375. </template>
  376. </el-table-column>
  377. <el-table-column label="课程名称" align="center" prop="courseName"/>
  378. <el-table-column label="小节名称" align="center" prop="videoName"/>
  379. <el-table-column label="是否全部正确" align="center" prop="isRightText"/>
  380. <!-- <el-table-column label="是否全部正确" align="center" prop="isRight">-->
  381. <!-- <template slot-scope="scope">-->
  382. <!-- <dict-tag :options="sysCompanyOr" :value="scope.row.isRight"></dict-tag>-->
  383. <!-- </template>-->
  384. <!-- </el-table-column>-->
  385. <el-table-column label="销售名称" align="center" prop="companyUserName"/>
  386. <el-table-column label="企微员工名称" align="center" prop="qwUserName"/>
  387. <el-table-column label="公司名称" align="center" prop="companyName"/>
  388. <el-table-column label="创建时间" align="center" prop="createTime"/>
  389. </el-table>
  390. <pagination
  391. v-show="answerLogTotal>0"
  392. :total="answerLogTotal"
  393. :page.sync="answerLogQueryParams.pageNum"
  394. :limit.sync="answerLogQueryParams.pageSize"
  395. @pagination="answerLogList"
  396. />
  397. </el-drawer>
  398. <el-drawer title="红包记录" :visible.sync="openRedLog" size="70%" append-to-body>
  399. <el-table border v-loading="" :data="redLogsList">
  400. <el-table-column type="selection" width="55" align="center" />
  401. <el-table-column label="记录编号" align="center" prop="logId" />
  402. <el-table-column label="批次单号" align="center" prop="outBatchNo" />
  403. <el-table-column label="课程名称" align="center" prop="courseId" >
  404. <template slot-scope="scope">
  405. <span prop="status" v-for="(item, index) in courseLists" v-if="scope.row.courseId==item.dictValue">{{item.dictLabel}}</span>
  406. </template>
  407. </el-table-column>
  408. <el-table-column label="小节名称" align="center" prop="title" />
  409. <!-- <el-table-column label="会员id" align="center" prop="userId" />-->
  410. <el-table-column label="会员用户" align="center" prop="fsNickName">
  411. <template slot-scope="scope">
  412. <div style="display: flex;white-space: nowrap">
  413. <div style="margin: auto">
  414. {{scope.row.fsNickName}}
  415. </div>
  416. <el-popover
  417. placement="right"
  418. title=""
  419. trigger="hover">
  420. <img slot="reference" :src="scope.row.fsAvatar" style="width: 30px;height: 30px">
  421. <img :src="scope.row.fsAvatar" style="max-width: 200px;max-height: 200px">
  422. </el-popover>
  423. </div>
  424. </template>
  425. </el-table-column>
  426. <!-- <el-table-column label="会员电话" align="center" prop="phone" />-->
  427. <!-- <el-table-column label="所属销售" align="center" prop="companyUserName" />-->
  428. <!-- <el-table-column label="所属公司" align="center" prop="companyName" />-->
  429. <el-table-column label="转账金额" align="center" prop="amount" />
  430. <el-table-column label="状态" align="center" prop="status" >
  431. <template slot-scope="scope">
  432. <el-tag>
  433. {{
  434. scope.row.status === 0 ? "发送中" :
  435. scope.row.status === 2 ? "待补发" :
  436. "已完成"
  437. }}
  438. </el-tag>
  439. </template>
  440. </el-table-column>
  441. <el-table-column label="所属企微" align="center" prop="qwUserName" />
  442. <el-table-column label="创建时间" align="center" prop="createTime" />
  443. </el-table>
  444. <pagination
  445. v-show="redLogTotal>0"
  446. :total="redLogTotal"
  447. :page.sync="redLogQueryParams.pageNum"
  448. :limit.sync="redLogQueryParams.pageSize"
  449. @pagination="redLogList"
  450. />
  451. </el-drawer>
  452. </div>
  453. </template>
  454. <script>
  455. import { deptListCourseWatchLog, getCourseWatchLog, delCourseWatchLog, addCourseWatchLog, updateCourseWatchLog, exportCourseWatchLog } from "@/api/course/courseWatchLog";
  456. import {courseList, myListCourseRedPacketLog, videoList} from '@/api/course/courseRedPacketLog'
  457. import {myListLogs} from "@/api/course/courseAnswerlogs";
  458. import { getCompanyUserListLikeName } from "@/api/company/companyUser";
  459. import {getTask} from "@/api/common";
  460. import Vue from 'vue'
  461. import Calendar from 'vue-mobile-calendar'
  462. import {infoSop} from "@/api/qw/sop";
  463. import {getMyQwUserList} from "@/api/qw/user";
  464. Vue.use(Calendar)
  465. export default {
  466. name: "CourseWatchLog",
  467. data() {
  468. return {
  469. companyName:process.env.VUE_APP_COURSE_COMPANY_NAME,
  470. sopSearchText: '', // SOP搜索框显示的文本
  471. selectedSopId: null, // 选中的SOP ID
  472. sendTypeOptions:[{
  473. dictLabel:"会员",dictValue:'1'
  474. },
  475. {
  476. dictLabel:"企微",dictValue:'2'
  477. }
  478. ],
  479. // 日历 key 控制刷新
  480. scheduleCalendarKey: 0,
  481. createCalendarKey: 0,
  482. updateCalendarKey: 0,
  483. qecCalendarKey: 0,
  484. periodTimeKey: 0,
  485. createTimeText: '',
  486. scheduleTimeText: '', // 新增
  487. updateTimeText: '', // 新增
  488. qecCreateTimeText: '', // 新增
  489. periodTimeText: '', // 营期课程时间
  490. scheduleTime: [], // 改为数组
  491. createTime: [], // 改为数组
  492. updateTime: [], // 改为数组
  493. qecCreateTime: [], // 改为数组
  494. periodTime: [], // 改为数组
  495. // 控制日历显隐
  496. showScheduleCalendar: false,
  497. showCreateCalendar: false,
  498. showUpdateCalendar: false,
  499. showQecCalendar: false,
  500. activeName:"00",
  501. courseLists:[],
  502. videoList:[],
  503. logTypeOptions:[],
  504. // 遮罩层
  505. loading: true,
  506. // 导出遮罩层
  507. exportLoading: false,
  508. // 选中数组
  509. ids: [],
  510. // 非单个禁用
  511. single: true,
  512. // 非多个禁用
  513. multiple: true,
  514. // 显示搜索条件
  515. showSearch: true,
  516. // 总条数
  517. total: 0,
  518. // 短链课程看课记录表格数据
  519. courseWatchLogList: [],
  520. // 弹出层标题
  521. title: "",
  522. // 是否显示弹出层
  523. open: false,
  524. //答题记录
  525. openAnswerLog: false,
  526. loadingAnswerLog: true,
  527. answerLogsList: [],
  528. answerLogTotal: 0,
  529. answerLogQueryParams: {
  530. pageNum: 1,
  531. pageSize: 10,
  532. },
  533. //红包记录
  534. openRedLog: false,
  535. loadingRedLog: true,
  536. redLogsList: [],
  537. redLogTotal: 0,
  538. redLogQueryParams: {
  539. pageNum: 1,
  540. pageSize: 10,
  541. },
  542. pickerOptions: {
  543. disabledDate(time) {
  544. // 获取13天前的日期(加上今天就是14天)
  545. const sixDaysAgo = new Date();
  546. sixDaysAgo.setDate(sixDaysAgo.getDate() - 13);
  547. sixDaysAgo.setHours(0, 0, 0, 0);
  548. // 获取明天的日期(不包括今天)
  549. const tomorrow = new Date();
  550. tomorrow.setDate(tomorrow.getDate() + 1);
  551. tomorrow.setHours(0, 0, 0, 0);
  552. return time.getTime() < sixDaysAgo.getTime() || time.getTime() >= tomorrow.getTime();
  553. }
  554. },
  555. // 查询参数
  556. queryParams: {
  557. pageNum: 1,
  558. pageSize: 10,
  559. userId: null,
  560. nickName: null,
  561. videoId: null,
  562. logType: null,
  563. qwExternalContactId: null,
  564. externalUserName:null,
  565. duration: null,
  566. qwUserId: null,
  567. qwUserName: null, //企微名称
  568. qwUserUserId: null, //企微id
  569. deptName: null, //部门名称
  570. companyUserId: null,
  571. companyId: null,
  572. courseId: null,
  573. sTime:null,
  574. eTime:null,
  575. upSTime:null,
  576. upETime:null,
  577. qecSTime:null,
  578. qecETime:null,
  579. periodSTime:null,
  580. periodETime:null,
  581. scheduleStartTime: null,
  582. scheduleEndTime: null,
  583. sendType:process.env.VUE_APP_COURSE_DEFAULT,
  584. sopId: null, // sopId
  585. },
  586. // 表单参数
  587. form: {},
  588. // 表单校验
  589. rules: {
  590. },
  591. // 员工选项列表
  592. companyUserOptionsParams: {
  593. name: undefined,
  594. hasNextPage: false,
  595. pageNum: 1,
  596. pageSize: 200
  597. },
  598. companyUserOptionsLoading: false,
  599. companyUserOptions: [],
  600. companyUserOptionsByAll: [],
  601. };
  602. },
  603. created() {
  604. courseList().then(response => {
  605. this.courseLists = response.list;
  606. });
  607. this.getDicts("sys_course_watch_log_type").then(response => {
  608. this.logTypeOptions = response.data;
  609. });
  610. // 设置默认当天时间 xgb 防止频繁查询大量数据
  611. this.setToday();
  612. this.getList();
  613. this.getCompanyUserListLikeName(true);
  614. this.loading=false;
  615. },
  616. methods: {
  617. setToday(){
  618. const today = new Date();
  619. const todayStart = new Date(today);
  620. todayStart.setHours(0, 0, 0, 0);
  621. const todayEnd = new Date(today);
  622. todayEnd.setHours(23, 59, 59, 999);
  623. this.createTimeText = [this.formatDate(todayStart), this.formatDate(todayEnd)];
  624. this.queryParams.sTime = this.formatDate(todayStart);
  625. this.queryParams.eTime = this.formatDate(todayEnd);
  626. },
  627. handleSendTypeChange() {
  628. this.handleQuery(); // 重新查询列表
  629. },
  630. // 重置日历组件
  631. resetCalendars() {
  632. this.scheduleTime = [];
  633. this.createTime = [];
  634. this.updateTime = [];
  635. this.qecCreateTime = [];
  636. this.periodTime = [];
  637. this.scheduleTimeText = '';
  638. this.createTimeText = '';
  639. this.updateTimeText = '';
  640. this.qecCreateTimeText = '';
  641. this.periodTimeText = [];
  642. // 强制刷新日历组件
  643. this.scheduleCalendarKey++;
  644. this.createCalendarKey++;
  645. this.updateCalendarKey++;
  646. this.qecCalendarKey++;
  647. this.periodTimeKey++;
  648. },
  649. formatDateRange(dates) {
  650. if (!dates || dates.length < 2) return '';
  651. return dates.map(date => date.format('YYYY-MM-DD')).join(' ~ ');
  652. },
  653. courseChange(row){
  654. this.queryParams.videoId=null;
  655. if(row === ''){
  656. this.videoList=[];
  657. return
  658. }
  659. videoList(row).then(response => {
  660. this.videoList=response.list
  661. });
  662. },
  663. handleClickX(tab,event){
  664. this.activeName=tab.name;
  665. if(tab.name=="00"){
  666. this.queryParams.logType=null;
  667. }else{
  668. this.queryParams.logType=tab.name;
  669. }
  670. this.getList()
  671. },
  672. /** 查询短链课程看课记录列表 */
  673. getList() {
  674. // xgb 看课数据量太大必须限制时间if (this.isEmptyArray(this.createTimeText) &&
  675. if (this.isEmptyArray(this.createTimeText) &&
  676. this.isEmptyArray(this.updateTimeText) &&
  677. this.isEmptyArray(this.scheduleTimeText)) {
  678. this.$message.warning('请选择创建时间或营期时间或最新更新时间');
  679. return;
  680. }
  681. this.loading = true;
  682. if(this.queryParams.logType == "10"){
  683. this.queryParams.logType = null;
  684. }
  685. deptListCourseWatchLog(this.queryParams).then(response => {
  686. this.courseWatchLogList = response.rows;
  687. this.total = response.total;
  688. this.loading = false;
  689. }).catch(() => {
  690. this.loading = false;
  691. }
  692. );
  693. },
  694. // 添加辅助方法
  695. isEmptyArray(arr) {
  696. return !arr || arr.length === 0;
  697. },
  698. // 取消按钮
  699. cancel() {
  700. this.open = false;
  701. this.reset();
  702. },
  703. // 表单重置
  704. reset() {
  705. this.form = {
  706. logId: null,
  707. userId: null,
  708. videoId: null,
  709. logType: null,
  710. createTime: null,
  711. updateTime: null,
  712. qwExternalContactId: null,
  713. externalUserName:null,
  714. duration: null,
  715. qwUserId: null,
  716. companyUserId: null,
  717. companyId: null,
  718. courseId: null,
  719. scheduleStartTime: null,
  720. scheduleEndTime: null,
  721. };
  722. this.scheduleTime=null;
  723. this.resetForm("form");
  724. },
  725. /** 搜索按钮操作 */
  726. handleQuery() {
  727. this.queryParams.pageNum = 1;
  728. this.getList();
  729. },
  730. /** 重置按钮操作 */
  731. resetQuery() {
  732. this.resetForm("queryForm");
  733. this.createTime = null;
  734. this.scheduleTime = null;
  735. this.qecCreateTime=null;
  736. this.queryParams.sTime = null;
  737. this.queryParams.eTime = null;
  738. this.queryParams.upSTime = null;
  739. this.queryParams.upETime = null;
  740. this.queryParams.qecSTime = null;
  741. this.queryParams.qecETime = null;
  742. this.queryParams.periodSTime = null;
  743. this.queryParams.periodDTime = null;
  744. this.queryParams.scheduleStartTime = null;
  745. this.queryParams.scheduleEndTime = null;
  746. this.queryParams.sopId = null; // 重置SOP ID
  747. this.scheduleTime=null;
  748. this.updateTime=null;
  749. this.queryParams.externalUserName=null;
  750. // 重置SOP搜索
  751. this.handleSopClear();
  752. // 统一重置日历组件
  753. this.resetCalendars();
  754. this.setToday();
  755. this.handleQuery();
  756. },
  757. // 多选框选中数据
  758. handleSelectionChange(selection) {
  759. this.ids = selection.map(item => item.logId)
  760. this.single = selection.length!==1
  761. this.multiple = !selection.length
  762. },
  763. /** 新增按钮操作 */
  764. handleAdd() {
  765. this.reset();
  766. this.open = true;
  767. this.title = "添加短链课程看课记录";
  768. },
  769. /** 修改按钮操作 */
  770. handleUpdate(row) {
  771. this.reset();
  772. const logId = row.logId || this.ids
  773. getCourseWatchLog(logId).then(response => {
  774. this.form = response.data;
  775. this.open = true;
  776. this.title = "修改短链课程看课记录";
  777. });
  778. },
  779. /** 提交按钮 */
  780. submitForm() {
  781. this.$refs["form"].validate(valid => {
  782. if (valid) {
  783. if (this.form.logId != null) {
  784. updateCourseWatchLog(this.form).then(response => {
  785. this.msgSuccess("修改成功");
  786. this.open = false;
  787. this.getList();
  788. });
  789. } else {
  790. addCourseWatchLog(this.form).then(response => {
  791. this.msgSuccess("新增成功");
  792. this.open = false;
  793. this.getList();
  794. });
  795. }
  796. }
  797. });
  798. },
  799. /** 删除按钮操作 */
  800. handleDelete(row) {
  801. const logIds = row.logId || this.ids;
  802. this.$confirm('是否确认删除短链课程看课记录编号为"' + logIds + '"的数据项?', "警告", {
  803. confirmButtonText: "确定",
  804. cancelButtonText: "取消",
  805. type: "warning"
  806. }).then(function() {
  807. return delCourseWatchLog(logIds);
  808. }).then(() => {
  809. this.getList();
  810. this.msgSuccess("删除成功");
  811. }).catch(() => {});
  812. },
  813. /** 导出按钮操作 */
  814. handleExport() {
  815. // xgb 看课数据量太大必须限制时间
  816. if (this.isEmptyArray(this.createTimeText) &&
  817. this.isEmptyArray(this.updateTimeText) &&
  818. this.isEmptyArray(this.scheduleTimeText)) {
  819. this.$message.warning('请选择创建时间或营期时间或最新更新时间');
  820. return;
  821. }
  822. const that = this
  823. const queryParams = this.queryParams;
  824. this.$confirm('是否确认导出所有短链课程看课记录数据项?', "警告", {
  825. confirmButtonText: "确定",
  826. cancelButtonText: "取消",
  827. type: "warning"
  828. }).then(() => {
  829. this.exportLoading = true;
  830. return exportCourseWatchLog(queryParams);
  831. }).then(response => {
  832. if (response.code === 200){
  833. that.msgSuccess(response.msg);
  834. that.taskId = response.data;
  835. that.time = setInterval(function(){
  836. //查订单
  837. getTask(that.taskId).then(res => {
  838. if(res.data.status === 1){
  839. that.exportLoading = false;
  840. clearTimeout(that.time)
  841. that.time = null;
  842. that.download(res.data.fileUrl);
  843. }
  844. });
  845. },10000);
  846. } else {
  847. that.msgError(response.msg)
  848. that.exportLoading = false
  849. }
  850. }).catch(() => {});
  851. },
  852. openAnswerLogFun(row) {
  853. this.openAnswerLog = true;
  854. this.answerLogQueryParams.watchLogId = row.logId;
  855. this.answerLogList();
  856. },
  857. answerLogList() {
  858. this.loadingAnswerLog = true;
  859. myListLogs(this.answerLogQueryParams).then(e => {
  860. this.answerLogsList = e.rows;
  861. this.answerLogTotal = e.total;
  862. this.loadingAnswerLog = false;
  863. })
  864. },
  865. openRedLogFun(row) {
  866. this.openRedLog = true;
  867. this.redLogQueryParams.watchLogId = row.logId;
  868. this.redLogList();
  869. },
  870. redLogList() {
  871. this.loadingRedLog = true;
  872. console.info("------------dept",this.redLogQueryParams)
  873. myListCourseRedPacketLog(this.redLogQueryParams).then(e => {
  874. this.redLogsList = e.rows;
  875. this.redLogTotal = e.total;
  876. this.loadingRedLog = false;
  877. })
  878. },
  879. // 营期时间
  880. handleScheduleTimeChange(scheduleTime) {
  881. if (scheduleTime && scheduleTime.length >= 2) {
  882. if(!this.checkDateRangeLimit(scheduleTime)){
  883. this.scheduleTimeText = null;
  884. this.queryParams.scheduleStartTime=null;
  885. this.queryParams.scheduleStartTime=null;
  886. return;
  887. }
  888. // this.scheduleTimeText = this.formatDateRange(scheduleTime);
  889. this.queryParams.scheduleStartTime = scheduleTime[0] || null;
  890. this.queryParams.scheduleEndTime = scheduleTime[1] || null;
  891. } else {
  892. this.scheduleTimeText = [];
  893. this.queryParams.scheduleStartTime = null;
  894. this.queryParams.scheduleEndTime = null;
  895. }
  896. },
  897. checkDateRangeLimit(dateRange) {
  898. if (dateRange && dateRange.length >= 2) {
  899. const startDate = new Date(dateRange[0]);
  900. const endDate = new Date(dateRange[1]);
  901. // 设置时间为当天开始,避免时间部分影响计算
  902. startDate.setHours(0, 0, 0, 0);
  903. endDate.setHours(0, 0, 0, 0);
  904. const timeDiff = Math.abs(endDate - startDate);
  905. const diffDays = Math.ceil(timeDiff / (1000 * 60 * 60 * 24));
  906. if (diffDays > 31) { // maxDays-1 因为包含起始日
  907. this.$message.warning('时间区间不能超过一个月');
  908. return false;
  909. }
  910. }
  911. return true;
  912. },
  913. // 创建时间
  914. createChange(createTime) {
  915. if (createTime && createTime.length >= 2) {
  916. if(!this.checkDateRangeLimit(createTime)){
  917. this.createTimeText = null;
  918. this.queryParams.sTime=null;
  919. this.queryParams.eTime=null;
  920. return;
  921. }
  922. // this.createTimeText = this.formatDateRange(createTime);
  923. this.queryParams.sTime = this.formatDate(createTime[0]) || null;
  924. this.queryParams.eTime = this.formatDate(createTime[1]) || null;
  925. } else {
  926. this.createTimeText = '';
  927. this.queryParams.sTime = null;
  928. this.queryParams.eTime = null;
  929. }
  930. },
  931. // 更新时间
  932. updateChange(updateTime) {
  933. if (updateTime && updateTime.length >= 2) {
  934. if(!this.checkDateRangeLimit(updateTime)){
  935. this.updateTimeText = null;
  936. this.queryParams.upSTime=null;
  937. this.queryParams.upETime=null;
  938. return;
  939. }
  940. this.updateTimeText = this.formatDateRange(updateTime);
  941. this.queryParams.upSTime = updateTime[0] || null;
  942. this.queryParams.upETime = updateTime[1] || null;
  943. } else {
  944. this.updateTimeText = '';
  945. this.queryParams.upSTime = null;
  946. this.queryParams.upETime = null;
  947. }
  948. },
  949. // 进线时间
  950. qecCreateTimeChange(qecCreateTime) {
  951. if (qecCreateTime && qecCreateTime.length >= 2) {
  952. // 检查选择的日期范围是否超过7天(包括起始和结束日期)
  953. const startDate = new Date(qecCreateTime[0]);
  954. const endDate = new Date(qecCreateTime[1]);
  955. // 设置时间为当天开始,避免时间部分影响计算
  956. startDate.setHours(0, 0, 0, 0);
  957. endDate.setHours(0, 0, 0, 0);
  958. const timeDiff = Math.abs(endDate - startDate);
  959. const diffDays = Math.ceil(timeDiff / (1000 * 60 * 60 * 24));
  960. // 如果超过6天的范围(总共7天,包括起始日)
  961. if (diffDays > 6) {
  962. this.$message.error('进线时间选择范围不能超过7天');
  963. // 清空选择
  964. this.qecCreateTime = [];
  965. this.qecCreateTimeText = [];
  966. this.queryParams.qecSTime = null;
  967. this.queryParams.qecETime = null;
  968. this.qecCalendarKey++;
  969. return;
  970. }
  971. // this.qecCreateTimeText = this.formatDateRange(qecCreateTime);
  972. this.queryParams.qecSTime = qecCreateTime[0] || null;
  973. this.queryParams.qecETime = qecCreateTime[1] || null;
  974. } else {
  975. this.qecCreateTimeText = '';
  976. this.queryParams.qecSTime = null;
  977. this.queryParams.qecETime = null;
  978. }
  979. },
  980. //营期课程时间
  981. qecPeriodTimeChange(periodTime){
  982. if (periodTime && periodTime.length >= 2) {
  983. // 检查选择的日期范围是否超过7天(包括起始和结束日期)
  984. const startDate = new Date(periodTime[0]);
  985. const endDate = new Date(periodTime[1]);
  986. // 设置时间为当天开始,避免时间部分影响计算
  987. startDate.setHours(0, 0, 0, 0);
  988. endDate.setHours(0, 0, 0, 0);
  989. const timeDiff = Math.abs(endDate - startDate);
  990. const diffDays = Math.ceil(timeDiff / (1000 * 60 * 60 * 24));
  991. // 如果超过6天的范围(总共7天,包括起始日)
  992. if (diffDays > 13) {
  993. this.$message.error('时间选择范围不能超过14天');
  994. // 清空选择
  995. this.periodTime = [];
  996. this.periodTimeText = [];
  997. this.queryParams.periodSTime = null;
  998. this.queryParams.periodETime = null;
  999. this.periodTimeKey++;
  1000. return;
  1001. }
  1002. this.queryParams.periodSTime = this.formatDate(periodTime[0]) || null;
  1003. this.queryParams.periodETime = this.formatDate(periodTime[1]) || null;
  1004. } else {
  1005. this.periodTimeText = '';
  1006. this.queryParams.periodSTime = null;
  1007. this.queryParams.periodETime = null;
  1008. }
  1009. },
  1010. formatDate(date) {
  1011. if (!date) return ''
  1012. // 确保 date 是 Date 对象
  1013. let dateObj = date
  1014. if (typeof date === 'string') {
  1015. dateObj = new Date(date)
  1016. }
  1017. // 如果转换失败,返回空字符串
  1018. if (!(dateObj instanceof Date) || isNaN(dateObj.getTime())) {
  1019. return ''
  1020. }
  1021. // 使用更安全的格式化方法
  1022. const year = dateObj.getFullYear()
  1023. const month = String(dateObj.getMonth() + 1).padStart(2, '0')
  1024. const day = String(dateObj.getDate()).padStart(2, '0')
  1025. const hours = String(dateObj.getHours()).padStart(2, '0')
  1026. const minutes = String(dateObj.getMinutes()).padStart(2, '0')
  1027. const seconds = String(dateObj.getSeconds()).padStart(2, '0')
  1028. return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
  1029. },
  1030. /**
  1031. * 根据名称模糊查询用户列表
  1032. * @param query 参数
  1033. */
  1034. loadCompanyUserOptions(query) {
  1035. this.companyUserOptions = [];
  1036. if (query === '') {
  1037. return;
  1038. }
  1039. this.companyUserOptionsParams.pageNum = 1
  1040. this.companyUserOptionsParams.name = query
  1041. this.companyUserOptionsLoading = true;
  1042. this.getCompanyUserListLikeName()
  1043. },
  1044. /**
  1045. * 获取员工列表
  1046. */
  1047. getCompanyUserListLikeName(isAll) {
  1048. if (isAll){
  1049. getCompanyUserListLikeName(this.companyUserOptionsParams).then(response => {
  1050. this.companyUserOptionsByAll = [...this.companyUserOptions, ...response.data.list]
  1051. this.companyUserOptionsParams.hasNextPage = response.data.hasNextPage
  1052. this.companyUserOptionsLoading = false;
  1053. });
  1054. }else {
  1055. this.companyUserOptionsParams.pageSize=10;
  1056. getCompanyUserListLikeName(this.companyUserOptionsParams).then(response => {
  1057. this.companyUserOptions = [...this.companyUserOptions, ...response.data.list]
  1058. this.companyUserOptionsParams.hasNextPage = response.data.hasNextPage
  1059. this.companyUserOptionsLoading = false;
  1060. });
  1061. }
  1062. },
  1063. /**
  1064. * 加载更多员工选项
  1065. */
  1066. loadMoreCompanyUserOptions() {
  1067. if (!this.companyUserOptionsParams.hasNextPage) {
  1068. return;
  1069. }
  1070. this.companyUserOptionsParams.pageNum += 1
  1071. this.getCompanyUserListLikeName()
  1072. },
  1073. /**
  1074. * 选择SOP
  1075. * @param {object} item - 选中的SOP项
  1076. */
  1077. handleSopSelect(item) {
  1078. this.selectedSopId = item.id;
  1079. this.queryParams.sopId = item.id;
  1080. this.sopSearchText = item.name;
  1081. },
  1082. /**
  1083. * 清空SOP选择
  1084. */
  1085. handleSopClear() {
  1086. this.selectedSopId = null;
  1087. this.queryParams.sopId = null;
  1088. this.sopSearchText = '';
  1089. },
  1090. /**
  1091. * 异步查询SOP列表
  1092. * @param {string} queryString - 查询字符串
  1093. * @param {function} callback - 回调函数
  1094. */
  1095. querySopAsync(queryString, callback) {
  1096. if (!queryString) {
  1097. callback([]);
  1098. return;
  1099. }
  1100. infoSop({ name: queryString }).then(response => {
  1101. if (response && response.rows) {
  1102. const suggestions = response.rows.map(item => ({
  1103. value: item.name,
  1104. id: item.id,
  1105. name: item.name
  1106. }));
  1107. callback(suggestions);
  1108. } else {
  1109. callback([]);
  1110. }
  1111. }).catch(error => {
  1112. console.error('通过sop查询失败:', error);
  1113. callback([]);
  1114. });
  1115. },
  1116. updateQwuser() {
  1117. for (const user of this.myQwUserList) {
  1118. if (user.dictValue == this.queryParams.qwUserId) {
  1119. this.queryParams.corpId = user.corpId;
  1120. break;
  1121. }
  1122. }
  1123. this.getList();
  1124. },
  1125. }
  1126. };
  1127. </script>