<template>
    <div class="groupunreviewed-all">
        <div class="groupunreviewed-title">团组未审核数据</div>
        <div class="groupunreviewed-haed">
            <el-date-picker @change="datechange" style="width:350px" v-model="value" type="daterange" align="left"
                unlink-panels range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期"
                :picker-options="pickerOptions">
            </el-date-picker>
            <div>
                <el-button type="primary">审核通过</el-button>
                <el-button type="danger">审核不通过</el-button>
            </div>
        </div>
        <div class="tree-box">
            <el-tree 
            @check="handleSelectionChange" 
            :data="groupstableData" 
            ref="tree"
            show-checkbox 
            :default-expand-all="false" 
            :default-checked-keys="defaultarr"
            node-key="id" 
            :props="defaultProps"
            highlight-current>
                <span class="custom-tree-node" slot-scope="{ data }">
                    <span>{{data.groupName?'（团组：'+data.groupName+'）':'' }}</span>
                    <span>
                        {{ data.applicant?'申请人：'+data.applicant:''}}
                    </span>
                    <span>
                        {{ data.payType?'【'+data.payType+'】':''}}
                    </span>
                    <span>
                        {{ data.moduleName?'['+data.moduleName+']':''}}
                    </span>
                    <span>
                        {{ data.priceName?data.priceName:''}}
                    </span>
                    <span>
                        {{ data.payee?'（收款方：'+data.payee+'）':'' }}
                    </span>
                    <span>
                        {{ data.payCurrCode?'  : '+data.payCurrCode+' ':'' }}
                    </span>
                    <span>
                        {{ data.paymentAmount!=undefined?'  '+twonumder(data.paymentAmount):'' }}
                    </span>
                    <span>
                        {{ data.cnyTotalAmount!=undefined?'&nbsp;&nbsp;&nbsp;付款金额&nbsp;&nbsp;&nbsp;CNY  '+twonumder(data.cnyTotalAmount):'' }}
                    </span>
                    <span>
                        {{ data.cnySubTotalAmount!=undefined?'  、 CNY  '+twonumder(data.cnySubTotalAmount=data.paymentAmount*data.payRate)+'&nbsp;&nbsp;&nbsp;汇率：':'' }}
                    </span>
                    <!-- <span>
                        {{data.groupName?'（团组：'+data.groupName+'）':'' }}
                    </span>
                    
                    
                    
                    
                    
                    
                    
                    <el-input-number v-if="data.payRate!=undefined" style="width:100px" @blur="inputblur(data.id,data.payRate,data.hotelSubId)" :precision="4" placeholder="公务翻译费" v-model="data.payRate" :controls='false'>
                    </el-input-number> -->
                </span>
            </el-tree>
        </div>
    </div>
</template>
<script>
export default {
    data () {
        return {
            pickerOptions: {
                shortcuts: [{
                    text: '最近一个月',
                    onClick(picker) {
                    const end = new Date();
                    const start = new Date();
                    start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
                    picker.$emit('pick', [start, end]);
                    }
                }, {
                    text: '最近三个月',
                    onClick(picker) {
                        const end = new Date();
                        const start = new Date();
                        start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
                        picker.$emit('pick', [start, end]);
                    }
                }, {
                    text: '最近六个月',
                    onClick(picker) {
                        const end = new Date();
                        const start = new Date();
                        start.setTime(start.getTime() - 3600 * 1000 * 24 * 180);
                        picker.$emit('pick', [start, end]);
                    }
                }, {
                    text: '最近一年',
                    onClick(picker) {
                        const end = new Date();
                        const start = new Date();
                        start.setTime(start.getTime() - 3600 * 1000 * 24 * 365);
                        picker.$emit('pick', [start, end]);
                    }
                }]
            },
            value:[],
            defaultarr:[],//团组勾选中
            groupstableData:[],//团组付款申请
            defaultProps: {
                children: 'childList',
                label: 'groupName'
            },
        }
    },
    methods:{
        //两位小数
        twonumder(val){
            return val.toFixed(2)
        },
        //处理日期
        datetime(val){
            var date=new Date(val);
            var y=date.getFullYear();
            var m=date.getMonth()+1>=10?date.getMonth()+1:'0'+(date.getMonth()+1).toString();
            var d=date.getDate()>=10?date.getDate():'0'+(date.getDate()).toString();
            return y+'-'+m+'-'+d
        },
        //切换时间
        datechange(){
            if(this.value==null){
                return
            }
            this.GroupUnAuditFeeList(this.datetime(this.value[0]),this.datetime(this.value[1]))
        },
        //获取团组未审核数据
        GroupUnAuditFeeList(beginDt,endDt){
            var that = this;
            var url = "/api/Financial/GroupUnAuditFeeList?beginDt="+beginDt+"&endDt="+endDt
            this.$axios({
                method: 'get',
                url: url,
                headers: {
                    Authorization: 'Bearer '
                },
            }).then(function (res) {
                if (res.data.code == 200) {
                    that.groupstableData=res.data.data.dataList
                } else {
                    that.$message.error(res.data.msg);
                }
            })
        },
        //勾选
        handleSelectionChange(data,node) {
            for(let i=0;i<node.checkedNodes.length;i++){
                for(let j=0;j<node.checkedKeys.length;j++){
                    if(node.checkedNodes[i].id==node.checkedKeys[j]){
                        this.hotelSubIdarr.push(node.checkedNodes[i].hotelSubId)
                    }
                }
            }
            this.defaultarr=node.checkedKeys
        },
    }
}
</script>
<style>
.groupunreviewed-all{
    background-color: #fff;
    padding: 10px;
    box-shadow: 0 0 5px #0005;
    border-radius: 10px;
    height: 100%;
    min-height: 840px;
    min-width: 1400px;
}
.groupunreviewed-title{
    color: #555;
    margin-bottom: 5px;
}
.groupunreviewed-haed{
    display: flex;
    justify-content: space-between;
}
.tree-box{
    margin-top: 10px;
    border: 1px solid #EBEEF5;
    padding: 10px;
}
</style>

