Jelajahi Sumber

编辑拼音校正

natasha 4 hari lalu
induk
melakukan
88cc7f12cc

+ 4 - 0
src/api/pinyinCorrection.js

@@ -22,5 +22,9 @@ export function toolCopyPinyinCorrectionToStorage(data) {
   return http.post(`${process.env.VUE_APP_EepServer}?MethodName=tool-CopyPinyinCorrectionToStorage`,data);
 }
 
+// 编辑拼音校正
+export function toolUpdatePinyinCorrection(data) {
+  return http.post(`${process.env.VUE_APP_EepServer}?MethodName=tool-UpdatePinyinCorrection`, data);
+}
 
 

+ 68 - 24
src/views/personal_workbench/pinyin_correction_list/index.vue

@@ -59,6 +59,7 @@
 
         <el-table-column prop="operation" label="操作" fixed="right" width="200" align="center" header-align="center">
           <template slot-scope="{ row }">
+            <span class="link" @click="editTemplate(row)">编辑</span>
             <span class="link danger" @click="deleteTemplate(row)">删除</span>
           </template>
         </el-table-column>
@@ -67,7 +68,7 @@
       <PaginationPage ref="pagination" :total="total" @getList="queryTemplateList" />
     </div>
     <el-dialog
-      title="添加拼音校正"
+      :title="data.id ? '编辑拼音校正' : '添加拼音校正'"
       :visible="visible"
       width="660px"
       :close-on-click-modal="false"
@@ -131,7 +132,12 @@ import MenuPage from '../common/menu.vue';
 import PaginationPage from '@/components/PaginationPage.vue';
 
 import { PageQueryPinyinCorrectionListPersonal } from '@/api/list.js';
-import { toolAddPinyinCorrection, toolDeletePinyinCorrection, toolGetCXList } from '@/api/pinyinCorrection';
+import {
+  toolAddPinyinCorrection,
+  toolDeletePinyinCorrection,
+  toolGetCXList,
+  toolUpdatePinyinCorrection,
+} from '@/api/pinyinCorrection';
 
 export default {
   name: 'PersonalWorkbenchPinyinCorrectionList',
@@ -248,29 +254,55 @@ export default {
     // 确定创建拼音校正
     addTemplate() {
       this.loading = true;
-      toolAddPinyinCorrection(this.data)
-        .then((res) => {
-          this.loading = false;
-          this.visible = false;
-          if (res.status === 1) {
-            this.$message({
-              type: 'success',
-              message: '创建成功!',
-            });
-            this.data = {
-              storage_type: 0,
-              word: '',
-              pos: '',
-              pinyin: '',
-              pinyin_lt: '',
-            };
+      if (this.data.id) {
+        toolUpdatePinyinCorrection(this.data)
+          .then((res) => {
+            this.loading = false;
+            this.visible = false;
+            if (res.status === 1) {
+              this.$message({
+                type: 'success',
+                message: '修改成功!',
+              });
+              this.data = {
+                storage_type: 0,
+                word: '',
+                pos: '',
+                pinyin: '',
+                pinyin_lt: '',
+              };
 
-            this.queryList();
-          }
-        })
-        .catch(() => {
-          this.loading = false;
-        });
+              this.queryList();
+            }
+          })
+          .catch(() => {
+            this.loading = false;
+          });
+      } else {
+        toolAddPinyinCorrection(this.data)
+          .then((res) => {
+            this.loading = false;
+            this.visible = false;
+            if (res.status === 1) {
+              this.$message({
+                type: 'success',
+                message: '创建成功!',
+              });
+              this.data = {
+                storage_type: 0,
+                word: '',
+                pos: '',
+                pinyin: '',
+                pinyin_lt: '',
+              };
+
+              this.queryList();
+            }
+          })
+          .catch(() => {
+            this.loading = false;
+          });
+      }
     },
 
     // 删除词汇
@@ -293,6 +325,18 @@ export default {
         })
         .catch(() => {});
     },
