DeliverGoods.vue
3.6 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<template>
<el-drawer
:title="title"
:visible.sync="visible"
:size="drawerSize"
direction="rtl"
class="drawer-form"
@close="closeDrawer"
>
<el-form :model="form" ref="form" label-width="120px">
<!-- 基本信息 -->
<div v-for="(section, index) in infoSections" :key="index" class="form-section">
<h3 class="section-title">{{ section.title }}</h3>
<el-row :gutter="20">
<el-col v-for="(item, index) in section.items" :key="index" :span="12">
<div class="info-field">
<span class="label">{{ item.label }}:</span>
<span class="value" :title="item.value">{{ item.value }}</span>
</div>
</el-col>
</el-row>
</div>
<!-- 快递信息 -->
<div class="form-section">
<h3 class="section-title">快递信息</h3>
<el-form-item label="物流公司" prop="logisticsCompany" :rules="[{ required: true, message: '物流公司不能为空', trigger: 'blur' }]">
<el-input v-model="form.logisticsCompany" maxlength="50" show-word-limit></el-input>
</el-form-item>
<el-form-item label="物流单号" prop="logisticsOrderNo" :rules="[{ required: true, message: '物流单号不能为空', trigger: 'blur' }]">
<el-input v-model="form.logisticsOrderNo" maxlength="50" show-word-limit></el-input>
</el-form-item>
</div>
</el-form>
<!-- 底部按钮 -->
<div class="drawer-footer">
<el-button size="small" @click="closeDrawer">取消</el-button>
<el-button size="small" type="primary" @click="submitForm">发货</el-button>
</div>
</el-drawer>
</template>
<script>
export default {
props: {
title: {
type: String,
default: '详细信息'
},
visible: {
type: Boolean,
required: true
},
drawerSize: {
type: String,
default: '50%'
},
goodsObj:{
type: Object,
default: () => {}
},
infoSections: Array // 传入的数据结构数组
},
data() {
return {
form: {
logisticsCompany: '',
logisticsOrderNo: '',
}
};
},
methods: {
closeDrawer() {
this.$emit('update:visible', false);
this.form = {
logisticsCompany: '',
logisticsOrderNo: ''
}
},
validateForm() {
return new Promise((resolve, reject) => {
this.$refs.form.validate((valid) => {
if (valid) {
resolve();
} else {
reject(new Error('请填写完整的快递信息'));
}
});
});
},
submitForm() {
this.validateForm().then(() => {
this.$emit('submit', {...this.form,...this.goodsObj});
this.closeDrawer();
}).catch(error => {
this.$message.error(error.message);
});
}
}
};
</script>
<style lang="scss" scoped>
.drawer-form {
/deep/.el-drawer__body{
padding: 16px;
}
.form-section {
margin-bottom: 20px;
.section-title {
margin-bottom: 10px;
color: #333;
font-size: 16px;
font-weight: bold;
}
.info-field {
margin-bottom: 10px;
line-height: 16px;
font-size: 14px;
padding: 10px 40px;
border-radius: 4px;
display: flex;
.label {
color: #666666;
}
.value {
width: 170px;
white-space: nowrap; /* 防止内容换行 */
overflow: hidden;
text-overflow: ellipsis;
}
}
}
.drawer-footer {
position: fixed;
bottom: 8px;
right: 8px;
.el-button {
margin-left: 8px;
}
}
}
</style>