yangan
22 小时以前 a28d0135ee42809b2c5863609da37155d3ecba5b
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
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
<template>
    <view>
        <view class="origin-info">
            <view class="origin-info_wrapper">
                <view class="origin-info_content">
                    <view class="first-line"><combined-title title="原发信息"></combined-title></view>
                    <u-form :model="originInfoForm"
                        :rules="rules"
                        label-position="top"
                        label-width="160"
                        :label-style="{'marginLeft':'9px'}"
                        ref="originInfoRef">
                        <!-- 外购---isweight === 1 称重 皮毛净 -->
                        <view v-if="isWeight"> 
                        <u-form-item prop="coalContactSkin">
                            <view class="second-line">
                                <view class="label-text"
                                    :class="{ focusClass: isfocus1 }"><text style="color: #f56c6c;">*</text>皮重</view>
                                <view class="input-container"
                                    :class="{ inputClass: isfocus1, disabledClass: isModifyoriginInfo }">
                                    <u--input placeholder="请输入皮重"
                                        border="surround"
                                        v-model="originInfoForm.coalContactSkin"
                                        @focus="inputFocus(1)"
                                        @blur="inputBlur"
                                        @change="inputChange"></u--input>
                                </view>
                                <view class="unit"
                                    :class="{ focusClass: isfocus1 }">吨</view>
                            </view>
                        </u-form-item>
                        <u-form-item prop="coalContactHair">
                            <view class="second-line">
                                <view class="label-text"
                                    :class="{ focusClass: isfocus2 }"><text style="color: #f56c6c;">*</text>毛重</view>
                                <view class="input-container"
                                    :class="{ inputClass: isfocus2, disabledClass: isModifyoriginInfo }">
                                    <u--input placeholder="请输入毛重"
                                        border="surround"
                                        v-model="originInfoForm.coalContactHair"
                                        @focus="inputFocus(2)"
                                        @blur="inputBlur"
                                        @change="inputChange"></u--input>
                                </view>
                                <view class="unit"
                                    :class="{ focusClass: isfocus2 }">吨</view>
                            </view>
                        </u-form-item>
                        <u-form-item>
                            <view class="second-line">
                                <view class="label-text"><text style="color: #f56c6c;">*</text>净重</view>
                                <view class="input-container"
                                    :class="{ disabledClass: isModifyoriginInfo }">
                                    <u--input placeholder="净重"
                                        border="surround"
                                        disabled
                                        v-model="coalContactClean"></u--input>
                                </view>
                                <view class="unit">吨</view>
                            </view>
                        </u-form-item>
                    
                        </view>
                        <view v-else class="table-div">
                        <uni-table 
                         border 
                        id="table-box"
                        emptyText="暂无更多数据">
                                <uni-tr>
                                    <uni-th align="center" >产品</uni-th>
                                    <!-- <uni-th align="center">皮重</uni-th>
                                    <uni-th align="center">毛重</uni-th>
                                    <uni-th align="center">净重</uni-th> -->
                                    <uni-th align="center">数量</uni-th>            
                                </uni-tr>
                                <uni-tr v-for="(subItem, index) in coalData.tmTaskCoalList" :key="index">
                                    <uni-td align="center">
                                        <view class="name">{{ subItem.productName }}</view></uni-td>
                                <!-- <uni-td align='right'>
                                    <view  v-if="subItem.skin">{{ Number( subItem.skin).toFixed(2)  || ''}}</view>
                                </uni-td>
                                <uni-td align='right'>
                                    <view class="name" v-if="subItem.hair">{{ Number(subItem.hair) .toFixed(2) || '' }}</view>
                                </uni-td>
                                <uni-td align='right'>
                                    <view class="name" v-if="subItem.clean">{{ Number( subItem.clean).toFixed(2) || '' }}</view>
                                </uni-td> -->
                                
                                <uni-td align="right">
                                <view>
                                <u--input
                                placeholder="请输入产品数量"
                                type='number'
                                v-model="subItem.productQuantity"
                                ></u--input>
                                </view></uni-td>
                                
                            </uni-tr>
                            </uni-table>
                        </view>
 
                            <u-form-item prop='contactPicture'>
                            <view class="label-text">
                                <text style="color: #f56c6c;">*</text>原发单据
                            </view>
                            <u-upload :fileList="fileList1"
                                @afterRead="afterRead"
                                @delete="deletePic"
                                name="1"
                                multiple
                                :maxCount="2"
                                width="250"
                                height="150"
                                :previewFullImage="true"></u-upload>
                        </u-form-item>
                    
                    </u-form>
                    <view class="submit-button">
                        <view class="">
                            <u-button text="立即预约"
                                type="primary"
                                @click.stop="directAppointment"
                                v-if="isSpecial"></u-button>
                        </view>
                        <view class="">
                            <u-button text="提交信息"
                                type="primary"
                                @click.stop="submitOriginInfo"
                                :loading="submitOriginInfoLoading"
                                :disabled="!coalContactClean"></u-button>
                        </view>
                    </view>
                </view>
            </view>
        </view>
    </view>
