<template>
    <fullscreen :fullscreen.sync="fullscreen" class="container">
        <div class="container-box">
            <toolList @iconCli='iconCli' :tooltit='tooltit'></toolList>
            <div class="search">
                <span v-if="tsts == 1">
                    <el-button type="primary" size="medium" @click="tijiao">提交</el-button>
                    <myUpload style="display:inline-block;" :fileInfo="fileInfot"
                        :fileList="fileInfot.fileList" @uploadBack='uploadBack'></myUpload>
                    <el-button type="primary" @click="downmb" size="medium">下载模板</el-button>
                </span>
                <span v-if="tsts == 0">
                    <el-button type="primary" @click="daochu" size="medium">导出</el-button>
                </span>
            </div>
            <div class="tabbox">
                <el-table height="calc(100% - 40px)" class="com-table" ref="multipleTable" :data="tableData"
                    tooltip-effect="dark" size="small" border style="width: 100%" v-loading="loading">

                    <el-table-column prop="cityName" label="地市">
                    </el-table-column>
                    <el-table-column prop="areaName" label="区县">
                    </el-table-column>
                    <el-table-column prop="channelCode" label="渠道编码">
                    </el-table-column>
                    <el-table-column prop="channelName" label="渠道名称">
                    </el-table-column>
                    <el-table-column prop="channelType" label="渠道类型">
                    </el-table-column>
                    <el-table-column prop="staffName" label="姓名">
                    </el-table-column>
                    <el-table-column prop="staffPlace" label="档位">
                    </el-table-column>
                    <el-table-column prop="bossNo" label="BOSS工号">
                    </el-table-column>
                    <el-table-column prop="staffNo" label="台席编号">
                    </el-table-column>
                    <el-table-column prop="month" label="统计月份">
                    </el-table-column>
                    <el-table-column prop="evaCoe" label="考评系数">
                    </el-table-column>
                    <el-table-column prop="settleAmount" label="结算金额">
                    </el-table-column>
                    <el-table-column prop="trainDays" label="培训天数">
                    </el-table-column>
                    <el-table-column prop="trainAmount" label="培训费">
                    </el-table-column>
                    <el-table-column prop="practiceDays" label="实习天数">
                    </el-table-column>
                    <el-table-column prop="practiceAmount" label="实习期费用">
                    </el-table-column>
                    <el-table-column prop="workDays" label="上岗天数">
                    </el-table-column>
                    <el-table-column prop="sickDays" label="病假天数">
                    </el-table-column>
                    <el-table-column prop="sickAmount" label="病假费用">
                    </el-table-column>
                    <el-table-column prop="maternityDays" label="产假天数">
                    </el-table-column>
                    <el-table-column prop="leaveDays" label="事假天数">
                    </el-table-column>
                    <el-table-column prop="leaveAmount" label="事假扣款">
                    </el-table-column>
                    <el-table-column prop="absentDays" label="旷工天数">
                    </el-table-column>
                    <el-table-column prop="yearHoliday" label="年休假">
                    </el-table-column>
                    <el-table-column prop="marryHoliday" label="婚假">
                    </el-table-column>
                    <el-table-column prop="deathHoliday" label="丧假">
                    </el-table-column>
                    <el-table-column prop="familyPlanHoliday" label="计划生育假">
                    </el-table-column>
                    <el-table-column prop="paidHoliday" label="带薪休假天数">
                    </el-table-column>
                    <el-table-column v-for="(item,index) in kzData" :prop="item.colName" :label="item.colContent">
                    </el-table-column>

                </el-table>
                <el-pagination class="pageBox" @current-change="currchange" layout="prev, pager, next" background
                    :total="total">
                </el-pagination>
            </div>
        </div>

        <myMessage :messTit='messTit' @closeMessage="closeMessage" :centerDialogVisible="centerDialogVisible"
            v-if="centerDialogVisible"></myMessage>
    </fullscreen>

