优化提号详情
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { Plus, Refresh, Search } from '@element-plus/icons-vue'
|
||||
import {
|
||||
@@ -11,9 +11,10 @@ import {
|
||||
type AdminPickup,
|
||||
type AvailableListing,
|
||||
} from '@/features/admin/api/adminPickup'
|
||||
import { formatCentWithSymbol } from '@/shared/utils/money'
|
||||
import { centToYuan, formatCentWithSymbol, yuanToCent } from '@/shared/utils/money'
|
||||
import { formatDateTime } from '@/shared/utils/time'
|
||||
import { pickupStatusLabel } from '@/shared/utils/statusLabels'
|
||||
import { adminPath } from '@/shared/utils/adminPath'
|
||||
|
||||
const loading = ref(false)
|
||||
const items = ref<AdminPickup[]>([])
|
||||
@@ -27,12 +28,16 @@ const activePickupId = ref(0)
|
||||
const createForm = reactive({
|
||||
listing_id: null as number | null,
|
||||
platform: '',
|
||||
profit_amount: 0,
|
||||
remark: '',
|
||||
})
|
||||
const completeForm = reactive({ settle_amount: 0, complete_remark: '' })
|
||||
const completeForm = reactive({ settle_amount: 0, profit_amount: 0, complete_remark: '' })
|
||||
|
||||
const listingOptions = ref<AvailableListing[]>([])
|
||||
const listingLoading = ref(false)
|
||||
const selectedListing = computed(
|
||||
() => listingOptions.value.find(item => item.id === createForm.listing_id) || null
|
||||
)
|
||||
|
||||
onMounted(loadList)
|
||||
|
||||
@@ -64,6 +69,7 @@ function handleSizeChange(s: number) {
|
||||
function openCreateDialog() {
|
||||
createForm.listing_id = null
|
||||
createForm.platform = ''
|
||||
createForm.profit_amount = 0
|
||||
createForm.remark = ''
|
||||
listingOptions.value = []
|
||||
createDialogVisible.value = true
|
||||
@@ -88,11 +94,16 @@ async function handleCreate() {
|
||||
ElMessage.warning('请选择要提号的账号')
|
||||
return
|
||||
}
|
||||
if (createForm.profit_amount < 0) {
|
||||
ElMessage.warning('线下利润不能为负数')
|
||||
return
|
||||
}
|
||||
loading.value = true
|
||||
try {
|
||||
await createAdminPickup({
|
||||
listing_id: createForm.listing_id,
|
||||
platform: createForm.platform,
|
||||
profit_amount_cent: yuanToCent(createForm.profit_amount),
|
||||
remark: createForm.remark,
|
||||
})
|
||||
ElMessage.success('提号订单已创建')
|
||||
@@ -105,9 +116,10 @@ async function handleCreate() {
|
||||
}
|
||||
}
|
||||
|
||||
function openCompleteDialog(id: number) {
|
||||
activePickupId.value = id
|
||||
function openCompleteDialog(row: AdminPickup) {
|
||||
activePickupId.value = row.id
|
||||
completeForm.settle_amount = 0
|
||||
completeForm.profit_amount = centToYuan(row.profit_amount_cent)
|
||||
completeForm.complete_remark = ''
|
||||
completeDialogVisible.value = true
|
||||
}
|
||||
@@ -117,10 +129,15 @@ async function handleComplete() {
|
||||
ElMessage.warning('请输入结算金额')
|
||||
return
|
||||
}
|
||||
if (completeForm.profit_amount < 0) {
|
||||
ElMessage.warning('线下利润不能为负数')
|
||||
return
|
||||
}
|
||||
loading.value = true
|
||||
try {
|
||||
await completeAdminPickup(activePickupId.value, {
|
||||
settle_amount_cent: Math.round(completeForm.settle_amount * 100),
|
||||
settle_amount_cent: yuanToCent(completeForm.settle_amount),
|
||||
profit_amount_cent: yuanToCent(completeForm.profit_amount),
|
||||
complete_remark: completeForm.complete_remark,
|
||||
})
|
||||
ElMessage.success('提号已完成,已给卖家结算')
|
||||
@@ -169,6 +186,13 @@ function errorMessage(e: unknown) {
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
function ratioText(value: number) {
|
||||
const ratio = Number(value || 0)
|
||||
if (ratio <= 0) return '-'
|
||||
const rounded = Math.round(ratio * 100) / 100
|
||||
return `1:${Number.isInteger(rounded) ? rounded : rounded.toFixed(2)}`
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -205,7 +229,9 @@ function errorMessage(e: unknown) {
|
||||
<el-table-column prop="pickup_no" label="提号编号" width="190" />
|
||||
<el-table-column prop="account_title" label="账号" min-width="180" />
|
||||
<el-table-column label="区服/平台" width="150">
|
||||
<template #default="{ row }">{{ row.server_region || '-' }} / {{ row.login_platform || '-' }}</template>
|
||||
<template #default="{ row }"
|
||||
>{{ row.server_region || '-' }} / {{ row.login_platform || '-' }}</template
|
||||
>
|
||||
</el-table-column>
|
||||
<el-table-column label="上架编号" width="120">
|
||||
<template #default="{ row }">{{ row.listing_no }}</template>
|
||||
@@ -218,7 +244,9 @@ function errorMessage(e: unknown) {
|
||||
</el-table-column>
|
||||
<el-table-column label="结算金额" width="130">
|
||||
<template #default="{ row }">
|
||||
<span v-if="row.status === 'completed'">{{ formatCentWithSymbol(row.settle_amount_cent) }}</span>
|
||||
<span v-if="row.status === 'completed'">{{
|
||||
formatCentWithSymbol(row.settle_amount_cent)
|
||||
}}</span>
|
||||
<span v-else class="text-muted">待结算</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -232,26 +260,30 @@ function errorMessage(e: unknown) {
|
||||
<el-table-column label="创建时间" width="170">
|
||||
<template #default="{ row }">{{ formatDateTime(row.created_at) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="180" fixed="right">
|
||||
<el-table-column label="操作" width="220" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button
|
||||
v-if="row.status === 'picking_up'"
|
||||
type="primary"
|
||||
size="small"
|
||||
@click="openCompleteDialog(row.id)"
|
||||
>
|
||||
完成结算
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="row.status === 'picking_up'"
|
||||
type="danger"
|
||||
size="small"
|
||||
plain
|
||||
@click="handleCancel(row.id)"
|
||||
>
|
||||
取消
|
||||
</el-button>
|
||||
<span v-if="row.status !== 'picking_up'" class="text-muted">—</span>
|
||||
<div class="action-buttons">
|
||||
<RouterLink :to="adminPath(`pickup/${row.id}`)">
|
||||
<el-button size="small">详情</el-button>
|
||||
</RouterLink>
|
||||
<el-button
|
||||
v-if="row.status === 'picking_up'"
|
||||
type="primary"
|
||||
size="small"
|
||||
@click="openCompleteDialog(row)"
|
||||
>
|
||||
完成结算
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="row.status === 'picking_up'"
|
||||
type="danger"
|
||||
size="small"
|
||||
plain
|
||||
@click="handleCancel(row.id)"
|
||||
>
|
||||
取消
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -285,15 +317,35 @@ function errorMessage(e: unknown) {
|
||||
<el-option
|
||||
v-for="item in listingOptions"
|
||||
:key="item.id"
|
||||
:label="`${item.listing_no} · ${item.account_title}`"
|
||||
:label="`${item.listing_no} · ${item.account_title} · ${formatCentWithSymbol(item.owner_price_cent)} / ${formatCentWithSymbol(item.listing_price_cent)}`"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
<div class="form-hint">仅显示已发布、已审核、未在交易中的账号</div>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="selectedListing" label="价格快照">
|
||||
<div class="price-snapshot">
|
||||
<span>号主价 {{ formatCentWithSymbol(selectedListing.owner_price_cent) }}</span>
|
||||
<span>网站售价 {{ formatCentWithSymbol(selectedListing.listing_price_cent) }}</span>
|
||||
<span>网站加价 {{ formatCentWithSymbol(selectedListing.website_profit_cent) }}</span>
|
||||
<span>回收 {{ ratioText(selectedListing.seller_ratio) }}</span>
|
||||
<span>售卖 {{ ratioText(selectedListing.buyer_ratio) }}</span>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="交易渠道">
|
||||
<el-input v-model="createForm.platform" placeholder="如 微信 / QQ / 闲鱼" />
|
||||
</el-form-item>
|
||||
<el-form-item label="线下利润(元)">
|
||||
<el-input-number
|
||||
v-model="createForm.profit_amount"
|
||||
:min="0"
|
||||
:step="1"
|
||||
:precision="2"
|
||||
controls-position="right"
|
||||
style="width: 100%"
|
||||
/>
|
||||
<div class="form-hint">电商平台实际成交利润,财务统计按该金额汇总</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注">
|
||||
<el-input
|
||||
v-model="createForm.remark"
|
||||
@@ -326,6 +378,17 @@ function errorMessage(e: unknown) {
|
||||
/>
|
||||
<div class="form-hint">给卖家钱包增加的可用余额</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="线下利润(元)">
|
||||
<el-input-number
|
||||
v-model="completeForm.profit_amount"
|
||||
:min="0"
|
||||
:step="1"
|
||||
:precision="2"
|
||||
controls-position="right"
|
||||
style="width: 100%"
|
||||
/>
|
||||
<div class="form-hint">可在结算时修正为最终利润,财务统计使用该值</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="完成备注">
|
||||
<el-input
|
||||
v-model="completeForm.complete_remark"
|
||||
@@ -335,7 +398,7 @@ function errorMessage(e: unknown) {
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-alert type="warning" :closable="false">
|
||||
完成后订单置为"已完成",卖家钱包立即入账,账号下架不可再上架。操作不可撤销。
|
||||
完成后提号记录置为"已完成",卖家钱包立即入账,账号下架不可再上架。操作不可撤销。
|
||||
</el-alert>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
@@ -355,4 +418,17 @@ function errorMessage(e: unknown) {
|
||||
.text-muted {
|
||||
color: #94a3b8;
|
||||
}
|
||||
.price-snapshot {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px 12px;
|
||||
color: #475569;
|
||||
font-size: 13px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.action-buttons {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user