userCourseCatalogDetailsZM.vue 56 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553
  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" :close-on-click-modal="false" 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. <template slot-scope="scope">
  440. <el-input class="el-input" v-model="scope.row.title"/>
  441. </template>
  442. </el-table-column>
  443. <el-table-column label="视频文件名称" align="center" show-overflow-tooltip prop="fileName">
  444. </el-table-column>
  445. <el-table-column label="视频时长" align="center" prop="duration">
  446. <template slot-scope="{ row }">
  447. {{ formatDuration(row.duration) }}
  448. </template>
  449. </el-table-column>
  450. <el-table-column label="红包金额" align="center" prop="redPacketMoney">
  451. <template slot-scope="scope">
  452. <el-input class="el-input" v-model="scope.row.redPacketMoney"/>
  453. </template>
  454. </el-table-column>
  455. <el-table-column label="排序" align="center" prop="courseSort"/>
  456. <el-table-column label="上传时间" align="center" prop="createTime"/>
  457. </el-table>
  458. <div slot="footer" class="dialog-footer">
  459. <el-button type="primary" @click="batchRedSave">确 定</el-button>
  460. </div>
  461. </el-dialog>
  462. <el-dialog :title="commentDialog.title" :visible.sync="commentDialog.open" width="1000px" append-to-body
  463. :close-on-click-modal="false">
  464. <course-watch-comment ref="courseWatchComment" :courseId="commentDialog.courseId" :videoId="commentDialog.videoId"
  465. v-if="commentDialog.open">
  466. </course-watch-comment>
  467. </el-dialog>
  468. <el-dialog title="修改课节排序" :visible.sync="openVideoSort" style="width: 1600px;" append-to-body>
  469. <draggable v-model="userCourseVideoSortList" @end="onDragEndDay" style="padding: 10px">
  470. <el-button style="margin: 8px 4px;" v-for="(item, index) in userCourseVideoSortList"
  471. :class="item.newCourseSort != item.courseSort ? 'red':''">第{{
  472. item.newCourseSort
  473. }}序(原排序第{{ item.courseSort }})
  474. </el-button>
  475. </draggable>
  476. <div style="float: right;margin-top: -20px">
  477. <el-button type="primary" @click="saveSorts">保存</el-button>
  478. </div>
  479. </el-dialog>
  480. <!-- 批量修改封面 -->
  481. <el-dialog :title="batchEditCoverDialog.title" :visible.sync="batchEditCoverDialog.visible" width="500px" append-to-body>
  482. <el-form ref="batchEditCoverDialogForm"
  483. :model="batchEditCoverDialog.form"
  484. :rules="batchEditCoverDialog.rules"
  485. v-loading="batchEditCoverDialog.uploadLoading">
  486. <el-form-item label="视频封面" prop="thumbnail">
  487. <el-upload v-model="batchEditCoverDialog.form.thumbnail"
  488. class="avatar-uploader"
  489. :action="uploadUrl"
  490. :show-file-list="false"
  491. :on-success="handleCoverSuccess"
  492. :before-upload="beforeAvatarUpload">
  493. <img v-if="batchEditCoverDialog.form.thumbnail" :src="batchEditCoverDialog.form.thumbnail" class="avatar" width="300px">
  494. <i v-else class="el-icon-plus avatar-uploader-icon"></i>
  495. </el-upload>
  496. </el-form-item>
  497. </el-form>
  498. <div slot="footer" class="dialog-footer">
  499. <el-button type="primary" @click="submitEditCoverForm">确 定</el-button>
  500. <el-button @click="cancelEditCoverForm">取 消</el-button>
  501. </div>
  502. </el-dialog>
  503. </div>
  504. </template>
  505. <script>
  506. import {
  507. addUserCourseVideo,
  508. batchSaveVideo,
  509. batchUpdateRed,
  510. delUserCourseVideo,
  511. getSort,
  512. getUserCourseVideo,
  513. getVideoListByCourseId,
  514. getVideoListByCourseIdAll,
  515. sortCourseVideo,
  516. updates,
  517. updateUserCourseVideo,
  518. syncTemplate, batchDownUserCourseVideo, batchEditCover, batchUpUserCourseVideo
  519. } from '@/api/course/userCourseVideo'
  520. // import {syncTemplate} from '@/api/course/userCourse'
  521. import QuestionBank from "@/views/course/courseQuestionBank/QuestionBank.vue";
  522. import CourseProduct from "@/views/course/fsCourseProduct/CourseProductZM.vue";
  523. import VideoUpload from "@/components/VideoUpload/index.vue";
  524. import {listVideoResource} from '@/api/course/videoResource';
  525. import {getByIds} from '@/api/course/courseQuestionBank'
  526. import CourseWatchComment from "./courseWatchComment.vue";
  527. import {getCateListByPid, getCatePidList} from '@/api/course/userCourseCategory'
  528. import draggable from 'vuedraggable'
  529. import { getConfigByKey } from '@/api/system/config'
  530. export default {
  531. name: "userCourseCatalog",
  532. components: {VideoUpload, QuestionBank, CourseWatchComment, CourseProduct, draggable},
  533. watch:{
  534. // 深度监听 rules 数组的变化,以更新总权重
  535. "form.randomRedPacketRulesArr": {
  536. handler(val) {
  537. // this.calculateTotalWeight();
  538. this.validateRules();
  539. },
  540. deep: true,
  541. },
  542. },
  543. data() {
  544. return {
  545. duration: null,
  546. packageList: [],
  547. //课题
  548. package: {
  549. title: '',
  550. open: false,
  551. },
  552. //课题
  553. questionBank: {
  554. title: '',
  555. open: false,
  556. },
  557. //拍商品
  558. courseProduct: {
  559. title: '',
  560. open: false,
  561. },
  562. isPrivate: null,
  563. videoUrl: "",
  564. uploadTypeOptions: [
  565. {dictLabel: "线路一", dictValue: 2},
  566. {dictLabel: "线路二", dictValue: 3},
  567. ],
  568. uploadLoading: false,
  569. courseId: null,
  570. videoName: '',
  571. title: "",
  572. // 是否显示弹出层
  573. open: false,
  574. uploadUrl: process.env.VUE_APP_BASE_API + "/common/uploadOSS",
  575. baseUrl: process.env.VUE_APP_BASE_API,
  576. typeOptions: [],
  577. files: [],
  578. fileList: [],
  579. // 上传成功后的地址
  580. videoURL: '',
  581. // 进度条百分比
  582. progress: 0,
  583. // 上传视频获取成功后拿到的fileID【备用】
  584. fileId: '',
  585. courseName: null,
  586. userCourseVideoList: [],
  587. userCourseVideoSortList: [],
  588. total: 0,
  589. redData: {
  590. queryParams: {
  591. pageNum: 1,
  592. pageSize: 99999,
  593. courseId: null,
  594. },
  595. list: [],
  596. open: false,
  597. loading: true,
  598. form: {}
  599. },
  600. queryParams: {
  601. pageNum: 1,
  602. pageSize: 10,
  603. courseId: null,
  604. videoId: null,
  605. title: null
  606. },
  607. addBatchData: {
  608. open: false,
  609. loading: true,
  610. form: {},
  611. select: [], // 按用户选择顺序存储视频ID
  612. total: 0,
  613. queryParams: {
  614. pageNum: 1,
  615. pageSize: 10,
  616. resourceName: null,
  617. typeId: null,
  618. typeSubId: null
  619. },
  620. typeOptions: [],
  621. typeSubOptions: []
  622. },
  623. // 显示搜索条件
  624. showSearch: true,
  625. // 遮罩层
  626. loading: true,
  627. // 导出遮罩层
  628. exportLoading: false,
  629. // 选中数组
  630. ids: [],
  631. // 非单个禁用
  632. single: true,
  633. // 非多个禁用
  634. multiple: true,
  635. loading3: false,
  636. openVideoSort: false,
  637. // 表单参数
  638. form: {
  639. isOnPut: 0,
  640. courseProducts: [],
  641. randomRedPacketRules:null,
  642. randomRedPacketRulesArr:[
  643. {
  644. minAmount: 0.01,
  645. maxAmount: 0.01,
  646. weight: 100,
  647. }
  648. ]
  649. },
  650. updateBatchData: {
  651. open: false,
  652. form: {}
  653. },
  654. // 表单校验
  655. rules: {
  656. title: [
  657. {required: true, message: "小节名称不能为空", trigger: "change"}
  658. ],
  659. courseSort: [
  660. {required: true, message: "排序不能为空", trigger: "change"}
  661. ],
  662. },
  663. // 评论弹窗数据
  664. commentDialog: {
  665. open: false,
  666. courseId: null,
  667. videoId: null,
  668. title: ""
  669. },
  670. enableRandomRedPacket:false,
  671. // 批量修改封面
  672. batchEditCoverDialog: {
  673. title: '修改视频封面',
  674. visible: false,
  675. uploadLoading: false,
  676. form: {
  677. thumbnail: null,
  678. },
  679. rules: {
  680. thumbnail: [
  681. {required: true, message: "视频封面不能为空", trigger: "change"}
  682. ],
  683. }
  684. }
  685. }
  686. },
  687. created() {
  688. this.getDicts("sys_course_temp_type").then(response => {
  689. this.typeOptions = response.data;
  690. });
  691. getConfigByKey('randomRedpacket:config').then(res=>{
  692. let configData = res.data;
  693. if(!!configData && !!configData.configValue){
  694. let configValue = JSON.parse(configData.configValue);
  695. if(!!configValue.enableRandomRedpacket){
  696. this.enableRandomRedPacket = configValue.enableRandomRedpacket;
  697. console.log("this.enableRandomRedPacket ::" + this.enableRandomRedPacket)
  698. }
  699. }
  700. }).catch(res=>{
  701. })
  702. },
  703. methods: {
  704. getPickerOptions() {
  705. const durationInMinutes = Math.floor(this.form.duration / 60); // 将秒转换为分钟
  706. const endHour = Math.floor(durationInMinutes / 60); // 起始小时
  707. const endMinute = durationInMinutes % 60; // 起始分钟
  708. return {
  709. start: "00:00", // 固定开始时间
  710. step: "00:01", // 时间间隔
  711. end: `${endHour.toString().padStart(2, "0")}:${endMinute
  712. .toString()
  713. .padStart(2, "0")}`, // 动态结束时间
  714. };
  715. },
  716. // 处理时间选择框值变化
  717. handleTimeChange(index, row) {
  718. // 确保 packageList 中的数据被正确更新
  719. this.$set(this.packageList, index, row);
  720. // 同步更新 form.packageJson 字段
  721. this.$nextTick(() => {
  722. // 确保每个疗法包都有 duration 字段
  723. this.packageList.forEach(item => {
  724. if (item.duration === undefined || item.duration === null) {
  725. item.duration = ''; // 空值应初始化为空字符串而不是null,避免显示"null"
  726. }
  727. });
  728. this.form.packageJson = JSON.stringify(this.packageList);
  729. });
  730. },
  731. handlePackageDelete(row) {
  732. this.packageList.splice(this.packageList.findIndex(item => item.packageId === row.packageId), 1)
  733. },
  734. choosePackage() {
  735. this.package.open = true;
  736. this.package.title = '疗法选择';
  737. },
  738. /**
  739. * 选择课题
  740. */
  741. chooseQuestionBank() {
  742. this.questionBank.open = true;
  743. this.questionBank.title = '课题选择';
  744. },
  745. /**
  746. * 选择拍商品
  747. */
  748. chooseCourseProduct() {
  749. this.courseProduct.open = true;
  750. this.courseProduct.title = '拍商品选择';
  751. },
  752. //选择疗法
  753. selectPackage(row) {
  754. const drug = {};
  755. for (var i = 0; i < this.packageList.length; i++) {
  756. if (this.packageList[i].packageId == row.packageId) {
  757. this.$message.warning("疗法已存在!")
  758. return;
  759. }
  760. }
  761. drug.packageId = row.packageId;
  762. drug.packageName = row.packageName;
  763. drug.secondName = row.secondName;
  764. drug.totalPrice = row.totalPrice;
  765. drug.imgUrl = row.imgUrl;
  766. this.packageList.push(drug);
  767. this.$message({
  768. message: '添加成功',
  769. type: 'success'
  770. });
  771. },
  772. courseProductResult(val) {
  773. this.form.courseProducts = this.form.courseProducts || [];
  774. const productData = {
  775. productId: val.productId, // 确保使用 productId
  776. productName: val.productName,
  777. price: val.price,
  778. stock: val.stock,
  779. id: val.productId, // 添加 id 字段,方便删除操作
  780. };
  781. // 检查商品是否已存在
  782. const exists = this.form.courseProducts.some(item => item.productId === val.productId);
  783. if (exists) {
  784. this.$message.error("当前商品已选择");
  785. return;
  786. }
  787. // 添加商品到列表
  788. this.form.courseProducts.push(val);
  789. this.$message.success("添加成功");
  790. },
  791. //选择结果
  792. questionBankResult(val) {
  793. // 确保 questionBankList 是数组
  794. this.form.questionBankList = this.form.questionBankList || [];
  795. for (var i = 0; i < this.form.questionBankList.length; i++) {
  796. if (this.form.questionBankList[i].id == val.id) {
  797. return this.$message.error("当前课题已选择")
  798. }
  799. }
  800. this.form.questionBankList.push(val);
  801. this.$message({
  802. message: '添加成功',
  803. type: 'success'
  804. });
  805. },
  806. //删除课题
  807. handleQuestionBankDelete(row) {
  808. this.form.questionBankList.splice(this.form.questionBankList.findIndex(item => item.id === row.id), 1)
  809. },
  810. //删除商品
  811. handleCourseProductDelete(row) {
  812. // 优先使用 productId 查找
  813. let index = -1;
  814. // 方法1:通过 productId 查找
  815. if (row.productId) {
  816. index = this.form.courseProducts.findIndex(item => item.productId === row.productId);
  817. }
  818. // 方法2:如果 productId 不存在,尝试通过 id 查找
  819. if (index === -1 && row.id) {
  820. index = this.form.courseProducts.findIndex(item => item.id === row.id);
  821. }
  822. // 方法3:如果以上都不行,通过 productName 查找(最后手段)
  823. if (index === -1 && row.productName) {
  824. index = this.form.courseProducts.findIndex(item => item.productName === row.productName);
  825. }
  826. if (index > -1) {
  827. this.form.courseProducts.splice(index, 1);
  828. this.$message.success('删除成功');
  829. } else {
  830. this.$message.warning('未找到对应商品');
  831. }
  832. },
  833. handleVideoChange() {
  834. if (this.form.uploadType == 1) {
  835. this.videoUrl = this.form.lineOne;
  836. } else if (this.form.uploadType == 2) {
  837. this.videoUrl = this.form.lineTwo;
  838. } else if (this.form.uploadType == 3) {
  839. this.videoUrl = this.form.lineThree;
  840. }
  841. },
  842. // 视频库课题
  843. handleSelectProjects(projectIds) {
  844. this.form.questionBankList = []
  845. if (!projectIds || projectIds.length === 0 || this.isPrivate === 0) {
  846. return
  847. }
  848. const params = {ids: projectIds}
  849. getByIds(params).then(response => {
  850. if (response.code === 200) {
  851. response.data.forEach(item => {
  852. let isExist = this.form.questionBankList.some(q => q.id === item.id)
  853. if (!isExist) {
  854. this.form.questionBankList.push(item)
  855. }
  856. });
  857. }
  858. })
  859. },
  860. handleVideoDuration(duration) {
  861. this.form.duration = duration;
  862. },
  863. formatDuration(seconds) {
  864. if (seconds === null || seconds === undefined) {
  865. return '未上传视频';
  866. }
  867. const hours = Math.floor(seconds / 3600);
  868. const minutes = Math.floor((seconds % 3600) / 60);
  869. const remainingSeconds = seconds % 60;
  870. const formattedHours = hours > 0 ? hours.toString() + ':' : '';
  871. const formattedMinutes = minutes.toString().padStart(2, '0');
  872. const formattedSeconds = remainingSeconds.toString().padStart(2, '0');
  873. return `${formattedHours}${formattedMinutes}:${formattedSeconds}`;
  874. },
  875. handleAvatarSuccess(res, file) {
  876. if (res.code == 200) {
  877. this.form.thumbnail = res.url;
  878. this.$forceUpdate()
  879. } else {
  880. this.msgError(res.msg);
  881. }
  882. },
  883. beforeAvatarUpload(file) {
  884. const isLt1M = file.size / 1024 / 1024 < 5;
  885. if (!isLt1M) {
  886. this.$message.error('上传图片大小不能超过 5MB!');
  887. }
  888. return isLt1M;
  889. },
  890. getDetails(courseId, courseName, isPrivate) {
  891. this.isPrivate = isPrivate
  892. this.courseName = courseName
  893. this.courseId = courseId;
  894. this.queryParams.courseId = courseId;
  895. this.getList();
  896. },
  897. getList() {
  898. this.loading = true;
  899. getVideoListByCourseId(this.queryParams).then(response => {
  900. this.userCourseVideoList = response.rows;
  901. this.total = response.total;
  902. this.loading = false;
  903. });
  904. },
  905. // 取消按钮
  906. cancel() {
  907. this.open = false;
  908. this.reset();
  909. },
  910. // 表单重置
  911. reset() {
  912. this.form = {
  913. videoId: null,
  914. title: null,
  915. description: null,
  916. url: null,
  917. thumbnail: null,
  918. duration: null,
  919. createTime: null,
  920. uploadType: null,
  921. lineOne: null,
  922. lineTwo: null,
  923. lineThree: null,
  924. fileName: null,
  925. userId: null,
  926. cateId: null,
  927. courseId: null,
  928. likes: null,
  929. views: null,
  930. comments: null,
  931. status: 0,
  932. courseSort: 1,
  933. isHot: null,
  934. isShow: null,
  935. isAudit: null,
  936. auditBy: null,
  937. auditTime: null,
  938. updateTime: null,
  939. source: null,
  940. isDel: null,
  941. shares: null,
  942. tags: null,
  943. productId: null,
  944. id: null,
  945. packageJson: null,
  946. questionBankId: null,
  947. questionBankList: [],
  948. redPacketMoney: 0,
  949. isTranscode: 0,
  950. transcodeFileKey: null,
  951. isProduct: 0,
  952. isFirst: 0,
  953. isSpeed: 0,
  954. isOnPut: 0,
  955. listingStartTime: null,
  956. listingEndTime: null,
  957. showProduct: 1, // 默认无商品
  958. randomRedPacketRules:null,
  959. randomRedPacketRulesArr:[
  960. {
  961. minAmount: 0.01,
  962. maxAmount: 0.01,
  963. weight: 100,
  964. }
  965. ]
  966. };
  967. this.videoURL = '';
  968. this.progress = 0;
  969. this.resetForm("form");
  970. },
  971. /** 搜索按钮操作 */
  972. handleQuery() {
  973. this.queryParams.pageNum = 1;
  974. this.getList();
  975. },
  976. /** 重置按钮操作 */
  977. resetQuery() {
  978. this.resetForm("queryForm");
  979. this.handleQuery();
  980. },
  981. // 多选框选中数据
  982. handleSelectionChange(selection) {
  983. this.ids = selection.map(item => item.videoId)
  984. this.single = selection.length !== 1
  985. this.multiple = !selection.length
  986. },
  987. // 视频库多选框选中数据(按用户点击顺序记录)
  988. handVideoleSelectionChange(selection) {
  989. // 提取当前选中的所有ID
  990. const selectedIds = selection.map(item => item.id);
  991. // 处理新增选中项:保留用户点击顺序
  992. selectedIds.forEach(id => {
  993. if (!this.addBatchData.select.includes(id)) {
  994. this.addBatchData.select.push(id);
  995. }
  996. });
  997. // 处理取消选中项:移除已取消的ID
  998. this.addBatchData.select = this.addBatchData.select.filter(id => selectedIds.includes(id));
  999. },
  1000. handleAdd() {
  1001. this.reset();
  1002. this.form.courseId = this.courseId;
  1003. this.open = true;
  1004. this.title = "添加课堂视频";
  1005. this.videoUrl = '';
  1006. this.packageList = [];
  1007. getSort(this.courseId).then(response => {
  1008. this.form.courseSort = Number(response.data);
  1009. })
  1010. setTimeout(() => {
  1011. this.$refs.videoUpload.resetUpload();
  1012. }, 500);
  1013. },
  1014. /** 修改按钮操作 */
  1015. handleUpdate(row) {
  1016. this.reset();
  1017. this.form.isOnPut = row.isOnPut;
  1018. this.packageList = [];
  1019. const videoId = row.videoId || this.ids;
  1020. getUserCourseVideo(videoId).then(response => {
  1021. console.log(response);
  1022. this.form = response.data;
  1023. this.$set(this.form, 'isOnPut', response.data.isOnPut !== undefined ? response.data.isOnPut : 0);
  1024. if (this.form.randomRedPacketRules) {
  1025. this.$set(this.form, 'randomRedPacketRulesArr', JSON.parse(this.form.randomRedPacketRules));
  1026. } else {
  1027. // 处理初始值
  1028. this.form.randomRedPacketRulesArr = [{
  1029. minAmount: 0.01,
  1030. maxAmount: 0.01,
  1031. weight: 100,
  1032. }];
  1033. }
  1034. if (response.data.videoUrl != null && response.data.videoUrl !== '') {
  1035. this.videoUrl = response.data.videoUrl;
  1036. }
  1037. if (this.form.packageJson != null) {
  1038. try {
  1039. // 检查 packageJson 是否包含商品数据,如果是则解析为 courseProducts
  1040. const parsedData = JSON.parse(this.form.packageJson);
  1041. if (Array.isArray(parsedData) && parsedData.length > 0 && parsedData[0].hasOwnProperty('productName')) {
  1042. // 如果是商品数据格式,则设置到 courseProducts
  1043. this.form.courseProducts = parsedData;
  1044. } else {
  1045. // 否则按照原有逻辑设置到 packageList
  1046. this.packageList = parsedData;
  1047. }
  1048. } catch (e) {
  1049. // 如果解析失败,按原来的处理方式
  1050. this.packageList = JSON.parse(this.form.packageJson);
  1051. }
  1052. }
  1053. if (response.data.viewStartTime != null && response.data.viewEndTime != null) {
  1054. this.form.timeRange = [response.data.viewStartTime, response.data.viewEndTime];
  1055. }
  1056. // 根据商品数量设置是否关联商品状态
  1057. if (this.form.courseProducts && this.form.courseProducts.length > 0) {
  1058. this.form.isProduct = 1; // 有关联商品时设为1(是)
  1059. } else {
  1060. this.form.isProduct = 0; // 无关联商品时设为0(否)
  1061. }
  1062. // 设置商品选择状态
  1063. if (this.form.id) {
  1064. this.form.showProduct = 0; // 有商品时设为0
  1065. } else {
  1066. this.form.showProduct = 1; // 无商品时设为1
  1067. }
  1068. setTimeout(() => {
  1069. this.$refs.videoUpload.resetUpload();
  1070. }, 500);
  1071. this.open = true;
  1072. this.title = "修改课堂视频";
  1073. });
  1074. },
  1075. /** 提交按钮 */
  1076. submitForm() {
  1077. this.$refs["form"].validate(valid => {
  1078. if (valid) {
  1079. this.form.videoUrl = this.videoUrl;
  1080. if (this.form.videoUrl == null || this.form.videoUrl === '') {
  1081. this.$message({
  1082. message: '请上传视频!',
  1083. type: 'warning'
  1084. });
  1085. return
  1086. }
  1087. if (this.form.timeRange && this.form.timeRange.length === 2) {
  1088. this.form.viewStartTime = this.form.timeRange[0];
  1089. this.form.viewEndTime = this.form.timeRange[1];
  1090. }
  1091. if (this.form.duration == null) {
  1092. this.$message({
  1093. message: '未识别到视频时长请稍等。。。',
  1094. type: 'warning'
  1095. });
  1096. return
  1097. }
  1098. if (this.form.isProduct != null && this.form.isProduct == 1 && (this.form.courseProducts == null || this.form.courseProducts.length < 1)) {
  1099. this.$message({
  1100. message: '请选择关联商品',
  1101. type: 'warning'
  1102. });
  1103. return
  1104. }
  1105. if (this.form.questionBankList !== null) {
  1106. this.form.questionBankId = this.form.questionBankList.map(item => item.id).join(',');
  1107. }
  1108. // 处理商品选择逻辑
  1109. if (this.form.courseProducts && this.form.courseProducts.length > 0) {
  1110. this.form.id = this.form.courseProducts.map(item => item.id).join(',');
  1111. this.form.showProduct = 0; // 有商品选择时设为0
  1112. // 将商品数据序列化为JSON字符串传递给packageJson
  1113. this.form.packageJson = JSON.stringify(this.form.courseProducts);
  1114. } else {
  1115. this.form.id = null;
  1116. this.form.showProduct = 1; // 无商品选择时设为1
  1117. this.form.packageJson = "[]"; // 无商品时传递空数组
  1118. }
  1119. if (this.form.randomRedPacketRulesArr) {
  1120. let rulesJson = JSON.stringify(this.form.randomRedPacketRulesArr);
  1121. this.form.randomRedPacketRules = rulesJson;
  1122. }
  1123. if (this.form.videoId != null) {
  1124. updateUserCourseVideo(this.form).then(response => {
  1125. this.msgSuccess("修改成功");
  1126. this.open = false;
  1127. this.getList();
  1128. });
  1129. } else {
  1130. addUserCourseVideo(this.form).then(response => {
  1131. this.msgSuccess("新增成功");
  1132. this.open = false;
  1133. this.getList();
  1134. });
  1135. }
  1136. }
  1137. });
  1138. },
  1139. openUpdates() {
  1140. this.updateBatchData.form = {};
  1141. this.updateBatchData.open = true;
  1142. },
  1143. /** 提交按钮 */
  1144. updateBatch() {
  1145. this.updateBatchData.form.ids = this.ids;
  1146. if (this.updateBatchData.form.timeRange != null && this.updateBatchData.form.timeRange.length === 2) {
  1147. this.updateBatchData.form.viewStartTime = this.updateBatchData.form.timeRange[0];
  1148. this.updateBatchData.form.viewEndTime = this.updateBatchData.form.timeRange[1];
  1149. }
  1150. updates(this.updateBatchData.form).then(response => {
  1151. this.msgSuccess("修改成功");
  1152. this.updateBatchData.open = false;
  1153. this.getList();
  1154. });
  1155. },
  1156. /** 删除按钮操作 */
  1157. handleDelete(row) {
  1158. const videoIds = row.videoId || this.ids;
  1159. this.$confirm('是否确认删除视频编号为"' + videoIds + '"的数据项?', "警告", {
  1160. confirmButtonText: "确定",
  1161. cancelButtonText: "取消",
  1162. type: "warning"
  1163. }).then(function () {
  1164. return delUserCourseVideo(videoIds);
  1165. }).then(() => {
  1166. this.getList();
  1167. this.msgSuccess("删除成功");
  1168. }).catch(() => {
  1169. });
  1170. },
  1171. /** 同步模板数据*/
  1172. handleSync() {
  1173. const courseId = this.courseId;
  1174. this.$confirm('是否同步课程数据至模板', "确认", {
  1175. confirmButtonText: "确定",
  1176. cancelButtonText: "取消",
  1177. type: "warning"
  1178. }).then(function () {
  1179. return syncTemplate(courseId);
  1180. }).then(() => {
  1181. this.getList();
  1182. this.msgSuccess("正在同步模板中!!请稍后!");
  1183. }).catch(() => {
  1184. });
  1185. },
  1186. handleCourseSort() {
  1187. getVideoListByCourseIdAll(this.queryParams.courseId).then(response => {
  1188. response.rows.forEach((item) => item.newCourseSort = item.courseSort);
  1189. this.userCourseVideoSortList = response.rows.sort((a, b) => a.courseSort - b.courseSort);
  1190. if (this.userCourseVideoSortList == null || this.userCourseVideoSortList.length == 0) {
  1191. this.$message.error("暂无课节天数")
  1192. } else {
  1193. this.openVideoSort = true;
  1194. }
  1195. })
  1196. },
  1197. onDragEndDay() {
  1198. this.userCourseVideoSortList.forEach((item, index) => {
  1199. item.newCourseSort = index + 1;
  1200. })
  1201. this.$forceUpdate()
  1202. },
  1203. saveSorts() {
  1204. let list = this.userCourseVideoSortList.filter(e => e.courseSort != e.newCourseSort).map(e => {
  1205. return {courseSort: e.newCourseSort, videoId: e.videoId}
  1206. })
  1207. this.loading3 = true;
  1208. sortCourseVideo(list).then(e => {
  1209. this.getList();
  1210. }).finally(() => {
  1211. this.userCourseVideoSortList = [];
  1212. this.openVideoSort = false;
  1213. })
  1214. },
  1215. openAdds() {
  1216. this.addBatchData.open = true;
  1217. this.getRootTypeList();
  1218. this.addBatchData.form = {
  1219. courseId: this.courseId,
  1220. };
  1221. // 重置选择顺序数组
  1222. this.addBatchData.select = [];
  1223. this.resourceList();
  1224. },
  1225. getRootTypeList() {
  1226. getCatePidList().then(response => {
  1227. this.addBatchData.typeOptions = response.data
  1228. });
  1229. },
  1230. async changeCateType(val) {
  1231. this.addBatchData.queryParams.typeSubId = null
  1232. this.addBatchData.typeSubOptions = []
  1233. if (!val) {
  1234. return
  1235. }
  1236. await getCateListByPid(val).then(response => {
  1237. this.addBatchData.typeSubOptions = response.data
  1238. })
  1239. },
  1240. resourceList() {
  1241. this.addBatchData.loading = true;
  1242. listVideoResource(this.addBatchData.queryParams).then(response => {
  1243. this.addBatchData.loading = false;
  1244. this.addBatchData.list = response.rows;
  1245. this.addBatchData.total = response.total;
  1246. });
  1247. },
  1248. batchVideoSave() {
  1249. if (this.addBatchData.select.length === 0) {
  1250. this.$message({
  1251. message: '请选择视频!!',
  1252. type: 'warning'
  1253. });
  1254. return
  1255. }
  1256. this.addBatchData.form.ids = this.addBatchData.select; // 按用户选择顺序提交
  1257. batchSaveVideo(this.addBatchData.form).then(response => {
  1258. this.addBatchData.open = false;
  1259. this.getList();
  1260. })
  1261. },
  1262. updateRedPageckeOpen() {
  1263. this.redData.open = true;
  1264. this.redData.loading = true;
  1265. this.redData.queryParams.courseId = this.courseId;
  1266. getVideoListByCourseId(this.redData.queryParams).then(response => {
  1267. if(!!response.rows && response.rows.length >0){
  1268. for(let i = 0; i < response.rows.length; i++){
  1269. if(!!response.rows[i].randomRedPacketRules){
  1270. this.$set(response.rows[i], 'randomRedPacketRulesArr', JSON.parse(response.rows[i].randomRedPacketRules)) ;
  1271. }
  1272. }
  1273. }
  1274. this.redData.list = response.rows;
  1275. console.log(this.redData.list);
  1276. this.redData.loading = false;
  1277. });
  1278. },
  1279. batchRedSave() {
  1280. batchUpdateRed(this.redData.list).then(response => {
  1281. this.redData.open = false;
  1282. this.getList();
  1283. })
  1284. },
  1285. /** 查看评论按钮操作 */
  1286. handleComment(row) {
  1287. this.commentDialog.courseId = row.courseId || this.courseId;
  1288. this.commentDialog.videoId = row.videoId;
  1289. this.commentDialog.title = `查看评论 - ${row.title}`;
  1290. this.commentDialog.open = true;
  1291. },
  1292. // 实时过滤金额输入,只允许两位小数
  1293. handleAmountInput(rule, field) {
  1294. let value = rule[field];
  1295. if (value === null || value === undefined) return;
  1296. // 转换为字符串处理
  1297. let str = value.toString();
  1298. // 移除除数字和小数点外的所有字符
  1299. str = str.replace(/[^0-9.]/g, '');
  1300. // 只保留一个小数点
  1301. const dotIndex = str.indexOf('.');
  1302. if (dotIndex !== -1) {
  1303. str = str.substring(0, dotIndex + 1) + str.substring(dotIndex + 1).replace(/\./g, '');
  1304. }
  1305. // 限制小数点后最多两位
  1306. if (dotIndex !== -1 && str.length > dotIndex + 3) {
  1307. str = str.substring(0, dotIndex + 3);
  1308. }
  1309. // 转换回数字并更新
  1310. rule[field] = parseFloat(str) || 0;
  1311. },
  1312. deleteRule(index) {
  1313. this.$confirm("确定要删除这个区间吗?", "提示", {
  1314. confirmButtonText: "确定",
  1315. cancelButtonText: "取消",
  1316. type: "warning",
  1317. }).then(() => {
  1318. this.form.randomRedPacketRulesArr.splice(index, 1);
  1319. this.$message({
  1320. type: "success",
  1321. message: "删除成功!",
  1322. });
  1323. });
  1324. },
  1325. addRule(index) {
  1326. // 在当前行的后面插入一个新行
  1327. this.form.randomRedPacketRulesArr.splice(index + 1, 0, {
  1328. minAmount: 0.01,
  1329. maxAmount: 0.01,
  1330. weight: 100,
  1331. });
  1332. },
  1333. // 自定义校验规则:确保最大金额大于最小金额
  1334. validateMinAmount(rule, value, callback) {
  1335. // debugger;
  1336. // const maxAmount = this.form29.rules[].maxAmount
  1337. const index = rule.index;
  1338. const maxAmount = this.form.randomRedPacketRulesArr[index].maxAmount;
  1339. if (value > maxAmount) {
  1340. callback(new Error("最小金额不能大于最大金额"));
  1341. } else {
  1342. callback();
  1343. }
  1344. },
  1345. validateRules() {
  1346. this.form.randomRedPacketRulesArr.forEach((rule) => {
  1347. if (rule.minAmount === undefined || rule.minAmount < 0.01) {
  1348. rule.minAmount = 0.01;
  1349. }
  1350. if (rule.maxAmount === undefined || rule.maxAmount < rule.minAmount) {
  1351. rule.maxAmount = rule.minAmount;
  1352. }
  1353. if (rule.weight === undefined || rule.weight < 1) {
  1354. rule.weight = 1;
  1355. }
  1356. });
  1357. },
  1358. /** 下架 **/
  1359. handleDown() {
  1360. const videoIds = this.ids;
  1361. this.$confirm('是否确认下架视频编号为"' + videoIds + '"的数据项?', "警告", {
  1362. confirmButtonText: "确定",
  1363. cancelButtonText: "取消",
  1364. type: "warning"
  1365. }).then(function () {
  1366. return batchDownUserCourseVideo(videoIds);
  1367. }).then(() => {
  1368. this.getList();
  1369. this.msgSuccess("下架成功");
  1370. }).catch(() => {
  1371. });
  1372. },
  1373. /** 上架按钮操作 */
  1374. handleUp() {
  1375. const videoIds = this.ids;
  1376. this.$confirm('是否确认上架视频编号为"' + videoIds + '"的数据项?', "警告", {
  1377. confirmButtonText: "确定",
  1378. cancelButtonText: "取消",
  1379. type: "warning"
  1380. }).then(function () {
  1381. return batchUpUserCourseVideo(videoIds);
  1382. }).then(() => {
  1383. this.getList();
  1384. this.msgSuccess("上架成功");
  1385. }).catch(function () {
  1386. });
  1387. },
  1388. /** 修改封面 **/
  1389. handleEditCover() {
  1390. this.batchEditCoverDialog.form = {
  1391. thumbnail: null
  1392. }
  1393. this.batchEditCoverDialog.visible = true
  1394. },
  1395. handleCoverSuccess(res, file) {
  1396. if (res.code === 200) {
  1397. this.batchEditCoverDialog.form.thumbnail = res.url;
  1398. this.$forceUpdate()
  1399. } else {
  1400. this.msgError(res.msg);
  1401. }
  1402. },
  1403. submitEditCoverForm() {
  1404. this.$refs["batchEditCoverDialogForm"].validate(valid => {
  1405. if (!valid) {
  1406. return;
  1407. }
  1408. const thumbnail = this.batchEditCoverDialog.form.thumbnail
  1409. const videoIds = this.ids
  1410. if (!thumbnail || thumbnail === '') {
  1411. this.$message({
  1412. message: '请上传封面!',
  1413. type: 'warning'
  1414. });
  1415. return
  1416. }
  1417. if (!videoIds || videoIds.length === 0) {
  1418. this.$message({
  1419. message: '请选择小节!',
  1420. type: 'warning'
  1421. });
  1422. return
  1423. }
  1424. const params = {
  1425. thumbnail: thumbnail,
  1426. videoIds: videoIds
  1427. }
  1428. batchEditCover(params).then(response => {
  1429. this.msgSuccess("修改成功")
  1430. this.batchEditCoverDialog.visible = false
  1431. this.getList();
  1432. });
  1433. });
  1434. },
  1435. cancelEditCoverForm() {
  1436. this.batchEditCoverDialog.visible = false
  1437. this.batchEditCoverDialog.form = {
  1438. thumbnail: null,
  1439. }
  1440. },
  1441. }
  1442. }
  1443. </script>
  1444. <style scoped>
  1445. .avatar-uploader-icon {
  1446. display: flex;
  1447. align-items: center;
  1448. justify-content: center;
  1449. }
  1450. </style>
  1451. <style>
  1452. .avatar-uploader .el-upload {
  1453. border: 1px dashed #d9d9d9;
  1454. border-radius: 6px;
  1455. cursor: pointer;
  1456. position: relative;
  1457. overflow: hidden;
  1458. }
  1459. .avatar-uploader .el-upload:hover {
  1460. border-color: #409EFF;
  1461. }
  1462. .avatar-uploader-icon {
  1463. font-size: 28px;
  1464. color: #8c939d;
  1465. width: 150px;
  1466. height: 150px;
  1467. line-height: 150px;
  1468. text-align: center;
  1469. }
  1470. .red:hover {
  1471. color: #dbdbdb !important;
  1472. }
  1473. .red {
  1474. background-color: #F56C6C !important;
  1475. color: #fff !important;
  1476. }
  1477. </style>