<template>
    <div class='replenishment-device-list'>
        <CustomList 
			ref="customList"
			@onLoad="onLoad">
			<div class="list plr15 pt10">
                <div v-for="(item, i) in list" :key="i" class="item bgc-fff plr15 c-333 fs-14">
                    <div class=" ptb10 kitbox">
                        <div class="box-flex-1 fs-14">众健信联1号</div>
                        <div class="">
                            <van-tag type="success">在线</van-tag>
                            <van-tag type="success" class="ml5">在售</van-tag>
                        </div>
                    </div>
                    <div class="lh20 ptb10 kitbox">
                        <div class="box-flex-1">
                            <div>药柜容量：1156</div>
                            <div>商品库存：340.00</div>
                            <div>设备所属：禾山街道社区卫生服务中心</div>
                            <div>设备编号：149122021070000</div>
                        </div>
                        <div class="fs-20 c-pr">
                            <van-icon name="arrow" />
                        </div>
                    </div>
                </div>
            </div>
		</CustomList>
    </div>
</template>
<script>
    export default{
        name: 'replenishmentDeviceList',
        data(){
            return {
                list: [],
            }
        },
        created() {
            
        },
        methods:{
            onLoad({page, pageSize, searchText}){
                setTimeout(()=>{
                    for(var i=0; i<pageSize; i++){
                        this.list.push((page-1)*pageSize + i)
                    }
                    console.log(this.list)
                    debugger
                    this.$refs.customList.endLoad(page==5, this.list.length)
                }, 1000)
                return
                var that = this, 
                    params = {
                        orgCode: this.$store.getters.orgCode,
                        doctorNameKey: searchText,
                        dept: this.routerParam.dept,
                        diseaseKey: this.routerParam.disease,
                        page: page,
                        pagesize: pageSize
                    };
                
                zhuanjiazixunApi
                    .findDoctorByHospitalAndDiseaseAndDept(params)
                    .then(res=>{
                        if(res.status == 200){
                            var list = res.detailModelList.map(item=>{
                                var data = item
                                data.photo = this.$root.setDocPhoto(data.photo)
                                return data
                            })
                            this.list = page==1? list : this.list.concat(list)
                            this.$refs.customList.endLoad(!res.detailModelList || res.detailModelList.length==0, this.list.length)
                        } else {
                            this.$refs.customList[this.active].endLoad(false, true)
                        }
                    }).catch(err=>{
                        console.error(err)
                        this.$refs.customList[this.active].endLoad(false, true)
                    })
            },
        },
    }
</script>
<style lang='scss' scoped>
.replenishment-device-list{
    .list{
        .item{
            margin-bottom: 10px;
            border-radius: 5px;
            &:last-child{
                margin-bottom: 0;
            }
            .van-icon{
                position: absolute;
                top: 50%;
                transform: translateY(calc(-50% - 15px));
                right: 0;
                color: #ccc;
            }
        }
    }   
}
</style>