zs
2025-06-04 5a149d626ae8bc3fa4bddbb53f8caf40f51f6da6
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
<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
                    class="forma-item"
                    label="批次号"
                    v-model="form.orderNo"
                    :msg="msg.orderNo"
                    :msg-type="msgType.orderNo"
                    @search="onSearchOrderNo"
                    @clear="onClearOrderNo"
                />
                
                <template v-if="materialObj.id">
                    <view class="material-block">
                        <view class="material-block-item">
                            <view class="label">批次号:</view>
                            <view class="content auto-wrap">{{materialObj.batch}}</view>
                        </view>
                        <view class="material-block-item">
                            <view class="label auto-wrap">流水号:</view>
                            <view class="content">
                                <input class="easy-input" v-model="materialObj.serialNo" />
                            </view>
                        </view>
                        <view class="material-block-item">
                            <view class="label">长:</view>
                            <view class="content auto-wrap">{{materialObj.long}}</view>
                        </view>
                        <view class="material-block-item">
                            <view class="label">宽:</view>
                            <view class="content auto-wrap">{{materialObj.wide}}</view>
                        </view>
                        <view class="material-block-item">
                            <view class="label">高:</view>
                            <view class="content auto-wrap">{{materialObj.high}}</view>
                        </view>
                    </view>
                    
                    <easy-select-form-item 
                        label="入库口"
                        v-model="form.entranceId"
                        :msg="msg.entranceId"
                        :msg-type="msgType.entranceId"
                        :list="selectList.entrances"
                        value-field="code"
                        label-field="name"
                        :clearable="false"
                    />
                </template>
                
            </view>
            
        </view>
        <template v-slot:footer>
            <view class="bottom-btns-row">
                <u-button type="primary" text="提交入库" :disabled="confirmBtnDisabled" @click="onSubmit"></u-button>
            </view>
        </template>
    </default-header-page-layout>
</template>
 
