bug
jiangping
2023-12-06 1f4e7d0f73a73e7350cf5a1df279d5f30904c5d5
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
<template>
    <view class="inspection">
        <div class="inspection_list">
            <div class="inspection_list_item">
                <span>检验类型</span>
                <div class="right">
                    <div class="right_item active">完工检</div>
                    <!-- <div class="right_item active" v-if="form.status == '1'">巡检</div>
                            <div class="right_item active" v-if="form.status == '2'">完工检</div> -->
                </div>
            </div>
        </div>
        <div class="x"></div>
        <div class="inspection_list">
            <div class="inspection_list_item" @click="jumpGD">
                <span>检验工单</span>
                <div class="right1">
                    <span :style="form.gdmc ? 'color: #000;' : ''">{{ form.gdmc ? form.gdmc : '点击选择检验工单'}}</span>
                    <u-icon name="arrow-right" color="#999999" size="18" />
                </div>
            </div>
            <div class="inspection_list_item" v-if="form.gdmc">
                <span>计划数量</span>
                <div class="right1">
                    <span style="color: black;">{{info.planNum}}{{info.umodel ? info.umodel.name : ''}}</span>
                </div>
            </div>
        </div>
        <div class="x"></div>
        <div class="inspection_list">
            <div class="inspection_list_item">
                <span>良品数</span>
                <div class="right1">
                    <input type="number" v-model="form.hgsl" placeholder="0" />
                    <span class="dw" v-if="info.umodel">{{info.umodel.name}}</span>
                </div>
            </div>
            <div class="inspection_list_item">
                <span>不良数量</span>
                <div class="right1">
                    <input type="number" v-model="form.blsl" placeholder="0" />
                    <span class="dw" v-if="info.umodel">{{info.umodel.name}}</span>
                </div>
            </div>
            <div class="inspection_list_item" @click="selectBad" v-if="form.blsl > 0">
                <span>不良说明</span>
                <div class="right1">
                    <span :style="form.blsm ? 'color: #000;' : ''">{{ form.blsm ? form.blsm : '点击选择不良原因'}}</span>
                    <u-icon name="arrow-right" color="#999999" size="18" />
                </div>
            </div>
        </div>
        <div class="inspection_footer">
            <button class="inspection_footer_sub" @click="submit" v-preventReClick>提交</button>
        </div>
        <u-picker :show="show1" title="请选择不良说明" :columns="columns" keyName="name" @cancel="show1=false"
            @confirm="badConfirm">
        </u-picker>
    </view>
</template>
 
<script>
    import {
        createStandard
    } from '@/util/api/QualityAPI'
    import {
        checkAllList
    } from "@/util/api/WorkOrderAPI"
    import { REGULAR } from '@/util/utils'
    export default {
        data() {
            return {
                info: {},
                show1: false,
                columns: [],
                form: {
                    status: '2',
                    gdid: '',
                    gdmc: '',
                    jygz: '',
                    jygzmc: '',
                    hgsl: 0,
                    blsl: 0,
                    blgz: '',
                    blgzmc: '',
                    blsm: '',
                    dw: ''
                }
            };
        },
        onLoad() {
            checkAllList({
                    bmodelCateType: '3'
                })
                .then(res => {
                    let bad = res.data.map(item => {
                        return {
                            name: item.combinationName,
                            id: item.id
                        }
                    })
                    this.columns = [bad]
                })
            uni.$on('workOrder', (data) => {
                this.form.gdmc = data.mmodel.name + '-' + data.pgmodel.name
                this.form.gdid = data.id
                this.info = data
 
            })
        },
        methods: {
            jumpGD() {
                uni.navigateTo({
                    url: '/pages/selectWorkOrder/selectWorkOrder?type=2'
                })
            },
            selectBad() {
                this.show1 = true
            },
            badConfirm({
                value
            }) {
                this.form.blsm = value[0].name
                this.show1 = false
            },
            submit() {
                if (!this.form.gdid) return uni.$u.toast('工单不能为空')
                
                if (this.form.hgsl || this.form.blsl) {
                    if (this.form.hgsl) {
                        if (this.form.dw == '0') { // 整数
                            if (!REGULAR.positiveInteger.test(this.form.hgsl)) return uni.$u.toast('良品数量只能为正整数') 
                        } else if (this.form.dw == '1') { // 小数
                            if (!REGULAR.number.test(this.form.hgsl)) uni.$u.toast('良品数量只能为正整数或四位小数')
                        }
                    }
                    if (this.form.blsl) {
                        if (this.form.dw == '0') { // 整数
                            if (!REGULAR.positiveInteger.test(this.form.blsl)) return uni.$u.toast('不良数量只能为正整数')
                        } else if (this.form.dw == '1') { // 小数
                            if (!REGULAR.number.test(this.form.blsl)) {
                                return uni.$u.toast('不良数量只能为正整数或四位小数')
                            }
                        }
                    }
                } else {
                    return uni.$u.toast('良品和不良不能同时为空')
                }
                let total = (this.form.hgsl ? Number(this.form.hgsl) : 0) + (this.form.blsl ? Number(this.form.blsl) : 0)
                if (total > this.info.planNum) {
                    return  uni.$u.toast('合格不良相加不能超过计划数量')
                }
                if (Number(this.form.blsl) > 0) {
                    if (!this.form.blsm) return uni.$u.toast('不良说明不能为空')
                }
                createStandard({
                    workorderId: this.form.gdid,
                    qualifiedNum: this.form.hgsl ? this.form.hgsl : 0,
                    unqualifiedNum: this.form.blsl ? this.form.blsl : 0,
                    checkInfo: this.form.blsm,
                    checkType: this.form.status
                }).then(res => {
                    if (res.code === 200) {
                        uni.$u.toast('检验成功')
                        uni.navigateBack()
                    }
                })
            }
        }
    }
