index.vue 9.14 KB
Newer Older
godwithdh's avatar
godwithdh committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14
<style lang="less">
    #kanban{
        background:#DCE9FE;
        display: flex;
        flex-direction: column;
        height: 100%;
        >.tap{
            flex-shrink: 0;
            background:#E6EFFE;
            display:flex;
            >span{
                width:calc(100%/5);
                text-align: center;
                position:relative;
godwithdh's avatar
godwithdh committed
15 16
                height: 35px;
                line-height: 35px;
godwithdh's avatar
godwithdh committed
17 18 19 20 21 22 23 24 25 26
                &:after{
                    content:" ";
                    left:50%;
                    position:absolute;
                    bottom:0;
                    width:0;
                    border-top:3px solid #5E9AFE;
                    border-radius: 20px;
                    transition: all 0.3s;
                }
godwithdh's avatar
godwithdh committed
27 28 29 30 31 32
                &.active{
                    font-size:15px;
                    &:after{
                        width:100%;
                        left:0;
                    }
godwithdh's avatar
godwithdh committed
33 34 35 36 37 38
                }
            }
        }
        >.date{
            flex-shrink: 0;
            display: flex;
godwithdh's avatar
godwithdh committed
39
            height: 30px;
godwithdh's avatar
godwithdh committed
40 41 42
            >div{
                flex-grow:1;
                display:flex;
godwithdh's avatar
godwithdh committed
43
                justify-content: center;
godwithdh's avatar
godwithdh committed
44
                align-items: center;
godwithdh's avatar
godwithdh committed
45
                font-size: 14px;
godwithdh's avatar
godwithdh committed
46
                >.line{
godwithdh's avatar
godwithdh committed
47 48
                    width: 15px;
                    background: #815EFF;
godwithdh's avatar
godwithdh committed
49 50
                    height: 3px;
                    border-radius: 50px;
godwithdh's avatar
godwithdh committed
51
                    margin: 0 5px;
godwithdh's avatar
godwithdh committed
52 53
                }
            }
godwithdh's avatar
godwithdh committed
54
            >button{
godwithdh's avatar
godwithdh committed
55 56
                flex-shrink: 0;
                padding: 0 10px;
godwithdh's avatar
godwithdh committed
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
                position:relative;
                overflow:hidden;
                color:#815EFF;
                &:after{
                    content:" ";
                    width:0;
                    height:0;
                    left:50%;
                    top:50%;
                    position:absolute;
                    background:rgba(50, 125, 255, 0.4);
                    border-radius: 50%;
                    transform:translate(-50%,-50%);
                }
                &:active:after{
                    transition: all 0.4s;
                    width:100px;
                    height:100px;
                }
godwithdh's avatar
godwithdh committed
76 77 78 79 80 81
            }
        }
        >.list{
            flex-shrink: 0;
            display:flex;
            background: #f2f2f2;
godwithdh's avatar
godwithdh committed
82
            color:#679FFE;
godwithdh's avatar
godwithdh committed
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
            >span{
                width: calc(100%/5);
                text-align: center;
                padding: 10px;
                box-sizing: border-box;
                transition: all 0.3s;
                &.active{
                    background: rgb(93, 148, 245);
                    color: #fff;
                    box-shadow: 2px 2px 3px rgba(94,154,254,0.4);
                }
            }
        }
        >.content{
            flex-grow:1;
            overflow:auto;
            height:1px;
godwithdh's avatar
godwithdh committed
100
            -webkit-overflow-scrolling: touch;
godwithdh's avatar
godwithdh committed
101 102 103 104 105 106 107 108 109 110 111 112 113
        }
    }
</style>
<template>
    <div id="kanban">
        <div class="tap">
            <span :class="{active:dateMode==1}" @click="dateSelect(1)">日</span>
            <span :class="{active:dateMode==2}" @click="dateSelect(2)">周</span>
            <span :class="{active:dateMode==3}" @click="dateSelect(3)">月</span>
            <span :class="{active:dateMode==4}" @click="dateSelect(4)">年</span>
            <span :class="{active:dateMode==5}" @click="dateSelect(5)">自定义</span>
        </div>
        <div class="date">
godwithdh's avatar
godwithdh committed
114
            <button v-if="dateMode<5" @click="preDate">上一{{dateMode==1&&'天'||dateMode==2&&'周'||dateMode==3&&'月'||dateMode==4&&'年'}}</button>
godwithdh's avatar
godwithdh committed
115 116 117 118 119
            <div>
                <span>{{startDate}}</span>
                <span v-show="dateMode>1" class="line" />
                <span v-show="dateMode>1">{{endDate}}</span>
            </div>
godwithdh's avatar
godwithdh committed
120
            <button v-if="dateMode<5" @click="nextDate">下一{{dateMode==1&&'天'||dateMode==2&&'周'||dateMode==3&&'月'||dateMode==4&&'年'}}</button>
godwithdh's avatar
godwithdh committed
121 122 123 124 125 126
        </div>
        <div class="list">
            <span :class="{active:situation=='operate'}" @click="situation='operate'">运营概况</span>
            <span :class="{active:situation=='capital'}" @click="situation='capital'">资金概况</span>
            <span :class="{active:situation=='Finance'}" @click="situation='Finance'">财务概况</span>
            <span :class="{active:situation=='abnormal'}" @click="situation='abnormal'">异常预警</span>
张锡奇's avatar
张锡奇 committed
127
            <span :class="{active:situation=='tiipChartInventory'}" @click="situation='tiipChartInventory'">库存资金</span>
godwithdh's avatar
godwithdh committed
128
        </div>
godwithdh's avatar
godwithdh committed
129
        <div class="content">
