list.vue 5.75 KB
Newer Older
张锡奇's avatar
张锡奇 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
<style lang="less" >
    @import url('../../../styles/common.less');
    #healthCardStatisticsList{
        background: #f6f5f9;
        height:100%;
        display: flex;
        flex-direction: column;
        .CONTENT{
            flex-grow: 1;
            height:1px;
            display: flex;
            flex-direction: column;
            .activeTab2{
                flex-grow: 1;
                height:1px;
                background: white;
                overflow: auto;
                -webkit-overflow-scrolling: touch;
                .items{
                    display: flex;
                    height:60px;
                    align-items: center;
                    margin:10px;
                    .avatar{
                        height:50px;
                        width:50px;
                        border-radius: 50%;
                        background: #3a8af7;
                        display: flex;
                        justify-content: center;
                        align-items: center;
                        color:white;
                        font-size:22px;
                        margin-right:10px;
                    }
                    .item{
                        flex:1;
                        height:60px;
                        border-bottom:1px solid #f6f6f6;
                        box-sizing: border-box;
                        display: flex;
                        align-items: center;
                        .name{
                            font-size:14px;
                        }
                        >div{
                            flex:1;
                        }
                    }
                }
                
            }
        }
张锡奇's avatar
张锡奇 committed
54 55 56 57 58 59 60 61 62
        .img{
            width:100%;
            display: flex;
            justify-content: center;
            img{
                width:100%;
                height:300px;
            }
        }
张锡奇's avatar
张锡奇 committed
63 64 65 66 67 68 69
    }
</style>

<template>
  <div id="healthCardStatisticsList">
      <div class="CONTENT">
        <tab v-model="activeTab" prevent-default @on-before-index-change="switchTabItem" bar-active-color="#4572d7" active-color="#4572d7" default-color="#8a8a8a">
张锡奇's avatar
张锡奇 committed
70 71
            <tab-item :selected="activeTab == 0">已填写({{list1.length}}</tab-item>
            <tab-item :selected="activeTab == 1">未填写({{list2.length}}</tab-item>
张锡奇's avatar
张锡奇 committed
72 73
        </tab>
        <div class="activeTab2">
张锡奇's avatar
张锡奇 committed
74
            <div class="items" v-for="(item,index) in (activeTab == 0 ? list1 : list2)" :key="index">
张锡奇's avatar
张锡奇 committed
75 76
                <div class="avatar">
                    <img src="" alt="">
张锡奇's avatar
张锡奇 committed
77
                    <span>{{item.sEmploeeName[0]}}</span>
张锡奇's avatar
张锡奇 committed
78 79
                </div>
                <div class="item">
张锡奇's avatar
张锡奇 committed
80
                    <div class="name">{{item.sEmploeeName}}</div>
张锡奇's avatar
张锡奇 committed
81 82
                </div>
            </div>
张锡奇's avatar
张锡奇 committed
83 84 85
            <div class="img" v-if="(activeTab == 0 ? list1 : list2).length <= 0">
                <img src="@/assets/noData.jpg" class="_img" alt="">
            </div>
张锡奇's avatar
张锡奇 committed
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
        </div>
      </div>
  </div>
</template>

<script>
import Util from '@/libs/util.js';
import {mapState} from 'vuex';
import { Tab, TabItem } from 'vux'

export default {
  name: 'healthCardStatisticsList',
  data () {
    return {
        activeTab:0,
张锡奇's avatar
张锡奇 committed
101 102 103 104 105 106
        page1:1,
        per_page1:20,
        page2:1,
        per_page2:20,
        list1:[],
        list2:[]
张锡奇's avatar
张锡奇 committed
107 108 109 110 111 112 113
    }
  },
  components:{
      Tab, TabItem
  },
  computed:{
    ...mapState({
张锡奇's avatar
张锡奇 committed
114
        hdr:state => state.healthStatistics.hdr
张锡奇's avatar
张锡奇 committed
115 116 117
    })
  },
  async mounted(){
张锡奇's avatar
张锡奇 committed
118
    
张锡奇's avatar
张锡奇 committed
119 120 121
  },
  async activated(){
    window.d = this;
张锡奇's avatar
张锡奇 committed
122 123 124 125
    this.activeTab = this.$route.params.type;
    this.clean();
    await this.getList1();
    await this.getList2();
张锡奇's avatar
张锡奇 committed
126 127
  },
  methods:{
张锡奇's avatar
张锡奇 committed
128 129 130 131 132 133 134 135
    clean(){
        this.page1 = 1;
        this.per_page1 = 20;
        this.list1 = [];
        this.page2 = 1;
        this.per_page2 = 20;
        this.list2 = [];
    },
张锡奇's avatar
张锡奇 committed
136 137
    switchTabItem(index){
        this.activeTab = index;
张锡奇's avatar
张锡奇 committed
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 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
        if(this.activeTab == 0){
            this.getList1();
        }else{this.activeTab == 1}{
            this.getList2();
        }
    },
    async getList1(){
        if(this.per_page1 < 20){
            this.$vux.toast.text('已加载全部数据!', 'middle')
            return false;
        }
        let res = await this.request('getStatisticalDetails',{
            data:[
                {key:'url',value:'HealthLog'},
                {key:'dDate',value: this.hdr.dDate},
                {key:'iCompanyId',value:'1'},
                {key:'iType',value:'1'}
            ],
            params:{
                page:this.page1,
                per_page:this.per_page1
            },
        },'加载中',{});
        if(res && res.length > 0){
            this.list1 = this.list1.concat(res);
            this.page1++;
            this.per_page1 = res.length;
        }
    },
    async getList2(){
        if(this.per_page2 < 20){
            this.$vux.toast.text('已加载全部数据!', 'middle')
            return false;
        }
        let res = await this.request('getStatisticalDetails',{
            data:[
                {key:'url',value:'HealthLog'},
                {key:'dDate',value:this.hdr.dDate},
                {key:'iCompanyId',value:'1'},
                {key:'iType',value:'0'}
            ],
            params:{
                page:this.page2,
                per_page:this.per_page2
            },
        },'加载中',{});
        if(res && res.length > 0){
            this.list2 = this.list2.concat(res);
            this.page2++;
            this.per_page2 = res.length;
        }
    },
    scrollToBottom(){
        let scrollDom = this.$refs['scrollDom'];
        if(Util.scrollToBottom(scrollDom)){
            if(this.activeTab == 0){
                this.getList1();
            }else{this.activeTab == 1}{
                this.getList2();
            }
        }
张锡奇's avatar
张锡奇 committed
199 200 201 202
    }
  }
}
</script>