<template>
    <el-dialog title="复审" :visible.sync="show" center width="600px">
        <el-form
            hide-required-asterisk
            :model="form"
            :rules="rules"
            ref="form"
            label-width="140px"
            style="padding-right: 130px;"
        >
            <el-form-item label="缴费通知书" prop="attachment1">
                <div slot="label" style="line-height: 22px;">
                    <div>撤销连续三年不使</div>
                    <div>用商标申请书</div>
                </div>
                <attachment-upload
                    v-model="form.attachment1"
                    :fileSize.sync="form.attachment1.size"
                ></attachment-upload>
            </el-form-item>

            <el-form-item label="商标撤销委托书" prop="attachment2">
                <attachment-upload
                    v-model="form.attachment2"
                    :fileSize.sync="form.attachment2.size"
                ></attachment-upload>
            </el-form-item>
            <el-form-item prop="attachment3" label="营业执照复印件">
                <attachment-upload
                    v-model="form.attachment3"
                    :fileSize.sync="form.attachment3.size"
                ></attachment-upload>
            </el-form-item>
            <el-form-item>
                <el-button style="width: 150px;" size="normal" type="primary" @click="onSubmit">提交</el-button>
                <el-button style="width: 120px;" size="normal" @click="show = false">取消</el-button>
            </el-form-item>
        </el-form>
    </el-dialog>
</template>

<script>
import logoPatent from '@/mixins/logoPatent';
export default {
    mixins: [logoPatent],
    props: {
        info: {}
    },
    data() {
        return {
            form: {
                attachment1: {
                    attachmentName: '撤销连续三年不使用商标申请书',
                    fileName: '',
                    url: '',
                    remark: '',
                    size: ''
                },
                attachment2: { attachmentName: '商标撤销委托书', fileName: '', url: '', remark: '', size: '' },
                attachment3: { attachmentName: '营业执照复印件', fileName: '', url: '', remark: '', size: '' }
            },
            show: false,
            rules: {
                attachment1: {
                    validator: (rule, value, callback) => {
                        if (!value.url) {
                            callback(new Error('请上传撤销连续三年不使用商标申请书'));
                        } else {
                            callback();
                        }
                    },
                    trigger: 'change'
                },
                attachment2: {
                    validator: (rule, value, callback) => {
                        if (!value.url) {
                            callback(new Error('请上传商标撤销委托书'));
                        } else {
                            callback();
                        }
                    },
                    trigger: 'change'
                },
                attachment3: {
                    validator: (rule, value, callback) => {
                        if (!value.url) {
                            callback(new Error('请上传营业执照复印件'));
                        } else {
                            callback();
                        }
                    },
                    trigger: 'change'
                }
            }
        };
    },
    methods: {
        onSubmit() {
            this.$refs.form.validate(valid => {
                if (valid) {
                    this.submit();
                } else {
                    return false;
                }
            });
        },
        submit() {
            let info = { ...this.info };

            this.$emit('uploadAttement', this.form.attachment1);
            this.$emit('uploadAttement', this.form.attachment2);
            this.$emit('uploadAttement', this.form.attachment3);
            info.logoWorkflow = 'REVIEW_PAYMENT';

            this.$emit('submit', info);
            this.show = false;
        }
    }
};
</script>

<style></style>
