index.vue 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px">
  4. <el-form-item label="课堂分类" prop="cateId">
  5. <el-select v-model="queryParams.cateId" placeholder="请选择" clearable size="small"
  6. @change="getQuerySubCateList(queryParams.cateId)">
  7. <el-option
  8. v-for="dict in categoryOptions"
  9. :key="dict.dictValue"
  10. :label="dict.dictLabel"
  11. :value="dict.dictValue"
  12. />
  13. </el-select>
  14. </el-form-item>
  15. <el-form-item label="课堂子分类" prop="subCateId">
  16. <el-select v-model="queryParams.subCateId" placeholder="请选择" clearable size="small">
  17. <el-option
  18. v-for="dict in querySubCateOptions"
  19. :key="dict.dictValue"
  20. :label="dict.dictLabel"
  21. :value="dict.dictValue"
  22. />
  23. </el-select>
  24. </el-form-item>
  25. <el-form-item label="课堂名称" prop="courseName">
  26. <el-input
  27. v-model="queryParams.courseName"
  28. placeholder="请输入课堂名称"
  29. clearable
  30. size="small"
  31. @keyup.enter.native="handleQuery"
  32. />
  33. </el-form-item>
  34. <el-form-item label="关联的公司" prop="companyIds">
  35. <el-select v-model="queryParams.companyIdsList" multiple placeholder="请选择公司" filterable clearable style="width: 90%;">
  36. <el-option
  37. v-for="dict in companyOptions"
  38. :key="dict.dictValue"
  39. :label="dict.dictLabel"
  40. :value="dict.dictValue"
  41. />
  42. </el-select>
  43. </el-form-item>
  44. <el-form-item label="课堂类型" prop="isPrivate" style="display: none">
  45. <el-select v-model="queryParams.isPrivate" placeholder="请选择" clearable size="small">
  46. <el-option
  47. v-for="dict in courseTypeOptions"
  48. :key="dict.dictValue"
  49. :label="dict.dictLabel"
  50. :value="dict.dictValue"
  51. />
  52. </el-select>
  53. </el-form-item>
  54. <el-form-item>
  55. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  56. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  57. </el-form-item>
  58. </el-form>
  59. <el-row :gutter="10" class="mb8">
  60. <el-col :span="1.5">
  61. <el-button
  62. type="primary"
  63. plain
  64. icon="el-icon-plus"
  65. size="mini"
  66. @click="handleAdd"
  67. v-hasPermi="['course:userCourse:add']"
  68. >新增
  69. </el-button>
  70. </el-col>
  71. <el-col :span="1.5">
  72. <el-button
  73. type="success"
  74. plain
  75. icon="el-icon-edit"
  76. size="mini"
  77. :disabled="single"
  78. @click="handleUpdate"
  79. v-hasPermi="['course:userCourse:edit']"
  80. >修改
  81. </el-button>
  82. </el-col>
  83. <el-col :span="1.5">
  84. <el-button
  85. type="danger"
  86. plain
  87. icon="el-icon-delete"
  88. size="mini"
  89. :disabled="multiple"
  90. @click="handleDelete"
  91. v-hasPermi="['course:userCourse:remove']"
  92. >删除
  93. </el-button>
  94. </el-col>
  95. <el-col :span="1.5">
  96. <el-button
  97. type="warning"
  98. plain
  99. icon="el-icon-download"
  100. size="mini"
  101. :loading="exportLoading"
  102. @click="handleExport"
  103. v-hasPermi="['course:userCourse:export']"
  104. >导出
  105. </el-button>
  106. </el-col>
  107. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  108. </el-row>
  109. <el-table height="600" border v-loading="loading" :data="userCourseList" @selection-change="handleSelectionChange" style="width: 100%" :fit="true">
  110. <el-table-column type="selection" width="55" align="center"/>
  111. <el-table-column label="课程ID" align="center" prop="courseId" width="55"/>
  112. <el-table-column label="所属项目" align="center" prop="projectName" width="120"/>
  113. <el-table-column label="封面图片" align="center" prop="imgUrl" width="170">
  114. <template slot-scope="scope">
  115. <el-popover
  116. placement="right"
  117. title=""
  118. trigger="hover"
  119. >
  120. <img slot="reference" :src="scope.row.imgUrl" width="100">
  121. <img :src="scope.row.imgUrl" style="max-width: 300px;">
  122. </el-popover>
  123. </template>
  124. </el-table-column>
  125. <el-table-column label="课堂名称" align="center" show-overflow-tooltip prop="courseName" min-width="100"/>
  126. <el-table-column label="排序" align="center" prop="sort" width="80"/>
  127. <el-table-column label="分类名称" align="center" prop="cateName" width="120"/>
  128. <el-table-column label="子分类名称" align="center" prop="subCateName" width="120"/>
  129. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  130. <template slot-scope="scope">
  131. <el-button
  132. size="mini"
  133. type="text"
  134. @click="handleCatalog(scope.row)"
  135. v-hasPermi="['course:userCourse:cateMange']"
  136. >目录管理
  137. </el-button>
  138. <el-button
  139. size="mini"
  140. type="text"
  141. icon="el-icon-edit"
  142. @click="handleUpdate(scope.row)"
  143. v-hasPermi="['course:userCourse:edit']"
  144. >修改
  145. </el-button>
  146. <el-button
  147. size="mini"
  148. type="text"
  149. icon="el-icon-edit"
  150. @click="handleUpdateRedPage(scope.row)"
  151. v-hasPermi="['course:userCourse:editRedPage']"
  152. >统一修改红包金额
  153. </el-button>
  154. <el-button
  155. size="mini"
  156. type="text"
  157. icon="el-icon-edit"
  158. @click="handleCopy(scope.row)"
  159. v-hasPermi="['course:userCourse:copy']"
  160. >复制
  161. </el-button>
  162. <el-button
  163. size="mini"
  164. type="text"
  165. icon="el-icon-delete"
  166. @click="handleDelete(scope.row)"
  167. v-hasPermi="['course:userCourse:remove']"
  168. >删除
  169. </el-button>
  170. <el-button
  171. size="mini"
  172. type="text"
  173. v-if="scope.row.isPrivate === 1"
  174. v-has-permi="['course:userCourse:editConfig']"
  175. @click="configCourse(scope.row)"
  176. >过程页配置
  177. </el-button>
  178. </template>
  179. </el-table-column>
  180. </el-table>
  181. <pagination
  182. v-show="total>0"
  183. :total="total"
  184. :page.sync="queryParams.pageNum"
  185. :limit.sync="queryParams.pageSize"
  186. @pagination="getList"
  187. />
  188. <!-- 添加或修改课程对话框 -->
  189. <el-dialog :title="title" :visible.sync="open" width="1200px" append-to-body>
  190. <el-form ref="form" :model="form" :rules="rules" label-width="110px">
  191. <el-row>
  192. <el-form-item label="所属项目" prop="project">
  193. <el-select v-model="form.project" placeholder="请选择项目" filterable clearable size="small">
  194. <el-option
  195. v-for="dict in projectOptions"
  196. :key="dict.dictValue"
  197. :label="dict.dictLabel"
  198. :value="dict.dictValue"
  199. />
  200. </el-select>
  201. </el-form-item>
  202. </el-row>
  203. <el-row>
  204. <el-col :span="8">
  205. <el-form-item label="课堂名称" prop="courseName">
  206. <el-input v-model="form.courseName" placeholder="请输入课堂名称"/>
  207. </el-form-item>
  208. </el-col>
  209. <el-col :span="8">
  210. <el-form-item label="课堂分类" prop="cateId">
  211. <el-select v-model="form.cateId" placeholder="请选择" clearable size="small"
  212. @change="getSubCateList(form.cateId)">
  213. <el-option
  214. v-for="dict in categoryOptions"
  215. :key="dict.dictValue"
  216. :label="dict.dictLabel"
  217. :value="dict.dictValue"
  218. />
  219. </el-select>
  220. </el-form-item>
  221. </el-col>
  222. <el-col :span="8">
  223. <el-form-item label="课堂子分类" prop="subCateId">
  224. <el-select v-model="form.subCateId" placeholder="请选择" clearable size="small">
  225. <el-option
  226. v-for="dict in subCategoryOptions"
  227. :key="dict.dictValue"
  228. :label="dict.dictLabel"
  229. :value="dict.dictValue"
  230. />
  231. </el-select>
  232. </el-form-item>
  233. </el-col>
  234. </el-row>
  235. <el-row>
  236. <el-col :span="24">
  237. <el-form-item label="排序" prop="sort">
  238. <el-input-number v-model="form.sort" :min="0" label="排序"></el-input-number>
  239. </el-form-item>
  240. </el-col>
  241. </el-row>
  242. <el-row>
  243. <el-col :span="24">
  244. <el-form-item label="课堂简介" prop="description">
  245. <el-input v-model="form.description" type="textarea" :rows="2" placeholder="请输入课堂简介"/>
  246. </el-form-item>
  247. </el-col>
  248. </el-row>
  249. <el-form-item label="课程封面" prop="imgUrl">
  250. <ImageUpload v-model="form.imgUrl" type="image" :num="10" :width="150" :height="150"/>
  251. </el-form-item>
  252. <el-form-item label="关联公司" prop="tags">
  253. <el-select v-model="companyIds" multiple placeholder="请选择公司" filterable clearable style="width: 90%;">
  254. <el-option
  255. v-for="dict in companyOptions"
  256. :key="dict.dictValue"
  257. :label="dict.dictLabel"
  258. :value="dict.dictValue"
  259. />
  260. </el-select>
  261. </el-form-item>
  262. </el-form>
  263. <div slot="footer" class="dialog-footer">
  264. <el-button type="primary" @click="submitForm">确 定</el-button>
  265. <el-button @click="cancel">取 消</el-button>
  266. </div>
  267. </el-dialog>
  268. <el-dialog title="修改课程红包金额" :visible.sync="openRedPage.open" width="1000px" append-to-body>
  269. <el-form ref="openRedPage" :model="openRedPage" :rules="rulesRedPage" label-width="110px">
  270. <el-form-item label="红包金额" prop="redPacketMoney">
  271. <el-input-number v-model="openRedPage.redPacketMoney" :min="0.1" :max="200" :step="0.1"></el-input-number>
  272. </el-form-item>
  273. <div v-if="!!enableRandomRedPacket" style=" display: flex;
  274. flex-direction: column;">
  275. <div v-for="(rule, index) in openRedPage.rules" :key="index" class="form-row">
  276. <el-form-item
  277. label="随机红包金额区间"
  278. :prop="`rules.${index}.minAmount`"
  279. :rules="[
  280. { required: true, message: '请输入最小金额', trigger: 'blur' },
  281. { validator: validateMinAmount, trigger: 'blur', index: index }
  282. ]"
  283. class="form-item-amount"
  284. >
  285. <el-input
  286. v-model.number="rule.minAmount"
  287. type="number"
  288. :min="0.01"
  289. :precision="2"
  290. :step="0.01"
  291. placeholder="最小金额"
  292. size="small"
  293. class="amount-input"
  294. @input="handleAmountInput(rule, 'minAmount')"
  295. ></el-input>
  296. <span class="separator">-</span>
  297. <el-input
  298. v-model.number="rule.maxAmount"
  299. type="number"
  300. :min="rule.minAmount || 0.01"
  301. :precision="2"
  302. :step="0.01"
  303. placeholder="最大金额"
  304. size="small"
  305. class="amount-input"
  306. @input="handleAmountInput(rule, 'maxAmount')"
  307. ></el-input>
  308. <span class="suffix">元</span>
  309. </el-form-item>
  310. <el-form-item
  311. label="随机权重"
  312. :prop="`rules.${index}.weight`"
  313. :rules="[
  314. { required: true, message: '请输入权重', trigger: 'blur' },
  315. { type: 'integer', message: '权重必须为整数', trigger: 'blur' },
  316. ]"
  317. class="form-item-weight"
  318. >
  319. <el-input
  320. v-model.number="rule.weight"
  321. type="number"
  322. :min="1"
  323. placeholder="权重"
  324. size="small"
  325. ></el-input>
  326. </el-form-item>
  327. <el-tooltip class="item" effect="dark" content="权重越高,被随机到的概率越大" placement="top">
  328. <i class="el-icon-question"></i>
  329. </el-tooltip>
  330. <div class="action-buttons">
  331. <el-button
  332. icon="el-icon-plus"
  333. size="mini"
  334. type="text"
  335. @click="addRule(index)"
  336. class="add-btn"
  337. >
  338. 新增
  339. </el-button>
  340. <el-button
  341. icon="el-icon-delete"
  342. size="mini"
  343. type="text"
  344. @click="deleteRule(index)"
  345. :disabled="openRedPage.rules.length <= 1"
  346. class="delete-btn"
  347. >
  348. 删除
  349. </el-button>
  350. </div>
  351. </div>
  352. </div>
  353. </el-form>
  354. <div slot="footer" class="dialog-footer">
  355. <el-button type="primary" @click="submitFormRedPage">确 定</el-button>
  356. <el-button @click="cancelRedPage">取 消</el-button>
  357. </div>
  358. </el-dialog>
  359. <!-- 过程页配置 -->
  360. <el-dialog
  361. :visible.sync="configDialog.dialogVisible"
  362. title="过程页配置"
  363. append-to-body
  364. width="1200px"
  365. >
  366. <el-form :model="configDialog.form" :rules="configDialog.rules" ref="configForm" label-width="110px">
  367. <el-form-item label="过程页图片" prop="coverImg">
  368. <ImageUpload v-model="configDialog.form.coverImg" :height="150" :limit="1" :width="150" type="image"/>
  369. <i class="el-icon-warning"/>
  370. <span style="color: rgb(153, 169, 191)"> 不配置将使用课程默认图片</span>
  371. </el-form-item>
  372. <el-form-item label="首播电视台" prop="tvEnable">
  373. <el-switch v-model="configDialog.form.tvEnable" active-color="#13ce66"/>
  374. </el-form-item>
  375. <el-form-item prop="tv" v-if="configDialog.form.tvEnable">
  376. <el-input v-model="configDialog.form.tv" clearable></el-input>
  377. <i class="el-icon-warning"/>
  378. <span style="color: rgb(153, 169, 191)"> 多个首播电视台,请用英文逗号隔开</span>
  379. </el-form-item>
  380. <el-form-item label="网络播放平台" prop="networkEnable">
  381. <el-switch v-model="configDialog.form.networkEnable" active-color="#13ce66"/>
  382. </el-form-item>
  383. <el-form-item prop="network" v-if="configDialog.form.networkEnable">
  384. <el-input v-model="configDialog.form.network" clearable></el-input>
  385. <i class="el-icon-warning"/>
  386. <span style="color: rgb(153, 169, 191)"> 多个网络播放平台,请用英文逗号隔开</span>
  387. </el-form-item>
  388. <el-form-item label="制作单位" prop="unitEnable">
  389. <el-switch v-model="configDialog.form.unitEnable" active-color="#13ce66"/>
  390. </el-form-item>
  391. <el-form-item prop="unit" v-if="configDialog.form.unitEnable">
  392. <el-input v-model="configDialog.form.unit" clearable></el-input>
  393. <i class="el-icon-warning"/>
  394. <span style="color: rgb(153, 169, 191)"> 多个制作单位,请用英文逗号隔开</span>
  395. </el-form-item>
  396. <el-form-item label="专家顾问团队" prop="teamEnable">
  397. <el-switch v-model="configDialog.form.teamEnable" active-color="#13ce66"/>
  398. </el-form-item>
  399. <el-form-item prop="team" v-if="configDialog.form.teamEnable">
  400. <el-input v-model="configDialog.form.team" clearable></el-input>
  401. <i class="el-icon-warning"/>
  402. <span style="color: rgb(153, 169, 191)"> 多个专家顾问,请用英文逗号隔开</span>
  403. </el-form-item>
  404. <el-form-item label="支持单位" prop="supportEnable">
  405. <el-switch v-model="configDialog.form.supportEnable" active-color="#13ce66"/>
  406. </el-form-item>
  407. <el-form-item prop="support" v-if="configDialog.form.supportEnable">
  408. <el-input v-model="configDialog.form.support" clearable></el-input>
  409. <i class="el-icon-warning"/>
  410. <span style="color: rgb(153, 169, 191)"> 多个支持单位,请用英文逗号隔开</span>
  411. </el-form-item>
  412. </el-form>
  413. <div slot="footer" class="dialog-footer">
  414. <el-button type="primary"
  415. :loading="configDialog.updating"
  416. :disabled="configDialog.updating"
  417. @click="submitConfigForm">确 定</el-button>
  418. <el-button @click="cancelConfig">取 消</el-button>
  419. </div>
  420. </el-dialog>
  421. <el-drawer
  422. :with-header="false"
  423. size="75%"
  424. :title="show.title" :visible.sync="show.open" append-to-body>
  425. <userCourseCatalogDetails ref="userCourseCatalogDetails"/>
  426. </el-drawer>
  427. </div>
  428. </template>
  429. <script>
  430. import {
  431. listUserCourse,
  432. getUserCourse,
  433. delUserCourse,
  434. addUserCourse,
  435. updateUserCourse,
  436. exportUserCourse,
  437. updateIsShow,
  438. copyUserCourse,
  439. putOn,
  440. pullOff, updateUserCourseRedPage,
  441. editConfig
  442. } from '@/api/course/userCourse'
  443. import {getSelectableRange} from "@/api/qw/sopTemp";
  444. import Treeselect from "@riophae/vue-treeselect";
  445. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  446. import Editor from '@/components/Editor/wang';
  447. import ImageUpload from '@/components/ImageUpload/index';
  448. import {listBySearch} from "@/api/course/userTalent";
  449. import userCourseCatalogDetails from '../../components/course/userCourseCatalogDetails.vue';
  450. import {getAllCourseCategoryList, getCatePidList, getCateListByPid} from "@/api/course/userCourseCategory";
  451. import {allList} from "@/api/company/company";
  452. import VideoUpload from '@/components/VideoUpload/index.vue'
  453. import { getConfigByKey } from '@/api/system/config'
  454. export default {
  455. name: "UserCourse",
  456. components: {
  457. VideoUpload,
  458. Treeselect,
  459. Editor, ImageUpload, userCourseCatalogDetails
  460. },
  461. watch:{
  462. // 深度监听 rules 数组的变化,以更新总权重
  463. "openRedPage.rules": {
  464. handler(val) {
  465. // this.calculateTotalWeight();
  466. this.validateRules();
  467. },
  468. deep: true,
  469. },
  470. },
  471. data() {
  472. return {
  473. talentParam: {
  474. phone: null,
  475. talentId: null
  476. },
  477. talentList: [],
  478. startTimeRange: [],
  479. show: {
  480. title: "目录管理",
  481. open: false
  482. },
  483. activeName: "1",
  484. projectOptions: [],
  485. tagsOptions: [],
  486. tags: [],
  487. companyIds: [],
  488. courseTypeOptions: [],
  489. orOptions: [],
  490. specShowOptions: [],
  491. specTypeOptions: [],
  492. categoryOptions: [],
  493. subCategoryOptions: [],
  494. querySubCateOptions: [],
  495. // 遮罩层
  496. loading: true,
  497. // 导出遮罩层
  498. exportLoading: false,
  499. // 选中数组
  500. ids: [],
  501. // 非单个禁用
  502. single: true,
  503. // 非多个禁用
  504. multiple: true,
  505. // 显示搜索条件
  506. showSearch: true,
  507. // 总条数
  508. total: 0,
  509. // 课程表格数据
  510. userCourseList: [],
  511. companyOptions: [],
  512. // 弹出层标题
  513. title: "",
  514. // 是否显示弹出层
  515. open: false,
  516. openRedPage:{
  517. open:false,
  518. courseId:null,
  519. courseName:null,
  520. redPacketMoney:0.1,
  521. //随机红包配置
  522. rules:[
  523. {
  524. minAmount: 0.01,
  525. maxAmount: 0.01,
  526. weight: 100,
  527. }
  528. ]
  529. },
  530. // 查询参数
  531. queryParams: {
  532. pageNum: 1,
  533. pageSize: 10,
  534. cateId: null,
  535. subCateId: null,
  536. title: null,
  537. imgUrl: null,
  538. userId: null,
  539. sort: null,
  540. status: null,
  541. isVip: null,
  542. isHot: null,
  543. isShow: "1",
  544. views: null,
  545. duration: null,
  546. description: null,
  547. hotRanking: null,
  548. integral: null,
  549. price: null,
  550. isPrivate: 1,
  551. companyIdsList:[],
  552. },
  553. // 表单参数
  554. form: {},
  555. // 表单校验
  556. rules: {
  557. courseName: [
  558. {required: true, message: "课堂名称不能为空", trigger: "blur"}
  559. ],
  560. imgUrl: [
  561. {required: true, message: "封面图片不能为空", trigger: "blur"}
  562. ],
  563. isTui: [
  564. {required: true, message: "是否推荐不能为空", trigger: "blur"}
  565. ],
  566. isBest: [
  567. {required: true, message: "是否精选不能为空", trigger: "blur"}
  568. ],
  569. isFast: [
  570. {required: true, message: "是否允许快进不能为空", trigger: "blur"}
  571. ],
  572. isAutoPlay: [
  573. {required: true, message: "是否自动播放不能为空", trigger: "blur"}
  574. ],
  575. sort: [
  576. {required: true, message: "排序不能为空", trigger: "blur"}
  577. ],
  578. views: [
  579. {required: true, message: "播放量不能为空", trigger: "blur"}
  580. ],
  581. likes: [
  582. {required: true, message: "点赞数不能为空", trigger: "blur"}
  583. ],
  584. favoriteNum: [
  585. {required: true, message: "收藏数不能为空", trigger: "blur"}
  586. ],
  587. shares: [
  588. {required: true, message: "分享数不能为空", trigger: "blur"}
  589. ],
  590. isIntegral: [
  591. {required: true, message: "是否允许积分兑换不能为空", trigger: "blur"}
  592. ],
  593. isShow: [
  594. {required: true, message: "上架状态不能为空", trigger: "blur"}
  595. ],
  596. isPrivate: [
  597. {required: true, message: "公私域不能为空", trigger: "blur"}
  598. ],
  599. integral: [
  600. {required: true, message: "小节兑换积分不能为空", trigger: "blur"}
  601. ],
  602. },
  603. rulesRedPage:{
  604. redPacketMoney: [
  605. {required: true, message: "红包金额不能为空", trigger: "blur"}
  606. ],
  607. },
  608. configDialog: {
  609. dialogVisible: false,
  610. updating: false,
  611. form: {
  612. id: null,
  613. coverImg: null,
  614. tvEnable: 0,
  615. tv: null,
  616. networkEnable: 0,
  617. network: null,
  618. unitEnable: 0,
  619. unit: null,
  620. teamEnable: 0,
  621. team: null,
  622. supportEnable: 0,
  623. support: null
  624. },
  625. rules: {
  626. tv: [
  627. { required: true, message: '首播电视台不能为空', trigger: 'blur' }
  628. ],
  629. network: [
  630. { required: true, message: '网络播放平台不能为空', trigger: 'blur' }
  631. ],
  632. unit: [
  633. { required: true, message: '制作单位不能为空', trigger: 'blur' }
  634. ],
  635. team: [
  636. { required: true, message: '专家顾问团队不能为空', trigger: 'blur' }
  637. ],
  638. support: [
  639. { required: true, message: '支持单位不能为空', trigger: 'blur' }
  640. ],
  641. }
  642. },
  643. enableRandomRedPacket:false
  644. };
  645. },
  646. created() {
  647. this.getList();
  648. getConfigByKey('randomRedpacket:config').then(res=>{
  649. console.log("res::")
  650. console.log(res);
  651. let configData = res.data;
  652. if(!!configData && !!configData.configValue){
  653. let configValue = JSON.parse(configData.configValue);
  654. console.log(configValue);
  655. if(!!configValue.enableRandomRedpacket){
  656. this.enableRandomRedPacket = configValue.enableRandomRedpacket;
  657. }
  658. }
  659. }).catch(res=>{
  660. })
  661. getCatePidList().then(response => {
  662. this.categoryOptions = response.data;
  663. });
  664. getSelectableRange().then(e => {
  665. this.startTimeRange = e.data;
  666. })
  667. // this.getTreeselect();
  668. this.getDicts("sys_spec_show").then(response => {
  669. this.specShowOptions = response.data;
  670. });
  671. this.getDicts("sys_spec_type").then(response => {
  672. this.specTypeOptions = response.data;
  673. });
  674. this.getDicts("sys_course_type").then(response => {
  675. this.courseTypeOptions = response.data;
  676. });
  677. this.getDicts("sys_course_project").then(response => {
  678. this.projectOptions = response.data;
  679. });
  680. this.getDicts("sys_course_tags").then(response => {
  681. this.tagsOptions = response.data;
  682. });
  683. this.getDicts("sys_company_or").then(response => {
  684. this.orOptions = response.data;
  685. });
  686. allList().then(response => {
  687. this.companyOptions = response.rows;
  688. });
  689. },
  690. methods: {
  691. selectTalent() {
  692. },
  693. talentMethod(query) {
  694. if (query !== '') {
  695. this.talentParam.phone = query;
  696. listBySearch(this.talentParam).then(response => {
  697. this.talentList = response.data;
  698. });
  699. }
  700. },
  701. getSubCateList(pid) {
  702. this.form.subCateId = null;
  703. if (pid == '') {
  704. this.subCategoryOptions = [];
  705. return
  706. }
  707. getCateListByPid(pid).then(response => {
  708. this.subCategoryOptions = response.data;
  709. });
  710. },
  711. getQuerySubCateList(pid) {
  712. this.queryParams.subCateId = null;
  713. if (pid == '') {
  714. this.querySubCateOptions = [];
  715. return
  716. }
  717. this.queryParams.subCateId = null;
  718. getCateListByPid(pid).then(response => {
  719. this.querySubCateOptions = response.data;
  720. });
  721. },
  722. handleShow(row) {
  723. var isShowValue = row.isShow === 0 ? 1 : 0;
  724. var course = {courseId: row.courseId, isShow: isShowValue};
  725. updateIsShow(course).then(response => {
  726. this.msgSuccess("修改成功");
  727. this.getList();
  728. });
  729. },
  730. handleCatalog(row) {
  731. const courseId = row.courseId;
  732. this.show.open = true;
  733. setTimeout(() => {
  734. this.$refs.userCourseCatalogDetails.getDetails(courseId, row.courseName, row.isPrivate);
  735. }, 200);
  736. },
  737. /** 转换课堂分类数据结构 */
  738. normalizer(node) {
  739. if (node.children && !node.children.length) {
  740. delete node.children;
  741. }
  742. return {
  743. id: node.cateId,
  744. label: node.cateName,
  745. children: node.children
  746. };
  747. },
  748. getTreeselect() {
  749. getAllCourseCategoryList().then(response => {
  750. this.categoryOptions = [];
  751. const data = this.handleTree(response.data, "cateId", "pid");
  752. this.categoryOptions = data;
  753. });
  754. },
  755. /** 查询课程列表 */
  756. getList() {
  757. this.loading = true;
  758. listUserCourse(this.queryParams).then(response => {
  759. this.userCourseList = response.rows;
  760. this.total = response.total;
  761. this.loading = false;
  762. });
  763. },
  764. // 取消按钮
  765. cancel() {
  766. this.open = false;
  767. this.reset();
  768. },
  769. // 表单重置
  770. reset() {
  771. this.form = {
  772. courseId: null,
  773. cateId: null,
  774. subCateId: null,
  775. title: null,
  776. imgUrl: null,
  777. secondImg: null,
  778. userId: null,
  779. sort: null,
  780. createTime: null,
  781. updateTime: null,
  782. status: 0,
  783. isVip: null,
  784. isAutoPlay: "1",
  785. isIntegral: "0",
  786. isShow: "1",
  787. isFast: "1",
  788. isTui: "1",
  789. isBest: "1",
  790. isNext: "1",
  791. isPrivate: "1",
  792. views: 100000,
  793. duration: null,
  794. description: null,
  795. hotRanking: null,
  796. integral: null,
  797. price: null,
  798. likes: 100000,
  799. shares: 100000,
  800. favoriteNum: 100000,
  801. hotNum: 100000,
  802. };
  803. this.tags = [];
  804. this.subCategoryOptions = []
  805. this.companyIds = []
  806. this.resetForm("form");
  807. },
  808. /** 搜索按钮操作 */
  809. handleQuery() {
  810. this.queryParams.pageNum = 1;
  811. this.getList();
  812. },
  813. /** 重置按钮操作 */
  814. resetQuery() {
  815. this.resetForm("queryForm");
  816. this.queryParams.isShow = this.activeName
  817. this.handleQuery();
  818. },
  819. // 多选框选中数据
  820. handleSelectionChange(selection) {
  821. this.ids = selection.map(item => item.courseId)
  822. this.single = selection.length !== 1
  823. this.multiple = !selection.length
  824. },
  825. /** 新增按钮操作 */
  826. handleAdd() {
  827. this.reset();
  828. this.talentList = [];
  829. this.open = true;
  830. this.title = "添加课程";
  831. },
  832. /** 修改按钮操作 */
  833. handleUpdate(row) {
  834. this.reset();
  835. this.talentList = [];
  836. const courseId = row.courseId || this.ids
  837. getUserCourse(courseId).then(response => {
  838. this.form = response.data;
  839. // this.form.cateId = response.data.cateId.toString();
  840. if (this.form.cateId) {
  841. getCateListByPid(this.form.cateId).then(response => {
  842. this.subCategoryOptions = response.data;
  843. });
  844. }
  845. // this.form.courseType = response.data.courseType.toString();
  846. if (response.data.project != null) {
  847. this.form.project = response.data.project.toString();
  848. }
  849. if (response.data.tags != null) {
  850. this.tags = response.data.tags.split(",")
  851. }
  852. this.form.isAutoPlay = response.data.isAutoPlay.toString();
  853. this.form.isShow = response.data.isShow.toString();
  854. this.form.isBest = response.data.isBest.toString();
  855. this.form.isFast = response.data.isFast.toString();
  856. this.form.isIntegral = response.data.isIntegral.toString();
  857. this.form.isTui = response.data.isTui.toString();
  858. this.form.isNext = response.data.isNext.toString();
  859. this.form.isPrivate = response.data.isPrivate.toString();
  860. this.talentParam.talentId = response.data.talentId;
  861. if (this.form.companyIds != null) {
  862. this.companyIds = ((this.form.companyIds).split(",").map(Number))
  863. } else {
  864. this.companyIds = []
  865. }
  866. listBySearch(this.talentParam).then(response => {
  867. this.talentList = response.data;
  868. });
  869. this.open = true;
  870. this.title = "修改课程";
  871. });
  872. },
  873. handleUpdateRedPage(row){
  874. this.openRedPage.open=true;
  875. this.openRedPage.courseId=row.courseId;
  876. this.openRedPage.courseName=row.courseName;
  877. },
  878. /** 提交按钮 */
  879. submitForm() {
  880. this.$refs["form"].validate(valid => {
  881. if (valid) {
  882. this.form.companyIds = this.companyIds.toString()
  883. // 私域课程
  884. this.form.isPrivate = 1
  885. if (this.form.courseId != null) {
  886. updateUserCourse(this.form).then(response => {
  887. this.msgSuccess("修改成功");
  888. this.open = false;
  889. this.getList();
  890. });
  891. } else {
  892. addUserCourse(this.form).then(response => {
  893. this.msgSuccess("新增成功");
  894. this.open = false;
  895. this.getList();
  896. });
  897. }
  898. }
  899. });
  900. },
  901. submitFormRedPage(){
  902. const courseId = this.openRedPage.courseId;
  903. const redPacketMoney = this.openRedPage.redPacketMoney;
  904. let randomRedPacketRules = JSON.stringify( this.openRedPage.rules);
  905. console.log(randomRedPacketRules)
  906. this.$confirm('是否确认将课程id 为"' + courseId + '"的红包批量修改为:【'+redPacketMoney+'】?', "警告", {
  907. confirmButtonText: "确定",
  908. cancelButtonText: "取消",
  909. type: "warning"
  910. }).then(function () {
  911. return updateUserCourseRedPage({courseId:courseId,redPacketMoney:redPacketMoney,randomRedPacketRules:randomRedPacketRules});
  912. }).then(() => {
  913. this.getList();
  914. this.msgSuccess("修改成功");
  915. this.openRedPage.open=false;
  916. }).finally(() => {
  917. this.getList();
  918. this.openRedPage.open=false;
  919. });
  920. },
  921. cancelRedPage(){
  922. this.openRedPage.open=false;
  923. },
  924. /** 复制按钮操作 */
  925. handleCopy(row) {
  926. const courseId = row.courseId;
  927. this.$confirm('是否确认复制课程编号为"' + courseId + '"的数据项?', "警告", {
  928. confirmButtonText: "确定",
  929. cancelButtonText: "取消",
  930. type: "warning"
  931. }).then(function () {
  932. return copyUserCourse(courseId);
  933. }).then(() => {
  934. this.getList();
  935. this.msgSuccess("复制成功");
  936. }).catch(() => {
  937. });
  938. },
  939. /** 删除按钮操作 */
  940. handleDelete(row) {
  941. const courseIds = row.courseId || this.ids;
  942. this.$confirm('是否确认删除课程编号为"' + courseIds + '"的数据项?', "警告", {
  943. confirmButtonText: "确定",
  944. cancelButtonText: "取消",
  945. type: "warning"
  946. }).then(function () {
  947. return delUserCourse(courseIds);
  948. }).then(() => {
  949. this.getList();
  950. this.msgSuccess("删除成功");
  951. }).catch(() => {
  952. });
  953. },
  954. /** 导出按钮操作 */
  955. handleExport() {
  956. const queryParams = this.queryParams;
  957. this.$confirm('是否确认导出所有课程数据项?', "警告", {
  958. confirmButtonText: "确定",
  959. cancelButtonText: "取消",
  960. type: "warning"
  961. }).then(() => {
  962. this.exportLoading = true;
  963. return exportUserCourse(queryParams);
  964. }).then(response => {
  965. this.download(response.msg);
  966. this.exportLoading = false;
  967. }).catch(() => {
  968. });
  969. },
  970. putOn() {
  971. const courseIds = this.ids;
  972. if (courseIds == null || courseIds == "") {
  973. return this.$message("未选择课程");
  974. }
  975. this.$confirm('是否确认批量上架课程?', "警告", {
  976. confirmButtonText: "确定",
  977. cancelButtonText: "取消",
  978. type: "warning"
  979. }).then(function () {
  980. return putOn(courseIds);
  981. }).then(() => {
  982. this.getList();
  983. this.msgSuccess("上架成功");
  984. }).catch(function () {
  985. });
  986. },
  987. pullOff() {
  988. const courseIds = this.ids;
  989. if (courseIds == null || courseIds == "") {
  990. return this.$message("未选择课程");
  991. }
  992. this.$confirm('是否确认批量下架课程?', "警告", {
  993. confirmButtonText: "确定",
  994. cancelButtonText: "取消",
  995. type: "warning"
  996. }).then(function () {
  997. return pullOff(courseIds);
  998. }).then(() => {
  999. this.getList();
  1000. this.msgSuccess("下架成功");
  1001. }).catch(function () {
  1002. });
  1003. },
  1004. configCourse(row) {
  1005. if (row.configJson) {
  1006. this.configDialog.form = {
  1007. tvEnable: 0,
  1008. networkEnable: 0,
  1009. unitEnable: 0,
  1010. teamEnable: 0,
  1011. supportEnable: 0,
  1012. ...JSON.parse(row.configJson)
  1013. }
  1014. }
  1015. this.configDialog.form.id = row.courseId
  1016. this.configDialog.dialogVisible = true;
  1017. this.configDialog.updating = false
  1018. },
  1019. submitConfigForm() {
  1020. this.$refs['configForm'].validate(valid => {
  1021. if (!valid) {
  1022. this.msgError('请完善配置内容')
  1023. return
  1024. }
  1025. if (this.configDialog.updating) {
  1026. return
  1027. }
  1028. this.configDialog.updating = true
  1029. const content = {
  1030. coverImg: this.configDialog.form.coverImg,
  1031. tvEnable: this.configDialog.form.tvEnable,
  1032. tv: this.configDialog.form.tv?.replace(",",","),
  1033. networkEnable: this.configDialog.form.networkEnable,
  1034. network: this.configDialog.form.network?.replace(",",","),
  1035. unitEnable: this.configDialog.form.unitEnable,
  1036. unit: this.configDialog.form.unit?.replace(",",","),
  1037. teamEnable: this.configDialog.form.teamEnable,
  1038. team: this.configDialog.form.team?.replace(",",","),
  1039. supportEnable: this.configDialog.form.supportEnable,
  1040. support: this.configDialog.form.support?.replace(",",","),
  1041. }
  1042. const params = {
  1043. id: this.configDialog.form.id,
  1044. configJson: JSON.stringify(content)
  1045. }
  1046. editConfig(params).then(() => {
  1047. this.msgSuccess('修改成功')
  1048. this.configDialog.dialogVisible = false;
  1049. this.getList()
  1050. }).finally(() => {
  1051. setTimeout(() => {
  1052. this.configDialog.updating = false
  1053. }, 500)
  1054. })
  1055. })
  1056. },
  1057. cancelConfig() {
  1058. this.configDialog.form = {
  1059. id: null,
  1060. coverImg: null,
  1061. tvEnable: 0,
  1062. tv: null,
  1063. networkEnable: 0,
  1064. network: null,
  1065. unitEnable: 0,
  1066. unit: null,
  1067. teamEnable: 0,
  1068. team: null,
  1069. supportEnable: 0,
  1070. support: null
  1071. }
  1072. this.resetForm('configForm')
  1073. this.configDialog.dialogVisible = false;
  1074. },
  1075. // 实时过滤金额输入,只允许两位小数
  1076. handleAmountInput(rule, field) {
  1077. let value = rule[field];
  1078. if (value === null || value === undefined) return;
  1079. // 转换为字符串处理
  1080. let str = value.toString();
  1081. // 移除除数字和小数点外的所有字符
  1082. str = str.replace(/[^0-9.]/g, '');
  1083. // 只保留一个小数点
  1084. const dotIndex = str.indexOf('.');
  1085. if (dotIndex !== -1) {
  1086. str = str.substring(0, dotIndex + 1) + str.substring(dotIndex + 1).replace(/\./g, '');
  1087. }
  1088. // 限制小数点后最多两位
  1089. if (dotIndex !== -1 && str.length > dotIndex + 3) {
  1090. str = str.substring(0, dotIndex + 3);
  1091. }
  1092. // 转换回数字并更新
  1093. rule[field] = parseFloat(str) || 0;
  1094. },
  1095. deleteRule(index) {
  1096. this.$confirm("确定要删除这个区间吗?", "提示", {
  1097. confirmButtonText: "确定",
  1098. cancelButtonText: "取消",
  1099. type: "warning",
  1100. }).then(() => {
  1101. this.openRedPage.rules.splice(index, 1);
  1102. this.$message({
  1103. type: "success",
  1104. message: "删除成功!",
  1105. });
  1106. });
  1107. },
  1108. addRule(index) {
  1109. // 在当前行的后面插入一个新行
  1110. this.openRedPage.rules.splice(index + 1, 0, {
  1111. minAmount: 0.01,
  1112. maxAmount: 0.01,
  1113. weight: 100,
  1114. });
  1115. },
  1116. // 自定义校验规则:确保最大金额大于最小金额
  1117. validateMinAmount(rule, value, callback) {
  1118. // debugger;
  1119. // const maxAmount = this.form29.rules[].maxAmount
  1120. const index = rule.index;
  1121. const maxAmount = this.openRedPage.rules[index].maxAmount;
  1122. if (value > maxAmount) {
  1123. callback(new Error("最小金额不能大于最大金额"));
  1124. } else {
  1125. callback();
  1126. }
  1127. },
  1128. validateRules() {
  1129. this.openRedPage.rules.forEach((rule) => {
  1130. if (rule.minAmount === undefined || rule.minAmount < 0.01) {
  1131. rule.minAmount = 0.01;
  1132. }
  1133. if (rule.maxAmount === undefined || rule.maxAmount < rule.minAmount) {
  1134. rule.maxAmount = rule.minAmount;
  1135. }
  1136. if (rule.weight === undefined || rule.weight < 1) {
  1137. rule.weight = 1;
  1138. }
  1139. });
  1140. },
  1141. }
  1142. };
  1143. </script>