modal-deliver.vue
3.21 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
<template>
<Modal
v-model="showModal"
width="500">
<div class="deliver-modal">
<div class="deliver-info">
<Row class-name="info-row">
<Col span="4" class-name="info-col">收货仓库:</Col>
<Col span="20">{{storeInfo.storeName}}</Col>
</Row>
<Row class-name="info-row">
<Col span="4">物流公司:</Col>
<Col span="20">
<Select v-model="expressId">
<Option v-for="item in expresses"
:value="item.id"
:key="item.id">
{{ item.companyName }}
</Option>
</Select>
</Col>
</Row>
<Row class-name="info-row">
<Col span="4">物流单号:</Col>
<Col span="20">
<Input v-model="expressNumber" placeholder="请填写发货商品对应的唯一物流单号"></Input>
</Col>
</Row>
<p class="info-tip">
发往:{{storeInfo.storeName}}{{storeInfo.address}}{{storeInfo.adminName}}{{storeInfo.phone}}
</p>
</div>
</div>
<div slot="footer">
<Button type="text" size="large" @click="hide">取消</Button>
<Button type="primary" size="large" :loading="showLoading" @click="deliver">提交</Button>
</div>
</Modal>
</template>
<script>
export default {
name: 'modal-deliver',
props: {
expresses: {
type: Array,
default() {
return [];
}
},
storeInfo: {
type: Object,
default() {
return {};
}
}
},
data() {
return {
showModal: false,
showLoading: false,
expressId: '',
expressNumber: '',
};
},
methods: {
show() {
this.showModal = true;
this.expressId = '';
this.expressNumber = '';
},
hide() {
this.showLoading = false;
this.showModal = false;
},
deliver() {
if (!this.expressId) {
this.$Message.error('请选择物流公司');
return;
}
if (!this.expressNumber) {
this.$Message.error('请填写物流单号');
return;
}
if (!/^[a-zA-Z\d]{6,20}$/.test(this.expressNumber)) {
this.$Message.error('物流单号不符合规则');
return;
}
this.showLoading = true;
this.$emit('deliver', {expressId: this.expressId, expressNumber: this.expressNumber});
}
}
};
</script>
<style lang="scss">
.deliver-modal {
padding: 30px;
.info-row {
line-height: 40px;
}
.info-tip {
margin-top: 20px;
color: #f00;
text-align: center;
}
.ivu-modal {
width: 50%;
}
}
</style>