index.vue 17 KB

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