upload-receipt.vue
2.24 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
<template>
<Page name="upload-receipt" flank>
<template #content>
<u-form :model="form" ref="uForm" labelWidth="100">
<view class="card">
<u-form-item :label="opType[type].title">
<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>
</Page>
</template>
<script>
import ZUpload from '../../components/zee/z-upload.vue';
import dayjs from 'dayjs';
export default {
name: 'upload-receipt',
components: { ZUpload },
data() {
return {
type: 'receiptAttachment',
form: {
receiptAttachment: '',
},
item: {},
opType: {
receiptAttachment: {
title: '上传回单',
url: 'modifyReceiptAttachment',
},
departureWeightAttachment: {
title: '装车磅单',
url: 'modifyDepartureWeightAttachment',
},
arrivalWeightAttachment: {
title: '卸车磅单',
url: 'modifyArrivalWeightAttachment',
},
},
};
},
onLoad(options) {
if (options.type) {
this.type = options.type;
}
if (options.code) {
this.initData(options.code);
}
},
methods: {
initData(code) {
uni.$u.api.freightOrder.getDetail({ code }).then(res => {
this.item = res.result || {};
this.form.receiptAttachment = this.item[this.type];
});
},
submit() {
uni.$u.api.freightOrder[this.type]({ code: this.item.code, [this.type]: this.form.receiptAttachment }).then(res => {
if (res.success) {
uni.showToast({ title: '操作成功', icon: 'none' });
this.getOpenerEventChannel().emit('refreshData');
setTimeout(() => uni.navigateBack(), 500);
}
});
},
},
};
</script>
<style lang="scss">
.page-upload-receipt {
&__footer {
background: $color-white;
}
.card {
color: #999999;
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>