index.vue 37 KB

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