index.vue 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195
  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-item label="监督投诉电话" prop="complaintPhone">
  423. <el-input v-model="configDialog.form.complaintPhone" placeholder="请输入监督投诉电话" clearable/>
  424. </el-form-item>
  425. </el-form>
  426. <div slot="footer" class="dialog-footer">
  427. <el-button type="primary"
  428. :loading="configDialog.updating"
  429. :disabled="configDialog.updating"
  430. @click="submitConfigForm">确 定</el-button>
  431. <el-button @click="cancelConfig">取 消</el-button>
  432. </div>
  433. </el-dialog>
  434. <el-drawer
  435. :with-header="false"
  436. size="75%"
  437. :title="show.title" :visible.sync="show.open" append-to-body>
  438. <userCourseCatalogDetails ref="userCourseCatalogDetails"/>
  439. </el-drawer>
  440. </div>
  441. </template>
  442. <script>
  443. import {
  444. listUserCourse,
  445. getUserCourse,
  446. delUserCourse,
  447. addUserCourse,
  448. updateUserCourse,
  449. exportUserCourse,
  450. updateIsShow,
  451. copyUserCourse,
  452. putOn,
  453. pullOff, updateUserCourseRedPage,
  454. editConfig
  455. } from '@/api/course/userCourse'
  456. import {getSelectableRange} from "@/api/qw/sopTemp";
  457. import Treeselect from "@riophae/vue-treeselect";
  458. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  459. import Editor from '@/components/Editor/wang';
  460. import ImageUpload from '@/components/ImageUpload/index';
  461. import {listBySearch} from "@/api/course/userTalent";
  462. import userCourseCatalogDetails from '../../components/course/userCourseCatalogDetails.vue';
  463. import {getAllCourseCategoryList, getCatePidList, getCateListByPid} from "@/api/course/userCourseCategory";
  464. import {allList} from "@/api/company/company";
  465. import VideoUpload from '@/components/VideoUpload/index.vue'
  466. import { getConfigByKey } from '@/api/system/config'
  467. export default {
  468. name: "UserCourse",
  469. components: {
  470. VideoUpload,
  471. Treeselect,
  472. Editor, ImageUpload, userCourseCatalogDetails
  473. },
  474. watch:{
  475. // 深度监听 rules 数组的变化,以更新总权重
  476. "openRedPage.rules": {
  477. handler(val) {
  478. // this.calculateTotalWeight();
  479. this.validateRules();
  480. },
  481. deep: true,
  482. },
  483. },
  484. data() {
  485. return {
  486. talentParam: {
  487. phone: null,
  488. talentId: null
  489. },
  490. talentList: [],
  491. startTimeRange: [],
  492. show: {
  493. title: "目录管理",
  494. open: false
  495. },
  496. activeName: "1",
  497. projectOptions: [],
  498. tagsOptions: [],
  499. tags: [],
  500. companyIds: [],
  501. courseTypeOptions: [],
  502. orOptions: [],
  503. specShowOptions: [],
  504. specTypeOptions: [],
  505. categoryOptions: [],
  506. subCategoryOptions: [],
  507. querySubCateOptions: [],
  508. // 遮罩层
  509. loading: true,
  510. // 导出遮罩层
  511. exportLoading: false,
  512. // 选中数组
  513. ids: [],
  514. // 非单个禁用
  515. single: true,
  516. // 非多个禁用
  517. multiple: true,
  518. // 显示搜索条件
  519. showSearch: true,
  520. // 总条数
  521. total: 0,
  522. // 课程表格数据
  523. userCourseList: [],
  524. companyOptions: [],
  525. // 弹出层标题
  526. title: "",
  527. // 是否显示弹出层
  528. open: false,
  529. openRedPage:{
  530. open:false,
  531. courseId:null,
  532. courseName:null,
  533. redPacketMoney:0.1,
  534. //随机红包配置
  535. rules:[
  536. {
  537. minAmount: 0.01,
  538. maxAmount: 0.01,
  539. weight: 100,
  540. }
  541. ]
  542. },
  543. // 查询参数
  544. queryParams: {
  545. pageNum: 1,
  546. pageSize: 10,
  547. cateId: null,
  548. subCateId: null,
  549. title: null,
  550. imgUrl: null,
  551. userId: null,
  552. sort: null,
  553. status: null,
  554. isVip: null,
  555. isHot: null,
  556. isShow: "1",
  557. views: null,
  558. duration: null,
  559. description: null,
  560. hotRanking: null,
  561. integral: null,
  562. price: null,
  563. courseId: null,
  564. isPrivate: 1,
  565. companyIdsList:[],
  566. },
  567. // 表单参数
  568. form: {},
  569. // 表单校验
  570. rules: {
  571. courseName: [
  572. {required: true, message: "课堂名称不能为空", trigger: "blur"}
  573. ],
  574. imgUrl: [
  575. {required: true, message: "封面图片不能为空", trigger: "blur"}
  576. ],
  577. isTui: [
  578. {required: true, message: "是否推荐不能为空", trigger: "blur"}
  579. ],
  580. isBest: [
  581. {required: true, message: "是否精选不能为空", trigger: "blur"}
  582. ],
  583. isFast: [
  584. {required: true, message: "是否允许快进不能为空", trigger: "blur"}
  585. ],
  586. isAutoPlay: [
  587. {required: true, message: "是否自动播放不能为空", trigger: "blur"}
  588. ],
  589. sort: [
  590. {required: true, message: "排序不能为空", trigger: "blur"}
  591. ],
  592. views: [
  593. {required: true, message: "播放量不能为空", trigger: "blur"}
  594. ],
  595. likes: [
  596. {required: true, message: "点赞数不能为空", trigger: "blur"}
  597. ],
  598. favoriteNum: [
  599. {required: true, message: "收藏数不能为空", trigger: "blur"}
  600. ],
  601. shares: [
  602. {required: true, message: "分享数不能为空", trigger: "blur"}
  603. ],
  604. isIntegral: [
  605. {required: true, message: "是否允许积分兑换不能为空", trigger: "blur"}
  606. ],
  607. isShow: [
  608. {required: true, message: "上架状态不能为空", trigger: "blur"}
  609. ],
  610. isPrivate: [
  611. {required: true, message: "公私域不能为空", trigger: "blur"}
  612. ],
  613. integral: [
  614. {required: true, message: "小节兑换积分不能为空", trigger: "blur"}
  615. ],
  616. },
  617. rulesRedPage:{
  618. redPacketMoney: [
  619. {required: true, message: "红包金额不能为空", trigger: "blur"}
  620. ],
  621. },
  622. configDialog: {
  623. dialogVisible: false,
  624. updating: false,
  625. form: {
  626. id: null,
  627. coverImg: null,
  628. tvEnable: 0,
  629. tv: null,
  630. networkEnable: 0,
  631. network: null,
  632. unitEnable: 0,
  633. unit: null,
  634. teamEnable: 0,
  635. team: null,
  636. supportEnable: 0,
  637. support: null,
  638. //监督投诉电话
  639. complaintPhone: null,
  640. },
  641. rules: {
  642. tv: [
  643. { required: true, message: '首播电视台不能为空', trigger: 'blur' }
  644. ],
  645. network: [
  646. { required: true, message: '网络播放平台不能为空', trigger: 'blur' }
  647. ],
  648. unit: [
  649. { required: true, message: '制作单位不能为空', trigger: 'blur' }
  650. ],
  651. team: [
  652. { required: true, message: '专家顾问团队不能为空', trigger: 'blur' }
  653. ],
  654. support: [
  655. { required: true, message: '支持单位不能为空', trigger: 'blur' }
  656. ],
  657. }
  658. },
  659. enableRandomRedPacket:false
  660. };
  661. },
  662. created() {
  663. this.getList();
  664. getConfigByKey('randomRedpacket:config').then(res=>{
  665. console.log("res::")
  666. console.log(res);
  667. let configData = res.data;
  668. if(!!configData && !!configData.configValue){
  669. let configValue = JSON.parse(configData.configValue);
  670. console.log(configValue);
  671. if(!!configValue.enableRandomRedpacket){
  672. this.enableRandomRedPacket = configValue.enableRandomRedpacket;
  673. }
  674. }
  675. }).catch(res=>{
  676. })
  677. getCatePidList().then(response => {
  678. this.categoryOptions = response.data;
  679. });
  680. getSelectableRange().then(e => {
  681. this.startTimeRange = e.data;
  682. })
  683. // this.getTreeselect();
  684. this.getDicts("sys_spec_show").then(response => {
  685. this.specShowOptions = response.data;
  686. });
  687. this.getDicts("sys_spec_type").then(response => {
  688. this.specTypeOptions = response.data;
  689. });
  690. this.getDicts("sys_course_type").then(response => {
  691. this.courseTypeOptions = response.data;
  692. });
  693. this.getDicts("sys_course_project").then(response => {
  694. this.projectOptions = response.data;
  695. });
  696. this.getDicts("sys_course_tags").then(response => {
  697. this.tagsOptions = response.data;
  698. });
  699. this.getDicts("sys_company_or").then(response => {
  700. this.orOptions = response.data;
  701. });
  702. allList().then(response => {
  703. this.companyOptions = response.rows;
  704. });
  705. },
  706. methods: {
  707. selectTalent() {
  708. },
  709. talentMethod(query) {
  710. if (query !== '') {
  711. this.talentParam.phone = query;
  712. listBySearch(this.talentParam).then(response => {
  713. this.talentList = response.data;
  714. });
  715. }
  716. },
  717. getSubCateList(pid) {
  718. this.form.subCateId = null;
  719. if (pid == '') {
  720. this.subCategoryOptions = [];
  721. return
  722. }
  723. getCateListByPid(pid).then(response => {
  724. this.subCategoryOptions = response.data;
  725. });
  726. },
  727. getQuerySubCateList(pid) {
  728. this.queryParams.subCateId = null;
  729. if (pid == '') {
  730. this.querySubCateOptions = [];
  731. return
  732. }
  733. this.queryParams.subCateId = null;
  734. getCateListByPid(pid).then(response => {
  735. this.querySubCateOptions = response.data;
  736. });
  737. },
  738. handleShow(row) {
  739. var isShowValue = row.isShow === 0 ? 1 : 0;
  740. var course = {courseId: row.courseId, isShow: isShowValue};
  741. updateIsShow(course).then(response => {
  742. this.msgSuccess("修改成功");
  743. this.getList();
  744. });
  745. },
  746. handleCatalog(row) {
  747. const courseId = row.courseId;
  748. this.show.open = true;
  749. setTimeout(() => {
  750. this.$refs.userCourseCatalogDetails.getDetails(courseId, row.courseName, row.isPrivate);
  751. }, 200);
  752. },
  753. /** 转换课堂分类数据结构 */
  754. normalizer(node) {
  755. if (node.children && !node.children.length) {
  756. delete node.children;
  757. }
  758. return {
  759. id: node.cateId,
  760. label: node.cateName,
  761. children: node.children
  762. };
  763. },
  764. getTreeselect() {
  765. getAllCourseCategoryList().then(response => {
  766. this.categoryOptions = [];
  767. const data = this.handleTree(response.data, "cateId", "pid");
  768. this.categoryOptions = data;
  769. });
  770. },
  771. /** 查询课程列表 */
  772. getList() {
  773. this.loading = true;
  774. listUserCourse(this.queryParams).then(response => {
  775. this.userCourseList = response.rows;
  776. this.total = response.total;
  777. this.loading = false;
  778. });
  779. },
  780. // 取消按钮
  781. cancel() {
  782. this.open = false;
  783. this.reset();
  784. },
  785. // 表单重置
  786. reset() {
  787. this.form = {
  788. courseId: null,
  789. cateId: null,
  790. subCateId: null,
  791. title: null,
  792. imgUrl: null,
  793. secondImg: null,
  794. userId: null,
  795. sort: null,
  796. createTime: null,
  797. updateTime: null,
  798. status: 0,
  799. isVip: null,
  800. isAutoPlay: "1",
  801. isIntegral: "0",
  802. isShow: "1",
  803. isFast: "1",
  804. isTui: "1",
  805. isBest: "1",
  806. isNext: "1",
  807. isPrivate: "1",
  808. views: 100000,
  809. duration: null,
  810. description: null,
  811. hotRanking: null,
  812. integral: null,
  813. price: null,
  814. likes: 100000,
  815. shares: 100000,
  816. favoriteNum: 100000,
  817. hotNum: 100000,
  818. };
  819. this.tags = [];
  820. this.subCategoryOptions = []
  821. this.companyIds = []
  822. this.resetForm("form");
  823. },
  824. /** 搜索按钮操作 */
  825. handleQuery() {
  826. this.queryParams.pageNum = 1;
  827. this.getList();
  828. },
  829. /** 重置按钮操作 */
  830. resetQuery() {
  831. this.resetForm("queryForm");
  832. this.queryParams.companyIdsList = [];
  833. this.queryParams.isShow = this.activeName
  834. this.handleQuery();
  835. },
  836. // 多选框选中数据
  837. handleSelectionChange(selection) {
  838. this.ids = selection.map(item => item.courseId)
  839. this.single = selection.length !== 1
  840. this.multiple = !selection.length
  841. },
  842. /** 新增按钮操作 */
  843. handleAdd() {
  844. this.reset();
  845. this.talentList = [];
  846. this.open = true;
  847. this.title = "添加课程";
  848. },
  849. /** 修改按钮操作 */
  850. handleUpdate(row) {
  851. this.reset();
  852. this.talentList = [];
  853. const courseId = row.courseId || this.ids
  854. getUserCourse(courseId).then(response => {
  855. this.form = response.data;
  856. // this.form.cateId = response.data.cateId.toString();
  857. if (this.form.cateId) {
  858. getCateListByPid(this.form.cateId).then(response => {
  859. this.subCategoryOptions = response.data;
  860. });
  861. }
  862. // this.form.courseType = response.data.courseType.toString();
  863. if (response.data.project != null) {
  864. this.form.project = response.data.project.toString();
  865. }
  866. if (response.data.tags != null) {
  867. this.tags = response.data.tags.split(",")
  868. }
  869. this.form.isAutoPlay = response.data.isAutoPlay.toString();
  870. this.form.isShow = response.data.isShow.toString();
  871. this.form.isBest = response.data.isBest.toString();
  872. this.form.isFast = response.data.isFast.toString();
  873. this.form.isIntegral = response.data.isIntegral.toString();
  874. this.form.isTui = response.data.isTui.toString();
  875. this.form.isNext = response.data.isNext.toString();
  876. this.form.isPrivate = response.data.isPrivate.toString();
  877. this.talentParam.talentId = response.data.talentId;
  878. if (this.form.companyIds != null) {
  879. this.companyIds = ((this.form.companyIds).split(",").map(Number))
  880. } else {
  881. this.companyIds = []
  882. }
  883. listBySearch(this.talentParam).then(response => {
  884. this.talentList = response.data;
  885. });
  886. this.open = true;
  887. this.title = "修改课程";
  888. });
  889. },
  890. handleUpdateRedPage(row){
  891. this.openRedPage.open=true;
  892. this.openRedPage.courseId=row.courseId;
  893. this.openRedPage.courseName=row.courseName;
  894. },
  895. /** 提交按钮 */
  896. submitForm() {
  897. this.$refs["form"].validate(valid => {
  898. if (valid) {
  899. this.form.companyIds = this.companyIds.toString()
  900. // 私域课程
  901. this.form.isPrivate = 1
  902. if (this.form.courseId != null) {
  903. updateUserCourse(this.form).then(response => {
  904. this.msgSuccess("修改成功");
  905. this.open = false;
  906. this.getList();
  907. });
  908. } else {
  909. addUserCourse(this.form).then(response => {
  910. this.msgSuccess("新增成功");
  911. this.open = false;
  912. this.getList();
  913. });
  914. }
  915. }
  916. });
  917. },
  918. submitFormRedPage(){
  919. const courseId = this.openRedPage.courseId;
  920. const redPacketMoney = this.openRedPage.redPacketMoney;
  921. let randomRedPacketRules = JSON.stringify( this.openRedPage.rules);
  922. console.log(randomRedPacketRules)
  923. this.$confirm('是否确认将课程id 为"' + courseId + '"的红包批量修改为:【'+redPacketMoney+'】?', "警告", {
  924. confirmButtonText: "确定",
  925. cancelButtonText: "取消",
  926. type: "warning"
  927. }).then(function () {
  928. return updateUserCourseRedPage({courseId:courseId,redPacketMoney:redPacketMoney,randomRedPacketRules:randomRedPacketRules});
  929. }).then(() => {
  930. this.getList();
  931. this.msgSuccess("修改成功");
  932. this.openRedPage.open=false;
  933. }).finally(() => {
  934. this.getList();
  935. this.openRedPage.open=false;
  936. });
  937. },
  938. cancelRedPage(){
  939. this.openRedPage.open=false;
  940. },
  941. /** 复制按钮操作 */
  942. handleCopy(row) {
  943. const courseId = row.courseId;
  944. this.$confirm('是否确认复制课程编号为"' + courseId + '"的数据项?', "警告", {
  945. confirmButtonText: "确定",
  946. cancelButtonText: "取消",
  947. type: "warning"
  948. }).then(function () {
  949. return copyUserCourse(courseId);
  950. }).then(() => {
  951. this.getList();
  952. this.msgSuccess("复制成功");
  953. }).catch(() => {
  954. });
  955. },
  956. /** 删除按钮操作 */
  957. handleDelete(row) {
  958. const courseIds = row.courseId || this.ids;
  959. this.$confirm('是否确认删除课程编号为"' + courseIds + '"的数据项?', "警告", {
  960. confirmButtonText: "确定",
  961. cancelButtonText: "取消",
  962. type: "warning"
  963. }).then(function () {
  964. return delUserCourse(courseIds);
  965. }).then(() => {
  966. this.getList();
  967. this.msgSuccess("删除成功");
  968. }).catch(() => {
  969. });
  970. },
  971. /** 导出按钮操作 */
  972. handleExport() {
  973. const queryParams = this.queryParams;
  974. this.$confirm('是否确认导出所有课程数据项?', "警告", {
  975. confirmButtonText: "确定",
  976. cancelButtonText: "取消",
  977. type: "warning"
  978. }).then(() => {
  979. this.exportLoading = true;
  980. return exportUserCourse(queryParams);
  981. }).then(response => {
  982. this.download(response.msg);
  983. this.exportLoading = false;
  984. }).catch(() => {
  985. });
  986. },
  987. putOn() {
  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 putOn(courseIds);
  998. }).then(() => {
  999. this.getList();
  1000. this.msgSuccess("上架成功");
  1001. }).catch(function () {
  1002. });
  1003. },
  1004. pullOff() {
  1005. const courseIds = this.ids;
  1006. if (courseIds == null || courseIds == "") {
  1007. return this.$message("未选择课程");
  1008. }
  1009. this.$confirm('是否确认批量下架课程?', "警告", {
  1010. confirmButtonText: "确定",
  1011. cancelButtonText: "取消",
  1012. type: "warning"
  1013. }).then(function () {
  1014. return pullOff(courseIds);
  1015. }).then(() => {
  1016. this.getList();
  1017. this.msgSuccess("下架成功");
  1018. }).catch(function () {
  1019. });
  1020. },
  1021. configCourse(row) {
  1022. if (row.configJson) {
  1023. this.configDialog.form = {
  1024. tvEnable: 0,
  1025. networkEnable: 0,
  1026. unitEnable: 0,
  1027. teamEnable: 0,
  1028. supportEnable: 0,
  1029. ...JSON.parse(row.configJson)
  1030. }
  1031. }
  1032. this.configDialog.form.id = row.courseId
  1033. this.configDialog.dialogVisible = true;
  1034. this.configDialog.updating = false
  1035. },
  1036. submitConfigForm() {
  1037. this.$refs['configForm'].validate(valid => {
  1038. if (!valid) {
  1039. this.msgError('请完善配置内容')
  1040. return
  1041. }
  1042. if (this.configDialog.updating) {
  1043. return
  1044. }
  1045. this.configDialog.updating = true
  1046. const content = {
  1047. coverImg: this.configDialog.form.coverImg,
  1048. tvEnable: this.configDialog.form.tvEnable,
  1049. tv: this.configDialog.form.tv?.replace(",",","),
  1050. networkEnable: this.configDialog.form.networkEnable,
  1051. network: this.configDialog.form.network?.replace(",",","),
  1052. unitEnable: this.configDialog.form.unitEnable,
  1053. unit: this.configDialog.form.unit?.replace(",",","),
  1054. teamEnable: this.configDialog.form.teamEnable,
  1055. team: this.configDialog.form.team?.replace(",",","),
  1056. supportEnable: this.configDialog.form.supportEnable,
  1057. support: this.configDialog.form.support?.replace(",",","),
  1058. }
  1059. const params = {
  1060. id: this.configDialog.form.id,
  1061. configJson: JSON.stringify(content)
  1062. }
  1063. editConfig(params).then(() => {
  1064. this.msgSuccess('修改成功')
  1065. this.configDialog.dialogVisible = false;
  1066. this.getList()
  1067. }).finally(() => {
  1068. setTimeout(() => {
  1069. this.configDialog.updating = false
  1070. }, 500)
  1071. })
  1072. })
  1073. },
  1074. cancelConfig() {
  1075. this.configDialog.form = {
  1076. id: null,
  1077. coverImg: null,
  1078. tvEnable: 0,
  1079. tv: null,
  1080. networkEnable: 0,
  1081. network: null,
  1082. unitEnable: 0,
  1083. unit: null,
  1084. teamEnable: 0,
  1085. team: null,
  1086. supportEnable: 0,
  1087. support: null
  1088. }
  1089. this.resetForm('configForm')
  1090. this.configDialog.dialogVisible = false;
  1091. },
  1092. // 实时过滤金额输入,只允许两位小数
  1093. handleAmountInput(rule, field) {
  1094. let value = rule[field];
  1095. if (value === null || value === undefined) return;
  1096. // 转换为字符串处理
  1097. let str = value.toString();
  1098. // 移除除数字和小数点外的所有字符
  1099. str = str.replace(/[^0-9.]/g, '');
  1100. // 只保留一个小数点
  1101. const dotIndex = str.indexOf('.');
  1102. if (dotIndex !== -1) {
  1103. str = str.substring(0, dotIndex + 1) + str.substring(dotIndex + 1).replace(/\./g, '');
  1104. }
  1105. // 限制小数点后最多两位
  1106. if (dotIndex !== -1 && str.length > dotIndex + 3) {
  1107. str = str.substring(0, dotIndex + 3);
  1108. }
  1109. // 转换回数字并更新
  1110. rule[field] = parseFloat(str) || 0;
  1111. },
  1112. deleteRule(index) {
  1113. this.$confirm("确定要删除这个区间吗?", "提示", {
  1114. confirmButtonText: "确定",
  1115. cancelButtonText: "取消",
  1116. type: "warning",
  1117. }).then(() => {
  1118. this.openRedPage.rules.splice(index, 1);
  1119. this.$message({
  1120. type: "success",
  1121. message: "删除成功!",
  1122. });
  1123. });
  1124. },
  1125. addRule(index) {
  1126. // 在当前行的后面插入一个新行
  1127. this.openRedPage.rules.splice(index + 1, 0, {
  1128. minAmount: 0.01,
  1129. maxAmount: 0.01,
  1130. weight: 100,
  1131. });
  1132. },
  1133. // 自定义校验规则:确保最大金额大于最小金额
  1134. validateMinAmount(rule, value, callback) {
  1135. // debugger;
  1136. // const maxAmount = this.form29.rules[].maxAmount
  1137. const index = rule.index;
  1138. const maxAmount = this.openRedPage.rules[index].maxAmount;
  1139. if (value > maxAmount) {
  1140. callback(new Error("最小金额不能大于最大金额"));
  1141. } else {
  1142. callback();
  1143. }
  1144. },
  1145. validateRules() {
  1146. this.openRedPage.rules.forEach((rule) => {
  1147. if (rule.minAmount === undefined || rule.minAmount < 0.01) {
  1148. rule.minAmount = 0.01;
  1149. }
  1150. if (rule.maxAmount === undefined || rule.maxAmount < rule.minAmount) {
  1151. rule.maxAmount = rule.minAmount;
  1152. }
  1153. if (rule.weight === undefined || rule.weight < 1) {
  1154. rule.weight = 1;
  1155. }
  1156. });
  1157. },
  1158. }
  1159. };
  1160. </script>