<template>
    <div class="home">
        <div class="user">
            <div>你好 ，MaikoXie , 欢迎开始一天的工作！</div>
            <ul class="user-list flex-between">
                  <li class="flex-colunm">
                    <img src="@static/images/user.png" alt="" />
                    <div>全部项目</div>
                    <div>{{ detail.projectCount }}</div>
                </li>
                  <li class="flex-colunm">
                    <img src="@static/images/user.png" alt="" />
                    <div>我的供应商</div>
                    <div>{{ detail.bidderCount }}</div>
                </li>
                  <li class="flex-colunm">
                    <img src="@static/images/user.png" alt="" />
                    <div>已定定标项目</div>
                    <div>{{ detail.calibrated }}</div>
                </li>
                  <li class="flex-colunm">
                    <img src="@static/images/user.png" alt="" />
                    <div>已流标项目</div>
                    <div>{{ detail.bidFailed }}</div>
                </li>
                  <li class="flex-colunm">
                    <img src="@static/images/user.png" alt="" />
                    <div>已经终止项目</div>
                    <div>{{ detail.end }}</div>
                </li>
            </ul>
            <h1>项目信息</h1>
            <dataTable :table-data="tableData" :columns="columns" :is-pageobj="false">
            </dataTable>
            <h1>待办事项</h1>
            <ul class="flex-between project-list">
                <li class="flex-colunm">
                    <img src="@static/images/item.png" alt="" />
                    <div>待修改项目</div>
                    <div>{{ detail.projectAduitNeedModify }}</div>
                </li>
                <li class="flex-colunm">
                    <img src="@static/images/item.png" alt="" />
                    <div>待修改询价公告</div>
                    <div>{{ detail.inquiryNoticeNeedModify }}</div>
                </li>
                <li class="flex-colunm">
                    <img src="@static/images/item.png" alt="" />
                    <div>待修改招标公告</div>
                    <div>{{ detail.biddingNoticeNeedModify }}</div>
                </li>
                <li class="flex-colunm">
                    <img src="@static/images/item.png" alt="" />
                    <div>待签署应收账款买断合同</div>
                    <div>{{ detail.payment }}</div>
                </li>
                <li class="flex-colunm">
                    <img src="@static/images/item.png" alt="" />
                    <div>待确认供应商凭证</div>
                    <div>{{ detail.credentials }}</div>
                </li>
            </ul>
        </div>
    </div>
</template>

<script>
import { home } from '@api/purchaser/home';
import { getSearchString } from '@utils/common';
import dataTable from '@components/nopageTable.vue';
export default {
    components: {
        dataTable
    },
    data() {
        return {
            detail: '',
            tableData: [
                {
                    state: '审核通过待发布的项目',
                    number: '10',
                    url: ''
                },
                {
                    state: '处于售标&投标阶段的项目',
                    number: '10',
                    url: ''
                },
                {
                    state: '处于投标阶段的项目',
                    number: '10',
                    url: ''
                },
                {
                    state: '今日截标（开标）的项目',
                    number: '10',
                    url: ''
                },
                {
                    state: '处于开标阶段的项目',
                    number: '10',
                    url: ''
                },
                {
                    state: '处于评标阶段的项目',
                    number: '10',
                    url: ''
                },
                {
                    state: '处于定标阶段的项目',
                    number: '10',
                    url: ''
                }
            ],
            columns: [
                {
                    label: '当前状态',
                    prop: 'state'
                },
                {
                    label: '数量',
                    prop: 'number'
                },
                {
                    slot: 'operate'
                }
            ], // 操作列
            projectlist: [
                {
                    id: 0,
                    img: require('@static/images/item.png'),
                    project: '待审核项目',
                    number: '100'
                },
                {
                    id: 1,
                    img: require('@static/images/item.png'),
                    project: '待审核项目',
                    number: '100'
                },
                {
                    id: 2,
                    img: require('@static/images/item.png'),
                    project: '待审核项目',
                    number: '100'
                },
                {
                    id: 3,
                    img: require('@static/images/item.png'),
                    project: '待审核项目',
                    number: '100'
                },
                {
                    id: 4,
                    img: require('@static/images/item.png'),
                    project: '待审核项目',
                    number: '100'
                }
            ]
        };
    },
    created() {
        let token = getSearchString('token');
       localStorage.setItem('token', token);
        this.gethome();
    },
    methods: {
        handleSee(row) {
            this.$router.push(row.url);
        },
        async gethome() {
            const { data, code } = await home();
            this.detail = data;
            this.tableData[0].number = data.prePublic;
            this.tableData[1].number = data.sellingBidding;
            this.tableData[2].number = data.bidding;
            this.tableData[3].number = data.open;
            this.tableData[4].number = data.bidOpening;
            this.tableData[5].number = data.bidOevaluating;
        }
    }
};
</script>

<style scoped>
.user > h1 {
    font-weight: bold;
    margin-top: 50px;
    margin-bottom: 30px;
}

.home {
    box-sizing: border-box;
    padding: 30px;
}

.home > .user {
    box-sizing: border-box;
    padding-left: 30px;
    padding-top: 30px;
    background: #fff;
}

.user > .user-list {
    margin-top: 50px;
    margin-left: 30px;
}

.user > ul {
    width: 80%;
}

.user > .user-list > li > div {
    margin-top: 10px;
    margin-bottom: 10px;
}

.project-list {
    margin-left: 30px;
}

.project-list > li > div {
    margin-top: 10px;
    margin-bottom: 10px;
}
</style>
