|
|
@@ -93,12 +93,24 @@ import { submitAftersale } from '@/api/orderAftersale'
|
|
93
|
93
|
import { mapOrderDetail } from '@/utils/orderDisplay'
|
|
94
|
94
|
import { ensureApiToken } from '@/utils/apiAuth'
|
|
95
|
95
|
import {
|
|
|
96
|
+ ORDER_STATUS,
|
|
96
|
97
|
AFTERSALE_APPLY_TYPE,
|
|
97
|
98
|
AFTERSALE_APPLY_TYPE_OPTIONS,
|
|
98
|
99
|
AFTERSALE_REASON_MAP,
|
|
99
|
100
|
AFTERSALE_DESC_MAX,
|
|
100
|
101
|
AFTERSALE_EVIDENCE_MAX
|
|
101
|
102
|
} from '@/constants/order'
|
|
|
103
|
+
|
|
|
104
|
+/** 订单状态 → 售后申请类型(与后端 OrderConstants 一致) */
|
|
|
105
|
+const APPLY_TYPE_BY_ORDER_STATUS = {
|
|
|
106
|
+ [ORDER_STATUS.PENDING_SHIP]: AFTERSALE_APPLY_TYPE.REFUND_UNSHIPPED,
|
|
|
107
|
+ [ORDER_STATUS.SHIPPED]: AFTERSALE_APPLY_TYPE.REFUND_SHIPPED,
|
|
|
108
|
+ [ORDER_STATUS.COMPLETED]: AFTERSALE_APPLY_TYPE.RETURN_REFUND
|
|
|
109
|
+}
|
|
|
110
|
+
|
|
|
111
|
+function resolveApplyTypeByOrderStatus(orderStatus) {
|
|
|
112
|
+ return APPLY_TYPE_BY_ORDER_STATUS[String(orderStatus)] || ''
|
|
|
113
|
+}
|
|
102
|
114
|
import { goAftersaleDetail } from '@/utils/orderNav'
|
|
103
|
115
|
import OrderGoodsRow from '@/components/order/OrderGoodsRow.vue'
|
|
104
|
116
|
import { useActionGuard } from '@/utils/actionGuard'
|
|
|
@@ -107,20 +119,26 @@ import ImageUploadGrid from '@/components/order/ImageUploadGrid.vue'
|
|
107
|
119
|
const submitGuard = useActionGuard()
|
|
108
|
120
|
|
|
109
|
121
|
const orderId = ref('')
|
|
|
122
|
+const orderStatus = ref('')
|
|
110
|
123
|
/** 整单商品行 */
|
|
111
|
124
|
const orderItems = ref([])
|
|
112
|
125
|
const payAmount = ref(0)
|
|
113
|
126
|
const pageLoading = ref(true)
|
|
114
|
127
|
const submitting = submitGuard.locked
|
|
115
|
128
|
|
|
116
|
|
-const applyType = ref(AFTERSALE_APPLY_TYPE.REFUND_UNSHIPPED)
|
|
|
129
|
+const applyType = ref('')
|
|
117
|
130
|
const applyReason = ref('')
|
|
118
|
131
|
const returnQuantity = ref(1)
|
|
119
|
132
|
const applyAmountInput = ref('')
|
|
120
|
133
|
const description = ref('')
|
|
121
|
134
|
const evidencePics = ref([])
|
|
122
|
135
|
|
|
123
|
|
-const applyTypeOptions = AFTERSALE_APPLY_TYPE_OPTIONS
|
|
|
136
|
+/** 按订单状态只展示对应的一种申请类型 */
|
|
|
137
|
+const applyTypeOptions = computed(() => {
|
|
|
138
|
+ const type = resolveApplyTypeByOrderStatus(orderStatus.value)
|
|
|
139
|
+ if (!type) return []
|
|
|
140
|
+ return AFTERSALE_APPLY_TYPE_OPTIONS.filter((opt) => opt.value === type)
|
|
|
141
|
+})
|
|
124
|
142
|
const descMax = AFTERSALE_DESC_MAX
|
|
125
|
143
|
const evidenceMax = AFTERSALE_EVIDENCE_MAX
|
|
126
|
144
|
|
|
|
@@ -156,6 +174,13 @@ async function loadOrder() {
|
|
156
|
174
|
if (!items.length) {
|
|
157
|
175
|
throw new Error('订单商品不存在')
|
|
158
|
176
|
}
|
|
|
177
|
+ const type = resolveApplyTypeByOrderStatus(mapped.orderStatus)
|
|
|
178
|
+ if (!type) {
|
|
|
179
|
+ throw new Error('当前订单状态不可申请售后')
|
|
|
180
|
+ }
|
|
|
181
|
+ orderStatus.value = mapped.orderStatus
|
|
|
182
|
+ applyType.value = type
|
|
|
183
|
+ applyReason.value = ''
|
|
159
|
184
|
orderItems.value = items
|
|
160
|
185
|
payAmount.value = mapped.payAmount
|
|
161
|
186
|
applyAmountInput.value = String(mapped.payAmount || '')
|