<template>
    <a-form-model layout="vertical" :model="form" :rules="rules">
        <a-form-model-item label="名称">
            <a-input v-model="form.jobName" :disabled="isView" />
        </a-form-model-item>
        <a-form-model-item label="描述">
            <a-textarea v-model="form.jobDescription" :disabled="isView" :rows="4" />
        </a-form-model-item>
    </a-form-model>
</template>

<script>
import JobsApi from '@/api/organization';
export default {
    data() {
        return {
            type: 0,
            form: {},
            rules: {},
            checkedKeys: [],
        };
    },
    computed: {
        isAdd() {
            return this.type === 0;
        },
        isEdit() {
            return this.type === 1;
        },
        isView() {
            return this.type === 2;
        },
    },
    methods: {
        submit() {
            if (this.isEdit) {
                return JobsApi.add({ ...this.form });
            }
            if (this.isAdd) {
                return JobsApi.update({ ...this.form });
            }
        },
        setData(data, type) {
            this.form = data;
            this.type = type;
        },
    },
};
</script>
