adultInput.vue 33 KB

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