index.vue 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343
  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. this.tableDataInfos = this.sortList.sort((a, b) => a.sort - b.sort);
  615. this.sortTablesBoxs = false;
  616. },
  617. openSortBoxs() {
  618. this.sortList = JSON.parse(JSON.stringify(this.tableDataInfos));
  619. this.sortTablesBoxs = true;
  620. },
  621. openExamBoxs() {
  622. this.getSJ(2);
  623. this.templateRadioLS = this.templateRadio;
  624. this.dialogVisiblePZDown = true;
  625. },
  626. //单选触发
  627. getTemplateRow(index, row) {
  628. this.templateRadioLS = row.examId;
  629. this.goodsNameLS = row.examName;
  630. },
  631. //2确定变化选项
  632. submitPZ() {
  633. this.templateRadio = this.templateRadioLS;
  634. this.goodsName = this.goodsNameLS;
  635. this.dialogVisiblePZDown = false;
  636. },
  637. closePZ() {
  638. this.dialogVisiblePZDown = false;
  639. },
  640. //删除题卷
  641. delExam() {
  642. this.templateRadio = "";
  643. this.goodsName = "";
  644. },
  645. //1确定关联试卷弹窗
  646. submitExam() {
  647. if (!this.templateRadio && !this.goodsName) {
  648. this.menuExamList = this.menuExamList.filter((item) => {
  649. return item.onlyId != this.onlyId;
  650. });
  651. } else {
  652. var arrays = {};
  653. let ast = this.onlyId.split("-").map(Number);
  654. arrays = {
  655. onlyId: this.onlyId,
  656. courseId: Number(this.$route.query.id),
  657. moduleId: ast[0],
  658. chapterId: ast[1],
  659. sectionId: ast[2],
  660. examId: this.templateRadio,
  661. examName: this.goodsName,
  662. };
  663. var stu = this.menuExamList.some((item) => {
  664. return item.onlyId == this.onlyId;
  665. });
  666. if (stu) {
  667. for (let i = 0; i < this.menuExamList.length; i++) {
  668. if (this.menuExamList[i].onlyId == this.onlyId) {
  669. this.menuExamList[i] = arrays;
  670. }
  671. }
  672. } else {
  673. this.menuExamList.push(arrays);
  674. }
  675. }
  676. this.aboutExamStatus = false;
  677. },
  678. //开启关联试卷盒子
  679. openExamBox(node, item) {
  680. var ints = item.id.split("-").map(Number);
  681. var arr = [];
  682. if (ints[0] === 1) {
  683. arr.push(ints[1]);
  684. if (ints[2]) {
  685. arr.push(ints[2]);
  686. } else {
  687. arr.push(0);
  688. }
  689. if (ints[3]) {
  690. arr.push(ints[3]);
  691. } else {
  692. arr.push(0);
  693. }
  694. }
  695. if (ints[0] === 2) {
  696. arr.push(0);
  697. arr.push(ints[1]);
  698. if (ints[2]) {
  699. arr.push(ints[2]);
  700. } else {
  701. arr.push(0);
  702. }
  703. }
  704. if (ints[0] === 3) {
  705. arr.push(0);
  706. arr.push(0);
  707. arr.push(ints[1]);
  708. }
  709. var atys = arr.join("-");
  710. var setTs = this.menuExamList.some((items) => {
  711. return items.onlyId == atys;
  712. });
  713. if (setTs) {
  714. this.menuExamList.map((items) => {
  715. if (items.onlyId == atys) {
  716. this.templateRadio = items.examId;
  717. this.goodsName = items.examName;
  718. }
  719. });
  720. } else {
  721. this.templateRadio = "";
  722. this.goodsName = "";
  723. }
  724. this.onlyId = atys;
  725. this.aboutExamStatus = true;
  726. },
  727. //关闭关联试卷盒子
  728. closeExam() {
  729. this.aboutExamStatus = false;
  730. },
  731. search() {
  732. this.$api.obtainCourseS(this.$route.query.id).then((res) => {
  733. this.pageInfo = res.data;
  734. });
  735. this.$api
  736. .inquireCoursemenuListS({ courseId: this.$route.query.id })
  737. .then((res) => {
  738. this.tableData = res.rows;
  739. this.changeApis();
  740. this.getList();
  741. });
  742. },
  743. getList() {
  744. this.$api
  745. .inquireCourseListSmenuexam({ courseId: this.$route.query.id })
  746. .then((res) => {
  747. res.rows.forEach((item) => {
  748. var lets = [];
  749. if (!item.moduleId) {
  750. lets.push(0);
  751. } else {
  752. lets.push(item.moduleId);
  753. }
  754. if (!item.chapterId) {
  755. lets.push(0);
  756. } else {
  757. lets.push(item.chapterId);
  758. }
  759. if (!item.sectionId) {
  760. lets.push(0);
  761. } else {
  762. lets.push(item.sectionId);
  763. }
  764. item.onlyId = lets.join("-");
  765. });
  766. this.menuExamList = res.rows;
  767. });
  768. },
  769. getDs() {
  770. this.$api.inquireCourseListmodule({ status: 1 }).then((res) => {
  771. this.theModuleList = res.rows;
  772. });
  773. this.$api.inquireCourseListchapter({ status: 1 }).then((res) => {
  774. this.theChapterList = res.rows;
  775. });
  776. this.$api.inquireCourseSection({ status: 1 }).then((res) => {
  777. this.theSectionList = res.rows;
  778. });
  779. },
  780. getSJ(int) {
  781. if (int === 1) {
  782. this.formData6.pageNum = 1;
  783. }
  784. if (int === 2) {
  785. this.formData6.name = "";
  786. this.formData6.key = "";
  787. this.formData6.pageNum = 1;
  788. this.formData6.pageSize = 10;
  789. }
  790. var data = JSON.parse(JSON.stringify(this.formData6));
  791. data.businessId = this.pageInfo.businessId;
  792. data.subjectId = this.pageInfo.subjectId;
  793. data.name = this.formData6.name;
  794. this.$api.inquirebankexamList(data).then((res) => {
  795. this.tableDataExam = res.rows;
  796. this.total6 = res.total;
  797. });
  798. },
  799. openBoxs() {
  800. this.radio = "";
  801. this.centerDialogVisible = true;
  802. },
  803. activeCheckBoxs() {
  804. var self = this;
  805. if (!this.radio) {
  806. this.$message.error("请选择添加类型");
  807. return;
  808. }
  809. if (this.radio === 1) {
  810. this.formList5 = [
  811. {
  812. placeholder: "模块标题/模块编码/标题前缀",
  813. prop: "key",
  814. },
  815. ];
  816. this.moduleApi(2);
  817. }
  818. if (this.radio === 2) {
  819. this.formList5 = [
  820. {
  821. placeholder: "章标题/章编码/标题前缀",
  822. prop: "key",
  823. },
  824. ];
  825. this.chapterApi(2);
  826. }
  827. if (this.radio === 3) {
  828. this.formList5 = [
  829. {
  830. placeholder: "节标题/节编码/标题前缀",
  831. prop: "key",
  832. },
  833. ];
  834. this.sectionApi(2);
  835. }
  836. this.centerDialogVisible = false;
  837. this.dialogVisible = true;
  838. this.$nextTick(function () {
  839. self.$refs.multipleTable.clearSelection();
  840. });
  841. },
  842. init5() {
  843. this.getInfos(2);
  844. },
  845. getInfos(int) {
  846. if (this.radio === 1) {
  847. this.moduleApi(int);
  848. }
  849. if (this.radio === 2) {
  850. this.chapterApi(int);
  851. }
  852. if (this.radio === 3) {
  853. this.sectionApi(int);
  854. }
  855. },
  856. moduleApi(int) {
  857. if (int === 1) {
  858. this.formData5.pageNum = 1;
  859. }
  860. if (int === 2) {
  861. this.formData5.name = "";
  862. this.formData5.key = "";
  863. this.formData5.pageNum = 1;
  864. this.formData5.pageSize = 10;
  865. }
  866. var data = JSON.parse(JSON.stringify(this.formData5));
  867. data.businessId = this.pageInfo.businessId;
  868. data.subjectId = this.pageInfo.subjectId;
  869. data.name = this.formData5.name;
  870. this.$api.inquireCourseListmodule(data).then((res) => {
  871. this.boxtableData = res.rows;
  872. this.total5 = res.total;
  873. });
  874. },
  875. chapterApi(int) {
  876. if (int === 1) {
  877. this.formData5.pageNum = 1;
  878. }
  879. if (int === 2) {
  880. this.formData5.name = "";
  881. this.formData5.pageNum = 1;
  882. this.formData5.key = "";
  883. this.formData5.pageSize = 10;
  884. }
  885. var data = JSON.parse(JSON.stringify(this.formData5));
  886. data.businessId = this.pageInfo.businessId;
  887. data.subjectId = this.pageInfo.subjectId;
  888. data.name = this.formData5.name;
  889. this.$api.inquireCourseListchapter(data).then((res) => {
  890. this.boxtableData = res.rows;
  891. this.total5 = res.total;
  892. });
  893. },
  894. sectionApi(int) {
  895. if (int === 1) {
  896. this.formData5.pageNum = 1;
  897. }
  898. if (int === 2) {
  899. this.formData5.name = "";
  900. this.formData5.key = "";
  901. this.formData5.pageNum = 1;
  902. this.formData5.pageSize = 10;
  903. }
  904. var data = JSON.parse(JSON.stringify(this.formData5));
  905. data.businessId = this.pageInfo.businessId;
  906. data.subjectId = this.pageInfo.subjectId;
  907. data.name = this.formData5.name;
  908. this.$api.inquireCourseSection(data).then((res) => {
  909. this.boxtableData = res.rows;
  910. this.total5 = res.total;
  911. });
  912. },
  913. // 查询是否存在下级 模块
  914. quireModule(id) {
  915. return new Promise((resolve, reject) => {
  916. this.$api.inquireCourseListmodulechapter(id).then((result) => {
  917. if (result.data.length === 0) {
  918. resolve(false);
  919. } else {
  920. resolve(true);
  921. }
  922. });
  923. });
  924. },
  925. // 查询是否存在下级 章
  926. quireChapter(id) {
  927. return new Promise((resolve, reject) => {
  928. this.$api.inquireCoursechaptersectionlist(id).then((result) => {
  929. if (result.data.length === 0) {
  930. resolve(false);
  931. } else {
  932. resolve(true);
  933. }
  934. });
  935. });
  936. },
  937. changeApis() {
  938. //inquireCourseListmodulechapter 模块与章关系
  939. // inquireCoursechaptersectionlist 章与节关系
  940. var arrays = [];
  941. this.tableData.map((item, index) => {
  942. if (item.type === 1) {
  943. // this.$api.obtainCoursemodule(item.menuId).then(async (res) => {
  944. var arr = {
  945. id: "1-" + item.menuId,
  946. CodeId: item.menuId,
  947. name: item.menuName,
  948. hasChildren: true,
  949. type: 1,
  950. isDels: true,
  951. sort: item.sort,
  952. };
  953. //查询是否存在下级
  954. arrays.push(arr);
  955. // });
  956. }
  957. if (item.type === 2) {
  958. // this.$api.obtainCoursechapter(item.menuId).then(async (res) => {
  959. var arr = {
  960. id: "2-" + item.menuId,
  961. CodeId: item.menuId,
  962. name: item.menuName,
  963. hasChildren: true,
  964. type: 2,
  965. isDels: true,
  966. sort: item.sort,
  967. };
  968. arrays.push(arr);
  969. // });
  970. }
  971. if (item.type === 3) {
  972. // this.$api.obtainCourseSection(item.menuId).then((res) => {
  973. var arr = {
  974. id: "3-" + item.menuId,
  975. CodeId: item.menuId,
  976. name: item.menuName,
  977. hasChildren: false,
  978. type: 3,
  979. isDels: true,
  980. sort: item.sort,
  981. };
  982. arrays.push(arr);
  983. // });
  984. }
  985. });
  986. this.$nextTick(() => {
  987. this.tableDataInfos = arrays;
  988. });
  989. },
  990. del(node, item) {
  991. this.tableDataInfos.map((items, indexs) => {
  992. if (items.id === item.id) {
  993. this.tableDataInfos.splice(indexs, 1);
  994. }
  995. });
  996. this.tableDataInfos = JSON.parse(JSON.stringify(this.tableDataInfos));
  997. if (item.type === 1) {
  998. this.menuExamList = this.menuExamList.filter((items) => {
  999. return items.moduleId !== item.CodeId;
  1000. });
  1001. }
  1002. if (item.type === 2) {
  1003. this.menuExamList = this.menuExamList.filter((items) => {
  1004. if (items.moduleId === 0) {
  1005. if (items.chapterId !== item.CodeId) {
  1006. return true;
  1007. } else {
  1008. return false;
  1009. }
  1010. } else {
  1011. return true;
  1012. }
  1013. });
  1014. }
  1015. },
  1016. getRowKeys(row) {
  1017. if (this.radio === 1) {
  1018. return row.moduleId;
  1019. }
  1020. if (this.radio === 2) {
  1021. return row.chapterId;
  1022. }
  1023. if (this.radio === 3) {
  1024. return row.sectionId;
  1025. }
  1026. },
  1027. checkboxT(row, index) {
  1028. var array = [];
  1029. this.tableDataInfos.map((item) => {
  1030. if (item.type === this.radio) {
  1031. array.push(item.CodeId);
  1032. }
  1033. });
  1034. if (
  1035. array.indexOf(
  1036. this.radio === 1
  1037. ? row.moduleId
  1038. : this.radio === 2
  1039. ? row.chapterId
  1040. : row.sectionId
  1041. ) !== -1
  1042. ) {
  1043. return false;
  1044. } else {
  1045. return true;
  1046. }
  1047. },
  1048. submitForm() {
  1049. if (this.activeLists.length === 0) {
  1050. this.dialogVisible = false;
  1051. return;
  1052. }
  1053. var array = [];
  1054. if (this.tableDataInfos.length) {
  1055. if (this.radio === 1) {
  1056. this.activeLists.map((item) => {
  1057. array.push({
  1058. id: 1 + "-" + item.moduleId,
  1059. CodeId: item.moduleId,
  1060. name: item.moduleName,
  1061. isDels: true,
  1062. hasChildren: true,
  1063. type: 1,
  1064. sort: 0,
  1065. });
  1066. });
  1067. } else if (this.radio === 2) {
  1068. this.activeLists.map((item) => {
  1069. array.push({
  1070. id: 2 + "-" + item.chapterId,
  1071. CodeId: item.chapterId,
  1072. name: item.name,
  1073. isDels: true,
  1074. hasChildren: true,
  1075. type: 2,
  1076. sort: 0,
  1077. });
  1078. });
  1079. } else if (this.radio === 3) {
  1080. this.activeLists.map((item) => {
  1081. array.push({
  1082. id: 3 + "-" + item.sectionId,
  1083. CodeId: item.sectionId,
  1084. name: item.name,
  1085. type: 3,
  1086. sort: 0,
  1087. isDels: true,
  1088. });
  1089. });
  1090. }
  1091. let maxIndex = 0;
  1092. this.tableDataInfos.forEach((item) => {
  1093. if (item.sort > maxIndex) {
  1094. maxIndex = item.sort;
  1095. }
  1096. });
  1097. array.forEach((item, index) => {
  1098. item.sort = maxIndex + index + 1;
  1099. });
  1100. } else {
  1101. if (this.radio === 1) {
  1102. this.activeLists.map((item) => {
  1103. array.push({
  1104. id: 1 + "-" + item.moduleId,
  1105. CodeId: item.moduleId,
  1106. name: item.moduleName,
  1107. isDels: true,
  1108. hasChildren: true,
  1109. type: 1,
  1110. sort: 0,
  1111. });
  1112. });
  1113. } else if (this.radio === 2) {
  1114. this.activeLists.map((item) => {
  1115. array.push({
  1116. id: 2 + "-" + item.chapterId,
  1117. CodeId: item.chapterId,
  1118. name: item.name,
  1119. isDels: true,
  1120. hasChildren: true,
  1121. type: 2,
  1122. sort: 0,
  1123. });
  1124. });
  1125. } else if (this.radio === 3) {
  1126. this.activeLists.map((item) => {
  1127. array.push({
  1128. id: 3 + "-" + item.sectionId,
  1129. CodeId: item.sectionId,
  1130. name: item.name,
  1131. type: 3,
  1132. sort: 0,
  1133. isDels: true,
  1134. });
  1135. });
  1136. }
  1137. array.forEach((item, index) => {
  1138. item.sort = index + 1;
  1139. });
  1140. }
  1141. for (let i = 0; i < array.length; i++) {
  1142. this.tableDataInfos.unshift(array[i]);
  1143. }
  1144. // this.tableDataInfos = this.tableDataInfos.concat(array);
  1145. this.activeLists = [];
  1146. this.dialogVisible = false;
  1147. this.$message.success("添加成功");
  1148. },
  1149. handleNodeClick() {},
  1150. async load(node, resolve) {
  1151. const tree = node.data;
  1152. if (tree.type === 1) {
  1153. var arrays = [];
  1154. await this.$api
  1155. .inquireCourseListmodulechapter(tree.CodeId)
  1156. .then((res) => {
  1157. res.data.map((item, index) => {
  1158. var arr = {
  1159. id: tree.id + "-" + item.chapterId,
  1160. CodeId: item.chapterId,
  1161. name: item.name,
  1162. hasChildren: true,
  1163. type: 2,
  1164. };
  1165. arrays.push(arr);
  1166. });
  1167. });
  1168. resolve(arrays);
  1169. }
  1170. if (tree.type === 2) {
  1171. this.$api.inquireCoursechaptersectionlist(tree.CodeId).then((res) => {
  1172. var arrays = [];
  1173. res.data.map((item, index) => {
  1174. var arr = {
  1175. id: tree.id + "-" + item.sectionId,
  1176. CodeId: item.sectionId,
  1177. name: item.name,
  1178. type: 3,
  1179. };
  1180. arrays.push(arr);
  1181. });
  1182. resolve(arrays);
  1183. });
  1184. }
  1185. if (tree.type === 3) {
  1186. resolve([]);
  1187. }
  1188. return;
  1189. },
  1190. handleSizeChange(v) {
  1191. this.formData5.pageSize = v;
  1192. this.formData5.pageNum = 1;
  1193. this.getInfos();
  1194. },
  1195. handleCurrentChange(v) {
  1196. this.formData5.pageNum = v;
  1197. this.getInfos();
  1198. },
  1199. handleSizeChange6(v) {
  1200. this.formData6.pageSize = v;
  1201. this.formData6.pageNum = 1;
  1202. this.getSJ();
  1203. },
  1204. handleCurrentChange6(v) {
  1205. this.formData6.pageNum = v;
  1206. this.getSJ();
  1207. },
  1208. init6() {
  1209. this.getSJ(2);
  1210. },
  1211. selectAll(value) {
  1212. this.activeLists = value;
  1213. },
  1214. select(value) {
  1215. this.activeLists = value;
  1216. },
  1217. backPage() {
  1218. this.$store.dispatch("tagsView/delView", this.$route).then((res) => {
  1219. this.$router.push({
  1220. path: "courseManagement",
  1221. });
  1222. });
  1223. },
  1224. submit() {
  1225. this.disabledBtn = true;
  1226. var array = [];
  1227. this.tableDataInfos.map((item) => {
  1228. array.push({
  1229. courseId: Number(this.$route.query.id),
  1230. menuId: item.CodeId,
  1231. parentId: 0,
  1232. status: 1,
  1233. type: item.type,
  1234. sort: item.sort,
  1235. });
  1236. });
  1237. var data = {
  1238. courseId: Number(this.$route.query.id),
  1239. menuExamList: this.menuExamList,
  1240. menuList: array,
  1241. };
  1242. this.$api
  1243. .editCoursemenu(data)
  1244. .then((res) => {
  1245. this.$message.success("编辑成功");
  1246. setTimeout(() => {
  1247. this.$store
  1248. .dispatch("tagsView/exitView", this.$route)
  1249. .then((res) => {
  1250. this.$router.push({
  1251. path: "courseManagement",
  1252. });
  1253. });
  1254. }, 300);
  1255. })
  1256. .catch(() => {
  1257. this.disabledBtn = false;
  1258. });
  1259. },
  1260. },
  1261. };
  1262. </script>
  1263. <style lang="less" scoped>
  1264. .fatherSty {
  1265. background-color: #eee;
  1266. padding: 10px;
  1267. margin-bottom: 15px;
  1268. }
  1269. .floatLefts {
  1270. font-size: 14px;
  1271. float: left;
  1272. margin-right: 30px;
  1273. }
  1274. .mar_b {
  1275. display: flex;
  1276. align-items: center;
  1277. justify-content: space-between;
  1278. margin-bottom: 12px;
  1279. }
  1280. .dis-f {
  1281. margin-top: 20px;
  1282. display: flex;
  1283. align-items: center;
  1284. justify-content: center;
  1285. }
  1286. /deep/.el-tree-node__content {
  1287. height: 35px;
  1288. }
  1289. .custom-tree-node {
  1290. flex: 1;
  1291. display: flex;
  1292. align-items: center;
  1293. justify-content: space-between;
  1294. padding-right: 8px;
  1295. }
  1296. /deep/.el-button {
  1297. border-radius: 8px;
  1298. }
  1299. /deep/.el-dialog {
  1300. border-radius: 8px;
  1301. .el-dialog__header {
  1302. padding: 0;
  1303. .hearders {
  1304. height: 40px;
  1305. display: flex;
  1306. align-items: center;
  1307. justify-content: space-between;
  1308. padding: 0px 18px 0px 20px;
  1309. border-bottom: 1px solid #e2e2e2;
  1310. .leftTitle {
  1311. font-size: 14px;
  1312. font-weight: bold;
  1313. color: #2f4378;
  1314. }
  1315. .rightBoxs {
  1316. display: flex;
  1317. align-items: center;
  1318. img {
  1319. width: 14px;
  1320. height: 14px;
  1321. margin-left: 13px;
  1322. cursor: pointer;
  1323. }
  1324. }
  1325. }
  1326. }
  1327. .el-dialog__footer {
  1328. padding: 0;
  1329. .dialog-footer {
  1330. padding: 0px 40px;
  1331. height: 70px;
  1332. border-top: 1px solid #e2e2e2;
  1333. display: flex;
  1334. align-items: center;
  1335. justify-content: flex-end;
  1336. }
  1337. }
  1338. }
  1339. </style>