index.vue 42 KB

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