userCourseCatalogDetails.vue 43 KB

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