SendFormDialog.vue
4.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
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<template>
<el-dialog title="寄送信息" class="dialog_scroll" :visible="visible" @open="openDialog" @close="closeDialog" :close-on-click-modal="false">
<el-form ref="form" :model="form" :rules="rules" label-width="140px">
<el-form-item label="收件人及联系方式">
<el-input type="textarea" v-model="receiverInfo" rows="1" disabled/>
</el-form-item>
<el-form-item label="快递公司" prop="logisticsId">
<el-select placeholder="请选择快递公司" v-model="form.logisticsId">
<el-option
v-for="(item, i) in logisticsOptions"
:key="i"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="快递单号" prop="expressSn">
<el-input v-model.trim="form.expressSn" placeholder="请输入快递单号" maxlength="50"/>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input type="textarea" v-model.trim="form.remark" placeholder="请输入备注" maxlength="200"/>
</el-form-item>
<el-form-item class="image-idcode-man-box is-required" label="上传附件:" prop="pictures">
<UploadImg
ref="UploadImg"
:maxNum="1"
@update="updateImgList"
/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="closeDialog">取 消</el-button>
<el-button type="primary" @click="confirm" :loading="submitting">确 定</el-button>
</div>
</el-dialog>
</template>
<script>
import UploadImg from '@/components/UploadImg'
import {
getBussinessApi,
getLogisticsCompanyName,
} from '@/api/system'
export default {
props: ['visible', 'id', 'receiverInfo'],
components: {
UploadImg,
},
data() {
let checkImg = (rule, vaule, cb)=>{
if(!this.imgList.length){
cb(new Error('请上传附件'))
}
cb()
}
return {
submitting: false,
logisticsOptions: [],
form: {
logisticsId: '',
expressSn: '',
remark: ''
},
imgList: [],
rules: {
logisticsId: [
{ required: true, message: '请选择快递公司', trigger: 'change', }
],
expressSn: [
{ required: true, message: '请输入快递单号', trigger: 'blur', },
{ pattern: /^[a-zA-Z0-9]{1,30}$/, message: '30位,英文数字', trigger: 'blur' }
],
remark: [
{ required: false, trigger: 'blur', validator: this.$Common.checkRegExpName }
],
pictures: [{validator: checkImg}]
},
}
},
watch: {
},
mounted() {
this.getLogistics()
},
methods: {
getParams(){
let params = {}
let form = this.form
for(let key in form){
form[key] && (params[key] = form[key])
}
if(this.imgList.length){
params.deliveryFileList = [{
filePath: this.imgList[0]
}]
}
return params
},
confirm(){
this.$refs.form.validate((valid) => {
if (valid) {
let params = this.getParams()
params.id = this.id
this.submitting = true
this.$store.dispatch('SetIsJson', true)
getBussinessApi(params, 'sendLogistics', 'post')
.then(res => {
if(res){
this.$message({
type: 'success',
message: `操作成功!`
});
this.$emit('close')
this.$emit('update')
}
this.submitting = false
})
.catch(()=>{
this.submitting = false
})
setTimeout(() => {
this.$store.dispatch('SetIsJson', false)
}, 3000)
} else {
return false;
}
});
},
closeDialog(){
this.$refs.form.resetFields()
this.imgList = []
this.$refs.UploadImg.reset()
this.$emit('close')
},
openDialog(){
},
updateImgList(list){
this.imgList = list
console.log(this.imgList)
},
getLogistics(){
getLogisticsCompanyName()
.then(response => {
if(response.code == 200){
let items = response.data;
let arr = [];
items.forEach( (item,index) =>{
arr.push(
{ label: item.expressCompany, value: item.id },
)
})
this.logisticsOptions = arr
}
})
.catch(error => {
});
},
}
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.el-cascader--medium{
width: 100%;
}
.el-select{
width: 100%;
}
</style>