<template>
    <div>
        <div class="content">
            <dataBreadcrumb :breads="breads"></dataBreadcrumb>
            <div class="message">
                <div class="flex-between">
                    <div>项目编号: {{ projectCode }}</div>
                    <div>项目名称：{{ projectName }}</div>
                </div>
                <div>
                    <div>开标一览表:</div>
                    <dataTable :tableData="tableData" :columns="nopagecolumns" :margin-top="0" :margin-bottom="0"> </dataTable>
                </div>
            </div>
            <changeNav :navs="navs" @getIndex="getIndex"></changeNav>
            <!-- 开标大厅消息 -->
            <div v-show="changeIndex == 0">
                <dataTable :table-data="behaviorList" :columns="behavior" :is-pageobj="false" :is-index="true">
                    <el-table-column slot="operate" label="消息内容" align="center">
                        <template slot-scope="scope">
                            <div class="flex content">
                                <div>{{ scope.row.time }}</div>
                                <div>{{ scope.row.role }}</div>
                                <div>{{ scope.row.name }}</div>
                                <div>{{ scope.row.behavior }}</div>
                            </div>
                        </template>
                    </el-table-column>
                </dataTable>
            </div>
            <!-- 对话消息 -->
            <div v-show="changeIndex == 1">
                <dataTable :table-data="chatList" :columns="chat" :is-pageobj="false" :is-index="true"> </dataTable>
            </div>
            <div class="centerButton">
                <el-button @click="back">返回</el-button>
            </div>
        </div>
    </div>
</template>

<script>
import { messageRecord, openInfo } from '@api/purchaser/bid';
import dataTable from '@components/nopageTable.vue';
import dataBreadcrumb from '@components/dataBreadcrumb.vue';
import changeNav from '@components/changeNav.vue';
export default {
    components: {
        dataTable,
        dataBreadcrumb,
        changeNav
    },
    data() {
        return {
            nopagecolumns: [
                {
                    label: '投标人名称',
                    prop: 'companyName'
                },
                {
                    label: '投标报价(元)',
                    prop: 'price'
                },
                {
                    label: '是否签名',
                    prop: 'isSign'
                }
            ], //
            changeIndex: '0',
            navs: ['开标大厅消息', '对话消息'],
            breads: ['招标管理', '招标项目管理', '工作台'],
            behaviorList: [],
            behavior: [
                {
                    slot: 'operate'
                }
            ], // 操作列
            chat: [
                {
                    label: '发送人',
                    prop: 'name'
                },
                {
                    label: '发送时间',
                    prop: 'time'
                },
                {
                    label: '发送内容',
                    prop: 'chatContent'
                }
            ],
            chatList: [],
            pageObj: {
                size: 10,
                total: 1,
                currentPage: 1,
                sizes: [100, 200, 300],
                func: (currentPage) => {
                    this.pageTurning(currentPage);
                }
            },
            projectCode: '',
            projectName: '',
            tableData: []
        };
    },
    methods: {
        back() {
            this.$router.go(-1);
        },
        examine() {
            this.$router.push('/admin/bid/bidingDetail');
        },
        getIndex(val) {
            this.changeIndex = val;
        },
        async getmessageRecord() {
            let projectId = localStorage.getItem('projectId');
            const { data, code } = await messageRecord(projectId);
            this.behaviorList = data.behaviorList;
            this.chatList = data.chatList;
        },
        async getopenInfo() {
            try {
                let projectId = localStorage.getItem('projectId');
                const { data, code } = await openInfo(projectId);
                if (code == 200) {
                    for (let item of data) {
                        if (item.isSign) {
                            item.isSign = '是';
                        } else {
                            item.isSign = '否';
                        }
                    }
                    this.tableData = data;
                }
            } catch (e) {
                console.log(e);
            }
        }
    },
    created() {
        this.projectCode = localStorage.getItem('projectCode');
        this.projectName = localStorage.getItem('projectName');
        this.getmessageRecord();
        this.getopenInfo();
    }
};
</script>

<style scoped>
.content > div {
    margin-right: 10px;
}
.upload > button {
    border: 1px solid #000000;
    background: #fff;
    width: 50px;
    height: 20px;
    margin-left: 10px;
}

.message > div {
    margin-bottom: 10px;
}

.message {
    margin: 30px 0 30px 50px;
}
</style>
