wtt
2026-03-20 410e69559e31fe4a8f2c33e892452582126e5bf3
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
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
<template>
    <view>
        <uni-popup ref="popup" type="bottom" @change="popupChangeHandler">
            <view class="form">
                <!-- 合格数量 -->
                <view class="form-item">
                    <view class="title">合格数量:</view>
                    <view class="right">
                        <input v-model="hform.HQty" placeholder="请输入合格数量" />
                    </view>
                </view>
                <!-- 不良数量 -->
                <view class="form-item">
                    <view class="title">不良数量:</view>
                    <view class="right">
                        <input v-model="hform.HBadCount" placeholder="请输入不良数量" />
                    </view>
                </view>
                <!-- 报废数量 -->
                <view class="form-item">
                    <view class="title">报废数量:</view>
                    <view class="right">
                        <input v-model="hform.HWasterQty" placeholder="请输入报废数量" />
                    </view>
                </view>
                <!-- 生产资源 -->
                <view class="form-item">
                    <view class="title">生产资源:</view>
                    <view class="right">
                        <uni-combox :candidates="arrayHSourceName" placeholder="请选择生产资源" v-model="hform.HSourceName"
                            @input="HSourceNameChange"></uni-combox>
                    </view>
                </view>
                <!-- 工作中心 -->
                <view class="form-item">
                    <view class="title">工作中心:</view>
                    <view class="right">
                        <uni-combox :candidates="arrayHCenterName" placeholder="请选择工作中心" v-model="hform.HCenterName"
                            @input="HCenterNameChange"></uni-combox>
                    </view>
                </view>
                <!-- 生产班组 -->
                <view class="form-item">
                    <view class="title">生产班组:</view>
                    <view class="right">
                        <uni-combox :candidates="arrayHGroupName" placeholder="请选择生产班组" v-model="hform.HGroupName"
                            @input="HGroupNameChange"></uni-combox>
                    </view>
                </view>
                <!-- 操作员 -->
                <view class="form-item">
                    <view class="title"><text>*</text>操作员:</view>
                    <view class="right">
                        <uni-combox :candidates="arrayHEmpName" placeholder="请选择操作员" v-model="hform.HEmpName"
                            @input="HEmpNameChange"></uni-combox>
                    </view>
                </view>
 
                <!-- 底部提交按钮 -->
                <view class="bottom-btn">
                    <button class="btn-a" size="mini" @tap="submit">提交</button>
                </view>
            </view>
        </uni-popup>
    </view>
</template>
 
