index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  1. <template>
  2. <div id="festival">
  3. <search-box-new
  4. ref="searchBox"
  5. :formData="formData"
  6. :formList="formList"
  7. @search="search"
  8. @init="init"
  9. />
  10. <table-list
  11. rowKey="sectionId"
  12. ref="tableList"
  13. :tableSets="tableSet"
  14. :tableData="tableData"
  15. :navText="navText"
  16. @addClick="addClick"
  17. :loading="loading"
  18. @editInfo="editInfo"
  19. >
  20. <template slot="customize">
  21. <el-button size="medium" type="success" @click="moreActive"
  22. >批量导入</el-button
  23. >
  24. </template>
  25. <template slot="btn" slot-scope="props">
  26. <el-button type="text" @click="addClick(props.scope.row, 0)"
  27. >修改</el-button
  28. >
  29. <el-button type="text" @click="del(props.scope.row)">删除</el-button>
  30. </template>
  31. </table-list>
  32. <pagination
  33. :total="total"
  34. :pageSize="formData.pageSize"
  35. :currentPage="formData.pageNum"
  36. @handleSizeChange="handleSizeChange"
  37. @handleCurrentChange="handleCurrentChange"
  38. />
  39. <el-dialog
  40. :visible.sync="dialogDR"
  41. width="660px"
  42. :show-close="false"
  43. :close-on-click-modal="false"
  44. >
  45. <div slot="title" class="hearders">
  46. <div class="leftTitle">导入</div>
  47. <div class="rightBoxs">
  48. <img
  49. src="@/assets/images/Close@2x.png"
  50. alt=""
  51. @click="dialogDR = false"
  52. />
  53. </div>
  54. </div>
  55. <div>
  56. <div class="swq">
  57. <img
  58. style="width: 182px; height: 168px"
  59. src="@/assets/images/dr.png"
  60. alt=""
  61. />
  62. </div>
  63. <div style="padding-left: 100px">
  64. <p>第一步:下载导入模板</p>
  65. <p style="padding-left: 50px">
  66. <i class="el-icon-upload"></i
  67. ><span class="dowmStys" @click="getDowm">下载模板</span>
  68. </p>
  69. <p>第二步:(批量新增):点击“上传Excel”完成导入</p>
  70. <label
  71. for="mobles"
  72. class="el-button el-button--primary"
  73. style="margin-left: 50px; padding: 10px 20px"
  74. >上传Excel</label
  75. ><input
  76. style="display: none"
  77. type="file"
  78. id="mobles"
  79. ref="input1"
  80. @change="importMobleadd"
  81. />
  82. </div>
  83. </div>
  84. <span slot="footer" class="dialog-footer">
  85. <el-button @click="dialogDR = false">取消</el-button>
  86. <!-- <el-button type="primary" @click="submitChecksDR">确定</el-button> -->
  87. </span>
  88. </el-dialog>
  89. <el-dialog
  90. append-to-body
  91. :visible.sync="dialogERROR"
  92. width="660px"
  93. :show-close="false"
  94. :close-on-click-modal="false"
  95. >
  96. <div slot="title" class="hearders">
  97. <div class="leftTitle">提示</div>
  98. <div class="rightBoxs">
  99. <img
  100. src="@/assets/images/Close@2x.png"
  101. alt=""
  102. @click="dialogERROR = false"
  103. />
  104. </div>
  105. </div>
  106. <div>
  107. <h4 style="margin-top: 0px; font-weight: bold; text-align: center">
  108. 导入失败原因
  109. </h4>
  110. <el-input
  111. readonly
  112. type="textarea"
  113. :autosize="{ minRows: 6, maxRows: 24 }"
  114. v-model="errorData"
  115. >
  116. </el-input>
  117. </div>
  118. <span slot="footer" class="dialog-footer">
  119. <el-button @click="dialogERROR = false">确定</el-button>
  120. </span>
  121. </el-dialog>
  122. </div>
  123. </template>
  124. <script>
  125. import * as baseUrls from "@/utils/request.js";
  126. import searchBoxNew from "@/components/searchBoxNew";
  127. import tableList from "@/components/tableList";
  128. import pagination from "@/components/pagination";
  129. export default {
  130. name: "Festival",
  131. components: { searchBoxNew, tableList, pagination },
  132. data() {
  133. return {
  134. dialogDR: false, //导入窗口
  135. loading: false, //当前表单加载是否加载动画
  136. navText: {
  137. title: "节类型",
  138. index: 0,
  139. ch: "条",
  140. num: true,
  141. border: true,
  142. choice: true,
  143. openCheckMore: true,
  144. addHide: false,
  145. backFatherBtn: {
  146. status: false,
  147. title: "未定义",
  148. },
  149. },
  150. //搜索
  151. formList: [
  152. {
  153. prop: "educationTypeId",
  154. placeholder: "教育类型",
  155. scope: "educationType",
  156. },
  157. {
  158. prop: "businessId",
  159. placeholder: "业务层次",
  160. scope: "businessLevel",
  161. edu: "educationTypeId",
  162. },
  163. {
  164. prop: "subjectId",
  165. placeholder: "科目",
  166. scope: "sujectType",
  167. edu: "educationTypeId",
  168. },
  169. {
  170. prop: "sectionType",
  171. placeholder: "节类型",
  172. scope: "select",
  173. options: [
  174. {
  175. label: "录播",
  176. value: 1,
  177. },
  178. {
  179. label: "直播",
  180. value: 2,
  181. },
  182. {
  183. label: "回放",
  184. value: 3,
  185. },
  186. ],
  187. },
  188. {
  189. prop: "prefixName",
  190. placeholder: "请输入标题前缀",
  191. },
  192. {
  193. prop: "publishStatus",
  194. placeholder: "发布状态",
  195. scope: "select",
  196. options: [
  197. {
  198. label: "发布",
  199. value: 1,
  200. },
  201. {
  202. label: "未发布",
  203. value: 0,
  204. },
  205. ],
  206. },
  207. {
  208. prop: "name",
  209. placeholder: "请输入节标题",
  210. },
  211. ],
  212. formData: {
  213. status: "0,1",
  214. pageSize: 10,
  215. pageNum: 1,
  216. },
  217. // 表单
  218. tableSet: [
  219. {
  220. label: "节编码",
  221. prop: "code",
  222. hidden: true,
  223. },
  224. {
  225. label: "标题前缀",
  226. prop: "prefixName",
  227. hidden: true,
  228. },
  229. {
  230. label: "节标题",
  231. prop: "name",
  232. hidden: true,
  233. scope: "editInfo",
  234. },
  235. {
  236. label: "适用业务层级",
  237. prop: "businessList",
  238. hidden: true,
  239. scope: "mapTypesMores",
  240. },
  241. {
  242. label: "关联章",
  243. prop: "chapterList",
  244. prop1: "chapterName",
  245. hidden: true,
  246. scope: "aboutChapter",
  247. int: 1,
  248. },
  249. // {
  250. // label: "关联模块",
  251. // prop: "educationName",
  252. // hidden: true,
  253. // },
  254. // {
  255. // label: "关联课程",
  256. // prop: "educationName",
  257. // hidden: true,
  258. // },
  259. {
  260. label: "节类型",
  261. prop: "sectionType",
  262. hidden: true,
  263. scope: "sectionTypesTTT",
  264. },
  265. {
  266. label: "节时长",
  267. prop: "durationTime",
  268. hidden: true,
  269. scope: "convert",
  270. },
  271. {
  272. label: "URL地址/直播地址",
  273. prop: "sectionType",
  274. prop1: "recordingUrl",
  275. prop2: "liveUrl",
  276. hidden: true,
  277. scope: "liveAndUrl",
  278. },
  279. // {
  280. // label: "直播开始时间",
  281. // prop: "liveStartTime",
  282. // hidden: true,
  283. // scope: "aTimeList",
  284. // width: "160",
  285. // },
  286. // {
  287. // label: "直播结束时间",
  288. // prop: "liveEndTime",
  289. // hidden: true,
  290. // scope: "aTimeList",
  291. // width: "160",
  292. // },
  293. {
  294. label: "最后编辑时间",
  295. prop: "updateTime",
  296. scope: "aTimeList",
  297. hidden: true,
  298. },
  299. {
  300. label: "创建时间",
  301. prop: "createTime",
  302. scope: "aTimeList",
  303. hidden: true,
  304. },
  305. {
  306. label: "发布状态",
  307. prop: "publishStatus",
  308. hidden: true,
  309. scope: "fabStatus",
  310. },
  311. ],
  312. tableData: [], //表单数据
  313. total: 0, //一共多少条
  314. pageSize: 10, //每页多少条数据
  315. currentPage: 1, //当前页码
  316. errorData: "", //导入错误原因
  317. dialogERROR: false,
  318. };
  319. },
  320. mounted() {
  321. this.search();
  322. },
  323. activated() {
  324. this.search();
  325. },
  326. methods: {
  327. getDowm() {
  328. let url = baseUrls.BASE_IMG_URL + "/oss/images/file/20220304/1646382321115.xlsx";
  329. let link = document.createElement("a");
  330. let fileName = "导入模板" + ".xlsx";
  331. document.body.appendChild(link);
  332. link.href = url;
  333. link.dowmload = fileName;
  334. link.click();
  335. link.remove();
  336. },
  337. importMobleadd(e) {
  338. var self = this;
  339. var file = e.target.files[0];
  340. let formData = new FormData();
  341. formData.append("file", file);
  342. this.$api
  343. .drCourseSectionimportData(formData)
  344. .then((res) => {
  345. if (res.code === 200) {
  346. if (!res.data.errorLog) {
  347. self.$message.success("导入成功");
  348. self.dialogDR = false;
  349. } else {
  350. self.errorData = res.data.errorLog;
  351. self.dialogERROR = true;
  352. }
  353. }
  354. })
  355. .finally(() => {
  356. self.search();
  357. e.target.value = "";
  358. });
  359. },
  360. moreActive() {
  361. this.dialogDR = true;
  362. },
  363. editInfo(v) {
  364. this.addClick(v, 0);
  365. },
  366. search(int) {
  367. this.loading = true;
  368. if (int === 1) {
  369. this.formData.pageNum = 1;
  370. }
  371. if (int === 2) {
  372. this.formData = {
  373. status: "0,1",
  374. pageSize: 10,
  375. pageNum: 1,
  376. };
  377. }
  378. this.$api
  379. .inquireCourseSection(this.formData)
  380. .then((res) => {
  381. this.tableData = res.rows;
  382. this.total = res.total;
  383. this.navText.index = res.total;
  384. })
  385. .finally(() => {
  386. this.loading = false;
  387. });
  388. },
  389. init() {
  390. this.search(2);
  391. },
  392. del(v) {
  393. this.$api
  394. .gradecheckGoodsChange({ sectionId: v.sectionId })
  395. .then((res) => {
  396. if (res.data > 0) {
  397. this.$message.error("已有学员正在学习,无法删除");
  398. return;
  399. } else {
  400. this.$alert(
  401. "确定删除此内容?<br />内容删除后将无法恢复,请慎重考虑",
  402. "提示",
  403. {
  404. dangerouslyUseHTMLString: true,
  405. }
  406. )
  407. .then(() => {
  408. var data = {
  409. sectionId: v.sectionId,
  410. status: -1,
  411. };
  412. this.$api.editCourseSection(data).then((res) => {
  413. this.$message.success("删除成功");
  414. this.$refs.tableList.clearMoreActive();
  415. this.search();
  416. });
  417. })
  418. .catch(() => {
  419. this.$message({
  420. type: "info",
  421. message: "已取消删除",
  422. });
  423. });
  424. }
  425. });
  426. },
  427. addClick(v, int) {
  428. if (v === undefined) {
  429. this.$router.push({
  430. path: "festivalAdd",
  431. });
  432. } else {
  433. const jump = () => {
  434. this.$router.push({
  435. path: "festivalEdit",
  436. query: {
  437. id: v.sectionId,
  438. },
  439. });
  440. };
  441. const statusPage = this.$store.state.tagsView.visitedViews.some(
  442. (item) => {
  443. return item.name == "FestivalEdit";
  444. }
  445. );
  446. if (statusPage) {
  447. this.$store
  448. .dispatch("tagsView/delCachedView", {
  449. name: "FestivalEdit",
  450. })
  451. .then((res) => {
  452. jump();
  453. });
  454. } else {
  455. jump();
  456. }
  457. }
  458. },
  459. handleSizeChange(v) {
  460. this.formData.pageSize = v;
  461. this.formData.pageNum = 1;
  462. this.search();
  463. },
  464. handleCurrentChange(v) {
  465. this.formData.pageNum = v;
  466. this.search();
  467. },
  468. },
  469. };
  470. </script>
  471. <style lang="less" scoped>
  472. /deep/.el-button {
  473. border-radius: 8px;
  474. }
  475. /deep/.el-dialog {
  476. border-radius: 8px;
  477. .el-dialog__header {
  478. padding: 0;
  479. .hearders {
  480. height: 40px;
  481. display: flex;
  482. align-items: center;
  483. justify-content: space-between;
  484. padding: 0px 18px 0px 20px;
  485. border-bottom: 1px solid #e2e2e2;
  486. .leftTitle {
  487. font-size: 14px;
  488. font-weight: bold;
  489. color: #2f4378;
  490. }
  491. .rightBoxs {
  492. display: flex;
  493. align-items: center;
  494. img {
  495. width: 14px;
  496. height: 14px;
  497. margin-left: 13px;
  498. cursor: pointer;
  499. }
  500. }
  501. }
  502. }
  503. .el-dialog__footer {
  504. padding: 0;
  505. .dialog-footer {
  506. padding: 0px 40px;
  507. height: 70px;
  508. border-top: 1px solid #e2e2e2;
  509. display: flex;
  510. align-items: center;
  511. justify-content: flex-end;
  512. }
  513. }
  514. }
  515. .swq {
  516. text-align: center;
  517. border-bottom: 1px solid #eee;
  518. }
  519. .dowmStys {
  520. color: blue;
  521. cursor: pointer;
  522. }
  523. .imgBox {
  524. width: 100%;
  525. // height: 210px;
  526. border: 1px solid #e2e2e2;
  527. border-radius: 8px;
  528. padding: 8px 8px 3px;
  529. display: flex;
  530. flex-direction: column;
  531. align-items: center;
  532. .imgLabel {
  533. flex: 1;
  534. width: 100%;
  535. border: 1px dotted #e2e2e2;
  536. color: #999;
  537. font-size: 14px;
  538. cursor: pointer;
  539. border-radius: 8px;
  540. .msPhoto {
  541. display: flex;
  542. justify-content: center;
  543. align-items: center;
  544. max-width: 100%;
  545. max-height: 270px;
  546. img {
  547. max-width: 100%;
  548. max-height: 270px;
  549. }
  550. }
  551. .imgbbx {
  552. display: flex;
  553. flex-direction: column;
  554. align-items: center;
  555. justify-content: center;
  556. width: 100%;
  557. height: 100%;
  558. i {
  559. font-weight: bold;
  560. margin: 14px 0;
  561. font-size: 24px;
  562. }
  563. }
  564. }
  565. p {
  566. margin: 5px 0px;
  567. }
  568. }
  569. </style>