</template>
 
<script>
    import combinedTitle from '@/components/combined-title/combined-title.vue'
    import BigNumber from "bignumber.js"
    import { BaseUrl } from '@/api/publicInterface.js'
    export default {
        components: {
            combinedTitle
        },
        data() {
            return {
                orderPlanId: "",
                // 聚焦时改变样式
                isfocus1: false,
                tmTaskCoalList:[],
                isfocus2: false,
                // 输入的原发信息
                originInfoForm: {
                    coalContactSkin: '',
                    coalContactHair: '',
                    coalContactClean: 0,
                    contactPicture: ''
                },
                fileList1: [], //图片列表
                rules: {},
                submitOriginInfoLoading: false,
                coalData: {},
                sendDate: '',
                deptId: '',
                filedId: '',
                isSpecial: null,
                isWeight:null,
            }
        },
        computed: {
            coalContactClean() {
                if(this.isWeight){
                    let xx = BigNumber(this.originInfoForm.coalContactHair ? this.originInfoForm.coalContactHair : 0)
                    let yy = BigNumber(this.originInfoForm.coalContactSkin ? this.originInfoForm.coalContactSkin : 0)
                    return xx.minus(yy).toNumber() > 0 ? xx.minus(yy).toNumber().toFixed(2) : 0
                }else{
                    //数量
                    if(!this.coalData.tmTaskCoalList.length){
                        return false
                    }else{
                        const reslut = this.coalData.tmTaskCoalList.find(item=>!item.productQuantity);
                        console.log(reslut);
                        if(reslut){
                            return false
                        }else{
                            return true
                        }
                    }
                }
            
            },
            
        },
        onLoad(params) {
            this.orderPlanId = params.orderPlanId || ''
            this.sendDate = params.sendDate || ''
            this.deptId = params.deptId || ''
            this.filedId = params.filedId || ''
            this.isSpecial = Number(params.isSpecial);
            this.isWeight = Number(params.isWeight)
            console.log(params.isSpecial, typeof params.isSpecial,params,'paramssssss');
            this.getTakeCoal()
        },
        methods: {
            getTakeCoal() {
                uni.showLoading({
                    title: '加载中'
                });
                this.$reqGet('getTakeCoal', { takeCoalId: this.orderPlanId }).then(res => {
                    uni.hideLoading();
                    if (res.code == 0) {
                        this.coalData = res.data
                    } else {
                        this.$u.toast('加载失败');
                    }
                })
            },
            // input聚焦
            inputFocus(v) {
                if (v == 1) {
                    this.isfocus1 = true;
                } else {
                    this.isfocus2 = true;
                }
            },
            // input失焦
            inputBlur() {
                this.isfocus1 = false;
                this.isfocus2 = false;
            },
            inputChange() {
                if (Number(this.originInfoForm.coalContactHair) > 0 && Number(this.originInfoForm.coalContactSkin >
                        0)) {
                    this.isInputOrigin = true;
                }
            },
            deletePic(event) {
                this.changeisUploadimg(true);
                this[`fileList${event.name}`].splice(event.index, 1);
            },
            async afterRead(event) {
                // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
                let lists = [].concat(event.file);
                let fileListLen = this[`fileList${event.name}`].length;
                lists.map(item => {
                    this[`fileList${event.name}`].push({
                        ...item,
                        status: 'uploading',
                        message: '上传中'
                    });
                });
                for (let i = 0; i < lists.length; i++) {
                    const result = await this.uploadFilePromise(lists[i].url, event.name);
                    let item = this[`fileList${event.name}`][fileListLen];
                    this[`fileList${event.name}`].splice(
                        fileListLen,
                        1,
                        Object.assign(item, {
                            status: 'success',
                            message: '上传成功',
                            url: result
                        })
                    );
                    fileListLen++;
                }
            },
            uploadFilePromise(url, num) {
                return new Promise((resolve, reject) => {
                    let a = uni.uploadFile({
                        url: BaseUrl + '/admin/sys-file/uploadUnToken',
                        filePath: url,
                        name: 'file',
                        success: res => {
                            if (num == 1) {
                                this.originInfoForm.contactPicture = JSON.parse(res.data)
                                    .data.url;
                                resolve(`${BaseUrl}${JSON.parse(res.data).data.url}`);
                            }
                        }
                    });
                });
            },
            directAppointment() {
                uni.navigateTo({
                    url: `/pages/driver-page/appointment/appointment?takeCoalId=${this.orderPlanId}&filedId=${this.filedId}&deptId=${this.deptId}&sendDate=${this.sendDate}`
                });
            },
            submitOriginInfo() {
                let form = {
                    skin: Number(this.originInfoForm.coalContactSkin),
                    hair: Number(this.originInfoForm.coalContactHair),
                    clean: Number(this.coalContactClean),
                    tmId: this.coalData.tmId,
                    contactPicture: this.originInfoForm.contactPicture,
                    deptId: this.coalData.deptId,
                    filedId: this.coalData.filedId,
                    coalName: this.coalData.coalName,
                    taskCoalCode: this.coalData.code,
                    carNo: this.coalData.carNo,
                }
                //称重 
                if(this.isWeight){
                    if (this.originInfoForm.coalContactSkin && this.originInfoForm.coalContactHair && this
                    .originInfoForm
                    .contactPicture) {
                        //原发净重限制
                        if(this.coalContactClean && this.coalContactClean > 200){
                            this.$u.toast('当前净重超过正常值,请检查皮毛重')
                            return
                            
                        }else{
                            this.submitOriginInfoLoading = true
                    this.$reqPost('appSaveContact', form, 'json').then(res => {
                        if (res.code === 0) {
                            this.$u.toast('提交成功')
                            this.submitOriginInfoLoading = false
                            setTimeout(() => {
                                uni.navigateTo({
                                    url: `/pages/driver-page/appointment/appointment?takeCoalId=${this.orderPlanId}&filedId=${this.filedId}&deptId=${this.deptId}&sendDate=${this.sendDate}`
                                });
                            }, 1500)
                        } else {
                            this.submitOriginInfoLoading = false
                            this.$u.toast(res.msg ? res.msg : '提交失败')
                        }
                    })
                        }
                
                } else {
                    uni.$u.toast('请填写完整原发信息')
                }
                }else{
                    //数量
                    form.numDtoList = this.coalData.tmTaskCoalList.map(item=>{
                        let obj  = {
                            tmId:item.id,
                            num:Number(item.productQuantity) 
                        }
                        return obj;
                    });
                    //删除皮毛净
                    delete form.clean;
                    delete form.hair;
                    delete form.skin;
                    if (this.coalContactClean && this
                    .originInfoForm
                    .contactPicture) {
                    this.submitOriginInfoLoading = true;
                    console.log(form,'form')
                    this.$reqPost('appSaveContact', form, 'json').then(res => {
                        if (res.code === 0) {
                            this.$u.toast('提交成功')
                            this.submitOriginInfoLoading = false
                            setTimeout(() => {
                                uni.navigateTo({
                                    url: `/pages/driver-page/appointment/appointment?takeCoalId=${this.orderPlanId}&filedId=${this.filedId}&deptId=${this.deptId}&sendDate=${this.sendDate}`
                                });
                            }, 1500)
                        } else {
                            this.submitOriginInfoLoading = false
                            this.$u.toast(res.msg ? res.msg : '提交失败')
                        }
                    })
                } else {
                    uni.$u.toast('请填写完整原发信息')
                }
                }
                
            }
        }
    }
