userCourseCatalogDetails.vue 37 KB

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