<template>
    <div>
        <el-card>
            <el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="120px" label-position="left">
                <el-row :gutter="10">
                    <el-col :span="12">
                        <el-form-item label="供应商名称" prop="field101">
                            <el-input v-model="formData.field101" placeholder="点击选择供应商" :disabled='true' clearable
                                :style="{ width: '100%' }"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="供应商编码" prop="field102">
                            <el-input v-model="formData.field102" placeholder="系统自动填写" :disabled='true' clearable
                                :style="{ width: '100%' }"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="合同编号" prop="field103">
                            <el-input v-model="formData.field103" placeholder="系统自动生成" :disabled='true' clearable
                                :style="{ width: '100%' }"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="合同名称" prop="field104">
                            <el-input v-model="formData.field104" placeholder="请输入合同名称" clearable
                                :style="{ width: '100%' }">
                            </el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="采购分类" prop="field105">
                            <el-radio-group v-model="formData.field105" size="medium">
                                <el-radio v-for="(item, index) in field105Options" :key="index" :label="item.value"
                                    :disabled="item.disabled">{{ item.label }}</el-radio>
                            </el-radio-group>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="资产申请单号" prop="field106">
                            <el-input v-model="formData.field106" placeholder="点击选择资产单号" :disabled='true' clearable
                                :style="{ width: '100%' }"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="开始日期" prop="field108">
                            <el-date-picker v-model="formData.field108" format="yyyy-MM-dd" value-format="yyyy-MM-dd"
                                :style="{ width: '100%' }" placeholder="请选择开始日期" clearable></el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="结束日期" prop="field109">
                            <el-date-picker v-model="formData.field109" format="yyyy-MM-dd" value-format="yyyy-MM-dd"
                                :style="{ width: '100%' }" placeholder="请选择结束日期" clearable></el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="签约日期" prop="field110">
                            <el-date-picker v-model="formData.field110" format="yyyy-MM-dd" value-format="yyyy-MM-dd"
                                :style="{ width: '100%' }" placeholder="请选择签约日期" clearable></el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="付款方式" prop="field111">
                            <el-select v-model="formData.field111" placeholder="请选择付款方式" clearable
                                :style="{ width: '100%' }">
                                <el-option v-for="(item, index) in field111Options" :key="index" :label="item.label"
                                    :value="item.value" :disabled="item.disabled"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="合同金额" prop="field112">
                            <el-input v-model="formData.field112" placeholder="请输入合同金额" clearable
                                :style="{ width: '100%' }">
                            </el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="合同金额大写" prop="field113">
                            <el-input v-model="formData.field113" placeholder="系统自动填写" :disabled='true' clearable
                                :style="{ width: '100%' }"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="24">
                        <el-form-item label="合同主要条款" prop="field114">
                            <el-input v-model="formData.field114" type="textarea" placeholder="请输入合同主要条款"
                                :autosize="{ minRows: 4, maxRows: 4 }" :style="{ width: '100%' }"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="24">
                        <el-form-item label="备注" prop="field116">
                            <el-input v-model="formData.field116" placeholder="请输入备注" clearable :style="{ width: '100%' }">
                            </el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="24">
                        <el-form-item label="附件" prop="field117" required>
                            <el-upload ref="field117" :file-list="field117fileList" :action="field117Action"
                                :before-upload="field117BeforeUpload">
                                <el-button size="small" type="primary" icon="el-icon-upload">点击上传</el-button>
                            </el-upload>
                        </el-form-item>
                    </el-col>
                    <el-col :span="24">
                        <el-form-item size="large">
                            <el-button type="primary" @click="submitForm">提交</el-button>
                            <el-button @click="resetForm">重置</el-button>
                        </el-form-item>
                    </el-col>
                </el-row>

            </el-form>
        </el-card>
    </div>
</template>
<script>
export default {
    components: {},
    props: [],
    data() {
        return {
            formData: {
                field101: undefined,
                field102: undefined,
                field103: undefined,
                field104: undefined,
                field105: 1,
                field106: undefined,
                field108: null,
                field109: null,
                field110: null,
                field111: undefined,
                field112: undefined,
                field113: undefined,
                field114: undefined,
                field116: undefined,
                field117: null,
            },
            rules: {
                field101: [{
                    required: true,
                    message: '点击选择供应商',
                    trigger: 'blur'
                }],
                field102: [{
                    required: true,
                    message: '系统自动填写',
                    trigger: 'blur'
                }],
                field103: [],
                field104: [{
                    required: true,
                    message: '请输入合同名称',
                    trigger: 'blur'
                }],
                field105: [{
                    required: true,
                    message: '采购分类不能为空',
                    trigger: 'change'
                }],
                field106: [{
                    required: true,
                    message: '点击选择资产单号',
                    trigger: 'blur'
                }],
                field108: [{
                    required: true,
                    message: '请选择开始日期',
                    trigger: 'change'
                }],
                field109: [{
                    required: true,
                    message: '请选择结束日期',
                    trigger: 'change'
                }],
                field110: [],
                field111: [{
                    required: true,
                    message: '请选择付款方式',
                    trigger: 'change'
                }],
                field112: [{
                    required: true,
                    message: '请输入合同金额',
                    trigger: 'blur'
                }],
                field113: [{
                    required: true,
                    message: '系统自动填写',
                    trigger: 'blur'
                }],
                field114: [],
                field116: [],
            },
            field117Action: 'https://jsonplaceholder.typicode.com/posts/',
            field117fileList: [],
            field105Options: [{
                "label": "资产采购",
                "value": 1
            }, {
                "label": "行政采购",
                "value": 2
            }],
            field111Options: [{
                "label": "选项一",
                "value": 1
            }, {
                "label": "选项二",
                "value": 2
            }],
        }
    },
    computed: {},
    watch: {},
    created() { },
    mounted() { },
    methods: {
        submitForm() {
            this.$refs['elForm'].validate(valid => {
                if (!valid) return
                // TODO 提交表单
            })
        },
        resetForm() {
            this.$refs['elForm'].resetFields()
        },
        field117BeforeUpload(file) {
            let isRightSize = file.size / 1024 / 1024 < 2
            if (!isRightSize) {
                this.$message.error('文件大小超过 2MB')
            }
            return isRightSize
        },
    }
}

</script>
<style>
.el-upload__tip {
    line-height: 1.2;
}
</style>
  