index.vue 39 KB

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