EditDictionary.vue
2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<template>
<a-modal v-model:visible="showModal" width="780px" :title="$t('common.edit')" @ok="submitForm" :ok-text="$t('common.ok')"
:cancel-text="$t('common.cancel')" :mask-closable="false">
<a-spin :spinning="submitted">
<a-form v-if="formState" :model="formState" :label-col="labelCol" :wrapper-col="wrapperCol" ref="formRef">
<a-form-item :label="this.$t('common.name')" name="optionName" has-feedback :rules="[rule_required(),rule_max(64)]">
<a-input v-model:value="formState.optionName" :placeholder="$t('common.please_enter')" :maxlength="64"/>
</a-form-item>
<a-form-item :label="$t('common.enabled')" name="enabled">
<a-switch v-model:checked="formState.enabled" :checked-children="$t('common.enabled_true')" :un-checked-children="$t('common.enabled_false')"/>
</a-form-item>
<a-form-item :label="$t('common.remark')" name="remark" :rules="[rule_max(255)]">
<a-textarea v-model:value="formState.remark" rows="6" :placeholder="$t('common.please_enter')"/>
</a-form-item>
</a-form>
</a-spin>
</a-modal>
</template>
<script lang="ts">
import {message} from 'ant-design-vue';
import {reactive} from 'vue';
import {Component, Prop} from 'vue-facing-decorator';
import {Dictionary} from "lib/src/core/dictionary/Dictionary";
import {FormComponent} from '@/core/form/FormComponent';
@Component({
components: {}
})
export default class EditDictionary extends FormComponent<Dictionary> {
@Prop()
dictionary: Dictionary;
created(): void {
const user: Dictionary = JSON.parse(JSON.stringify(this.dictionary));
this.formState = reactive<Dictionary>(user);
}
/**
* 成功回调
* @param formValue
*/
onValidSuccess(formValue: Dictionary): void {
formValue.dictionaryId = this.dictionary.dictionaryId;
// @ts-ignore
this.axios.post('dictionary/updateDictionary', formValue).then(response => {
message.success('保存成功');
this.$emit('handleOk');
this.showModal = false;
});
}
}
</script>
<style scoped>
</style>