userCourseCatalogDetails.vue 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917
  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>
  286. <el-button type="primary" icon="el-icon-search" size="mini" @click="resourceList">搜索</el-button>
  287. </el-form-item>
  288. </el-form>
  289. <!-- 视频列表 -->
  290. <el-table v-loading="addBatchData.loading" :data="addBatchData.list" @selection-change="handVideoleSelectionChange" height="400px">
  291. <el-table-column type="selection" width="55" align="center" />
  292. <el-table-column label="素材名称" align="center" prop="resourceName" />
  293. <el-table-column label="文件名称" align="center" prop="fileName" />
  294. <el-table-column label="缩略图" align="center">
  295. <template slot-scope="scope">
  296. <el-popover
  297. placement="right"
  298. title=""
  299. trigger="hover"
  300. >
  301. <img alt="" slot="reference" :src="scope.row.thumbnail" style="width: 80px; height: 50px" />
  302. <img alt="" :src="scope.row.thumbnail" style="max-width: 150px;" />
  303. </el-popover>
  304. </template>
  305. </el-table-column>
  306. <el-table-column label="视频时长" align="center">
  307. <template slot-scope="scope">
  308. <span>{{ formatDuration(scope.row.duration) }}</span>
  309. </template>
  310. </el-table-column>
  311. </el-table>
  312. <!-- 分页 -->
  313. <pagination
  314. v-show="addBatchData.total>0"
  315. :total="addBatchData.total"
  316. :page.sync="addBatchData.queryParams.pageNum"
  317. :limit.sync="addBatchData.queryParams.pageSize"
  318. @pagination="resourceList"
  319. />
  320. <div slot="footer" class="dialog-footer">
  321. <el-button type="primary" @click="batchVideoSave">确 定</el-button>
  322. </div>
  323. </el-dialog>
  324. <el-dialog title="章节红包" :visible.sync="redData.open" width="900px" append-to-body>
  325. <el-table border v-loading="redData.loading" :data="redData.list" height="600px">
  326. <el-table-column label="小节名称" align="center" show-overflow-tooltip prop="title" />
  327. <el-table-column label="视频文件名称" align="center" show-overflow-tooltip prop="fileName" >
  328. </el-table-column>
  329. <el-table-column label="视频时长" align="center" prop="duration">
  330. <template slot-scope="{ row }">
  331. {{ formatDuration(row.duration) }}
  332. </template>
  333. </el-table-column>
  334. <el-table-column label="红包金额" align="center" prop="redPacketMoney">
  335. <template slot-scope="scope">
  336. <el-input class="el-input" v-model="scope.row.redPacketMoney" />
  337. </template>
  338. </el-table-column>
  339. <el-table-column label="排序" align="center" prop="courseSort" />
  340. <el-table-column label="上传时间" align="center" prop="createTime" />
  341. </el-table>
  342. <div slot="footer" class="dialog-footer">
  343. <el-button type="primary" @click="batchRedSave">确 定</el-button>
  344. </div>
  345. </el-dialog>
  346. <el-dialog :title="commentDialog.title" :visible.sync="commentDialog.open" width="1000px" append-to-body :close-on-click-modal="false">
  347. <course-watch-comment
  348. ref="courseWatchComment"
  349. :courseId="commentDialog.courseId"
  350. :videoId="commentDialog.videoId"
  351. v-if="commentDialog.open">
  352. </course-watch-comment>
  353. </el-dialog>
  354. </div>
  355. </template>
  356. <script>
  357. import {
  358. addUserCourseVideo,
  359. delUserCourseVideo,
  360. getSort,
  361. getUserCourseVideo,
  362. getVideoListByCourseId,
  363. updates,
  364. batchSaveVideo,
  365. batchUpdateRed,
  366. updateUserCourseVideo
  367. } from "@/api/course/userCourseVideo";
  368. import QuestionBank from "@/views/course/courseQuestionBank/QuestionBank.vue";
  369. import VideoUpload from "@/components/VideoUpload/index.vue";
  370. import { listVideoResource } from '@/api/course/videoResource';
  371. import { getByIds } from '@/api/course/courseQuestionBank'
  372. import CourseWatchComment from "./courseWatchComment.vue";
  373. export default {
  374. name: "userCourseCatalog",
  375. components: {VideoUpload,QuestionBank,CourseWatchComment},
  376. data() {
  377. return {
  378. duration: null,
  379. packageList:[],
  380. //课题
  381. package:{
  382. title:'',
  383. open:false,
  384. },
  385. //课题
  386. questionBank:{
  387. title:'',
  388. open:false,
  389. },
  390. isPrivate:null,
  391. videoUrl: "",
  392. uploadTypeOptions: [
  393. { dictLabel: "线路一", dictValue: 2 },
  394. { dictLabel: "线路二", dictValue: 3 },
  395. ],
  396. uploadLoading:false,
  397. courseId:null,
  398. videoName:'',
  399. title: "",
  400. // 是否显示弹出层
  401. open: false,
  402. uploadUrl:process.env.VUE_APP_BASE_API+"/common/uploadOSS",
  403. baseUrl: process.env.VUE_APP_BASE_API,
  404. typeOptions:[],
  405. files:[],
  406. fileList: [],
  407. // 上传成功后的地址
  408. videoURL: '',
  409. // 进度条百分比
  410. progress: 0,
  411. // 上传视频获取成功后拿到的fileID【备用】
  412. fileId: '',
  413. courseName:null,
  414. userCourseVideoList:[],
  415. total: 0,
  416. redData:{
  417. queryParams: {
  418. pageNum: 1,
  419. pageSize: 99999,
  420. courseId:null,
  421. },
  422. list: [],
  423. open: false,
  424. loading:true,
  425. form:{
  426. }
  427. },
  428. queryParams: {
  429. pageNum: 1,
  430. pageSize: 10,
  431. courseId:null,
  432. title:null
  433. },
  434. addBatchData: {
  435. open: false,
  436. loading: true,
  437. form: {},
  438. select: [],
  439. total:0,
  440. queryParams: {
  441. pageNum: 1,
  442. pageSize: 10,
  443. },
  444. },
  445. // 显示搜索条件
  446. showSearch: true,
  447. // 遮罩层
  448. loading: true,
  449. // 导出遮罩层
  450. exportLoading: false,
  451. // 选中数组
  452. ids: [],
  453. // 非单个禁用
  454. single: true,
  455. // 非多个禁用
  456. multiple: true,
  457. // 表单参数
  458. form: {},
  459. updateBatchData: {
  460. open: false,
  461. form:{}
  462. },
  463. // 表单校验
  464. rules: {
  465. title: [
  466. { required: true, message: "小节名称不能为空", trigger: "change" }
  467. ],
  468. courseSort: [
  469. { required: true, message: "排序不能为空", trigger: "change" }
  470. ],
  471. },
  472. // 评论弹窗数据
  473. commentDialog: {
  474. open: false,
  475. courseId: null,
  476. videoId: null,
  477. title: ""
  478. },
  479. }
  480. },
  481. created() {
  482. this.getDicts("sys_course_temp_type").then(response => {
  483. this.typeOptions = response.data;
  484. });
  485. },
  486. methods: {
  487. getPickerOptions() {
  488. const durationInMinutes = Math.floor(this.form.duration / 60); // 将秒转换为分钟
  489. const endHour = Math.floor(durationInMinutes / 60); // 起始小时
  490. const endMinute = durationInMinutes % 60; // 起始分钟
  491. return {
  492. start: "00:00", // 固定开始时间
  493. step: "00:01", // 时间间隔
  494. end: `${endHour.toString().padStart(2, "0")}:${endMinute
  495. .toString()
  496. .padStart(2, "0")}`, // 动态结束时间
  497. };
  498. },
  499. handlePackageDelete(row){
  500. this.packageList.splice(this.packageList.findIndex(item => item.packageId === row.packageId), 1)
  501. },
  502. choosePackage(){
  503. this.package.open=true;
  504. this.package.title='疗法选择';
  505. },
  506. /**
  507. * 选择课题
  508. */
  509. chooseQuestionBank(){
  510. this.questionBank.open=true;
  511. this.questionBank.title='课题选择';
  512. },
  513. //选择疗法
  514. selectPackage(row){
  515. const drug = {};
  516. for(var i=0;i<this.packageList.length;i++){
  517. if(this.packageList[i].packageId==row.packageId){
  518. this.$message.warning("疗法已存在!")
  519. return;
  520. }
  521. }
  522. drug.packageId=row.packageId;
  523. drug.packageName=row.packageName;
  524. drug.secondName=row.secondName;
  525. drug.totalPrice=row.totalPrice;
  526. drug.imgUrl=row.imgUrl;
  527. this.packageList.push(drug);
  528. this.$message({
  529. message: '添加成功',
  530. type: 'success'
  531. });
  532. },
  533. //选择结果
  534. questionBankResult(val){
  535. // 确保 questionBankList 是数组
  536. this.form.questionBankList = this.form.questionBankList || [];
  537. for(var i=0;i<this.form.questionBankList.length;i++){
  538. if(this.form.questionBankList[i].id==val.id){
  539. return this.$message.error("当前课题已选择")
  540. }
  541. }
  542. this.form.questionBankList.push(val);
  543. this.$message({
  544. message: '添加成功',
  545. type: 'success'
  546. });
  547. },
  548. //删除课题
  549. handleQuestionBankDelete(row){
  550. this.form.questionBankList.splice(this.form.questionBankList.findIndex(item => item.id === row.id), 1)
  551. },
  552. handleVideoChange(){
  553. if(this.form.uploadType==1){
  554. this.videoUrl = this.form.lineOne;
  555. }else if(this.form.uploadType==2){
  556. this.videoUrl = this.form.lineTwo;
  557. }else if(this.form.uploadType==3){
  558. this.videoUrl = this.form.lineThree;
  559. }
  560. // console.log("选择的video=======>>>>>>>",this.videoUrl)
  561. },
  562. // 视频库课题
  563. handleSelectProjects(projectIds) {
  564. this.form.questionBankList = []
  565. if (!projectIds || projectIds.length === 0 || this.isPrivate === 0) {
  566. return
  567. }
  568. const params = {ids: projectIds}
  569. getByIds(params).then(response => {
  570. if (response.code === 200) {
  571. response.data.forEach(item => {
  572. let isExist = this.form.questionBankList.some(q => q.id === item.id)
  573. if (!isExist) {
  574. this.form.questionBankList.push(item)
  575. }
  576. });
  577. }
  578. })
  579. },
  580. handleVideoDuration(duration) {
  581. this.form.duration = duration;
  582. },
  583. formatDuration(seconds) {
  584. if (seconds === null || seconds === undefined) {
  585. return '未上传视频'; // 或者您可以根据具体需求返回其他默认值
  586. }
  587. const hours = Math.floor(seconds / 3600);
  588. const minutes = Math.floor((seconds % 3600) / 60);
  589. const remainingSeconds = seconds % 60;
  590. const formattedHours = hours > 0 ? hours.toString() + ':' : '';
  591. const formattedMinutes = minutes.toString().padStart(2, '0');
  592. const formattedSeconds = remainingSeconds.toString().padStart(2, '0');
  593. return `${formattedHours}${formattedMinutes}:${formattedSeconds}`;
  594. },
  595. handleAvatarSuccess(res, file) {
  596. if(res.code==200){
  597. this.form.thumbnail=res.url;
  598. this.$forceUpdate()
  599. }
  600. else{
  601. this.msgError(res.msg);
  602. }
  603. },
  604. beforeAvatarUpload(file) {
  605. const isLt1M = file.size / 1024 / 1024 < 1;
  606. if (!isLt1M) {
  607. this.$message.error('上传图片大小不能超过 1MB!');
  608. }
  609. return isLt1M;
  610. },
  611. getDetails(courseId,courseName,isPrivate) {
  612. this.isPrivate = isPrivate
  613. this.courseName = courseName
  614. this.courseId = courseId;
  615. this.queryParams.courseId = courseId;
  616. this.getList();
  617. },
  618. getList() {
  619. this.loading = true;
  620. getVideoListByCourseId(this.queryParams).then(response => {
  621. this.userCourseVideoList = response.rows;
  622. this.total = response.total;
  623. this.loading = false;
  624. });
  625. },
  626. // 取消按钮
  627. cancel() {
  628. this.open = false;
  629. this.reset();
  630. },
  631. // 表单重置
  632. reset() {
  633. this.form = {
  634. videoId: null,
  635. title: null,
  636. description: null,
  637. url: null,
  638. thumbnail: null,
  639. duration: null,
  640. createTime: null,
  641. uploadType:null,
  642. lineOne:null,
  643. lineTwo:null,
  644. lineThree:null,
  645. fileName:null,
  646. userId: null,
  647. cateId: null,
  648. courseId: null,
  649. likes: null,
  650. views: null,
  651. comments: null,
  652. status: 0,
  653. courseSort: 1,
  654. isHot: null,
  655. isShow: null,
  656. isAudit: null,
  657. auditBy: null,
  658. auditTime: null,
  659. updateTime: null,
  660. source: null,
  661. isDel: null,
  662. shares: null,
  663. tags: null,
  664. productId: null,
  665. productJson: null,
  666. questionBankId:null,
  667. questionBankList:[],
  668. redPacketMoney:0,
  669. };
  670. this.videoURL = '';
  671. this.progress=0;
  672. this.resetForm("form");
  673. },
  674. /** 搜索按钮操作 */
  675. handleQuery() {
  676. this.queryParams.pageNum = 1;
  677. this.getList();
  678. },
  679. /** 重置按钮操作 */
  680. resetQuery() {
  681. this.resetForm("queryForm");
  682. this.handleQuery();
  683. },
  684. // 多选框选中数据
  685. handleSelectionChange(selection) {
  686. this.ids = selection.map(item => item.videoId)
  687. this.single = selection.length!==1
  688. this.multiple = !selection.length
  689. },
  690. // 多选框选中数据
  691. handVideoleSelectionChange(selection) {
  692. this.addBatchData.select = selection.map(item => item.id);
  693. },
  694. handleAdd(){
  695. this.reset();
  696. this.form.courseId = this.courseId;
  697. this.open = true;
  698. this.title = "添加课堂视频";
  699. this.videoUrl = '';
  700. this.packageList=[];
  701. getSort(this.courseId).then(response => {
  702. this.form.courseSort = Number(response.data);
  703. })
  704. setTimeout(() => {
  705. this.$refs.videoUpload.resetUpload();
  706. }, 500);
  707. },
  708. /** 修改按钮操作 */
  709. handleUpdate(row) {
  710. this.reset();
  711. this.packageList=[];
  712. const videoId = row.videoId || this.ids
  713. getUserCourseVideo(videoId).then(response => {
  714. this.form = response.data;
  715. if(response.data.videoUrl!=null && response.data.videoUrl!==''){
  716. this.videoUrl = response.data.videoUrl;
  717. }
  718. if (this.form.packageJson!=null){
  719. this.packageList = JSON.parse(this.form.packageJson);
  720. }
  721. if(response.data.viewStartTime != null && response.data.viewEndTime != null){
  722. this.form.timeRange = [response.data.viewStartTime, response.data.viewEndTime]
  723. }
  724. setTimeout(() => {
  725. this.$refs.videoUpload.resetUpload();
  726. }, 500);
  727. this.open = true;
  728. this.title = "修改课堂视频";
  729. });
  730. },
  731. /** 提交按钮 */
  732. submitForm() {
  733. this.$refs["form"].validate(valid => {
  734. if (valid) {
  735. this.form.videoUrl = this.videoUrl;
  736. if(this.form.videoUrl==null || this.form.videoUrl===''){
  737. this.$message({
  738. message: '请上传视频!',
  739. type: 'warning'
  740. });
  741. return
  742. }
  743. if(this.form.timeRange != null && this.form.timeRange.length === 2){
  744. this.form.viewStartTime = this.form.timeRange[0];
  745. this.form.viewEndTime = this.form.timeRange[1];
  746. }
  747. if(this.form.duration==null){
  748. this.$message({
  749. message: '未识别到视频时长请稍等。。。',
  750. type: 'warning'
  751. });
  752. return
  753. }
  754. if(this.form.uploadType==null){
  755. this.$message({
  756. message: '请选择播放线路!',
  757. type: 'warning'
  758. });
  759. return
  760. }
  761. if (this.form.questionBankList!==null){
  762. this.form.questionBankId = this.form.questionBankList.map(item => item.id).join(',');
  763. }
  764. if (this.packageList.length>0){
  765. this.form.packageJson = JSON.stringify(this.packageList);
  766. }
  767. if (this.form.videoId != null) {
  768. updateUserCourseVideo(this.form).then(response => {
  769. this.msgSuccess("修改成功");
  770. this.open = false;
  771. this.getList();
  772. });
  773. } else {
  774. addUserCourseVideo(this.form).then(response => {
  775. this.msgSuccess("新增成功");
  776. this.open = false;
  777. this.getList();
  778. });
  779. }
  780. }
  781. });
  782. },
  783. openUpdates(){
  784. this.updateBatchData.form = {};
  785. this.updateBatchData.open = true;
  786. },
  787. /** 提交按钮 */
  788. updateBatch() {
  789. this.updateBatchData.form.ids = this.ids;
  790. if(this.updateBatchData.form.timeRange != null && this.updateBatchData.form.timeRange.length === 2){
  791. this.updateBatchData.form.viewStartTime = this.updateBatchData.form.timeRange[0];
  792. this.updateBatchData.form.viewEndTime = this.updateBatchData.form.timeRange[1];
  793. }
  794. updates(this.updateBatchData.form).then(response => {
  795. this.msgSuccess("修改成功");
  796. this.updateBatchData.open = false;
  797. this.getList();
  798. });
  799. },
  800. /** 删除按钮操作 */
  801. handleDelete(row) {
  802. const videoIds = row.videoId || this.ids;
  803. this.$confirm('是否确认删除视频编号为"' + videoIds + '"的数据项?', "警告", {
  804. confirmButtonText: "确定",
  805. cancelButtonText: "取消",
  806. type: "warning"
  807. }).then(function() {
  808. return delUserCourseVideo(videoIds);
  809. }).then(() => {
  810. this.getList();
  811. this.msgSuccess("删除成功");
  812. }).catch(() => {});
  813. },
  814. openAdds(){
  815. this.addBatchData.open = true;
  816. this.addBatchData.form = {
  817. courseId: this.courseId,
  818. };
  819. this.resourceList();
  820. },
  821. resourceList(){
  822. this.addBatchData.loading = true;
  823. listVideoResource(this.addBatchData.queryParams).then(response => {
  824. this.addBatchData.loading = false;
  825. this.addBatchData.list = response.rows;
  826. this.addBatchData.total = response.total;
  827. });
  828. },
  829. batchVideoSave(){
  830. if (this.addBatchData.select.length===0){
  831. this.$message({
  832. message: '请选择视频!!',
  833. type: 'warning'
  834. });
  835. return
  836. }
  837. console.log(this.addBatchData.select)
  838. this.addBatchData.form.ids = this.addBatchData.select;
  839. batchSaveVideo(this.addBatchData.form).then(response => {
  840. this.addBatchData.open = false;
  841. this.getList();
  842. })
  843. },
  844. updateRedPageckeOpen(){
  845. this.redData.open = true;
  846. this.redData.loading = true;
  847. this.redData.queryParams.courseId = this.courseId;
  848. getVideoListByCourseId(this.redData.queryParams).then(response => {
  849. this.redData.list = response.rows;
  850. this.redData.loading = false;
  851. });
  852. },
  853. batchRedSave(){
  854. batchUpdateRed(this.redData.list).then(response => {
  855. this.redData.open = false;
  856. this.getList();
  857. })
  858. },
  859. /** 查看评论按钮操作 */
  860. handleComment(row) {
  861. this.commentDialog.courseId = row.courseId || this.courseId;
  862. this.commentDialog.videoId = row.videoId;
  863. this.commentDialog.title = `查看评论 - ${row.title}`;
  864. this.commentDialog.open = true;
  865. },
  866. }
  867. }
  868. </script>
  869. <style>
  870. .avatar-uploader .el-upload {
  871. border: 1px dashed #d9d9d9;
  872. border-radius: 6px;
  873. cursor: pointer;
  874. position: relative;
  875. overflow: hidden;
  876. }
  877. .avatar-uploader .el-upload:hover {
  878. border-color: #409EFF;
  879. }
  880. .avatar-uploader-icon {
  881. font-size: 28px;
  882. color: #8c939d;
  883. width: 150px;
  884. height: 150px;
  885. line-height: 150px;
  886. text-align: center;
  887. }
  888. </style>