<template>
    <div>

        <el-card>
            <el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="120px" label-position="left">
                <el-form-item label="组织名称" prop="field101">
                    <el-input v-model="formData.field101" placeholder="请输入组织名称" clearable :style="{ width: '100%' }">
                    </el-input>
                </el-form-item>
                <el-form-item label="部门名称" prop="field102">
                    <el-input v-model="formData.field102" placeholder="请输入部门名称" clearable :style="{ width: '100%' }">
                    </el-input>
                </el-form-item>
                <el-form-item label="供应商名称" prop="field120">
                    <el-input v-model="formData.field120" placeholder="点击选择供应商" :disabled='true' clearable
                        :style="{ width: '100%' }"></el-input>
                </el-form-item>
                <el-form-item label="供应商编码" prop="field121">
                    <el-input v-model="formData.field121" placeholder="系统自动填写" :disabled='true' clearable
                        :style="{ width: '100%' }"></el-input>
                </el-form-item>
                <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-form-item label="合同名称" prop="field107">
                    <el-input v-model="formData.field107" placeholder="系统自动填写" :disabled='true' clearable
                        :style="{ width: '100%' }"></el-input>
                </el-form-item>
                <el-form-item label="项目编码" prop="field105">
                    <el-input v-model="formData.field105" placeholder="系统自动填写" :disabled='true' clearable
                        :style="{ width: '100%' }"></el-input>
                </el-form-item>
                <el-form-item label="合同类型" prop="field122">
                    <el-input v-model="formData.field122" placeholder="系统自动填写" :disabled='true' clearable
                        :style="{ width: '100%' }"></el-input>
                </el-form-item>
                <el-form-item label="票据编号" prop="field110">
                    <el-input v-model="formData.field110" placeholder="请输入票据编号" clearable :style="{ width: '100%' }">
                    </el-input>
                </el-form-item>
                <el-form-item label="开户银行" prop="field123">
                    <el-input v-model="formData.field123" placeholder="系统自动填写" :disabled='true' clearable
                        :style="{ width: '100%' }"></el-input>
                </el-form-item>
                <el-form-item label="账户编码" prop="field125">
                    <el-input v-model="formData.field125" placeholder="系统自动填写" :disabled='true' clearable
                        :style="{ width: '100%' }"></el-input>
                </el-form-item>
                <el-form-item label="汇票类型" prop="field126">
                    <el-input v-model="formData.field126" placeholder="系统自动填写" :disabled='true' clearable
                        :style="{ width: '100%' }"></el-input>
                </el-form-item>
                <el-form-item label="汇票承兑银行" prop="field127">
                    <el-input v-model="formData.field127" placeholder="系统自动填写" :disabled='true' clearable
                        :style="{ width: '100%' }"></el-input>
                </el-form-item>
                <el-form-item label="汇票到期日期" prop="field128">
                    <el-date-picker v-model="formData.field128" format="yyyy-MM-dd" value-format="yyyy-MM-dd"
                        :style="{ width: '100%' }" placeholder="系统自动填写" clearable :disabled='true'></el-date-picker>
                </el-form-item>
                <el-form-item label="付款日期" prop="field129">
                    <el-date-picker v-model="formData.field129" format="yyyy-MM-dd" value-format="yyyy-MM-dd"
                        :style="{ width: '100%' }" placeholder="请选择付款日期" clearable></el-date-picker>
                </el-form-item>
                <el-form-item label="金额" prop="field130">
                    <el-input v-model="formData.field130" placeholder="请输入金额" clearable :style="{ width: '100%' }">
                    </el-input>
                </el-form-item>
                <el-form-item label="金额大写" prop="field131">
                    <el-input v-model="formData.field131" placeholder="系统自动填写" :disabled='true' clearable
                        :style="{ width: '100%' }"></el-input>
                </el-form-item>
                <el-form-item label="备注" prop="field132">
                    <el-input v-model="formData.field132" type="textarea" placeholder="请输入备注"
                        :autosize="{ minRows: 4, maxRows: 4 }" :style="{ width: '100%' }"></el-input>
                </el-form-item>
                <el-form-item label="附件" prop="field133">
                    <el-upload ref="field133" :file-list="field133fileList" :action="field133Action"
                        :before-upload="field133BeforeUpload">
                        <el-button size="small" type="primary" icon="el-icon-upload">点击上传</el-button>
                    </el-upload>
                </el-form-item>
                <el-form-item size="large">
                    <el-button type="primary" @click="submitForm">提交</el-button>
                    <el-button @click="resetForm">重置</el-button>
                </el-form-item>
            </el-form>

        </el-card>
    </div>
</template>
<script>
export default {
    components: {},
    props: [],
    data() {
        return {
            formData: {
                field101: undefined,
                field102: undefined,
                field120: undefined,
                field121: undefined,
                field106: undefined,
                field107: undefined,
                field105: undefined,
                field122: undefined,
                field110: undefined,
                field123: undefined,
                field125: undefined,
                field126: undefined,
                field127: undefined,
                field128: null,
                field129: null,
                field130: undefined,
                field131: undefined,
                field132: undefined,
                field133: null,
            },
            rules: {
                field101: [{
                    required: true,
                    message: '请输入组织名称',
                    trigger: 'blur'
                }],
                field102: [{
                    required: true,
                    message: '请输入部门名称',
                    trigger: 'blur'
                }],
                field120: [{
                    required: true,
                    message: '点击选择供应商',
                    trigger: 'blur'
                }],
                field121: [{
                    required: true,
                    message: '系统自动填写',
                    trigger: 'blur'
                }],
                field106: [],
                field107: [],
                field105: [],
                field122: [],
                field110: [{
                    required: true,
                    message: '请输入票据编号',
                    trigger: 'blur'
                }],
                field123: [{
                    required: true,
                    message: '系统自动填写',
                    trigger: 'blur'
                }],
                field125: [],
                field126: [{
                    required: true,
                    message: '系统自动填写',
                    trigger: 'blur'
                }],
                field127: [{
                    required: true,
                    message: '系统自动填写',
                    trigger: 'blur'
                }],
                field128: [{
                    required: true,
                    message: '系统自动填写',
                    trigger: 'change'
                }],
                field129: [],
                field130: [{
                    required: true,
                    message: '请输入金额',
                    trigger: 'blur'
                }],
                field131: [{
                    required: true,
                    message: '系统自动填写',
                    trigger: 'blur'
                }],
                field132: [],
            },
            field133Action: 'https://jsonplaceholder.typicode.com/posts/',
            field133fileList: [],
        }
    },
    computed: {},
    watch: {},
    created() { },
    mounted() { },
    methods: {
        submitForm() {
            this.$refs['elForm'].validate(valid => {
                if (!valid) return
                // TODO 提交表单
            })
        },
        resetForm() {
            this.$refs['elForm'].resetFields()
        },
        field133BeforeUpload(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>
  