<script>
    import getDateTime from '@/utils/getdateTime.js';
    import {
        getUserInfo
    } from "@/utils/auth.js";
    import {
        CommonUtils
    } from '../../utils/common';
 
    export default {
        name: "BillListPopup_gongxuOut",
        data() {
            return {
                userInfo: getUserInfo(),
                serverUrl: uni.getStorageSync('serverUrl') || 'http://47.96.97.237/API',
                // 下拉框候选数组
                arrayHSourceName: [],
                HSourceNameList: [],
                arrayHGroupName: [],
                HGroupNameList: [],
                arrayHEmpName: [],
                HEmpNameList: [],
                arrayHCenterName: [],
                HCenterNameList: [],
 
                hform: {
                    HInterID: '',          // 内部使用,不展示
                    HBillNo: '',            // 内部使用,不展示
                    HQty: '',
                    HBadCount: 0,
                    HWasterQty: 0,
                    HSourceName: '',
                    HSourceID: 0,
                    HCenterName: '',
                    HCenterID: 0,
                    HGroupName: '',
                    HGroupID: 0,
                    HEmpName: '',
                    HEmpID: 0,
                }
            }
        },
 
        mounted() {
            this.getNewData();               // 获取新单号
            this.getHSourceList();            // 生产资源
            this.getHGroupList();              // 生产班组
            this.getHEmpList();                 // 操作员
            this.getHCenterList();               // 工作中心
            this.getDefValByUser();              // 用户默认值
        },
 
        methods: {
            // 弹窗开关处理
            popupChangeHandler(e) {
                if (e.show === false) {
                    // 关闭时重置数量
                    this.hform.HQty = '';
                    this.hform.HBadCount = 0;
                    this.hform.HWasterQty = 0;
                    this.getNewData();
                }
            },
 
            // 打开弹窗
            showPopup(item) {
                this.hform.HInterID=item.HInterID
                this.hform.HQty=item.接收合格数量
                this.hform.HWasterQty=item.报废数量
                this.hform.HBadCount=item.不良数量
                this.hform.HSourceID=item.HSourceID
 
                this.hform.HSourceID=item.HSourceID
                this.hform.HSourceName=item.生产资源
                this.hform.HCenterID=item.HCenterID
                this.hform.HCenterName=item.工作中心
                this.hform.HGroupID=item.HGroupID
                this.hform.HGroupName=item.班组
                this.hform.HEmpID=item.HEmpID
                this.hform.HEmpName=item.操作员
                this.$refs.popup.open();
            },
 
            // 通过登录用户获取默认值
            getDefValByUser() {
                uni.request({
                    url: this.serverUrl + '/Cj_StationInBill/GetDefValByUser',
                    method: "GET",
                    async: false,
                    data: {
                        "Czybm": this.userInfo.Czybm,
                        "Czymc": this.userInfo.Czymc
                    },
                    success: (res) => {
                        if (res.data.count == 1) {
                            var data = res.data.data[0];
                            this.hform.HGroupID = data.HGroupID;
                            this.hform.HGroupName = data.生产班组名称;
                            this.hform.HEmpID = data.HEmpID;
                            this.hform.HEmpName = data.操作员名称;
                            this.hform.HSourceID = data.HSourceID;
                            this.hform.HSourceName = data.生产资源名称;
                            this.hform.HCenterID = data.HWorkCenterID;
                            this.hform.HCenterName = data.工作中心名称;
                        } else {
                            uni.showToast({
                                title: '获取默认值失败',
                                icon: 'none'
                            });
                        }
                    },
                    fail: () => {
                        uni.showToast({
                            title: '接口请求失败',
                            icon: 'none'
                        });
                    },
                });
            },
 
            // 生产资源列表
            getHSourceList() {
                uni.request({
                    url: this.serverUrl + '/api/newBill/getSourceList',
                    data: { sWhere: '' },
                    success: (res) => {
                        if (res.data.code == 1) {
                            this.HSourceNameList = res.data.data.Gy_Source;
                            this.arrayHSourceName = this.HSourceNameList.map(item => item.生产资源);
                            this.$forceUpdate();
                        } else {
                            uni.showToast({ title: res.data.Message, icon: 'none' });
                        }
                    },
                    fail: () => {
                        uni.showToast({ title: '接口请求失败', icon: 'none' });
                    },
                });
            },
            HSourceNameChange(e) {
                const found = this.HSourceNameList.find(item => item.生产资源 == e);
                if (found) this.hform.HSourceID = found.HItemID;
            },
 
            // 生产班组列表
            getHGroupList() {
                uni.request({
                    url: this.serverUrl + '/Web/GetProductionTeamList_Json',
                    data: { sWhere: "and HUSEORGID = " + uni.getStorageSync('OrganizationID') },
                    success: (res) => {
                        if (res.data.count == 1) {
                            this.HGroupNameList = res.data.data;
                            this.arrayHGroupName = this.HGroupNameList.map(item => item.班组);
                            this.$forceUpdate();
                        } else {
                            uni.showToast({ title: res.data.Message, icon: 'none' });
                        }
                    },
                    fail: () => {
                        uni.showToast({ title: '接口请求失败', icon: 'none' });
                    },
                });
            },
            HGroupNameChange(e) {
                const found = this.HGroupNameList.find(item => item.班组 == e);
                if (found) this.hform.HGroupID = found.HItemID;
            },
 
            // 操作员列表
            getHEmpList() {
                uni.request({
                    url: this.serverUrl + '/Web/GetEmployeeList_Json',
                    data: {
                        Employee: '',
                        HGroupID: 0,
                        HDeptID: uni.getStorageSync("HDeptID")
                    },
                    success: (res) => {
                        if (res.data.count == 1) {
                            this.HEmpNameList = res.data.data;
                            this.arrayHEmpName = this.HEmpNameList.map(item => item.HName);
                            this.$forceUpdate();
                        } else {
                            uni.showToast({ title: res.data.Message, icon: 'none' });
                        }
                    },
                    fail: () => {
                        uni.showToast({ title: '接口请求失败', icon: 'none' });
                    },
                });
            },
            HEmpNameChange(e) {
                const found = this.HEmpNameList.find(item => item.HName == e);
                if (found) this.hform.HEmpID = found.HItemID;
            },
 
            // 工作中心列表
            getHCenterList() {
                uni.request({
                    url: this.serverUrl + '/api/newBill/getWorkCenterList',
                    data: { sWhere: '' },
                    success: (res) => {
                        if (res.data.code == 1) {
                            this.HCenterNameList = res.data.data.Gy_Source;
                            this.arrayHCenterName = this.HCenterNameList.map(item => item.工作中心);
                            this.$forceUpdate();
                        } else {
                            uni.showToast({ title: res.data.Message, icon: 'none' });
                        }
                    },
                    fail: () => {
                        uni.showToast({ title: '接口请求失败', icon: 'none' });
                    },
                });
            },
            HCenterNameChange(e) {
                const found = this.HCenterNameList.find(item => item.工作中心 == e);
                if (found) this.hform.HCenterID = found.HItemID;
            },
 
            // 获取新单据号(内部使用)
            getNewData() {
                uni.request({
                    url: this.serverUrl + '/Web/GetMAXNum',
                    data: { HBillType: '3791' },
                    success: (res) => {
                        if (res.data.count == 1) {
                            this.hform.HInterID = res.data.data[0].HInterID;
                            this.hform.HBillNo = res.data.data[0].HBillNo;
                        } else {
                            uni.showToast({ title: res.data.Message, icon: 'none' });
                        }
                    },
                    fail: () => {
                        uni.showToast({ title: '接口请求失败', icon: 'none' });
                    },
                });
            },
 
            // 提交前校验
            preSubmitCheck() {
                if (CommonUtils.isEmpty(this.hform.HQty)) {
                    return { pass: false, message: '合格数量不能为空' };
                }
                if (CommonUtils.isEmpty(this.hform.HBadCount)) {
                    return { pass: false, message: '不良数量不能为空' };
                }
                if (CommonUtils.isEmpty(this.hform.HWasterQty)) {
                    return { pass: false, message: '报废数量不能为空' };
                }
                if (!this.hform.HEmpName) {
                    return { pass: false, message: '请选择操作员' };
                }
                return { pass: true, message: '' };
            },
 
            // 提交
            submit() {
                const { pass, message } = this.preSubmitCheck();
                if (!pass) {
                    return uni.showToast({ icon: 'none', title: message });
                }
 
                uni.showLoading({ title: '提交中...' });
 
 
                const submitData = {
                    HInterID: this.hform.HInterID,
                    HBillNo: this.hform.HBillNo,
                    HQty: this.hform.HQty,
                    HBadCount: this.hform.HBadCount,
                    HWasterQty: this.hform.HWasterQty,
                    HSourceID: this.hform.HSourceID,
                    HSourceName: this.hform.HSourceName,
                    HCenterID: this.hform.HCenterID,
                    HCenterName: this.hform.HCenterName,
                    HGroupID: this.hform.HGroupID,
                    HGroupName: this.hform.HGroupName,
                    HEmpID: this.hform.HEmpID,
                    HEmpName: this.hform.HEmpName,
                    
                };
 
                uni.request({
                    url: this.serverUrl + '/Cj_StationEntrustOutBill/setOtherProperty',
                    method: 'POST',
                    data: {
                        oMain: JSON.stringify(submitData)+ ";" + uni.getStorageSync('HUserName'),
                        
                    },
                    success: (res) => {
                        uni.hideLoading();
                        if (res.data.count == 1) {
                            uni.showToast({ title: '提交成功', icon: 'none' });
                            setTimeout(() => {
                                this.$refs.popup.close();
                            }, 1500);
                        } else {
                            uni.showToast({ title: res.data.Message, icon: 'none' });
                        }
                    },
                    fail: () => {
                        uni.hideLoading();
                        uni.showToast({ title: '接口请求失败', icon: 'none' });
                    },
                });
            }
        }
    }
