<template>
    <div>
        <div class="content-head">
            <dataBreadcrumb :breads="breads"></dataBreadcrumb>
            <h3>招标项目流标处理</h3>
            <h5>招标项目流标处理</h5>
        </div>
        <div class="content">
            <div class="message">
                <div class="flex-between">
                    <div>项目编号：{{projectCode}}</div>
                    <div>项目名称：{{projectName}}</div>
                </div>
                <div class="flex">
                    <div class="adjustment">评价报告</div>
                    <Upload :limit="1" :max="100" tip="最多上传一个文件，每个文件不超过100M。" @input="getfile"></Upload>
                </div>
                <div class="flex">
                    <div class="adjustment">评标报告扫描件</div>
                    <Upload :limit="1" :max="100" tip="最多上传5个文件，每个文件不超过100M。" @input="getfile1"></Upload>
                </div>
                <div class="flex-center" style="margin: 100px 0">
                    <el-button @click="prev">取消</el-button>
                    <el-button type="primary" style="margin-left: 20px" @click="submitData">提交</el-button>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import { bidFailed } from '@api/purchaser/bid';
import dataBreadcrumb from '@components/dataBreadcrumb.vue';
import Upload from '@components/Upload/Upload.vue';
export default {
    components: {
        dataBreadcrumb,
        Upload
    },
    data() {
        return {
            breads: ['招标管理', '招标项目管理', '工作台'],
            file: [],
            file1: [],
            projectName: '',
            projectCode: ''
        };
    },
    created() {
        this.projectCode = localStorage.getItem('projectCode');
        this.projectName = localStorage.getItem('projectName');
    },
    methods: {
        /* 取消返回上一步 */
        prev(){
            this.$router.back()
        },
        //
        getfile(val) {
            this.file = val;
        },
        getfile1(val) {
            this.file1 = val;
        },
        // 提交
        async submitData() {
            try {
                let message = {};
                let filePOList = [];
                let file = this.file;
                let file1 = this.file1;
                for (let item of file) {
                    item.type = 1;
                }
                for (let item1 of file1) {
                    item1.type = 2;
                }
                filePOList = file.concat(file1);
                message.filePOList = filePOList;
                message.projectId = localStorage.getItem('projectId');
                const { code, msg } = await bidFailed(message);
                if (code == 200) {
                    this.$message({
                        message: msg,
                        type: 'success',
                        duration: 1500
                    });
                    setTimeout(() => {
                        this.$router.go(-1);
                    }, 1500);
                }
            } catch (e) {
                console.log(e);
            }
        }
    }
};
</script>

	
<style scoped>
.message {
    width: 50%;
    margin: 50px auto;
}
.message > div {
    margin-bottom: 20px;
}
.adjustment {
    width: 120px;
    text-align: center;
}
</style>
