index.vue 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403
  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. header-align="center"
  345. >
  346. <!-- :show-overflow-tooltip="true" -->
  347. <template slot-scope="scope">
  348. <el-popover
  349. v-if="item.scope === 'moreList'"
  350. placement="right-end"
  351. trigger="hover"
  352. >
  353. <ul>
  354. <li
  355. v-for="(items, indexs) in scope.row['businessList']"
  356. :key="indexs"
  357. >
  358. {{ getBusinessName(items, item) }}
  359. </li>
  360. </ul>
  361. <ul slot="reference" style="cursor: pointer;">
  362. <li
  363. v-for="(items, indexs) in scope.row['businessList'].slice(0, 3)"
  364. :key="indexs"
  365. >
  366. {{ getBusinessName(items, item) }}
  367. </li>
  368. 等{{ scope.row['businessList'].length }}份试卷
  369. </ul>
  370. </el-popover>
  371. <span v-else-if="item.scope === 'status'">{{
  372. scope.row[item.prop] === 1
  373. ? "发布"
  374. : scope.row[item.prop] === 0
  375. ? "未发布"
  376. : "未知"
  377. }}</span>
  378. <span v-else>{{ scope.row[item.prop] }}</span></template
  379. >
  380. </el-table-column></template
  381. >
  382. </el-table>
  383. <pagination
  384. :total="total6"
  385. :pageSize="formData6.pageSize"
  386. :currentPage="formData6.pageNum"
  387. @handleSizeChange="handleSizeChange6"
  388. @handleCurrentChange="handleCurrentChange6"
  389. />
  390. </div>
  391. <span slot="footer" class="dialog-footer">
  392. <el-button @click="closePZ">取 消</el-button>
  393. <el-button type="primary" @click="submitPZ">确 定</el-button>
  394. </span>
  395. </el-dialog>
  396. <test-paper-preview ref="testPaperPreview" />
  397. <video-preview ref="preview" />
  398. <preference ref="preference" :tableDataInfos.sync="tableDataInfos" />
  399. </div>
  400. </template>
  401. <script>
  402. import searchBoxNew from "@/components/searchBoxNew";
  403. import pagination from "@/components/pagination";
  404. import testPaperPreview from "@/components/testPaperPreview";
  405. import videoPreview from "@/components/videoPreview";
  406. import preference from "./preference";
  407. export default {
  408. name: "ChapterContent",
  409. components: {
  410. searchBoxNew,
  411. pagination,
  412. testPaperPreview,
  413. videoPreview,
  414. preference,
  415. },
  416. data() {
  417. return {
  418. disabledBtn: false,
  419. sortTablesBoxs: false,
  420. activeName: "second",
  421. status: false,
  422. tableDataExam: [],
  423. tableListExam: [
  424. {
  425. label: "试卷编码",
  426. prop: "code",
  427. width: "120px",
  428. },
  429. {
  430. label: "标题前缀",
  431. prop: "prefixName",
  432. width: "160px",
  433. },
  434. {
  435. label: "试卷标题",
  436. prop: "examName",
  437. width: "300px",
  438. },
  439. {
  440. label: "业务层级",
  441. prop1: "educationName",
  442. prop2: "projectName",
  443. prop3: "businessName",
  444. prop4: "subjectName",
  445. scope: "moreList",
  446. width: "300px",
  447. },
  448. {
  449. label: "发布状态",
  450. prop: "publishStatus",
  451. scope: "status",
  452. },
  453. ],
  454. templateRadioLS: "",
  455. goodsNameLS: "",
  456. templateRadio: "",
  457. goodsName: "",
  458. menuExamList: [], //关联试卷列表
  459. onlyId: "",
  460. newShowObj: {}, //当前关联题卷OBJ
  461. dialogVisiblePZDown: false,
  462. aboutExamStatus: false, //关联试卷弹出
  463. centerDialogVisible: false,
  464. radio: "",
  465. headerData: [
  466. {
  467. label: "课程名称",
  468. prop: "courseName",
  469. },
  470. {
  471. label: "业务层次",
  472. prop1: "projectName",
  473. prop2: "businessName",
  474. scope: "more",
  475. },
  476. {
  477. label: "所属院校",
  478. prop: "schoolName",
  479. },
  480. // {
  481. // label: "所属专业",
  482. // prop: "categoryName",
  483. // },
  484. {
  485. label: "科目",
  486. prop: "subjectName",
  487. },
  488. ],
  489. pageInfo: {},
  490. tableData: [],
  491. tableDataInfos: [],
  492. tableSet: [
  493. { label: "编码", prop: "code", width: "120" },
  494. { label: "标题前缀", prop: "prefixName", width: "160" },
  495. {
  496. label: "标题",
  497. prop: "moduleName",
  498. prop1: "name",
  499. scope: "teshu",
  500. width: "300",
  501. },
  502. {
  503. label: "发布状态",
  504. prop: "publishStatus",
  505. scope: "Status",
  506. },
  507. ],
  508. dialogVisible: false,
  509. boxtableData: [],
  510. activeLists: [],
  511. total5: 0, //一共多少条
  512. formData5: {
  513. pageSize: 10,
  514. pageNum: 1,
  515. status: 1,
  516. publishStatus: 1,
  517. name: "",
  518. key: "",
  519. },
  520. formList5: [],
  521. total6: 0,
  522. formData6: {
  523. pageSize: 10,
  524. pageNum: 1,
  525. status: 1,
  526. publishStatus: 1,
  527. name: "",
  528. key: "",
  529. },
  530. formList6: [
  531. {
  532. placeholder: "试卷标题/试卷编码/标题前缀",
  533. prop: "key",
  534. },
  535. ],
  536. theModuleList: [],
  537. theChapterList: [],
  538. theSectionList: [],
  539. sortList: [],
  540. noStudent: true,
  541. layoutTreeProps: {
  542. label(data, node) {
  543. return data.name;
  544. },
  545. isLeaf(data, node) {
  546. return data.hasChildren ? false : true;
  547. },
  548. },
  549. activeArray: [],
  550. nowActiveCheck: [], //当前选中复选框
  551. nowActiveCheckObj: {}, //当前选中单选框
  552. ActiveExamType: null, //当前关联类型
  553. };
  554. },
  555. computed: {
  556. /**
  557. * 查询是否关联试卷
  558. */
  559. getShowStatus: function () {
  560. return function (item) {
  561. var ints = item.id.split("-").map(Number);
  562. if (ints[0] === 1) {
  563. var atys = `${ints[1]}-${ints[2] || 0}-${ints[3] || 0}`;
  564. }
  565. if (ints[0] === 2) {
  566. var atys = `0-${ints[1]}-${ints[2] || 0}`;
  567. }
  568. if (ints[0] === 3) {
  569. var atys = `0-0-${ints[1]}`;
  570. }
  571. var setTs = this.menuExamList.some((items) => {
  572. return items.onlyId == atys;
  573. });
  574. return setTs;
  575. };
  576. },
  577. // 获取业务层次列全称
  578. getBusinessName: function() {
  579. return function(items, item) {
  580. return `${items[item.prop1]}-${items[item.prop2]}-${items[item.prop3]}-${items[item.prop4]}`
  581. }
  582. }
  583. },
  584. mounted() {
  585. this.$api
  586. .gradecheckGoodsChange({ courseId: this.$route.query.id })
  587. .then((res) => {
  588. if (res.data > 0) {
  589. // this.noStudent = false;
  590. }
  591. });
  592. // this.getDs();
  593. this.search();
  594. },
  595. methods: {
  596. openPreferenceBoxs() {
  597. this.$refs.preference.openBoxs(
  598. JSON.parse(JSON.stringify(this.tableDataInfos))
  599. );
  600. },
  601. allowDrag(node) {
  602. if (node.level == 1) {
  603. return true;
  604. } else {
  605. return false;
  606. }
  607. },
  608. allowDrop(draggingNode, dropNode, type) {
  609. if (
  610. (type === "prev" || type === "next") &&
  611. draggingNode.level == 1 &&
  612. dropNode.level == 1
  613. ) {
  614. return true;
  615. }
  616. },
  617. selectionChangeExam(a) {
  618. this.nowActiveCheck = a;
  619. },
  620. preview(node, data) {
  621. if (data.type === 1 || data.type === 2) {
  622. var ints = data.id.split("-").map(Number);
  623. if (ints[0] === 1) {
  624. var atys = `${ints[1]}-${ints[2] || 0}-${ints[3] || 0}`;
  625. }
  626. if (ints[0] === 2) {
  627. var atys = `0-${ints[1]}-${ints[2] || 0}`;
  628. }
  629. if (ints[0] === 3) {
  630. var atys = `0-0-${ints[1]}`;
  631. }
  632. if (this.menuExamList.some((items) => items.onlyId == atys)) {
  633. const array = this.menuExamList.filter((item) => item.onlyId == atys);
  634. this.$refs.testPaperPreview.openBox(1, array);
  635. }
  636. }
  637. if (data.type === 3) {
  638. this.$api.obtainCourseSection(data.CodeId).then((res) => {
  639. this.$refs.preview.diavosFun(res.data);
  640. });
  641. }
  642. },
  643. initSort() {
  644. this.sortList = JSON.parse(JSON.stringify(this.tableDataInfos));
  645. },
  646. submitTableBoxs() {
  647. let arr = this.sortList.map((items) => {
  648. return items.sort;
  649. });
  650. if (new Set(arr).size != arr.length) {
  651. this.$message.warning("排序不允许有重复值");
  652. return;
  653. }
  654. this.tableDataInfos = this.sortList.sort((a, b) => a.sort - b.sort);
  655. this.sortTablesBoxs = false;
  656. },
  657. openSortBoxs() {
  658. this.sortList = JSON.parse(JSON.stringify(this.tableDataInfos));
  659. this.sortTablesBoxs = true;
  660. },
  661. openExamBoxs() {
  662. this.getSJ(2);
  663. if (this.ActiveExamType === 3) {
  664. if (this.activeArray.length === 0) {
  665. this.nowActiveCheckObj = {};
  666. } else {
  667. this.nowActiveCheckObj = JSON.parse(
  668. JSON.stringify(this.activeArray[0])
  669. );
  670. }
  671. } else {
  672. this.nowActiveCheck = [];
  673. }
  674. this.dialogVisiblePZDown = true;
  675. this.$nextTick(() => {
  676. this.$refs.tableExam.clearSelection();
  677. });
  678. },
  679. //单选触发
  680. getTemplateRow(index, row) {
  681. this.nowActiveCheckObj = row;
  682. console.log(row.examId, this.nowActiveCheckObj.examId);
  683. },
  684. //2确定变化选项
  685. submitPZ() {
  686. if (this.ActiveExamType !== 3) {
  687. this.activeArray.push(...this.nowActiveCheck);
  688. } else {
  689. this.activeArray = [this.nowActiveCheckObj];
  690. }
  691. this.dialogVisiblePZDown = false;
  692. },
  693. closePZ() {
  694. this.dialogVisiblePZDown = false;
  695. },
  696. //1确定关联试卷弹窗
  697. submitExam() {
  698. if (this.ActiveExamType === 3 && this.activeArray.length > 1) {
  699. this.$message.error("只允许关联一张试卷");
  700. return;
  701. }
  702. this.menuExamList = this.menuExamList.filter(
  703. (item) => item.onlyId != this.onlyId
  704. );
  705. if (this.activeArray.length !== 0) {
  706. let ast = this.onlyId.split("-").map(Number);
  707. var newList = this.activeArray.map((item) => {
  708. return {
  709. onlyId: this.onlyId,
  710. courseId: Number(this.$route.query.id),
  711. moduleId: ast[0],
  712. chapterId: ast[1],
  713. sectionId: ast[2],
  714. examId: item.examId,
  715. examName: item.examName,
  716. };
  717. });
  718. this.menuExamList.push(...newList);
  719. }
  720. this.aboutExamStatus = false;
  721. },
  722. //开启关联试卷盒子
  723. openExamBox(node, item) {
  724. var ints = item.id.split("-").map(Number);
  725. if (ints[0] === 1) {
  726. var atys = `${ints[1]}-${ints[2] || 0}-${ints[3] || 0}`;
  727. }
  728. if (ints[0] === 2) {
  729. var atys = `0-${ints[1]}-${ints[2] || 0}`;
  730. }
  731. if (ints[0] === 3) {
  732. var atys = `0-0-${ints[1]}`;
  733. }
  734. if (this.menuExamList.some((i) => i.onlyId == atys)) {
  735. this.activeArray = this.menuExamList.filter(
  736. (items) => items.onlyId == atys
  737. );
  738. } else {
  739. this.activeArray = [];
  740. }
  741. this.onlyId = atys;
  742. this.ActiveExamType = item.type;
  743. this.aboutExamStatus = true;
  744. },
  745. //关闭关联试卷盒子
  746. closeExam() {
  747. this.aboutExamStatus = false;
  748. },
  749. search() {
  750. this.$api.obtainCourseS(this.$route.query.id).then((res) => {
  751. this.pageInfo = res.data;
  752. });
  753. this.$api
  754. .inquireCoursemenuListS({ courseId: this.$route.query.id })
  755. .then((res) => {
  756. this.tableData = res.rows;
  757. this.changeApis();
  758. this.getList();
  759. });
  760. },
  761. getList() {
  762. this.$api
  763. .inquireCourseListSmenuexam({ courseId: this.$route.query.id })
  764. .then((res) => {
  765. res.rows.forEach((item) => {
  766. item.onlyId = `${item.moduleId || 0}-${item.chapterId || 0}-${
  767. item.sectionId || 0
  768. }`;
  769. });
  770. this.menuExamList = res.rows;
  771. });
  772. },
  773. getDs() {
  774. this.$api.inquireCourseListmodule({ status: 1 }).then((res) => {
  775. this.theModuleList = res.rows;
  776. });
  777. this.$api.inquireCourseListchapter({ status: 1 }).then((res) => {
  778. this.theChapterList = res.rows;
  779. });
  780. this.$api.inquireCourseSection({ status: 1 }).then((res) => {
  781. this.theSectionList = res.rows;
  782. });
  783. },
  784. getSJ(int) {
  785. if (int === 1) {
  786. this.formData6.pageNum = 1;
  787. }
  788. if (int === 2) {
  789. this.formData6.name = "";
  790. this.formData6.key = "";
  791. this.formData6.pageNum = 1;
  792. this.formData6.pageSize = 10;
  793. }
  794. var data = JSON.parse(JSON.stringify(this.formData6));
  795. data.businessId = this.pageInfo.businessId;
  796. data.subjectId = this.pageInfo.subjectId;
  797. data.name = this.formData6.name;
  798. data.exclude = 1;
  799. this.$api.inquirebankexamList(data).then((res) => {
  800. this.tableDataExam = res.rows;
  801. this.total6 = res.total;
  802. });
  803. },
  804. openBoxs() {
  805. this.radio = "";
  806. this.centerDialogVisible = true;
  807. },
  808. activeCheckBoxs() {
  809. var self = this;
  810. if (!this.radio) {
  811. this.$message.error("请选择添加类型");
  812. return;
  813. }
  814. if (this.radio === 1) {
  815. this.formList5 = [
  816. {
  817. placeholder: "模块标题/模块编码/标题前缀",
  818. prop: "key",
  819. },
  820. ];
  821. this.moduleApi(2);
  822. }
  823. if (this.radio === 2) {
  824. this.formList5 = [
  825. {
  826. placeholder: "章标题/章编码/标题前缀",
  827. prop: "key",
  828. },
  829. ];
  830. this.chapterApi(2);
  831. }
  832. if (this.radio === 3) {
  833. this.formList5 = [
  834. {
  835. placeholder: "节标题/节编码/标题前缀",
  836. prop: "key",
  837. },
  838. ];
  839. this.sectionApi(2);
  840. }
  841. this.centerDialogVisible = false;
  842. this.dialogVisible = true;
  843. this.$nextTick(function () {
  844. self.activeLists = [];
  845. self.$refs.multipleTable.clearSelection();
  846. });
  847. },
  848. init5() {
  849. this.getInfos(2);
  850. },
  851. getInfos(int) {
  852. if (this.radio === 1) {
  853. this.moduleApi(int);
  854. }
  855. if (this.radio === 2) {
  856. this.chapterApi(int);
  857. }
  858. if (this.radio === 3) {
  859. this.sectionApi(int);
  860. }
  861. },
  862. moduleApi(int) {
  863. if (int === 1) {
  864. this.formData5.pageNum = 1;
  865. }
  866. if (int === 2) {
  867. this.formData5.name = "";
  868. this.formData5.key = "";
  869. this.formData5.pageNum = 1;
  870. this.formData5.pageSize = 10;
  871. }
  872. var data = JSON.parse(JSON.stringify(this.formData5));
  873. data.businessId = this.pageInfo.businessId;
  874. data.subjectId = this.pageInfo.subjectId;
  875. data.name = this.formData5.name;
  876. this.$api.inquireCourseListmodule(data).then((res) => {
  877. this.boxtableData = res.rows;
  878. this.total5 = res.total;
  879. });
  880. },
  881. chapterApi(int) {
  882. if (int === 1) {
  883. this.formData5.pageNum = 1;
  884. }
  885. if (int === 2) {
  886. this.formData5.name = "";
  887. this.formData5.pageNum = 1;
  888. this.formData5.key = "";
  889. this.formData5.pageSize = 10;
  890. }
  891. var data = JSON.parse(JSON.stringify(this.formData5));
  892. data.businessId = this.pageInfo.businessId;
  893. data.subjectId = this.pageInfo.subjectId;
  894. data.name = this.formData5.name;
  895. this.$api.inquireCourseListchapter(data).then((res) => {
  896. this.boxtableData = res.rows;
  897. this.total5 = res.total;
  898. });
  899. },
  900. sectionApi(int) {
  901. if (int === 1) {
  902. this.formData5.pageNum = 1;
  903. }
  904. if (int === 2) {
  905. this.formData5.name = "";
  906. this.formData5.key = "";
  907. this.formData5.pageNum = 1;
  908. this.formData5.pageSize = 10;
  909. }
  910. var data = JSON.parse(JSON.stringify(this.formData5));
  911. data.businessId = this.pageInfo.businessId;
  912. data.subjectId = this.pageInfo.subjectId;
  913. data.name = this.formData5.name;
  914. this.$api.inquireCourseSection(data).then((res) => {
  915. this.boxtableData = res.rows;
  916. this.total5 = res.total;
  917. });
  918. },
  919. // 查询是否存在下级 模块
  920. quireModule(id) {
  921. return new Promise((resolve, reject) => {
  922. this.$api.inquireCourseListmodulechapter(id).then((result) => {
  923. if (result.data.length === 0) {
  924. resolve(false);
  925. } else {
  926. resolve(true);
  927. }
  928. });
  929. });
  930. },
  931. // 查询是否存在下级 章
  932. quireChapter(id) {
  933. return new Promise((resolve, reject) => {
  934. this.$api.inquireCoursechaptersectionlist(id).then((result) => {
  935. if (result.data.length === 0) {
  936. resolve(false);
  937. } else {
  938. resolve(true);
  939. }
  940. });
  941. });
  942. },
  943. changeApis() {
  944. //inquireCourseListmodulechapter 模块与章关系
  945. // inquireCoursechaptersectionlist 章与节关系
  946. var arrays = [];
  947. this.tableData.map((item, index) => {
  948. if (item.type === 1) {
  949. // this.$api.obtainCoursemodule(item.menuId).then(async (res) => {
  950. var arr = {
  951. id: "1-" + item.menuId,
  952. CodeId: item.menuId,
  953. name: item.menuName,
  954. hasChildren: true,
  955. type: 1,
  956. isDels: true,
  957. sort: item.sort,
  958. };
  959. //查询是否存在下级
  960. arrays.push(arr);
  961. // });
  962. }
  963. if (item.type === 2) {
  964. // this.$api.obtainCoursechapter(item.menuId).then(async (res) => {
  965. var arr = {
  966. id: "2-" + item.menuId,
  967. CodeId: item.menuId,
  968. name: item.menuName,
  969. hasChildren: true,
  970. type: 2,
  971. isDels: true,
  972. sort: item.sort,
  973. firstChoiceStatus: item.firstChoiceStatus || 0,
  974. };
  975. arrays.push(arr);
  976. // });
  977. }
  978. if (item.type === 3) {
  979. // this.$api.obtainCourseSection(item.menuId).then((res) => {
  980. var arr = {
  981. id: "3-" + item.menuId,
  982. CodeId: item.menuId,
  983. name: item.menuName,
  984. hasChildren: false,
  985. type: 3,
  986. isDels: true,
  987. sort: item.sort,
  988. };
  989. arrays.push(arr);
  990. // });
  991. }
  992. });
  993. this.$nextTick(() => {
  994. this.tableDataInfos = arrays;
  995. });
  996. },
  997. del(node, item) {
  998. this.tableDataInfos.map((items, indexs) => {
  999. if (items.id === item.id) {
  1000. this.tableDataInfos.splice(indexs, 1);
  1001. }
  1002. });
  1003. this.tableDataInfos = JSON.parse(JSON.stringify(this.tableDataInfos));
  1004. if (item.type === 1) {
  1005. this.menuExamList = this.menuExamList.filter((items) => {
  1006. return items.moduleId !== item.CodeId;
  1007. });
  1008. }
  1009. if (item.type === 2) {
  1010. this.menuExamList = this.menuExamList.filter((items) => {
  1011. if (items.moduleId === 0) {
  1012. if (items.chapterId !== item.CodeId) {
  1013. return true;
  1014. } else {
  1015. return false;
  1016. }
  1017. } else {
  1018. return true;
  1019. }
  1020. });
  1021. }
  1022. },
  1023. getRowKeys(row) {
  1024. if (this.radio === 1) {
  1025. return row.moduleId;
  1026. }
  1027. if (this.radio === 2) {
  1028. return row.chapterId;
  1029. }
  1030. if (this.radio === 3) {
  1031. return row.sectionId;
  1032. }
  1033. },
  1034. checkboxT(row, index) {
  1035. var array = [];
  1036. array = this.tableDataInfos.map((item) => {
  1037. if (item.type === this.radio) {
  1038. return item.CodeId;
  1039. }
  1040. });
  1041. if (
  1042. array.indexOf(
  1043. this.radio === 1
  1044. ? row.moduleId
  1045. : this.radio === 2
  1046. ? row.chapterId
  1047. : row.sectionId
  1048. ) !== -1
  1049. ) {
  1050. return false;
  1051. } else {
  1052. return true;
  1053. }
  1054. },
  1055. checkboxExam(row, index) {
  1056. return this.activeArray.findIndex((item) => item.examId == row.examId) ===
  1057. -1
  1058. ? true
  1059. : false;
  1060. },
  1061. submitForm() {
  1062. if (this.activeLists.length === 0) {
  1063. this.dialogVisible = false;
  1064. return;
  1065. }
  1066. var array = [];
  1067. if (this.tableDataInfos.length) {
  1068. if (this.radio === 1) {
  1069. this.activeLists.map((item) => {
  1070. array.push({
  1071. id: 1 + "-" + item.moduleId,
  1072. CodeId: item.moduleId,
  1073. name: item.moduleName,
  1074. isDels: true,
  1075. hasChildren: true,
  1076. type: 1,
  1077. sort: 0,
  1078. });
  1079. });
  1080. } else if (this.radio === 2) {
  1081. this.activeLists.map((item) => {
  1082. array.push({
  1083. id: 2 + "-" + item.chapterId,
  1084. CodeId: item.chapterId,
  1085. name: item.name,
  1086. isDels: true,
  1087. hasChildren: true,
  1088. type: 2,
  1089. sort: 0,
  1090. });
  1091. });
  1092. } else if (this.radio === 3) {
  1093. this.activeLists.map((item) => {
  1094. array.push({
  1095. id: 3 + "-" + item.sectionId,
  1096. CodeId: item.sectionId,
  1097. name: item.name,
  1098. type: 3,
  1099. sort: 0,
  1100. isDels: true,
  1101. });
  1102. });
  1103. }
  1104. let maxIndex = 0;
  1105. this.tableDataInfos.forEach((item) => {
  1106. if (item.sort > maxIndex) {
  1107. maxIndex = item.sort;
  1108. }
  1109. });
  1110. array.forEach((item, index) => {
  1111. item.sort = maxIndex + index + 1;
  1112. });
  1113. } else {
  1114. if (this.radio === 1) {
  1115. this.activeLists.map((item) => {
  1116. array.push({
  1117. id: 1 + "-" + item.moduleId,
  1118. CodeId: item.moduleId,
  1119. name: item.moduleName,
  1120. isDels: true,
  1121. hasChildren: true,
  1122. type: 1,
  1123. sort: 0,
  1124. });
  1125. });
  1126. } else if (this.radio === 2) {
  1127. this.activeLists.map((item) => {
  1128. array.push({
  1129. id: 2 + "-" + item.chapterId,
  1130. CodeId: item.chapterId,
  1131. name: item.name,
  1132. isDels: true,
  1133. hasChildren: true,
  1134. type: 2,
  1135. sort: 0,
  1136. });
  1137. });
  1138. } else if (this.radio === 3) {
  1139. this.activeLists.map((item) => {
  1140. array.push({
  1141. id: 3 + "-" + item.sectionId,
  1142. CodeId: item.sectionId,
  1143. name: item.name,
  1144. type: 3,
  1145. sort: 0,
  1146. isDels: true,
  1147. });
  1148. });
  1149. }
  1150. array.forEach((item, index) => {
  1151. item.sort = index + 1;
  1152. });
  1153. }
  1154. for (let i = 0; i < array.length; i++) {
  1155. this.tableDataInfos.unshift(array[i]);
  1156. }
  1157. // this.tableDataInfos = this.tableDataInfos.concat(array);
  1158. this.activeLists = [];
  1159. this.dialogVisible = false;
  1160. this.$message.success("添加成功");
  1161. },
  1162. handleNodeClick() {},
  1163. async load(node, resolve) {
  1164. const tree = node.data;
  1165. if (tree.type === 1) {
  1166. var arrays = [];
  1167. await this.$api
  1168. .inquireCourseListmodulechapter(tree.CodeId)
  1169. .then((res) => {
  1170. res.data.map((item, index) => {
  1171. var arr = {
  1172. id: tree.id + "-" + item.chapterId,
  1173. CodeId: item.chapterId,
  1174. name: item.name,
  1175. hasChildren: true,
  1176. type: 2,
  1177. };
  1178. arrays.push(arr);
  1179. });
  1180. });
  1181. resolve(arrays);
  1182. }
  1183. if (tree.type === 2) {
  1184. this.$api.inquireCoursechaptersectionlist(tree.CodeId).then((res) => {
  1185. var arrays = [];
  1186. res.data.map((item, index) => {
  1187. var arr = {
  1188. id: tree.id + "-" + item.sectionId,
  1189. CodeId: item.sectionId,
  1190. name: item.name,
  1191. type: 3,
  1192. };
  1193. arrays.push(arr);
  1194. });
  1195. resolve(arrays);
  1196. });
  1197. }
  1198. if (tree.type === 3) {
  1199. resolve([]);
  1200. }
  1201. return;
  1202. },
  1203. handleSizeChange(v) {
  1204. this.formData5.pageSize = v;
  1205. this.formData5.pageNum = 1;
  1206. this.getInfos();
  1207. },
  1208. handleCurrentChange(v) {
  1209. this.formData5.pageNum = v;
  1210. this.getInfos();
  1211. },
  1212. handleSizeChange6(v) {
  1213. this.formData6.pageSize = v;
  1214. this.formData6.pageNum = 1;
  1215. this.getSJ();
  1216. },
  1217. handleCurrentChange6(v) {
  1218. this.formData6.pageNum = v;
  1219. this.getSJ();
  1220. },
  1221. init6() {
  1222. this.getSJ(2);
  1223. },
  1224. /**
  1225. * 多选框变化触发
  1226. */
  1227. selectionChange(arr) {
  1228. this.activeLists = arr;
  1229. },
  1230. backPage() {
  1231. this.$store.dispatch("tagsView/delView", this.$route).then((res) => {
  1232. this.$router.push({
  1233. path: "courseManagement",
  1234. });
  1235. });
  1236. },
  1237. submit() {
  1238. this.disabledBtn = true;
  1239. var array = [];
  1240. this.tableDataInfos.map((item) => {
  1241. array.push({
  1242. courseId: Number(this.$route.query.id),
  1243. menuId: item.CodeId,
  1244. parentId: 0,
  1245. status: 1,
  1246. type: item.type,
  1247. sort: item.sort,
  1248. firstChoiceStatus: item.firstChoiceStatus || 0,
  1249. });
  1250. });
  1251. if (this.menuExamList && this.menuExamList.length > 0) {
  1252. this.menuExamList.forEach((item) => {
  1253. if (
  1254. item.moduleId != 0 &&
  1255. item.sectionId == 0 &&
  1256. item.chapterId == 0
  1257. ) {
  1258. item.type = 3;
  1259. } else if (item.sectionId != 0) {
  1260. item.type = 2;
  1261. } else {
  1262. item.type = 1;
  1263. }
  1264. });
  1265. }
  1266. var data = {
  1267. courseId: Number(this.$route.query.id),
  1268. menuExamList: this.menuExamList,
  1269. menuList: array,
  1270. };
  1271. this.$api
  1272. .editCoursemenu(data)
  1273. .then((res) => {
  1274. this.$message.success("编辑成功");
  1275. setTimeout(() => {
  1276. this.$store
  1277. .dispatch("tagsView/exitView", this.$route)
  1278. .then((res) => {
  1279. this.$router.push({
  1280. path: "courseManagement",
  1281. });
  1282. });
  1283. }, 300);
  1284. })
  1285. .catch(() => {
  1286. this.disabledBtn = false;
  1287. });
  1288. },
  1289. },
  1290. };
  1291. </script>
  1292. <style lang="less" scoped>
  1293. .radioTables {
  1294. border-radius: 50%;
  1295. width: 18px;
  1296. height: 18px;
  1297. border: 1px solid #eee;
  1298. background-color: #fff;
  1299. cursor: pointer;
  1300. position: relative;
  1301. & > .activeRadio {
  1302. position: absolute;
  1303. transition: all 0.3s;
  1304. left: 50%;
  1305. top: 50%;
  1306. transform: translateX(-50%) translateY(-50%);
  1307. width: 12px;
  1308. height: 12px;
  1309. border-radius: 50%;
  1310. overflow: hidden;
  1311. background-color: rgb(24, 144, 255);
  1312. animation: radios 0.3s;
  1313. }
  1314. }
  1315. @keyframes radios {
  1316. 0% {
  1317. opacity: 0;
  1318. }
  1319. 100% {
  1320. opacity: 1;
  1321. }
  1322. }
  1323. .fatherSty {
  1324. background-color: #eee;
  1325. padding: 10px;
  1326. margin-bottom: 15px;
  1327. }
  1328. .floatLefts {
  1329. font-size: 14px;
  1330. float: left;
  1331. margin-right: 30px;
  1332. }
  1333. .mar_b {
  1334. display: flex;
  1335. align-items: center;
  1336. justify-content: space-between;
  1337. margin-bottom: 12px;
  1338. }
  1339. .dis-f {
  1340. margin-top: 20px;
  1341. display: flex;
  1342. align-items: center;
  1343. justify-content: center;
  1344. }
  1345. /deep/.el-tree-node__content {
  1346. height: 35px;
  1347. }
  1348. .custom-tree-node {
  1349. flex: 1;
  1350. display: flex;
  1351. align-items: center;
  1352. justify-content: space-between;
  1353. padding-right: 8px;
  1354. }
  1355. /deep/.el-button {
  1356. border-radius: 8px;
  1357. }
  1358. /deep/.el-dialog {
  1359. border-radius: 8px;
  1360. .el-dialog__header {
  1361. padding: 0;
  1362. .hearders {
  1363. height: 40px;
  1364. display: flex;
  1365. align-items: center;
  1366. justify-content: space-between;
  1367. padding: 0px 18px 0px 20px;
  1368. border-bottom: 1px solid #e2e2e2;
  1369. .leftTitle {
  1370. font-size: 14px;
  1371. font-weight: bold;
  1372. color: #2f4378;
  1373. }
  1374. .rightBoxs {
  1375. display: flex;
  1376. align-items: center;
  1377. img {
  1378. width: 14px;
  1379. height: 14px;
  1380. margin-left: 13px;
  1381. cursor: pointer;
  1382. }
  1383. }
  1384. }
  1385. }
  1386. .el-dialog__footer {
  1387. padding: 0;
  1388. .dialog-footer {
  1389. padding: 0px 40px;
  1390. height: 70px;
  1391. border-top: 1px solid #e2e2e2;
  1392. display: flex;
  1393. align-items: center;
  1394. justify-content: flex-end;
  1395. }
  1396. }
  1397. }
  1398. </style>