index.vue 25 KB

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