approveComp.vue
5.47 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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<template>
<h-dialog ref="myDialog" :title="title" :isVisible="isVisible" @confirm="handleSubmit" @cancel="handleCancel">
<div class="formObj">
<div class="cell" @click="handleSelect" v-if="['2', '5', '6'].includes(staffType)">
<div class="label">
发货主体
<span class="require">*</span>
</div>
<van-cell is-link :value="approveForm.sendOutMerchantName" />
</div>
<div class="line-feed">
<div class="label">备注</div>
<van-field class="textarea" v-model="approveForm.remark" rows="8" :autosize="{ maxHeight: 220 }" label="" type="textarea" maxlength="200" placeholder="请输入备注" show-word-limit />
</div>
<div class="explain" v-if="staffType == 2">说明:订单审核后自动流转至下一节点进行复审。</div>
<div class="explain" v-if="staffType == 6">说明:订单审核后自动流转至下一节点进行复审。</div>
<div class="explain" v-if="staffType == 3">说明:订单审核后会自动流转至供应商进行确认并发货。</div>
<div class="explain" v-if="staffType == 5">说明:订单审核后自动流转至商务进行复审。</div>
</div>
<send-out-comp :isVisible="sendOutVisible" v-if="sendOutVisible" @cancel="handleSendCancel" @submit="handleSendSumit" :sendOutMerchantId="approveForm.sendOutMerchantId"></send-out-comp>
</h-dialog>
</template>
<script>
import { Toast } from 'vant'
import hDialog from './dialog'
import sendOutComp from './sendOutComp'
import purchaseApi from '@/api/purchase'
export default {
components: { hDialog, sendOutComp },
data() {
return {
isSubmit: false,
name: this.$route.query.name,
staffType: this.$route.query.staffType,
sendOutVisible: false,
title: '通过',
approveForm: {
remark: '',
sendOutMerchantId: '',
sendOutMerchantName: ''
}
}
},
props: {
isVisible: {
type: Boolean,
default: false
},
infoData: {
type: Object,
default: () => ({})
}
},
watch: {
infoData: {
handler(val) {
this.initData(val)
},
immediate: true,
deep: true
}
},
methods: {
handleSendCancel() {
this.sendOutVisible = false
},
handleSendSumit(data) {
this.approveForm.sendOutMerchantName = data.shippingEntity
this.approveForm.sendOutMerchantId = data.shippingEntityId
this.handleSendCancel()
},
initData(val) {
this.approveForm.sendOutMerchantName = val.sendOutMerchantName ? val.sendOutMerchantName : ''
this.approveForm.sendOutMerchantId = val.sendOutMerchantId
},
handleSelect() {
console.log('handleSelect')
// this.$emit('handleSelect')
this.sendOutVisible = true
},
validateRequiredFields() {
let validators = {
sendOutMerchantId: () => {
Toast('请选择发货主体')
}
}
for (let key in validators) {
if (!this.approveForm[key]) {
validators[key]()
return false
}
}
return true
},
getMethodByStaffType() {
const methodMap = {
2: 'operatorAudit',
3: 'businessAudit',
5: 'directorAudit',
6: 'managerAudit'
}
return methodMap[this.staffType]
},
async handleSubmit() {
const isValid = this.validateRequiredFields()
if (!isValid) return
const methodName = this.getMethodByStaffType()
if (!methodName) {
Toast('当前角色不支持此操作')
return
}
try {
this.isSubmit = true
this.$refs.myDialog.startLoading()
const params = {
orderCode: this.infoData.orderCode,
operatorName: this.name,
...this.approveForm
}
//运营审核有该字段,商户审核没有2-运营审核 3-商务审核
if (this.staffType == 3) {
delete params.sendOutMerchantName
delete params.sendOutMerchantId
}
const result = await purchaseApi[methodName](params)
if (result.code == 0) {
Toast.success('操作成功')
this.isSubmit = false
this.$refs.myDialog.stopLoading()
this.handleCancel()
this.$emit('success')
} else {
this.$refs.myDialog.stopLoading()
Toast.fail(result.message || '请求失败')
}
} catch (error) {
this.isSubmit = false
this.$refs.myDialog.stopLoading()
Toast.fail('系统异常,请稍后再试')
console.error(error)
}
},
handleCancel() {
this.$emit('cancel')
}
}
}
</script>
<style lang="scss" scoped>
.formObj {
margin: 0 12px;
font-size: 14px;
.cell {
display: flex;
align-items: center;
height: 52px;
border-bottom: 1px solid #eff0f2;
}
.label {
color: #333333;
font-size: 14px;
margin-right: 18px;
display: flex;
align-items: center;
white-space: nowrap;
line-height: 20px;
.require {
color: #f24724;
font-size: 14px;
margin-left: 4px;
line-height: 52px;
margin-top: 5px;
}
}
.line-feed {
.label {
line-height: 52px;
}
.textarea {
border-radius: 8px;
border: 1px solid #eff0f2;
// height: 220px;
}
}
.explain {
color: #999999;
font-size: 14px;
margin-top: 10px;
}
::v-deep .van-cell__value--alone {
text-align: right;
color: #333333;
font-size: 14px;
width: 300px;
}
}
</style>