index.vue 22 KB

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