userCourseCatalogDetails.vue 49 KB

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