<!--
 * @Author: Kane
 * @Date: 2023-03-23 16:05:08
 * @LastEditors: Kane
 * @FilePath: /task_schedule/src/views/telsaler/TelsalerManagement.vue
 * @Description: 坐席管理组件
 *
 * Copyright (c) ${2022} by Kane, All Rights Reserved.
-->
<template>
    <div class="wrapper">
        <div class="query_wrapper">
            <el-row :gutter="10">
                <el-col :span="2">
                    <span>工号：</span>
                </el-col>
                <el-col :span="4">
                    <el-input v-model.trim.lazy="ui.caller_code" />
                </el-col>
                <el-col :span="2">
                    <span>姓名：</span>
                </el-col>
                <el-col :span="4">
                    <el-input />
                </el-col>
                <el-col :span="2">
                    <span>部门代码：</span>
                </el-col>
                <el-col :span="4">
                    <el-input />
                </el-col>
                <el-col :span="2">
                    <span>部门名称：</span>
                </el-col>
                <el-col :span="4">
                    <el-input />
                </el-col>
            </el-row>
            <el-row :gutter="10">
                <el-col :span="2">
                    <span>团队：</span>
                </el-col>
                <el-col :span="10">
                    <el-input />
                </el-col>
                <el-col :span="12">
                    <div class="query-button">
                        <el-button
                            type="primary"
                            icon="search"
                        >
                            查询
                        </el-button>
                        <el-button
                            icon="refresh"
                            @click="onResetQuery"
                        >
                            重置
                        </el-button>
                        <el-button
                            icon="upload"
                            type="warning"
                            @click="ui.showUploadDialog = true;"
                        >
                            上传
                        </el-button>
                    </div>
                </el-col>
            </el-row>
        </div>
        <el-table
            border
            stripe
            style="width:100%;"
            :height="tableHeight"
        >
            <el-table-column
                type="selection"
                align="center"
            />
            <el-table-column
                label="工号"
                align="center"
                width="120"
            />
            <el-table-column
                label="名称"
                align="center"
                width="200"
            />
            <el-table-column
                label="团队名称"
                align="center"
            />
            <el-table-column
                label="部门"
                align="center"
                width="300"
            />
        </el-table>
        <div class="pagination_wrapper">
            <el-pagination
                v-model="ui.table_current_page_index"
                class="pull_left"
                size="small"
                background
                :page-size="ui.table_page_size"
                :page-sizes="[10, 20, 50, 100]"
                layout="total, sizes, prev, pager, next, jumper"
                :total="ui.callers.length"
                @current-change="onCurrentPageIndexChange"
                @size-change="onTablePageSizeChange"
            />
        </div>
        <div class="upload-dialog-wrapper">
            <el-dialog
                v-model="ui.showUploadDialog"
                title="上传报表"
                width="600px"
                :close-on-click-modal="false"
                :close-on-press-escape="false"
                :show-close="true"
            >
                <DataUploadView :report-type="10" />
            </el-dialog>
        </div>
    </div>
</template>
<script lang="ts">
import DataUploadView from "@/views/data/DataUploadView.vue";
import { reactive, computed } from "vue";

export default {
    name: "TelsalerManagement",
    components: { DataUploadView, },
    setup()
    {
        const ui = reactive({
            showUploadDialog: false,
            caller_code: "",
            caller_name: "",
            section_office_code: "",
            section_office_name: "",
            department_code: "",
            department_name: "",
            team_name: "",
            table_current_page_index: 1,
            table_page_size: 50,
            callers: [],
        });

        const onCurrentPageIndexChange = ( pageIndex: number ): void =>
        {
            ui.table_current_page_index = pageIndex;
        };

        /**
         * 设置表格每页显示记录的数量
         * @param pageSize 表格页记录数量
         */
        const onTablePageSizeChange = ( pageSize: number ): void =>
        {
            ui.table_page_size = pageSize;
        };

        /**
         * 表格高度
         */
        const tableHeight = computed(() =>
        {
            return 10 * 50 + 40;
        });

        const onResetQuery = (): void =>
        {
            ui.caller_code = "";
            ui.caller_name = "";
            ui.section_office_code = "";
            ui.section_office_name = "";
            ui.department_code = "";
            ui.department_name = "";
            ui.team_name = "";
        };

        return { ui, onResetQuery, onCurrentPageIndexChange, onTablePageSizeChange, tableHeight, };
    },
};
</script>
<style lang="scss" scoped>
@import "@/assets/css/public/_public.scss";

.wrapper {
    padding: 10px;

    background-color: #fff;

    min-width: 800px;

    > *+* {
        margin-top: 10px;
    }
}

.query_wrapper {
    // display: flex;
    border-radius: 5px;

    padding: 15px;

    @include query-box-wrap;

    .query-button {
        display: flex;
        justify-content: flex-end;
        align-items: center;
    }
}

.pagination_wrapper
{
    display: flex;
    justify-content: flex-end;
}

</style>
