<template>
    <a-form-model layout="vertical" :model="form" :rules="rules" ref="DrawerForm">
        <a-form-model-item label="语言" prop="paramLocale">
            <a-select
                v-model="form.paramLocale"
                :options="langList"
                placeholder="请选择"
                :disabled="isView"
            />
        </a-form-model-item>
        <a-form-model-item label="参数模块" prop="paramModule">
            <a-input v-model="form.paramModule" placeholder="请输入" :disabled="isView" />
        </a-form-model-item>
        <a-form-model-item label="参数编码" prop="paramCode">
            <a-input v-model="form.paramCode" placeholder="请输入" :disabled="isView" />
        </a-form-model-item>
        <a-form-model-item label="参数值" prop="paramValue">
            <a-input v-model="form.paramValue" placeholder="请输入" :disabled="isView" />
        </a-form-model-item>
        <a-form-model-item label="参数名称" prop="paramName">
            <a-input v-model="form.paramName" placeholder="请输入" :disabled="isView" />
        </a-form-model-item>
        <a-form-model-item label="显示顺序" prop="paramIndex">
            <a-input v-model="form.paramIndex" placeholder="请输入" :disabled="isView" />
        </a-form-model-item>
        <a-form-model-item label="说明" prop="remark">
            <a-textarea v-model="form.remark" :disabled="isView" :rows="4" />
        </a-form-model-item>
    </a-form-model>
</template>

<script>
import Api from '@/api/organization';
import FormMixin from '@/components/FormMixin';
import { globalConfig } from '@/config';
import { formatObj } from '@/utils';

export default {
    mixins: [FormMixin],
    data() {
        return {
            rules: {
                paramLocale: [{ required: true, message: 'Please select Activity zone', trigger: 'change' }],
                paramModule: [{ required: true, message: 'Please select Activity zone', trigger: 'change' }],
                paramCode: [{ required: true, message: 'Please select Activity zone', trigger: 'change' }],
                paramValue: [{ required: true, message: 'Please select Activity zone', trigger: 'change' }],
                paramName: [{ required: true, message: 'Please select Activity zone', trigger: 'change' }],
                paramIndex: [{ required: true, message: 'Please select Activity zone', trigger: 'change' }],
            },
            langList: [],
        };
    },
    async mounted() {
        this.langList = await formatObj(globalConfig.langs, { value: 'key', label: 'name', key: 'key' });
    },
    methods: {
        add() {
            return Api.addBusiness({ ...this.form });
        },
        edit() {
            return Api.updateBusiness({ ...this.form });
        },
    },
};
</script>
