index.vue 27 KB

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