change-goods.vue
3.44 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
<template>
<Page name="change-goods" flank>
<template #content>
<u-form :model="form" ref="uForm" labelWidth="100">
<view class="card">
<u-form-item label="货物名称" required @click="choseGoodsName">
<u-input v-model="form.goodsName" border="none" suffix-icon="arrow-right" placeholder="请选择" disabledColor="#ffffff" disabled />
</u-form-item>
<u-form-item v-if="showGoodsValue" label="货物价值" required>
<u-input v-model="form.goodsValue" border="none" type="number" placeholder="请输入" />
</u-form-item>
<u-form-item label="货物件数">
<u-input v-model="form.goodsPiece" border="none" type="number" placeholder="请输入,选填" />
</u-form-item>
<u-form-item label="货物吨数" required>
<u-input v-model="form.goodsWeight" border="none" type="number" placeholder="请输入" />
</u-form-item>
<u-form-item label="货物方数">
<u-input v-model="form.goodsVolume" border="none" type="number" placeholder="请输入,选填" />
</u-form-item>
</view>
</u-form>
</template>
<template #footer>
<u-button type="primary" @tap="submit">确认修改</u-button>
</template>
</Page>
</template>
<script>
import { urlParam } from '@/utils/param';
export default {
name: 'change-goods',
data() {
return {
form: {
goodsName: '',
goodsValue: '',
goodsPiece: '',
goodsWeight: '',
goodsVolume: '',
},
item: {},
currentFreight: {},
};
},
onLoad(options) {
if (options.code) {
this.initData(options.code);
}
},
computed: {
showGoodsValue() {
return this.currentFreight ? this.currentFreight.driverSecurityServiceFlag || this.currentFreight.securityServiceFlag : false;
},
},
methods: {
initData(code) {
uni.$u.api.freightOrder.currentFreight({}).then(en => {
this.currentFreight = en?.result || {};
});
uni.$u.api.freightOrder.getDetail({ code }).then(res => {
this.item = res.result || {};
this.form = {
goodsName: this.item.goodsName,
goodsValue: this.item.goodsValue,
goodsPiece: this.item.goodsPiece,
goodsWeight: this.item.goodsWeight,
goodsVolume: this.item.goodsVolume,
};
});
},
choseGoodsName() {
uni.$once('select-common', option => {
this.form.goodsName = option.name;
});
uni.navigateTo({
url: `/pages/global/search-common${urlParam({
mode: 'select',
url: 'goodsName',
title: '货物名称',
label: 'name',
value: '',
})}`,
});
},
submit() {
uni.$u.api.freightOrder.modifyGoods({ code: 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-change-goods {
&__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>