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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
<template>
    <van-popup
        v-model:show="props.show"
        position="bottom"
        :style="{ height: '100%' }">
        <div class="title">
            <div class="close" @click="close"><van-icon name="arrow-down" size="30" color="#ffffff" /></div>
        </div>
        <div class="content">
            <div :class="{ 'content_top': status }" class="content_search">
                <v-Search ref="V" @searchInput="searchInput" @submit="submit" :isShow="false" placeholder="搜索工装编码"></v-Search>
                <template v-if="props.classification">
                    <div class="content_search_x"></div>
                    <v-LableSelection :TagList="tagList" :isShow="false" @change="clickTag"></v-LableSelection>
                </template>
            </div>
            <div class="content_total">共{{form.total}}条数据</div>
            <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
                <van-list
                    v-model:loading="loading"
                    :finished="finished"
                    finished-text="没有更多了~"
                    @load="onLoad">
                    <div class="content_list">
                        <div class="content_list_item" v-for="(item, i) in list" :key="i" @click="jump(item)">
                            <div class="content_list_item_status success" v-if="item.smodelLabel === Attribute.HG">[{{item.smodelCode}}]</div>
                            <div class="content_list_item_status warning" v-else-if="item.smodelLabel === Attribute.BL">[{{item.smodelCode}}]</div>
                            <div class="content_list_item_status serious" v-else-if="item.smodelLabel === Attribute.BF">[{{item.smodelCode}}]</div>
                            <div class="content_list_item_status black" v-else-if="item.smodelLabel === Attribute.HH">[{{item.smodelCode}}]</div>
                            <div class="content_list_item_name">{{item.cmodel1BigName}}-{{item.code}}</div>
                        </div>
                    </div>
                </van-list>
            </van-pull-refresh>
        </div>
    </van-popup>
</template>
 
<script setup lang="ts">
    import { defineProps, defineEmits, onMounted, ref, reactive, watch } from 'vue'
    import { checkAllList, toolingList } from '@/apis/WorkOrderAPI'
    import { model } from '@/interface'
    import { Attribute } from '@/enum'
    import { judgmentPlatform } from "@/utils/utils"
    import vSearch from '@/components/common/Search.vue'
    import vLableSelection from '@/components/common/LabelSelection.vue'
 
    // 搜索数据接口
    interface form extends model {
        total: number,
        smodelLabel: string,
        categoryId: string
    }
 
    const form = reactive<form>({
        capacity: 50,
        page: 0,
        total: 0,
        smodelLabel: '',
        categoryId: ''
    })
 
    // 搜索分类标签
    let tagList = ref<Array<{id: string, name: string, num: string}>>([])
 
    // 列表数据
    const list: any = ref([]);
    const loading = ref(false);
    const finished = ref(false);
    const refreshing = ref(false)
    let isOne = ref<boolean>(true)
    const V = ref(null)
    let isOpen = ref<boolean>(true)
 
    const test = () => {
        const { text } = V.value
        form.smodelLabel = ''
        V.value.text = ''
    }
 
    const clickTag = (tag: string): void => {
        form.categoryId = tag
        list.value = []
        finished.value = false
        form.page = 0
        form.total = 0
        onLoad()
    }
 
    // 搜索框
    const searchInput = (data: any) => {
        form.page = 0
        finished.value = false
        list.value = []
        form.smodelLabel = data
        onLoad()
    }
 
    // 搜索提交
    const submit = (): void => {
        form.page = 0
        finished.value = false
        list.value = []
        onLoad()
    }
 
    // 返回上一页带参数
    const jump = (item: any) => {
        emit('value', item)
    }
 
    // 获取工单列表数据
    const onLoad = async () => {
        if (isOne.value && props.classification) await checkAllLists()
        if (!finished.value) {
            loading.value = true;
            form.page = form.page + 1
            toolingList({
                capacity: form.capacity,
                page: form.page,
                model: {
                    categoryId: form.categoryId,
                    code: form.smodelLabel,
                    smodelLabel: props.attribute,
                    statusname: props.statusname
                }
            }).then(res => {
                if (refreshing.value) {
                    list.value = []
                    refreshing.value = false;
                }
                loading.value = false;
                if (res.code === 200 && res.data.records && res.data.records.length !== 0) {
                    form.total = res.data.total
                    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;
                }
            })
        }
    }
 
    // 下拉刷新优化页面
    const onRefresh = () => {
        finished.value = false;
        form.page = 0
        loading.value = true;
        onLoad()
    }
 
    let status = ref<boolean>(false)
 
    const props = defineProps({
        show: {
            type: Boolean,
            required: true
        },
        classification: {   // 是否需要展示分类
            type: Boolean,
            default: false
        },
        attribute: {    // 工装属性
            type: String,
            required: false,
            default: ''
        },
        statusname: {   // 工装状态
            type: String,
            required: false,
            default: '1,2,3'
        }
    })
 
    const emit = defineEmits(['close', 'value'])
 
    // 关闭回调
    const close = () => {
        emit('close')
    }
 
    // 获取工装器具分类
    const checkAllLists = async () => {
        let res = await checkAllList({
            bmodelCateType: '2'
        })
        if (res.code === 200 && res.data.length !== 0) {
            tagList.value = []
            res.data.forEach((item: any) => {
                tagList.value.push({ id: item.id, name: item.combinationName, num: '' })
            })
            form.categoryId = tagList.value[0].id
            isOne.value = false
        }
    }
 
    watch(() => props.show, (news) => {
        if (!news) {
            test()
        } else {
            if (!isOpen.value) {
                list.value = []
                finished.value = false;
                form.page = 0
                loading.value = true;
                onLoad()
            }
            isOpen.value = false
        }
    })
 
    onMounted(() => {
        status.value = judgmentPlatform()
    })
</script>
 
<style lang="scss" scoped>
    .title {
        position: fixed;
        right: 50px;
        bottom: 100px;
        z-index: 9;
        .close {
            width: 80px;
            height: 80px;
            border-radius: 50%;
            background: #999999;
            display: flex;
            align-items: center;
            justify-content: center;
        }
    }
    .content {
        .content_code {
            position: fixed;
            right: 30px;
            bottom: 100px;
            img {
                width: 138px;
                height: 138px;
            }
        }
        .content_top {
            top: 0 !important;
        }
        .content_search {
            padding: 30px;
            background: white;
            position: sticky;
            top: 88px;
            z-index: 9;
            .content_search_x {
                height: 24px;
            }
        }
        .content_total {
            padding: 24px 30px;
            background: #F7F7F7;
            font-size: 24px;
            font-weight: 400;
            color: #666666;
        }
        .content_list {
            width: 100%;
            height: 100%;
            display: flex;
            flex-direction: column;
            .content_list_item {
                padding: 30px;
                display: flex;
                border-bottom: 1px solid #ececec;
                .serious {
                    color: $nav-stateColor4 !important;
                }
                .success {
                    color: $nav-stateColor2 !important;
                }
                .warning {
                    color: $nav-stateColor5 !important;
                }
                .content_list_item_status {
                    font-size: 28px;
                    margin-right: 10px;
                }
                .content_list_item_name {
                    font-size: 28px;
                }
            }
        }
    }
</style>