<template>
    <div class="downloadpage-all">
        <div class="downloadpage-Groups">
            <el-select v-model="diIdselect" clearable filterable placeholder="团组选择" style="width: 100%;">
                <el-option v-for="item in delegationInfoList" :key="item.row_Number" :label="item.teamName"
                    :value="item.id">
                </el-option>
            </el-select>
        </div>
        <div class="downloadpage-ps">PS:请先选择团组再下载！</div>
        <div class="downloadpage-table">
            <div class="downloadpage-table-tr">
                <div class="downloadpage-table-tb tb-name">OP行程单</div> 
                <div class="downloadpage-table-tb tb-type">WORD</div> 
                <div class="downloadpage-table-tb tb-Language">中文</div> 
                <div class="downloadpage-table-tb tb-download">
                    <el-button size="small" @click="dcwzxc(0)" type="primary">下载</el-button>
                </div> 
            </div>
            <div class="downloadpage-table-tr">
                <div class="downloadpage-table-tb tb-name">OP行程单</div> 
                <div class="downloadpage-table-tb tb-type">PDF</div> 
                <div class="downloadpage-table-tb tb-Language">中文</div> 
                <div class="downloadpage-table-tb tb-download">
                    <el-button size="small" @click="dcwzxc(1)" type="primary">下载</el-button>
                </div> 
            </div>
            <div class="downloadpage-table-tr">
                <div class="downloadpage-table-tb tb-name">团组名单</div> 
                <div class="downloadpage-table-tb tb-type">WORD</div> 
                <div class="downloadpage-table-tb tb-Language">中文</div> 
                <div class="downloadpage-table-tb tb-download">
                    <el-button size="small" @click="Exportlist(0)" type="primary">下载</el-button>
                </div> 
            </div>
            <div class="downloadpage-table-tr">
                <div class="downloadpage-table-tb tb-name">团组名单</div> 
                <div class="downloadpage-table-tb tb-type">WORD</div> 
                <div class="downloadpage-table-tb tb-Language">英文</div> 
                <div class="downloadpage-table-tb tb-download">
                    <el-button size="small"  @click="Exportlist(1)" type="primary">下载</el-button>
                </div> 
            </div>
            <div class="downloadpage-table-tr">
                <div class="downloadpage-table-tb tb-name">导出倒推表</div> 
                <div class="downloadpage-table-tb tb-type">WORD</div> 
                <div class="downloadpage-table-tb tb-Language">中文</div> 
                <div class="downloadpage-table-tb tb-download">
                    <el-button size="small" @click="PostInvertedListFileDownload" type="primary">下载</el-button>
                </div> 
            </div>
            <div class="downloadpage-table-tr">
                <div class="downloadpage-table-tb tb-name">出国出境经费审核计算明细</div> 
                <div class="downloadpage-table-tb tb-type">WORD</div> 
                <div class="downloadpage-table-tb tb-Language">中文</div> 
                <div class="downloadpage-table-tb tb-download">
                    <el-button size="small" @click="eptschedule(1,1005)" type="primary">下载</el-button>
                </div> 
            </div>
            <div class="downloadpage-table-tr">
                <div class="downloadpage-table-tb tb-name">因公出国(境)经费测算明细表</div> 
                <div class="downloadpage-table-tb tb-type">WORD</div> 
                <div class="downloadpage-table-tb tb-Language">中文</div> 
                <div class="downloadpage-table-tb tb-download">
                    <el-button size="small" @click="eptschedule(1,1006)" type="primary">下载</el-button>
                </div> 
            </div>
            <div class="downloadpage-table-tr">
                <div class="downloadpage-table-tb tb-name">四川省商务厅出国经费财政先行审核表</div> 
                <div class="downloadpage-table-tb tb-type">EXCEL</div> 
                <div class="downloadpage-table-tb tb-Language">中文</div> 
                <div class="downloadpage-table-tb tb-download">
                    <el-button size="small" @click="eptschedule(1,1007)" type="primary">下载</el-button>
                </div> 
            </div>
            <div class="downloadpage-table-tr">
                <div class="downloadpage-table-tb tb-name">成都市因公临时出国任务和预算审批意见表（外专培训团专用）</div> 
                <div class="downloadpage-table-tb tb-type">WORD</div> 
                <div class="downloadpage-table-tb tb-Language">中文</div> 
                <div class="downloadpage-table-tb tb-download">
                    <el-button size="small" @click="eptschedule(1,1066)" type="primary">下载</el-button>
                </div> 
            </div>
            <div class="downloadpage-table-tr">
                <div class="downloadpage-table-tb tb-name">派员单位出(境)任务和预算审批意见表</div> 
                <div class="downloadpage-table-tb tb-type">WORD</div> 
                <div class="downloadpage-table-tb tb-Language">中文</div> 
                <div class="downloadpage-table-tb tb-download">
                    <el-button size="small" @click="eptschedule(2,1008)" type="primary">下载</el-button>
                </div> 
            </div>
            <div class="downloadpage-table-tr">
                <div class="downloadpage-table-tb tb-name">省级单位出(境)经费报销单</div> 
                <div class="downloadpage-table-tb tb-type">WORD</div> 
                <div class="downloadpage-table-tb tb-Language">中文</div> 
                <div class="downloadpage-table-tb tb-download">
                    <el-button size="small" @click="eptschedule(2,1009)" type="primary">下载</el-button>
                </div> 
            </div>
        </div>
    </div>
