jiangping
2023-08-11 5c98be0b50b8ca78ed05358cbd434193e75dcd8a
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
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
<template>
    <div class="page">
        <div class="page_title">当前:<template v-if="info.wmodel">{{info.wmodel.name}}</template> / {{info.unionName}}</div>
        <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
            <van-list
                v-model:loading="loading"
                :finished="finished"
                finished-text="没有更多了~"
                @load="getList"
            >
                <div class="page_info" v-for="(item, index) in list" :key="index">
                    <div class="page_info_nr">
                        <div class="item">
                            <div class="item_label">{{item.materialName}} | {{item.materialCode}}</div>
                            <div class="item_label1">
                                <span class="green" v-if="item.qualityType === '0'">合格</span>
                                <span class="yellow" v-if="item.qualityType === '1'">不良</span>
                                <span class="red" v-if="item.qualityType === '2'">报废</span>
                                | {{item.procedureName ? item.procedureName : '-'}} | {{item.batch ? item.batch : '-'}}
                            </div>
                            <div class="item_label2">数量:{{item.num}}{{item.unitName}}</div>
                        </div>
                    </div>
                </div>
            </van-list>
        </van-pull-refresh>
    </div>
</template>
 
<script setup lang="ts">
    import { ref, onMounted, reactive } from 'vue'
    import { useRoute } from "vue-router"
    import { pageForH5, pageHW } from '@/apis/WorkOrderAPI'
    import { getLocationInfo } from '@/apis/ExWarehouse'
 
    const route = useRoute()
 
    const form = reactive({
        capacity: 10,
        page: 0
    })
 
    // 列表数据
    const list: any = ref([]);
    const loading = ref(false);
    const finished = ref(false);
    const refreshing = ref(false)
 
    // 货位信息
    let info = ref({})
 
    // 下拉刷新优化页面
    const onRefresh = () => {
        finished.value = false;
        form.page = 0
        loading.value = true;
        getList()
    }
 
    // 通过货位id获取id详情
    const getLocation = () => {
        pageHW({
            capacity: 1,
            page: 1,
            model: {
                id: route.query.id
            }
        })
            .then(res => {
                if (res.code === 200) {
                    info.value = res.data.records[0]
                }
            })
    }
 
    const getList = () => {
        if (!finished.value) {
            loading.value = true;
            form.page = form.page + 1
            pageForH5({
                capacity: form.capacity,
                page: form.page,
                model: {
                    locationId: route.query.id,
                    groupType: 3,
                    greaterZero: 1
                }
            }).then(res => {
                loading.value = false;
                if (refreshing.value) {
                    list.value = []
                    refreshing.value = false;
                }
                if (res.code === 200 && res.data.records && res.data.records.length !== 0) {
                    list.value.push(...res.data.records)
                } else {
                    finished.value = true;
                }
            }).catch((err: any) => {
                loading.value = false;
                finished.value = true;
                if (refreshing.value) {
                    list.value = []
                    refreshing.value = false;
                }
            })
        }
    }
 
    onMounted(() => {
        getList()
        getLocation()
    })
</script>
 
<style lang="scss" scoped>
    .page {
        width: 100%;
        height: 100%;
        position: absolute;
        background: #F7F7F7;
        .page_info {
            padding: 30px;
            background: #ffffff;
            margin-bottom: 30px;
            &:last-child {
                margin-bottom: 0 !important;
            }
            .page_info_nr {
                border-radius: 16px;
                display: flex;
                align-items: center;
                flex-wrap: wrap;
                .item {
                    width: 55%;
                    display: flex;
                    flex-direction: column;
                    margin-top: 24px;
                    &:first-child {
                        margin-top: 0 !important;
                    }
                    .item_label {
                        font-size: 28px;
                        font-weight: 400;
                        color: #000000;
                        flex-shrink: 0;
                    }
                    .item_label1 {
                        font-size: 24px;
                        font-weight: 400;
                        color: #666666;
                        flex-shrink: 0;
                        margin-top: 20px;
                    }
                    .item_label2 {
                        font-size: 24px;
                        font-weight: 400;
                        color: #000000;
                        flex-shrink: 0;
                        margin-top: 20px;
                    }
                }
            }
        }
        .page_title {
            padding: 20px 30px 20px 30px;
            font-size: 24px;
            font-weight: 500;
            color: #222222;
        }
    }
</style>