userCourseCatalogDetails.vue 45 KB

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