<template>
|
<view class="card_box">
|
<z-paging
|
ref="pagingRef"
|
v-model="list"
|
:fixed="false"
|
:auto-show-back-to-top="true"
|
@query="getList"
|
>
|
<template #top>
|
<Statistics class="statistics_box" />
|
</template>
|
<ProductCard
|
v-for="(item, index) in list"
|
:key="index"
|
:data="item"
|
:map="map"
|
@click="toDetail(item.id, item.type)"
|
/>
|
</z-paging>
|
</view>
|
</template>
|
|
<script setup lang="ts">
|
import Statistics from "../components/Statistics.vue";
|
import ProductCard from "@/components/product_card/index.vue";
|
import { useUserStore } from "@/store/modules/user";
|
import zPaging from "@/components/z-paging/z-paging.vue";
|
const userStore = useUserStore();
|
const userInfo: any = computed(() => userStore.userInfo);
|
const pagingRef = ref();
|
const map = reactive({
|
deviceModel: "deviceModel",
|
model: "model",
|
totalAmount: "totalAmount",
|
amount: "amount",
|
unAmount: "unAmount",
|
});
|
const props = defineProps({
|
api: {
|
type: Function,
|
default: () => {},
|
},
|
state: {
|
type: String,
|
default: "",
|
},
|
});
|
|
const emits = defineEmits(["ok"]);
|
const list = ref<any[]>([]);
|
|
const toDetail = (id: number, type: string) => {
|
if (type == "拉丝") {
|
uni.navigateTo({
|
url: `/pages/production/detail/wireDetail?id=${id}`,
|
});
|
} else if (type == "绞线") {
|
uni.navigateTo({
|
url: `/pages/production/detail/twistDetail?id=${id}`,
|
});
|
}
|
};
|
|
const getList = async (pageNo: number, pageSize: number) => {
|
const { code, data } = await props.api({
|
userName: userInfo.value.userName,
|
state: props.state,
|
current: pageNo,
|
size: pageSize,
|
});
|
if (code == 200) {
|
if (data.type == "绞线") {
|
map.deviceModel = "deviceModel";
|
map.model = "model";
|
map.totalAmount = "totalLength";
|
map.amount = "length";
|
map.unAmount = "unLength";
|
} else if (data.type == "拉丝") {
|
map.deviceModel = "deviceModel";
|
map.model = "model";
|
map.totalAmount = "totalAmount";
|
map.amount = "amount";
|
map.unAmount = "unAmount";
|
}
|
if (data.data.total == 0) {
|
pagingRef.value.complete(true);
|
} else {
|
pagingRef.value.complete(data.data.records);
|
}
|
emits("ok", data.data.total);
|
}
|
};
|
</script>
|
|
<style lang="scss" scoped>
|
.card_box {
|
height: calc(100vh - 140px);
|
}
|
</style>
|