liabilities.vue 5.22 KB
Newer Older
godwithdh's avatar
godwithdh committed
1 2 3 4 5 6 7
<style lang="less">
    @import url('../../../styles/common.less');
    #liabilities{
        background: #f6f5f9;
        height:100%;
        display: flex;
        flex-direction: column;
godwithdh's avatar
godwithdh committed
8 9 10
        >.tabs{
            flex-shrink: 0;
        }
godwithdh's avatar
godwithdh committed
11
        .HEADER{
godwithdh's avatar
godwithdh committed
12
            flex-shrink: 0;
godwithdh's avatar
godwithdh committed
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
            display:flex;
            padding:10px;
            >span{
                flex-shrink: 0;
                &.number{
                    color:#3BA5EF;
                    margin-left:5px;
                    flex-grow:1;
                    text-align: right;
                }
            }
            >div{
                margin: 0 10px;
                background:#3BA5EF;
                border-radius: 5px;
            }
        }
        
        .Content{
godwithdh's avatar
godwithdh committed
32 33
            // height:100%;
            height:20rpx;
godwithdh's avatar
godwithdh committed
34 35 36 37 38 39
            flex-grow: 1;
            overflow: auto;
            -webkit-overflow-scrolling: touch;
            margin-bottom:8px;
            >div{
                display:flex;
godwithdh's avatar
godwithdh committed
40
                // align-items: center;
godwithdh's avatar
godwithdh committed
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
                &{
                    >div{
                        border-bottom:1px solid #ddd;
                    }
                }
                >div{
                    flex-grow:1;
                    padding:15px 0;
                }
                >span{
                    flex-shrink: 0;
                    padding: 0 13px;
                    &.num{
                        font-weight: bold;
                        color: #555;
                        font-size: 16px;
                        align-self: center;
                    }
                    
                }
                >a{
                    flex-shrink: 0;
                    padding: 18px 13px;
                    &.iconfont{
                        border-bottom: 1px solid #ddd;
                        display: flex;
                        align-items: center;
                        color: #FF7601;
                        font-size: 20px;
                    }
                }
            }
        }
        .img{
            width:100%;
            display: flex;
            justify-content: center;
            img{
                width:100%;
                height:300px;
            }
        }
    }
</style>
<template>
    <div id="liabilities">
        <div class="tabs">
            <tab active-color="#708bf6">
                <tab-item :selected="activeIndex=='客户'" @on-item-click="activeIndex='客户'">客户欠款</tab-item>
                <tab-item :selected="activeIndex=='供应商'" @on-item-click="activeIndex='供应商'">欠供应商款</tab-item>
            </tab>
        </div>
        
        <div class="HEADER iCard">
godwithdh's avatar
godwithdh committed
95
            <span style="color:#777;margin-right:10rpx;" v-if="activeIndex=='客户'">总应收额</span>
godwithdh's avatar
godwithdh committed
96
            <span style="color:#777;margin-right:10rpx;" v-else>总欠款额</span>
godwithdh's avatar
godwithdh committed
97 98 99 100 101 102 103 104
            <div :style="{'width':rate+'%','background':color}"></div>
            <span class="number">{{total}}</span>
        </div>

        <div class="Content iCard">
            <div v-for="(v,k) in list" :key="k">
                <span class="num">{{k+1}}</span>
                <div @click="routerToDetail(v)">
godwithdh's avatar
godwithdh committed
105 106
                    <div style="margin-bottom:10px" v-if="activeIndex=='客户'">{{v.sCustomerName}}</div>
                    <div style="margin-bottom:10px" v-else>{{v.sProviderName}}</div>
godwithdh's avatar
godwithdh committed
107 108
                    <div style="font-size:12rpx;color:#777;">欠款: {{v.nAmount}}</div>
                </div>
张锡奇's avatar
张锡奇 committed
109
                <a class="iconfont icon-dianhua" :href="`tel:${v.sTelephone01}`" v-if="activeIndex=='客户' || v.sTelephone01" />
godwithdh's avatar
godwithdh committed
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
            </div>
            <div class="img" v-if="list.length<=0">
                <img src="@/assets/noData.jpg" />
            </div>
        </div>
    </div>
</template>
<script>
import Util from '@/libs/util.js';
import { Tab, TabItem } from 'vux'
export default {
    name:"liabilities",
    components:{Tab, TabItem },
    data(){
        return{
            activeIndex:"客户",
            list:[],
            rate:0,
            color:"",
            total:0,
        }
    },
    mounted(){
        this.$nextTick(()=>{
            this.getData()
        })
    },
    methods:{
        async getData(){
            var value=await this.request("getTiipLiabilities",{
                data:{
                    sCustomerType:this.activeIndex
                }
            },"加载中",{});

            this.total=0
            this.rate=0
            if(value.length>0){
                this.list=value.map(v=>{
                    this.total+=v.nAmount||0
godwithdh's avatar
godwithdh committed
150
                    this.rate+=v.nPercent||0
godwithdh's avatar
godwithdh committed
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
                    v.nAmount=(Math.round(v.nAmount*100)/100).toLocaleString()
                    return v;
                })
                this.total=(Math.round(this.total*100)/100).toLocaleString()
                this.rate=Math.round(this.rate*10000)/100
                this.rate>=30&&this.rate<60&&(this.color="yellow")
                this.rate>=90&&(this.color="red")
            }
        },
        routerToDetail(value){
            this.$router.push({name:"tipLiabilitiesDetail",params:{iCustomerId:value.uGUID,sCustomerType:this.activeIndex}})
        },
    },
    watch:{
        activeIndex(n){
            this.getData()
        }
    },
}
</script>