userCourseCatalogDetails.vue 37 KB

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