adultInput.vue 34 KB

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