userCourseCatalogDetails.vue 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959
  1. <template>
  2. <div class="app-container">
  3. <div style="padding-bottom: 20px">
  4. <span v-if="courseName!=null">{{ courseName }}</span>
  5. </div>
  6. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  7. <el-form-item label="小节名称" prop="title">
  8. <el-input
  9. v-model="queryParams.title"
  10. placeholder="请输入小节名称"
  11. clearable
  12. size="small"
  13. @keyup.enter.native="handleQuery"
  14. />
  15. </el-form-item>
  16. <el-form-item>
  17. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  18. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  19. </el-form-item>
  20. </el-form>
  21. <el-row :gutter="10" class="mb8">
  22. <el-col :span="1.5">
  23. <el-button
  24. type="primary"
  25. plain
  26. icon="el-icon-plus"
  27. size="mini"
  28. @click="handleAdd"
  29. v-hasPermi="['course:userCourseVideo:add']"
  30. >新增目录</el-button>
  31. </el-col>
  32. <el-col :span="1.5">
  33. <el-button
  34. type="primary"
  35. plain
  36. :disabled="!ids || ids.length <= 0"
  37. size="mini"
  38. @click="openUpdates"
  39. v-hasPermi="['course:userCourseVideo:updateTime']"
  40. >修改时间</el-button>
  41. </el-col>
  42. <el-col :span="1.5">
  43. <el-button
  44. type="primary"
  45. plain
  46. size="mini"
  47. @click="openAdds"
  48. v-hasPermi="['course:userCourseVideo:batchAdd']"
  49. >批量添加</el-button>
  50. </el-col>
  51. <el-col :span="1.5">
  52. <el-button
  53. type="primary"
  54. plain
  55. size="mini"
  56. v-if="isPrivate === 1"
  57. @click="updateRedPageckeOpen"
  58. v-hasPermi="['course:userCourseVideo:updateRed']"
  59. >修改红包</el-button>
  60. </el-col>
  61. <el-col :span="1.5">
  62. <el-button
  63. type="danger"
  64. plain
  65. icon="el-icon-delete"
  66. size="mini"
  67. :disabled="multiple"
  68. @click="handleDelete"
  69. v-hasPermi="['course:userCourseVideo:remove']"
  70. >删除</el-button>
  71. </el-col>
  72. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  73. </el-row>
  74. <el-table border v-loading="loading" :data="userCourseVideoList" @selection-change="handleSelectionChange">
  75. <el-table-column type="selection" width="55" align="center" />
  76. <el-table-column label="视频ID" align="center" prop="videoId" />
  77. <!-- <el-table-column label="轮次" align="center" prop="round" />-->
  78. <el-table-column label="小节名称" align="center" show-overflow-tooltip prop="title" />
  79. <el-table-column label="视频文件名称" align="center" show-overflow-tooltip prop="fileName" >
  80. </el-table-column>
  81. <el-table-column label="视频时长" align="center" prop="duration">
  82. <template slot-scope="{ row }">
  83. {{ formatDuration(row.duration) }}
  84. </template>
  85. </el-table-column>
  86. <el-table-column label="看课开始时间" align="center" prop="duration">
  87. <template slot-scope="{ row }">
  88. <el-tag v-if="row.viewStartTime">{{row.viewStartTime}}</el-tag>
  89. <el-tag type="danger" v-if="!row.viewStartTime">无</el-tag>
  90. </template>
  91. </el-table-column>
  92. <el-table-column label="看课结束时间" align="center" prop="duration">
  93. <template slot-scope="{ row }">
  94. <el-tag v-if="row.viewEndTime">{{row.viewEndTime}}</el-tag>
  95. <el-tag type="danger" v-if="!row.viewEndTime">无</el-tag>
  96. </template>
  97. </el-table-column>
  98. <el-table-column label="领取红包时间" align="center" prop="duration">
  99. <template slot-scope="{ row }">
  100. <el-tag v-if="row.lastJoinTime">{{ row.lastJoinTime }}</el-tag>
  101. <el-tag type="danger" v-if="!row.lastJoinTime">无</el-tag>
  102. </template>
  103. </el-table-column>
  104. <el-table-column label="红包金额" align="center" prop="redPacketMoney" v-if="isPrivate === 1"/>
  105. <el-table-column label="排序" align="center" prop="courseSort" />
  106. <el-table-column label="上传时间" align="center" prop="createTime" />
  107. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  108. <template slot-scope="scope">
  109. <el-button
  110. size="mini"
  111. type="text"
  112. icon="el-icon-edit"
  113. @click="handleUpdate(scope.row)"
  114. v-hasPermi="['course:userCourseVideo:edit']"
  115. >修改</el-button>
  116. <el-button
  117. size="mini"
  118. type="text"
  119. icon="el-icon-edit"
  120. @click="handleComment(scope.row)"
  121. >查看评论</el-button>
  122. <el-button
  123. size="mini"
  124. type="text"
  125. icon="el-icon-delete"
  126. @click="handleDelete(scope.row)"
  127. v-hasPermi="['course:userCourseVideo:remove']"
  128. >删除</el-button>
  129. </template>
  130. </el-table-column>
  131. </el-table>
  132. <pagination
  133. v-show="total>0"
  134. :total="total"
  135. :page.sync="queryParams.pageNum"
  136. :limit.sync="queryParams.pageSize"
  137. @pagination="getList"
  138. />
  139. <el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body >
  140. <el-form ref="form" :model="form" :rules="rules" label-width="110px" v-loading="uploadLoading">
  141. <el-form-item label="视频标题" prop="title">
  142. <el-input v-model="form.title" placeholder="请输入内容" />
  143. </el-form-item>
  144. <el-form-item label="视频描述" prop="description">
  145. <el-input v-model="form.description" type="textarea" :rows="2" placeholder="请输入内容" />
  146. </el-form-item>
  147. <el-form-item label="轮次" prop="round">
  148. <el-input v-model="form.round" placeholder="请输入内容" />
  149. </el-form-item>
  150. <el-form-item label="课程排序" prop="courseSort">
  151. <el-input-number v-model="form.courseSort" :min="1" ></el-input-number>
  152. </el-form-item>
  153. <!-- <el-form-item label="看课时间" prop="timeRange" v-if="isPrivate === 1">-->
  154. <!-- <el-time-picker-->
  155. <!-- is-range-->
  156. <!-- v-model="form.timeRange"-->
  157. <!-- range-separator="至"-->
  158. <!-- start-placeholder="开始时间"-->
  159. <!-- value-format="HH:mm:ss"-->
  160. <!-- end-placeholder="结束时间"-->
  161. <!-- placeholder="选择时间范围">-->
  162. <!-- </el-time-picker>-->
  163. <!-- </el-form-item>-->
  164. <!-- <el-form-item label="领取红包时间" prop="lastJoinTime" v-if="isPrivate === 1">-->
  165. <!-- <el-time-picker-->
  166. <!-- v-model="form.lastJoinTime"-->
  167. <!-- :selectableRange="form.timeRange"-->
  168. <!-- value-format="HH:mm:ss"-->
  169. <!-- placeholder="选择时间范围">-->
  170. <!-- </el-time-picker>-->
  171. <!-- <p style="color: red;margin: 0;font-size: 12px">超过领取红包时间,只允许看课,不允许领取红包</p>-->
  172. <!-- </el-form-item>-->
  173. <el-form-item label="视频缩略图" prop="thumbnail">
  174. <el-upload
  175. v-model="form.thumbnail"
  176. class="avatar-uploader"
  177. :action="uploadUrl"
  178. :show-file-list="false"
  179. :on-success="handleAvatarSuccess"
  180. :before-upload="beforeAvatarUpload">
  181. <img v-if="form.thumbnail" :src="form.thumbnail" class="avatar" width="300px">
  182. <i v-else class="el-icon-plus avatar-uploader-icon"></i>
  183. </el-upload>
  184. </el-form-item>
  185. <video-upload
  186. :type = "1"
  187. :isPrivate = "isPrivate"
  188. :fileKey.sync = "form.fileKey"
  189. :fileSize.sync = "form.fileSize"
  190. :videoUrl.sync="videoUrl"
  191. :fileName.sync="form.fileName"
  192. :line_1.sync="form.lineOne"
  193. :line_2.sync="form.lineTwo"
  194. :line_3.sync="form.lineThree"
  195. :thumbnail.sync="form.thumbnail"
  196. :uploadType.sync="form.uploadType"
  197. @video-duration="handleVideoDuration"
  198. @change="handleVideoChange"
  199. @selectProjects="handleSelectProjects"
  200. ref="videoUpload"
  201. append-to-body
  202. />
  203. <el-form-item label="课题选择" prop="questionBankId" v-if="isPrivate === 1">
  204. <el-button size="small" type="primary" @click="chooseQuestionBank">选取课题</el-button>
  205. <el-table border width="100%" style="margin-top:5px;" :data="form.questionBankList">
  206. <el-table-column label="问题" align="center" prop="title">
  207. <template slot-scope="scope">
  208. <el-tooltip class="item" effect="dark" :content="scope.row.title" placement="top">
  209. <div style="display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; text-overflow: ellipsis;">
  210. <span>{{ scope.row.title }}</span>
  211. </div>
  212. </el-tooltip>
  213. </template>
  214. </el-table-column>
  215. <el-table-column label="类别" align="center" prop="type">
  216. <template slot-scope="scope">
  217. <dict-tag :options="typeOptions" :value="scope.row.type"/>
  218. </template>
  219. </el-table-column>
  220. <el-table-column label="答案" align="center" prop="answer" />
  221. <el-table-column label="操作" align="center" width="100px" fixed="right">
  222. <template slot-scope="scope">
  223. <el-button
  224. size="mini"
  225. type="text"
  226. icon="el-icon-delete"
  227. @click="handleQuestionBankDelete(scope.row)"
  228. >删除</el-button>
  229. </template>
  230. </el-table-column>
  231. </el-table>
  232. </el-form-item >
  233. <el-form-item label="红包金额" prop="redPacketMoney" v-if="isPrivate === 1">
  234. <el-input-number v-model="form.redPacketMoney" :min="0.1" :max="200" :step="0.1" ></el-input-number>
  235. </el-form-item>
  236. </el-form>
  237. <div slot="footer" class="dialog-footer">
  238. <el-button type="primary" @click="submitForm">确 定</el-button>
  239. <el-button @click="cancel">取 消</el-button>
  240. </div>
  241. </el-dialog>
  242. <el-dialog :title="title" :visible.sync="updateBatchData.open" width="1000px" append-to-body >
  243. <el-form ref="form" :model="updateBatchData.form" label-width="110px">
  244. <el-form-item label="看课时间" prop="timeRange">
  245. <el-time-picker
  246. is-range
  247. v-model="updateBatchData.form.timeRange"
  248. range-separator="至"
  249. start-placeholder="开始时间"
  250. value-format="HH:mm:ss"
  251. end-placeholder="结束时间"
  252. placeholder="选择时间范围">
  253. </el-time-picker>
  254. </el-form-item>
  255. <el-form-item label="领取红包时间" prop="lastJoinTime">
  256. <el-time-picker
  257. v-model="updateBatchData.form.lastJoinTime"
  258. :selectableRange="updateBatchData.form.timeRange"
  259. value-format="HH:mm:ss"
  260. placeholder="选择时间范围">
  261. </el-time-picker>
  262. <p style="color: red;margin: 0;font-size: 12px">超过领取红包时间,只允许看课,不允许领取红包</p>
  263. </el-form-item>
  264. </el-form>
  265. <div slot="footer" class="dialog-footer">
  266. <el-button type="primary" @click="updateBatch">确 定</el-button>
  267. <el-button @click="updateBatchData.open = false">取 消</el-button>
  268. </div>
  269. </el-dialog>
  270. <el-dialog :title="questionBank.title" :visible.sync="questionBank.open" width="1000px" append-to-body >
  271. <question-bank ref="questionBank" @questionBankResult="questionBankResult" ></question-bank>
  272. </el-dialog>
  273. <el-dialog title="视频库选择" :visible.sync="addBatchData.open" width="900px" append-to-body>
  274. <!-- 搜索条件 -->
  275. <el-form :inline="true" :model="addBatchData.queryParams" class="library-search">
  276. <el-form-item label="素材名称">
  277. <el-input
  278. v-model="addBatchData.queryParams.resourceName"
  279. placeholder="请输入素材名称"
  280. clearable
  281. size="small"
  282. @keyup.enter.native="resourceList"
  283. />
  284. </el-form-item>
  285. <el-form-item label="类型">
  286. <el-select v-model="addBatchData.queryParams.typeId" @change="changeCateType" placeholder="请选择素材类型" clearable size="small">
  287. <el-option
  288. v-for="item in addBatchData.typeOptions"
  289. :key="item.dictValue"
  290. :label="item.dictLabel"
  291. :value="item.dictValue"
  292. />
  293. </el-select>
  294. </el-form-item>
  295. <el-form-item label="子类型">
  296. <el-select v-model="addBatchData.queryParams.typeSubId" placeholder="请选择素材子类型" clearable size="small">
  297. <el-option
  298. v-for="item in addBatchData.typeSubOptions"
  299. :key="item.dictValue"
  300. :label="item.dictLabel"
  301. :value="item.dictValue"
  302. />
  303. </el-select>
  304. </el-form-item>
  305. <el-form-item>
  306. <el-button type="primary" icon="el-icon-search" size="mini" @click="resourceList">搜索</el-button>
  307. </el-form-item>
  308. </el-form>
  309. <!-- 视频列表 -->
  310. <el-table v-loading="addBatchData.loading" :data="addBatchData.list" @selection-change="handVideoleSelectionChange" height="400px">
  311. <el-table-column type="selection" width="55" align="center" />
  312. <el-table-column label="素材名称" align="center" prop="resourceName" />
  313. <el-table-column label="文件名称" align="center" prop="fileName" />
  314. <el-table-column label="缩略图" align="center">
  315. <template slot-scope="scope">
  316. <el-popover
  317. placement="right"
  318. title=""
  319. trigger="hover"
  320. >
  321. <img alt="" slot="reference" :src="scope.row.thumbnail" style="width: 80px; height: 50px" />
  322. <img alt="" :src="scope.row.thumbnail" style="max-width: 150px;" />
  323. </el-popover>
  324. </template>
  325. </el-table-column>
  326. <el-table-column label="视频时长" align="center">
  327. <template slot-scope="scope">
  328. <span>{{ formatDuration(scope.row.duration) }}</span>
  329. </template>
  330. </el-table-column>
  331. </el-table>
  332. <!-- 分页 -->
  333. <pagination
  334. v-show="addBatchData.total>0"
  335. :total="addBatchData.total"
  336. :page.sync="addBatchData.queryParams.pageNum"
  337. :limit.sync="addBatchData.queryParams.pageSize"
  338. @pagination="resourceList"
  339. />
  340. <div slot="footer" class="dialog-footer">
  341. <el-button type="primary" @click="batchVideoSave">确 定</el-button>
  342. </div>
  343. </el-dialog>
  344. <el-dialog title="章节红包" :visible.sync="redData.open" width="900px" append-to-body>
  345. <el-table border v-loading="redData.loading" :data="redData.list" height="600px">
  346. <el-table-column label="小节名称" align="center" show-overflow-tooltip prop="title" />
  347. <el-table-column label="视频文件名称" align="center" show-overflow-tooltip prop="fileName" >
  348. </el-table-column>
  349. <el-table-column label="视频时长" align="center" prop="duration">
  350. <template slot-scope="{ row }">
  351. {{ formatDuration(row.duration) }}
  352. </template>
  353. </el-table-column>
  354. <el-table-column label="红包金额" align="center" prop="redPacketMoney">
  355. <template slot-scope="scope">
  356. <el-input class="el-input" v-model="scope.row.redPacketMoney" />
  357. </template>
  358. </el-table-column>
  359. <el-table-column label="排序" align="center" prop="courseSort" />
  360. <el-table-column label="上传时间" align="center" prop="createTime" />
  361. </el-table>
  362. <div slot="footer" class="dialog-footer">
  363. <el-button type="primary" @click="batchRedSave">确 定</el-button>
  364. </div>
  365. </el-dialog>
  366. <el-dialog :title="commentDialog.title" :visible.sync="commentDialog.open" width="1000px" append-to-body :close-on-click-modal="false">
  367. <course-watch-comment
  368. ref="courseWatchComment"
  369. :courseId="commentDialog.courseId"
  370. :videoId="commentDialog.videoId"
  371. v-if="commentDialog.open">
  372. </course-watch-comment>
  373. </el-dialog>
  374. </div>
  375. </template>
  376. <script>
  377. import {
  378. addUserCourseVideo,
  379. delUserCourseVideo,
  380. getSort,
  381. getUserCourseVideo,
  382. getVideoListByCourseId,
  383. updates,
  384. batchSaveVideo,
  385. batchUpdateRed,
  386. updateUserCourseVideo
  387. } from "@/api/course/userCourseVideo";
  388. import QuestionBank from "@/views/course/courseQuestionBank/QuestionBank.vue";
  389. import VideoUpload from "@/components/VideoUpload/index.vue";
  390. import { listVideoResource } from '@/api/course/videoResource';
  391. import { getByIds } from '@/api/course/courseQuestionBank'
  392. import CourseWatchComment from "./courseWatchComment.vue";
  393. import { getCateListByPid, getCatePidList } from '@/api/course/userCourseCategory'
  394. export default {
  395. name: "userCourseCatalog",
  396. components: {VideoUpload,QuestionBank,CourseWatchComment},
  397. data() {
  398. return {
  399. duration: null,
  400. packageList:[],
  401. //课题
  402. package:{
  403. title:'',
  404. open:false,
  405. },
  406. //课题
  407. questionBank:{
  408. title:'',
  409. open:false,
  410. },
  411. isPrivate:null,
  412. videoUrl: "",
  413. uploadTypeOptions: [
  414. { dictLabel: "线路一", dictValue: 2 },
  415. { dictLabel: "线路二", dictValue: 3 },
  416. ],
  417. uploadLoading:false,
  418. courseId:null,
  419. videoName:'',
  420. title: "",
  421. // 是否显示弹出层
  422. open: false,
  423. uploadUrl:process.env.VUE_APP_BASE_API+"/common/uploadOSS",
  424. baseUrl: process.env.VUE_APP_BASE_API,
  425. typeOptions:[],
  426. files:[],
  427. fileList: [],
  428. // 上传成功后的地址
  429. videoURL: '',
  430. // 进度条百分比
  431. progress: 0,
  432. // 上传视频获取成功后拿到的fileID【备用】
  433. fileId: '',
  434. courseName:null,
  435. userCourseVideoList:[],
  436. total: 0,
  437. redData:{
  438. queryParams: {
  439. pageNum: 1,
  440. pageSize: 99999,
  441. courseId:null,
  442. },
  443. list: [],
  444. open: false,
  445. loading:true,
  446. form:{
  447. }
  448. },
  449. queryParams: {
  450. pageNum: 1,
  451. pageSize: 10,
  452. courseId:null,
  453. title:null
  454. },
  455. addBatchData: {
  456. open: false,
  457. loading: true,
  458. form: {},
  459. select: [],
  460. total:0,
  461. queryParams: {
  462. pageNum: 1,
  463. pageSize: 10,
  464. resourceName: null,
  465. typeId: null,
  466. typeSubId: null
  467. },
  468. typeOptions: [],
  469. typeSubOptions: []
  470. },
  471. // 显示搜索条件
  472. showSearch: true,
  473. // 遮罩层
  474. loading: true,
  475. // 导出遮罩层
  476. exportLoading: false,
  477. // 选中数组
  478. ids: [],
  479. // 非单个禁用
  480. single: true,
  481. // 非多个禁用
  482. multiple: true,
  483. // 表单参数
  484. form: {},
  485. updateBatchData: {
  486. open: false,
  487. form:{}
  488. },
  489. // 表单校验
  490. rules: {
  491. title: [
  492. { required: true, message: "小节名称不能为空", trigger: "change" }
  493. ],
  494. courseSort: [
  495. { required: true, message: "排序不能为空", trigger: "change" }
  496. ],
  497. },
  498. // 评论弹窗数据
  499. commentDialog: {
  500. open: false,
  501. courseId: null,
  502. videoId: null,
  503. title: ""
  504. },
  505. }
  506. },
  507. created() {
  508. this.getDicts("sys_course_temp_type").then(response => {
  509. this.typeOptions = response.data;
  510. });
  511. },
  512. methods: {
  513. getPickerOptions() {
  514. const durationInMinutes = Math.floor(this.form.duration / 60); // 将秒转换为分钟
  515. const endHour = Math.floor(durationInMinutes / 60); // 起始小时
  516. const endMinute = durationInMinutes % 60; // 起始分钟
  517. return {
  518. start: "00:00", // 固定开始时间
  519. step: "00:01", // 时间间隔
  520. end: `${endHour.toString().padStart(2, "0")}:${endMinute
  521. .toString()
  522. .padStart(2, "0")}`, // 动态结束时间
  523. };
  524. },
  525. handlePackageDelete(row){
  526. this.packageList.splice(this.packageList.findIndex(item => item.packageId === row.packageId), 1)
  527. },
  528. choosePackage(){
  529. this.package.open=true;
  530. this.package.title='疗法选择';
  531. },
  532. /**
  533. * 选择课题
  534. */
  535. chooseQuestionBank(){
  536. this.questionBank.open=true;
  537. this.questionBank.title='课题选择';
  538. },
  539. //选择疗法
  540. selectPackage(row){
  541. const drug = {};
  542. for(var i=0;i<this.packageList.length;i++){
  543. if(this.packageList[i].packageId==row.packageId){
  544. this.$message.warning("疗法已存在!")
  545. return;
  546. }
  547. }
  548. drug.packageId=row.packageId;
  549. drug.packageName=row.packageName;
  550. drug.secondName=row.secondName;
  551. drug.totalPrice=row.totalPrice;
  552. drug.imgUrl=row.imgUrl;
  553. this.packageList.push(drug);
  554. this.$message({
  555. message: '添加成功',
  556. type: 'success'
  557. });
  558. },
  559. //选择结果
  560. questionBankResult(val){
  561. // 确保 questionBankList 是数组
  562. this.form.questionBankList = this.form.questionBankList || [];
  563. for(var i=0;i<this.form.questionBankList.length;i++){
  564. if(this.form.questionBankList[i].id==val.id){
  565. return this.$message.error("当前课题已选择")
  566. }
  567. }
  568. this.form.questionBankList.push(val);
  569. this.$message({
  570. message: '添加成功',
  571. type: 'success'
  572. });
  573. },
  574. //删除课题
  575. handleQuestionBankDelete(row){
  576. this.form.questionBankList.splice(this.form.questionBankList.findIndex(item => item.id === row.id), 1)
  577. },
  578. handleVideoChange(){
  579. if(this.form.uploadType==1){
  580. this.videoUrl = this.form.lineOne;
  581. }else if(this.form.uploadType==2){
  582. this.videoUrl = this.form.lineTwo;
  583. }else if(this.form.uploadType==3){
  584. this.videoUrl = this.form.lineThree;
  585. }
  586. // console.log("选择的video=======>>>>>>>",this.videoUrl)
  587. },
  588. // 视频库课题
  589. handleSelectProjects(projectIds) {
  590. this.form.questionBankList = []
  591. if (!projectIds || projectIds.length === 0 || this.isPrivate === 0) {
  592. return
  593. }
  594. const params = {ids: projectIds}
  595. getByIds(params).then(response => {
  596. if (response.code === 200) {
  597. response.data.forEach(item => {
  598. let isExist = this.form.questionBankList.some(q => q.id === item.id)
  599. if (!isExist) {
  600. this.form.questionBankList.push(item)
  601. }
  602. });
  603. }
  604. })
  605. },
  606. handleVideoDuration(duration) {
  607. this.form.duration = duration;
  608. },
  609. formatDuration(seconds) {
  610. if (seconds === null || seconds === undefined) {
  611. return '未上传视频'; // 或者您可以根据具体需求返回其他默认值
  612. }
  613. const hours = Math.floor(seconds / 3600);
  614. const minutes = Math.floor((seconds % 3600) / 60);
  615. const remainingSeconds = seconds % 60;
  616. const formattedHours = hours > 0 ? hours.toString() + ':' : '';
  617. const formattedMinutes = minutes.toString().padStart(2, '0');
  618. const formattedSeconds = remainingSeconds.toString().padStart(2, '0');
  619. return `${formattedHours}${formattedMinutes}:${formattedSeconds}`;
  620. },
  621. handleAvatarSuccess(res, file) {
  622. if(res.code==200){
  623. this.form.thumbnail=res.url;
  624. this.$forceUpdate()
  625. }
  626. else{
  627. this.msgError(res.msg);
  628. }
  629. },
  630. beforeAvatarUpload(file) {
  631. const isLt1M = file.size / 1024 / 1024 < 1;
  632. if (!isLt1M) {
  633. this.$message.error('上传图片大小不能超过 1MB!');
  634. }
  635. return isLt1M;
  636. },
  637. getDetails(courseId,courseName,isPrivate) {
  638. this.isPrivate = isPrivate
  639. this.courseName = courseName
  640. this.courseId = courseId;
  641. this.queryParams.courseId = courseId;
  642. this.getList();
  643. },
  644. getList() {
  645. this.loading = true;
  646. getVideoListByCourseId(this.queryParams).then(response => {
  647. this.userCourseVideoList = response.rows;
  648. this.total = response.total;
  649. this.loading = false;
  650. });
  651. },
  652. // 取消按钮
  653. cancel() {
  654. this.open = false;
  655. this.reset();
  656. },
  657. // 表单重置
  658. reset() {
  659. this.form = {
  660. videoId: null,
  661. title: null,
  662. description: null,
  663. url: null,
  664. thumbnail: null,
  665. duration: null,
  666. createTime: null,
  667. uploadType:null,
  668. lineOne:null,
  669. lineTwo:null,
  670. lineThree:null,
  671. fileName:null,
  672. userId: null,
  673. cateId: null,
  674. courseId: null,
  675. likes: null,
  676. views: null,
  677. comments: null,
  678. status: 0,
  679. courseSort: 1,
  680. isHot: null,
  681. isShow: null,
  682. isAudit: null,
  683. auditBy: null,
  684. auditTime: null,
  685. updateTime: null,
  686. source: null,
  687. isDel: null,
  688. shares: null,
  689. tags: null,
  690. productId: null,
  691. productJson: null,
  692. questionBankId:null,
  693. questionBankList:[],
  694. redPacketMoney:0,
  695. };
  696. this.videoURL = '';
  697. this.progress=0;
  698. this.resetForm("form");
  699. },
  700. /** 搜索按钮操作 */
  701. handleQuery() {
  702. this.queryParams.pageNum = 1;
  703. this.getList();
  704. },
  705. /** 重置按钮操作 */
  706. resetQuery() {
  707. this.resetForm("queryForm");
  708. this.handleQuery();
  709. },
  710. // 多选框选中数据
  711. handleSelectionChange(selection) {
  712. this.ids = selection.map(item => item.videoId)
  713. this.single = selection.length!==1
  714. this.multiple = !selection.length
  715. },
  716. // 多选框选中数据
  717. handVideoleSelectionChange(selection) {
  718. this.addBatchData.select = selection.map(item => item.id);
  719. },
  720. handleAdd(){
  721. this.reset();
  722. this.form.courseId = this.courseId;
  723. this.open = true;
  724. this.title = "添加课堂视频";
  725. this.videoUrl = '';
  726. this.packageList=[];
  727. getSort(this.courseId).then(response => {
  728. this.form.courseSort = Number(response.data);
  729. })
  730. setTimeout(() => {
  731. this.$refs.videoUpload.resetUpload();
  732. }, 500);
  733. },
  734. /** 修改按钮操作 */
  735. handleUpdate(row) {
  736. this.reset();
  737. this.packageList=[];
  738. const videoId = row.videoId || this.ids
  739. getUserCourseVideo(videoId).then(response => {
  740. this.form = response.data;
  741. if(response.data.videoUrl!=null && response.data.videoUrl!==''){
  742. this.videoUrl = response.data.videoUrl;
  743. }
  744. if (this.form.packageJson!=null){
  745. this.packageList = JSON.parse(this.form.packageJson);
  746. }
  747. if(response.data.viewStartTime != null && response.data.viewEndTime != null){
  748. this.form.timeRange = [response.data.viewStartTime, response.data.viewEndTime]
  749. }
  750. setTimeout(() => {
  751. this.$refs.videoUpload.resetUpload();
  752. }, 500);
  753. this.open = true;
  754. this.title = "修改课堂视频";
  755. });
  756. },
  757. /** 提交按钮 */
  758. submitForm() {
  759. this.$refs["form"].validate(valid => {
  760. if (valid) {
  761. this.form.videoUrl = this.videoUrl;
  762. if(this.form.videoUrl==null || this.form.videoUrl===''){
  763. this.$message({
  764. message: '请上传视频!',
  765. type: 'warning'
  766. });
  767. return
  768. }
  769. if(this.form.timeRange != null && this.form.timeRange.length === 2){
  770. this.form.viewStartTime = this.form.timeRange[0];
  771. this.form.viewEndTime = this.form.timeRange[1];
  772. }
  773. if(this.form.duration==null){
  774. this.$message({
  775. message: '未识别到视频时长请稍等。。。',
  776. type: 'warning'
  777. });
  778. return
  779. }
  780. if(this.form.uploadType==null){
  781. this.$message({
  782. message: '请选择播放线路!',
  783. type: 'warning'
  784. });
  785. return
  786. }
  787. if (this.form.questionBankList!==null){
  788. this.form.questionBankId = this.form.questionBankList.map(item => item.id).join(',');
  789. }
  790. if (this.packageList.length>0){
  791. this.form.packageJson = JSON.stringify(this.packageList);
  792. }
  793. if (this.form.videoId != null) {
  794. updateUserCourseVideo(this.form).then(response => {
  795. this.msgSuccess("修改成功");
  796. this.open = false;
  797. this.getList();
  798. });
  799. } else {
  800. addUserCourseVideo(this.form).then(response => {
  801. this.msgSuccess("新增成功");
  802. this.open = false;
  803. this.getList();
  804. });
  805. }
  806. }
  807. });
  808. },
  809. openUpdates(){
  810. this.updateBatchData.form = {};
  811. this.updateBatchData.open = true;
  812. },
  813. /** 提交按钮 */
  814. updateBatch() {
  815. this.updateBatchData.form.ids = this.ids;
  816. if(this.updateBatchData.form.timeRange != null && this.updateBatchData.form.timeRange.length === 2){
  817. this.updateBatchData.form.viewStartTime = this.updateBatchData.form.timeRange[0];
  818. this.updateBatchData.form.viewEndTime = this.updateBatchData.form.timeRange[1];
  819. }
  820. updates(this.updateBatchData.form).then(response => {
  821. this.msgSuccess("修改成功");
  822. this.updateBatchData.open = false;
  823. this.getList();
  824. });
  825. },
  826. /** 删除按钮操作 */
  827. handleDelete(row) {
  828. const videoIds = row.videoId || this.ids;
  829. this.$confirm('是否确认删除视频编号为"' + videoIds + '"的数据项?', "警告", {
  830. confirmButtonText: "确定",
  831. cancelButtonText: "取消",
  832. type: "warning"
  833. }).then(function() {
  834. return delUserCourseVideo(videoIds);
  835. }).then(() => {
  836. this.getList();
  837. this.msgSuccess("删除成功");
  838. }).catch(() => {});
  839. },
  840. openAdds(){
  841. this.addBatchData.open = true;
  842. this.getRootTypeList();
  843. this.addBatchData.form = {
  844. courseId: this.courseId,
  845. };
  846. this.resourceList();
  847. },
  848. getRootTypeList() {
  849. getCatePidList().then(response => {
  850. this.addBatchData.typeOptions = response.data
  851. });
  852. },
  853. async changeCateType(val) {
  854. this.addBatchData.queryParams.typeSubId = null
  855. this.addBatchData.typeSubOptions = []
  856. if (!val) {
  857. return
  858. }
  859. await getCateListByPid(val).then(response => {
  860. this.addBatchData.typeSubOptions = response.data
  861. })
  862. },
  863. resourceList(){
  864. this.addBatchData.loading = true;
  865. listVideoResource(this.addBatchData.queryParams).then(response => {
  866. this.addBatchData.loading = false;
  867. this.addBatchData.list = response.rows;
  868. this.addBatchData.total = response.total;
  869. });
  870. },
  871. batchVideoSave(){
  872. if (this.addBatchData.select.length===0){
  873. this.$message({
  874. message: '请选择视频!!',
  875. type: 'warning'
  876. });
  877. return
  878. }
  879. console.log(this.addBatchData.select)
  880. this.addBatchData.form.ids = this.addBatchData.select;
  881. batchSaveVideo(this.addBatchData.form).then(response => {
  882. this.addBatchData.open = false;
  883. this.getList();
  884. })
  885. },
  886. updateRedPageckeOpen(){
  887. this.redData.open = true;
  888. this.redData.loading = true;
  889. this.redData.queryParams.courseId = this.courseId;
  890. getVideoListByCourseId(this.redData.queryParams).then(response => {
  891. this.redData.list = response.rows;
  892. this.redData.loading = false;
  893. });
  894. },
  895. batchRedSave(){
  896. batchUpdateRed(this.redData.list).then(response => {
  897. this.redData.open = false;
  898. this.getList();
  899. })
  900. },
  901. /** 查看评论按钮操作 */
  902. handleComment(row) {
  903. this.commentDialog.courseId = row.courseId || this.courseId;
  904. this.commentDialog.videoId = row.videoId;
  905. this.commentDialog.title = `查看评论 - ${row.title}`;
  906. this.commentDialog.open = true;
  907. },
  908. }
  909. }
  910. </script>
  911. <style>
  912. .avatar-uploader .el-upload {
  913. border: 1px dashed #d9d9d9;
  914. border-radius: 6px;
  915. cursor: pointer;
  916. position: relative;
  917. overflow: hidden;
  918. }
  919. .avatar-uploader .el-upload:hover {
  920. border-color: #409EFF;
  921. }
  922. .avatar-uploader-icon {
  923. font-size: 28px;
  924. color: #8c939d;
  925. width: 150px;
  926. height: 150px;
  927. line-height: 150px;
  928. text-align: center;
  929. }
  930. </style>