liabilities.vue 4.89 KB
Newer Older
godwithdh's avatar
godwithdh committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 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 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 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
<style lang="less">
    @import url('../../../styles/common.less');
    #liabilities{
        background: #f6f5f9;
        height:100%;
        display: flex;
        flex-direction: column;
        .HEADER{
            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{
            height:100%;
            height:1px;
            flex-grow: 1;
            overflow: auto;
            -webkit-overflow-scrolling: touch;
            margin-bottom:8px;
            >div{
                display:flex;
                align-items: center;
                &{
                    >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">
            <span style="color:#777;margin-right:10rpx;">总负债额</span>
            <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)">
                    <div style="margin-bottom:10px">{{v.sCustomerName}}</div>
                    <div style="font-size:12rpx;color:#777;">欠款: {{v.nAmount}}</div>
                </div>
                <a class="iconfont icon-dianhua" :href="`tel:${v.sTelephone01}`" v-if="activeIndex=='客户'" />
            </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
144
                    this.rate+=v.nPercent||0
godwithdh's avatar
godwithdh committed
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
                    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>