userCourseCatalogDetails.vue 38 KB

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