userCourseCatalogDetails.vue 31 KB

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