<script>
import DefaultHeaderPageLayout from '@/components/DefaultHeaderPageLayout.vue'
import ActionUserRow from '@/components/ActionUserRow.vue'
import ScanInputFormItem from '@/components/ScanInputFormItem.vue'
import EasySelectFormItem from '@/components/EasySelectFormItem.vue'
import { $alert, $successInfo, regexValidate } from '@/static/js/utils/index.js'
let initInterVal = null;
const defaultForm = {
    orderNo:'',
    entranceId:''
}
export default {
    name:'fapaoInStorePage',
    components:{DefaultHeaderPageLayout,ActionUserRow,ScanInputFormItem,EasySelectFormItem},
    data(){
        return {
            pageBodyHeight:0,
            step:1,
            form:{...defaultForm},
            msg:{
                orderNo:'',
                entranceId:''
            },
            msgType:{
                orderNo:'error',
                entranceId:'error'
            },
            materialObj:{},
            selectList:{
                entrances:[]
            }
        }
    },
    computed:{
        confirmBtnDisabled(){
            let res = true;
            if (this.materialObj.id && this.form.entranceId) {
                res = false
            }
            return res;
        }
    },
    methods:{
        /* 单据编号搜索 */
        onSearchOrderNo(){
            if (!this.form.orderNo) {
              this.msg.orderNo = '请输入批次号!';
              return false;
            }
            this.msg.orderNo = '';
            this.getSearchInfo()
        },
        /* 清除单据编号 */
        onClearOrderNo(){
            this.resetOrderNo()
        },
        /* 清除单据编号信息 */
        resetOrderNo(){
          this.msg.orderNo = '';
          this.form.orderNo = ''
          this.materialObj = {};
          this.form.entranceId = null
        },
        getSelectOptions(callback){
            this.$api.get('PdaGetWarehouseEntrance',{Id:this.materialObj.id},{block:'fapaoIn',loading:false}).then(d=>{
                this.selectList.entrances = d.outEntranceListOutputList || []
                this.form.entranceId = d.defaultCode
                callback && callback(true)
            }).catch((errmsg)=>{
                callback && callback(false,errmsg)
            })
        },
        getSearchInfo(callback,needloding=true){
            if (needloding) {
                uni.showLoading({
                    title: '加载中...',
                    mask:true
                });
            }
            this.getInMaterilaInfo((f,msg1)=>{
                if (f){
                    this.getSelectOptions((fx,msg2)=>{
                        if (needloding) {
                            uni.hideLoading();
                            if (!fx) {
                                $alert(msg2)
                            }
                        }
                        callback && callback(fx,msg2)
                    })
                } else {
                    if (needloding) {
                        uni.hideLoading();
                        $alert(msg1)
                    }
                    callback && callback(false,msg1)
                }
            })
        },
        /* 获取入库物料信息 */
        getInMaterilaInfo(callback){
            let params = {Batch:this.form.orderNo}
            this.$api.get('GetDetail',params,{block:'fapaoIn',loading:false,warn:false}).then((d)=>{
                this.materialObj = d
                callback && callback(true)
            }).catch((_errmsg)=>{
                this.resetOrderNo()
                callback && callback(false,_errmsg)
            })
        },
        inputCheck(){
            let res = true, msg = '';
            if (!this.materialObj.serialNo) {
                msg = '请输入流水号';
                res = false
            }
            
            if (res && !regexValidate.positiveInteger(this.materialObj.serialNo)) {
                msg = '请输入只能是正整数';
                res = false
            }
            
            if (res && Number(this.materialObj.serialNo)<=0) {
                msg = '请输入只能是正整数';
                res = false
            }
            
            if (!res) {
                $alert(msg)
            }
            
            return res;
        },
        /* 响应提交按钮 */
        onSubmit(){
            if (!this.inputCheck()) return false;
            uni.showLoading({
                title: '加载中...',
                mask:true
            });
            this.dealConfirm((f,_errmsg1)=>{
                if (f) {
                    setTimeout(()=>{
                        this.getSearchInfo((fx,_errmsg2)=>{
                            uni.hideLoading();
                            if (fx) {
                                $successInfo('入库成功')
                            } else {
                                $alert(`入库成功,但:${_errmsg2}`)
                            }
                        },false)
                    },5000)
                } else {
                    uni.hideLoading();
                    $alert(_errmsg1)
                }
            })
        },
        /* 提交接口调用 */
        dealConfirm(callback){
            let params = {
                batch:this.materialObj.batch,
              serialNo:this.materialObj.serialNo,
              entranceCode:this.form.entranceId
            }
            this.$api.post('FoamingPdaAutomaticWarehouse',params,{block:'fapaoIn',loading:false,warn:false}).then(()=>{
                callback && callback(true)
            }).catch((e)=>{
                callback && callback(false,e)
            })
        },
        /* 页面初始化获取页面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(()=>{
            /* 页面初始化后需要执行的代码在这边调用 */
        })
    },
    onUnload(){
        this.clearInitInterval()
    }
}
</script>
 
<style scoped lang="scss">
.bottom-btns-row{
    padding: 10rpx;
    background-color: $uni-bg-color;
}
.forma-item{
    margin-bottom: 24rpx;
}
.material-block{
    background-color: $uni-bg-color;
    padding: 8rpx 16rpx;
    font-size: 1.1em;
    margin-bottom: 24rpx;
    border-width: 2rpx 0;
    border-style: solid;
    border-color: $uni-border-color;
    .material-block-item{
        border-bottom: 2rpx dashed $uni-text-color-grey;
        display: flex;
        &>.label{
            opacity: .7;
            flex-shrink: 0;
            width: 130rpx;
            text-align: right;
            padding-top: 11rpx;
        }
        &>.content{
            width: 1px;
            flex-grow: 1;
            line-height: 1.5em;
            padding: 8rpx 0;
        }
        &:last-child{
            border-bottom: 0;
        }
    }
    .easy-input{
        font-size: inherit;
        color: $uni-color-primary;
        text-decoration: underline;
    }
}
</style>