</template>
<script>
    import mySearch from "../../../components/search.vue";
    import myMessage from "../../../components/myMessage.vue"
    import toolList from '../../../components/toolList'
    import myUpload from '../../../components/upload'
    import uploadDown from '../../../components/uploadDown.vue'
    import deptTreeOnly from "../../../components/deptTreeOnly.vue"

    export default {
        components: {
            mySearch,
            myMessage,
            toolList,
            myUpload,
            uploadDown,
            deptTreeOnly
        },
        data() {

            return {
                tooltit: '台席管理',
                fullscreen: false,
                total: 0,
                pageSize: 1,
                tableData: [{}],
                dialogStatus: false,
                disableStatus: false,
                titname: '',
                infolist: {

                },
                userInfo: {},
                params: {},
                centerDialogVisible: false,
                messTit: '',
                delid: '',
                loading: false,
                loadinged: false,
                fileInfot: {
                    type: 'btn',
                    typename: '导入',
                    btntype: 'primary',
                    limit: 1,
                    url: '/market/cStoreOutWo/importData',
                    fileList: [],
                    woNo: "",
                },
                tsts:'',
                kzData:[]
            }
        },
        methods: {
            tijiao(){
                this.$http({
                    url: "/market/cStoreOutWo/commitInfoByCity",
                    method: "post",
                    headers: {
                        "Content-Type": "application/json",
                    },
                    data: {woNo:this.$route.query.id.split(",")[0]},
                }).then((res) => {
                    this.getList(this.params, this.pageSize);
                });
            },
            uploadBack(v) {
            },
            daochu(){
                let param = new FormData();
                param.append("woNo", this.$route.query.id.split(",")[0]);
                this.$http({
                    url: '/market/cStoreOutWo/excelExport',
                    method: "post",
                    responseType: 'blob',
                    headers: {
                        "Content-Type": "application/json",
                    },
                    data: param,
                }).then((response) => {
                    if (window.navigator && window.navigator.msSaveOrOpenBlob) {
                        let blob = new Blob([response.data], {
                            type: response.data.type
                        });
                        window.navigator.msSaveOrOpenBlob(blob, '数据.xlsx');
                    } else {
                        /* 火狐谷歌的文件下载方式 */
                        var blob = new Blob([response.data])
                        var downloadElement = document.createElement('a')
                        var href = window.URL.createObjectURL(blob);
                        downloadElement.href = href;
                        downloadElement.download = '数据.xlsx';
                        document.body.appendChild(downloadElement);
                        downloadElement.click();
                        document.body.removeChild(downloadElement);
                        window.URL.revokeObjectURL(href);
                    }
                });
            },
            downmb(){
                let param = new FormData();
                param.append("woNo", this.$route.query.id.split(",")[0]);
                this.$http({
                    url: '/market/cStoreOutWo/downLoadTemp',
                    method: "post",
                    responseType: 'blob',
                    headers: {
                        "Content-Type": "application/json",
                    },
                    data: param,
                }).then((response) => {
                    if (window.navigator && window.navigator.msSaveOrOpenBlob) {
                        let blob = new Blob([response.data], {
                            type: response.data.type
                        });
                        window.navigator.msSaveOrOpenBlob(blob, '模板.csv');
                    } else {
                        /* 火狐谷歌的文件下载方式 */
                        var blob = new Blob([response.data])
                        var downloadElement = document.createElement('a')
                        var href = window.URL.createObjectURL(blob);
                        downloadElement.href = href;
                        downloadElement.download = '模板.csv';
                        document.body.appendChild(downloadElement);
                        downloadElement.click();
                        document.body.removeChild(downloadElement);
                        window.URL.revokeObjectURL(href);
                    }
                });
            },
            //获取列表
            getList(v, n) {
                this.pageSize = n;
                let _this = this;
                this.loading = true;
                v.woNo = this.$route.query.id.split(",")[0]
                this.$http({
                    url: "/market/cStoreOutWo/queryMkStoreOutInfoPage",
                    method: "post",
                    headers: {
                        "Content-Type": "application/json",
                        "page": '{"pageNo":"' + n + '","pageSize":"10"}'
                    },
                    data: v,
                }).then((res) => {
                    this.tableData = res.data.data;
                    this.total = res.data.totalRecord;
                    this.loading = false;
                });
            },
            // 分页
            currchange(v) {
                this.pageSize = v;
                this.getList(this.params, this.pageSize);
            },
            //申请
            dialogCheck(v, n) {

            },
            //功能栏
            iconCli(v) {
                if (v === 1) {
                    this.getList(this.params, this.pageSize);
                }
                if (v === 2) {
                    this.fullscreen = !this.fullscreen
                }
            },
            getUser() {
                this.userInfo = JSON.parse(window.sessionStorage.userInfo);
                this.fileInfot.woNo = this.$route.query.id.split(",")[0];
                this.tsts = this.$route.query.id.split(",")[1];

                this.$http({
                    url: "/market/cStoreOutWo/queryMkStoreOutInfoExtList",
                    method: "post",
                    headers: {
                        "Content-Type": "application/json",
                    },
                    data: {woNo : this.$route.query.id.split(",")[0]}
                }).then((res) => {
                    this.kzData = res.data
                });
            },
        },
        mounted() {
            this.getList({}, 1);
            this.getUser();
        },
        created() {

        }
    }
