98 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			Plaintext
		
	
	
			
		
		
	
	
			98 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			Plaintext
		
	
	
| <template>
 | |
|   <el-form
 | |
|     ref="sceneConfigForm"
 | |
|     v-loading="loading"
 | |
|     :model="form"
 | |
|     label-width="160px"
 | |
|     size="small"
 | |
|     :rules="rules"
 | |
|   >
 | |
|     <div class="base-dialog-body">
 | |
|       <el-form-item label="编号: " prop="Code">
 | |
|         <el-input v-model="form.Code" />
 | |
|       </el-form-item>
 | |
|       <el-form-item label="场景类型: " prop="Name">
 | |
|         <el-input v-model="form.Name" />
 | |
|       </el-form-item>
 | |
|       <el-form-item label="签名内容(EN): " prop="Value">
 | |
|         <el-input v-model="form.Value" type="textarea" rows="5" />
 | |
|       </el-form-item>
 | |
|       <el-form-item label="签名内容(CN): " prop="ValueCN">
 | |
|         <el-input v-model="form.ValueCN" type="textarea" rows="5" />
 | |
|       </el-form-item>
 | |
|     </div>
 | |
|     <div class="base-dialog-footer" style="text-align:right;margin-top:10px;">
 | |
|       <el-form-item style="text-align:right;">
 | |
|         <el-button size="small" type="primary" :disabled="form.Type === '' || form.Name === ''" :loading="saveBtnLoading" @click="handleSave">Save</el-button>
 | |
|       </el-form-item>
 | |
|     </div>
 | |
|   </el-form>
 | |
| </template>
 | |
| <script>
 | |
| import { addOrUpdateSystemBasicData } from '@/api/dictionary'
 | |
| export default {
 | |
|   props: {
 | |
|     data: {
 | |
|       type: Object,
 | |
|       default() { return {} }
 | |
|     },
 | |
|     parentId: {
 | |
|       type: String,
 | |
|       required: true
 | |
|     }
 | |
|   },
 | |
| 
 | |
|   data() {
 | |
|     return {
 | |
|       form: {
 | |
|         Id: '',
 | |
|         Code: '',
 | |
|         Name: '',
 | |
|         Value: '',
 | |
|         ValueCN: '',
 | |
|         ParentId: ''
 | |
|       },
 | |
|       rules: {
 | |
|         Code: [{ required: true, message: 'Please specify', trigger: ['blur'] }],
 | |
|         Name: [{ required: true, message: 'Please specify', trigger: ['blur'] }],
 | |
|         Value: [{ required: true, message: 'Please specify', trigger: ['blur'] }],
 | |
|         ValueCN: [{ required: true, message: 'Please specify', trigger: ['blur'] }]
 | |
|       },
 | |
|       scenarioOption: [],
 | |
|       saveBtnLoading: false,
 | |
|       loading: false
 | |
|     }
 | |
|   },
 | |
|   mounted() {
 | |
|     this.initForm()
 | |
|   },
 | |
|   methods: {
 | |
|     async initForm() {
 | |
|       this.loading = true
 | |
|       for (const k in this.form) {
 | |
|         if (this.data.hasOwnProperty(k)) {
 | |
|           this.form[k] = this.data[k]
 | |
|         }
 | |
|       }
 | |
|       this.loading = false
 | |
|     },
 | |
|     // 保存
 | |
|     handleSave() {
 | |
|       this.$refs.sceneConfigForm.validate(valid => {
 | |
|         if (!valid) return
 | |
|         this.saveBtnLoading = true
 | |
|         this.form.ParentId = this.parentId
 | |
|         addOrUpdateSystemBasicData(this.form).then(res => {
 | |
|           this.saveBtnLoading = false
 | |
|           this.$emit('closeDialog')
 | |
|           this.$emit('getList')
 | |
|           this.$message.success('Saved successfully')
 | |
|         }).catch(() => {
 | |
|           this.saveBtnLoading = false
 | |
|         })
 | |
|       })
 | |
|     }
 | |
|   }
 | |
| }
 | |
| </script>
 |