</script>
 
<style lang="scss" scoped>
    .form {
        box-sizing: border-box;
        border-radius: 15rpx 15rpx 0 0;
         padding: 20rpx 20rpx 160rpx 20rpx;
        background-color: #fff;
        display: flex;
        flex-direction: column;
        gap: 10rpx;
        overflow-y: auto;
        // max-height: 70vh;
        max-height: calc(80vh - 120px);
    }
 
    .form-item {
        display: flex;
        align-items: center;
        font-size: 30rpx;
        padding: 6rpx 0;
 
        .title {
            width: 180rpx;
            flex-shrink: 0;
 
            text {
                color: red;
                font-weight: bold;
            }
        }
 
        .right {
            flex: 1;
            border-radius: 22rpx;
            border: 1px solid #acacac;
        }
 
        input, .uni-combox {
            width: 100%;
            padding: 8rpx 20rpx;
            font-size: 30rpx;
        }
    }
 
    .bottom-btn {
        width: 100%;
        box-sizing: border-box;
        position: fixed;
        bottom: 0;
        left: 0;
        background-color: #fff;
        box-shadow: 0 2rpx 10rpx 2rpx rgba(0, 0, 0, 0.4);
        padding: 30rpx 40rpx 40rpx 40rpx;
        display: flex;
        justify-content: center;
 
        button {
            border-radius: 50rpx;
            width: 300rpx;
            height: 66rpx;
            line-height: 66rpx;
            font-size: 28rpx;
            background-color: #3A78FF;
            color: #fff;
        }
    }
</style>