indexZM.vue 40 KB

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