<script setup>
import { warehouseList } from '@/api/home';
import { ref } from 'vue';
import { transformData, objectToQuery } from '../until'

const myWarehouseList = ref([])

const onChecked = (item) => {
    if (!item.deptId) return
    uni.navigateTo({
        url: `/pages/components/EquipmentInfo?deptId=${item.deptId}&warehouseName=${item.warehouseName || ''}&projectName=${item.parentName || ''}`
    })
}
const getMyWarehouseList = () => {
    warehouseList().then((res) => {
        myWarehouseList.value = transformData(res.data)
        console.log('我的仓库===>', res, transformData(res.data));
    })

}

getMyWarehouseList()

</script>
<template>

    <uv-list v-for="(item, index) in myWarehouseList" :key="index" class="list">
        <view class="title line">{{ item.parentName }}</view>
        <uv-list-item v-for="(i, idx) in item.items" :key="idx" link clickable @tap="onChecked(i)"
            :title="i.warehouseName">
            <template v-slot:footer>
                <view :style="i?.onlineRate > 0 ? 'color :#9CCC65;font-size: 14px;' : 'color :#000;font-size: 14px;'">
                    <text>在线率：</text>
                    <text>{{ i?.onlineRate }}%</text>
                </view>

            </template>
        </uv-list-item>


    </uv-list>


</template>
<style scoped>
.list {

    background-color: #fff;
    margin-bottom: 8px;
}

.title {
    padding: 8px 30rpx;
}
</style>