userCourseCatalogDetails.vue 33 KB

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