userCourseCatalogDetails.vue 38 KB

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