EditDictionary.vue 2.21 KB
<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>