index.vue 32 KB

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