index.vue 31 KB

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