index.vue 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045
  1. <template>
  2. <div id="topicManagement">
  3. <search-box-new
  4. ref="searchBox"
  5. :formData="formData"
  6. :formList="formList"
  7. @search="search"
  8. @init="init"
  9. />
  10. <table-list
  11. :tableSets="tableSet"
  12. :tableData="tableData"
  13. :navText="navText"
  14. @addClick="addClick"
  15. :loading="loading"
  16. @editInfo="editInfo"
  17. ref="tableList"
  18. rowKey="questionId"
  19. >
  20. <template slot="customize">
  21. <el-button size="medium" @click="dialogDRword = true" type="success"
  22. >Word批量导入</el-button
  23. ><el-button size="medium" @click="dialogDRexcel = true" type="success"
  24. >Excel批量导入</el-button
  25. ><el-button size="medium" @click="batchDel" type="warning"
  26. >批量删除</el-button
  27. >
  28. </template>
  29. <template slot="btn" slot-scope="props">
  30. <el-button type="text" @click="addClick(props.scope.row, 0)"
  31. >修改</el-button
  32. >
  33. <el-button type="text" @click="del(props.scope.row)">删除</el-button>
  34. </template>
  35. </table-list>
  36. <pagination
  37. :total="total"
  38. :pageSize="formData.pageSize"
  39. :currentPage="formData.pageNum"
  40. @handleSizeChange="handleSizeChange"
  41. @handleCurrentChange="handleCurrentChange"
  42. />
  43. <!-- ------------------- -->
  44. <el-dialog
  45. @closed="clearData"
  46. :visible.sync="dialogDRword"
  47. :append-to-body="true"
  48. width="780px"
  49. :show-close="false"
  50. :close-on-click-modal="false"
  51. >
  52. <div slot="title" class="hearders">
  53. <div class="leftTitle">批量导入</div>
  54. <div class="rightBoxs">
  55. <img
  56. src="@/assets/images/Close@2x.png"
  57. alt=""
  58. @click="dialogDRword = false"
  59. />
  60. </div>
  61. </div>
  62. <word-pop @search="search" ref="wordpop" />
  63. <span slot="footer" class="dialog-footer">
  64. <el-button @click="dialogDRword = false">取 消</el-button>
  65. </span>
  66. </el-dialog>
  67. <el-dialog
  68. :visible.sync="dialogDRexcel"
  69. :append-to-body="true"
  70. width="780px"
  71. :show-close="false"
  72. :close-on-click-modal="false"
  73. >
  74. <div slot="title" class="hearders">
  75. <div class="leftTitle">批量导入</div>
  76. <div class="rightBoxs">
  77. <img
  78. src="@/assets/images/Close@2x.png"
  79. alt=""
  80. @click="dialogDRexcel = false"
  81. />
  82. </div>
  83. </div>
  84. <excel-pop @search="search" />
  85. <span slot="footer" class="dialog-footer">
  86. <el-button @click="dialogDRexcel = false">取 消</el-button>
  87. </span>
  88. </el-dialog>
  89. <el-dialog
  90. @closed="loadingClose"
  91. width="1180px"
  92. :visible.sync="innerVisiblePaperTopic"
  93. append-to-body
  94. :show-close="false"
  95. :fullscreen="fullscreenChildPaperTopic"
  96. :close-on-click-modal="false"
  97. >
  98. <div slot="title" class="hearders">
  99. <div class="leftTitle">
  100. {{ statusPop === 1 ? "添加" : statusPop === 0 ? "修改" : "详情" }}
  101. </div>
  102. <div class="rightBoxs">
  103. <img
  104. src="@/assets/images/Max@2x.png"
  105. alt=""
  106. @click="fullscreenChildPaperTopic = !fullscreenChildPaperTopic"
  107. />
  108. <img src="@/assets/images/Close@2x.png" alt="" @click="closeBefore" />
  109. </div>
  110. </div>
  111. <div v-if="statusHide">
  112. <busIns
  113. @amdis="changeAmdis"
  114. ref="sujects"
  115. :sujectApisTable="sujectApis"
  116. :newSujectApisTable="newSujectApis"
  117. :typeBus="typeBus"
  118. />
  119. <el-form
  120. label-position="right"
  121. label-width="110px"
  122. :model="listData"
  123. ref="listData"
  124. :rules="rulesTest"
  125. >
  126. <el-form-item
  127. v-for="(items, indexs) in listitem"
  128. :key="indexs"
  129. :label="items.label"
  130. :prop="items.prop"
  131. >
  132. <div v-if="items.scope === 'bussing'">
  133. <div v-if="!activeExam.length">请在下面输入框添加知识点</div>
  134. <ul v-else class="BusBoxs">
  135. <li
  136. class="fot_Le"
  137. v-for="(item, index) in activeExam"
  138. :key="index"
  139. >
  140. {{ item.knowledgeName }}
  141. <i
  142. class="el-icon-error icon_clear"
  143. @click="clearBusName(index)"
  144. ></i>
  145. </li>
  146. <div style="clear: both"></div>
  147. </ul>
  148. <el-select
  149. v-model="value"
  150. placeholder="请选择知识点"
  151. @change="changeKnow"
  152. >
  153. <el-option
  154. v-for="item in options"
  155. :key="item.knowledgeId"
  156. :label="item.knowledgeName"
  157. :value="item.knowledgeId"
  158. :disabled="comLs(item)"
  159. >
  160. </el-option>
  161. </el-select>
  162. <!-- <el-button @click="addExam">自定义添加</el-button> -->
  163. </div>
  164. <el-radio-group
  165. v-else-if="items.scope === 'radio'"
  166. v-model="listData[items.prop]"
  167. >
  168. <el-radio :label="1">发布</el-radio>
  169. <el-radio :label="0">未发布</el-radio>
  170. </el-radio-group>
  171. <el-input
  172. v-model="listData[items.prop]"
  173. v-else
  174. ></el-input> </el-form-item
  175. ></el-form>
  176. <questionBank
  177. v-for="(item, index) in listNums"
  178. :key="index"
  179. :dingFormInfo="item"
  180. :nums="index"
  181. ref="child"
  182. />
  183. </div>
  184. <span slot="footer" class="dialog-footer">
  185. <el-button @click="closeBefore">关 闭</el-button>
  186. <el-button
  187. @click="submitForm('listData')"
  188. :loading="disabledBtn"
  189. v-if="statusPop === 1 || statusPop === 0"
  190. >完成</el-button
  191. >
  192. <el-button
  193. type="primary"
  194. v-if="statusPop === 1"
  195. :loading="disabledBtn"
  196. @click="submitForm('listData', 1)"
  197. >完成,并继续添加</el-button
  198. >
  199. </span>
  200. </el-dialog>
  201. <el-dialog
  202. :visible.sync="dialogVisible"
  203. :append-to-body="true"
  204. width="780px"
  205. :show-close="false"
  206. :close-on-click-modal="false"
  207. >
  208. <div slot="title" class="hearders">
  209. <div class="leftTitle">添加</div>
  210. <div class="rightBoxs">
  211. <img src="@/assets/images/Close@2x.png" alt="" @click="closeBoxs" />
  212. </div>
  213. </div>
  214. <div>
  215. <el-form label-position="right" label-width="110px">
  216. <el-form-item label="知识点">
  217. <div>
  218. <div v-if="!BusNameList.length">请在下面输入框添加知识点</div>
  219. <ul v-else class="BusBoxs">
  220. <li
  221. class="fot_Le"
  222. v-for="(item, index) in BusNameList"
  223. :key="index"
  224. >
  225. {{ item }}
  226. <i
  227. class="el-icon-error icon_clear"
  228. @click="clearBus(index)"
  229. ></i>
  230. </li>
  231. <div style="clear: both"></div>
  232. </ul>
  233. <el-input
  234. style="width: 40%; margin-right: 10px"
  235. v-model="BusName"
  236. ></el-input
  237. ><el-button @click="addBusName">添加</el-button>
  238. </div></el-form-item
  239. ></el-form
  240. >
  241. </div>
  242. <span slot="footer" class="dialog-footer">
  243. <el-button @click="closeBoxs">取 消</el-button>
  244. <el-button type="primary" @click="submit">确 定</el-button>
  245. </span>
  246. </el-dialog>
  247. </div>
  248. </template>
  249. <script>
  250. import searchBoxNew from "@/components/searchBoxNew";
  251. import tableList from "@/components/tableList";
  252. import pagination from "@/components/pagination";
  253. import busIns from "@/components/busIns";
  254. import questionBank from "@/components/questionBank";
  255. import wordPop from "./wordPop.vue";
  256. import excelPop from "./excelPop.vue";
  257. export default {
  258. components: {
  259. questionBank,
  260. busIns,
  261. tableList,
  262. pagination,
  263. searchBoxNew,
  264. wordPop,
  265. excelPop,
  266. },
  267. name: "TopicManagement",
  268. data() {
  269. return {
  270. dialogDRword: false,
  271. dialogDRexcel: false,
  272. disabledBtn: false,
  273. statusHide: false,
  274. loading: false, //当前表单加载是否加载动画
  275. navText: {
  276. title: "题目管理",
  277. index: 0,
  278. ch: "条",
  279. num: false,
  280. border: true,
  281. choice: true,
  282. addHide: false,
  283. openCheckMore: true,
  284. backFatherBtn: {
  285. status: false,
  286. title: "未定义",
  287. },
  288. },
  289. //搜索
  290. formList: [
  291. {
  292. prop: "educationTypeId",
  293. placeholder: "教育类型",
  294. scope: "educationType",
  295. },
  296. {
  297. prop: "businessId",
  298. placeholder: "业务层次",
  299. scope: "businessLevel",
  300. edu: "educationTypeId",
  301. },
  302. {
  303. prop: "subjectId",
  304. placeholder: "科目",
  305. scope: "sujectType",
  306. edu: "educationTypeId",
  307. },
  308. {
  309. prop: "prefixName",
  310. placeholder: "请输入标题前缀",
  311. },
  312. {
  313. prop: "type",
  314. placeholder: "题目类型",
  315. scope: "selectBank",
  316. },
  317. {
  318. prop: "publishStatus",
  319. placeholder: "发布状态",
  320. scope: "select",
  321. options: [
  322. {
  323. label: "已发布",
  324. value: 1,
  325. },
  326. {
  327. label: "未发布",
  328. value: 0,
  329. },
  330. ],
  331. },
  332. {
  333. prop: "key",
  334. placeholder: "题目编码/标题前缀/题目标题",
  335. },
  336. ],
  337. formData: {
  338. status: "0,1",
  339. pageSize: 10,
  340. pageNum: 1,
  341. },
  342. // 表单
  343. tableSet: [
  344. {
  345. label: "题目编码",
  346. prop: "code",
  347. hidden: false,
  348. },
  349. {
  350. label: "题目类型",
  351. prop: "type",
  352. hidden: true,
  353. scope: "topic",
  354. },
  355. {
  356. label: "标题前缀",
  357. prop: "prefixName",
  358. hidden: false,
  359. },
  360. {
  361. label: "题目详细",
  362. prop: "content",
  363. hidden: true,
  364. scope: "htmlInfo",
  365. width: "600px",
  366. dontCenter: true,
  367. },
  368. {
  369. label: "知识点",
  370. prop: "knowledgeList",
  371. hidden: false,
  372. scope: "knowledge",
  373. showTooltip: true,
  374. },
  375. {
  376. label: "适用业务层级",
  377. prop: "businessList",
  378. hidden: false,
  379. scope: "mapTypesMores",
  380. },
  381. {
  382. label: "最后编辑时间",
  383. prop: "updateTime",
  384. scope: "aTimeList",
  385. hidden: false,
  386. },
  387. {
  388. label: "创建时间",
  389. prop: "createTime",
  390. scope: "aTimeList",
  391. hidden: false,
  392. },
  393. {
  394. label: "发布状态",
  395. prop: "publishStatus",
  396. hidden: true,
  397. scope: "isOptions",
  398. options: [
  399. {
  400. label: "已发布",
  401. value: 1,
  402. },
  403. {
  404. label: "未发布",
  405. value: 0,
  406. },
  407. ],
  408. },
  409. {
  410. label: "关联试卷",
  411. prop: "examList",
  412. prop1: "examName",
  413. hidden: false,
  414. scope: "aboutChapter",
  415. int: 5,
  416. },
  417. ],
  418. sujectApis: [],
  419. newSujectApis: [],
  420. tableData: [], //表单数据
  421. total: 0, //一共多少条
  422. //-----------------------------------------------
  423. dialogVisible: false,
  424. innerVisiblePaperTopic: false,
  425. fullscreenChildPaperTopic: false,
  426. statusPop: 1,
  427. dingForm: {},
  428. questionId: "",
  429. queryData: {},
  430. allOptions: [], //知识点列表
  431. options: [], //当前知识点列表
  432. activeExam: [], // 已选知识点列表
  433. value: "",
  434. BusName: "", //弹窗新增知识点输入框
  435. BusNameList: [],
  436. listNums: [],
  437. typeBus: 1,
  438. listData: {
  439. publishStatus: "",
  440. prefixName: "",
  441. },
  442. int: "",
  443. listitem: [
  444. {
  445. label: "标题前缀",
  446. prop: "prefixName",
  447. },
  448. {
  449. label: "知识点",
  450. scope: "bussing",
  451. },
  452. {
  453. label: "发布状态",
  454. prop: "publishStatus",
  455. scope: "radio",
  456. },
  457. ],
  458. rulesTest: {
  459. publishStatus: [
  460. { required: true, message: "请选择发布状态", trigger: "change" },
  461. ],
  462. },
  463. };
  464. },
  465. mounted() {
  466. this.getFns();
  467. this.search();
  468. },
  469. activated() {
  470. this.getFns();
  471. this.search();
  472. },
  473. methods: {
  474. batchDel() {
  475. if (!this.$refs.tableList.allCheckData.length) {
  476. this.$message.warning("请勾选需要删除的题目");
  477. return;
  478. }
  479. this.$confirm(`此操作将永久删除所勾选的${this.$refs.tableList.allCheckData.length}条题目, 是否继续?`, "提示", {
  480. confirmButtonText: "确定",
  481. cancelButtonText: "取消",
  482. type: "warning",
  483. })
  484. .then(() => {
  485. const questionIdsList = this.$refs.tableList.allCheckData.map(
  486. (item) => {
  487. return item.questionId;
  488. }
  489. );
  490. this.$api
  491. .editbankquestion({
  492. status: -1,
  493. questionIds: questionIdsList,
  494. })
  495. .then((res) => {
  496. this.$message.success("批量删除成功");
  497. this.$refs.tableList.clearMoreActive();
  498. this.search(1);
  499. });
  500. })
  501. .catch(() => {});
  502. // console.log(this.$refs.tableList.)
  503. },
  504. clearData() {
  505. this.$refs.wordpop.formData = {
  506. eduId: "",
  507. businessId: "",
  508. subjectId: "",
  509. projectId: "",
  510. };
  511. },
  512. loadingClose() {
  513. this.disabledBtn = false;
  514. },
  515. editInfo(v) {
  516. this.addClick(v, 0);
  517. },
  518. search(int) {
  519. this.loading = true;
  520. if (int === 1) {
  521. this.formData.pageNum = 1;
  522. }
  523. if (int === 2) {
  524. this.formData = {
  525. status: "0,1",
  526. pageSize: 10,
  527. pageNum: 1,
  528. };
  529. this.$refs.tableList.clearMoreActive();
  530. }
  531. this.$api
  532. .inquirebankquestionList(this.formData)
  533. .then((res) => {
  534. for (let i = 0; i < res.rows.length; i++) {
  535. if (res.rows[i].knowledgeList) {
  536. for (let j = 0; j < res.rows[i].knowledgeList.length; j++) {
  537. res.rows[i].knowledgeList[j].knowledgeName =
  538. res.rows[i].knowledgeList[j].knowledgeName + " ";
  539. }
  540. }
  541. }
  542. // res.rows.forEach(item => {
  543. // item.knowledgeList.forEach(items => {
  544. // items.knowledgeName = items.knowledgeName + ' '
  545. // })
  546. // })
  547. this.tableData = res.rows;
  548. this.total = res.total;
  549. this.navText.index = res.total;
  550. })
  551. .finally(() => {
  552. this.loading = false;
  553. });
  554. },
  555. init() {
  556. this.search(2);
  557. },
  558. del(v) {
  559. this.$alert(
  560. "确定删除此内容?<br />内容删除后将无法恢复,请慎重考虑",
  561. "提示",
  562. {
  563. dangerouslyUseHTMLString: true,
  564. }
  565. )
  566. .then(() => {
  567. var data = {
  568. questionId: v.questionId,
  569. status: -1,
  570. };
  571. this.$api.editbankquestion(data).then((res) => {
  572. this.$message.success("删除成功");
  573. this.search();
  574. });
  575. })
  576. .catch(() => {
  577. this.$message({
  578. type: "info",
  579. message: "已取消删除",
  580. });
  581. });
  582. },
  583. addClick(v, int) {
  584. this.disabledBtn = false;
  585. var self = this;
  586. self.listNums = [];
  587. if (v === undefined) {
  588. self.statusPop = 1;
  589. self.innerVisiblePaperTopic = true;
  590. self.statusHide = true;
  591. self.$nextTick(() => {
  592. var datas = {
  593. type: 1,
  594. optionsList: [],
  595. answerQuestionList: [],
  596. content: "",
  597. status: "",
  598. analysisContent: "",
  599. answerQuestion: "",
  600. };
  601. for (let i = 0; i < 4; i++) {
  602. datas.optionsList.push({
  603. content: "",
  604. imgUrl: null,
  605. optionsId: i + 1,
  606. });
  607. }
  608. self.listNums = [datas];
  609. self.$refs.sujects.eduType = "";
  610. self.$refs.sujects.courType = "";
  611. self.options = [];
  612. self.sujectApis = [];
  613. self.newSujectApis = [];
  614. self.listData = {
  615. publishStatus: 1,
  616. };
  617. self.activeExam = [];
  618. });
  619. } else {
  620. self.statusPop = int;
  621. self.$api.obtainbankquestion(v.questionId).then((res) => {
  622. self.questionId = v.questionId;
  623. res.data.optionsList = JSON.parse(res.data.jsonStr);
  624. if (res.data.knowledgeIds) {
  625. var a = [];
  626. res.data.knowledgeIds
  627. .split(",")
  628. .map(Number)
  629. .map((items) => {
  630. self.allOptions.map((item) => {
  631. if (item.knowledgeId === items) {
  632. a.push(item);
  633. }
  634. });
  635. });
  636. self.activeExam = a;
  637. } else {
  638. self.activeExam = [];
  639. }
  640. if (res.data.type === 2) {
  641. if (res.data.answerQuestion) {
  642. res.data.answerQuestionList = res.data.answerQuestion
  643. .split(",")
  644. .map(Number);
  645. }
  646. } else if (res.data.type === 4) {
  647. res.data.optionsList.map((item) => {
  648. if (item.type === 2) {
  649. if (item.answerQuestion) {
  650. item.answerQuestionList = item.answerQuestion
  651. .split(",")
  652. .map(Number);
  653. }
  654. } else {
  655. item.answerQuestionList = [];
  656. }
  657. });
  658. } else {
  659. res.data.answerQuestionList = [];
  660. }
  661. self.$refs.sujects.eduType = "";
  662. self.$refs.sujects.courType = "";
  663. self.listData.prefixName = res.data.prefixName;
  664. self.listData.publishStatus = res.data.publishStatus;
  665. self.listNums.push(res.data);
  666. });
  667. this.$api
  668. .inquirebankquestionListbusiness({ majorId: v.questionId, type: 1 })
  669. .then((res) => {
  670. var arrays = [];
  671. res.rows.map((item) => {
  672. arrays.push(item.businessId + "-" + item.subjectId);
  673. });
  674. self.sujectApis = arrays;
  675. self.newSujectApis = res.rows;
  676. });
  677. this.innerVisiblePaperTopic = true;
  678. this.statusHide = true;
  679. }
  680. },
  681. handleSizeChange(v) {
  682. this.formData.pageSize = v;
  683. this.formData.pageNum = 1;
  684. this.search();
  685. },
  686. handleCurrentChange(v) {
  687. this.formData.pageNum = v;
  688. this.search();
  689. },
  690. //-----------------------------------------------
  691. comLs(item) {
  692. var os = this.activeExam.some((items) => {
  693. return items.knowledgeId === item.knowledgeId;
  694. });
  695. if (os) {
  696. return true;
  697. } else {
  698. return false;
  699. }
  700. },
  701. getFns() {
  702. return new Promise((resolve, reject) => {
  703. this.$api.inquireKnowledgeExamListS({ status: 1 }).then((res) => {
  704. this.allOptions = res.rows;
  705. resolve();
  706. });
  707. });
  708. },
  709. addBusName() {
  710. if (this.BusName.trim()) {
  711. var as = this.allOptions.some((item) => {
  712. return item.knowledgeName == this.BusName;
  713. });
  714. if (as) {
  715. this.$message.warning("当前知识点名称已存在");
  716. return;
  717. }
  718. this.BusNameList.push(this.BusName);
  719. this.BusName = "";
  720. } else {
  721. this.$message({
  722. message: "请输入知识点内容",
  723. type: "warning",
  724. duration: 1200,
  725. });
  726. this.BusName = "";
  727. }
  728. },
  729. submit() {
  730. var data = {
  731. examKnowledgeBusinessAddBoList: this.newSujectApis,
  732. knowledgeName: this.BusNameList,
  733. status: 1,
  734. };
  735. this.$api.addKnowledgeExam(data).then(async (res) => {
  736. this.$message.success("添加成功");
  737. this.dialogVisible = false;
  738. await this.getFns();
  739. this.changeAmdis();
  740. });
  741. },
  742. closeBoxs() {
  743. this.dialogVisible = false;
  744. },
  745. addExam() {
  746. if (!this.$refs.sujects.courType) {
  747. this.$message.warning("请选择业务层级");
  748. return;
  749. }
  750. this.BusNameList = [];
  751. this.BusName = "";
  752. this.dialogVisible = true;
  753. },
  754. clearBus() {
  755. this.BusNameList.splice(index, 1);
  756. },
  757. //子组件回调 业务层及变换-知识点重新筛选
  758. changeAmdis() {
  759. var int = this.$refs.sujects.courType;
  760. var ao = [];
  761. for (let i = 0; i < this.allOptions.length; i++) {
  762. let acts = this.allOptions[i].courseBusinessList.some((items) => {
  763. return items.businessId === int;
  764. });
  765. if (acts) {
  766. ao.push(this.allOptions[i]);
  767. }
  768. }
  769. // this.allOptions.map((item, index) => {
  770. // });
  771. this.options = ao;
  772. },
  773. clearBusName(index) {
  774. this.activeExam.splice(index, 1);
  775. },
  776. changeKnow(item) {
  777. this.allOptions.map((items) => {
  778. if (items.knowledgeId === item) {
  779. this.activeExam.push(items);
  780. }
  781. });
  782. this.value = "";
  783. },
  784. addListNums() {
  785. this.listNums.push({
  786. type: 1,
  787. optionsList: [],
  788. answerQuestionList: [],
  789. content: "",
  790. status: "",
  791. analysisContent: "",
  792. answerQuestion: "",
  793. });
  794. },
  795. closeBefore() {
  796. this.innerVisiblePaperTopic = false;
  797. this.statusHide = false;
  798. },
  799. async submitForm(formName, int) {
  800. this.$refs[formName].validate((valid) => {
  801. if (valid) {
  802. var self = this;
  803. if (!this.$refs.sujects.newSujectApis.length) {
  804. this.$message.error("请选择科目");
  805. return;
  806. }
  807. var data = this.$refs.child[0].getInfosPage();
  808. if (!data.content || data.content == "<p><br></p>") {
  809. self.$message.error("请填写题目内容");
  810. return;
  811. }
  812. if (data.type != 3 && data.type != 5 && !data.optionsList.length) {
  813. self.$message.error("请添加选项");
  814. return;
  815. }
  816. if (data.type != 3 && data.type != 4 && data.optionsList.length) {
  817. var ast = data.optionsList.some((item) => {
  818. return !item.content && !item.imgUrl;
  819. });
  820. if (ast) {
  821. self.$message.error("请完善选项内容");
  822. return;
  823. }
  824. }
  825. if (data.type != 5 && data.type != 4) {
  826. if (data.type === 2 && !data.answerQuestionList.length) {
  827. self.$message.error("请选择正确答案");
  828. return;
  829. }
  830. if (data.type !== 2 && !data.answerQuestion) {
  831. self.$message.error("请选择正确答案");
  832. return;
  833. }
  834. }
  835. if (data.type == 4 && data.optionsList.length) {
  836. for (let i = 0; i < data.optionsList.length; i++) {
  837. if (
  838. !data.optionsList[i].content ||
  839. data.optionsList[i].content == "<p><br></p>"
  840. ) {
  841. self.$message.error("请填写题目内容");
  842. return;
  843. }
  844. if (
  845. data.optionsList[i].type != 3 &&
  846. data.optionsList[i].type != 5 &&
  847. !data.optionsList[i].optionsList.length
  848. ) {
  849. self.$message.error("请添加选项");
  850. return;
  851. }
  852. if (
  853. data.optionsList[i].type != 3 &&
  854. data.optionsList[i].optionsList.length
  855. ) {
  856. var ast = data.optionsList[i].optionsList.some((item) => {
  857. return !item.content && !item.imgUrl;
  858. });
  859. if (ast) {
  860. self.$message.error("请完善选项内容");
  861. return;
  862. }
  863. }
  864. if (data.optionsList[i].type != 5) {
  865. if (
  866. data.optionsList[i].type === 2 &&
  867. !data.optionsList[i].answerQuestionList.length
  868. ) {
  869. self.$message.error("请选择正确答案");
  870. return;
  871. }
  872. if (
  873. data.optionsList[i].type !== 2 &&
  874. !data.optionsList[i].answerQuestion
  875. ) {
  876. self.$message.error("请选择正确答案");
  877. return;
  878. }
  879. }
  880. }
  881. }
  882. this.disabledBtn = true;
  883. var numList = [];
  884. this.activeExam.map((item) => {
  885. numList.push(item.knowledgeId);
  886. });
  887. data.prefixName = this.listData.prefixName;
  888. data.knowledgeIds = numList.toString();
  889. data.publishStatus = this.listData.publishStatus;
  890. data.businessList = this.$refs.sujects.newSujectApis;
  891. if (data.type === 2) {
  892. if (data.answerQuestionList.length) {
  893. data.answerQuestion = data.answerQuestionList.toString();
  894. }
  895. }
  896. if (data.type === 4) {
  897. data.optionsList.map((item) => {
  898. if (item.type === 2) {
  899. if (item.answerQuestionList.length) {
  900. item.answerQuestion = item.answerQuestionList.toString();
  901. }
  902. }
  903. });
  904. }
  905. if (this.statusPop === 1) {
  906. data.status = 1;
  907. this.$api
  908. .addbankquestion(data)
  909. .then((res) => {
  910. self.$methodsTools.cacheBusinessList(
  911. self.$refs.sujects.newSujectApis
  912. );
  913. self.$refs.sujects.UPDates();
  914. self.$message.success("添加成功");
  915. self.innerVisiblePaperTopic = false;
  916. self.statusHide = true;
  917. self.search();
  918. if (int === 1) {
  919. self.addClick();
  920. }
  921. })
  922. .catch(() => {
  923. this.disabledBtn = false;
  924. });
  925. }
  926. if (this.statusPop === 0) {
  927. data.questionId = self.questionId;
  928. this.$api
  929. .editbankquestion(data)
  930. .then((res) => {
  931. self.$message.success("修改成功");
  932. self.innerVisiblePaperTopic = false;
  933. self.statusHide = true;
  934. self.search();
  935. })
  936. .catch(() => {
  937. this.disabledBtn = false;
  938. });
  939. }
  940. } else {
  941. console.log("error submit!!");
  942. return false;
  943. }
  944. });
  945. },
  946. //保存且添加下一题
  947. async submitAndNext() {
  948. var data = JSON.parse(JSON.stringify(this.dingForm));
  949. data.parentType = Number(this.queryData.typeId);
  950. data.examId = Number(this.queryData.examId) || 0;
  951. data.bankSectionId = Number(this.queryData.bankSectionId) || 0;
  952. this.$message.success("添加成功");
  953. this.innerVisiblePaperTopic = false;
  954. this.statusHide = true;
  955. // this.search();
  956. this.dingForm = {
  957. jsonStr: [],
  958. };
  959. },
  960. },
  961. };
  962. </script>
  963. <style lang="less" scoped>
  964. .BusBoxs {
  965. min-height: 100px;
  966. border: 1px solid #a4a4a4;
  967. margin-bottom: 10px;
  968. border-radius: 8px;
  969. max-height: 280px;
  970. padding: 10px;
  971. overflow-y: auto;
  972. .fot_Le {
  973. border-radius: 12px;
  974. border: 1px solid yellowgreen;
  975. padding: 0px 10px;
  976. height: 30px;
  977. line-height: 30px;
  978. text-align: center;
  979. float: left;
  980. margin-right: 6px;
  981. margin-bottom: 6px;
  982. .icon_clear {
  983. margin-left: 2px;
  984. font-size: 15px;
  985. color: #f56c6c;
  986. cursor: pointer;
  987. }
  988. }
  989. }
  990. .marg_play {
  991. display: flex;
  992. margin-bottom: 15px;
  993. .spans {
  994. text-align: right;
  995. width: 80px;
  996. }
  997. }
  998. /deep/.el-button {
  999. border-radius: 8px;
  1000. }
  1001. /deep/.el-dialog {
  1002. border-radius: 8px;
  1003. .el-dialog__header {
  1004. padding: 0;
  1005. .hearders {
  1006. height: 40px;
  1007. display: flex;
  1008. align-items: center;
  1009. justify-content: space-between;
  1010. padding: 0px 18px 0px 20px;
  1011. border-bottom: 1px solid #e2e2e2;
  1012. .leftTitle {
  1013. font-size: 14px;
  1014. font-weight: bold;
  1015. color: #2f4378;
  1016. }
  1017. .rightBoxs {
  1018. display: flex;
  1019. align-items: center;
  1020. img {
  1021. width: 14px;
  1022. height: 14px;
  1023. margin-left: 13px;
  1024. cursor: pointer;
  1025. }
  1026. }
  1027. }
  1028. }
  1029. .el-dialog__footer {
  1030. padding: 0;
  1031. .dialog-footer {
  1032. padding: 0px 40px;
  1033. height: 70px;
  1034. border-top: 1px solid #e2e2e2;
  1035. display: flex;
  1036. align-items: center;
  1037. justify-content: center;
  1038. }
  1039. }
  1040. }
  1041. </style>