<template>
    <div>
        <div class="content">
            <dataTable
                :columns="columns"
                :breads="breads"
                :checklist="checklist"
                :page-obj="pageobj"
                :margin-top="100"
                url="/bidder/project/takePart/list"
            >
                <el-table-column slot="operate" label="项目类型" fixed="right" width="100">
                    <template slot-scope="scope">
                        <div>{{ scope.row.bidType == 0 ? '公开招标' : '邀请招标' }}</div>
                    </template>
                </el-table-column>
                <el-table-column slot="operate" align="center" label="项目状态" flexd="right" width="200px">
                    <template slot-scope="scope">
                        <div>{{ totalMarks(scope.row.status) }}</div>
                    </template>
                </el-table-column>
                <el-table-column slot="operate" label="操作" fixed="right" width="200">
                    <template slot-scope="scope">
                        <div v-if="scope.row.type == 1">
                            <el-button type="text" size="small" @click="handlesee(scope.row)">查看投标邀请书 </el-button>
                            <el-button type="text" size="small" @click="jump(scope.row)">查看询价公告 </el-button>
                        </div>
                        <div v-else class="flex-center">
                            <el-button type="text" size="small " @click="send(scope.row)">工作台</el-button>
                        </div>
                        
                    </template>
                </el-table-column>
            </dataTable>
        </div>
    </div>
</template>

<script>
import { projectStatusList } from '@api/common/list';
import dataTable from '@components/dataTable.vue';
export default {
    components: {
        dataTable
    },
    data() {
        return {
            //分页
            pageobj: {
                size: 10,
                currentPage: 1,
                func: (currentPage) => {
                    this.pageTurning(currentPage);
                }
            },
            //表格第一行
            columns: [
                {
                    label: '项目编号',
                    prop: 'projectCode'
                },
                {
                    label: '项目名称',
                    prop: 'projectName'
                },
                {
                    label: '采购商',
                    prop: 'companyName'
                },
                {
                    label: '投标截止时间',
                    prop: 'endTime'
                },
                {
                    slot: 'operate'
                }
            ],
            checklist: [
                {
                    title: '采购商:',
                    type: 'input',
                    model: 'companyName'
                },
                {
                    title: '项目名称:',
                    type: 'input',
                    model: 'projectName'
                },

                {
                    title: '状态',
                    type: 'select',
                    selectlist: [],
                    change: (row) => '',
                    model: 'status'
                },
                {
                    title: '项目类型',
                    type: 'select',
                    selectlist: [
                        {
                            value: '1',
                            label: '公开招标'
                        },
                        {
                            value: '2',
                            label: '邀请招标'
                        }
                    ],
                    change: (row) => '',
                    model: 'type'
                }
            ],
            breads: ['投标管理', '我参与的项目']
        };
    },
    methods: {
        handlesee(row) {
            this.$router.push('/supply/bid/signupOnline/seeAnnouncement');
            // this.$router.push(`/supply/bid/signupOnline/seeAnnouncement?id=${row.projectId}`)
            localStorage.setItem('projectId', row.projectId);
        },
        jump(row) {
            this.$router.push('/supply/bid/signupOnline/seePrice');
            localStorage.setItem('projectId', row.projectId);
        },
        totalMarks: function (status) {
            let value = this.map.get(status);
            return value;
        },
        send(row) {
            this.$router.push('/supply/bid/joinProject/workbench');
            localStorage.setItem('projectId', row.projectId);
            localStorage.setItem('projectName', row.projectName);
            localStorage.setItem('projectCode', row.projectCode);
        },
        async getprojectStatusList() {
            const data = await projectStatusList();
            this.map = new Map();
            for (let item of data) {
                item.value = item.id;
                item.label = item.name;
                this.map.set(item.id, item.name);
            }
            this.checklist[2].selectlist = data;
        }
    },
    created() {
        this.getprojectStatusList();
        this.pageobj.companyId = localStorage.getItem('companyId');
    }
};
</script>

<style scoped>
</style>
