jiangping
2023-08-21 2837bdd57f72e386bbf9a725e7b3a13e5eb9e930
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
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
<template>
    <div class="details">
        <V-WorkOrderInfo :info="info"></V-WorkOrderInfo>
        <div class="details_cz">
            <div class="details_cz_sdtl" @click="jump" v-if="proxy.$auth('h5:workorderinput:create')">
                <img src="@/assets/icon/gongdan_ic_shoudong@2x.png" alt="" />
                <span>手动投料</span>
            </div>
            <!-- <div style="width: 20px;"></div>
            <div class="details_cz_smtl" @click="jump1" v-if="proxy.$auth('h5:workorderinput:create')">
                <img src="@/assets/icon/gongdan_ic_saoma@2x.png" alt="" />
                <span>扫码投料</span>
            </div> -->
        </div>
        <div class="details_dj">
            <div class="details_dj_title">
                <div class="details_x"></div>
                <span>生产点检</span>
            </div>
            <div class="details_dj_list">
                <van-list
                    v-model:loading="loading"
                    :finished="finished"
                    finished-text="没有更多了~"
                    @load="pageDJs">
                    <van-swipe-cell v-for="(item, index) in djData" :key="index">
                        <div class="details_dj_list_item">
                            <span>{{item.attrName}}:{{item.val}}</span>
                            <span>{{item.userName}} {{item.createTime}}</span>
                        </div>
                        <template #right>
                            <van-button square type="danger" style="height: 100%;" @click="dele(item.id)" text="删除" />
                        </template>
                    </van-swipe-cell>
                </van-list>
            </div>
        </div>
        <div class="details_zw"></div>
        <div class="details_footer">
            <div class="details_footer_buttona" @click="jumpdj" v-if="proxy.$auth('h5:workorder:processRecord')">生产点检</div>
            <div style="width: 20px;"></div>
            <div class="details_footer_buttonb" @click="jumpbg" v-if="proxy.$auth('h5:workorderoutput:confirm')">工单报工</div>
        </div>
        <v-ScanCode
            :openCode="openCode"
            :infos="['请扫描工装码']"
            @closePopup="closePopup"
            @onDecode="onDecode" />
    </div>
</template>
 
<script setup lang="ts">
    import { nextTick, onMounted, ref, reactive, getCurrentInstance } from 'vue'
    import { useRouter, useRoute } from "vue-router"
    import { queryById, getBarcodeContent, pageDJ, getListByCondition, deletedj } from '@/apis/WorkOrderAPI'
    import { Toast } from "vant"
    import { QRCodeType } from '@/enum'
    const { proxy }: any = getCurrentInstance()
    import VWorkOrderInfo from '@/components/common/WorkOrderInfo.vue'
 
    const router = useRouter()
    const route = useRoute()
 
    // 详情数据
    let info: any = ref({})
 
    // 点检数据
    let djData: any = ref([])
 
    // 控制扫码显示隐藏
    const openCode = ref<boolean>(false)
 
    // 分页查询数据
    let page = reactive({
        capacity: 10,
        page: 0
    })
 
    const list: any = ref([]);
    const loading = ref(false);
    const finished = ref(false);
 
    // 删除点检
    const dele = (id: string | number): void => {
        deletedj(id)
            .then(res => {
                if (res.code === 200) {
                    djData.value = []
                    finished.value = false
                    page.page = 0
                    pageDJs()
                }
            })
    }
 
    // 关闭扫码组件
    const closePopup = (): void => {
        openCode.value = false
    }
 
    // 获取扫码值
    const onDecode = (data: string[]): void => {
        getBarcodeContent({
            barcode: data[0]
        }).then(res => {
            if (res.code === 200) {
                if (res.data.barcodeType === QRCodeType.GZ) {
                    getListByCondition({ id: res.data.id })
                        .then(gz => {
                            if (gz.code === 200) {
                                if (gz.data[0].status !== 1) {
                                    router.push({ name: 'codeScanningFeeding', query: { id: route.query.id, gzId: res.data.id } })
                                } else {
                                    Toast.fail({ message: '扫描的工装状态不能为空', duration: 2000 })
                                }
                            }
                        })
                } else {
                    Toast.fail({ message: '请扫描正确的篮筐码', duration: 2000 })
                }
            }
        })
        nextTick(() => {
            openCode.value = false
        })
    }
 
    // 跳转手动投料
    const jump = () => {
        router.push({ name: 'manualFeeding', query: { id: route.query.id } })
    }
 
    // 跳转扫码投料
    const jump1 = () => {
        openCode.value = true
    }
 
    // 跳转工单报工
    const jumpbg = () => {
        router.push({ name: 'workOrderReporting', query: { id: route.query.id } })
    }
 
    // 跳转点检
    const jumpdj = () => {
        router.push({ name: 'spotCheck', query: { id: route.query.id } })
    }
 
    // 获取详情数据
    const queryByIds = () => {
        queryById(route.query.id).then(res => {
            if (res.code === 200) {
                info.value = res.data
            }
        })
    }
 
    // 点检数据
    const pageDJs = () => {
        if (!finished.value) {
            page.page = page.page + 1
            loading.value = true
            pageDJ({
                capacity: page.capacity,
                page: page.page,
                model: {
                    workorderId: route.query.id
                }
            }).then(res => {
                if (res.code === 200 && res.data && res.data.records.length !== 0) {
                    djData.value.push(...res.data.records)
                } else {
                    finished.value = true
                }
                loading.value = false
            }).catch(err => {
                loading.value = false
                finished.value = true
            })
        }
    }
 
    onMounted(() => {
        queryByIds()
        pageDJs()
    })
