index.vue 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153
  1. <template>
  2. <div id="chapterContent">
  3. <el-tabs v-model="activeName" type="card" v-if="status">
  4. <el-tab-pane label="课程基本信息" name="first" disabled></el-tab-pane>
  5. <el-tab-pane label="课程章节内容" name="second"></el-tab-pane>
  6. </el-tabs>
  7. <ul class="fatherSty">
  8. <li class="floatLefts" v-for="(item, index) in headerData" :key="index">
  9. {{ item.label }}:{{
  10. item.scope === "more"
  11. ? pageInfo[item.prop1] + "-" + pageInfo[item.prop2]
  12. : pageInfo[item.prop]
  13. }}
  14. </li>
  15. <div style="clear: both"></div>
  16. </ul>
  17. <div class="mar_b">
  18. <el-button slot="reference" type="success" @click="openBoxs"
  19. >添加 模块/章/节</el-button
  20. >
  21. <el-button type="primary" @click="openSortBoxs">排序</el-button>
  22. </div>
  23. <el-tree
  24. ref="tree"
  25. :data="tableDataInfos"
  26. lazy
  27. :load="load"
  28. :props="layoutTreeProps"
  29. @node-click="handleNodeClick"
  30. >
  31. <span class="custom-tree-node" slot-scope="{ node, data }">
  32. <span>{{ node.label }}</span>
  33. <span>
  34. <el-button
  35. v-if="data.isDels"
  36. type="text"
  37. size="mini"
  38. @click.stop="del(node, data)"
  39. >
  40. 删除
  41. </el-button>
  42. <el-button
  43. v-if="data.type === 2"
  44. type="text"
  45. size="mini"
  46. style="color: green"
  47. @click.stop="openExamBox(node, data)"
  48. >
  49. 关联试卷
  50. </el-button>
  51. </span>
  52. </span>
  53. </el-tree>
  54. <div class="dis-f">
  55. <el-button @click="backPage">取消</el-button>
  56. <el-button type="primary" @click="submit">确定</el-button>
  57. </div>
  58. <el-dialog
  59. :visible.sync="centerDialogVisible"
  60. width="300px"
  61. :show-close="false"
  62. :close-on-click-modal="false"
  63. >
  64. <div slot="title" class="hearders">
  65. <div class="leftTitle">添加模块/章/节</div>
  66. <div class="rightBoxs">
  67. <img
  68. src="@/assets/images/Close@2x.png"
  69. alt=""
  70. @click="centerDialogVisible = false"
  71. />
  72. </div>
  73. </div>
  74. <el-radio-group v-model="radio" class="dis-f">
  75. <el-radio :label="1">模块</el-radio>
  76. <el-radio :label="2">章</el-radio>
  77. <el-radio :label="3">节</el-radio>
  78. </el-radio-group>
  79. <span slot="footer" class="dialog-footer">
  80. <el-button @click="centerDialogVisible = false" size="small"
  81. >取 消</el-button
  82. >
  83. <el-button type="primary" @click="activeCheckBoxs" size="small"
  84. >确 定</el-button
  85. >
  86. </span>
  87. </el-dialog>
  88. <el-dialog
  89. :visible.sync="dialogVisible"
  90. width="800px"
  91. :show-close="false"
  92. :close-on-click-modal="false"
  93. >
  94. <div slot="title" class="hearders">
  95. <div class="leftTitle">
  96. {{ radio === 1 ? "添加模块" : radio === 2 ? "添加章" : "添加节" }}
  97. </div>
  98. <div class="rightBoxs">
  99. <img
  100. src="@/assets/images/Close@2x.png"
  101. alt=""
  102. @click="dialogVisible = false"
  103. />
  104. </div>
  105. </div>
  106. <search-box-new
  107. ref="searchBox"
  108. :formData="formData5"
  109. :formList="formList5"
  110. @search="getInfos"
  111. @init="init5"
  112. />
  113. <el-table
  114. ref="multipleTable"
  115. :data="boxtableData"
  116. border
  117. @select-all="selectAll"
  118. @select="select"
  119. :row-key="getRowKeys"
  120. :header-cell-style="{
  121. 'background-color': '#eee',
  122. padding: '8px',
  123. color: '#333',
  124. }"
  125. >
  126. <el-table-column
  127. align="center"
  128. type="selection"
  129. width="55"
  130. header-align="center"
  131. :selectable="checkboxT"
  132. :reserve-selection="true"
  133. >
  134. </el-table-column>
  135. <template v-for="(item, index) in tableSet">
  136. <el-table-column
  137. :width="item.width"
  138. :key="index"
  139. :label="item.label"
  140. align="center"
  141. :show-overflow-tooltip="true"
  142. header-align="center"
  143. >
  144. <template slot-scope="scope">
  145. <span v-if="item.scope === 'Status'">
  146. {{
  147. scope.row[item.prop] === 1
  148. ? "发布"
  149. : scope.row[item.prop] === 0
  150. ? "未发布"
  151. : "未知"
  152. }}
  153. </span>
  154. <span v-else-if="item.scope === 'teshu'">
  155. {{ radio === 1 ? scope.row[item.prop] : scope.row[item.prop1] }}
  156. </span>
  157. <span v-else>{{ scope.row[item.prop] }}</span></template
  158. >
  159. </el-table-column></template
  160. >
  161. </el-table>
  162. <pagination
  163. :total="total5"
  164. :pageSize="formData5.pageSize"
  165. :currentPage="formData5.pageNum"
  166. @handleSizeChange="handleSizeChange"
  167. @handleCurrentChange="handleCurrentChange"
  168. />
  169. <span slot="footer" class="dialog-footer">
  170. <el-button @click="dialogVisible = false">取 消</el-button>
  171. <el-button type="primary" @click="submitForm">确 定</el-button>
  172. </span>
  173. </el-dialog>
  174. <el-dialog
  175. :visible.sync="aboutExamStatus"
  176. width="560px"
  177. :show-close="false"
  178. :close-on-click-modal="false"
  179. >
  180. <div slot="title" class="hearders">
  181. <div class="leftTitle">关联题卷</div>
  182. <div class="rightBoxs">
  183. <img src="@/assets/images/Close@2x.png" alt="" @click="closeExam" />
  184. </div>
  185. </div>
  186. <div>
  187. <div><el-button @click="openExamBoxs">选择题卷</el-button></div>
  188. <div>
  189. <span>{{ goodsName }}</span>
  190. <el-button
  191. v-if="goodsName && templateRadio"
  192. type="text"
  193. style="margin-left: 10px"
  194. @click="delExam"
  195. >删除</el-button
  196. >
  197. </div>
  198. </div>
  199. <span slot="footer" class="dialog-footer">
  200. <el-button @click="closeExam">取 消</el-button>
  201. <el-button type="primary" @click="submitExam">确 定</el-button>
  202. </span>
  203. </el-dialog>
  204. <el-dialog
  205. :visible.sync="sortTablesBoxs"
  206. width="560px"
  207. :show-close="false"
  208. :close-on-click-modal="false"
  209. >
  210. <div slot="title" class="hearders">
  211. <div class="leftTitle">排序</div>
  212. <div class="rightBoxs">
  213. <img
  214. src="@/assets/images/Close@2x.png"
  215. alt=""
  216. @click="sortTablesBoxs = false"
  217. />
  218. </div>
  219. </div>
  220. <div>
  221. <el-row>
  222. <el-col :span="22">
  223. <ul>
  224. <li
  225. v-for="(item, index) in sortList"
  226. :key="index"
  227. style="margin-bottom: 6px"
  228. >
  229. <el-input-number
  230. :controls="false"
  231. size="mini"
  232. v-model="sortList[index].sort"
  233. :min="0"
  234. style="width: 50px"
  235. ></el-input-number>
  236. <span style="margin-left: 10px">{{ item.name }}</span>
  237. </li>
  238. </ul>
  239. </el-col>
  240. <el-col :span="2">
  241. <button @click="initSort">重置</button>
  242. </el-col>
  243. </el-row>
  244. </div>
  245. <span slot="footer" class="dialog-footer">
  246. <el-button @click="sortTablesBoxs = false">取 消</el-button>
  247. <el-button type="primary" @click="submitTableBoxs">确 定</el-button>
  248. </span>
  249. </el-dialog>
  250. <el-dialog
  251. :visible.sync="dialogVisiblePZDown"
  252. width="900px"
  253. :show-close="false"
  254. :close-on-click-modal="false"
  255. >
  256. <div slot="title" class="hearders">
  257. <div class="leftTitle">选择题卷</div>
  258. <div class="rightBoxs">
  259. <img src="@/assets/images/Close@2x.png" alt="" @click="closePZ" />
  260. </div>
  261. </div>
  262. <div>
  263. <search-box-new
  264. ref="searchBox"
  265. :formData="formData6"
  266. :formList="formList6"
  267. @search="getSJ(1)"
  268. @init="init6"
  269. />
  270. <el-table
  271. ref="multipleTable"
  272. :data="tableDataExam"
  273. border
  274. :header-cell-style="{
  275. 'background-color': '#eee',
  276. padding: '8px',
  277. color: '#333',
  278. }"
  279. >
  280. <el-table-column label="" width="45" align="center">
  281. <template scope="scope">
  282. <el-radio
  283. class="radioTables"
  284. :label="scope.row.examId"
  285. v-model="templateRadioLS"
  286. @change.native="getTemplateRow(scope.$index, scope.row)"
  287. >{{ "" }}</el-radio
  288. >
  289. </template>
  290. </el-table-column>
  291. <template v-for="(item, index) in tableListExam">
  292. <el-table-column
  293. v-if="item.scope !== 'inputs'"
  294. :width="item.width"
  295. :key="index"
  296. :label="item.label"
  297. align="center"
  298. :show-overflow-tooltip="true"
  299. header-align="center"
  300. >
  301. <template slot-scope="scope">
  302. <span v-if="item.scope === 'moreList'">
  303. {{
  304. scope.row[item.prop1] +
  305. "-" +
  306. scope.row[item.prop2] +
  307. "-" +
  308. scope.row[item.prop3]
  309. }}
  310. </span>
  311. <span v-else-if="item.prop === 'status'">{{
  312. scope.row[item.prop] === 1
  313. ? "发布"
  314. : scope.row[item.prop] === 0
  315. ? "未发布"
  316. : "未知"
  317. }}</span>
  318. <span v-else>{{ scope.row[item.prop] }}</span></template
  319. >
  320. </el-table-column></template
  321. >
  322. </el-table>
  323. <pagination
  324. :total="total6"
  325. :pageSize="formData6.pageSize"
  326. :currentPage="formData6.pageNum"
  327. @handleSizeChange="handleSizeChange6"
  328. @handleCurrentChange="handleCurrentChange6"
  329. />
  330. </div>
  331. <span slot="footer" class="dialog-footer">
  332. <el-button @click="closePZ">取 消</el-button>
  333. <el-button type="primary" @click="submitPZ">确 定</el-button>
  334. </span>
  335. </el-dialog>
  336. </div>
  337. </template>
  338. <script>
  339. import searchBoxNew from "@/components/searchBoxNew";
  340. import pagination from "@/components/pagination";
  341. export default {
  342. components: { searchBoxNew, pagination },
  343. data() {
  344. return {
  345. sortTablesBoxs: false,
  346. activeName: "second",
  347. status: false,
  348. tableDataExam: [],
  349. tableListExam: [
  350. {
  351. label: "试卷编码",
  352. prop: "code",
  353. },
  354. {
  355. label: "标题前缀",
  356. prop: "prefixName",
  357. },
  358. {
  359. label: "试卷标题",
  360. prop: "examName",
  361. },
  362. {
  363. label: "业务层级",
  364. prop1: "educationName",
  365. prop2: "projectName",
  366. prop3: "businessName",
  367. scope: "moreList",
  368. width: "250px",
  369. },
  370. {
  371. label: "发布状态",
  372. prop: "publishStatus",
  373. scope: "status",
  374. },
  375. ],
  376. templateRadioLS: "",
  377. goodsNameLS: "",
  378. templateRadio: "",
  379. goodsName: "",
  380. menuExamList: [], //关联试卷列表
  381. onlyId: "",
  382. newShowObj: {}, //当前关联题卷OBJ
  383. dialogVisiblePZDown: false,
  384. aboutExamStatus: false, //关联试卷弹出
  385. centerDialogVisible: false,
  386. radio: "",
  387. headerData: [
  388. {
  389. label: "课程名称",
  390. prop: "courseName",
  391. },
  392. {
  393. label: "业务层次",
  394. prop1: "projectName",
  395. prop2: "businessName",
  396. scope: "more",
  397. },
  398. {
  399. label: "所属院校",
  400. prop: "schoolName",
  401. },
  402. {
  403. label: "所属专业",
  404. prop: "categoryName",
  405. },
  406. {
  407. label: "科目",
  408. prop: "subjectName",
  409. },
  410. ],
  411. pageInfo: {},
  412. tableData: [],
  413. tableDataInfos: [],
  414. tableSet: [
  415. { label: "编码", prop: "code" },
  416. { label: "标题前缀", prop: "prefixName", width: "120" },
  417. { label: "标题", prop: "moduleName", prop1: "name", scope: "teshu" },
  418. {
  419. label: "发布状态",
  420. prop: "publishStatus",
  421. scope: "Status",
  422. width: "120",
  423. },
  424. ],
  425. dialogVisible: false,
  426. boxtableData: [],
  427. activeLists: [],
  428. total5: 0, //一共多少条
  429. formData5: {
  430. pageSize: 10,
  431. pageNum: 1,
  432. status: 1,
  433. publishStatus: 1,
  434. name: "",
  435. key:""
  436. },
  437. formList5: [],
  438. total6:0,
  439. formData6: {
  440. pageSize: 10,
  441. pageNum: 1,
  442. status: 1,
  443. publishStatus: 1,
  444. name: "",
  445. key:'',
  446. },
  447. formList6: [
  448. {
  449. placeholder: "试卷标题/试卷编码/标题前缀",
  450. prop: "key",
  451. },
  452. ],
  453. theModuleList: [],
  454. theChapterList: [],
  455. theSectionList: [],
  456. sortList: [],
  457. layoutTreeProps: {
  458. label(data, node) {
  459. return data.name;
  460. },
  461. isLeaf(data, node) {
  462. return data.hasChildren ? false : true;
  463. },
  464. },
  465. };
  466. },
  467. mounted() {
  468. this.getDs();
  469. this.search();
  470. },
  471. methods: {
  472. initSort() {
  473. this.sortList = JSON.parse(JSON.stringify(this.tableDataInfos));
  474. },
  475. submitTableBoxs() {
  476. this.tableDataInfos = this.sortList.sort((a, b) => a.sort - b.sort);
  477. this.sortTablesBoxs = false;
  478. },
  479. openSortBoxs() {
  480. this.sortList = JSON.parse(JSON.stringify(this.tableDataInfos));
  481. this.sortTablesBoxs = true;
  482. },
  483. openExamBoxs() {
  484. this.getSJ(2);
  485. this.templateRadioLS = this.templateRadio;
  486. this.dialogVisiblePZDown = true;
  487. },
  488. //单选触发
  489. getTemplateRow(index, row) {
  490. this.templateRadioLS = row.examId;
  491. this.goodsNameLS = row.examName;
  492. },
  493. //2确定变化选项
  494. submitPZ() {
  495. this.templateRadio = this.templateRadioLS;
  496. this.goodsName = this.goodsNameLS;
  497. this.dialogVisiblePZDown = false;
  498. },
  499. closePZ() {
  500. this.dialogVisiblePZDown = false;
  501. },
  502. //删除题卷
  503. delExam() {
  504. this.templateRadio = "";
  505. this.goodsName = "";
  506. },
  507. //1确定关联试卷弹窗
  508. submitExam() {
  509. if (!this.templateRadio && !this.goodsName) {
  510. this.menuExamList = this.menuExamList.filter((item) => {
  511. return item.onlyId != this.onlyId;
  512. });
  513. } else {
  514. var arrays = {};
  515. let ast = this.onlyId.split("-").map(Number);
  516. arrays = {
  517. onlyId: this.onlyId,
  518. courseId: Number(this.$route.query.id),
  519. moduleId: ast[0],
  520. chapterId: ast[1],
  521. sectionId: ast[2],
  522. examId: this.templateRadio,
  523. examName: this.goodsName,
  524. };
  525. var stu = this.menuExamList.some((item) => {
  526. return item.onlyId == this.onlyId;
  527. });
  528. if (stu) {
  529. for (let i = 0; i < this.menuExamList.length; i++) {
  530. if (this.menuExamList[i].onlyId == this.onlyId) {
  531. this.menuExamList[i] = arrays;
  532. }
  533. }
  534. } else {
  535. this.menuExamList.push(arrays);
  536. }
  537. }
  538. this.aboutExamStatus = false;
  539. },
  540. //开启关联试卷盒子
  541. openExamBox(node, item) {
  542. var ints = item.id.split("-").map(Number);
  543. var arr = [];
  544. if (ints[0] === 1) {
  545. arr.push(ints[1]);
  546. if (ints[2]) {
  547. arr.push(ints[2]);
  548. } else {
  549. arr.push(0);
  550. }
  551. if (ints[3]) {
  552. arr.push(ints[3]);
  553. } else {
  554. arr.push(0);
  555. }
  556. }
  557. if (ints[0] === 2) {
  558. arr.push(0);
  559. arr.push(ints[1]);
  560. if (ints[2]) {
  561. arr.push(ints[2]);
  562. } else {
  563. arr.push(0);
  564. }
  565. }
  566. if (ints[0] === 3) {
  567. arr.push(0);
  568. arr.push(0);
  569. arr.push(ints[1]);
  570. }
  571. var atys = arr.join("-");
  572. var setTs = this.menuExamList.some((items) => {
  573. return items.onlyId == atys;
  574. });
  575. if (setTs) {
  576. this.menuExamList.map((items) => {
  577. if (items.onlyId == atys) {
  578. this.templateRadio = items.examId;
  579. this.goodsName = items.examName;
  580. }
  581. });
  582. } else {
  583. this.templateRadio = "";
  584. this.goodsName = "";
  585. }
  586. this.onlyId = atys;
  587. this.aboutExamStatus = true;
  588. },
  589. //关闭关联试卷盒子
  590. closeExam() {
  591. this.aboutExamStatus = false;
  592. },
  593. search() {
  594. this.$api.obtainCourseS(this.$route.query.id).then((res) => {
  595. this.pageInfo = res.data;
  596. });
  597. this.$api
  598. .inquireCoursemenuListS({ courseId: this.$route.query.id })
  599. .then((res) => {
  600. this.tableData = res.rows;
  601. this.changeApis();
  602. this.getList();
  603. });
  604. },
  605. getList() {
  606. this.$api
  607. .inquireCourseListSmenuexam({ courseId: this.$route.query.id })
  608. .then((res) => {
  609. res.rows.forEach((item) => {
  610. var lets = [];
  611. if (!item.moduleId) {
  612. lets.push(0);
  613. } else {
  614. lets.push(item.moduleId);
  615. }
  616. if (!item.chapterId) {
  617. lets.push(0);
  618. } else {
  619. lets.push(item.chapterId);
  620. }
  621. if (!item.sectionId) {
  622. lets.push(0);
  623. } else {
  624. lets.push(item.sectionId);
  625. }
  626. item.onlyId = lets.join("-");
  627. });
  628. this.menuExamList = res.rows;
  629. console.log(this.menuExamList);
  630. });
  631. },
  632. getDs() {
  633. this.$api.inquireCourseListmodule({ status: 1 }).then((res) => {
  634. this.theModuleList = res.rows;
  635. });
  636. this.$api.inquireCourseListchapter({ status: 1 }).then((res) => {
  637. this.theChapterList = res.rows;
  638. });
  639. this.$api.inquireCourseSection({ status: 1 }).then((res) => {
  640. this.theSectionList = res.rows;
  641. });
  642. },
  643. getSJ(int) {
  644. if (int === 1) {
  645. this.formData6.pageNum = 1;
  646. }
  647. if (int === 2) {
  648. this.formData6.name = "";
  649. this.formData6.key = "";
  650. this.formData6.pageNum = 1;
  651. this.formData6.pageSize = 10;
  652. }
  653. var data = JSON.parse(JSON.stringify(this.formData6));
  654. data.businessId = this.pageInfo.businessId;
  655. data.subjectId = this.pageInfo.subjectId;
  656. data.name = this.formData6.name;
  657. this.$api.inquirebankexamList(data).then((res) => {
  658. this.tableDataExam = res.rows;
  659. this.total6 = res.total
  660. });
  661. },
  662. openBoxs() {
  663. this.radio = "";
  664. this.centerDialogVisible = true;
  665. },
  666. activeCheckBoxs() {
  667. var self = this;
  668. if (!this.radio) {
  669. this.$message.error("请选择添加类型");
  670. return;
  671. }
  672. if (this.radio === 1) {
  673. this.formList5 = [
  674. {
  675. placeholder: "模块标题/模块编码/标题前缀",
  676. prop: "key",
  677. },
  678. ];
  679. this.moduleApi(2);
  680. }
  681. if (this.radio === 2) {
  682. this.formList5 = [
  683. {
  684. placeholder: "章标题/章编码/标题前缀",
  685. prop: "key",
  686. },
  687. ];
  688. this.chapterApi(2);
  689. }
  690. if (this.radio === 3) {
  691. this.formList5 = [
  692. {
  693. placeholder: "节标题/节编码/标题前缀",
  694. prop: "key",
  695. },
  696. ];
  697. this.sectionApi(2);
  698. }
  699. this.centerDialogVisible = false;
  700. this.dialogVisible = true;
  701. this.$nextTick(function () {
  702. self.$refs.multipleTable.clearSelection();
  703. });
  704. },
  705. init5() {
  706. this.getInfos(2);
  707. },
  708. getInfos(int) {
  709. if (this.radio === 1) {
  710. this.moduleApi(int);
  711. }
  712. if (this.radio === 2) {
  713. this.chapterApi(int);
  714. }
  715. if (this.radio === 3) {
  716. this.sectionApi(int);
  717. }
  718. },
  719. moduleApi(int) {
  720. if (int === 1) {
  721. this.formData5.pageNum = 1;
  722. }
  723. if (int === 2) {
  724. this.formData5.name = "";
  725. this.formData5.key = "";
  726. this.formData5.pageNum = 1;
  727. this.formData5.pageSize = 10;
  728. }
  729. var data = JSON.parse(JSON.stringify(this.formData5));
  730. data.businessId = this.pageInfo.businessId;
  731. data.subjectId = this.pageInfo.subjectId;
  732. data.name = this.formData5.name;
  733. this.$api.inquireCourseListmodule(data).then((res) => {
  734. this.boxtableData = res.rows;
  735. this.total5 = res.total;
  736. });
  737. },
  738. chapterApi(int) {
  739. if (int === 1) {
  740. this.formData5.pageNum = 1;
  741. }
  742. if (int === 2) {
  743. this.formData5.name = "";
  744. this.formData5.pageNum = 1;
  745. this.formData5.key = "";
  746. this.formData5.pageSize = 10;
  747. }
  748. var data = JSON.parse(JSON.stringify(this.formData5));
  749. data.businessId = this.pageInfo.businessId;
  750. data.subjectId = this.pageInfo.subjectId;
  751. data.name = this.formData5.name;
  752. this.$api.inquireCourseListchapter(data).then((res) => {
  753. this.boxtableData = res.rows;
  754. this.total5 = res.total;
  755. });
  756. },
  757. sectionApi(int) {
  758. if (int === 1) {
  759. this.formData5.pageNum = 1;
  760. }
  761. if (int === 2) {
  762. this.formData5.name = "";
  763. this.formData5.key = "";
  764. this.formData5.pageNum = 1;
  765. this.formData5.pageSize = 10;
  766. }
  767. var data = JSON.parse(JSON.stringify(this.formData5));
  768. data.businessId = this.pageInfo.businessId;
  769. data.subjectId = this.pageInfo.subjectId;
  770. data.name = this.formData5.name;
  771. this.$api.inquireCourseSection(data).then((res) => {
  772. this.boxtableData = res.rows;
  773. this.total5 = res.total;
  774. });
  775. },
  776. // 查询是否存在下级 模块
  777. quireModule(id) {
  778. return new Promise((resolve, reject) => {
  779. this.$api.inquireCourseListmodulechapter(id).then((result) => {
  780. if (result.data.length === 0) {
  781. resolve(false);
  782. } else {
  783. resolve(true);
  784. }
  785. });
  786. });
  787. },
  788. // 查询是否存在下级 章
  789. quireChapter(id) {
  790. return new Promise((resolve, reject) => {
  791. this.$api.inquireCoursechaptersectionlist(id).then((result) => {
  792. if (result.data.length === 0) {
  793. resolve(false);
  794. } else {
  795. resolve(true);
  796. }
  797. });
  798. });
  799. },
  800. changeApis() {
  801. //inquireCourseListmodulechapter 模块与章关系
  802. // inquireCoursechaptersectionlist 章与节关系
  803. var arrays = [];
  804. this.tableData.map((item, index) => {
  805. if (item.type === 1) {
  806. // this.$api.obtainCoursemodule(item.menuId).then(async (res) => {
  807. var arr = {
  808. id: "1-" + item.menuId,
  809. CodeId: item.menuId,
  810. name: item.menuName,
  811. hasChildren: true,
  812. type: 1,
  813. isDels: true,
  814. sort: item.sort,
  815. };
  816. //查询是否存在下级
  817. arrays.push(arr);
  818. // });
  819. }
  820. if (item.type === 2) {
  821. // this.$api.obtainCoursechapter(item.menuId).then(async (res) => {
  822. var arr = {
  823. id: "2-" + item.menuId,
  824. CodeId: item.menuId,
  825. name: item.menuName,
  826. hasChildren: true,
  827. type: 2,
  828. isDels: true,
  829. sort: item.sort,
  830. };
  831. arrays.push(arr);
  832. // });
  833. }
  834. if (item.type === 3) {
  835. // this.$api.obtainCourseSection(item.menuId).then((res) => {
  836. var arr = {
  837. id: "3-" + item.menuId,
  838. CodeId: item.menuId,
  839. name: item.menuName,
  840. hasChildren: false,
  841. type: 3,
  842. isDels: true,
  843. sort: item.sort,
  844. };
  845. arrays.push(arr);
  846. // });
  847. }
  848. });
  849. this.$nextTick(() => {
  850. this.tableDataInfos = arrays;
  851. });
  852. },
  853. del(node, item) {
  854. this.tableDataInfos.map((items, indexs) => {
  855. if (items.id === item.id) {
  856. this.tableDataInfos.splice(indexs, 1);
  857. }
  858. });
  859. this.tableDataInfos = JSON.parse(JSON.stringify(this.tableDataInfos));
  860. },
  861. getRowKeys(row) {
  862. if (this.radio === 1) {
  863. return row.moduleId;
  864. }
  865. if (this.radio === 2) {
  866. return row.chapterId;
  867. }
  868. if (this.radio === 3) {
  869. return row.sectionId;
  870. }
  871. },
  872. checkboxT(row, index) {
  873. var array = [];
  874. this.tableDataInfos.map((item) => {
  875. if (item.type === this.radio) {
  876. array.push(item.CodeId);
  877. }
  878. });
  879. if (
  880. array.indexOf(
  881. this.radio === 1
  882. ? row.moduleId
  883. : this.radio === 2
  884. ? row.chapterId
  885. : row.sectionId
  886. ) !== -1
  887. ) {
  888. return false;
  889. } else {
  890. return true;
  891. }
  892. },
  893. submitForm() {
  894. if (this.activeLists.length === 0) {
  895. this.dialogVisible = false;
  896. return;
  897. }
  898. var array = [];
  899. if (this.radio === 1) {
  900. this.activeLists.map((item) => {
  901. array.push({
  902. id: 1 + "-" + item.moduleId,
  903. CodeId: item.moduleId,
  904. name: item.moduleName,
  905. isDels: true,
  906. hasChildren: true,
  907. type: 1,
  908. sort: 0,
  909. });
  910. });
  911. } else if (this.radio === 2) {
  912. this.activeLists.map((item) => {
  913. array.push({
  914. id: 2 + "-" + item.chapterId,
  915. CodeId: item.chapterId,
  916. name: item.name,
  917. isDels: true,
  918. hasChildren: true,
  919. type: 2,
  920. sort: 0,
  921. });
  922. });
  923. } else if (this.radio === 3) {
  924. this.activeLists.map((item) => {
  925. array.push({
  926. id: 3 + "-" + item.sectionId,
  927. CodeId: item.sectionId,
  928. name: item.name,
  929. type: 3,
  930. sort: 0,
  931. isDels: true,
  932. });
  933. });
  934. }
  935. for (let i = 0; i < array.length; i++) {
  936. this.tableDataInfos.unshift(array[i]);
  937. }
  938. // this.tableDataInfos = this.tableDataInfos.concat(array);
  939. this.activeLists = [];
  940. this.dialogVisible = false;
  941. this.$message.success("添加成功");
  942. },
  943. handleNodeClick() {},
  944. async load(node, resolve) {
  945. const tree = node.data;
  946. if (tree.type === 1) {
  947. var arrays = [];
  948. await this.$api
  949. .inquireCourseListmodulechapter(tree.CodeId)
  950. .then((res) => {
  951. res.data.map((item, index) => {
  952. var arr = {
  953. id: tree.id + "-" + item.chapterId,
  954. CodeId: item.chapterId,
  955. name: item.name,
  956. hasChildren: true,
  957. type: 2,
  958. };
  959. arrays.push(arr);
  960. });
  961. });
  962. resolve(arrays);
  963. }
  964. if (tree.type === 2) {
  965. this.$api.inquireCoursechaptersectionlist(tree.CodeId).then((res) => {
  966. var arrays = [];
  967. res.data.map((item, index) => {
  968. var arr = {
  969. id: tree.id + "-" + item.sectionId,
  970. CodeId: item.sectionId,
  971. name: item.name,
  972. type: 3,
  973. };
  974. arrays.push(arr);
  975. });
  976. resolve(arrays);
  977. });
  978. }
  979. return;
  980. if (tree.type === 1) {
  981. var arrays = [];
  982. await this.$api
  983. .inquireCourseListmodulechapter(tree.CodeId)
  984. .then((res) => {
  985. res.data.map((item, index) => {
  986. var arr = {
  987. id: tree.id + "-" + item.chapterId,
  988. CodeId: item.chapterId,
  989. name: item.name,
  990. hasChildren: true,
  991. type: 2,
  992. };
  993. arrays.push(arr);
  994. });
  995. });
  996. resolve(arrays);
  997. }
  998. if (tree.type === 2) {
  999. this.$api.inquireCoursechaptersectionlist(tree.CodeId).then((res) => {
  1000. var arrays = [];
  1001. res.data.map((item, index) => {
  1002. var arr = {
  1003. id: tree.id + "-" + item.sectionId,
  1004. CodeId: item.sectionId,
  1005. name: item.name,
  1006. type: 3,
  1007. };
  1008. arrays.push(arr);
  1009. });
  1010. resolve(arrays);
  1011. });
  1012. }
  1013. },
  1014. handleSizeChange(v) {
  1015. this.formData5.pageSize = v;
  1016. this.formData5.pageNum = 1;
  1017. this.getInfos();
  1018. },
  1019. handleCurrentChange(v) {
  1020. this.formData5.pageNum = v;
  1021. this.getInfos();
  1022. },
  1023. handleSizeChange6(v) {
  1024. this.formData6.pageSize = v;
  1025. this.formData6.pageNum = 1;
  1026. this.getSJ();
  1027. },
  1028. handleCurrentChange6(v) {
  1029. this.formData6.pageNum = v;
  1030. this.getSJ();
  1031. },
  1032. init6(){
  1033. this.getSJ(2)
  1034. },
  1035. selectAll(value) {
  1036. this.activeLists = value;
  1037. },
  1038. select(value) {
  1039. this.activeLists = value;
  1040. },
  1041. backPage() {
  1042. this.$router.push({
  1043. path: "courseManagement",
  1044. });
  1045. },
  1046. submit() {
  1047. var array = [];
  1048. this.tableDataInfos.map((item) => {
  1049. array.push({
  1050. courseId: Number(this.$route.query.id),
  1051. menuId: item.CodeId,
  1052. parentId: 0,
  1053. status: 1,
  1054. type: item.type,
  1055. sort: item.sort,
  1056. });
  1057. });
  1058. var data = {
  1059. courseId: Number(this.$route.query.id),
  1060. menuExamList: this.menuExamList,
  1061. menuList: array,
  1062. };
  1063. this.$api.editCoursemenu(data).then((res) => {
  1064. this.$message.success("编辑成功");
  1065. setTimeout(() => {
  1066. this.$router.push({
  1067. path: "courseManagement",
  1068. });
  1069. }, 300);
  1070. });
  1071. },
  1072. },
  1073. };
  1074. </script>
  1075. <style lang="less" scoped>
  1076. .fatherSty {
  1077. background-color: #eee;
  1078. padding: 10px;
  1079. margin-bottom: 15px;
  1080. }
  1081. .floatLefts {
  1082. font-size: 14px;
  1083. float: left;
  1084. margin-right: 30px;
  1085. }
  1086. .mar_b {
  1087. display: flex;
  1088. align-items: center;
  1089. justify-content: space-between;
  1090. margin-bottom: 12px;
  1091. }
  1092. .dis-f {
  1093. margin-top: 20px;
  1094. display: flex;
  1095. align-items: center;
  1096. justify-content: center;
  1097. }
  1098. /deep/.el-tree-node__content {
  1099. height: 35px;
  1100. }
  1101. .custom-tree-node {
  1102. flex: 1;
  1103. display: flex;
  1104. align-items: center;
  1105. justify-content: space-between;
  1106. padding-right: 8px;
  1107. }
  1108. /deep/.el-button {
  1109. border-radius: 8px;
  1110. }
  1111. /deep/.el-dialog {
  1112. border-radius: 8px;
  1113. .el-dialog__header {
  1114. padding: 0;
  1115. .hearders {
  1116. height: 40px;
  1117. display: flex;
  1118. align-items: center;
  1119. justify-content: space-between;
  1120. padding: 0px 18px 0px 20px;
  1121. border-bottom: 1px solid #e2e2e2;
  1122. .leftTitle {
  1123. font-size: 14px;
  1124. font-weight: bold;
  1125. color: #2f4378;
  1126. }
  1127. .rightBoxs {
  1128. display: flex;
  1129. align-items: center;
  1130. img {
  1131. width: 14px;
  1132. height: 14px;
  1133. margin-left: 13px;
  1134. cursor: pointer;
  1135. }
  1136. }
  1137. }
  1138. }
  1139. .el-dialog__footer {
  1140. padding: 0;
  1141. .dialog-footer {
  1142. padding: 0px 40px;
  1143. height: 70px;
  1144. border-top: 1px solid #e2e2e2;
  1145. display: flex;
  1146. align-items: center;
  1147. justify-content: flex-end;
  1148. }
  1149. }
  1150. }
  1151. </style>