优化线下提号利润修改

This commit is contained in:
yml2213
2026-07-25 14:53:11 +08:00
parent 7ca68e6b8b
commit 9bb57b7094
10 changed files with 404 additions and 6 deletions
@@ -1,13 +1,14 @@
<script setup lang="ts">
import { computed, onMounted, reactive, ref } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { Plus, Refresh, Search } from '@element-plus/icons-vue'
import { EditPen, Plus, Refresh, Search } from '@element-plus/icons-vue'
import {
cancelAdminPickup,
completeAdminPickup,
createAdminPickup,
fetchAdminPickups,
fetchAvailableListings,
updateAdminPickupProfit,
type AdminPickup,
type AvailableListing,
} from '@/features/admin/api/adminPickup'
@@ -23,7 +24,9 @@ const filters = reactive({ page: 1, page_size: 20, keyword: '', status: '' })
const createDialogVisible = ref(false)
const completeDialogVisible = ref(false)
const profitDialogVisible = ref(false)
const activePickupId = ref(0)
const profitSaving = ref(false)
const createForm = reactive({
listing_id: null as number | null,
@@ -32,6 +35,7 @@ const createForm = reactive({
remark: '',
})
const completeForm = reactive({ settle_amount: 0, profit_amount: 0, complete_remark: '' })
const profitForm = reactive({ profit_amount: 0, reason: '' })
const listingOptions = ref<AvailableListing[]>([])
const listingLoading = ref(false)
@@ -139,6 +143,13 @@ function openCompleteDialog(row: AdminPickup) {
completeDialogVisible.value = true
}
function openProfitDialog(row: AdminPickup) {
activePickupId.value = row.id
profitForm.profit_amount = centToYuan(row.profit_amount_cent)
profitForm.reason = ''
profitDialogVisible.value = true
}
async function handleComplete() {
if (completeForm.settle_amount <= 0) {
ElMessage.warning('请输入结算金额')
@@ -165,6 +176,27 @@ async function handleComplete() {
}
}
async function handleUpdateProfit() {
if (profitForm.profit_amount < 0) {
ElMessage.warning('线下利润不能为负数')
return
}
profitSaving.value = true
try {
await updateAdminPickupProfit(activePickupId.value, {
profit_amount_cent: yuanToCent(profitForm.profit_amount),
reason: profitForm.reason,
})
ElMessage.success('线下利润已更新')
profitDialogVisible.value = false
loadList()
} catch (e: unknown) {
ElMessage.error(errorMessage(e) || '修改失败')
} finally {
profitSaving.value = false
}
}
async function handleCancel(id: number) {
try {
const { value } = await ElMessageBox.prompt('请输入取消原因', '取消提号', {
@@ -275,6 +307,9 @@ function listingOwnerTotalCent(item: AvailableListing) {
<span v-else class="text-muted">待结算</span>
</template>
</el-table-column>
<el-table-column label="线下利润" width="120">
<template #default="{ row }">{{ formatCentWithSymbol(row.profit_amount_cent) }}</template>
</el-table-column>
<el-table-column label="状态" width="100">
<template #default="{ row }">
<el-tag :type="statusType(row.status)" effect="light">
@@ -285,12 +320,22 @@ function listingOwnerTotalCent(item: AvailableListing) {
<el-table-column label="创建时间" width="170">
<template #default="{ row }">{{ formatDateTime(row.created_at) }}</template>
</el-table-column>
<el-table-column label="操作" width="220" fixed="right">
<el-table-column label="操作" width="300" fixed="right">
<template #default="{ row }">
<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="success"
size="small"
plain
:icon="EditPen"
@click="openProfitDialog(row)"
>
改利润
</el-button>
<el-button
v-if="row.status === 'picking_up'"
type="primary"
@@ -433,6 +478,37 @@ function listingOwnerTotalCent(item: AvailableListing) {
<el-button type="primary" :loading="loading" @click="handleComplete">确认结算</el-button>
</template>
</el-dialog>
<el-dialog v-model="profitDialogVisible" title="修改线下利润" width="460px">
<el-form label-width="110px">
<el-form-item label="线下利润(元)" required>
<el-input-number
v-model="profitForm.profit_amount"
:min="0"
:step="1"
:precision="2"
controls-position="right"
style="width: 100%"
/>
</el-form-item>
<el-form-item label="修改原因">
<el-input
v-model="profitForm.reason"
type="textarea"
:rows="3"
maxlength="255"
show-word-limit
placeholder="可选"
/>
</el-form-item>
</el-form>
<template #footer>
<el-button @click="profitDialogVisible = false">取消</el-button>
<el-button type="primary" :loading="profitSaving" @click="handleUpdateProfit">
保存
</el-button>
</template>
</el-dialog>
</section>
</template>