</template>
<script>
export default {
    data() {
        return {
            diIdselect:'',
            delegationInfoList:[],
            pageloadData: {
                "portType": 1,
                "pageIndex": 1,
                "pageSize": 10,
                "contact": "",
                "location": "",
                "client": "",
                "userid": "",
                "lvlid": 0,
                "business": "",
                "Range": 0,
                "Category": 0,
                "operationUserId": 0
            },
            token:'',
            pageId:'',
            userId:''
        }
    },
    methods:{
        //页面加载
        padeload(){
            var url = "/api/Business/PostGroupNameScreen"
            var that = this
            this.$axios({
                method: 'post',
                url: url,
                headers: {
                    Authorization: 'Bearer ' + this.token
                },
                data:{
                    portType: 1,
                    pageIndex:1,
                    pageSize: 9000,
                    groupName:'',
                    userId:that.userId==21?-1:that.userId,
                }
            }).then(function (res) {
                console.log(res)
                if(res.data.code==200){
                    that.delegationInfoList=res.data.data;
                    that.diIdselect=that.delegationInfoList[0].id;
                }else{
                    that.$message.error(res.data.msg);
                }
            })
        },
        //ctable获取团组
        PostGroupListByCTableAndUserId(){
            var url = "/api/Business/PostGroupListByCTableAndUserId"
            var that = this
            this.$axios({
                method: 'post',
                url: url,
                headers: {
                    Authorization: 'Bearer ' + this.token
                },
                data:{
                    portType: 1,
                    pageIndex:1,
                    pageSize: 9000,
                    cTable:1081,
                    userId:that.userId,
                    teamName:"",
                }
            }).then(function (res) {
                if(res.data.code==200){
                    that.delegationInfoList=res.data.data;
                    that.diIdselect=that.delegationInfoList[0].id;
                }else{
                    that.$message.error(res.data.msg);
                }
            })
        },
        //导出完整行程
        dcwzxc(val){
            var url = "/api/Groups/ExportTravel"
            var that = this
            this.$axios({
                method: 'post',
                url: url,
                headers: {
                    Authorization: 'Bearer ' + that.token
                },
                data: {
                    diid: that.diIdselect,
                    isPDF:val
                }
            }).then(function (res) {
                if (res.data.code == 200) {
                    that.$message({
                        message: res.data.msg,
                        type: 'success',
                        offset: 50
                    });
                    window.open(res.data.data.replace('C:/Server/File/OA2023/','http://132.232.92.186:24/'));
                } else {
                    that.$message.error(res.data.msg);
                }
            }).catch(function (error) {
                that.$message.error(error);
            });
        },
        //团组名单
        Exportlist(val) {
            var url = "/api/Groups/PostTourClientListDownloadFile"
            var that = this
            this.$axios({
                method: 'post',
                url: url,
                headers: {
                    Authorization: 'Bearer ' + this.token
                },
                data: {
                    portType: 1,
                    userId: that.userId,
                    pageId: that.pageId,
                    diId: that.diIdselect,
                    language: val
                }
            }).then(function (res) {
                console.log(res)
                if (res.data.code == 200) {
                    window.location.href = res.data.data
                    that.$message({
                        type: 'success',
                        message: res.data.msg
                    });
                } else {
                    that.$message.error(res.data.msg);
                }
            }).catch(function (error) {
                that.$message.error("下载失败！");
            });
        },
        //导出倒推表
        PostInvertedListFileDownload() {
            var url = "/api/Groups/PostInvertedListFileDownload"
            var that = this
            this.$axios({
                method: 'post',
                url: url,
                headers: {
                    Authorization: 'Bearer ' + that.token
                },
                data: {
                    portType: 1,
                    diId: that.diIdselect
                }
            }).then(function (res) {
                if (res.data.code == 200) {
                    that.$message({
                        message:res.data.msg ,
                        type: 'success',
                        offset:50
                    });
                    window.open(res.data.data);
                }else{
                    that.$message.error(res.data.msg);
                }
            }).catch(function (error) {
                that.$message.error(error);
            });
        },
        //三公导出
        eptschedule(val1,val2){
            var url = "/api/Groups/PostEnterExitCostDownload"
            var that = this
            this.$axios({
                method: 'post',
                url: url,
                headers: {
                    Authorization: 'Bearer ' + this.token
                },
                data:{
                    portType: 1,
                    diId: that.diIdselect,
                    exportType: val1,
                    subTypeId:val2
                }
            }).then(function (res) {
                console.log(res)
                if(res.data.code==200){
                    that.$message({
                        type: 'success',
                        message: res.data.msg
                    });
                    window.open(res.data.data.url);
                }else{
                    that.$message.error(res.data.msg);
                }
            })
        },
    },
    created(){
        this.token = JSON.parse(localStorage.getItem('userinif')).token;
        this.userId = JSON.parse(localStorage.getItem('userinif')).userInfo.userId
        this.pageId = Number(localStorage.getItem('indexs').split('-')[1]);//页面id
        this.PostGroupListByCTableAndUserId()
    }
}
</script>
<style>
.downloadpage-all {
    background-color: #fff;
    padding: 20px;
    box-shadow: 0 0 5px #0005;
    border-radius: 10px;
    min-height: 810px;
}
.downloadpage-Groups{
    width: 394px;
}
.downloadpage-btn{
    width: 200px;
}
.downloadpage-table-tr{
    display: flex;
    
}
.downloadpage-ps{
    margin-top:20px ;
    font-size: 14px;
}
.downloadpage-table{
    max-height: 700px;
    border-bottom: 1px solid #DCDFE6;
    overflow: hidden;
    overflow: auto;
}
.downloadpage-table-tr{
    border-top: 1px solid #DCDFE6;
}
.downloadpage-table-tb{
    padding: 10px;
    text-align: center;
    border-left: 1px solid #DCDFE6;
    font-size: 14px;
    color: #555;
    display: flex;
    justify-content: center;
    align-items: center;
}
.downloadpage-table-tb:last-child{
    border-right: 1px solid #DCDFE6;
}
.tb-name{
    width: 40%;
}
.tb-type{
    width: 25%;
}
.tb-Language{
    width: 25%;
}
.tb-download{
    width: 10%;
}
</style>