</script>
 
<style lang="scss" scoped>
.details {
    width: 100%;
    height: 100%;
    position: absolute;
    background: #F7F7F7;
    .details_cz {
        width: 100%;
        padding: 30px;
        box-sizing: border-box;
        display: flex;
        align-items: center;
        justify-content: space-between;
        .details_cz_sdtl {
            flex: 1;
            height: 76px;
            background: #FFFFFF;
            border-radius: 36px;
            display: flex;
            align-items: center;
            justify-content: center;
            img {
                width: 28px;
                height: 28px;
                margin-right: 14px;
            }
            span {
                font-size: 26px;
                font-weight: 400;
                color: #222222;
            }
        }
        .details_cz_smtl {
            flex: 1;
            height: 76px;
            background: $nav-color;
            border-radius: 36px;
            display: flex;
            align-items: center;
            justify-content: center;
            img {
                width: 28px;
                height: 28px;
                margin-right: 14px;
            }
            span {
                font-size: 26px;
                font-weight: 400;
                color: #ffffff;
            }
        }
    }
    .details_dj {
        display: flex;
        flex-direction: column;
        .details_dj_title {
            width: 100%;
            display: flex;
            align-items: center;
            padding: 0 30px 30px 30px;
            box-sizing: border-box;
            .details_x {
                width: 8px;
                height: 30px;
                background: $nav-color;
                border-radius: 2px;
                margin-right: 12px;
            }
            span {
                font-size: 32px;
                font-weight: 500;
                color: #222222;
            }
        }
        .details_dj_list {
            width: 100%;
            /*padding: 30px;*/
            box-sizing: border-box;
            background: #ffffff;
            display: flex;
            flex-direction: column;
            .details_dj_list_item {
                display: flex;
                flex-direction: column;
                border-bottom: 1px solid #E5E5E5;
                padding: 30px;
                /*margin: 30px;*/
                /*padding-bottom: 30px;*/
                /*margin-bottom: 30px !important;*/
                span {
                    &:nth-child(1) {
                        font-size: 28px;
                        font-weight: 400;
                        color: #222222;
                    }
                    &:nth-child(2) {
                        font-size: 24px;
                        font-weight: 400;
                        color: #999999;
                        margin-top: 24px;
                    }
                }
            }
        }
    }
    .details_zw {
        height: 160px;
    }
    .details_footer {
        width: 100%;
        position: fixed;
        bottom: 0;
        left: 0;
        padding-bottom: 68px;
        padding-left: 30px;
        padding-right: 30px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        box-sizing: border-box;
        .details_footer_buttona {
            flex: 1;
            height: 88px;
            background: #FFFFFF;
            box-shadow: 0 0 12px 0 rgba(0, 0, 0, 0.08);
            border-radius: 8px;
            font-size: 30px;
            font-weight: 500;
            color: $nav-color;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .details_footer_buttonb {
            flex: 1;
            height: 88px;
            background: $nav-color;
            box-shadow: 0 0 12px 0 rgba(0, 0, 0, 0.08);
            border-radius: 8px;
            font-size: 30px;
            font-weight: 500;
            color: #FFFFFF;
            display: flex;
            align-items: center;
            justify-content: center;
        }
    }
}
</style>