22
schangxiang@126.com
2025-05-21 40c6e31e722088fb5577552271eb0af7f695131e
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
<template>
    <default-header-page-layout ref="page" title="分拣">
        <view class="page-frame with-action-user-row" :style="{height:pageBodyHeight+'px'}" v-if="pageBodyHeight">
            <action-user-row />
            <view class="with-action-user-row-page-content">
                <scan-input-form-item :msgType='msgType' class="forma-item" label="托盘编号" v-model="form.containerCode "
                    :msg="msg" @search="onSearchContainter" @clear="onClearContainter" />
                <scan-input-form-item v-show="Boolean(form.orderNo)" placeholder="" disabled :hasScan="false" :hasSearch="false" class="forma-item" label="单据号"
                    :value="form.orderNo" @search="onSearchNO" @clear="onClearNO" />
            
                <view v-if="true">
                    <view v-for="(item,index) in wmsSortOrderList" :key="index">
                        <bar-content :index="index" :content="item"></bar-content>
                    </view>
                
                </view>
            </view>
 
 
        </view>
        <template v-slot:footer>
            <view class="bottom-btns-row">
                <view class="btn-frame">
                    <!--  -->
                    <u-button :disabled="!bindIn" @click="onSubmit" type="primary" text="提 交">
                    </u-button>
                </view>
            </view>
        </template>
    </default-header-page-layout>
</template>
<script>
    import DefaultHeaderPageLayout from '@/components/DefaultHeaderPageLayout.vue'
    import ScanInputFormItem from '@/components/ScanInputFormItem.vue'
    import ActionUserRow from '@/components/ActionUserRow.vue'
    import barContent from './modules/barContent.vue'
    import {
        $alert,
        $successInfo
    } from '@/static/js/utils'
    import {
        SortSure,
        GetSortInfo
    } from '@/api/slicingOn.js'
    import {
        getSysEnumData
    } from '@/api/common.js'
    const defaultForm = {
        code: '',
        material: ''
    }
    let initInterVal = null;
 
    export default {
        name: 'slicingOnPage',
        components: {
            DefaultHeaderPageLayout,
            ScanInputFormItem,
            ActionUserRow,
            barContent
        },
        data() {
            return {
                pageBodyHeight: 0,
                form: {
                    containerCode: '',
                    orderNo: ''
                },
                msg: '',
                msgType: 'info',
                ContainerStatus: [],
                wmsSortOrderList:[],
                wmsContainer:{}
            }
        },
        computed:{
            bindIn(){
                return Boolean(this.wmsContainer.containerCode)
            }
        },
        methods: {
            // 获取托盘信息
            onSearchContainter(containerCode) {
                if (containerCode) {
                    this.form.containerCode = containerCode
                }
                const param = {
                    containerCode: this.form.containerCode
                }
                GetSortInfo(param).then(res => {
                    const {
                        data
                    } = res
                    console.log(res, 'res');
                    if (Boolean(data) && Boolean(data.wmsContainer) && data.wmsSortOrderList.length > 0) {
                        const {
                            wmsSortOrderList,
                            wmsContainer
                        } = data
                        this.wmsSortOrderList=wmsSortOrderList
                        this.wmsContainer=wmsContainer
                        this.form.orderNo = wmsSortOrderList[0].orderNo
                        //     this.contaninerData = res.data
                        //         const containterDetail = this.contaninerData.wmsContainer || {}
                        //         this.wmsMaterials=this.contaninerData.wmsMaterials||[]
                        //         this.noData.forEach(item=>{
                        //         const result=this.wmsMaterials.filter(obj => obj.materialName == item.materialname)
                        //         if(result.length>0) {
                        //             this.$set(item, 'checked', true)
                        //             this.$set(item,'qty',result[0].bindQuantity)
                        //         }else {
                        //             this.$set(item, 'checked', false)        
                        //         }
 
                        //         })
                        const result = this.ContainerStatus.filter(item => item.code == wmsContainer
                            .containerStatus)
                        var containerStatusName = ''
                        if (result.length > 0) {
                            containerStatusName = result[0].value
                        }
                        this.msgType = 'info'
                        this.msg =
                            `尺寸:${wmsContainer.specLength+'*'+wmsContainer.specWidth+'*'+wmsContainer.specHeight},状态:${containerStatusName}`
                    } else {
                        this.msg = res.message
                        this.msgType = 'error'
                    }
                })
            },
            // 清除托盘信息
            onClearContainter() {
                this.form={
                    containerCode: '',
                    orderNo: ''
                }
                this.msg = ''
                this.msgType = 'info'
                this.wmsSortOrderList=[]
                this.wmsContainer={}
            },
            // 获取枚举信息
            async getSysEnumData() {
                try {
                    let {
                        data
                    } = await getSysEnumData({
                        enumName: 'ContainerStatus'
                    })
                    this.ContainerStatus = data
                } catch (e) {
                    //TODO handle the exception
                    console.log(e);
                }
            },
            
            // 确认提交
            async onSubmit() {
                uni.showModal({
                    title: '分拣确认',
                    content: '确定执行分拣操作吗?',
                    showCancel: true,
                    cancelText: '取消',
                    confirmText: '确定',
                    success: async (type) => {
                        let {
                            confirm,
                            cancel
                        } = type
                        if (confirm) {
                            const {wmsContainer,wmsSortOrderList}=this
                            let data={wmsContainer,wmsSortOrderList}
                            try{
                                await SortSure(data)
                                uni.showToast({
                                    title: '分拣成功',
                                    success: () => {
                                        this.onClearContainter()
                                    }
                                })
                            }catch(e){
                                //TODO handle the exception
                            }
                        
                        }
                    }
                })
                
                
            },
            
            /* 页面初始化获取页面body高度的定时器 */
            startInitInterval(callback) {
                initInterVal = setInterval(() => {
                    if (this.pageBodyHeight) {
                        this.clearInitInterval()
                        callback && callback()
                    } else {
                        this.pageBodyHeight = this.$refs.page.getBodyHeight()
                    }
                }, 200)
            },
            /* 清除定时器 */
            clearInitInterval() {
                try {
                    clearInterval(initInterVal)
                    initInterVal = null
                } catch (e) {
                    //TODO handle the exception
                }
            },
    
        },
        onReady() {
            this.startInitInterval(() => {
                /* 页面初始化后需要执行的代码在这边调用 */
                this.getSysEnumData()
            })
        },
        onUnload() {
            this.clearInitInterval()
        }
    }
</script>
<style lang="scss" scoped>
    .bottom-btns-row {
        padding: 10rpx;
        background-color: $uni-bg-color;
    }
 
    .forma-item {
        margin-bottom: 24rpx;
    }
 
    .slicing-on-page-content {
        height: 100%;
        display: flex;
        flex-direction: column;
 
        &>.top-view {
            flex-shrink: 0;
        }
 
        &>.list-view {
            height: 1px;
            overflow: auto;
            flex-grow: 1;
 
            .list-items-group {
                padding-top: 24rpx;
            }
        }
    }
</style>