</script>
 
<style lang="scss"
    scoped>
    .table-div{
   /deep/ .uni-table{
    width: 95%;
    min-width: 0!important;
    margin-left: 20rpx;
  }
        
    }
    /deep/.u-button {
        font-size: 28rpx;
        font-weight: 300;
        color: #ffffff !important;
        background: #497bfb !important;
        letter-spacing: 4rpx;
        border-radius: 37rpx 37rpx 37rpx 37rpx !important;
        box-shadow: 2rpx 3rpx 13rpx 0rpx rgba(43, 98, 239, 0.5), 0rpx 0rpx 9rpx 0rpx rgba(247, 250, 253, 0.29);
    }
 
    @mixin flex {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
 
    .origin-info {
        width: 690rpx;
        height: 100%;
        margin: vww(20) vww(15) vww(13);
        background: #ffffff;
        box-shadow: 0rpx 0rpx 14rpx 0rpx rgba(73, 120, 240, 0.14), 0rpx 7rpx 45rpx 0rpx rgba(73, 120, 240, 0.12);
        border-radius: 20rpx;
        @include flex;
        justify-content: center;
        overflow: hidden;
        position: relative;
        top: vww(120);
 
        &_wrapper {
            width: 650rpx;
            height: 100%;
            @include flex;
            flex-direction: column;
            margin-bottom: vww(20);
            position: relative;
 
            .origin-info_content {
                width: 100%;
                height: 100%;
                // overflow-y: scroll;
 
                .first-line,
                .second-line {
                    width: 90%;
                    height: vww(44);
 
                    .focusClass {
                        color: #5b95fd;
                    }
 
                    .inputClass {
                        border: 1px solid rgba(73, 95, 252, 0.6) !important;
                        box-shadow: 0rpx 5rpx 13rpx 0rpx rgba(73, 95, 252, 0.6) !important;
                        border-radius: 12rpx !important;
                    }
 
                    .isInputOrigin {
                        background-color: #f4f4fc;
                    }
 
                    .input-container {
                        border: 2px solid #c5c5c5;
                        box-shadow: 0rpx 5rpx 13rpx 0rpx #c5c5c5;
                        border-radius: 12rpx;
                    }
                }
 
                .first-line {
                    @include flex;
                    position: relative;
                    top: vww(8);
                }
 
                .second-line {
                    @include flex;
                }
 
                .submit-button {
                    width: 450rpx;
                    margin: vww(8) auto;
                    @include flex;
 
                    .u-button {
                        width: 45%;
                        font-size: 28rpx;
                        font-weight: 300;
                        color: #ffffff;
                        background: #497bfb;
                        letter-spacing: 4rpx;
                        border-radius: 37rpx 37rpx 37rpx 37rpx;
                        box-shadow: 2rpx 3rpx 13rpx 0rpx rgba(43, 98, 239, 0.5), 0rpx 0rpx 9rpx 0rpx rgba(247, 250, 253, 0.29);
                    }
                }
            }
        }
    }
</style>