arrival-car.vue
4.18 KB
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
<template>
<Page name="start-car">
<template #content>
<view class="address">
<view class="icon-waypoint icon-end">卸</view>
<text>{{ item.waypoints[1].address }}</text>
</view>
<u-form :model="form" ref="uForm" labelWidth="100">
<view class="card">
<u-form-item label="实际发车时间" required @click="(timeType = 'departTime'), (showLoadTime = true)">
<u-input v-model="form.departTime" border="none" suffix-icon="arrow-right" placeholder="请选择时间" disabledColor="#ffffff" disabled />
</u-form-item>
</view>
<view class="card">
<u-form-item label="实际到达时间" required @click="(timeType = 'arrivalTime'), (showLoadTime = true)">
<u-input v-model="form.arrivalTime" border="none" suffix-icon="arrow-right" placeholder="请选择时间" disabledColor="#ffffff" disabled />
</u-form-item>
</view>
<view class="card">
<u-form-item label="上传回单">
<z-upload v-model="form.receiptAttachment" :limit="20"></z-upload>
</u-form-item>
</view>
</u-form>
</template>
<template #footer>
<u-button type="primary" @tap="submit">确认到达</u-button>
</template>
<u-datetime-picker :show="showLoadTime" :value="loadTimeDef" @cancel="showLoadTime = false" @close="showLoadTime = false" @confirm="loadTimeFormat"></u-datetime-picker>
</Page>
</template>
<script>
import ZUpload from '../../components/zee/z-upload.vue';
import dayjs from 'dayjs';
export default {
name: 'arrivalCar',
components: { ZUpload },
data() {
return {
timeType: '',
showLoadTime: false,
loadTimeDef: new Date(),
form: {
departTime: '',
arrivalTime: '',
receiptAttachment: '',
},
item: {},
};
},
onLoad(options) {
if (options.code) {
this.initData(options.code);
}
},
methods: {
initData(code) {
uni.$u.api.freightOrder.getDetail({ code }).then(res => {
this.item = res.result || {};
this.form = {
departTime: this.item.confirmDepartureTime,
arrivalTime: this.item.confirmArrivalTime,
receiptAttachment: this.item.receiptAttachment,
};
});
},
loadTimeFormat({ value }) {
this.form[this.timeType] = dayjs(value).format('YYYY-MM-DD HH:mm:ss');
this.showLoadTime = false;
},
submit() {
if (!this.form.departTime || !this.form.departTime) {
uni.showToast({ title: '发车时间和到达时间不能为空', icon: 'none' });
return;
}
if (new Date(this.form.departTime).getTime() > new Date().getTime()) {
uni.showToast({ title: '发车时间不能大于当前时间', icon: 'none' });
return;
}
if (new Date(this.form.arrivalTime).getTime() > new Date().getTime()) {
uni.showToast({ title: '到达时间不能大于当前时间', icon: 'none' });
return;
}
if (new Date(this.form.departTime).getTime() > new Date(this.form.arrivalTime).getTime()) {
uni.showToast({ title: '到达时间不能小于发车时间', icon: 'none' });
return;
}
uni.$u.api.freightOrder.arrive({ codeList: [this.item.code], ...this.form }).then(res => {
if (res.success) {
uni.showToast({ title: '操作成功', icon: 'none' });
this.getOpenerEventChannel().emit('refreshData');
setTimeout(() => uni.navigateBack(), 500);
}
});
},
},
};
</script>
<style lang="scss">
.page-start-car {
&__content {
padding-top: 0 !important;
}
&__footer {
background: $color-white;
}
.address {
background-color: $color-white;
padding: $padding-md;
.icon-waypoint {
font-size: $font-sm;
margin-right: $padding-sm;
height: $padding-md * 1.2;
width: $padding-md * 1.2;
min-width: $padding-md * 1.2;
}
}
.card {
color: #999999;
margin: $padding-md;
background-color: $color-white;
border-radius: $radius-md;
box-shadow: $shadow-normal;
.u-form-item {
padding-left: $padding-md !important;
padding-right: $padding-sm !important;
}
}
}
</style>