<template>
    <div>
        <el-card>
            <el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="130px" 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="field130">
                    <el-input v-model="formData.field130" placeholder="点击选择目项点需求名称" :disabled='true' clearable
                        suffix-icon='el-icon-search' :style="{ width: '100%' }"></el-input>
                </el-form-item>
                <el-form-item label="竞争对手联系人" prop="field131" label-width="132px">
                    <el-input v-model="formData.field131" placeholder="请输入竞争对手联系人" clearable :style="{ width: '100%' }">
                    </el-input>
                </el-form-item>
                <el-form-item label="联系人电话" prop="field132">
                    <el-input v-model="formData.field132" placeholder="请输入联系人电话" clearable :style="{ width: '100%' }">
                    </el-input>
                </el-form-item>
                <el-form-item label="竞争能力" prop="field134">
                    <el-input v-model="formData.field134" type="textarea" placeholder="请输入竞争能力"
                        :autosize="{ minRows: 4, maxRows: 4 }" :style="{ width: '100%' }"></el-input>
                </el-form-item>
                <el-form-item label="竞争能对手优势" prop="field135">
                    <el-input v-model="formData.field135" type="textarea" placeholder="请输入竞争能对手优势"
                        :autosize="{ minRows: 4, maxRows: 4 }" :style="{ width: '100%' }"></el-input>
                </el-form-item>
                <el-form-item label="竞争能对手劣势" prop="field136">
                    <el-input v-model="formData.field136" type="textarea" placeholder="请输入竞争能对手劣势"
                        :autosize="{ minRows: 4, maxRows: 4 }" :style="{ width: '100%' }"></el-input>
                </el-form-item>
                <el-form-item label="备注" prop="field137">
                    <el-input v-model="formData.field137" type="textarea" placeholder="请输入备注"
                        :autosize="{ minRows: 4, maxRows: 4 }" :style="{ width: '100%' }"></el-input>
                </el-form-item>
                <el-form-item label="附件" prop="field138">
                    <el-upload ref="field138" :file-list="field138fileList" :action="field138Action"
                        :before-upload="field138BeforeUpload">
                        <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,
                field130: undefined,
                field131: undefined,
                field132: undefined,
                field134: undefined,
                field135: undefined,
                field136: undefined,
                field137: undefined,
                field138: 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'
                }],
                field130: [{
                    required: true,
                    message: '教选择目项点需求名称',
                    trigger: 'blur'
                }],
                field131: [{
                    required: true,
                    message: '请输入竞争对手联系人',
                    trigger: 'blur'
                }],
                field132: [],
                field134: [],
                field135: [],
                field136: [],
                field137: [],
            },
            field138Action: 'https://jsonplaceholder.typicode.com/posts/',
            field138fileList: [],
            field104Options: [{
                "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()
        },
        field138BeforeUpload(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>
  