userCourseCatalogDetails.vue 36 KB

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