refactor(admin-order): 拆分线下结算弹窗逻辑
This commit is contained in:
@@ -0,0 +1,110 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { formatCentWithSymbol } from '@/shared/utils/money'
|
||||
|
||||
type OperatorOption = {
|
||||
id: number
|
||||
name: string
|
||||
}
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
modelValue: boolean
|
||||
amountCent: number
|
||||
operators: OperatorOption[]
|
||||
loading?: boolean
|
||||
submitting?: boolean
|
||||
defaultOperator?: string
|
||||
}>(),
|
||||
{
|
||||
loading: false,
|
||||
submitting: false,
|
||||
defaultOperator: '',
|
||||
}
|
||||
)
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:modelValue': [value: boolean]
|
||||
confirm: [value: { operator: string; remark: string }]
|
||||
}>()
|
||||
|
||||
const actualOperator = ref('')
|
||||
const remark = ref('')
|
||||
const visible = computed({
|
||||
get: () => props.modelValue,
|
||||
set: value => emit('update:modelValue', value),
|
||||
})
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
open => {
|
||||
if (!open) return
|
||||
actualOperator.value = props.defaultOperator
|
||||
remark.value = ''
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
function submit() {
|
||||
emit('confirm', {
|
||||
operator: actualOperator.value.trim(),
|
||||
remark: remark.value.trim(),
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-dialog v-model="visible" title="确认线下结算" width="520px" destroy-on-close>
|
||||
<div class="dialog-body">
|
||||
<p>
|
||||
待打款金额
|
||||
<strong>{{ formatCentWithSymbol(amountCent) }}</strong>
|
||||
</p>
|
||||
<el-form label-position="top">
|
||||
<el-form-item label="实际操作人" required>
|
||||
<el-select
|
||||
v-model="actualOperator"
|
||||
filterable
|
||||
clearable
|
||||
class="full-control"
|
||||
:loading="loading"
|
||||
placeholder="请选择实际完成出款的人员"
|
||||
no-data-text="暂无可选项,请先在客服手动录单的配置中添加"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in operators"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.name"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="结算备注">
|
||||
<el-input
|
||||
v-model="remark"
|
||||
type="textarea"
|
||||
:rows="4"
|
||||
placeholder="填写线下转账备注,可留空"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
<template #footer>
|
||||
<el-button @click="visible = false">取消</el-button>
|
||||
<el-button type="primary" :loading="submitting" @click="submit">确认已结算</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.dialog-body {
|
||||
display: grid;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.dialog-body p {
|
||||
margin: 0;
|
||||
color: #52616f;
|
||||
line-height: 1.6;
|
||||
}
|
||||
</style>
|
||||
@@ -107,3 +107,38 @@ export function paymentBizTypeLabel(type: string) {
|
||||
export function paymentPaidAt(record: Pick<AdminPayment, 'paid_at' | 'updated_at' | 'created_at'>) {
|
||||
return record.paid_at || record.updated_at || record.created_at
|
||||
}
|
||||
|
||||
export function formatHandoffRecordType(type: string) {
|
||||
const typeMap: Record<string, string> = {
|
||||
owner_handoff: '卖家交接',
|
||||
platform_handoff: '客服代交接',
|
||||
renter_checkout: '买家结账',
|
||||
owner_counter_checkout: '卖家反驳结账',
|
||||
platform_checkout_counter: '客服修改结账',
|
||||
renter_confirm_checkout: '买家确认结账',
|
||||
owner_accept_checkout: '卖家接受结账',
|
||||
admin_arbitration: '客服仲裁',
|
||||
platform_checkout_dispute_opened: '客服发起结账争议',
|
||||
}
|
||||
return typeMap[type] || type
|
||||
}
|
||||
|
||||
export function handoffModeLabel(mode?: string) {
|
||||
const labels: Record<string, string> = {
|
||||
owner: '号主交接',
|
||||
platform: '平台代管',
|
||||
}
|
||||
return labels[mode || 'owner'] || mode || '-'
|
||||
}
|
||||
|
||||
export function settlementModeLabel(mode?: string) {
|
||||
const labels: Record<string, string> = {
|
||||
owner_wallet: '号主钱包',
|
||||
platform_managed: '线下结算',
|
||||
}
|
||||
return labels[mode || 'owner_wallet'] || mode || '-'
|
||||
}
|
||||
|
||||
export function accountSourceLabel(source?: string) {
|
||||
return source === 'external' ? '外部上传' : '站内上传'
|
||||
}
|
||||
|
||||
@@ -54,11 +54,16 @@ import { formatDateTime } from '@/shared/utils/time'
|
||||
import { formatGameName, formatListingNo } from '@/shared/utils/listingDisplay'
|
||||
import AdminOrderMetrics, { type AdminOrderMetric } from '../components/AdminOrderMetrics.vue'
|
||||
import AdminOrderPaymentRecords from '../components/AdminOrderPaymentRecords.vue'
|
||||
import OfflineSettlementDialog from '../components/OfflineSettlementDialog.vue'
|
||||
import ProcessTimeline from '../components/ProcessTimeline.vue'
|
||||
import {
|
||||
accountSourceLabel,
|
||||
estimateOrderEndAt,
|
||||
formatHandoffRecordType,
|
||||
handoffModeLabel,
|
||||
orderPlatformFeeBreakdown,
|
||||
paymentStatusLabel,
|
||||
settlementModeLabel,
|
||||
} from '../utils/adminOrderPresentation'
|
||||
|
||||
const route = useRoute()
|
||||
@@ -98,8 +103,6 @@ const platformCheckoutCounterForm = ref({
|
||||
evidenceText: '',
|
||||
})
|
||||
const offlineSettlementVisible = ref(false)
|
||||
const offlineSettlementRemark = ref('')
|
||||
const offlineSettlementOperator = ref('')
|
||||
const disbursementOperators = ref<ManualEntryOption[]>([])
|
||||
const disbursementOperatorsLoading = ref(false)
|
||||
const platformSubmitting = ref(false)
|
||||
@@ -815,26 +818,20 @@ function loadDisbursementOperators() {
|
||||
}
|
||||
|
||||
function openOfflineSettlement() {
|
||||
offlineSettlementRemark.value = ''
|
||||
offlineSettlementOperator.value = ''
|
||||
offlineSettlementVisible.value = true
|
||||
if (!disbursementOperators.value.length) loadDisbursementOperators()
|
||||
}
|
||||
|
||||
async function submitOfflineSettlement() {
|
||||
async function submitOfflineSettlement(input: { operator: string; remark: string }) {
|
||||
if (!order.value) return
|
||||
const actualOperator = offlineSettlementOperator.value.trim()
|
||||
const actualOperator = input.operator.trim()
|
||||
if (!actualOperator) {
|
||||
ElMessage.warning('请选择出款实际操作人')
|
||||
return
|
||||
}
|
||||
platformSubmitting.value = true
|
||||
try {
|
||||
await adminMarkOfflineSettlement(
|
||||
order.value.id,
|
||||
actualOperator,
|
||||
offlineSettlementRemark.value.trim()
|
||||
)
|
||||
await adminMarkOfflineSettlement(order.value.id, actualOperator, input.remark.trim())
|
||||
ElMessage.success('线下结算已确认')
|
||||
offlineSettlementVisible.value = false
|
||||
await loadOrder()
|
||||
@@ -910,41 +907,6 @@ function firstQueryValue(value: unknown) {
|
||||
return typeof value === 'string' ? value : ''
|
||||
}
|
||||
|
||||
function formatHandoffRecordType(type: string) {
|
||||
const typeMap: Record<string, string> = {
|
||||
owner_handoff: '卖家交接',
|
||||
platform_handoff: '客服代交接',
|
||||
renter_checkout: '买家结账',
|
||||
owner_counter_checkout: '卖家反驳结账',
|
||||
platform_checkout_counter: '客服修改结账',
|
||||
renter_confirm_checkout: '买家确认结账',
|
||||
owner_accept_checkout: '卖家接受结账',
|
||||
admin_arbitration: '客服仲裁',
|
||||
platform_checkout_dispute_opened: '客服发起结账争议',
|
||||
}
|
||||
return typeMap[type] || type
|
||||
}
|
||||
|
||||
function handoffModeLabel(mode?: string) {
|
||||
const map: Record<string, string> = {
|
||||
owner: '号主交接',
|
||||
platform: '平台代管',
|
||||
}
|
||||
return map[mode || 'owner'] || mode || '-'
|
||||
}
|
||||
|
||||
function settlementModeLabel(mode?: string) {
|
||||
const map: Record<string, string> = {
|
||||
owner_wallet: '号主钱包',
|
||||
platform_managed: '线下结算',
|
||||
}
|
||||
return map[mode || 'owner_wallet'] || mode || '-'
|
||||
}
|
||||
|
||||
function accountSourceLabel(source?: string) {
|
||||
return source === 'external' ? '外部上传' : '站内上传'
|
||||
}
|
||||
|
||||
function offlineSettlementStatusLabel(status?: string) {
|
||||
const map: Record<string, string> = {
|
||||
none: '无需线下结算',
|
||||
@@ -1804,53 +1766,14 @@ function formatRatioNumber(value: number) {
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog
|
||||
<OfflineSettlementDialog
|
||||
v-model="offlineSettlementVisible"
|
||||
title="确认线下结算"
|
||||
width="520px"
|
||||
destroy-on-close
|
||||
>
|
||||
<div v-if="order" class="dialog-body">
|
||||
<p>
|
||||
待打款金额
|
||||
<strong>{{ moneyCent(order.offline_settlement_amount_cent) }}</strong>
|
||||
</p>
|
||||
<el-form label-position="top">
|
||||
<el-form-item label="实际操作人" required>
|
||||
<el-select
|
||||
v-model="offlineSettlementOperator"
|
||||
filterable
|
||||
clearable
|
||||
class="full-control"
|
||||
:loading="disbursementOperatorsLoading"
|
||||
placeholder="请选择实际完成出款的人员"
|
||||
no-data-text="暂无可选项,请先在客服手动录单的配置中添加"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in disbursementOperators"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.name"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="结算备注">
|
||||
<el-input
|
||||
v-model="offlineSettlementRemark"
|
||||
type="textarea"
|
||||
:rows="4"
|
||||
placeholder="填写线下转账备注,可留空"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
<template #footer>
|
||||
<el-button @click="offlineSettlementVisible = false">取消</el-button>
|
||||
<el-button type="primary" :loading="platformSubmitting" @click="submitOfflineSettlement">
|
||||
确认已结算
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
:amount-cent="order?.offline_settlement_amount_cent ?? 0"
|
||||
:operators="disbursementOperators"
|
||||
:loading="disbursementOperatorsLoading"
|
||||
:submitting="platformSubmitting"
|
||||
@confirm="submitOfflineSettlement"
|
||||
/>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user