rejectComp.vue
4.81 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
<template>
<h-dialog ref="myDialog" :title="title" :isVisible="isVisible" @confirm="handleSubmit" @cancel="handleCancel">
<div class="formObj">
<div class="cell">
<div class="label">
驳回节点
<span class="require">*</span>
</div>
<van-radio-group v-model="rejectForm.rejectNode" direction="horizontal">
<van-radio v-for="item in dynamicNodeList" :key="item.value" :name="item.value" icon-size="16px">
{{ item.label }}
</van-radio>
</van-radio-group>
</div>
<div class="line-feed">
<div class="label">
驳回原因
<span class="require">*</span>
</div>
<van-field class="textarea" v-model="rejectForm.rejectCause" rows="8" :autosize="{ maxHeight: 220 }" label="" type="textarea" maxlength="200" placeholder="请输入驳回原因" show-word-limit />
</div>
<!-- <div class="explain" v-if="staffType == 4">说明:驳回后,整个采购订单进行驳回,无法再重新进行发货操作。</div> -->
</div>
</h-dialog>
</template>
<script>
import hDialog from './dialog'
import { Toast } from 'vant'
import allocateApi from '@/api/allocate'
export default {
components: { hDialog },
data() {
return {
name: this.$route.query.name,
staffType: this.$route.query.staffType, //(2-运营审核 3-商务审核 4-采购发货审核)
title: '驳回',
rejectForm: {
rejectNode: '',
rejectCause: ''
}
}
},
props: {
isVisible: {
type: Boolean,
default: false
},
infoData: {
type: Object,
default: () => ({})
}
},
computed: {
/**
* 根据 staffType 动态生成驳回节点列表
*/
dynamicNodeList() {
const baseOptions = [
{ label: '调拨商户', value: '1' },
{ label: '运营审核', value: '2' },
{ label: '商务审核', value: '3' }
]
switch (this.staffType) {
case '2': // 运营审核
return [baseOptions[0]] // 只返回采购审核
case '3': // 商务审核
return baseOptions.slice(0, 2) // 返回采购审核、运营审核
case '4': // 调拨发货审核
return baseOptions // 返回全部
default:
return [] // 默认无选项
}
}
},
methods: {
validateRequiredFields() {
let validators = {
rejectNode: () => {
Toast('请选择驳回节点')
},
rejectCause: () => {
Toast('请输入驳回原因')
}
}
for (let key in validators) {
if (!this.rejectForm[key]) {
validators[key]()
return false
}
}
return true
},
getRejectMethodByStaffType() {
const methodMap = {
2: 'operatorReject',
3: 'businessReject',
4: 'allocateDeliveryReject'
}
return methodMap[this.staffType]
},
async handleSubmit() {
const isValid = this.validateRequiredFields()
if (!isValid) return
const methodName = this.getRejectMethodByStaffType()
if (!methodName) {
Toast('当前角色不支持此操作')
return
}
try {
this.$refs.myDialog.startLoading()
const params = {
allocateCode: this.infoData.allocateCode,
updatedBy: this.name,
userName:this.name,
...this.rejectForm
}
const result = await allocateApi[methodName](params)
if (result.code == 0) {
Toast.success('操作成功')
this.$refs.myDialog.stopLoading()
this.handleCancel()
this.$emit('success')
} else {
this.$refs.myDialog.stopLoading()
Toast.fail(result.message || '请求失败')
}
} catch (error) {
this.$refs.myDialog.stopLoading()
Toast.fail('系统异常,请稍后再试')
console.error(error)
}
// this.$refs.myDialog.stopLoading();
},
handleCancel() {
this.$emit('cancel')
// this.isVisible = false
}
}
}
</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;
}
}
</style>