index.vue 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380
  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. };
  953. arrays.push(arr);
  954. // });
  955. }
  956. if (item.type === 3) {
  957. // this.$api.obtainCourseSection(item.menuId).then((res) => {
  958. var arr = {
  959. id: "3-" + item.menuId,
  960. CodeId: item.menuId,
  961. name: item.menuName,
  962. hasChildren: false,
  963. type: 3,
  964. isDels: true,
  965. sort: item.sort,
  966. };
  967. arrays.push(arr);
  968. // });
  969. }
  970. });
  971. this.$nextTick(() => {
  972. this.tableDataInfos = arrays;
  973. });
  974. },
  975. del(node, item) {
  976. this.tableDataInfos.map((items, indexs) => {
  977. if (items.id === item.id) {
  978. this.tableDataInfos.splice(indexs, 1);
  979. }
  980. });
  981. this.tableDataInfos = JSON.parse(JSON.stringify(this.tableDataInfos));
  982. if (item.type === 1) {
  983. this.menuExamList = this.menuExamList.filter((items) => {
  984. return items.moduleId !== item.CodeId;
  985. });
  986. }
  987. if (item.type === 2) {
  988. this.menuExamList = this.menuExamList.filter((items) => {
  989. if (items.moduleId === 0) {
  990. if (items.chapterId !== item.CodeId) {
  991. return true;
  992. } else {
  993. return false;
  994. }
  995. } else {
  996. return true;
  997. }
  998. });
  999. }
  1000. },
  1001. getRowKeys(row) {
  1002. if (this.radio === 1) {
  1003. return row.moduleId;
  1004. }
  1005. if (this.radio === 2) {
  1006. return row.chapterId;
  1007. }
  1008. if (this.radio === 3) {
  1009. return row.sectionId;
  1010. }
  1011. },
  1012. checkboxT(row, index) {
  1013. var array = [];
  1014. array = this.tableDataInfos.map((item) => {
  1015. if (item.type === this.radio) {
  1016. return item.CodeId;
  1017. }
  1018. });
  1019. if (
  1020. array.indexOf(
  1021. this.radio === 1
  1022. ? row.moduleId
  1023. : this.radio === 2
  1024. ? row.chapterId
  1025. : row.sectionId
  1026. ) !== -1
  1027. ) {
  1028. return false;
  1029. } else {
  1030. return true;
  1031. }
  1032. },
  1033. checkboxExam(row, index) {
  1034. return this.activeArray.findIndex((item) => item.examId == row.examId) ===
  1035. -1
  1036. ? true
  1037. : false;
  1038. },
  1039. submitForm() {
  1040. if (this.activeLists.length === 0) {
  1041. this.dialogVisible = false;
  1042. return;
  1043. }
  1044. var array = [];
  1045. if (this.tableDataInfos.length) {
  1046. if (this.radio === 1) {
  1047. this.activeLists.map((item) => {
  1048. array.push({
  1049. id: 1 + "-" + item.moduleId,
  1050. CodeId: item.moduleId,
  1051. name: item.moduleName,
  1052. isDels: true,
  1053. hasChildren: true,
  1054. type: 1,
  1055. sort: 0,
  1056. });
  1057. });
  1058. } else if (this.radio === 2) {
  1059. this.activeLists.map((item) => {
  1060. array.push({
  1061. id: 2 + "-" + item.chapterId,
  1062. CodeId: item.chapterId,
  1063. name: item.name,
  1064. isDels: true,
  1065. hasChildren: true,
  1066. type: 2,
  1067. sort: 0,
  1068. });
  1069. });
  1070. } else if (this.radio === 3) {
  1071. this.activeLists.map((item) => {
  1072. array.push({
  1073. id: 3 + "-" + item.sectionId,
  1074. CodeId: item.sectionId,
  1075. name: item.name,
  1076. type: 3,
  1077. sort: 0,
  1078. isDels: true,
  1079. });
  1080. });
  1081. }
  1082. let maxIndex = 0;
  1083. this.tableDataInfos.forEach((item) => {
  1084. if (item.sort > maxIndex) {
  1085. maxIndex = item.sort;
  1086. }
  1087. });
  1088. array.forEach((item, index) => {
  1089. item.sort = maxIndex + index + 1;
  1090. });
  1091. } else {
  1092. if (this.radio === 1) {
  1093. this.activeLists.map((item) => {
  1094. array.push({
  1095. id: 1 + "-" + item.moduleId,
  1096. CodeId: item.moduleId,
  1097. name: item.moduleName,
  1098. isDels: true,
  1099. hasChildren: true,
  1100. type: 1,
  1101. sort: 0,
  1102. });
  1103. });
  1104. } else if (this.radio === 2) {
  1105. this.activeLists.map((item) => {
  1106. array.push({
  1107. id: 2 + "-" + item.chapterId,
  1108. CodeId: item.chapterId,
  1109. name: item.name,
  1110. isDels: true,
  1111. hasChildren: true,
  1112. type: 2,
  1113. sort: 0,
  1114. });
  1115. });
  1116. } else if (this.radio === 3) {
  1117. this.activeLists.map((item) => {
  1118. array.push({
  1119. id: 3 + "-" + item.sectionId,
  1120. CodeId: item.sectionId,
  1121. name: item.name,
  1122. type: 3,
  1123. sort: 0,
  1124. isDels: true,
  1125. });
  1126. });
  1127. }
  1128. array.forEach((item, index) => {
  1129. item.sort = index + 1;
  1130. });
  1131. }
  1132. for (let i = 0; i < array.length; i++) {
  1133. this.tableDataInfos.unshift(array[i]);
  1134. }
  1135. // this.tableDataInfos = this.tableDataInfos.concat(array);
  1136. this.activeLists = [];
  1137. this.dialogVisible = false;
  1138. this.$message.success("添加成功");
  1139. },
  1140. handleNodeClick() {},
  1141. async load(node, resolve) {
  1142. const tree = node.data;
  1143. if (tree.type === 1) {
  1144. var arrays = [];
  1145. await this.$api
  1146. .inquireCourseListmodulechapter(tree.CodeId)
  1147. .then((res) => {
  1148. res.data.map((item, index) => {
  1149. var arr = {
  1150. id: tree.id + "-" + item.chapterId,
  1151. CodeId: item.chapterId,
  1152. name: item.name,
  1153. hasChildren: true,
  1154. type: 2,
  1155. };
  1156. arrays.push(arr);
  1157. });
  1158. });
  1159. resolve(arrays);
  1160. }
  1161. if (tree.type === 2) {
  1162. this.$api.inquireCoursechaptersectionlist(tree.CodeId).then((res) => {
  1163. var arrays = [];
  1164. res.data.map((item, index) => {
  1165. var arr = {
  1166. id: tree.id + "-" + item.sectionId,
  1167. CodeId: item.sectionId,
  1168. name: item.name,
  1169. type: 3,
  1170. };
  1171. arrays.push(arr);
  1172. });
  1173. resolve(arrays);
  1174. });
  1175. }
  1176. if (tree.type === 3) {
  1177. resolve([]);
  1178. }
  1179. return;
  1180. },
  1181. handleSizeChange(v) {
  1182. this.formData5.pageSize = v;
  1183. this.formData5.pageNum = 1;
  1184. this.getInfos();
  1185. },
  1186. handleCurrentChange(v) {
  1187. this.formData5.pageNum = v;
  1188. this.getInfos();
  1189. },
  1190. handleSizeChange6(v) {
  1191. this.formData6.pageSize = v;
  1192. this.formData6.pageNum = 1;
  1193. this.getSJ();
  1194. },
  1195. handleCurrentChange6(v) {
  1196. this.formData6.pageNum = v;
  1197. this.getSJ();
  1198. },
  1199. init6() {
  1200. this.getSJ(2);
  1201. },
  1202. /**
  1203. * 多选框变化触发
  1204. */
  1205. selectionChange(arr) {
  1206. this.activeLists = arr;
  1207. },
  1208. backPage() {
  1209. this.$store.dispatch("tagsView/delView", this.$route).then((res) => {
  1210. this.$router.push({
  1211. path: "courseManagement",
  1212. });
  1213. });
  1214. },
  1215. submit() {
  1216. this.disabledBtn = true;
  1217. var array = [];
  1218. this.tableDataInfos.map((item) => {
  1219. array.push({
  1220. courseId: Number(this.$route.query.id),
  1221. menuId: item.CodeId,
  1222. parentId: 0,
  1223. status: 1,
  1224. type: item.type,
  1225. sort: item.sort,
  1226. firstChoiceStatus: item.firstChoiceStatus || 0,
  1227. });
  1228. });
  1229. if (this.menuExamList && this.menuExamList.length > 0) {
  1230. this.menuExamList.forEach((item) => {
  1231. if (
  1232. item.moduleId != 0 &&
  1233. item.sectionId == 0 &&
  1234. item.chapterId == 0
  1235. ) {
  1236. item.type = 3;
  1237. } else if (item.sectionId != 0) {
  1238. item.type = 2;
  1239. } else {
  1240. item.type = 1;
  1241. }
  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. .radioTables {
  1272. border-radius: 50%;
  1273. width: 18px;
  1274. height: 18px;
  1275. border: 1px solid #eee;
  1276. background-color: #fff;
  1277. cursor: pointer;
  1278. position: relative;
  1279. & > .activeRadio {
  1280. position: absolute;
  1281. transition: all 0.3s;
  1282. left: 50%;
  1283. top: 50%;
  1284. transform: translateX(-50%) translateY(-50%);
  1285. width: 12px;
  1286. height: 12px;
  1287. border-radius: 50%;
  1288. overflow: hidden;
  1289. background-color: rgb(24, 144, 255);
  1290. animation: radios 0.3s;
  1291. }
  1292. }
  1293. @keyframes radios {
  1294. 0% {
  1295. opacity: 0;
  1296. }
  1297. 100% {
  1298. opacity: 1;
  1299. }
  1300. }
  1301. .fatherSty {
  1302. background-color: #eee;
  1303. padding: 10px;
  1304. margin-bottom: 15px;
  1305. }
  1306. .floatLefts {
  1307. font-size: 14px;
  1308. float: left;
  1309. margin-right: 30px;
  1310. }
  1311. .mar_b {
  1312. display: flex;
  1313. align-items: center;
  1314. justify-content: space-between;
  1315. margin-bottom: 12px;
  1316. }
  1317. .dis-f {
  1318. margin-top: 20px;
  1319. display: flex;
  1320. align-items: center;
  1321. justify-content: center;
  1322. }
  1323. /deep/.el-tree-node__content {
  1324. height: 35px;
  1325. }
  1326. .custom-tree-node {
  1327. flex: 1;
  1328. display: flex;
  1329. align-items: center;
  1330. justify-content: space-between;
  1331. padding-right: 8px;
  1332. }
  1333. /deep/.el-button {
  1334. border-radius: 8px;
  1335. }
  1336. /deep/.el-dialog {
  1337. border-radius: 8px;
  1338. .el-dialog__header {
  1339. padding: 0;
  1340. .hearders {
  1341. height: 40px;
  1342. display: flex;
  1343. align-items: center;
  1344. justify-content: space-between;
  1345. padding: 0px 18px 0px 20px;
  1346. border-bottom: 1px solid #e2e2e2;
  1347. .leftTitle {
  1348. font-size: 14px;
  1349. font-weight: bold;
  1350. color: #2f4378;
  1351. }
  1352. .rightBoxs {
  1353. display: flex;
  1354. align-items: center;
  1355. img {
  1356. width: 14px;
  1357. height: 14px;
  1358. margin-left: 13px;
  1359. cursor: pointer;
  1360. }
  1361. }
  1362. }
  1363. }
  1364. .el-dialog__footer {
  1365. padding: 0;
  1366. .dialog-footer {
  1367. padding: 0px 40px;
  1368. height: 70px;
  1369. border-top: 1px solid #e2e2e2;
  1370. display: flex;
  1371. align-items: center;
  1372. justify-content: flex-end;
  1373. }
  1374. }
  1375. }
  1376. </style>