| <template>  | 
|   <a-form style="margin-top: 8px">  | 
|     <a-modal  | 
|       title="编辑-字典"  | 
|       destroyOnClose  | 
|       :visible="visible"  | 
|       @cancel="handleCancel"  | 
|       @ok="handleOk"  | 
|       okText="保存"  | 
|     >  | 
|       <a-form style="margin-top: 8px">  | 
|         <a-form-item  | 
|           :labelCol="{ span: 5 }"  | 
|           :wrapperCol="{ span: 15 }"  | 
|           label="key"  | 
|           fieldDecoratorId="userName"  | 
|         >  | 
|           <a-input placeholder="请输入key" v-model="editTableInform.key"  disabled/>  | 
|         </a-form-item>  | 
|         <a-form-item  | 
|           :labelCol="{ span: 5 }"  | 
|           :wrapperCol="{ span: 15 }"  | 
|           label="value"  | 
|           fieldDecoratorId="mobile"  | 
|         >  | 
|           <a-input placeholder="请输入value" v-model="editTableInform.value" />  | 
|         </a-form-item>  | 
|   | 
|       </a-form>  | 
|     </a-modal>  | 
|   </a-form>  | 
| </template>  | 
|   | 
| <script lang="ts">  | 
| import {  | 
|   Component,  | 
|   Prop,  | 
|   Vue,  | 
|   Emit,  | 
|   Model,  | 
|   Watch  | 
| } from "vue-property-decorator";  | 
| import { State, Mutation, namespace } from "vuex-class";  | 
|   | 
| import { get, post } from "@/util/request";  | 
|   | 
| @Component({  | 
|   components: {}  | 
| })  | 
| export default class dictionaryManage extends Vue {  | 
|   private editTableInform: any = {  | 
|     key: null,  | 
|     value: null,  | 
|     id:null  | 
|   };  | 
|   @Prop({  | 
|     type: Boolean,  | 
|     default: false  | 
|   })  | 
|   private visible!: boolean;  | 
|   | 
|   @Prop({  | 
|     type: Object,  | 
|     default() {  | 
|       return {};  | 
|     }  | 
|   })  | 
|   private record!: any;  | 
|   | 
|   private handleCancel(): void {  | 
|      this.editTableInform.key = this.record.key;  | 
|     this.editTableInform.value = this.record.value;  | 
|     this.updateVisible(false);  | 
|   }  | 
|   // 保存 更新数据库  | 
|   private handleOk(): void {  | 
|     if(this.editTableInform.key!==this.record.key||this.editTableInform.value!==this.record.value){  | 
|       post("dict/data/update",  | 
|         {  | 
|           id: this.editTableInform.id,  | 
|           key: this.editTableInform.key==this.record.key?null:this.editTableInform.key,  | 
|           value: this.editTableInform.value==this.record.value?null:this.editTableInform.value,  | 
|         }).then(res => {  | 
|         if(res.data.code!=0){  | 
|           this.$message.error(res.data.message)  | 
|         }else{  | 
|         //保存成功,组件刷新数据  | 
|         this.$emit("updateData");  | 
|         this.$message.success(res.data.message)  | 
|         this.updateVisible(false);  | 
|         }  | 
|       })  | 
|       .catch(err => {  | 
|         console.log(err);  | 
|       });  | 
|     }else {  | 
|       this.$message.warning('未修改!')  | 
|     }  | 
|   | 
|   }  | 
|   | 
|   private updateVisible(visible: boolean): void {  | 
|     this.$emit("update:visible", visible);  | 
|   }  | 
|   | 
|   //监听编辑回调值  | 
|   @Watch("record", {  | 
|     immediate: true, //监听开始后是否立即调用该回调函数;  | 
|     deep: true //深度监听  | 
|   })  | 
|   //监听编辑逻辑赋值  | 
|   private recordChange(value: any, oldValue: any): void {  | 
|     this.editTableInform.key = this.record.key;  | 
|     this.editTableInform.value = this.record.value;  | 
|     this.editTableInform.id=this.record.id  | 
|   }  | 
| }  | 
| </script>  |