</script>
<style scoped lang="scss">
    .onetab {
        margin-bottom: 20px;
        padding: 0 20px;
    }

    .titbox {
        div {
            float: right;

            i {
                font-size: 22px;
                margin-left: 20px;
                cursor: pointer;
            }
        }
    }

    .tabbox {
        margin-top: 15px;
    }

    .pageBox {
        text-align: right;
        margin-top: 10px;
    }

    .info-line {
        width: 100%;
        display: block;
        padding-left: 20px;

        div {
            width: 50%;
            display: inline-block;
        }

        span {
            width: 80px;
            display: inline-block;
            text-align: left;

            i {
                color: red;
                display: inline-block;
                padding-right: 5px;
            }
        }

        .el-select,
        .el-input {
            width: calc(100% - 100px);
        }
    }

    .online {
        width: 100%;

        .el-select {
            width: calc(100% - 100px);
        }

        span {
            vertical-align: top;
        }

        .el-textarea {
            width: calc(100% - 80px);
        }

        .tree {
            width: calc(50% - 60px);
            display: inline-block;
            margin-right: 20px;
            height: 300px;
            overflow-y: scroll;
            p {
                overflow: hidden;
                display: flex;
                justify-content: space-between;
            }

            .p-btn {
                width: 50px !important;
                cursor: pointer;
                color: #0074DA;
            }

            span {
                display: inline-block;
                width: calc(100% - 100px);
            }

            .el-icon-error {
                float: right;
                font-size: 20px;
                margin-top: 9px;
                cursor: pointer;
            }
        }

        .treeUser {
            margin: 0;
            border: 1px solid #ddd;

            p {
                background: #f4f4f4;
                padding: 0 20px;
                margin-bottom: 5px;
            }
        }

        .treeUserb {
            width: calc(100% - 80px);
            border: 1px solid #ddd;
            background: #f4f4f4;
            border-radius: 3px;
            height: auto;
            overflow: hidden;

            p {
                display: inline-block;
                padding: 0 20px;
                margin-bottom: 5px;
            }
        }
    }

    .adv-type {
        margin-top: 20px;
        display: flex;
        justify-content: space-between;
        flex-wrap: wrap;
        // border: 1px solid #ddd;
        border-radius: 5px;
        padding: 20px;
        box-shadow: 0 2px 12px 0 rgba(0, 0, 0, .1);

        div {
            width: 33%;
            text-align: center;
            height: 80px;
            overflow: hidden;
            min-width: 100px;
            cursor: pointer;
            padding-top: 10px;
            margin: 10px 0;
        }

        div:hover {
            background: #CFE8FC;
            border-radius: 5px;
        }

        span {
            width: 100%;
            display: inline-block;
            height: 40px;

            // line-height: 40px;
            i {
                color: #0074D9;
                font-size: 36px;
            }
        }
    }
    .tempbox{
        // border: 1px solid #ddd;
        padding: 5px;
        margin-bottom: 10px;
        span{
            display: inline-block;
            width: 40%;
            padding: 0 10px;
        }
        span:first-child{
            width: 20%;
            text-align: center;
        }
    }
    .treeUserp {
        p {
            padding: 5px;
        }

        p:hover {
            background: #01BEF0;
            color: #fff;
            cursor: pointer;
        }
    }
</style>
