<template>
    <div>
        <div class="describe">上传招标文件</div>
        <div class="padding">
            <div class="details">
                <el-form ref="ruleForm" :model="ruleForm" :rules="rules" label-width="100px" class="demo-ruleForm">
                    <el-form-item label="上传附件" prop="file">
                        <dataTable :table-data="ruleForm.bidBookDO" :columns="columns" :is-pageobj="false">
                            <el-table-column slot="operate" label="文件大小" align="center" fixed="right" width="300">
                                <template slot-scope="scope">
                                    <div>{{ getMb(scope.row.size) }}KB</div>
                                </template>
                            </el-table-column>
                            <el-table-column slot="operate" label="价格" align="center" fixed="right" width="300">
                                <template slot-scope="scope">
                                    <div>{{ scope.row.free ? scope.row.free : '无' }}</div>
                                </template>
                            </el-table-column>
                        </dataTable>
                    </el-form-item>
                    <el-form-item label="其他附件"> 
                        <dataTable :table-data="ruleForm.bidBookAccessoryDO" :columns="columns" :is-pageobj="false">
                            <el-table-column slot="operate" label="文件大小" align="center" fixed="right" width="300">
                                <template slot-scope="scope">
                                    <div>{{ getMb(scope.row.size) }}KB</div>
                                </template>
                            </el-table-column>
                        </dataTable>
                    </el-form-item>
                </el-form>
            </div>
        </div>
    </div>
</template>
<script>
import { creatProject } from '@api/purchaser/bid';
import dataTable from '@components/nopageTable.vue'
import upload from '@components/Upload/specialUpload.vue';
export default {
    components: {
        upload,
        dataTable
    },
    props: {
        allForm: {
            type: Object,
            default() {
                return {};
            }
        }
    },
    data() {
        let checkidentity = (rule, value, callback) => {
            let le;
            if (this.ruleForm.bidBookPO.length === 0) {
                callback(new Error('请上传附件'));
            } else {
                callback();
            }
        };
        return {
            columns: [
                {
                    label: '文件名称',
                    prop: 'name'
                },

                {
                    label: '上传时间',
                    prop: 'time'
                },
                {
                    slot: 'operate'
                }
            ],
            ruleForm: {
                bidBookPO: [],
                bidBookAccessoryPOList: []
            },
            fileList: [],
            rules: {
                file: [
                    {
                        required: true,
                        validator: checkidentity,
                        trigger: 'change'
                    }
                ]
            }
        };
    },
    methods: {
        getfile(val) {
            this.ruleForm.bidBookPO = val;
        },
        getfile1(val) {
            this.ruleForm.bidBookAccessoryPOList = val;
        },
    }
};
</script>

<style scoped>
.padding {
    padding: 0px 20px 30px 20px;
}

.details > div {
    margin-bottom: 20px;
}

.correct {
    margin-right: 20px;
    margin-top: 5px;
}

.button {
    display: flex;
    justify-content: flex-end;
    padding-bottom: 20px;
    margin-right: 20px;
}
</style>