godwithdh's avatar
godwithdh committed
130
            <component :is="situation" :dateMode="dateMode" :start="DateValue[0]" :end="DateValue[1]"/>
godwithdh's avatar
godwithdh committed
131 132 133 134 135 136 137 138 139 140 141 142 143 144
        </div>
        <calendar 
            :show.sync="calendarShow"
            mode="during"
            :defaultDate="calendarValue"
            @change="Change"/>
    </div>
</template>
<script>
import util from "@/libs/util.js"
import operate from "./operate"
import capital from "./capital"
import Finance from "./Finance"
import abnormal from "./abnormal"
godwithdh's avatar
godwithdh committed
145
import tiipChartInventory from "@/view/tiip/chart/inventory"
godwithdh's avatar
godwithdh committed
146 147 148

export default {
    name:"kanban",
godwithdh's avatar
godwithdh committed
149
    components:{operate,capital,Finance,abnormal,tiipChartInventory},
godwithdh's avatar
godwithdh committed
150 151 152 153 154 155 156 157 158 159 160
    data(){
        return{
            calendarShow:false,
            DateValue:[new Date],
            calendarValue:[],
            dateMode:1,
            situation:"operate",
        }
    },
    mounted(){
        window.kanban=this
godwithdh's avatar
godwithdh committed
161
        this.$store.dispatch('saveUserId',this.$route.params.userId);
godwithdh's avatar
godwithdh committed
162
        this.dateMode=3
godwithdh's avatar
godwithdh committed
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
    },
    methods:{
        preDate(){
            switch(this.dateMode){
                case 1:this.DateValue=[new Date(this.DateValue[0].setDate(this.DateValue[0].getDate()-1))]; break;
                case 2:this.DateValue=[this.setWeek(this.DateValue[0],-1,"start"),
                        this.setWeek(this.DateValue[1],-1,'end')];break;
                case 3:this.DateValue=[this.setMonth(this.DateValue[0],-1,"start"),
                        this.setMonth(this.DateValue[1],-1,'end')];break;
                case 4:this.DateValue=[this.setYear(this.DateValue[0],-1,"start"),
                        this.setYear(this.DateValue[1],-1,'end')];break;
            }
        },
        nextDate(){
            switch(this.dateMode){
                case 1:this.DateValue=[new Date(this.DateValue[0].setDate(this.DateValue[0].getDate()+1))]; break;
                case 2:this.DateValue=[this.setWeek(this.DateValue[0],+1,"start"),
                        this.setWeek(this.DateValue[1],+1,'end')];break;
                case 3:this.DateValue=[this.setMonth(this.DateValue[0],+1,"start"),
                        this.setMonth(this.DateValue[1],+1,'end')];break;
                case 4:this.DateValue=[this.setYear(this.DateValue[0],+1,"start"),
                        this.setYear(this.DateValue[1],+1,'end')];break;
            }
        },
        dateSelect(index){//选择日期方式
            if(index==5){
                this.calendarShow=true
            }else{
                this.calendarValue=[]
                this.dateMode=index
            }
        },
        Change(e){
            console.log(e)
            if(e.length==2){
                this.DateValue=this.calendarValue=[e[0].$d,e[1].$d]
                this.dateMode=5
                this.calendarShow=false
            }
        },
        setWeek(date,val,mode){
            if(mode=="start"){
                date.setDate(date.getDate()+1-(date.getDay()||7)+val*7)
            }else{
                date.setDate(date.getDate()+7-(date.getDay()||7)+val*7)
            }
godwithdh's avatar
godwithdh committed
209
            return new Date(date.getTime());
godwithdh's avatar
godwithdh committed
210 211
        },
        setMonth(date,val,mode){
godwithdh's avatar
godwithdh committed
212
            date.setDate(1)
godwithdh's avatar
godwithdh committed
213
            date.setMonth(date.getMonth()+val)
godwithdh's avatar
godwithdh committed
214
            if(mode=='end'){
godwithdh's avatar
godwithdh committed
215 216 217
                date.setMonth(date.getMonth()+1)
                date.setDate(0)
            }
godwithdh's avatar
godwithdh committed
218
            return new Date(date.getTime());
godwithdh's avatar
godwithdh committed
219 220 221 222 223 224 225 226 227 228
        },
        setYear(date,val,mode){
            date.setFullYear(date.getFullYear()+val)
            date.setMonth(0)
            if(mode=="start"){
                date.setDate(1)
            }else{
                date.setFullYear(date.getFullYear()+1)
                date.setDate(0);
            }
godwithdh's avatar
godwithdh committed
229
            return new Date(date.getTime());
godwithdh's avatar
godwithdh committed
230 231 232 233
        },
    },
    computed:{
        startDate(val){
godwithdh's avatar
godwithdh committed
234
            return util.dateFormat(this.DateValue[0],"yyyy年MM月dd日")
godwithdh's avatar
godwithdh committed
235 236
        },
        endDate(val){
godwithdh's avatar
godwithdh committed
237
            return util.dateFormat(this.DateValue[1],"yyyy年MM月dd日");
godwithdh's avatar
godwithdh committed
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261
        }
    },
    watch:{
        dateMode(n){
            var date=new Date
            switch(n){
                case 1:this.DateValue=[date];break;
                case 2:this.DateValue=[
                        this.setWeek(new Date(),0,'start'),
                        this.setWeek(new Date(),0,'end')
                    ];break;
                case 3:this.DateValue=[
                        this.setMonth(new Date(),0,"start"),
                        this.setMonth(new Date(),0,"end"),
                    ];break;
                case 4:this.DateValue=[
                        this.setYear(new Date(),0,"start"),
                        this.setYear(new Date(),0,"end")
                    ];break;
            }
        }
    },
}
</script>