questionBank.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923
  1. <template>
  2. <div id="questionBank">
  3. <el-col :span="24" style="display: flex; justify-content: center">
  4. <el-col
  5. :span="2"
  6. style="
  7. display: flex;
  8. align-items: center;
  9. justify-content: flex-start;
  10. cursor: pointer;
  11. "
  12. >
  13. <el-button
  14. type="success"
  15. icon="el-icon-arrow-left"
  16. circle
  17. size="small"
  18. @click="back"
  19. v-if="statusPop === 2"
  20. ></el-button>
  21. </el-col>
  22. <el-col :span="20" class="contentMore">
  23. <div class="marg_play">
  24. <span class="spans">题目类型:</span>
  25. <el-radio-group v-model="dingForm.type" @change="changeTypes">
  26. <el-radio
  27. :disabled="statusPop === 2 || statusPop === 0"
  28. v-for="(item, index) in radioArrays"
  29. :key="index"
  30. :label="item.value"
  31. >{{ item.label }}</el-radio
  32. >
  33. </el-radio-group>
  34. </div>
  35. <div class="marg_play">
  36. <span class="spans"><span style="color: red">* </span>题目:</span>
  37. <div>
  38. <editor
  39. v-model="dingForm.content"
  40. :max-height="300"
  41. :uploadStatus="uploadStatus"
  42. />
  43. </div>
  44. </div>
  45. <!-- <div class="marg_play">
  46. <span class="spans">图片:</span>
  47. <div>
  48. <div class="imgBoxTopic">
  49. <label class="imgLabel">
  50. <div class="msPhoto" v-if="dingForm.imgUrl">
  51. <img
  52. :src="$methodsTools.splitImgHost(dingForm.imgUrl)"
  53. alt="图片加载失败"
  54. />
  55. </div>
  56. <div class="imgbbx" v-else>
  57. <p>点击添加图片</p>
  58. <i class="el-icon-plus"></i>
  59. </div>
  60. <input
  61. :disabled="statusPop === 2"
  62. :id="'inputstopic' + nums"
  63. type="file"
  64. ref="filetopic"
  65. style="display: none"
  66. @change="getImgFiletopic(nums, $event)"
  67. />
  68. </label>
  69. </div>
  70. <p style="color: #999999; line-height: 22px">
  71. 支持扩展名:.jpeg .bmp .png .jpg...<br />为保证显示效果,请上传分辨率为100x100且大小小于2M图片
  72. </p>
  73. </div>
  74. </div> -->
  75. <div
  76. class="marg_play"
  77. v-if="
  78. dingForm.type === 1 || dingForm.type === 2 || dingForm.type === 5
  79. "
  80. >
  81. <span class="spans"><span style="color: red">* </span>选项:</span>
  82. <div style="flex: 1">
  83. <div
  84. style="display: flex; align-items: center; margin-bottom: 8px"
  85. v-for="(options, indexsop) in dingForm.optionsList"
  86. :key="indexsop"
  87. >
  88. <span>选项{{ indexsop + 1 }}:</span>
  89. <el-input
  90. style="flex: 1; margin: 0px 10px"
  91. type="textarea"
  92. :disabled="statusPop === 2"
  93. v-model="options.content"
  94. placeholder="请输入内容"
  95. :autosize="{ minRows: 2, maxRows: 2 }"
  96. maxlength="500"
  97. ></el-input>
  98. <span>{{ options.content.length }}/500</span>
  99. <el-button
  100. v-if="statusPop === 1"
  101. @click="delList(indexsop)"
  102. style="border-radius: 50%; margin: 0px 6px"
  103. type="danger"
  104. icon="el-icon-delete"
  105. size="mini"
  106. circle
  107. ></el-button>
  108. <label class="btnSty" v-if="statusPop !== 2"
  109. ><input
  110. type="file"
  111. style="display: none"
  112. @change="uploadListImg(indexsop, $event)"
  113. />{{
  114. options.imgUrl !== null && options.imgUrl
  115. ? "更换图片"
  116. : "上传图片"
  117. }}</label
  118. >
  119. <el-image
  120. v-if="options.imgUrl !== null && options.imgUrl"
  121. style="
  122. width: 50px;
  123. height: 50px;
  124. border-radius: 4px;
  125. border: 1px dotted #a4a4a4;
  126. padding: 4px;
  127. "
  128. :src="$methodsTools.splitImgHost(options.imgUrl)"
  129. :preview-src-list="[$methodsTools.splitImgHost(options.imgUrl)]"
  130. >
  131. </el-image>
  132. <!-- <img
  133. v-if="options.imgUrl !== null && options.imgUrl"
  134. style="
  135. width: 50px;
  136. height: 50px;
  137. border-radius: 4px;
  138. border: 1px dotted #a4a4a4;
  139. padding: 4px;
  140. "
  141. :src="$methodsTools.splitImgHost(options.imgUrl)"
  142. alt=""
  143. /> -->
  144. </div>
  145. <div
  146. style="display: flex; align-items: center"
  147. v-if="statusPop !== 2"
  148. >
  149. <i
  150. class="el-icon-circle-plus"
  151. style="margin-right: 5px; font-size: 30px; cursor: pointer"
  152. @click="addListcontent"
  153. ></i>
  154. <span
  155. style="color: #409eff; cursor: pointer"
  156. @click="addListcontent"
  157. >添加选项</span
  158. >
  159. </div>
  160. </div>
  161. </div>
  162. <div style="margin-bottom: 15px" v-if="dingForm.type === 4">
  163. <div
  164. style="display: flex; align-items: center"
  165. v-if="statusPop !== 2"
  166. >
  167. <i
  168. class="el-icon-circle-plus"
  169. style="margin-right: 5px; font-size: 30px; cursor: pointer"
  170. @click="addListItem"
  171. ></i
  172. ><span style="color: #409eff; cursor: pointer" @click="addListItem"
  173. >添加问题</span
  174. >
  175. </div>
  176. <!-- 案例题 -->
  177. <div style="padding-left: 50px">
  178. <div v-for="(ans, ain) in dingForm.optionsList" :key="ain">
  179. <div class="marg_play">
  180. <el-button
  181. v-if="statusPop !== 2"
  182. @click="delAnliChi(ain)"
  183. style="border-radius: 50%; margin: 0px 6px"
  184. type="danger"
  185. icon="el-icon-delete"
  186. size="mini"
  187. circle
  188. ></el-button>
  189. <span class="spans">题目类型:</span>
  190. <el-radio-group
  191. v-model="ans.type"
  192. @change="changeTypeChild(ain)"
  193. >
  194. <el-radio
  195. v-for="(tng, nindex) in radioArray"
  196. :key="nindex"
  197. :label="tng.value"
  198. :disabled="statusPop === 2"
  199. >{{ tng.label }}</el-radio
  200. >
  201. </el-radio-group>
  202. </div>
  203. <div class="marg_play">
  204. <span class="spans"
  205. ><span style="color: red">* </span>题目:</span
  206. >
  207. <div>
  208. <editor
  209. v-model="ans.content"
  210. :max-height="300"
  211. :uploadStatus="uploadStatus"
  212. />
  213. </div>
  214. </div>
  215. <!-- <div class="marg_play">
  216. <span class="spans">图片:</span>
  217. <div>
  218. <div class="imgBoxTopic">
  219. <label class="imgLabel">
  220. <div class="msPhoto" v-if="ans.imgUrl">
  221. <img
  222. :src="$methodsTools.splitImgHost(ans.imgUrl)"
  223. alt="图片加载失败"
  224. />
  225. </div>
  226. <div class="imgbbx" v-else>
  227. <p>点击添加图片</p>
  228. <i class="el-icon-plus"></i>
  229. </div>
  230. <input
  231. :id="'inputstopi' + nums + ain"
  232. type="file"
  233. :disabled="statusPop === 2"
  234. style="display: none"
  235. @change="getImgFiletopics(ain, $event)"
  236. />
  237. </label>
  238. </div>
  239. <p style="color: #999999; line-height: 22px">
  240. 支持扩展名:.jpeg .bmp .png .jpg...<br />为保证显示效果,请上传分辨率为100x100且大小小于2M图片
  241. </p>
  242. </div>
  243. </div> -->
  244. <div
  245. class="marg_play"
  246. v-if="ans.type === 1 || ans.type === 2 || ans.type === 5"
  247. >
  248. <span class="spans"
  249. ><span style="color: red">* </span>选项:</span
  250. >
  251. <div style="flex: 1">
  252. <div
  253. style="
  254. display: flex;
  255. align-items: center;
  256. margin-bottom: 8px;
  257. "
  258. v-for="(answerItem, indexsops) in ans.optionsList"
  259. :key="indexsops"
  260. >
  261. <span>选项{{ indexsops + 1 }}:</span>
  262. <el-input
  263. style="flex: 1; margin: 0px 10px"
  264. type="textarea"
  265. :disabled="statusPop === 2"
  266. v-model="answerItem.content"
  267. placeholder="请输入内容"
  268. :autosize="{ minRows: 2, maxRows: 2 }"
  269. maxlength="500"
  270. ></el-input>
  271. <span>{{ answerItem.content.length }}/500</span>
  272. <el-button
  273. v-if="statusPop === 1"
  274. @click="delListchi(ain, indexsops)"
  275. style="border-radius: 50%; margin: 0px 6px"
  276. type="danger"
  277. icon="el-icon-delete"
  278. size="mini"
  279. circle
  280. ></el-button>
  281. <label class="btnSty" v-if="statusPop !== 2"
  282. ><input
  283. type="file"
  284. style="display: none"
  285. @change="uploadListImgchi(ain, indexsops, $event)"
  286. />{{
  287. answerItem.imgUrl !== null && answerItem.imgUrl
  288. ? "更换图片"
  289. : "上传图片"
  290. }}</label
  291. >
  292. <el-image
  293. v-if="answerItem.imgUrl !== null && answerItem.imgUrl"
  294. style="
  295. width: 50px;
  296. height: 50px;
  297. border-radius: 4px;
  298. border: 1px dotted #a4a4a4;
  299. padding: 4px;
  300. "
  301. :src="$methodsTools.splitImgHost(answerItem.imgUrl)"
  302. :preview-src-list="[
  303. $methodsTools.splitImgHost(answerItem.imgUrl),
  304. ]"
  305. >
  306. </el-image>
  307. <!-- <img
  308. v-if="answerItem.imgUrl !== null && answerItem.imgUrl"
  309. style="
  310. width: 50px;
  311. height: 50px;
  312. border-radius: 4px;
  313. border: 1px dotted #a4a4a4;
  314. padding: 4px;
  315. "
  316. :src="$methodsTools.splitImgHost(answerItem.imgUrl)"
  317. alt=""
  318. /> -->
  319. </div>
  320. <div
  321. style="display: flex; align-items: center"
  322. v-if="statusPop !== 2"
  323. >
  324. <i
  325. class="el-icon-circle-plus"
  326. style="
  327. margin-right: 5px;
  328. font-size: 30px;
  329. cursor: pointer;
  330. "
  331. @click="addListcontentchi(ain)"
  332. ></i>
  333. <span
  334. style="color: #409eff; cursor: pointer"
  335. @click="addListcontentchi(ain)"
  336. >添加选项</span
  337. >
  338. </div>
  339. </div>
  340. </div>
  341. <div class="marg_play" v-if="ans.type === 1">
  342. <span class="spans"
  343. ><span style="color: red">* </span>正确答案:</span
  344. >
  345. <el-radio-group
  346. v-for="(oAsz, oindexsz) in ans.optionsList"
  347. :key="oindexsz"
  348. v-model="ans.answerQuestion"
  349. >
  350. <el-radio
  351. :disabled="statusPop === 2"
  352. :label="oindexsz + 1 + ''"
  353. >选项{{ oindexsz + 1 }}</el-radio
  354. >
  355. </el-radio-group>
  356. </div>
  357. <div class="marg_play" v-else-if="ans.type === 2">
  358. <span class="spans"
  359. ><span style="color: red">* </span>正确答案:</span
  360. >
  361. <el-checkbox-group v-model="ans.answerQuestionList">
  362. <el-checkbox
  363. v-for="(oAsz, oindexsz) in ans.optionsList"
  364. :key="oindexsz"
  365. :disabled="statusPop === 2"
  366. :label="oindexsz + 1"
  367. >选项{{ oindexsz + 1 }}</el-checkbox
  368. >
  369. </el-checkbox-group>
  370. </div>
  371. <div class="marg_play" v-if="ans.type === 3">
  372. <span class="spans"
  373. ><span style="color: red">* </span>正确答案:</span
  374. >
  375. <el-radio-group v-model="ans.answerQuestion">
  376. <el-radio :disabled="statusPop === 2" label="1"
  377. >正确</el-radio
  378. >
  379. <el-radio :disabled="statusPop === 2" label="0"
  380. >错误</el-radio
  381. >
  382. </el-radio-group>
  383. </div>
  384. <div class="marg_play">
  385. <span class="spans">答案解析:</span>
  386. <div>
  387. <editor
  388. v-model="ans.analysisContent"
  389. :max-height="300"
  390. :uploadStatus="uploadStatus"
  391. />
  392. </div>
  393. </div>
  394. </div>
  395. </div>
  396. <!-- 案例题 -->
  397. </div>
  398. <div class="marg_play" v-if="dingForm.type === 1">
  399. <span class="spans"
  400. ><span style="color: red">* </span>正确答案:</span
  401. >
  402. <el-radio-group
  403. v-for="(oA, oindex) in dingForm.optionsList"
  404. :key="oindex"
  405. v-model="dingForm.answerQuestion"
  406. >
  407. <el-radio :disabled="statusPop === 2" :label="oindex + 1 + ''"
  408. >选项{{ oindex + 1 }}</el-radio
  409. >
  410. </el-radio-group>
  411. </div>
  412. <div class="marg_play" v-else-if="dingForm.type === 2">
  413. <span class="spans"
  414. ><span style="color: red">* </span>正确答案:</span
  415. >
  416. <el-checkbox-group v-model="dingForm.answerQuestionList">
  417. <el-checkbox
  418. v-for="(oA, oindex) in dingForm.optionsList"
  419. :key="oindex"
  420. :disabled="statusPop === 2"
  421. :label="oindex + 1"
  422. >选项{{ oindex + 1 }}</el-checkbox
  423. >
  424. </el-checkbox-group>
  425. </div>
  426. <div class="marg_play" v-if="dingForm.type === 3">
  427. <span class="spans"
  428. ><span style="color: red">* </span>正确答案:</span
  429. >
  430. <el-radio-group v-model="dingForm.answerQuestion">
  431. <el-radio :disabled="statusPop === 2" label="1">正确</el-radio>
  432. <el-radio :disabled="statusPop === 2" label="0">错误</el-radio>
  433. </el-radio-group>
  434. </div>
  435. <div class="marg_play">
  436. <span class="spans">答案解析:</span>
  437. <div>
  438. <editor
  439. v-model="dingForm.analysisContent"
  440. :max-height="300"
  441. :uploadStatus="uploadStatus"
  442. />
  443. </div>
  444. </div>
  445. <!-- <div class="marg_play">
  446. <span class="spans">是否启用:</span>
  447. <el-radio-group v-model="dingForm.status">
  448. <el-radio :disabled="statusPop === 2" :label="1">启用</el-radio>
  449. <el-radio :disabled="statusPop === 2" :label="0">停用</el-radio>
  450. </el-radio-group>
  451. </div> -->
  452. </el-col>
  453. <el-col
  454. :span="2"
  455. style="
  456. display: flex;
  457. align-items: center;
  458. justify-content: flex-end;
  459. cursor: pointer;
  460. "
  461. >
  462. <el-button
  463. type="success"
  464. icon="el-icon-arrow-right"
  465. circle
  466. @click="next"
  467. v-if="statusPop === 2"
  468. ></el-button>
  469. </el-col>
  470. </el-col>
  471. </div>
  472. </template>
  473. <script>
  474. import Editor from "@/components/Editor";
  475. export default {
  476. components: { Editor },
  477. name: "questionBank",
  478. props: ["nums", "dingFormInfo"],
  479. data() {
  480. return {
  481. dingForm: {},
  482. uploadStatus: 2,
  483. statusPop: 1,
  484. innerVisiblePaperTopic: false,
  485. fullscreenChildPaperTopic: false, //当前打开窗数据
  486. radioArrays: [
  487. {
  488. label: "单选题",
  489. value: 1,
  490. },
  491. {
  492. label: "多选题",
  493. value: 2,
  494. },
  495. {
  496. label: "判断题",
  497. value: 3,
  498. },
  499. {
  500. label: "简答题",
  501. value: 5,
  502. },
  503. {
  504. label: "案例题",
  505. value: 4,
  506. },
  507. ],
  508. radioArray: [
  509. {
  510. label: "单选题",
  511. value: 1,
  512. },
  513. {
  514. label: "多选题",
  515. value: 2,
  516. },
  517. {
  518. label: "判断题",
  519. value: 3,
  520. },
  521. {
  522. label: "简答题",
  523. value: 5,
  524. },
  525. ],
  526. queryData: 1,
  527. };
  528. },
  529. mounted() {
  530. // this.$nextTick(function () {
  531. // this.$on("childmethods", function (v, int) {
  532. // this.addClick(v, int);
  533. // });
  534. // });
  535. },
  536. watch: {
  537. dingFormInfo: {
  538. handler(newVal, oldVal) {
  539. this.dingForm = newVal;
  540. },
  541. // 立即处理 进入页面就触发
  542. immediate: true,
  543. },
  544. },
  545. methods: {
  546. changeTypes(int) {
  547. this.dingForm = {
  548. questionId: this.dingForm.questionId ? this.dingForm.questionId : "",
  549. type: int,
  550. optionsList: [],
  551. answerQuestionList: [],
  552. answerQuestion: "",
  553. content: "",
  554. // status: "",
  555. analysisContent: "",
  556. };
  557. },
  558. changeTypeChild(index) {
  559. this.dingForm.optionsList[index].optionsList = [];
  560. this.dingForm.optionsList[index].answerQuestion = "";
  561. },
  562. getInfosPage() {
  563. return this.dingForm;
  564. },
  565. back() {
  566. this.tableData.forEach((item, index) => {
  567. if (item.questionId === this.dingForm.questionId) {
  568. if (index === 0) {
  569. this.$message.warning("这是当前页第一题了");
  570. } else {
  571. var datas = this.tableData[index - 1].questionId;
  572. this.$api.obtainbankquestion(datas).then((res) => {
  573. this.dingForm = res.data;
  574. });
  575. }
  576. }
  577. });
  578. },
  579. next() {
  580. this.tableData.forEach((item, index) => {
  581. if (item.questionId === this.dingForm.questionId) {
  582. if (this.tableData.length - 1 === index) {
  583. this.$message.warning("这是当前页最后一题了");
  584. } else {
  585. var datas = this.tableData[index + 1].questionId;
  586. this.$api.obtainbankquestion(datas).then((res) => {
  587. this.dingForm = res.data;
  588. });
  589. }
  590. }
  591. });
  592. },
  593. addClick(v, int) {
  594. if (v === undefined) {
  595. this.dingForm = {
  596. optionsList: [],
  597. status: 1,
  598. };
  599. this.statusPop = 1;
  600. } else {
  601. var datas = v.questionId;
  602. this.statusPop = int;
  603. this.$api.obtainbankquestion(datas).then((res) => {
  604. this.dingForm = res.data;
  605. });
  606. }
  607. this.innerVisiblePaperTopic = true;
  608. },
  609. delTopic() {
  610. this.$confirm("此操作将删除该题目, 是否继续?", "提示", {
  611. confirmButtonText: "确定",
  612. cancelButtonText: "取消",
  613. type: "warning",
  614. })
  615. .then(async () => {
  616. var data = JSON.parse(JSON.stringify(this.dingForm));
  617. data.parentType = Number(this.queryData.typeId);
  618. // data.status = -1;
  619. console.log(data);
  620. this.$message.success("删除成功");
  621. this.search();
  622. this.innerVisiblePaperTopic = false;
  623. })
  624. .catch(() => {
  625. this.$message({
  626. type: "info",
  627. message: "已取消删除",
  628. });
  629. });
  630. },
  631. //删除案例问题
  632. delAnliChi(int) {
  633. this.dingForm.optionsList.splice(int, 1);
  634. },
  635. //删除选项 非案例
  636. delList(index) {
  637. this.dingForm.optionsList.splice(index, 1);
  638. this.dingForm.optionsList.map((items, indexs) => {
  639. items.optionsId = indexs + 1;
  640. });
  641. if (this.dingForm.type === 1) {
  642. this.dingForm.answerQuestion = "";
  643. }
  644. if (this.dingForm.type === 2) {
  645. this.dingForm.answerQuestionList = [];
  646. }
  647. },
  648. //删除选项 案例
  649. delListchi(fatherIndex, childrenIndex) {
  650. this.dingForm.optionsList[fatherIndex].optionsList.splice(
  651. childrenIndex,
  652. 1
  653. );
  654. this.dingForm.optionsList[fatherIndex].optionsList.map(
  655. (items, indexs) => {
  656. items.optionsId = indexs + 1;
  657. }
  658. );
  659. if (this.dingForm.optionsList[fatherIndex].type === 1) {
  660. this.dingForm.optionsList[fatherIndex].answerQuestion = "";
  661. }
  662. if (this.dingForm.optionsList[fatherIndex].type === 2) {
  663. this.dingForm.optionsList[fatherIndex].answerQuestionList = [];
  664. }
  665. },
  666. //新增选项 非案例
  667. addListcontent() {
  668. var data = {
  669. content: "",
  670. imgUrl: null,
  671. optionsId: this.dingForm.optionsList.length + 1,
  672. };
  673. this.dingForm.optionsList.push(data);
  674. },
  675. //新增选项 案例
  676. addListcontentchi(int) {
  677. var data = {
  678. content: "",
  679. imgUrl: null,
  680. optionsId: this.dingForm.optionsList[int].optionsList.length + 1,
  681. };
  682. this.dingForm.optionsList[int].optionsList.push(data);
  683. },
  684. //新增问题 案例
  685. addListItem() {
  686. var data = {
  687. analysisContent: "",
  688. answerQuestion: "",
  689. answerQuestionList: [],
  690. content: "",
  691. optionsList: [],
  692. type: 1,
  693. };
  694. this.dingForm.optionsList.push(data);
  695. },
  696. // 上传图片
  697. async getImgFiletopic(nums, e) {
  698. var file = e.target.files[0];
  699. if (file === undefined) {
  700. return;
  701. }
  702. if (file.size > 2 * 1024 * 1024) {
  703. this.$message.error("图片不得大于2MB");
  704. return;
  705. }
  706. var type = e.target.value.toLowerCase().split(".").splice(-1);
  707. if (
  708. type[0] != "jpg" &&
  709. type[0] != "png" &&
  710. type[0] != "jpeg" &&
  711. type[0] != "bmp"
  712. ) {
  713. this.$message.error("上传格式需为:.jpg/.png/.jpeg/bmp");
  714. return;
  715. }
  716. const imgUrls = await this.imgUpload(file, 2);
  717. console.log(this.dingForm, nums);
  718. this.$set(this.dingForm, "imgUrl", imgUrls);
  719. },
  720. // 上传内容list图片
  721. async uploadListImg(k, e) {
  722. var file = e.target.files[0];
  723. if (file === undefined) {
  724. return;
  725. }
  726. if (file.size > 2 * 1024 * 1024) {
  727. this.$message.error("图片不得大于2MB");
  728. return;
  729. }
  730. var type = e.target.value.toLowerCase().split(".").splice(-1);
  731. if (
  732. type[0] != "jpg" &&
  733. type[0] != "png" &&
  734. type[0] != "jpeg" &&
  735. type[0] != "bmp"
  736. ) {
  737. this.$message.error("上传格式需为:.jpg/.png/.jpeg/bmp");
  738. return;
  739. }
  740. const imgUrls = await this.imgUpload(file, 2);
  741. this.$set(this.dingForm.optionsList[k], "imgUrl", imgUrls);
  742. },
  743. // 案例上传内容list图片
  744. async uploadListImgchi(fatherIndex, k, e) {
  745. var file = e.target.files[0];
  746. if (file === undefined) {
  747. return;
  748. }
  749. if (file.size > 2 * 1024 * 1024) {
  750. this.$message.error("图片不得大于2MB");
  751. return;
  752. }
  753. var type = e.target.value.toLowerCase().split(".").splice(-1);
  754. if (
  755. type[0] != "jpg" &&
  756. type[0] != "png" &&
  757. type[0] != "jpeg" &&
  758. type[0] != "bmp"
  759. ) {
  760. this.$message.error("上传格式需为:.jpg/.png/.jpeg/bmp");
  761. return;
  762. }
  763. const imgUrls = await this.imgUpload(file, 2);
  764. this.$set(
  765. this.dingForm.optionsList[fatherIndex].optionsList[k],
  766. "imgUrl",
  767. imgUrls
  768. );
  769. },
  770. //案例 子题目图片
  771. async getImgFiletopics(int, e) {
  772. var file = e.target.files[0];
  773. if (file === undefined) {
  774. return;
  775. }
  776. if (file.size > 2 * 1024 * 1024) {
  777. this.$message.error("图片不得大于2MB");
  778. return;
  779. }
  780. var type = e.target.value.toLowerCase().split(".").splice(-1);
  781. if (
  782. type[0] != "jpg" &&
  783. type[0] != "png" &&
  784. type[0] != "jpeg" &&
  785. type[0] != "bmp"
  786. ) {
  787. this.$message.error("上传格式需为:.jpg/.png/.jpeg/bmp");
  788. return;
  789. }
  790. const imgUrls = await this.imgUpload(file, 2);
  791. this.$set(this.dingForm.optionsList[int], "imgUrl", imgUrls);
  792. },
  793. imgUpload(file, int) {
  794. var self = this;
  795. return new Promise((resolve, reject) => {
  796. this.$upload
  797. .upload(file, int)
  798. .then((res) => {
  799. resolve(res);
  800. })
  801. .catch((err) => {
  802. self.$message.error("图片上传错误");
  803. });
  804. });
  805. },
  806. },
  807. };
  808. </script>
  809. <style lang="less" scoped>
  810. .contentMore {
  811. border: 1px solid #999;
  812. padding: 10px;
  813. }
  814. .marg_play {
  815. display: flex;
  816. margin-bottom: 15px;
  817. .spans {
  818. text-align: right;
  819. width: 80px;
  820. }
  821. }
  822. .imgBox {
  823. width: 100%;
  824. // height: 210px;
  825. border: 1px solid #e2e2e2;
  826. border-radius: 8px;
  827. padding: 8px 8px 3px;
  828. display: flex;
  829. flex-direction: column;
  830. align-items: center;
  831. .imgLabel {
  832. flex: 1;
  833. width: 100%;
  834. border: 1px dotted #e2e2e2;
  835. color: #999;
  836. font-size: 14px;
  837. cursor: pointer;
  838. border-radius: 8px;
  839. .msPhoto {
  840. display: flex;
  841. justify-content: center;
  842. align-items: center;
  843. max-width: 100%;
  844. max-height: 270px;
  845. img {
  846. max-width: 100%;
  847. max-height: 270px;
  848. }
  849. }
  850. .imgbbx {
  851. display: flex;
  852. flex-direction: column;
  853. align-items: center;
  854. justify-content: center;
  855. width: 100%;
  856. height: 100%;
  857. i {
  858. font-weight: bold;
  859. margin: 14px 0;
  860. font-size: 24px;
  861. }
  862. }
  863. }
  864. p {
  865. margin: 5px 0px;
  866. }
  867. }
  868. .imgBoxTopic {
  869. width: 150px;
  870. height: 150px;
  871. border: 1px solid #e2e2e2;
  872. border-radius: 8px;
  873. display: flex;
  874. flex-direction: column;
  875. align-items: center;
  876. .imgLabel {
  877. flex: 1;
  878. width: 100%;
  879. background-color: #f9f9f9;
  880. color: #999;
  881. font-size: 14px;
  882. cursor: pointer;
  883. border-radius: 8px;
  884. .msPhoto {
  885. display: flex;
  886. justify-content: center;
  887. align-items: center;
  888. height: 100%;
  889. max-width: 100%;
  890. max-height: 150px;
  891. img {
  892. max-width: 100%;
  893. max-height: 150px;
  894. }
  895. }
  896. .imgbbx {
  897. display: flex;
  898. flex-direction: column;
  899. align-items: center;
  900. justify-content: center;
  901. width: 100%;
  902. height: 100%;
  903. i {
  904. font-weight: bold;
  905. margin: 8px 0;
  906. font-size: 20px;
  907. }
  908. }
  909. }
  910. }
  911. .btnSty {
  912. cursor: pointer;
  913. padding: 4px 10px;
  914. background-color: #409eff;
  915. color: #fff;
  916. text-align: center;
  917. border-radius: 8px;
  918. margin-right: 6px;
  919. }
  920. </style>