index.vue 28 KB

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