+    // 编辑词汇
+    editTemplate(row) {
+      this.data = {
+        id: row.id,
+        storage_type: 0,
+        word: row.word,
+        pos: row.pos,
+        pinyin: row.pinyin,
+        pinyin_lt: row.pinyin_lt,
+      };
+      this.visible = true;
+    },
     CopyToClipboard(element) {
       var doc = document,
         text = doc.getElementById(element),

+ 64 - 24
src/views/personal_workbench/pinyin_correction_list_manager/index.vue

@@ -73,8 +73,9 @@
 
         <el-table-column prop="operation" label="操作" fixed="right" width="200" align="center" header-align="center">
           <template slot-scope="{ row }">
-            <span class="link danger" @click="deleteTemplate(row)">删除</span>
+            <span class="link" @click="editTemplate(row)">编辑</span>
             <span class="link" @click="copyPinyin(row)" v-if="row.storage_type !== 2">写入全域库</span>
+            <span class="link danger" @click="deleteTemplate(row)">删除</span>
           </template>
         </el-table-column>
       </el-table>
@@ -82,7 +83,7 @@
       <PaginationPage ref="pagination" :total="total" @getList="queryTemplateList" />
     </div>
     <el-dialog
-      title="添加拼音校正"
+      :title="data.id ? '编辑拼音校正' : '添加拼音校正'"
       :visible="visible"
       width="660px"
       :close-on-click-modal="false"
@@ -151,6 +152,7 @@ import {
   toolDeletePinyinCorrection,
   toolGetCXList,
   toolCopyPinyinCorrectionToStorage,
+  toolUpdatePinyinCorrection,
 } from '@/api/pinyinCorrection';
 
 export default {
@@ -287,29 +289,55 @@ export default {
     // 确定创建拼音校正
     addTemplate() {
       this.loading = true;
-      toolAddPinyinCorrection(this.data)
-        .then((res) => {
-          this.loading = false;
-          this.visible = false;
-          if (res.status === 1) {
-            this.$message({
-              type: 'success',
-              message: '创建成功!',
-            });
-            this.data = {
-              storage_type: 2,
-              word: '',
-              pos: '',
-              pinyin: '',
-              pinyin_lt: '',
-            };
+      if (this.data.id) {
+        toolUpdatePinyinCorrection(this.data)
+          .then((res) => {
+            this.loading = false;
+            this.visible = false;
+            if (res.status === 1) {
+              this.$message({
+                type: 'success',
+                message: '修改成功!',
+              });
+              this.data = {
+                storage_type: 2,
+                word: '',
+                pos: '',
+                pinyin: '',
+                pinyin_lt: '',
+              };
 
-            this.queryList();
-          }
-        })
-        .catch(() => {
-          this.loading = false;
-        });
+              this.queryList();
+            }
+          })
+          .catch(() => {
+            this.loading = false;
+          });
+      } else {
+        toolAddPinyinCorrection(this.data)
+          .then((res) => {
+            this.loading = false;
+            this.visible = false;
+            if (res.status === 1) {
+              this.$message({
+                type: 'success',
+                message: '创建成功!',
+              });
+              this.data = {
+                storage_type: 2,
+                word: '',
+                pos: '',
+                pinyin: '',
+                pinyin_lt: '',
+              };
+
+              this.queryList();
+            }
+          })
+          .catch(() => {
+            this.loading = false;
+          });
+      }
     },
 
     // 删除词汇
@@ -332,6 +360,18 @@ export default {
         })
         .catch(() => {});
     },
+    // 编辑词汇
+    editTemplate(row) {
+      this.data = {
+        id: row.id,
+        storage_type: row.storage_type,
+        word: row.word,
+        pos: row.pos,
+        pinyin: row.pinyin,
+        pinyin_lt: row.pinyin_lt,
+      };
+      this.visible = true;
+    },
     // 复制拼音到指定库
     copyPinyin(row) {
       this.$confirm('是否要将此词汇写入机构库吗?', '提示', {

+ 64 - 24
src/views/personal_workbench/pinyin_correction_list_org/index.vue

@@ -73,8 +73,9 @@
 
         <el-table-column prop="operation" label="操作" fixed="right" width="200" align="center" header-align="center">
           <template slot-scope="{ row }">
-            <span class="link danger" @click="deleteTemplate(row)">删除</span>
+            <span class="link" @click="editTemplate(row)">编辑</span>
             <span class="link" @click="copyPinyin(row)" v-if="row.storage_type === 0">写入机构库</span>
+            <span class="link danger" @click="deleteTemplate(row)">删除</span>
           </template>
         </el-table-column>
       </el-table>
@@ -82,7 +83,7 @@
       <PaginationPage ref="pagination" :total="total" @getList="queryTemplateList" />
     </div>
     <el-dialog
-      title="添加拼音校正"
+      :title="data.id ? '编辑拼音校正' : '添加拼音校正'"
       :visible="visible"
       width="660px"
       :close-on-click-modal="false"
@@ -151,6 +152,7 @@ import {
   toolDeletePinyinCorrection,
   toolGetCXList,
   toolCopyPinyinCorrectionToStorage,
+  toolUpdatePinyinCorrection,
 } from '@/api/pinyinCorrection';
 
 export default {
@@ -283,29 +285,55 @@ export default {
     // 确定创建拼音校正
     addTemplate() {
       this.loading = true;
-      toolAddPinyinCorrection(this.data)
-        .then((res) => {
-          this.loading = false;
-          this.visible = false;
-          if (res.status === 1) {
-            this.$message({
-              type: 'success',
-              message: '创建成功!',
-            });
-            this.data = {
-              storage_type: 1,
-              word: '',
-              pos: '',
-              pinyin: '',
-              pinyin_lt: '',
-            };
+      if (this.data.id) {
+        toolUpdatePinyinCorrection(this.data)
+          .then((res) => {
+            this.loading = false;
+            this.visible = false;
+            if (res.status === 1) {
+              this.$message({
+                type: 'success',
+                message: '修改成功!',
+              });
+              this.data = {
+                storage_type: 1,
+                word: '',
+                pos: '',
+                pinyin: '',
+                pinyin_lt: '',
+              };
 
-            this.queryList();
-          }
-        })
-        .catch(() => {
-          this.loading = false;
-        });
+              this.queryList();
+            }
+          })
+          .catch(() => {
+            this.loading = false;
+          });
+      } else {
+        toolAddPinyinCorrection(this.data)
+          .then((res) => {
+            this.loading = false;
+            this.visible = false;
+            if (res.status === 1) {
+              this.$message({
+                type: 'success',
+                message: '创建成功!',
+              });
+              this.data = {
+                storage_type: 1,
+                word: '',
+                pos: '',
+                pinyin: '',
+                pinyin_lt: '',
+              };
+
+              this.queryList();
+            }
+          })
+          .catch(() => {
+            this.loading = false;
+          });
+      }
     },
 
     // 删除词汇
@@ -328,6 +356,18 @@ export default {
         })
         .catch(() => {});
     },
+    // 编辑词汇
+    editTemplate(row) {
+      this.data = {
+        id: row.id,
+        storage_type: row.storage_type,
+        word: row.word,
+        pos: row.pos,
+        pinyin: row.pinyin,
+        pinyin_lt: row.pinyin_lt,
+      };
+      this.visible = true;
+    },
     // 复制拼音到指定库
     copyPinyin(row) {
       this.$confirm('是否要将此词汇写入机构库吗?', '提示', {