</script>
 
<style lang="scss" scoped>
    .inspection {
        width: 100%;
        height: 100%;
        position: absolute;
        background: #F7F7F7;
 
        .x {
            height: 20rpx;
        }
 
        .inspection_list {
            padding: 0 30rpx;
            background: white;
 
            .inspection_list_item {
                height: 98rpx;
                display: flex;
                align-items: center;
                justify-content: space-between;
                border-bottom: 1rpx solid #E5E5E5;
 
                &:last-child {
                    border: none;
                }
 
                span {
                    font-size: 30rpx;
                    font-weight: 400;
                    color: #222222;
                }
 
                .right1 {
                    display: flex;
                    align-items: center;
 
                    span {
                        font-size: 28rpx;
                        font-weight: 400;
                        color: #999999;
                        margin-right: 10rpx;
                    }
 
                    input {
                        width: 180rpx;
                        height: 60rpx;
                        border-radius: 8rpx;
                        border: 1rpx solid #CCCCCC;
                        margin-right: 10rpx;
                        padding: 0 30rpx;
                        box-sizing: border-box;
                        font-size: 28rpx;
                    }
 
                    input::-webkit-input-placeholder {
                        font-size: 28rpx;
                        font-weight: 400;
                        color: #999999;
                    }
 
                    .dw {
                        font-size: 28rpx;
                        font-weight: 400;
                        color: #666666;
                    }
                }
 
                .right {
                    display: flex;
                    align-items: center;
 
                    .active {
                        background: $nav-color !important;
                        color: #ffffff !important;
                    }
 
                    .right_item {
                        padding: 18rpx 32rpx;
                        background: #F2F2F2;
                        border-radius: 8rpx;
                        font-size: 26rpx;
                        font-weight: 400;
                        color: #333333;
                        display: flex;
                        align-items: center;
                        justify-content: center;
                        margin-left: 20rpx;
                    }
                }
            }
        }
 
        .inspection_footer {
            position: fixed;
            bottom: 0;
            left: 0;
            width: calc(100% - 60rpx);
            padding: 30rpx 30rpx 68rpx 30rpx;
            background: #F7F7F7;
 
            .inspection_footer_sub {
                width: 100%;
                height: 88rpx;
                background: #4275FC;
                box-shadow: 0 0 12rpx 0 rgba(0, 0, 0, 0.0800);
                border-radius: 8rpx;
                font-size: 30rpx;
                font-weight: 500;
                color: #FFFFFF;
                display: flex;
                align-items: center;
                justify-content: center;
                border: none;
            }
        }
    }
</style>