<template>
    <el-table
            :data="tableData"
            border
            class="table"
            height="auto"
            @selection-change="handleSelectionChange"
            style="width: 100%">
        <el-table-column
                type="selection"
                fixed
                width="55">
        </el-table-column>
        <el-table-column
                prop="name"
                label="联系人"
                width="150">
        </el-table-column>
        <el-table-column
                prop="phone"
                label="手机号"
                width="200">
        </el-table-column>
        <el-table-column
                prop="company"
                label="公司名称"
                width="200">
        </el-table-column>
        <el-table-column
                prop="area"
                label="公司所在地区"
                width="320">
        </el-table-column>
        <el-table-column
                prop="email"
                label="邮箱"
                width="180">
        </el-table-column>
        <el-table-column
                prop="createTime"
                label="注册时间"
                width="180">
        </el-table-column>
      <!--  <el-table-column
                prop="updateTime"
                label="处理时间"
                width="360">
        </el-table-column>-->
        <el-table-column
                prop="stateName"
                label="处理状态"
                width="180">
        </el-table-column>
        <el-table-column
                label="操作"
                fixed="right"
        >
            <template slot-scope="scope">
                <el-button v-if="scope.row.state === 0" type="text" @click="handleAudit(scope.row)">处理</el-button>
                <el-button v-else type="text" @click="handleUnAudit(scope.row)">撤回</el-button>
            </template>
        </el-table-column>
    </el-table>
</template>

<script>
    export default {
        name:     'Table',
        inject:   {
            tableServiceData:      {
                type:    Object,
                default: () => {
                },
            },
            paginationServiceData: {
                type:    Object,
                default: () => {
                },
            },
        },
        computed: {
            tableData() {
                return this.tableServiceData.myData;
            },
        },
        methods:  {
            handleSelectionChange(data) {
                const arr = [];
                data.forEach(item => {
                    arr.push(item.deId);
                });
                this.$emit('select-change', arr);
            },
            handleAudit(data) {
                this.$emit('audit', data);
            },
            handleUnAudit(data) {
                this.$emit('unAudit', data);
            },
        },
    };
</script>

<style lang="scss" scoped>
    .table {
        ::v-deep .is-leaf {
            .cell {
                text-align: center;
            }
        }

        ::v-deep .el-table-column--selection {
            .cell {
                text-align: center;
            }
        }
    }
</style>
