userCourseCatalogDetails.vue 28 KB

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