userCourseCatalogDetailsZM.vue 56 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549
  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 label="小节id" prop="videoId">
  12. <el-input v-model="queryParams.videoId" placeholder="请输入小节id" clearable size="small"
  13. @keyup.enter.native="handleQuery"/>
  14. </el-form-item>
  15. <el-form-item>
  16. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  17. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  18. </el-form-item>
  19. </el-form>
  20. <el-row :gutter="10" class="mb8">
  21. <el-col :span="1.5">
  22. <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
  23. v-hasPermi="['course:userCourseVideo:add']">新增目录
  24. </el-button>
  25. </el-col>
  26. <el-col :span="1.5">
  27. <el-button type="primary" plain :disabled="!ids || ids.length <= 0" size="mini" @click="openUpdates"
  28. v-hasPermi="['course:userCourseVideo:updateTime']">修改时间
  29. </el-button>
  30. </el-col>
  31. <el-col :span="1.5">
  32. <el-button type="primary" plain size="mini" @click="openAdds"
  33. v-hasPermi="['course:userCourseVideo:batchAdd']">批量添加
  34. </el-button>
  35. </el-col>
  36. <el-col :span="1.5">
  37. <el-button type="primary" plain size="mini" @click="updateRedPageckeOpen"
  38. v-hasPermi="['course:userCourseVideo:updateRed']">修改红包
  39. </el-button>
  40. </el-col>
  41. <el-col :span="1.5">
  42. <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
  43. v-hasPermi="['course:userCourseVideo:remove']">删除
  44. </el-button>
  45. </el-col>
  46. <el-col :span="1.5">
  47. <el-button type="warning" plain icon="el-icon-edit" size="mini" @click="handleCourseSort"
  48. v-hasPermi="['course:userCourseVideo:sort']">修改课节排序
  49. </el-button>
  50. </el-col>
  51. <el-col :span="1.5">
  52. <el-button type="primary" plain icon="el-icon-delete" size="mini" @click="handleSync"
  53. v-hasPermi="['course:userCourseVideo:sync']">同步模板数据
  54. </el-button>
  55. </el-col>
  56. <el-col :span="1.5">
  57. <el-button type="primary" plain icon="el-icon-edit" size="mini" :disabled="multiple" @click="handleDown"
  58. v-hasPermi="['course:userCourseVideo:batchDown']">批量下架
  59. </el-button>
  60. </el-col>
  61. <el-col :span="1.5">
  62. <el-button type="primary" plain icon="el-icon-edit" size="mini" :disabled="multiple" @click="handleUp"
  63. v-hasPermi="['course:userCourseVideo:batchUp']">批量上架</el-button>
  64. </el-col>
  65. <el-col :span="1.5">
  66. <el-button type="primary" plain icon="el-icon-edit" size="mini" :disabled="multiple" @click="handleEditCover"
  67. v-hasPermi="['course:userCourseVideo:batchEditCover']">批量修改封面图
  68. </el-button>
  69. </el-col>
  70. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  71. </el-row>
  72. <el-table border v-loading="loading" :data="userCourseVideoList" @selection-change="handleSelectionChange">
  73. <el-table-column type="selection" width="55" align="center"/>
  74. <el-table-column label="视频ID" align="center" prop="videoId"/>
  75. <el-table-column label="小节名称" align="center" show-overflow-tooltip prop="title"/>
  76. <el-table-column label="视频文件名称" align="center" show-overflow-tooltip prop="fileName">
  77. </el-table-column>
  78. <el-table-column label="视频时长" align="center" prop="duration">
  79. <template slot-scope="{ row }">
  80. {{ formatDuration(row.duration) }}
  81. </template>
  82. </el-table-column>
  83. <el-table-column label="看课开始时间" align="center" prop="duration">
  84. <template slot-scope="{ row }">
  85. <el-tag v-if="row.viewStartTime">{{ row.viewStartTime }}</el-tag>
  86. <el-tag type="danger" v-if="!row.viewStartTime">无</el-tag>
  87. </template>
  88. </el-table-column>
  89. <el-table-column label="看课结束时间" align="center" prop="duration">
  90. <template slot-scope="{ row }">
  91. <el-tag v-if="row.viewEndTime">{{ row.viewEndTime }}</el-tag>
  92. <el-tag type="danger" v-if="!row.viewEndTime">无</el-tag>
  93. </template>
  94. </el-table-column>
  95. <el-table-column label="领取红包时间" align="center" prop="duration">
  96. <template slot-scope="{ row }">
  97. <el-tag v-if="row.lastJoinTime">{{ row.lastJoinTime }}</el-tag>
  98. <el-tag type="danger" v-if="!row.lastJoinTime">无</el-tag>
  99. </template>
  100. </el-table-column>
  101. <el-table-column label="红包金额" align="center" prop="redPacketMoney"/>
  102. <el-table-column label="排序" align="center" prop="courseSort"/>
  103. <el-table-column label="上传时间" align="center" prop="createTime"/>
  104. <el-table-column label="是否上架" align="center" prop="isOnPut">
  105. <template slot-scope="{ row }">
  106. <el-tag v-if="row.isOnPut == 0">是</el-tag>
  107. <el-tag type="danger" v-if="row.isOnPut == 1">否</el-tag>
  108. </template>
  109. </el-table-column>
  110. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  111. <template slot-scope="scope">
  112. <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
  113. v-hasPermi="['course:userCourseVideo:edit']">修改
  114. </el-button>
  115. <el-button size="mini" type="text" icon="el-icon-edit" @click="handleComment(scope.row)"
  116. v-hasPermi="['course:courseWatchComment:list']">查看评论
  117. </el-button>
  118. <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
  119. v-hasPermi="['course:userCourseVideo:remove']">删除
  120. </el-button>
  121. </template>
  122. </el-table-column>
  123. </el-table>
  124. <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
  125. @pagination="getList"/>
  126. <el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
  127. <el-form ref="form" :model="form" :rules="rules" label-width="110px" v-loading="uploadLoading">
  128. <el-form-item label="视频标题" prop="title">
  129. <el-input v-model="form.title" placeholder="请输入内容"/>
  130. </el-form-item>
  131. <el-form-item label="视频描述" prop="description">
  132. <el-input v-model="form.description" type="textarea" :rows="2" placeholder="请输入内容"/>
  133. </el-form-item>
  134. <el-form-item label="课程排序" prop="courseSort">
  135. <el-input-number v-model="form.courseSort" :min="1"></el-input-number>
  136. </el-form-item>
  137. <el-form-item label="视频缩略图" prop="thumbnail">
  138. <el-upload v-model="form.thumbnail" class="avatar-uploader" :action="uploadUrl" :show-file-list="false"
  139. :on-success="handleAvatarSuccess" :before-upload="beforeAvatarUpload">
  140. <img v-if="form.thumbnail" :src="form.thumbnail" class="avatar" width="300px">
  141. <i v-else class="el-icon-plus avatar-uploader-icon"></i>
  142. </el-upload>
  143. </el-form-item>
  144. <video-upload :type="1" :isPrivate="isPrivate" :fileKey.sync="form.fileKey" :fileSize.sync="form.fileSize"
  145. :videoUrl.sync="videoUrl" :fileName.sync="form.fileName" :line_1.sync="form.lineOne"
  146. :line_2.sync="form.lineTwo" :line_3.sync="form.lineThree" :thumbnail.sync="form.thumbnail"
  147. :uploadType.sync="form.uploadType" :isTranscode.sync="form.isTranscode"
  148. :transcodeFileKey.sync="form.transcodeFileKey" @video-duration="handleVideoDuration"
  149. @change="handleVideoChange" @selectProjects="handleSelectProjects" ref="videoUpload"
  150. append-to-body/>
  151. <el-form-item label="关联疗法" >
  152. <el-button size="small" type="primary" @click="choosePackage">选取疗法</el-button>
  153. <el-table border width="100%" style="margin-top:5px;" :data="packageList">
  154. <el-table-column label="疗法名称" align="center" prop="packageName"/>
  155. <el-table-column label="疗法图片" align="center" prop="imgUrl">
  156. <template slot-scope="scope">
  157. <img :src="scope.row.imgUrl" style="height: 80px;">
  158. </template>
  159. </el-table-column>
  160. <el-table-column label="疗法别名" align="center" prop="secondName"/>
  161. <el-table-column label="总金额" align="center" prop="totalPrice"/>
  162. <!-- 根据课程类型控制是否显示弹出时间列:0是公域(显示),1是私域(不显示) -->
  163. <el-table-column label="弹出时间" align="center" width="250px" v-if="isPrivate == 0">
  164. <template slot-scope="scope">
  165. <div>
  166. <el-time-select
  167. v-model="scope.row.duration"
  168. size="mini"
  169. placeholder="选择时间"
  170. :picker-options="getPickerOptions()"
  171. @change="handleTimeChange(scope.$index, scope.row)"
  172. ></el-time-select>
  173. </div>
  174. </template>
  175. </el-table-column>
  176. <el-table-column label="操作" align="center" width="100px" fixed="right">
  177. <template slot-scope="scope">
  178. <el-button
  179. size="mini"
  180. type="text"
  181. icon="el-icon-delete"
  182. @click="handlePackageDelete(scope.row)"
  183. >删除</el-button>
  184. </template>
  185. </el-table-column>
  186. </el-table>
  187. </el-form-item >
  188. <el-form-item label="课题选择" prop="questionBankId">
  189. <el-button size="small" type="primary" @click="chooseQuestionBank">选取课题</el-button>
  190. <el-table border width="100%" style="margin-top:5px;" :data="form.questionBankList">
  191. <el-table-column label="问题" align="center" prop="title">
  192. <template slot-scope="scope">
  193. <el-tooltip class="item" effect="dark" :content="scope.row.title" placement="top">
  194. <div
  195. style="display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; text-overflow: ellipsis;">
  196. <span>{{ scope.row.title }}</span>
  197. </div>
  198. </el-tooltip>
  199. </template>
  200. </el-table-column>
  201. <el-table-column label="类别" align="center" prop="type">
  202. <template slot-scope="scope">
  203. <dict-tag :options="typeOptions" :value="scope.row.type"/>
  204. </template>
  205. </el-table-column>
  206. <el-table-column label="答案" align="center" prop="answer"/>
  207. <el-table-column label="操作" align="center" width="100px" fixed="right">
  208. <template slot-scope="scope">
  209. <el-button size="mini" type="text" icon="el-icon-delete"
  210. @click="handleQuestionBankDelete(scope.row)">删除
  211. </el-button>
  212. </template>
  213. </el-table-column>
  214. </el-table>
  215. </el-form-item>
  216. <el-form-item label="红包金额" prop="redPacketMoney">
  217. <el-input-number v-model="form.redPacketMoney" :min="0.1" :max="200" :step="0.1"></el-input-number>
  218. </el-form-item>
  219. <!-- v-if="!!form.randomRedPacketRulesArr" -->
  220. <el-form-item v-if="!!enableRandomRedPacket" label="随机红包金额" >
  221. <template >
  222. <div v-for="(rule, index) in form.randomRedPacketRulesArr" :key="index" class="form-row">
  223. <el-form-item
  224. label="随机红包金额区间"
  225. :prop="`randomRedPacketRulesArr.${index}.minAmount`"
  226. :rules="[
  227. { required: true, message: '请输入最小金额', trigger: 'blur' },
  228. { validator: validateMinAmount, trigger: 'blur', index: index }
  229. ]"
  230. class="form-item-amount"
  231. >
  232. <el-input
  233. v-model.number="rule.minAmount"
  234. type="number"
  235. :min="0.01"
  236. :precision="2"
  237. :step="0.01"
  238. placeholder="最小金额"
  239. size="small"
  240. class="amount-input"
  241. @input="handleAmountInput(rule, 'minAmount')"
  242. ></el-input>
  243. <span class="separator">-</span>
  244. <el-input
  245. v-model.number="rule.maxAmount"
  246. type="number"
  247. :min="rule.minAmount || 0.01"
  248. :precision="2"
  249. :step="0.01"
  250. placeholder="最大金额"
  251. size="small"
  252. class="amount-input"
  253. @input="handleAmountInput(rule, 'maxAmount')"
  254. ></el-input>
  255. <span class="suffix">元</span>
  256. </el-form-item>
  257. <el-form-item
  258. label="随机权重"
  259. :prop="`randomRedPacketRulesArr.${index}.weight`"
  260. :rules="[
  261. { required: true, message: '请输入权重', trigger: 'blur' },
  262. { type: 'integer', message: '权重必须为整数', trigger: 'blur' },
  263. ]"
  264. class="form-item-weight"
  265. >
  266. <el-input
  267. v-model.number="rule.weight"
  268. type="number"
  269. :min="1"
  270. placeholder="权重"
  271. size="small"
  272. ></el-input>
  273. </el-form-item>
  274. <el-tooltip class="item" effect="dark" content="权重越高,被随机到的概率越大" placement="top">
  275. <i class="el-icon-question"></i>
  276. </el-tooltip>
  277. <div class="action-buttons">
  278. <el-button
  279. icon="el-icon-plus"
  280. size="mini"
  281. type="text"
  282. @click="addRule(index)"
  283. class="add-btn"
  284. >
  285. 新增
  286. </el-button>
  287. <el-button
  288. icon="el-icon-delete"
  289. size="mini"
  290. type="text"
  291. @click="deleteRule(index)"
  292. :disabled="form.randomRedPacketRulesArr.length <= 1"
  293. class="delete-btn"
  294. >
  295. 删除
  296. </el-button>
  297. </div>
  298. </div>
  299. </template>
  300. </el-form-item>
  301. <el-form-item label="是否关联商品">
  302. <el-radio v-model="form.isProduct" :label=0>否</el-radio>
  303. <el-radio v-model="form.isProduct" :label=1>是</el-radio>
  304. </el-form-item>
  305. <el-form-item label="是否先导课" prop="isFirst">
  306. <el-radio-group v-model="form.isFirst">
  307. <el-radio :label="1">是</el-radio>
  308. <el-radio :label="0">否</el-radio>
  309. </el-radio-group>
  310. </el-form-item>
  311. <el-form-item label="是否启用倍速" prop="isSpeed">
  312. <el-radio-group v-model="form.isSpeed">
  313. <el-radio :label="1">是</el-radio>
  314. <el-radio :label="0">否</el-radio>
  315. </el-radio-group>
  316. </el-form-item>
  317. <el-form-item label="是否上架" prop="isOnPut">
  318. <el-radio-group v-model="form.isOnPut">
  319. <el-radio :label="0">上架</el-radio>
  320. <el-radio :label="1">下架</el-radio>
  321. </el-radio-group>
  322. </el-form-item>
  323. <el-form-item label="商品选择" v-if="form.isProduct === 1">
  324. <el-button size="small" type="primary" @click="chooseCourseProduct">选取商品</el-button>
  325. <el-table border width="100%" style="margin-top:5px;" :data="form.courseProducts">
  326. <el-table-column label="商品名称" align="center" prop="productName"/>
  327. <el-table-column label="商品价格" align="center" prop="price"/>
  328. <el-table-column label="库存" align="center" prop="stock"/>
  329. <el-table-column label="操作" align="center" width="100px" fixed="right">
  330. <template slot-scope="scope">
  331. <el-button size="mini" type="text" icon="el-icon-delete"
  332. @click="handleCourseProductDelete(scope.row)">删除
  333. </el-button>
  334. </template>
  335. </el-table-column>
  336. </el-table>
  337. </el-form-item>
  338. <el-row>
  339. <el-col :span="12">
  340. <el-form-item v-if="form.isProduct === 1" label="商品售卖时间" prop="listingStartTime">
  341. <el-input-number v-model="form.listingStartTime" :min="0" label="商品售卖时间"></el-input-number>
  342. </el-form-item>
  343. </el-col>
  344. <el-col :span="12">
  345. <el-form-item v-if="form.isProduct === 1" label="结束售卖时间" prop="listingStartTime">
  346. <el-input-number v-model="form.listingEndTime" :min="0" label="结束售卖时间"></el-input-number>
  347. </el-form-item>
  348. </el-col>
  349. </el-row>
  350. </el-form>
  351. <div slot="footer" class="dialog-footer">
  352. <el-button type="primary" @click="submitForm">确 定</el-button>
  353. <el-button @click="cancel">取 消</el-button>
  354. </div>
  355. </el-dialog>
  356. <el-dialog :title="title" :visible.sync="updateBatchData.open" width="1000px" append-to-body>
  357. <el-form ref="form" :model="updateBatchData.form" label-width="110px">
  358. <el-form-item label="看课时间" prop="timeRange">
  359. <el-time-picker is-range v-model="updateBatchData.form.timeRange" range-separator="至"
  360. start-placeholder="开始时间"
  361. value-format="HH:mm:ss" end-placeholder="结束时间" placeholder="选择时间范围">
  362. </el-time-picker>
  363. </el-form-item>
  364. <el-form-item label="领取红包时间" prop="lastJoinTime">
  365. <el-time-picker v-model="updateBatchData.form.lastJoinTime" :selectableRange="updateBatchData.form.timeRange"
  366. value-format="HH:mm:ss" placeholder="选择时间范围">
  367. </el-time-picker>
  368. <p style="color: red;margin: 0;font-size: 12px">超过领取红包时间,只允许看课,不允许领取红包</p>
  369. </el-form-item>
  370. </el-form>
  371. <div slot="footer" class="dialog-footer">
  372. <el-button type="primary" @click="updateBatch">确 定</el-button>
  373. <el-button @click="updateBatchData.open = false">取 消</el-button>
  374. </div>
  375. </el-dialog>
  376. <el-dialog :title="questionBank.title" :visible.sync="questionBank.open" width="1000px" append-to-body>
  377. <question-bank ref="questionBank" @questionBankResult="questionBankResult"></question-bank>
  378. </el-dialog>
  379. <el-dialog :title="courseProduct.title" :visible.sync="courseProduct.open" width="1000px" append-to-body>
  380. <course-product ref="courseProduct" @courseProductResult="courseProductResult"></course-product>
  381. </el-dialog>
  382. <el-dialog title="视频库选择" :visible.sync="addBatchData.open" width="900px" append-to-body>
  383. <!-- 搜索条件 -->
  384. <el-form :inline="true" :model="addBatchData.queryParams" class="library-search">
  385. <el-form-item label="素材名称">
  386. <el-input v-model="addBatchData.queryParams.resourceName" placeholder="请输入素材名称" clearable size="small"
  387. @keyup.enter.native="resourceList"/>
  388. </el-form-item>
  389. <el-form-item label="类型">
  390. <el-select v-model="addBatchData.queryParams.typeId" @change="changeCateType" placeholder="请选择素材类型"
  391. clearable
  392. size="small">
  393. <el-option v-for="item in addBatchData.typeOptions" :key="item.dictValue" :label="item.dictLabel"
  394. :value="item.dictValue"/>
  395. </el-select>
  396. </el-form-item>
  397. <el-form-item label="子类型">
  398. <el-select v-model="addBatchData.queryParams.typeSubId" placeholder="请选择素材子类型" clearable size="small">
  399. <el-option v-for="item in addBatchData.typeSubOptions" :key="item.dictValue" :label="item.dictLabel"
  400. :value="item.dictValue"/>
  401. </el-select>
  402. </el-form-item>
  403. <el-form-item>
  404. <el-button type="primary" icon="el-icon-search" size="mini" @click="resourceList">搜索</el-button>
  405. </el-form-item>
  406. </el-form>
  407. <!-- 视频列表 -->
  408. <el-table v-loading="addBatchData.loading" :data="addBatchData.list"
  409. @selection-change="handVideoleSelectionChange" height="400px">
  410. <el-table-column type="selection" width="55" align="center"/>
  411. <el-table-column label="素材名称" align="center" prop="resourceName"/>
  412. <el-table-column label="文件名称" align="center" prop="fileName"/>
  413. <el-table-column label="排序" align="center" prop="sort"/>
  414. <el-table-column label="缩略图" align="center">
  415. <template slot-scope="scope">
  416. <el-popover placement="right" title="" trigger="hover">
  417. <img alt="" slot="reference" :src="scope.row.thumbnail" style="width: 80px; height: 50px"/>
  418. <img alt="" :src="scope.row.thumbnail" style="max-width: 150px;"/>
  419. </el-popover>
  420. </template>
  421. </el-table-column>
  422. <el-table-column label="视频时长" align="center">
  423. <template slot-scope="scope">
  424. <span>{{ formatDuration(scope.row.duration) }}</span>
  425. </template>
  426. </el-table-column>
  427. </el-table>
  428. <!-- 分页 -->
  429. <pagination v-show="addBatchData.total > 0" :total="addBatchData.total"
  430. :page.sync="addBatchData.queryParams.pageNum" :limit.sync="addBatchData.queryParams.pageSize"
  431. @pagination="resourceList"/>
  432. <div slot="footer" class="dialog-footer">
  433. <el-button type="primary" @click="batchVideoSave">确 定</el-button>
  434. </div>
  435. </el-dialog>
  436. <el-dialog title="章节红包" :visible.sync="redData.open" width="900px" append-to-body>
  437. <el-table border v-loading="redData.loading" :data="redData.list" height="600px">
  438. <el-table-column label="小节名称" align="center" show-overflow-tooltip prop="title"/>
  439. <el-table-column label="视频文件名称" align="center" show-overflow-tooltip prop="fileName">
  440. </el-table-column>
  441. <el-table-column label="视频时长" align="center" prop="duration">
  442. <template slot-scope="{ row }">
  443. {{ formatDuration(row.duration) }}
  444. </template>
  445. </el-table-column>
  446. <el-table-column label="红包金额" align="center" prop="redPacketMoney">
  447. <template slot-scope="scope">
  448. <el-input class="el-input" v-model="scope.row.redPacketMoney"/>
  449. </template>
  450. </el-table-column>
  451. <el-table-column label="排序" align="center" prop="courseSort"/>
  452. <el-table-column label="上传时间" align="center" prop="createTime"/>
  453. </el-table>
  454. <div slot="footer" class="dialog-footer">
  455. <el-button type="primary" @click="batchRedSave">确 定</el-button>
  456. </div>
  457. </el-dialog>
  458. <el-dialog :title="commentDialog.title" :visible.sync="commentDialog.open" width="1000px" append-to-body
  459. :close-on-click-modal="false">
  460. <course-watch-comment ref="courseWatchComment" :courseId="commentDialog.courseId" :videoId="commentDialog.videoId"
  461. v-if="commentDialog.open">
  462. </course-watch-comment>
  463. </el-dialog>
  464. <el-dialog title="修改课节排序" :visible.sync="openVideoSort" style="width: 1600px;" append-to-body>
  465. <draggable v-model="userCourseVideoSortList" @end="onDragEndDay" style="padding: 10px">
  466. <el-button style="margin: 8px 4px;" v-for="(item, index) in userCourseVideoSortList"
  467. :class="item.newCourseSort != item.courseSort ? 'red':''">第{{
  468. item.newCourseSort
  469. }}序(原排序第{{ item.courseSort }})
  470. </el-button>
  471. </draggable>
  472. <div style="float: right;margin-top: -20px">
  473. <el-button type="primary" @click="saveSorts">保存</el-button>
  474. </div>
  475. </el-dialog>
  476. <!-- 批量修改封面 -->
  477. <el-dialog :title="batchEditCoverDialog.title" :visible.sync="batchEditCoverDialog.visible" width="500px" append-to-body>
  478. <el-form ref="batchEditCoverDialogForm"
  479. :model="batchEditCoverDialog.form"
  480. :rules="batchEditCoverDialog.rules"
  481. v-loading="batchEditCoverDialog.uploadLoading">
  482. <el-form-item label="视频封面" prop="thumbnail">
  483. <el-upload v-model="batchEditCoverDialog.form.thumbnail"
  484. class="avatar-uploader"
  485. :action="uploadUrl"
  486. :show-file-list="false"
  487. :on-success="handleCoverSuccess"
  488. :before-upload="beforeAvatarUpload">
  489. <img v-if="batchEditCoverDialog.form.thumbnail" :src="batchEditCoverDialog.form.thumbnail" class="avatar" width="300px">
  490. <i v-else class="el-icon-plus avatar-uploader-icon"></i>
  491. </el-upload>
  492. </el-form-item>
  493. </el-form>
  494. <div slot="footer" class="dialog-footer">
  495. <el-button type="primary" @click="submitEditCoverForm">确 定</el-button>
  496. <el-button @click="cancelEditCoverForm">取 消</el-button>
  497. </div>
  498. </el-dialog>
  499. </div>
  500. </template>
  501. <script>
  502. import {
  503. addUserCourseVideo,
  504. batchSaveVideo,
  505. batchUpdateRed,
  506. delUserCourseVideo,
  507. getSort,
  508. getUserCourseVideo,
  509. getVideoListByCourseId,
  510. getVideoListByCourseIdAll,
  511. sortCourseVideo,
  512. updates,
  513. updateUserCourseVideo,
  514. syncTemplate, batchDownUserCourseVideo, batchEditCover, batchUpUserCourseVideo
  515. } from '@/api/course/userCourseVideo'
  516. // import {syncTemplate} from '@/api/course/userCourse'
  517. import QuestionBank from "@/views/course/courseQuestionBank/QuestionBank.vue";
  518. import CourseProduct from "@/views/course/fsCourseProduct/CourseProductZM.vue";
  519. import VideoUpload from "@/components/VideoUpload/index.vue";
  520. import {listVideoResource} from '@/api/course/videoResource';
  521. import {getByIds} from '@/api/course/courseQuestionBank'
  522. import CourseWatchComment from "./courseWatchComment.vue";
  523. import {getCateListByPid, getCatePidList} from '@/api/course/userCourseCategory'
  524. import draggable from 'vuedraggable'
  525. import { getConfigByKey } from '@/api/system/config'
  526. export default {
  527. name: "userCourseCatalog",
  528. components: {VideoUpload, QuestionBank, CourseWatchComment, CourseProduct, draggable},
  529. watch:{
  530. // 深度监听 rules 数组的变化,以更新总权重
  531. "form.randomRedPacketRulesArr": {
  532. handler(val) {
  533. // this.calculateTotalWeight();
  534. this.validateRules();
  535. },
  536. deep: true,
  537. },
  538. },
  539. data() {
  540. return {
  541. duration: null,
  542. packageList: [],
  543. //课题
  544. package: {
  545. title: '',
  546. open: false,
  547. },
  548. //课题
  549. questionBank: {
  550. title: '',
  551. open: false,
  552. },
  553. //拍商品
  554. courseProduct: {
  555. title: '',
  556. open: false,
  557. },
  558. isPrivate: null,
  559. videoUrl: "",
  560. uploadTypeOptions: [
  561. {dictLabel: "线路一", dictValue: 2},
  562. {dictLabel: "线路二", dictValue: 3},
  563. ],
  564. uploadLoading: false,
  565. courseId: null,
  566. videoName: '',
  567. title: "",
  568. // 是否显示弹出层
  569. open: false,
  570. uploadUrl: process.env.VUE_APP_BASE_API + "/common/uploadOSS",
  571. baseUrl: process.env.VUE_APP_BASE_API,
  572. typeOptions: [],
  573. files: [],
  574. fileList: [],
  575. // 上传成功后的地址
  576. videoURL: '',
  577. // 进度条百分比
  578. progress: 0,
  579. // 上传视频获取成功后拿到的fileID【备用】
  580. fileId: '',
  581. courseName: null,
  582. userCourseVideoList: [],
  583. userCourseVideoSortList: [],
  584. total: 0,
  585. redData: {
  586. queryParams: {
  587. pageNum: 1,
  588. pageSize: 99999,
  589. courseId: null,
  590. },
  591. list: [],
  592. open: false,
  593. loading: true,
  594. form: {}
  595. },
  596. queryParams: {
  597. pageNum: 1,
  598. pageSize: 10,
  599. courseId: null,
  600. videoId: null,
  601. title: null
  602. },
  603. addBatchData: {
  604. open: false,
  605. loading: true,
  606. form: {},
  607. select: [], // 按用户选择顺序存储视频ID
  608. total: 0,
  609. queryParams: {
  610. pageNum: 1,
  611. pageSize: 10,
  612. resourceName: null,
  613. typeId: null,
  614. typeSubId: null
  615. },
  616. typeOptions: [],
  617. typeSubOptions: []
  618. },
  619. // 显示搜索条件
  620. showSearch: true,
  621. // 遮罩层
  622. loading: true,
  623. // 导出遮罩层
  624. exportLoading: false,
  625. // 选中数组
  626. ids: [],
  627. // 非单个禁用
  628. single: true,
  629. // 非多个禁用
  630. multiple: true,
  631. loading3: false,
  632. openVideoSort: false,
  633. // 表单参数
  634. form: {
  635. isOnPut: 0,
  636. courseProducts: [],
  637. randomRedPacketRules:null,
  638. randomRedPacketRulesArr:[
  639. {
  640. minAmount: 0.01,
  641. maxAmount: 0.01,
  642. weight: 100,
  643. }
  644. ]
  645. },
  646. updateBatchData: {
  647. open: false,
  648. form: {}
  649. },
  650. // 表单校验
  651. rules: {
  652. title: [
  653. {required: true, message: "小节名称不能为空", trigger: "change"}
  654. ],
  655. courseSort: [
  656. {required: true, message: "排序不能为空", trigger: "change"}
  657. ],
  658. },
  659. // 评论弹窗数据
  660. commentDialog: {
  661. open: false,
  662. courseId: null,
  663. videoId: null,
  664. title: ""
  665. },
  666. enableRandomRedPacket:false,
  667. // 批量修改封面
  668. batchEditCoverDialog: {
  669. title: '修改视频封面',
  670. visible: false,
  671. uploadLoading: false,
  672. form: {
  673. thumbnail: null,
  674. },
  675. rules: {
  676. thumbnail: [
  677. {required: true, message: "视频封面不能为空", trigger: "change"}
  678. ],
  679. }
  680. }
  681. }
  682. },
  683. created() {
  684. this.getDicts("sys_course_temp_type").then(response => {
  685. this.typeOptions = response.data;
  686. });
  687. getConfigByKey('randomRedpacket:config').then(res=>{
  688. let configData = res.data;
  689. if(!!configData && !!configData.configValue){
  690. let configValue = JSON.parse(configData.configValue);
  691. if(!!configValue.enableRandomRedpacket){
  692. this.enableRandomRedPacket = configValue.enableRandomRedpacket;
  693. console.log("this.enableRandomRedPacket ::" + this.enableRandomRedPacket)
  694. }
  695. }
  696. }).catch(res=>{
  697. })
  698. },
  699. methods: {
  700. getPickerOptions() {
  701. const durationInMinutes = Math.floor(this.form.duration / 60); // 将秒转换为分钟
  702. const endHour = Math.floor(durationInMinutes / 60); // 起始小时
  703. const endMinute = durationInMinutes % 60; // 起始分钟
  704. return {
  705. start: "00:00", // 固定开始时间
  706. step: "00:01", // 时间间隔
  707. end: `${endHour.toString().padStart(2, "0")}:${endMinute
  708. .toString()
  709. .padStart(2, "0")}`, // 动态结束时间
  710. };
  711. },
  712. // 处理时间选择框值变化
  713. handleTimeChange(index, row) {
  714. // 确保 packageList 中的数据被正确更新
  715. this.$set(this.packageList, index, row);
  716. // 同步更新 form.packageJson 字段
  717. this.$nextTick(() => {
  718. // 确保每个疗法包都有 duration 字段
  719. this.packageList.forEach(item => {
  720. if (item.duration === undefined || item.duration === null) {
  721. item.duration = ''; // 空值应初始化为空字符串而不是null,避免显示"null"
  722. }
  723. });
  724. this.form.packageJson = JSON.stringify(this.packageList);
  725. });
  726. },
  727. handlePackageDelete(row) {
  728. this.packageList.splice(this.packageList.findIndex(item => item.packageId === row.packageId), 1)
  729. },
  730. choosePackage() {
  731. this.package.open = true;
  732. this.package.title = '疗法选择';
  733. },
  734. /**
  735. * 选择课题
  736. */
  737. chooseQuestionBank() {
  738. this.questionBank.open = true;
  739. this.questionBank.title = '课题选择';
  740. },
  741. /**
  742. * 选择拍商品
  743. */
  744. chooseCourseProduct() {
  745. this.courseProduct.open = true;
  746. this.courseProduct.title = '拍商品选择';
  747. },
  748. //选择疗法
  749. selectPackage(row) {
  750. const drug = {};
  751. for (var i = 0; i < this.packageList.length; i++) {
  752. if (this.packageList[i].packageId == row.packageId) {
  753. this.$message.warning("疗法已存在!")
  754. return;
  755. }
  756. }
  757. drug.packageId = row.packageId;
  758. drug.packageName = row.packageName;
  759. drug.secondName = row.secondName;
  760. drug.totalPrice = row.totalPrice;
  761. drug.imgUrl = row.imgUrl;
  762. this.packageList.push(drug);
  763. this.$message({
  764. message: '添加成功',
  765. type: 'success'
  766. });
  767. },
  768. courseProductResult(val) {
  769. this.form.courseProducts = this.form.courseProducts || [];
  770. const productData = {
  771. productId: val.productId, // 确保使用 productId
  772. productName: val.productName,
  773. price: val.price,
  774. stock: val.stock,
  775. id: val.productId, // 添加 id 字段,方便删除操作
  776. };
  777. // 检查商品是否已存在
  778. const exists = this.form.courseProducts.some(item => item.productId === val.productId);
  779. if (exists) {
  780. this.$message.error("当前商品已选择");
  781. return;
  782. }
  783. // 添加商品到列表
  784. this.form.courseProducts.push(val);
  785. this.$message.success("添加成功");
  786. },
  787. //选择结果
  788. questionBankResult(val) {
  789. // 确保 questionBankList 是数组
  790. this.form.questionBankList = this.form.questionBankList || [];
  791. for (var i = 0; i < this.form.questionBankList.length; i++) {
  792. if (this.form.questionBankList[i].id == val.id) {
  793. return this.$message.error("当前课题已选择")
  794. }
  795. }
  796. this.form.questionBankList.push(val);
  797. this.$message({
  798. message: '添加成功',
  799. type: 'success'
  800. });
  801. },
  802. //删除课题
  803. handleQuestionBankDelete(row) {
  804. this.form.questionBankList.splice(this.form.questionBankList.findIndex(item => item.id === row.id), 1)
  805. },
  806. //删除商品
  807. handleCourseProductDelete(row) {
  808. // 优先使用 productId 查找
  809. let index = -1;
  810. // 方法1:通过 productId 查找
  811. if (row.productId) {
  812. index = this.form.courseProducts.findIndex(item => item.productId === row.productId);
  813. }
  814. // 方法2:如果 productId 不存在,尝试通过 id 查找
  815. if (index === -1 && row.id) {
  816. index = this.form.courseProducts.findIndex(item => item.id === row.id);
  817. }
  818. // 方法3:如果以上都不行,通过 productName 查找(最后手段)
  819. if (index === -1 && row.productName) {
  820. index = this.form.courseProducts.findIndex(item => item.productName === row.productName);
  821. }
  822. if (index > -1) {
  823. this.form.courseProducts.splice(index, 1);
  824. this.$message.success('删除成功');
  825. } else {
  826. this.$message.warning('未找到对应商品');
  827. }
  828. },
  829. handleVideoChange() {
  830. if (this.form.uploadType == 1) {
  831. this.videoUrl = this.form.lineOne;
  832. } else if (this.form.uploadType == 2) {
  833. this.videoUrl = this.form.lineTwo;
  834. } else if (this.form.uploadType == 3) {
  835. this.videoUrl = this.form.lineThree;
  836. }
  837. },
  838. // 视频库课题
  839. handleSelectProjects(projectIds) {
  840. this.form.questionBankList = []
  841. if (!projectIds || projectIds.length === 0 || this.isPrivate === 0) {
  842. return
  843. }
  844. const params = {ids: projectIds}
  845. getByIds(params).then(response => {
  846. if (response.code === 200) {
  847. response.data.forEach(item => {
  848. let isExist = this.form.questionBankList.some(q => q.id === item.id)
  849. if (!isExist) {
  850. this.form.questionBankList.push(item)
  851. }
  852. });
  853. }
  854. })
  855. },
  856. handleVideoDuration(duration) {
  857. this.form.duration = duration;
  858. },
  859. formatDuration(seconds) {
  860. if (seconds === null || seconds === undefined) {
  861. return '未上传视频';
  862. }
  863. const hours = Math.floor(seconds / 3600);
  864. const minutes = Math.floor((seconds % 3600) / 60);
  865. const remainingSeconds = seconds % 60;
  866. const formattedHours = hours > 0 ? hours.toString() + ':' : '';
  867. const formattedMinutes = minutes.toString().padStart(2, '0');
  868. const formattedSeconds = remainingSeconds.toString().padStart(2, '0');
  869. return `${formattedHours}${formattedMinutes}:${formattedSeconds}`;
  870. },
  871. handleAvatarSuccess(res, file) {
  872. if (res.code == 200) {
  873. this.form.thumbnail = res.url;
  874. this.$forceUpdate()
  875. } else {
  876. this.msgError(res.msg);
  877. }
  878. },
  879. beforeAvatarUpload(file) {
  880. const isLt1M = file.size / 1024 / 1024 < 5;
  881. if (!isLt1M) {
  882. this.$message.error('上传图片大小不能超过 5MB!');
  883. }
  884. return isLt1M;
  885. },
  886. getDetails(courseId, courseName, isPrivate) {
  887. this.isPrivate = isPrivate
  888. this.courseName = courseName
  889. this.courseId = courseId;
  890. this.queryParams.courseId = courseId;
  891. this.getList();
  892. },
  893. getList() {
  894. this.loading = true;
  895. getVideoListByCourseId(this.queryParams).then(response => {
  896. this.userCourseVideoList = response.rows;
  897. this.total = response.total;
  898. this.loading = false;
  899. });
  900. },
  901. // 取消按钮
  902. cancel() {
  903. this.open = false;
  904. this.reset();
  905. },
  906. // 表单重置
  907. reset() {
  908. this.form = {
  909. videoId: null,
  910. title: null,
  911. description: null,
  912. url: null,
  913. thumbnail: null,
  914. duration: null,
  915. createTime: null,
  916. uploadType: null,
  917. lineOne: null,
  918. lineTwo: null,
  919. lineThree: null,
  920. fileName: null,
  921. userId: null,
  922. cateId: null,
  923. courseId: null,
  924. likes: null,
  925. views: null,
  926. comments: null,
  927. status: 0,
  928. courseSort: 1,
  929. isHot: null,
  930. isShow: null,
  931. isAudit: null,
  932. auditBy: null,
  933. auditTime: null,
  934. updateTime: null,
  935. source: null,
  936. isDel: null,
  937. shares: null,
  938. tags: null,
  939. productId: null,
  940. id: null,
  941. packageJson: null,
  942. questionBankId: null,
  943. questionBankList: [],
  944. redPacketMoney: 0,
  945. isTranscode: 0,
  946. transcodeFileKey: null,
  947. isProduct: 0,
  948. isFirst: 0,
  949. isSpeed: 0,
  950. isOnPut: 0,
  951. listingStartTime: null,
  952. listingEndTime: null,
  953. showProduct: 1, // 默认无商品
  954. randomRedPacketRules:null,
  955. randomRedPacketRulesArr:[
  956. {
  957. minAmount: 0.01,
  958. maxAmount: 0.01,
  959. weight: 100,
  960. }
  961. ]
  962. };
  963. this.videoURL = '';
  964. this.progress = 0;
  965. this.resetForm("form");
  966. },
  967. /** 搜索按钮操作 */
  968. handleQuery() {
  969. this.queryParams.pageNum = 1;
  970. this.getList();
  971. },
  972. /** 重置按钮操作 */
  973. resetQuery() {
  974. this.resetForm("queryForm");
  975. this.handleQuery();
  976. },
  977. // 多选框选中数据
  978. handleSelectionChange(selection) {
  979. this.ids = selection.map(item => item.videoId)
  980. this.single = selection.length !== 1
  981. this.multiple = !selection.length
  982. },
  983. // 视频库多选框选中数据(按用户点击顺序记录)
  984. handVideoleSelectionChange(selection) {
  985. // 提取当前选中的所有ID
  986. const selectedIds = selection.map(item => item.id);
  987. // 处理新增选中项:保留用户点击顺序
  988. selectedIds.forEach(id => {
  989. if (!this.addBatchData.select.includes(id)) {
  990. this.addBatchData.select.push(id);
  991. }
  992. });
  993. // 处理取消选中项:移除已取消的ID
  994. this.addBatchData.select = this.addBatchData.select.filter(id => selectedIds.includes(id));
  995. },
  996. handleAdd() {
  997. this.reset();
  998. this.form.courseId = this.courseId;
  999. this.open = true;
  1000. this.title = "添加课堂视频";
  1001. this.videoUrl = '';
  1002. this.packageList = [];
  1003. getSort(this.courseId).then(response => {
  1004. this.form.courseSort = Number(response.data);
  1005. })
  1006. setTimeout(() => {
  1007. this.$refs.videoUpload.resetUpload();
  1008. }, 500);
  1009. },
  1010. /** 修改按钮操作 */
  1011. handleUpdate(row) {
  1012. this.reset();
  1013. this.form.isOnPut = row.isOnPut;
  1014. this.packageList = [];
  1015. const videoId = row.videoId || this.ids;
  1016. getUserCourseVideo(videoId).then(response => {
  1017. console.log(response);
  1018. this.form = response.data;
  1019. this.$set(this.form, 'isOnPut', response.data.isOnPut !== undefined ? response.data.isOnPut : 0);
  1020. if (this.form.randomRedPacketRules) {
  1021. this.$set(this.form, 'randomRedPacketRulesArr', JSON.parse(this.form.randomRedPacketRules));
  1022. } else {
  1023. // 处理初始值
  1024. this.form.randomRedPacketRulesArr = [{
  1025. minAmount: 0.01,
  1026. maxAmount: 0.01,
  1027. weight: 100,
  1028. }];
  1029. }
  1030. if (response.data.videoUrl != null && response.data.videoUrl !== '') {
  1031. this.videoUrl = response.data.videoUrl;
  1032. }
  1033. if (this.form.packageJson != null) {
  1034. try {
  1035. // 检查 packageJson 是否包含商品数据,如果是则解析为 courseProducts
  1036. const parsedData = JSON.parse(this.form.packageJson);
  1037. if (Array.isArray(parsedData) && parsedData.length > 0 && parsedData[0].hasOwnProperty('productName')) {
  1038. // 如果是商品数据格式,则设置到 courseProducts
  1039. this.form.courseProducts = parsedData;
  1040. } else {
  1041. // 否则按照原有逻辑设置到 packageList
  1042. this.packageList = parsedData;
  1043. }
  1044. } catch (e) {
  1045. // 如果解析失败,按原来的处理方式
  1046. this.packageList = JSON.parse(this.form.packageJson);
  1047. }
  1048. }
  1049. if (response.data.viewStartTime != null && response.data.viewEndTime != null) {
  1050. this.form.timeRange = [response.data.viewStartTime, response.data.viewEndTime];
  1051. }
  1052. // 根据商品数量设置是否关联商品状态
  1053. if (this.form.courseProducts && this.form.courseProducts.length > 0) {
  1054. this.form.isProduct = 1; // 有关联商品时设为1(是)
  1055. } else {
  1056. this.form.isProduct = 0; // 无关联商品时设为0(否)
  1057. }
  1058. // 设置商品选择状态
  1059. if (this.form.id) {
  1060. this.form.showProduct = 0; // 有商品时设为0
  1061. } else {
  1062. this.form.showProduct = 1; // 无商品时设为1
  1063. }
  1064. setTimeout(() => {
  1065. this.$refs.videoUpload.resetUpload();
  1066. }, 500);
  1067. this.open = true;
  1068. this.title = "修改课堂视频";
  1069. });
  1070. },
  1071. /** 提交按钮 */
  1072. submitForm() {
  1073. this.$refs["form"].validate(valid => {
  1074. if (valid) {
  1075. this.form.videoUrl = this.videoUrl;
  1076. if (this.form.videoUrl == null || this.form.videoUrl === '') {
  1077. this.$message({
  1078. message: '请上传视频!',
  1079. type: 'warning'
  1080. });
  1081. return
  1082. }
  1083. if (this.form.timeRange && this.form.timeRange.length === 2) {
  1084. this.form.viewStartTime = this.form.timeRange[0];
  1085. this.form.viewEndTime = this.form.timeRange[1];
  1086. }
  1087. if (this.form.duration == null) {
  1088. this.$message({
  1089. message: '未识别到视频时长请稍等。。。',
  1090. type: 'warning'
  1091. });
  1092. return
  1093. }
  1094. if (this.form.isProduct != null && this.form.isProduct == 1 && (this.form.courseProducts == null || this.form.courseProducts.length < 1)) {
  1095. this.$message({
  1096. message: '请选择关联商品',
  1097. type: 'warning'
  1098. });
  1099. return
  1100. }
  1101. if (this.form.questionBankList !== null) {
  1102. this.form.questionBankId = this.form.questionBankList.map(item => item.id).join(',');
  1103. }
  1104. // 处理商品选择逻辑
  1105. if (this.form.courseProducts && this.form.courseProducts.length > 0) {
  1106. this.form.id = this.form.courseProducts.map(item => item.id).join(',');
  1107. this.form.showProduct = 0; // 有商品选择时设为0
  1108. // 将商品数据序列化为JSON字符串传递给packageJson
  1109. this.form.packageJson = JSON.stringify(this.form.courseProducts);
  1110. } else {
  1111. this.form.id = null;
  1112. this.form.showProduct = 1; // 无商品选择时设为1
  1113. this.form.packageJson = "[]"; // 无商品时传递空数组
  1114. }
  1115. if (this.form.randomRedPacketRulesArr) {
  1116. let rulesJson = JSON.stringify(this.form.randomRedPacketRulesArr);
  1117. this.form.randomRedPacketRules = rulesJson;
  1118. }
  1119. if (this.form.videoId != null) {
  1120. updateUserCourseVideo(this.form).then(response => {
  1121. this.msgSuccess("修改成功");
  1122. this.open = false;
  1123. this.getList();
  1124. });
  1125. } else {
  1126. addUserCourseVideo(this.form).then(response => {
  1127. this.msgSuccess("新增成功");
  1128. this.open = false;
  1129. this.getList();
  1130. });
  1131. }
  1132. }
  1133. });
  1134. },
  1135. openUpdates() {
  1136. this.updateBatchData.form = {};
  1137. this.updateBatchData.open = true;
  1138. },
  1139. /** 提交按钮 */
  1140. updateBatch() {
  1141. this.updateBatchData.form.ids = this.ids;
  1142. if (this.updateBatchData.form.timeRange != null && this.updateBatchData.form.timeRange.length === 2) {
  1143. this.updateBatchData.form.viewStartTime = this.updateBatchData.form.timeRange[0];
  1144. this.updateBatchData.form.viewEndTime = this.updateBatchData.form.timeRange[1];
  1145. }
  1146. updates(this.updateBatchData.form).then(response => {
  1147. this.msgSuccess("修改成功");
  1148. this.updateBatchData.open = false;
  1149. this.getList();
  1150. });
  1151. },
  1152. /** 删除按钮操作 */
  1153. handleDelete(row) {
  1154. const videoIds = row.videoId || this.ids;
  1155. this.$confirm('是否确认删除视频编号为"' + videoIds + '"的数据项?', "警告", {
  1156. confirmButtonText: "确定",
  1157. cancelButtonText: "取消",
  1158. type: "warning"
  1159. }).then(function () {
  1160. return delUserCourseVideo(videoIds);
  1161. }).then(() => {
  1162. this.getList();
  1163. this.msgSuccess("删除成功");
  1164. }).catch(() => {
  1165. });
  1166. },
  1167. /** 同步模板数据*/
  1168. handleSync() {
  1169. const courseId = this.courseId;
  1170. this.$confirm('是否同步课程数据至模板', "确认", {
  1171. confirmButtonText: "确定",
  1172. cancelButtonText: "取消",
  1173. type: "warning"
  1174. }).then(function () {
  1175. return syncTemplate(courseId);
  1176. }).then(() => {
  1177. this.getList();
  1178. this.msgSuccess("正在同步模板中!!请稍后!");
  1179. }).catch(() => {
  1180. });
  1181. },
  1182. handleCourseSort() {
  1183. getVideoListByCourseIdAll(this.queryParams.courseId).then(response => {
  1184. response.rows.forEach((item) => item.newCourseSort = item.courseSort);
  1185. this.userCourseVideoSortList = response.rows.sort((a, b) => a.courseSort - b.courseSort);
  1186. if (this.userCourseVideoSortList == null || this.userCourseVideoSortList.length == 0) {
  1187. this.$message.error("暂无课节天数")
  1188. } else {
  1189. this.openVideoSort = true;
  1190. }
  1191. })
  1192. },
  1193. onDragEndDay() {
  1194. this.userCourseVideoSortList.forEach((item, index) => {
  1195. item.newCourseSort = index + 1;
  1196. })
  1197. this.$forceUpdate()
  1198. },
  1199. saveSorts() {
  1200. let list = this.userCourseVideoSortList.filter(e => e.courseSort != e.newCourseSort).map(e => {
  1201. return {courseSort: e.newCourseSort, videoId: e.videoId}
  1202. })
  1203. this.loading3 = true;
  1204. sortCourseVideo(list).then(e => {
  1205. this.getList();
  1206. }).finally(() => {
  1207. this.userCourseVideoSortList = [];
  1208. this.openVideoSort = false;
  1209. })
  1210. },
  1211. openAdds() {
  1212. this.addBatchData.open = true;
  1213. this.getRootTypeList();
  1214. this.addBatchData.form = {
  1215. courseId: this.courseId,
  1216. };
  1217. // 重置选择顺序数组
  1218. this.addBatchData.select = [];
  1219. this.resourceList();
  1220. },
  1221. getRootTypeList() {
  1222. getCatePidList().then(response => {
  1223. this.addBatchData.typeOptions = response.data
  1224. });
  1225. },
  1226. async changeCateType(val) {
  1227. this.addBatchData.queryParams.typeSubId = null
  1228. this.addBatchData.typeSubOptions = []
  1229. if (!val) {
  1230. return
  1231. }
  1232. await getCateListByPid(val).then(response => {
  1233. this.addBatchData.typeSubOptions = response.data
  1234. })
  1235. },
  1236. resourceList() {
  1237. this.addBatchData.loading = true;
  1238. listVideoResource(this.addBatchData.queryParams).then(response => {
  1239. this.addBatchData.loading = false;
  1240. this.addBatchData.list = response.rows;
  1241. this.addBatchData.total = response.total;
  1242. });
  1243. },
  1244. batchVideoSave() {
  1245. if (this.addBatchData.select.length === 0) {
  1246. this.$message({
  1247. message: '请选择视频!!',
  1248. type: 'warning'
  1249. });
  1250. return
  1251. }
  1252. this.addBatchData.form.ids = this.addBatchData.select; // 按用户选择顺序提交
  1253. batchSaveVideo(this.addBatchData.form).then(response => {
  1254. this.addBatchData.open = false;
  1255. this.getList();
  1256. })
  1257. },
  1258. updateRedPageckeOpen() {
  1259. this.redData.open = true;
  1260. this.redData.loading = true;
  1261. this.redData.queryParams.courseId = this.courseId;
  1262. getVideoListByCourseId(this.redData.queryParams).then(response => {
  1263. if(!!response.rows && response.rows.length >0){
  1264. for(let i = 0; i < response.rows.length; i++){
  1265. if(!!response.rows[i].randomRedPacketRules){
  1266. this.$set(response.rows[i], 'randomRedPacketRulesArr', JSON.parse(response.rows[i].randomRedPacketRules)) ;
  1267. }
  1268. }
  1269. }
  1270. this.redData.list = response.rows;
  1271. console.log(this.redData.list);
  1272. this.redData.loading = false;
  1273. });
  1274. },
  1275. batchRedSave() {
  1276. batchUpdateRed(this.redData.list).then(response => {
  1277. this.redData.open = false;
  1278. this.getList();
  1279. })
  1280. },
  1281. /** 查看评论按钮操作 */
  1282. handleComment(row) {
  1283. this.commentDialog.courseId = row.courseId || this.courseId;
  1284. this.commentDialog.videoId = row.videoId;
  1285. this.commentDialog.title = `查看评论 - ${row.title}`;
  1286. this.commentDialog.open = true;
  1287. },
  1288. // 实时过滤金额输入,只允许两位小数
  1289. handleAmountInput(rule, field) {
  1290. let value = rule[field];
  1291. if (value === null || value === undefined) return;
  1292. // 转换为字符串处理
  1293. let str = value.toString();
  1294. // 移除除数字和小数点外的所有字符
  1295. str = str.replace(/[^0-9.]/g, '');
  1296. // 只保留一个小数点
  1297. const dotIndex = str.indexOf('.');
  1298. if (dotIndex !== -1) {
  1299. str = str.substring(0, dotIndex + 1) + str.substring(dotIndex + 1).replace(/\./g, '');
  1300. }
  1301. // 限制小数点后最多两位
  1302. if (dotIndex !== -1 && str.length > dotIndex + 3) {
  1303. str = str.substring(0, dotIndex + 3);
  1304. }
  1305. // 转换回数字并更新
  1306. rule[field] = parseFloat(str) || 0;
  1307. },
  1308. deleteRule(index) {
  1309. this.$confirm("确定要删除这个区间吗?", "提示", {
  1310. confirmButtonText: "确定",
  1311. cancelButtonText: "取消",
  1312. type: "warning",
  1313. }).then(() => {
  1314. this.form.randomRedPacketRulesArr.splice(index, 1);
  1315. this.$message({
  1316. type: "success",
  1317. message: "删除成功!",
  1318. });
  1319. });
  1320. },
  1321. addRule(index) {
  1322. // 在当前行的后面插入一个新行
  1323. this.form.randomRedPacketRulesArr.splice(index + 1, 0, {
  1324. minAmount: 0.01,
  1325. maxAmount: 0.01,
  1326. weight: 100,
  1327. });
  1328. },
  1329. // 自定义校验规则:确保最大金额大于最小金额
  1330. validateMinAmount(rule, value, callback) {
  1331. // debugger;
  1332. // const maxAmount = this.form29.rules[].maxAmount
  1333. const index = rule.index;
  1334. const maxAmount = this.form.randomRedPacketRulesArr[index].maxAmount;
  1335. if (value > maxAmount) {
  1336. callback(new Error("最小金额不能大于最大金额"));
  1337. } else {
  1338. callback();
  1339. }
  1340. },
  1341. validateRules() {
  1342. this.form.randomRedPacketRulesArr.forEach((rule) => {
  1343. if (rule.minAmount === undefined || rule.minAmount < 0.01) {
  1344. rule.minAmount = 0.01;
  1345. }
  1346. if (rule.maxAmount === undefined || rule.maxAmount < rule.minAmount) {
  1347. rule.maxAmount = rule.minAmount;
  1348. }
  1349. if (rule.weight === undefined || rule.weight < 1) {
  1350. rule.weight = 1;
  1351. }
  1352. });
  1353. },
  1354. /** 下架 **/
  1355. handleDown() {
  1356. const videoIds = this.ids;
  1357. this.$confirm('是否确认下架视频编号为"' + videoIds + '"的数据项?', "警告", {
  1358. confirmButtonText: "确定",
  1359. cancelButtonText: "取消",
  1360. type: "warning"
  1361. }).then(function () {
  1362. return batchDownUserCourseVideo(videoIds);
  1363. }).then(() => {
  1364. this.getList();
  1365. this.msgSuccess("下架成功");
  1366. }).catch(() => {
  1367. });
  1368. },
  1369. /** 上架按钮操作 */
  1370. handleUp() {
  1371. const videoIds = this.ids;
  1372. this.$confirm('是否确认上架视频编号为"' + videoIds + '"的数据项?', "警告", {
  1373. confirmButtonText: "确定",
  1374. cancelButtonText: "取消",
  1375. type: "warning"
  1376. }).then(function () {
  1377. return batchUpUserCourseVideo(videoIds);
  1378. }).then(() => {
  1379. this.getList();
  1380. this.msgSuccess("上架成功");
  1381. }).catch(function () {
  1382. });
  1383. },
  1384. /** 修改封面 **/
  1385. handleEditCover() {
  1386. this.batchEditCoverDialog.form = {
  1387. thumbnail: null
  1388. }
  1389. this.batchEditCoverDialog.visible = true
  1390. },
  1391. handleCoverSuccess(res, file) {
  1392. if (res.code === 200) {
  1393. this.batchEditCoverDialog.form.thumbnail = res.url;
  1394. this.$forceUpdate()
  1395. } else {
  1396. this.msgError(res.msg);
  1397. }
  1398. },
  1399. submitEditCoverForm() {
  1400. this.$refs["batchEditCoverDialogForm"].validate(valid => {
  1401. if (!valid) {
  1402. return;
  1403. }
  1404. const thumbnail = this.batchEditCoverDialog.form.thumbnail
  1405. const videoIds = this.ids
  1406. if (!thumbnail || thumbnail === '') {
  1407. this.$message({
  1408. message: '请上传封面!',
  1409. type: 'warning'
  1410. });
  1411. return
  1412. }
  1413. if (!videoIds || videoIds.length === 0) {
  1414. this.$message({
  1415. message: '请选择小节!',
  1416. type: 'warning'
  1417. });
  1418. return
  1419. }
  1420. const params = {
  1421. thumbnail: thumbnail,
  1422. videoIds: videoIds
  1423. }
  1424. batchEditCover(params).then(response => {
  1425. this.msgSuccess("修改成功")
  1426. this.batchEditCoverDialog.visible = false
  1427. this.getList();
  1428. });
  1429. });
  1430. },
  1431. cancelEditCoverForm() {
  1432. this.batchEditCoverDialog.visible = false
  1433. this.batchEditCoverDialog.form = {
  1434. thumbnail: null,
  1435. }
  1436. },
  1437. }
  1438. }
  1439. </script>
  1440. <style scoped>
  1441. .avatar-uploader-icon {
  1442. display: flex;
  1443. align-items: center;
  1444. justify-content: center;
  1445. }
  1446. </style>
  1447. <style>
  1448. .avatar-uploader .el-upload {
  1449. border: 1px dashed #d9d9d9;
  1450. border-radius: 6px;
  1451. cursor: pointer;
  1452. position: relative;
  1453. overflow: hidden;
  1454. }
  1455. .avatar-uploader .el-upload:hover {
  1456. border-color: #409EFF;
  1457. }
  1458. .avatar-uploader-icon {
  1459. font-size: 28px;
  1460. color: #8c939d;
  1461. width: 150px;
  1462. height: 150px;
  1463. line-height: 150px;
  1464. text-align: center;
  1465. }
  1466. .red:hover {
  1467. color: #dbdbdb !important;
  1468. }
  1469. .red {
  1470. background-color: #F56C6C !important;
  1471. color: #fff !important;
  1472. }
  1473. </style>