<template>
    <div>
        <el-card>
            <el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="100px" 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="field104">
                    <el-select v-model="formData.field104" placeholder="请选择部门名称" clearable :style="{ width: '100%' }">
                        <el-option v-for="(item, index) in field104Options" :key="index" :label="item.label"
                            :value="item.value" :disabled="item.disabled"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="项目名称" prop="field109">
                    <el-input v-model="formData.field109" 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="field108">
                    <el-input v-model="formData.field108" placeholder="系统自动获取" :disabled='true' clearable
                        :style="{ width: '100%' }"></el-input>
                </el-form-item>
                <el-form-item label="概算来源" prop="field118">
                    <el-radio-group v-model="formData.field118" size="medium">
                        <el-radio v-for="(item, index) in field118Options" :key="index" :label="item.value"
                            :disabled="item.disabled">{{ item.label }}</el-radio>
                    </el-radio-group>
                </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="field119">
                    <el-input v-model="formData.field119" placeholder="点教选择联系人" :disabled='true' 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="field123">
                    <el-input v-model="formData.field123" placeholder="请输入制单人" clearable :style="{ width: '100%' }">
                    </el-input>
                </el-form-item>
                <el-form-item label="报价日期" prop="field124">
                    <el-date-picker v-model="formData.field124" 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="field125">
                    <el-radio-group v-model="formData.field125" size="medium">
                        <el-radio v-for="(item, index) in field125Options" :key="index" :label="item.value"
                            :disabled="item.disabled">{{ item.label }}</el-radio>
                    </el-radio-group>
                </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="field126">
                    <el-input v-model="formData.field126" placeholder="点教选择概算金额(万)" clearable :style="{ width: '100%' }">
                    </el-input>
                </el-form-item>
                <el-form-item label="需求" prop="field128">
                    <el-input v-model="formData.field128" type="textarea" placeholder="请输入需求"
                        :autosize="{ minRows: 4, maxRows: 4 }" :style="{ width: '100%' }"></el-input>
                </el-form-item>
                <el-form-item label="附件" prop="field129">
                    <el-upload ref="field129" :file-list="field129fileList" :action="field129Action"
                        :before-upload="field129BeforeUpload">
                        <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,
                field104: undefined,
                field109: undefined,
                field105: undefined,
                field108: undefined,
                field118: undefined,
                field122: undefined,
                field119: undefined,
                field120: undefined,
                field123: undefined,
                field124: null,
                field125: undefined,
                field127: undefined,
                field126: undefined,
                field128: undefined,
                field129: null,
            },
            rules: {
                field101: [{
                    required: true,
                    message: '请输入组织名称',
                    trigger: 'blur'
                }],
                field104: [{
                    required: true,
                    message: '请选择部门名称',
                    trigger: 'change'
                }],
                field109: [{
                    required: true,
                    message: '点教选择项目',
                    trigger: 'blur'
                }],
                field105: [{
                    required: true,
                    message: '系统自动获取',
                    trigger: 'blur'
                }],
                field108: [{
                    required: true,
                    message: '系统自动获取',
                    trigger: 'blur'
                }],
                field118: [{
                    required: true,
                    message: '概算来源不能为空',
                    trigger: 'change'
                }],
                field122: [],
                field119: [],
                field120: [],
                field123: [],
                field124: [],
                field125: [],
                field127: [],
                field126: [],
                field128: [],
            },
            field129Action: 'https://jsonplaceholder.typicode.com/posts/',
            field129fileList: [],
            field104Options: [{
                "label": "选项一",
                "value": 1
            }, {
                "label": "选项二",
                "value": 2
            }],
            field118Options: [{
                "label": "自己概算",
                "value": 1
            }, {
                "label": "客户提供",
                "value": 2
            }],
            field125Options: [{
                "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()
        },
        field129BeforeUpload(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>
  