index.vue 37 KB

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