曹睿
2025-04-23 913796ff8463b132be6ebb92c44f0dabb2ff279f
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<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="{
          deviceModel: item.deviceModel,
          model: item.model,
          totalAmount: item.totalLength,
          amount: item.length,
          unAmount: item.unLength,
        }"
        @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 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.total == 0) {
      pagingRef.value.complete(true);
    } else {
      pagingRef.value.complete(data.records);
    }
    emits("ok", data.total);
  }
};
</script>
 
<style lang="scss" scoped>
.card_box {
  height: calc(100vh - 140px);
}
</style>