adultInput.vue 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001
  1. <!-- -->
  2. <template>
  3. <div class="Big-Book-container adult-book-input-sty">
  4. <Header />
  5. <div class="Big-Book-content">
  6. <div class="content-tree">
  7. <Catelog
  8. :book-id="bookId"
  9. :book-level="bookLevel"
  10. :book-node-index="bookIndex"
  11. :change-id="changeId"
  12. />
  13. </div>
  14. <div class="Book-content" v-if="currentTreeID">
  15. <div class="Big-Book-save">
  16. <el-button type="primary" @click="onSave">保 存</el-button>
  17. <el-button type="danger" @click="onPreview" plain>预 览</el-button>
  18. </div>
  19. <el-tabs
  20. v-model="editableTabsValue"
  21. type="card"
  22. editable
  23. @edit="handleTabsEdit"
  24. @tab-click="tabClick"
  25. >
  26. <el-tab-pane
  27. v-for="(item, index) in question_list"
  28. :key="item.name"
  29. :label="item.title"
  30. :name="item.name"
  31. >
  32. <div class="createTable">
  33. <el-input
  34. maxlength="1"
  35. style="width: 50px"
  36. v-model="row"
  37. type="text"
  38. @input="rowLine('row')"
  39. />*<el-input
  40. style="width: 50px"
  41. v-model="line"
  42. type="text"
  43. maxlength="1"
  44. @input="rowLine('line')"
  45. />
  46. <el-button
  47. @click="createTable"
  48. style="margin-left: 10px"
  49. type="primary"
  50. >增加题</el-button
  51. >
  52. </div>
  53. <div
  54. v-for="(topic, toindex) in item.cur_fn_data"
  55. :key="'topic' + toindex + index"
  56. >
  57. <p>第{{ toindex + 1 }}题</p>
  58. <div class="Big-Book-top">
  59. <span>正标题</span>
  60. <el-input
  61. style="width: 80%"
  62. type="textarea"
  63. autosize
  64. placeholder="请输入正标题"
  65. v-model="topic.z_title"
  66. @blur="onBlur(topic, 'z_title')"
  67. ></el-input>
  68. </div>
  69. <div class="Big-Book-top">
  70. <span>副标题</span>
  71. <el-input
  72. style="width: 80%"
  73. type="textarea"
  74. autosize
  75. placeholder="请输入副标题"
  76. v-model="topic.f_title"
  77. @blur="onBlur(topic, 'f_title')"
  78. ></el-input>
  79. </div>
  80. <div class="Big-Book-top">
  81. <span>是否有背景色</span>
  82. <el-radio v-model="topic.is_bg" :label="true">有</el-radio>
  83. <el-radio v-model="topic.is_bg" :label="false">无</el-radio>
  84. </div>
  85. <div class="Big-Book-top">
  86. <span>是否有背景图</span>
  87. <el-radio v-model="topic.is_layout" :label="true">有</el-radio>
  88. <el-radio v-model="topic.is_layout" :label="false">无</el-radio>
  89. </div>
  90. <div
  91. v-for="(rowItem, rowIndex) in topic.table_list"
  92. :key="'row' + rowIndex + index"
  93. >
  94. <div
  95. v-for="(topicIitem, lineIndex) in rowItem"
  96. :key="lineIndex"
  97. >
  98. <p>{{ topicIitem.text }}</p>
  99. <div>
  100. <template
  101. v-if="
  102. topicIitem.type == 'article_chs' ||
  103. (topicIitem.data &&
  104. topicIitem.data.type == 'article_chs')
  105. "
  106. >
  107. <template v-if="topicIitem.is_edit">
  108. <ArticleTemChs
  109. :curQue="topicIitem.data"
  110. :changeCurQue="changeCurQue"
  111. />
  112. </template>
  113. <template v-else>
  114. <ArticleView :curQue="topicIitem.data" />
  115. </template>
  116. </template>
  117. <template v-if="topicIitem.type == 'sentence_segword_chs'">
  118. <template v-if="topicIitem.is_edit">
  119. <SentenceSegwordChs
  120. :curQue="topicIitem.data"
  121. :changeCurQue="changeCurQue"
  122. />
  123. </template>
  124. <template v-else>
  125. <ArticleView :curQue="topicIitem.data" />
  126. </template>
  127. </template>
  128. <template
  129. v-if="
  130. topicIitem.type == 'dialog_article_chs' ||
  131. (topicIitem.data &&
  132. topicIitem.data.type == 'dialog_article_chs')
  133. "
  134. >
  135. <template v-if="topicIitem.is_edit">
  136. <DialogueArticleChs
  137. :curQue="topicIitem.data"
  138. :changeCurQue="changeCurQue"
  139. />
  140. </template>
  141. <template v-else>
  142. <!-- <ArticleView :curQue="topicIitem.que" /> -->
  143. </template>
  144. </template>
  145. <template v-if="topicIitem.type == 'NewWord_chs'">
  146. <template v-if="topicIitem.is_edit">
  147. <Neword
  148. :curQue="topicIitem.data"
  149. :changeCurQue="changeCurQue"
  150. />
  151. </template>
  152. <template v-else>
  153. <NewordPhraseview :curQue="topicIitem.data" />
  154. </template>
  155. </template>
  156. <template v-if="topicIitem.type == 'notes_chs'">
  157. <template v-if="topicIitem.is_edit">
  158. <Notes
  159. :curQue="topicIitem.data"
  160. :changeCurQue="changeCurQue"
  161. />
  162. </template>
  163. <template v-else>
  164. <NewordPhraseview :curQue="topicIitem.data" />
  165. </template>
  166. </template>
  167. <template v-if="topicIitem.type == 'input_record_chs'">
  168. <template v-if="topicIitem.is_edit">
  169. <InputRecord
  170. :curQue="topicIitem.data"
  171. :fn_data="fn_data"
  172. :changeCurQue="changeCurQue"
  173. />
  174. </template>
  175. <template v-else> </template>
  176. </template>
  177. <template
  178. v-if="
  179. topicIitem.type == 'recordHZ_inputPY_chs' ||
  180. topicIitem.type == 'inputItem_chs' ||
  181. topicIitem.type == 'sentence_input' ||
  182. topicIitem.type == 'sentence_judge' ||
  183. topicIitem.type == 'sentence_record'
  184. "
  185. >
  186. <template v-if="topicIitem.is_edit">
  187. <Sentence
  188. :curQue="topicIitem.data"
  189. :type="topicIitem.type"
  190. :fn_data="fn_data"
  191. :changeCurQue="changeCurQue"
  192. />
  193. </template>
  194. <template v-else> </template>
  195. </template>
  196. <template v-if="topicIitem.type == 'upload_control_chs'">
  197. <template v-if="topicIitem.is_edit">
  198. <UploadControl
  199. :curQue="topicIitem.data"
  200. :type="topicIitem.type"
  201. :fn_data="fn_data"
  202. :changeCurQue="changeCurQue"
  203. />
  204. </template>
  205. <template v-else>
  206. <UploadControlView
  207. :curQue="topicIitem.data"
  208. :fn_data="fn_data"
  209. />
  210. </template>
  211. </template>
  212. <template v-if="topicIitem.type == 'sudoku_chs'">
  213. <template v-if="topicIitem.is_edit">
  214. <Sudoku
  215. :curQue="topicIitem.data"
  216. :type="topicIitem.type"
  217. :fn_data="fn_data"
  218. :changeCurQue="changeCurQue"
  219. />
  220. </template>
  221. <template v-else> </template>
  222. </template>
  223. <template v-if="topicIitem.type == 'NumberCombination_chs'">
  224. <template v-if="topicIitem.is_edit">
  225. <NumberCombination
  226. :curQue="topicIitem.data"
  227. :type="topicIitem.type"
  228. :fn_data="fn_data"
  229. :changeCurQue="changeCurQue"
  230. />
  231. </template>
  232. <template v-else> </template>
  233. </template>
  234. <template v-if="topicIitem.type == 'toneSelect_chs'">
  235. <template v-if="topicIitem.is_edit">
  236. <ToneSelect
  237. :curQue="topicIitem.data"
  238. :type="topicIitem.type"
  239. :fn_data="fn_data"
  240. :changeCurQue="changeCurQue"
  241. />
  242. </template>
  243. <template v-else> </template>
  244. </template>
  245. </div>
  246. <div
  247. class="addoption"
  248. v-if="topicIitem.data && topicIitem.is_edit"
  249. @click="
  250. remoeModule(toindex, rowIndex, lineIndex, topicIitem)
  251. "
  252. >
  253. 删除模板
  254. </div>
  255. <div
  256. v-else-if="
  257. TopicIndex == toindex &&
  258. RowIndex == rowIndex &&
  259. lineIndex == LineIndex
  260. "
  261. class="addoption"
  262. >
  263. 选择模板
  264. </div>
  265. <div
  266. v-if="!topicIitem.data && topicIitem.is_add_module"
  267. class="addoption"
  268. @click="addModule(toindex, rowIndex, lineIndex, topicIitem)"
  269. >
  270. 添加模板
  271. </div>
  272. <template v-if="topicIitem.data">
  273. <div class="Big-Book-save" v-if="topicIitem.is_edit">
  274. <el-button
  275. type="success"
  276. size="small"
  277. @click="onSure(topicIitem)"
  278. >确定</el-button
  279. >
  280. </div>
  281. <div class="Big-Book-save" v-else>
  282. <el-button
  283. type="primary"
  284. size="small"
  285. @click.stop="editCurQue(topicIitem)"
  286. >编辑</el-button
  287. >
  288. </div>
  289. </template>
  290. </div>
  291. </div>
  292. </div>
  293. </el-tab-pane>
  294. </el-tabs>
  295. </div>
  296. <div class="Book-function" v-if="currentTreeID">
  297. <ul class="function-list">
  298. <li
  299. v-for="(item, index) in fn_data"
  300. :key="'fn' + index"
  301. @click="selectedFnType(item, index)"
  302. >
  303. <el-dropdown v-if="item.list">
  304. <span class="fn-name">
  305. {{ item.name }}<i class="el-icon-arrow-down el-icon--right"></i>
  306. </span>
  307. <el-dropdown-menu slot="dropdown" trigger="click">
  308. <el-dropdown-item
  309. @click.native="selectSmallModule(item, child, index, i)"
  310. v-for="(child, i) in item.list"
  311. :key="i"
  312. >{{ child.name }}</el-dropdown-item
  313. >
  314. </el-dropdown-menu>
  315. </el-dropdown>
  316. <span v-else class="fn-name">{{ item.name }}</span>
  317. </li>
  318. </ul>
  319. </div>
  320. </div>
  321. <el-dialog
  322. :visible.sync="previewVisible"
  323. title="预览"
  324. top="0"
  325. width="100%"
  326. @close="handleClosePre"
  327. >
  328. <div class="chooseCon">
  329. <Preview
  330. :context="context"
  331. :que-index="queIndex"
  332. :fatherName="fatherName"
  333. />
  334. </div>
  335. <span slot="footer" class="dialog-footer">
  336. <el-button @click="handleClosePre">关 闭</el-button>
  337. </span>
  338. </el-dialog>
  339. </div>
  340. </template>
  341. <script>
  342. import Header from "@/components/Header.vue";
  343. import Catelog from "@/components/Adult/inputModules/Catelog";
  344. import ArticleTemChs from "@/components/Adult/inputModules/ArticleTemChs/index.vue";
  345. import SentenceSegwordChs from "@/components/Adult/inputModules/SentenceSegwordChs/index.vue";
  346. import DialogueArticleChs from "@/components/Adult/inputModules/DialogueArticleChs/index.vue";
  347. import Single from "@/components/Adult/inputModules/Single.vue";
  348. import Judge from "@/components/Adult/inputModules/Judge.vue";
  349. import Dialogue from "@/components/Adult/inputModules/Dialogue.vue";
  350. import MatrixSingle from "@/components/Adult/inputModules/MatrixSingle.vue";
  351. import MultiRowInput from "@/components/Adult/inputModules/MultiRowInput.vue";
  352. import Ligature from "@/components/Adult/inputModules/Ligature.vue";
  353. import Neword from "@/components/Adult/inputModules/Neword.vue";
  354. import Notes from "@/components/Adult/inputModules/Notes.vue";
  355. import InputRecord from "@/components/Adult/inputModules/InputRecord.vue";
  356. import AudioControl from "@/components/Adult/inputModules/AudioControl.vue";
  357. import SuitchControl from "@/components/Adult/inputModules/SuitchControl.vue";
  358. import BgControl from "@/components/Adult/inputModules/BgControl.vue";
  359. import UploadControl from "@/components/Adult/inputModules/UploadControl.vue";
  360. import TextItem from "@/components/Adult/inputModules/TextItem.vue";
  361. import Sentence from "@/components/Adult/inputModules/Sentence.vue";
  362. import Sudoku from "@/components/Adult/inputModules/Sudoku.vue";
  363. import ToneSelect from "@/components/Adult/inputModules/ToneSelect.vue";
  364. import NumberCombination from "@/components/Adult/inputModules/NumberCombination.vue";
  365. import Textdes from "@/components/Adult/inputModules/Textdes.vue";
  366. import Record from "@/components/Adult/inputModules/Record.vue";
  367. import Hanzi from "@/components/Adult/inputModules/Hanzi.vue";
  368. import Picture from "@/components/Adult/inputModules/Picture.vue";
  369. import Singleview from "@/components/Adult/preview/Single.vue";
  370. import Judgeview from "@/components/Adult/preview/Judge.vue";
  371. import Textdesview from "@/components/Adult/preview/Textdes.vue";
  372. import Hanziview from "@/components/Adult/preview/Hanzi.vue";
  373. import Pictureview from "@/components/Adult/preview/Picture.vue";
  374. import Dialogueview from "@/components/Adult/preview/Dialogue.vue";
  375. import MatrixSingleview from "@/components/Adult/preview/MatrixSingle.vue";
  376. import MultiRowInputview from "@/components/Adult/preview/MultiRowInput.vue";
  377. import Ligatureview from "@/components/Adult/preview/Ligature.vue";
  378. import InputRecordview from "@/components/Adult/preview/InputRecord.vue";
  379. import BgControlview from "@/components/Adult/preview/BgControl.vue";
  380. import NewordPhraseview from "@/components/Adult/preview/WordPhrase.vue";
  381. import UploadControlView from "@/components/Adult/preview/UploadControlView.vue";
  382. import Preview from "@/components/Adult/Preview.vue";
  383. import fn from "@/components/Adult/common/data.js";
  384. import { getContent, getStaticContent } from "@/api/ajax";
  385. export default {
  386. components: {
  387. Header,
  388. Catelog,
  389. Single,
  390. Textdes,
  391. Record,
  392. Singleview,
  393. Textdesview,
  394. Hanziview,
  395. Pictureview,
  396. Preview,
  397. Hanzi,
  398. Picture,
  399. Judge,
  400. Judgeview,
  401. Dialogue,
  402. Dialogueview,
  403. MatrixSingle,
  404. MatrixSingleview,
  405. MultiRowInput,
  406. MultiRowInputview,
  407. Ligature,
  408. Ligatureview,
  409. Neword,
  410. Notes,
  411. InputRecord,
  412. ArticleTemChs,
  413. SentenceSegwordChs,
  414. DialogueArticleChs,
  415. AudioControl,
  416. SuitchControl,
  417. BgControl,
  418. InputRecordview,
  419. BgControlview,
  420. NewordPhraseview,
  421. UploadControl,
  422. TextItem,
  423. Sentence,
  424. UploadControlView,
  425. Sudoku,
  426. NumberCombination,
  427. ToneSelect,
  428. },
  429. data() {
  430. return {
  431. bookId: 1,
  432. bookLevel: "",
  433. bookIndex: "",
  434. fn_data: [],
  435. fn_type: "",
  436. cur_fn_data: null, //当前模块的数据结构
  437. cur_page_queIsEdit: [], //当前页数的某个题
  438. question_list: [
  439. {
  440. name: "tab1",
  441. title: "第1页",
  442. cur_fn_data: [],
  443. },
  444. ], //总的数据列表
  445. cur_page_que_index: 0,
  446. editableTabsValue: "tab1",
  447. tabIndex: 0,
  448. previewVisible: false,
  449. context: [],
  450. queIndex: 0,
  451. currentTreeID: null,
  452. row: null, //行
  453. line: null, //列
  454. TopicIndex: null, //第几题的索引
  455. RowIndex: null, //第几行
  456. LineIndex: null, //第几列
  457. bgControlX: null, // 背景图插入模板的 x
  458. bgControlY: null, // 背景图插入模板的 y
  459. bgControlIndex: null, //插入第几个
  460. DeletebgControlIndex: null, //删除第几个
  461. fatherName: "",
  462. module_type: "",
  463. tmInde: "",
  464. };
  465. },
  466. computed: {
  467. getCurrentQuestionView() {
  468. const function_type = this.fn_type;
  469. switch (function_type) {
  470. case "single":
  471. return Single;
  472. case "text":
  473. return Textdes;
  474. case "record":
  475. return Record;
  476. }
  477. },
  478. },
  479. watch: {},
  480. //方法集合
  481. methods: {
  482. // 随意插入模板获取位置
  483. changeSite(x, y) {
  484. this.bgControlX = x;
  485. this.bgControlY = y;
  486. },
  487. // 插入索引
  488. changebgControlIndex(index) {
  489. this.bgControlIndex = index;
  490. },
  491. // 删除索引
  492. changeDeletebgControlIndex(index) {
  493. this.DeletebgControlIndex = index;
  494. },
  495. rowLine(value) {
  496. this[value] = this[value].match(/^\d*(\.?\d{0,2})/g)[0] || "";
  497. },
  498. createTable() {
  499. if (this.row && this.line) {
  500. let arr = {
  501. z_title: "",
  502. f_title: "",
  503. is_bg: false, //是否有背景色
  504. is_layout: false, // 是不是按背景图布局
  505. table_list: [],
  506. };
  507. for (let i = 0; i < this.row; i++) {
  508. let rowArr = [];
  509. for (let j = 0; j < this.line; j++) {
  510. let obj = {
  511. text: `第${i + 1}行,第${j + 1}列`,
  512. is_add_module: true,
  513. is_edit: true,
  514. };
  515. rowArr.push(obj);
  516. }
  517. arr.table_list.push(rowArr);
  518. }
  519. this.question_list[this.tabIndex].cur_fn_data.push(arr);
  520. this.row = null;
  521. this.line = null;
  522. } else {
  523. this.$message.warning("请输入行和列");
  524. }
  525. },
  526. // 添加模板
  527. addModule(topicIndex, rowindex, lineIndex, item) {
  528. this.TopicIndex = topicIndex;
  529. this.RowIndex = rowindex;
  530. this.LineIndex = lineIndex;
  531. item.is_add_module = false;
  532. },
  533. // 删除模板
  534. remoeModule(topicIndex, rowindex, lineIndex, item) {
  535. // this.question_list[this.tabIndex].cur_fn_data[topicIndex].tableList[
  536. // rowindex
  537. // ][lineIndex].que = null;
  538. // this.$set(
  539. // this.question_list[this.tabIndex].cur_fn_data[topicIndex].tableList[
  540. // rowindex
  541. // ][lineIndex],
  542. // "que",
  543. // null
  544. // );
  545. item.type = "";
  546. item.data = null;
  547. this.TopicIndex = null;
  548. this.RowIndex = null;
  549. this.LineIndex = null;
  550. item.is_add_module = true;
  551. },
  552. handleClosePre() {
  553. if (window.stopAudioVoice) window.stopAudioVoice();
  554. if (window.stopAudioAudio) window.stopAudioAudio();
  555. if (window.stopAudioSound) window.stopAudioSound();
  556. this.previewVisible = false;
  557. },
  558. onBlur(item, field) {
  559. item[field] = item[field] ? item[field].trim() : "";
  560. },
  561. // 当前目录id name 父级name/当前 name
  562. changeId(id, name, fatherName) {
  563. this.fatherName = fatherName;
  564. this.currentTreeID = id;
  565. // 根据当前目录切换题
  566. let MethodName = "book-courseware_manager-GetCoursewareContent";
  567. let data = {
  568. id,
  569. };
  570. getContent(MethodName, data)
  571. .then((res) => {
  572. this.question_list = JSON.parse(res.content);
  573. this.cur_page_que_index =
  574. this.question_list[this.tabIndex].cur_fn_data.length - 1;
  575. })
  576. .catch((error) => {});
  577. },
  578. handleTabsEdit(targetName, action) {
  579. if (action === "add") {
  580. let leg = this.question_list.length;
  581. let obj = {
  582. name: `tab${leg + 1}`,
  583. title: `第${leg + 1}页`,
  584. cur_fn_data: [],
  585. };
  586. this.question_list.push(obj);
  587. }
  588. if (action === "remove") {
  589. let tabs = JSON.parse(JSON.stringify(this.question_list));
  590. let activeName = this.editableTabsValue;
  591. if (activeName === targetName) {
  592. tabs.forEach((tab, index) => {
  593. if (tab.name === targetName) {
  594. let nextTab = tabs[index + 1] || tabs[index - 1];
  595. if (nextTab) {
  596. activeName = nextTab.name;
  597. }
  598. }
  599. });
  600. }
  601. this.editableTabsValue = activeName;
  602. let question_list = tabs.filter((tab) => tab.name !== targetName);
  603. question_list.map((item, index) => {
  604. item.name = `tab${index + 1}`;
  605. item.title = `第${index + 1}页`;
  606. return item;
  607. });
  608. this.question_list = question_list;
  609. this.TopicIndex = null;
  610. this.RowIndex = null;
  611. this.LineIndex = null;
  612. }
  613. },
  614. tabClick(tab) {
  615. this.tabIndex = tab.index;
  616. },
  617. // 大模板
  618. selectedFnType(item, index) {
  619. if (item.list) {
  620. return;
  621. }
  622. if (
  623. Object.prototype.toString.call(this.TopicIndex).indexOf("Number") ==
  624. -1 &&
  625. Object.prototype.toString.call(this.LineIndex).indexOf("Number") == -1
  626. ) {
  627. this.$message.warning("请先选择添加模板的位置");
  628. return;
  629. }
  630. if (
  631. this.question_list[this.tabIndex].cur_fn_data[this.TopicIndex]
  632. .table_list[this.RowIndex][this.LineIndex].data
  633. ) {
  634. this.$message.warning("每列只能添加一个模板");
  635. } else {
  636. console.log("不存在");
  637. this.$set(
  638. this.question_list[this.tabIndex].cur_fn_data[this.TopicIndex]
  639. .table_list[this.RowIndex][this.LineIndex],
  640. "type",
  641. item.type
  642. );
  643. this.$set(
  644. this.question_list[this.tabIndex].cur_fn_data[this.TopicIndex]
  645. .table_list[this.RowIndex][this.LineIndex],
  646. "data",
  647. null
  648. );
  649. console.log(this.question_list);
  650. }
  651. },
  652. changeCurQue(data_stru) {
  653. console.log(this.RowIndex, this.LineIndex);
  654. this.$set(
  655. this.question_list[this.tabIndex].cur_fn_data[this.TopicIndex]
  656. .table_list[this.RowIndex][this.LineIndex],
  657. "data",
  658. JSON.parse(JSON.stringify(data_stru))
  659. );
  660. console.log(this.question_list);
  661. },
  662. // 小模板
  663. selectSmallModule(item, child, itemIndex, childIndex) {
  664. console.log("选择了小模版");
  665. if (
  666. Object.prototype.toString.call(this.TopicIndex).indexOf("Number") ==
  667. -1 &&
  668. Object.prototype.toString.call(this.LineIndex).indexOf("Number") == -1
  669. ) {
  670. this.$message.warning("请先选择添加模板的位置");
  671. return;
  672. }
  673. if (
  674. this.question_list[this.tabIndex].cur_fn_data[this.TopicIndex]
  675. .table_list[this.RowIndex][this.LineIndex].data
  676. ) {
  677. this.$message.warning("每列只能添加一个模板");
  678. } else {
  679. this.$set(
  680. this.question_list[this.tabIndex].cur_fn_data[this.TopicIndex]
  681. .table_list[this.RowIndex][this.LineIndex],
  682. "type",
  683. child.type
  684. );
  685. this.$set(
  686. this.question_list[this.tabIndex].cur_fn_data[this.TopicIndex]
  687. .table_list[this.RowIndex][this.LineIndex],
  688. "data",
  689. null
  690. );
  691. }
  692. },
  693. //删除某页中一个部分
  694. deleteCurQue(item, queIndex) {
  695. item.queList.splice(queIndex, 1);
  696. },
  697. saveNewwordAndSentences() {
  698. let question_list = this.question_list;
  699. let sentence_list = [],
  700. new_word_list = [];
  701. question_list.forEach((item) => {
  702. item.cur_fn_data.forEach((curItem) => {
  703. curItem.table_list.forEach((tabItem) => {
  704. tabItem.forEach((topicIitem) => {
  705. if (topicIitem.type == "article_chs") {
  706. topicIitem.data.detail.forEach((item) => {
  707. sentence_list = sentence_list.concat(item.sentences);
  708. });
  709. } else if (topicIitem.type == "NewWord_chs") {
  710. new_word_list = topicIitem.data.option;
  711. }
  712. });
  713. });
  714. });
  715. });
  716. return {
  717. new_word_list: new_word_list,
  718. sentence_list: sentence_list,
  719. };
  720. },
  721. onSave() {
  722. let question_list_str = JSON.stringify(this.question_list);
  723. console.log(this.question_list);
  724. localStorage.setItem("question_list", question_list_str);
  725. let result = this.saveNewwordAndSentences();
  726. this.$message.success("保存成功");
  727. const MethodName = "book-courseware_manager-SaveCoursewareContent";
  728. let data = {
  729. id: this.currentTreeID,
  730. content: JSON.stringify(this.question_list),
  731. new_word_list: result.new_word_list,
  732. sentence_list: result.sentence_list,
  733. };
  734. getContent(MethodName, data)
  735. .then((res) => {
  736. this.$message.success("保存成功!");
  737. })
  738. .catch((error) => {});
  739. },
  740. async onPreview() {
  741. let _this = this;
  742. let question_data = null;
  743. if (_this.question_list) {
  744. debugger;
  745. const question2 = JSON.parse(JSON.stringify(_this.question_list));
  746. question_data = await _this.getFileUrl_preview(question2);
  747. _this.previewVisible = true;
  748. _this.context = question_data;
  749. console.log("预览数据");
  750. console.log(this.question_list);
  751. } else {
  752. _this.$message.warning("还没有录入数据");
  753. }
  754. },
  755. getFileUrl_preview(question) {
  756. let questionStr = JSON.stringify(question);
  757. const reg = /\[FID##(.*?)##FID\]/g;
  758. let regConArr = [];
  759. if (reg.test(questionStr)) {
  760. regConArr = questionStr.match(reg);
  761. }
  762. if (regConArr.length > 0) {
  763. regConArr = regConArr.map((item) => {
  764. item = item.replace("[FID##", "").replace("##FID]", "");
  765. return item;
  766. });
  767. }
  768. return new Promise((resolve, reject) => {
  769. const MethodName = "file_store_manager-GetFileURLMap";
  770. const data = {
  771. file_id_list: regConArr,
  772. };
  773. getStaticContent(MethodName, data).then((res) => {
  774. const backData = res.url_map;
  775. for (const key in backData) {
  776. const url = backData[key];
  777. if (questionStr.indexOf(key) > -1) {
  778. const d = `\\[FID##${key}##FID\\]`;
  779. const regD = new RegExp(d, "g");
  780. questionStr = questionStr.replace(regD, url);
  781. }
  782. }
  783. const question3 = JSON.parse(questionStr);
  784. resolve(question3);
  785. });
  786. });
  787. },
  788. onSure(curItem) {
  789. this.TopicIndex = null;
  790. this.RowIndex = null;
  791. this.LineIndex = null;
  792. curItem.is_edit = false;
  793. },
  794. onDel(item, curIndex) {
  795. item.cur_fn_data.splice(curIndex, 1);
  796. if (this.question_list[this.tabIndex].cur_fn_data.length > 0) {
  797. this.cur_page_que_index =
  798. this.question_list[this.tabIndex].cur_fn_data.length - 1;
  799. } else {
  800. this.cur_page_que_index = 0;
  801. }
  802. // let question_list_str = JSON.stringify(this.question_list);
  803. // localStorage.setItem("question_list", question_list_str);
  804. },
  805. //编辑当前题型
  806. editCurQue(curItem) {
  807. curItem.is_edit = true;
  808. // if (!curItem.isEdit) {
  809. // let count = 0;
  810. // let tabIndex = this.tabIndex;
  811. // let leg = this.question_list[tabIndex].cur_fn_data.length;
  812. // this.question_list[tabIndex].cur_fn_data.forEach((item) => {
  813. // if (item.isEdit) {
  814. // count++;
  815. // }
  816. // });
  817. // if (count == 0) {
  818. // if (!curItem.isEdit) {
  819. // curItem.isEdit = true;
  820. // }
  821. // } else {
  822. // this.$message.warning("有题目未保存");
  823. // }
  824. // }
  825. },
  826. },
  827. //生命周期 - 创建完成(可以访问当前this实例)
  828. created() {
  829. this.fn_data = fn.fnData;
  830. },
  831. //生命周期 - 挂载完成(可以访问DOM元素)
  832. mounted() {
  833. console.log(this.question_list);
  834. // let question_list_str = localStorage.getItem("question_list");
  835. // if (question_list_str) {
  836. // this.question_list = JSON.parse(question_list_str);
  837. // this.cur_page_que_index =
  838. // this.question_list[this.tabIndex].cur_fn_data.length - 1;
  839. // }
  840. },
  841. beforeCreate() {}, //生命周期 - 创建之前
  842. beforeMount() {}, //生命周期 - 挂载之前
  843. beforeUpdate() {}, //生命周期 - 更新之前
  844. updated() {}, //生命周期 - 更新之后
  845. beforeDestroy() {}, //生命周期 - 销毁之前
  846. destroyed() {}, //生命周期 - 销毁完成
  847. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  848. };
  849. </script>
  850. <style lang='scss' scoped>
  851. //@import url(); 引入公共css类
  852. .Big-Book-container {
  853. width: 100%;
  854. min-height: 100vh;
  855. .Big-Book-content {
  856. padding: 26px 0;
  857. display: flex;
  858. justify-content: flex-start;
  859. align-items: flex-start;
  860. }
  861. .content-tree {
  862. width: 280px;
  863. }
  864. .Book-content {
  865. flex: 1;
  866. box-sizing: border-box;
  867. padding: 30px;
  868. height: 859px;
  869. overflow-y: auto;
  870. &-inner {
  871. // width: 860px;
  872. }
  873. .addoption {
  874. width: 148px;
  875. height: 40px;
  876. background: #f3f3f3;
  877. border: 1px dashed rgba(0, 0, 0, 0.15);
  878. box-sizing: border-box;
  879. border-radius: 4px;
  880. text-align: center;
  881. line-height: 40px;
  882. cursor: pointer;
  883. font-size: 14px;
  884. color: #000000;
  885. margin-top: 20px;
  886. }
  887. .createTable {
  888. }
  889. }
  890. .Big-Book-save {
  891. width: 860px;
  892. display: flex;
  893. justify-content: flex-end;
  894. padding: 0 0 20px 0;
  895. }
  896. .Big-Book {
  897. &-add {
  898. position: absolute;
  899. top: -40px;
  900. right: 0;
  901. z-index: 1;
  902. width: 73px;
  903. height: 40px;
  904. background: #f7f7f7;
  905. border: 1px solid #d9d9d9;
  906. line-height: 40px;
  907. text-align: center;
  908. font-weight: bold;
  909. font-size: 18px;
  910. text-align: center;
  911. color: #000000;
  912. }
  913. &-name {
  914. display: flex;
  915. justify-content: flex-start;
  916. align-items: center;
  917. margin-bottom: 10px;
  918. > p {
  919. font-size: 14px;
  920. }
  921. }
  922. &-delete {
  923. width: 16px;
  924. height: 16px;
  925. margin-left: 15px;
  926. cursor: pointer;
  927. }
  928. &-curPage {
  929. margin-bottom: 20px;
  930. &.Big-Book-curPage-edit {
  931. border-top: 1px solid #e0e0e0;
  932. border-bottom: 1px solid #e0e0e0;
  933. background-color: #fafafa;
  934. }
  935. &.Big-Book-curPage-preview {
  936. border-top: 1px solid #fff;
  937. border-bottom: 1px solid #fff;
  938. display: flex;
  939. justify-content: flex-start;
  940. align-items: flex-start;
  941. &:hover {
  942. background-color: #fafafa;
  943. border-top: 1px solid #e0e0e0;
  944. border-bottom: 1px solid #e0e0e0;
  945. }
  946. }
  947. }
  948. &-queBox {
  949. padding: 10px 0;
  950. }
  951. }
  952. .Book-function {
  953. width: 204px;
  954. background: #f7f7f7;
  955. box-sizing: border-box;
  956. padding: 30px 16px;
  957. height: 859px;
  958. overflow-y: auto;
  959. .function-list {
  960. width: 100%;
  961. > li {
  962. width: 100%;
  963. width: 172px;
  964. height: 40px;
  965. background: #ffffff;
  966. border: 1px solid rgba(0, 0, 0, 0.15);
  967. box-sizing: border-box;
  968. border-radius: 4px;
  969. cursor: pointer;
  970. margin-bottom: 5px;
  971. display: flex;
  972. justify-content: center;
  973. align-items: center;
  974. > span {
  975. font-weight: normal;
  976. font-size: 16px;
  977. line-height: 150%;
  978. color: #000000;
  979. }
  980. }
  981. }
  982. }
  983. .Big-Book-top {
  984. margin-top: 20px;
  985. display: flex;
  986. align-items: center;
  987. span {
  988. margin-right: 10px;
  989. }
  990. }
  991. }
  992. </style>