| <template>  | 
|   <a-form-model style="margin-top: 8px"  | 
|                 :model="saveData"  | 
|                 :rules="rules"  | 
|                 ref="ruleForm"  | 
|   >  | 
|     <a-modal title="编辑-角色" destroyOnClose :visible="visible" @cancel="handleCancel">  | 
|       <a-form-model-item key="name" v-bind="formLayout" label="名称" prop="name">  | 
|         <a-input placeholder="请输入" v-model="saveData.name"/>  | 
|       </a-form-model-item>  | 
|       <!-- <a-form-item key="id" v-bind="formLayout" label="编号" fieldDecoratorId="id" :fieldDecoratorOptions="{  | 
|               rules: [{ required: true, message: '角色编号' }],  | 
|               initialValue: record.id,  | 
|           }">  | 
|           <a-input placeholder="请输入" />  | 
|       </a-form-item> -->  | 
|       <a-form-model-item key="desc" v-bind="formLayout" label="备注" >  | 
|         <a-input placeholder="请输入" v-model="saveData.desc"/>  | 
|       </a-form-model-item>  | 
|       <template slot="footer">  | 
|         <a-button key="cancel" @click="handleCancel">  | 
|           取消  | 
|         </a-button>  | 
|         <a-button key="forward" type="primary" @click="handleOk">  | 
|           完成  | 
|         </a-button>  | 
|       </template>  | 
|     </a-modal>  | 
|   </a-form-model>  | 
| </template>  | 
|   | 
| <script lang="ts">  | 
| import {  | 
|   Component,  | 
|   Prop,  | 
|   Vue,  | 
|   Emit,  | 
|   Model,  | 
|   Watch,  | 
| } from 'vue-property-decorator';  | 
| import { get, post } from "@/util/request";  | 
|   | 
| @Component({  | 
|   components: {},  | 
| })  | 
| export default class UpdateTaskForm extends Vue {  | 
|   | 
|   @Prop({  | 
|     type: Boolean,  | 
|     default: false,  | 
|   })  | 
|   private visible!: boolean;  | 
|   | 
|   @Prop({  | 
|     type: Object,  | 
|     default() {  | 
|       return {};  | 
|     },  | 
|   })  | 
|   private record!: any;  | 
|   | 
|   //规则定义  | 
|   private rules: any = {  | 
|     name:[  | 
|       {required:true,message:'名称不能为空',trigger:'blur'},  | 
|     ]  | 
|   }  | 
|   | 
|   @Watch('visible',{deep:true})  | 
|   private visibleWatch(newVal: boolean, oldVal: boolean) {  | 
|     if (newVal === true) {  | 
|       this.saveData.name = this.record.name  | 
|       this.saveData.desc = this.record.desc  | 
|     }else {  | 
|       this.saveData.name = ''  | 
|       this.saveData.desc = ''  | 
|     }  | 
|   }  | 
|   | 
|   private saveData: any = {  | 
|     name: '',  | 
|     desc: ''  | 
|   };  | 
|   | 
|   private form: any = null;  | 
|   | 
|   private formVals: any = {  | 
|     target: '0',  | 
|     template: '0',  | 
|     type: '1',  | 
|     time: '',  | 
|     frequency: 'month',  | 
|   };  | 
|   | 
|   private currentStep: number = 0;  | 
|   | 
|   private formLayout = {  | 
|     labelCol: {  | 
|       span: 7,  | 
|     },  | 
|     wrapperCol: {  | 
|       span: 13,  | 
|     },  | 
|   };  | 
|   | 
|   private handleBackward(): void {  | 
|     this.currentStep--;  | 
|   }  | 
|   | 
|   private handleNext(): void {  | 
|     this.form.validateFields((err: any, fieldsValue: any) => {  | 
|       if (err) {  | 
|         return;  | 
|       }  | 
|       this.formVals = {...this.formVals, ...fieldsValue};  | 
|       this.currentStep++;  | 
|     });  | 
|   }  | 
|   | 
|   private handleCancel(): void {  | 
|     this.updateVisible(false);  | 
|   }  | 
|   | 
|   private handleOk(): void {  | 
|     this.$refs.ruleForm.validate((valid: any) => {  | 
|       if (valid) {  | 
|         if (this.saveData.name || this.saveData.desc) {  | 
|           if (this.record.name !== this.saveData.name || this.record.desc !== this.saveData.desc) {  | 
|             post('manageRole/updateManageRole',  | 
|                 {  | 
|                   name: this.saveData.name,  | 
|                   desc: this.saveData.desc,  | 
|                   id: this.record.id  | 
|                 }  | 
|             )  | 
|                 .then((res) => {  | 
|                   if (res.data.code === 0) {  | 
|                     this.updateVisible(false);  | 
|                     this.onOk();  | 
|                     this.$message.success(res.data.message)  | 
|                     this.saveData.name = ''  | 
|                     this.saveData.desc = ''  | 
|                   }  | 
|                 })  | 
|                 .catch((err) => {  | 
|                   console.log(err);  | 
|                 })  | 
|           }else {  | 
|             this.$message.warning('未修改')  | 
|           }  | 
|         }  | 
|       } else {  | 
|         console.log('error submit!!');  | 
|         return false;  | 
|       }  | 
|     });  | 
|   | 
|   }  | 
|   | 
|   @Emit('ok')  | 
|   private onOk() {  | 
|   | 
|   }  | 
|   | 
|   private updateVisible(visible: boolean): void {  | 
|     this.$emit('update:visible', visible);  | 
|   }  | 
|   | 
|   private mounted(): void {  | 
|     this.currentStep = 0;  | 
|   }  | 
|   | 
|   @Watch('record', {  | 
|     immediate: true,  | 
|     deep: true,  | 
|   })  | 
|   private recordChange(value: any, oldValue: any): void {  | 
|     this.formVals = {  | 
|       ...value,  | 
|       ...this.formVals,  | 
|     };  | 
|     this.currentStep = 0;  | 
|   }  | 
|   | 
|   | 
| }  | 
| </script>  |