<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
                                suffix-icon='el-icon-search' :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
                                suffix-icon='el-icon-search' :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
                                suffix-icon='el-icon-search' :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="系统自动填写" :disabled='true' clearable
                                suffix-icon='el-icon-search' :style="{ width: '100%' }"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="合同类型" prop="field107">
                            <el-select v-model="formData.field107" placeholder="系统自动填写" :disabled='true' clearable
                                :style="{ width: '100%' }">
                                <el-option v-for="(item, index) in field107Options" :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="field105">
                            <el-input v-model="formData.field105" placeholder="系统自动获取" :disabled='true' clearable
                                suffix-icon='el-icon-search' :style="{ width: '100%' }"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="签约日期" prop="field106">
                            <el-date-picker v-model="formData.field106" format="yyyy-MM-dd" value-format="yyyy-MM-dd"
                                :style="{ width: '100%' }" placeholder="请输入签约日期" clearable
                                :disabled='true'></el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="业务负责人" prop="field108">
                            <el-input v-model="formData.field108" placeholder="点击选择" :disabled='true' clearable></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="治商单位名称" prop="field109">
                            <el-input v-model="formData.field109" placeholder="请输入治商单位名称" clearable
                                :style="{ width: '100%' }">
                            </el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="治商编号" prop="field110">
                            <el-input v-model="formData.field110" placeholder="系统自动获取" :disabled='true' clearable
                                :style="{ width: '100%' }"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="治商金额" prop="field111">
                            <el-input v-model="formData.field111" placeholder="请输入治商金额" clearable
                                :style="{ width: '100%' }">
                            </el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="治商类别" prop="field135">
                            <el-radio-group v-model="formData.field135" size="medium">
                                <el-radio v-for="(item, index) in field135Options" :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="field136">
                            <el-input v-model="formData.field136" placeholder="请输入成本金额(人工)" clearable
                                :style="{ width: '100%' }"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="成本金额(材料)" prop="field137">
                            <el-input v-model="formData.field137" placeholder="请输入成本金额(材料)" clearable
                                :style="{ width: '100%' }"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="治商质保金额" prop="field138">
                            <el-input v-model="formData.field138" placeholder="请输入治商质保金额" clearable
                                :style="{ width: '100%' }">
                            </el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="治商质保到期时间" prop="field139" label-width="130px">
                            <el-input v-model="formData.field139" placeholder="请输入治商质保到期时间" clearable
                                :style="{ width: '100%' }"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="利润" prop="field140">
                            <el-input v-model="formData.field140" placeholder="请输入利润" :disabled='true' clearable
                                :style="{ width: '100%' }"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="利润率" prop="field141">
                            <el-input v-model="formData.field141" placeholder="请输入利润率" :disabled='true' clearable
                                :style="{ width: '100%' }"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="24">
                        <el-form-item label="治商内容" prop="field142">
                            <el-input v-model="formData.field142" 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="field143">
                            <el-input v-model="formData.field143" 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="field144">
                            <el-upload ref="field144" :file-list="field144fileList" :action="field144Action"
                                :before-upload="field144BeforeUpload">
                                <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 label="治商依据" prop="field145">
                            <el-upload ref="field145" :file-list="field145fileList" :action="field145Action"
                                :before-upload="field145BeforeUpload">
                                <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,
                field107: undefined,
                field105: undefined,
                field106: undefined,
                field108: undefined,
                field109: undefined,
                field110: undefined,
                field111: undefined,
                field135: 1,
                field136: undefined,
                field137: undefined,
                field138: undefined,
                field139: undefined,
                field140: undefined,
                field141: undefined,
                field142: undefined,
                field143: undefined,
                field144: null,
                field145: null,
            },
            rules: {
                field101: [{
                    required: true,
                    message: '点击选择合同',
                    trigger: 'blur'
                }],
                field102: [{
                    required: true,
                    message: '点击选择合同编号',
                    trigger: 'blur'
                }],
                field103: [{
                    required: true,
                    message: '点击选择项目名称',
                    trigger: 'blur'
                }],
                field104: [{
                    required: true,
                    message: '系统自动填写',
                    trigger: 'blur'
                }],
                field107: [{
                    required: true,
                    message: '系统自动填写',
                    trigger: 'change'
                }],
                field105: [{
                    required: true,
                    message: '系统自动获取',
                    trigger: 'blur'
                }],
                field106: [{
                    required: true,
                    message: '请输入签约日期',
                    trigger: 'change'
                }],
                field108: [{
                    required: true,
                    message: '点击选择',
                    trigger: 'blur'
                }],
                field109: [{
                    required: true,
                    message: '请输入治商单位名称',
                    trigger: 'blur'
                }],
                field110: [],
                field111: [{
                    required: true,
                    message: '请输入治商金额',
                    trigger: 'blur'
                }],
                field135: [],
                field136: [],
                field137: [],
                field138: [],
                field139: [],
                field140: [],
                field141: [],
                field142: [],
                field143: [],
            },
            field144Action: 'https://jsonplaceholder.typicode.com/posts/',
            field144fileList: [],
            field145Action: 'https://jsonplaceholder.typicode.com/posts/',
            field145fileList: [],
            field107Options: [{
                "label": "选项一",
                "value": 1
            }, {
                "label": "选项二",
                "value": 2
            }],
            field108Options: [{
                "label": "总价合同",
                "value": 1
            }, {
                "label": "清单计价",
                "value": 2
            }],
            field135Options: [{
                "label": "设计变更",
                "value": 1
            }, {
                "label": "现场变更",
                "value": 2
            }, {
                "label": "补充协议",
                "value": 3
            }],
        }
    },
    computed: {},
    watch: {},
    created() { },
    mounted() { },
    methods: {
        submitForm() {
            this.$refs['elForm'].validate(valid => {
                if (!valid) return
                // TODO 提交表单
            })
        },
        resetForm() {
            this.$refs['elForm'].resetFields()
        },
        field144BeforeUpload(file) {
            let isRightSize = file.size / 1024 / 1024 < 2
            if (!isRightSize) {
                this.$message.error('文件大小超过 2MB')
            }
            return isRightSize
        },
        field145BeforeUpload(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>
  