userCourseCatalogDetails.vue 45 KB

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