index.vue 27 KB

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