index.vue 39 KB

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