Quellcode durchsuchen

存储汉字卡片已存储信息

natasha vor 1 Jahr
Ursprung
Commit
a5d9de6b27
2 geänderte Dateien mit 74 neuen und 15 gelöschten Zeilen
  1. 45 11
      src/views/wordcard/cread.vue
  2. 29 4
      src/views/wordcard/writeTable.vue

+ 45 - 11
src/views/wordcard/cread.vue

@@ -136,6 +136,7 @@
             :totalNumber="writeTableData.result.length"
             :fontSize="from.fontSize"
             :audio_file_obj="writeTableData.audio_file_obj"
+            :infoObj="from.infoObj"
           />
         </div>
       </div>
@@ -180,7 +181,7 @@
 //这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
 //例如:import 《组件名称》from ‘《组件路径》';
 import Header from '@/components/Header';
-import { getLogin, LearnWebSI } from '@/api/api';
+import { getLogin, LearnWebSI, getHZChineseInfo, getContentFile } from '@/api/api';
 import writeTable from './writeTable.vue';
 import html2canvas from 'html2canvas';
 import { jsPDF } from 'jspdf';
@@ -217,6 +218,7 @@ export default {
         writeColor: '#000000', //书写颜色
         borderColor: '#D65353', //边框颜色
         fontColor: '#000000', //文字颜色
+        infoObj: {}, // 存储上传图片及文字信息等内容
       },
       loading: false,
       writeTableData: null,
@@ -437,6 +439,7 @@ export default {
         writeBoxNumber: this.from.writeBoxNumber,
         miaoRedBoxNumber: this.from.miaoRedBoxNumber,
         lastNullrow: this.from.lastNullrow,
+        infoObj: this.from.infoObj ? this.from.infoObj : {}, // 存储上传图片及文字信息等内容
       };
       if (this.from.fontSize == 'big') {
         data.width = '62px';
@@ -604,15 +607,36 @@ export default {
           });
           item.hz_list = hz_list;
           item.pinyin = pinyin(item.con);
-          let MethodName = 'tool-PinyinToVoiceFile';
+          let MethodName = 'tool-TextToVoiceFile';
           let datas = {
-            pinyin: item.pinyin.split(' ').join(','),
+            text: item.con,
           };
           await getLogin(MethodName, datas).then((res) => {
             if (res.status === 1) {
               audio_file_obj[item.con] = res.file_id;
             }
           });
+          // let data = {
+          //   query: item.con,
+          // };
+          // getHZChineseInfo(data).then((res) => {
+          //   let dataDetail = res.data.result;
+          //   if (dataDetail && dataDetail.length > 0) {
+          //     dataDetail.forEach((item) => {
+          //       if (item.request.queryType == 'entity') {
+          //         // 读音
+          //         item.response.entity.forEach((items) => {
+          //           items.attrs.forEach((itemss) => {
+          //             if (itemss.key == 'pronunciation') {
+          //               // 音频
+          //               audio_file_obj[item.con] = itemss.objects[0]['@value'] ? itemss.objects[0]['@value'] : '';
+          //             }
+          //           });
+          //         });
+          //       }
+          //     });
+          //   }
+          // });
         });
 
         data.option.forEach((item) => {
@@ -711,13 +735,22 @@ export default {
               arr.push(numrow);
             }
           }
+          if (!this.from.infoObj[item.con]) {
+            let item_con_obj = {
+              fileList: [],
+              definition: '',
+              collocation: '',
+              exampleSent: '',
+            };
+            this.$set(this.from.infoObj, item.con, item_con_obj);
+          }
           if (arr.length <= data.firstPageLine) {
             let obj = {
-              fileList: [],
+              fileList: this.from.infoObj[item.con] ? this.from.infoObj[item.con].fileList : [],
               info: {
-                definition: '',
-                collocation: '',
-                exampleSent: '',
+                definition: this.from.infoObj[item.con] ? this.from.infoObj[item.con].definition : '',
+                collocation: this.from.infoObj[item.con] ? this.from.infoObj[item.con].collocation : '',
+                exampleSent: this.from.infoObj[item.con] ? this.from.infoObj[item.con].exampleSent : '',
               },
               list: arr,
               hz_info: item.hz_list,
@@ -727,11 +760,11 @@ export default {
             final_result.push(obj);
           } else {
             let obj = {
-              fileList: [],
+              fileList: this.from.infoObj[item.con] ? this.from.infoObj[item.con].fileList : [],
               info: {
-                definition: '',
-                collocation: '',
-                exampleSent: '',
+                definition: this.from.infoObj[item.con] ? this.from.infoObj[item.con].definition : '',
+                collocation: this.from.infoObj[item.con] ? this.from.infoObj[item.con].collocation : '',
+                exampleSent: this.from.infoObj[item.con] ? this.from.infoObj[item.con].exampleSent : '',
               },
               list: arr.slice(0, data.firstPageLine),
               hz_info: item.hz_list,
@@ -1029,6 +1062,7 @@ export default {
         writeColor: '#000000', //书写颜色
         borderColor: '#D65353', //边框颜色
         fontColor: '#000000', //文字颜色
+        infoObj: {},
       };
       this.loading = false;
       this.writeTableData = null;

+ 29 - 4
src/views/wordcard/writeTable.vue

@@ -73,11 +73,23 @@
               </template>
               <template v-else>
                 <div class="item-info-row">
-                  <el-input v-model="data.info.definition" placeholder="输入释义"></el-input>
-                  <el-input v-model="data.info.collocation" placeholder="输入搭配"></el-input>
+                  <el-input
+                    v-model="data.info.definition"
+                    placeholder="输入释义"
+                    @blur="changeInfoObj('definition')"
+                  ></el-input>
+                  <el-input
+                    v-model="data.info.collocation"
+                    placeholder="输入搭配"
+                    @blur="changeInfoObj('collocation')"
+                  ></el-input>
                 </div>
                 <div class="item-info-row">
-                  <el-input v-model="data.info.exampleSent" placeholder="输入例句"></el-input>
+                  <el-input
+                    v-model="data.info.exampleSent"
+                    placeholder="输入例句"
+                    @blur="changeInfoObj('exampleSent')"
+                  ></el-input>
                 </div>
               </template>
             </div>
@@ -111,7 +123,14 @@
                   <div class="item-info-all">{{ data.info.definition }}</div>
                 </div>
               </template>
-              <el-input v-else type="textarea" v-model="data.info.definition" rows="2" placeholder="输入"></el-input>
+              <el-input
+                v-else
+                type="textarea"
+                v-model="data.info.definition"
+                rows="2"
+                placeholder="输入"
+                @blur="changeInfoObj('definition')"
+              ></el-input>
             </div>
           </template>
         </div>
@@ -241,6 +260,7 @@ export default {
     'fontSize',
     'audio_file_obj',
     'is_preview',
+    'infoObj',
   ],
   data() {
     //这里存放数据
@@ -310,9 +330,11 @@ export default {
         fileUrl: file.file_url_open,
       };
       this.data.fileList.push(obj);
+      this.infoObj[this.data.con].fileList = [obj];
     },
     handleDeleteImg() {
       this.data.fileList = [];
+      this.infoObj[this.data.con].fileList = [];
     },
     initHanziwrite() {
       let _this = this;
@@ -333,6 +355,9 @@ export default {
         },
       );
     },
+    changeInfoObj(param) {
+      this.infoObj[this.data.con][param] = this.data.info[param] ? this.data.info[param].trim() : '';
+    },
   },
   //生命周期 - 创建完成(可以访问当前this实例)
   created() {