index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696
  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="isPrivate" style="display: none">
  35. <el-select v-model="queryParams.isPrivate" placeholder="请选择" clearable size="small">
  36. <el-option
  37. v-for="dict in courseTypeOptions"
  38. :key="dict.dictValue"
  39. :label="dict.dictLabel"
  40. :value="dict.dictValue"
  41. />
  42. </el-select>
  43. </el-form-item>
  44. <el-form-item>
  45. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  46. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  47. </el-form-item>
  48. </el-form>
  49. <el-row :gutter="10" class="mb8">
  50. <el-col :span="1.5">
  51. <el-button
  52. type="primary"
  53. plain
  54. icon="el-icon-plus"
  55. size="mini"
  56. @click="handleAdd"
  57. v-hasPermi="['course:userCourse:add']"
  58. >新增
  59. </el-button>
  60. </el-col>
  61. <el-col :span="1.5">
  62. <el-button
  63. type="success"
  64. plain
  65. icon="el-icon-edit"
  66. size="mini"
  67. :disabled="single"
  68. @click="handleUpdate"
  69. v-hasPermi="['course:userCourse:edit']"
  70. >修改
  71. </el-button>
  72. </el-col>
  73. <el-col :span="1.5">
  74. <el-button
  75. type="danger"
  76. plain
  77. icon="el-icon-delete"
  78. size="mini"
  79. :disabled="multiple"
  80. @click="handleDelete"
  81. v-hasPermi="['course:userCourse:remove']"
  82. >删除
  83. </el-button>
  84. </el-col>
  85. <el-col :span="1.5">
  86. <el-button
  87. type="warning"
  88. plain
  89. icon="el-icon-download"
  90. size="mini"
  91. :loading="exportLoading"
  92. @click="handleExport"
  93. v-hasPermi="['course:userCourse:export']"
  94. >导出
  95. </el-button>
  96. </el-col>
  97. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  98. </el-row>
  99. <el-table height="600" border v-loading="loading" :data="userCourseList" @selection-change="handleSelectionChange">
  100. <el-table-column type="selection" width="55" align="center"/>
  101. <el-table-column label="课程ID" align="center" prop="courseId"/>
  102. <el-table-column label="所属项目" align="center" prop="projectName"/>
  103. <el-table-column label="封面图片" align="center" prop="imgUrl" width="120">
  104. <template slot-scope="scope">
  105. <el-popover
  106. placement="right"
  107. title=""
  108. trigger="hover"
  109. >
  110. <img slot="reference" :src="scope.row.imgUrl" width="100">
  111. <img :src="scope.row.imgUrl" style="max-width: 300px;">
  112. </el-popover>
  113. </template>
  114. </el-table-column>
  115. <el-table-column label="课堂名称" align="center" show-overflow-tooltip prop="courseName"/>
  116. <el-table-column label="排序" align="center" prop="sort"/>
  117. <el-table-column label="分类名称" align="center" prop="cateName"/>
  118. <el-table-column label="子分类名称" align="center" prop="subCateName"/>
  119. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  120. <template slot-scope="scope">
  121. <el-button
  122. size="mini"
  123. type="text"
  124. @click="handleCatalog(scope.row)"
  125. >目录管理
  126. </el-button>
  127. <el-button
  128. size="mini"
  129. type="text"
  130. icon="el-icon-edit"
  131. @click="handleUpdate(scope.row)"
  132. v-hasPermi="['course:userCourse:edit']"
  133. >修改
  134. </el-button>
  135. <el-button
  136. size="mini"
  137. type="text"
  138. icon="el-icon-delete"
  139. @click="handleDelete(scope.row)"
  140. v-hasPermi="['course:userCourse:remove']"
  141. >删除
  142. </el-button>
  143. </template>
  144. </el-table-column>
  145. </el-table>
  146. <pagination
  147. v-show="total>0"
  148. :total="total"
  149. :page.sync="queryParams.pageNum"
  150. :limit.sync="queryParams.pageSize"
  151. @pagination="getList"
  152. />
  153. <!-- 添加或修改课程对话框 -->
  154. <el-dialog :title="title" :visible.sync="open" width="1200px" append-to-body>
  155. <el-form ref="form" :model="form" :rules="rules" label-width="110px">
  156. <el-row>
  157. <el-form-item label="所属项目" prop="project">
  158. <el-select v-model="form.project" placeholder="请选择项目" filterable clearable size="small">
  159. <el-option
  160. v-for="dict in projectOptions"
  161. :key="dict.dictValue"
  162. :label="dict.dictLabel"
  163. :value="dict.dictValue"
  164. />
  165. </el-select>
  166. </el-form-item>
  167. </el-row>
  168. <el-row>
  169. <el-col :span="8">
  170. <el-form-item label="课堂名称" prop="courseName">
  171. <el-input v-model="form.courseName" placeholder="请输入课堂名称"/>
  172. </el-form-item>
  173. </el-col>
  174. <el-col :span="8">
  175. <el-form-item label="课堂分类" prop="cateId">
  176. <el-select v-model="form.cateId" placeholder="请选择" clearable size="small"
  177. @change="getSubCateList(form.cateId)">
  178. <el-option
  179. v-for="dict in categoryOptions"
  180. :key="dict.dictValue"
  181. :label="dict.dictLabel"
  182. :value="dict.dictValue"
  183. />
  184. </el-select>
  185. </el-form-item>
  186. </el-col>
  187. <el-col :span="8">
  188. <el-form-item label="课堂子分类" prop="subCateId">
  189. <el-select v-model="form.subCateId" placeholder="请选择" clearable size="small">
  190. <el-option
  191. v-for="dict in subCategoryOptions"
  192. :key="dict.dictValue"
  193. :label="dict.dictLabel"
  194. :value="dict.dictValue"
  195. />
  196. </el-select>
  197. </el-form-item>
  198. </el-col>
  199. </el-row>
  200. <el-row>
  201. <el-col :span="24">
  202. <el-form-item label="课堂简介" prop="description">
  203. <el-input v-model="form.description" type="textarea" :rows="2" placeholder="请输入课堂简介"/>
  204. </el-form-item>
  205. </el-col>
  206. </el-row>
  207. <el-form-item label="课程封面" prop="imgUrl">
  208. <ImageUpload v-model="form.imgUrl" type="image" :num="10" :width="150" :height="150"/>
  209. </el-form-item>
  210. <el-form-item label="关联公司" prop="tags">
  211. <el-select v-model="companyIds" multiple placeholder="请选择公司" filterable clearable style="width: 90%;">
  212. <el-option
  213. v-for="dict in companyOptions"
  214. :key="dict.dictValue"
  215. :label="dict.dictLabel"
  216. :value="dict.dictValue"
  217. />
  218. </el-select>
  219. </el-form-item>
  220. </el-form>
  221. <div slot="footer" class="dialog-footer">
  222. <el-button type="primary" @click="submitForm">确 定</el-button>
  223. <el-button @click="cancel">取 消</el-button>
  224. </div>
  225. </el-dialog>
  226. <el-drawer
  227. :with-header="false"
  228. size="75%"
  229. :title="show.title" :visible.sync="show.open" append-to-body>
  230. <userCourseCatalogDetails ref="userCourseCatalogDetails"/>
  231. </el-drawer>
  232. </div>
  233. </template>
  234. <script>
  235. import {
  236. listUserCourse,
  237. getUserCourse,
  238. delUserCourse,
  239. addUserCourse,
  240. updateUserCourse,
  241. exportUserCourse,
  242. updateIsShow,
  243. putOn,
  244. pullOff
  245. } from "@/api/course/userCourse";
  246. import {getSelectableRange} from "@/api/qw/sopTemp";
  247. import Treeselect from "@riophae/vue-treeselect";
  248. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  249. import Editor from '@/components/Editor/wang';
  250. import ImageUpload from '@/components/ImageUpload/index';
  251. import {listBySearch} from "@/api/course/userTalent";
  252. import userCourseCatalogDetails from '../../components/course/userCourseCatalogDetails.vue';
  253. import {getAllCourseCategoryList, getCatePidList, getCateListByPid} from "@/api/course/userCourseCategory";
  254. import {allList} from "@/api/company/company";
  255. export default {
  256. name: "UserCourse",
  257. components: {
  258. Treeselect,
  259. Editor, ImageUpload, userCourseCatalogDetails
  260. },
  261. data() {
  262. return {
  263. talentParam: {
  264. phone: null,
  265. talentId: null
  266. },
  267. talentList: [],
  268. startTimeRange: [],
  269. show: {
  270. title: "目录管理",
  271. open: false
  272. },
  273. activeName: "1",
  274. projectOptions: [],
  275. tagsOptions: [],
  276. tags: [],
  277. companyIds: [],
  278. courseTypeOptions: [],
  279. orOptions: [],
  280. specShowOptions: [],
  281. specTypeOptions: [],
  282. categoryOptions: [],
  283. subCategoryOptions: [],
  284. querySubCateOptions: [],
  285. // 遮罩层
  286. loading: true,
  287. // 导出遮罩层
  288. exportLoading: false,
  289. // 选中数组
  290. ids: [],
  291. // 非单个禁用
  292. single: true,
  293. // 非多个禁用
  294. multiple: true,
  295. // 显示搜索条件
  296. showSearch: true,
  297. // 总条数
  298. total: 0,
  299. // 课程表格数据
  300. userCourseList: [],
  301. companyOptions: [],
  302. // 弹出层标题
  303. title: "",
  304. // 是否显示弹出层
  305. open: false,
  306. // 查询参数
  307. queryParams: {
  308. pageNum: 1,
  309. pageSize: 10,
  310. cateId: null,
  311. subCateId: null,
  312. title: null,
  313. imgUrl: null,
  314. userId: null,
  315. sort: null,
  316. status: null,
  317. isVip: null,
  318. isHot: null,
  319. isShow: "1",
  320. views: null,
  321. duration: null,
  322. description: null,
  323. hotRanking: null,
  324. integral: null,
  325. price: null,
  326. isPrivate: 1
  327. },
  328. // 表单参数
  329. form: {},
  330. // 表单校验
  331. rules: {
  332. courseName: [
  333. {required: true, message: "课堂名称不能为空", trigger: "blur"}
  334. ],
  335. imgUrl: [
  336. {required: true, message: "封面图片不能为空", trigger: "blur"}
  337. ],
  338. isTui: [
  339. {required: true, message: "是否推荐不能为空", trigger: "blur"}
  340. ],
  341. isBest: [
  342. {required: true, message: "是否精选不能为空", trigger: "blur"}
  343. ],
  344. isFast: [
  345. {required: true, message: "是否允许快进不能为空", trigger: "blur"}
  346. ],
  347. isAutoPlay: [
  348. {required: true, message: "是否自动播放不能为空", trigger: "blur"}
  349. ],
  350. sort: [
  351. {required: true, message: "排序不能为空", trigger: "blur"}
  352. ],
  353. views: [
  354. {required: true, message: "播放量不能为空", trigger: "blur"}
  355. ],
  356. likes: [
  357. {required: true, message: "点赞数不能为空", trigger: "blur"}
  358. ],
  359. favoriteNum: [
  360. {required: true, message: "收藏数不能为空", trigger: "blur"}
  361. ],
  362. shares: [
  363. {required: true, message: "分享数不能为空", trigger: "blur"}
  364. ],
  365. isIntegral: [
  366. {required: true, message: "是否允许积分兑换不能为空", trigger: "blur"}
  367. ],
  368. isShow: [
  369. {required: true, message: "上架状态不能为空", trigger: "blur"}
  370. ],
  371. isPrivate: [
  372. {required: true, message: "公私域不能为空", trigger: "blur"}
  373. ],
  374. integral: [
  375. {required: true, message: "小节兑换积分不能为空", trigger: "blur"}
  376. ],
  377. }
  378. };
  379. },
  380. created() {
  381. this.getList();
  382. getCatePidList().then(response => {
  383. this.categoryOptions = response.data;
  384. });
  385. getSelectableRange().then(e => {
  386. this.startTimeRange = e.data;
  387. })
  388. // this.getTreeselect();
  389. this.getDicts("sys_spec_show").then(response => {
  390. this.specShowOptions = response.data;
  391. });
  392. this.getDicts("sys_spec_type").then(response => {
  393. this.specTypeOptions = response.data;
  394. });
  395. this.getDicts("sys_course_type").then(response => {
  396. this.courseTypeOptions = response.data;
  397. });
  398. this.getDicts("sys_course_project").then(response => {
  399. this.projectOptions = response.data;
  400. });
  401. this.getDicts("sys_course_tags").then(response => {
  402. this.tagsOptions = response.data;
  403. });
  404. this.getDicts("sys_company_or").then(response => {
  405. this.orOptions = response.data;
  406. });
  407. allList().then(response => {
  408. this.companyOptions = response.rows;
  409. });
  410. },
  411. methods: {
  412. selectTalent() {
  413. },
  414. talentMethod(query) {
  415. if (query !== '') {
  416. this.talentParam.phone = query;
  417. listBySearch(this.talentParam).then(response => {
  418. this.talentList = response.data;
  419. });
  420. }
  421. },
  422. getSubCateList(pid) {
  423. this.form.subCateId = null;
  424. if (pid == '') {
  425. this.subCategoryOptions = [];
  426. return
  427. }
  428. getCateListByPid(pid).then(response => {
  429. this.subCategoryOptions = response.data;
  430. });
  431. },
  432. getQuerySubCateList(pid) {
  433. this.queryParams.subCateId = null;
  434. if (pid == '') {
  435. this.querySubCateOptions = [];
  436. return
  437. }
  438. this.queryParams.subCateId = null;
  439. getCateListByPid(pid).then(response => {
  440. this.querySubCateOptions = response.data;
  441. });
  442. },
  443. handleShow(row) {
  444. var isShowValue = row.isShow === 0 ? 1 : 0;
  445. var course = {courseId: row.courseId, isShow: isShowValue};
  446. updateIsShow(course).then(response => {
  447. this.msgSuccess("修改成功");
  448. this.getList();
  449. });
  450. },
  451. handleCatalog(row) {
  452. const courseId = row.courseId;
  453. this.show.open = true;
  454. setTimeout(() => {
  455. this.$refs.userCourseCatalogDetails.getDetails(courseId, row.courseName, row.isPrivate);
  456. }, 200);
  457. },
  458. /** 转换课堂分类数据结构 */
  459. normalizer(node) {
  460. if (node.children && !node.children.length) {
  461. delete node.children;
  462. }
  463. return {
  464. id: node.cateId,
  465. label: node.cateName,
  466. children: node.children
  467. };
  468. },
  469. getTreeselect() {
  470. getAllCourseCategoryList().then(response => {
  471. this.categoryOptions = [];
  472. const data = this.handleTree(response.data, "cateId", "pid");
  473. this.categoryOptions = data;
  474. });
  475. },
  476. /** 查询课程列表 */
  477. getList() {
  478. this.loading = true;
  479. listUserCourse(this.queryParams).then(response => {
  480. this.userCourseList = response.rows;
  481. this.total = response.total;
  482. this.loading = false;
  483. });
  484. },
  485. // 取消按钮
  486. cancel() {
  487. this.open = false;
  488. this.reset();
  489. },
  490. // 表单重置
  491. reset() {
  492. this.form = {
  493. courseId: null,
  494. cateId: null,
  495. subCateId: null,
  496. title: null,
  497. imgUrl: null,
  498. secondImg: null,
  499. userId: null,
  500. sort: null,
  501. createTime: null,
  502. updateTime: null,
  503. status: 0,
  504. isVip: null,
  505. isAutoPlay: "1",
  506. isIntegral: "0",
  507. isShow: "1",
  508. isFast: "1",
  509. isTui: "1",
  510. isBest: "1",
  511. isNext: "1",
  512. isPrivate: "1",
  513. views: 100000,
  514. duration: null,
  515. description: null,
  516. hotRanking: null,
  517. integral: null,
  518. price: null,
  519. likes: 100000,
  520. shares: 100000,
  521. favoriteNum: 100000,
  522. hotNum: 100000,
  523. };
  524. this.tags = [];
  525. this.subCategoryOptions = []
  526. this.companyIds = []
  527. this.resetForm("form");
  528. },
  529. /** 搜索按钮操作 */
  530. handleQuery() {
  531. this.queryParams.pageNum = 1;
  532. this.getList();
  533. },
  534. /** 重置按钮操作 */
  535. resetQuery() {
  536. this.resetForm("queryForm");
  537. this.queryParams.isShow = this.activeName
  538. this.handleQuery();
  539. },
  540. // 多选框选中数据
  541. handleSelectionChange(selection) {
  542. this.ids = selection.map(item => item.courseId)
  543. this.single = selection.length !== 1
  544. this.multiple = !selection.length
  545. },
  546. /** 新增按钮操作 */
  547. handleAdd() {
  548. this.reset();
  549. this.talentList = [];
  550. this.open = true;
  551. this.title = "添加课程";
  552. },
  553. /** 修改按钮操作 */
  554. handleUpdate(row) {
  555. this.reset();
  556. this.talentList = [];
  557. const courseId = row.courseId || this.ids
  558. getUserCourse(courseId).then(response => {
  559. this.form = response.data;
  560. // this.form.cateId = response.data.cateId.toString();
  561. if (this.form.cateId) {
  562. getCateListByPid(this.form.cateId).then(response => {
  563. this.subCategoryOptions = response.data;
  564. });
  565. }
  566. // this.form.courseType = response.data.courseType.toString();
  567. if (response.data.project != null) {
  568. this.form.project = response.data.project.toString();
  569. }
  570. if (response.data.tags != null) {
  571. this.tags = response.data.tags.split(",")
  572. }
  573. this.form.isAutoPlay = response.data.isAutoPlay.toString();
  574. this.form.isShow = response.data.isShow.toString();
  575. this.form.isBest = response.data.isBest.toString();
  576. this.form.isFast = response.data.isFast.toString();
  577. this.form.isIntegral = response.data.isIntegral.toString();
  578. this.form.isTui = response.data.isTui.toString();
  579. this.form.isNext = response.data.isNext.toString();
  580. this.form.isPrivate = response.data.isPrivate.toString();
  581. this.talentParam.talentId = response.data.talentId;
  582. if (this.form.companyIds != null) {
  583. this.companyIds = ((this.form.companyIds).split(",").map(Number))
  584. } else {
  585. this.companyIds = []
  586. }
  587. listBySearch(this.talentParam).then(response => {
  588. this.talentList = response.data;
  589. });
  590. this.open = true;
  591. this.title = "修改课程";
  592. });
  593. },
  594. /** 提交按钮 */
  595. submitForm() {
  596. this.$refs["form"].validate(valid => {
  597. if (valid) {
  598. this.form.companyIds = this.companyIds.toString()
  599. // 私域课程
  600. this.form.isPrivate = 1
  601. if (this.form.courseId != null) {
  602. updateUserCourse(this.form).then(response => {
  603. this.msgSuccess("修改成功");
  604. this.open = false;
  605. this.getList();
  606. });
  607. } else {
  608. addUserCourse(this.form).then(response => {
  609. this.msgSuccess("新增成功");
  610. this.open = false;
  611. this.getList();
  612. });
  613. }
  614. }
  615. });
  616. },
  617. /** 删除按钮操作 */
  618. handleDelete(row) {
  619. const courseIds = row.courseId || this.ids;
  620. this.$confirm('是否确认删除课程编号为"' + courseIds + '"的数据项?', "警告", {
  621. confirmButtonText: "确定",
  622. cancelButtonText: "取消",
  623. type: "warning"
  624. }).then(function () {
  625. return delUserCourse(courseIds);
  626. }).then(() => {
  627. this.getList();
  628. this.msgSuccess("删除成功");
  629. }).catch(() => {
  630. });
  631. },
  632. /** 导出按钮操作 */
  633. handleExport() {
  634. const queryParams = this.queryParams;
  635. this.$confirm('是否确认导出所有课程数据项?', "警告", {
  636. confirmButtonText: "确定",
  637. cancelButtonText: "取消",
  638. type: "warning"
  639. }).then(() => {
  640. this.exportLoading = true;
  641. return exportUserCourse(queryParams);
  642. }).then(response => {
  643. this.download(response.msg);
  644. this.exportLoading = false;
  645. }).catch(() => {
  646. });
  647. },
  648. putOn() {
  649. const courseIds = this.ids;
  650. if (courseIds == null || courseIds == "") {
  651. return this.$message("未选择课程");
  652. }
  653. this.$confirm('是否确认批量上架课程?', "警告", {
  654. confirmButtonText: "确定",
  655. cancelButtonText: "取消",
  656. type: "warning"
  657. }).then(function () {
  658. return putOn(courseIds);
  659. }).then(() => {
  660. this.getList();
  661. this.msgSuccess("上架成功");
  662. }).catch(function () {
  663. });
  664. },
  665. pullOff() {
  666. const courseIds = this.ids;
  667. if (courseIds == null || courseIds == "") {
  668. return this.$message("未选择课程");
  669. }
  670. this.$confirm('是否确认批量下架课程?', "警告", {
  671. confirmButtonText: "确定",
  672. cancelButtonText: "取消",
  673. type: "warning"
  674. }).then(function () {
  675. return pullOff(courseIds);
  676. }).then(() => {
  677. this.getList();
  678. this.msgSuccess("下架成功");
  679. }).catch(function () {
  680. });
  681. }
  682. }
  683. };
  684. </script>