index.vue 36 KB

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