<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="field102">
                    <el-input v-model="formData.field102" placeholder="请输入本文行单客户名称" clearable :style="{ width: '100%' }">
                    </el-input>
                </el-form-item>
                <el-form-item label="联系人" prop="field103">
                    <el-input v-model="formData.field103" placeholder="请输入本文行单联系人" clearable :style="{ width: '100%' }">
                    </el-input>
                </el-form-item>
                <el-form-item label="日期" prop="field107">
                    <el-date-picker v-model="formData.field107" 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="field108">
                    <el-select v-model="formData.field108" placeholder="请选择类型" clearable :style="{ width: '100%' }">
                        <el-option v-for="(item, index) in field108Options" :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="请输入本文行单执行人" clearable :style="{ width: '100%' }">
                    </el-input>
                </el-form-item>
                <el-form-item label="行动描述" prop="field110">
                    <el-input v-model="formData.field110" type="textarea" placeholder="请输入行动描述"
                        :autosize="{ minRows: 4, maxRows: 4 }" :style="{ width: '100%' }"></el-input>
                </el-form-item>
                <el-form-item label="附件/现场照片" prop="field111" label-width="120px">
                    <el-upload ref="field111" :file-list="field111fileList" :action="field111Action"
                        :before-upload="field111BeforeUpload">
                        <el-button size="small" type="primary" icon="el-icon-upload">点击上传</el-button>
                    </el-upload>
                </el-form-item>
                <el-form-item label="位置" prop="field112">
                    <el-input v-model="formData.field112" placeholder="请输入位置" clearable :style="{ width: '100%' }">
                    </el-input>
                </el-form-item>
                <el-form-item label="下次回访日期" prop="field113">
                    <el-date-picker v-model="formData.field113" format="yyyy-MM-dd" value-format="yyyy-MM-dd"
                        :style="{ width: '100%' }" placeholder="请选择下次回访日期" clearable></el-date-picker>
                </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,
                field103: undefined,
                field107: null,
                field108: undefined,
                field109: undefined,
                field110: undefined,
                field111: null,
                field112: undefined,
                field113: null,
            },
            rules: {
                field101: [{
                    required: true,
                    message: '请输入主题',
                    trigger: 'blur'
                }],
                field102: [],
                field103: [],
                field107: [{
                    required: true,
                    message: '请选择日期',
                    trigger: 'change'
                }],
                field108: [{
                    required: true,
                    message: '请选择类型',
                    trigger: 'change'
                }],
                field109: [],
                field110: [],
                field112: [],
                field113: [],
            },
            field111Action: 'https://jsonplaceholder.typicode.com/posts/',
            field111fileList: [],
            field108Options: [{
                "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()
        },
        field111BeforeUpload(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>
  