index.vue 18 KB

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