userCourseCatalogDetails.vue 35 KB

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