userCourseCatalogDetails.vue 29 KB

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