feat: 面单余额变动日志支持筛选与导出
添加充值/消费类型筛选与时间范围筛选; 新增异步导出功能(exportPrintQuantityLogs API + 进度查询); where参数支持gt/lt/between操作符; 集成AsyncExportProgressDialog导出进度弹窗
This commit is contained in:
parent
86f76ba14a
commit
3508316fca
@ -215,6 +215,7 @@ export function storeWarehouseQueryPrintQuantityLogs(data: {
|
|||||||
page?: number
|
page?: number
|
||||||
page_size?: number
|
page_size?: number
|
||||||
}
|
}
|
||||||
|
where?: Record<string, any>
|
||||||
}) {
|
}) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system',
|
url: '/system',
|
||||||
@ -360,3 +361,39 @@ export function storeWarehouseOpenAccount(data: {
|
|||||||
isSystemApi: true
|
isSystemApi: true
|
||||||
} as any)
|
} as any)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 提交面单余额变更日志导出任务 */
|
||||||
|
export function storeWarehouseExportPrintQuantityLogs(data: {
|
||||||
|
store_id: number | string
|
||||||
|
pagination?: { page?: number; page_size?: number }
|
||||||
|
where?: Record<string, any>
|
||||||
|
}) {
|
||||||
|
return request({
|
||||||
|
url: '/system',
|
||||||
|
method: 'post',
|
||||||
|
params: {
|
||||||
|
method: 'storeWarehouse.store.exportPrintQuantityLogs',
|
||||||
|
v,
|
||||||
|
timestamp: new Date().getTime()
|
||||||
|
},
|
||||||
|
data,
|
||||||
|
isSystemApi: true
|
||||||
|
} as any)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询面单余额变更日志导出任务进度 */
|
||||||
|
export function storeWarehouseExportPrintQuantityLogsTaskProgress(data: {
|
||||||
|
task_id: string
|
||||||
|
}) {
|
||||||
|
return request({
|
||||||
|
url: '/system',
|
||||||
|
method: 'post',
|
||||||
|
params: {
|
||||||
|
method: 'storeWarehouse.store.exportPrintQuantityLogsTaskProgress',
|
||||||
|
v,
|
||||||
|
timestamp: new Date().getTime()
|
||||||
|
},
|
||||||
|
data,
|
||||||
|
isSystemApi: true
|
||||||
|
} as any)
|
||||||
|
}
|
||||||
|
|||||||
@ -183,9 +183,37 @@
|
|||||||
<div class="detail-container">
|
<div class="detail-container">
|
||||||
<div v-if="activeTab === 'balanceLogs'" class="balance-log-panel store-detail-pane">
|
<div v-if="activeTab === 'balanceLogs'" class="balance-log-panel store-detail-pane">
|
||||||
<div class="balance-log-toolbar">
|
<div class="balance-log-toolbar">
|
||||||
<el-button size="small" @click="loadBalanceLogs">刷新</el-button>
|
<div class="balance-log-toolbar__left">
|
||||||
<div class="balance-log-toolbar__meta">
|
<el-button size="small" @click="loadBalanceLogs">刷新</el-button>
|
||||||
<span>变动记录:{{ balanceLogPagination.total }}</span>
|
<el-select
|
||||||
|
v-model="balanceLogFilter"
|
||||||
|
size="small"
|
||||||
|
placeholder="流水类型"
|
||||||
|
style="width: 130px"
|
||||||
|
clearable
|
||||||
|
@change="handleBalanceLogFilterChange"
|
||||||
|
>
|
||||||
|
<el-option label="充值" value="recharge" />
|
||||||
|
<el-option label="消费" value="consumption" />
|
||||||
|
</el-select>
|
||||||
|
<el-date-picker
|
||||||
|
v-model="balanceLogDateRange"
|
||||||
|
type="datetimerange"
|
||||||
|
size="small"
|
||||||
|
range-separator="至"
|
||||||
|
start-placeholder="开始时间"
|
||||||
|
end-placeholder="结束时间"
|
||||||
|
value-format="YYYY-MM-DD HH:mm:ss"
|
||||||
|
style="width: 380px"
|
||||||
|
@change="handleBalanceLogFilterChange"
|
||||||
|
/>
|
||||||
|
<el-button
|
||||||
|
v-if="hasPermission('storeWarehouse.store.exportPrintQuantityLogs')"
|
||||||
|
size="small"
|
||||||
|
type="primary"
|
||||||
|
:loading="exportLoading"
|
||||||
|
@click="handleExportBalanceLogs"
|
||||||
|
>导出</el-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<el-table
|
<el-table
|
||||||
@ -220,12 +248,12 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="变动类型" min-width="120">
|
<el-table-column label="变动类型" min-width="120">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
{{ getBalanceLogChangeType(row) || '—' }}
|
{{ row.change_type_label || getBalanceLogChangeType(row) || '—' }}
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="业务类型" min-width="120">
|
<el-table-column label="业务类型" min-width="120">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
{{ getBalanceLogBusinessType(row) || '—' }}
|
{{ row.business_type_label || getBalanceLogBusinessType(row) || '—' }}
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="业务ID" min-width="100" align="right">
|
<el-table-column label="业务ID" min-width="100" align="right">
|
||||||
@ -898,6 +926,21 @@
|
|||||||
</el-button>
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
|
<!-- 余额变动导出进度弹窗 -->
|
||||||
|
<AsyncExportProgressDialog
|
||||||
|
:visible="exportDialogVisible"
|
||||||
|
title="导出面单余额变更日志"
|
||||||
|
:loading="exportLoading"
|
||||||
|
:progress-percent="exportProgressPercent"
|
||||||
|
:progress-status="exportProgressStatus"
|
||||||
|
:status-label="exportStatusLabel"
|
||||||
|
:task-id="exportTaskProgress.taskId"
|
||||||
|
:message="exportTaskProgress.message"
|
||||||
|
:error="exportTaskProgress.error"
|
||||||
|
:update-time="exportTaskProgress.updateTime"
|
||||||
|
@update:visible="exportDialogVisible = $event"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -909,7 +952,9 @@ import { storeWarehouseList, storeWarehouseUnbind,
|
|||||||
storeWarehouseRename, storeWarehouseGetPolicyConfig, storeWarehouseGetPolicyConfigFields,
|
storeWarehouseRename, storeWarehouseGetPolicyConfig, storeWarehouseGetPolicyConfigFields,
|
||||||
storeWarehouseSavePolicyConfig, saveApiConfig, storeWarehouseDeleteQimenConfig,
|
storeWarehouseSavePolicyConfig, saveApiConfig, storeWarehouseDeleteQimenConfig,
|
||||||
storeWarehouseAdjustPrintQuantity, storeWarehouseQueryPrintQuantityLogs, listApiConfig,
|
storeWarehouseAdjustPrintQuantity, storeWarehouseQueryPrintQuantityLogs, listApiConfig,
|
||||||
storeWarehouseOpenAccount, storeWarehouseConfirmSign
|
storeWarehouseOpenAccount, storeWarehouseConfirmSign,
|
||||||
|
storeWarehouseExportPrintQuantityLogs,
|
||||||
|
storeWarehouseExportPrintQuantityLogsTaskProgress
|
||||||
} from '@/api/storewarehouse.store/storeWarehouse'
|
} from '@/api/storewarehouse.store/storeWarehouse'
|
||||||
import { listInterfaceTypes, getExpressList, getPlatformList, getQimenAppList } from '@/api/index/index'
|
import { listInterfaceTypes, getExpressList, getPlatformList, getQimenAppList } from '@/api/index/index'
|
||||||
import ScanBox from '@/components/ScanBox/index.vue'
|
import ScanBox from '@/components/ScanBox/index.vue'
|
||||||
@ -919,12 +964,17 @@ import type { ToolbarButtonConfig } from '@/views/order/orderManagement/config/o
|
|||||||
import Detail from './component/detail.vue'
|
import Detail from './component/detail.vue'
|
||||||
import Log from './component/log.vue'
|
import Log from './component/log.vue'
|
||||||
import { useSettingsStore } from '@/stores/modules/settings'
|
import { useSettingsStore } from '@/stores/modules/settings'
|
||||||
|
import { useUserStore } from '@/stores/modules/user'
|
||||||
import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane'
|
import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane'
|
||||||
|
import { useAsyncExportTask } from '@/composables/useAsyncExportTask'
|
||||||
|
import AsyncExportProgressDialog from '@/components/AsyncExportProgressDialog.vue'
|
||||||
import { safeInvoke } from '@/utils/safe-invoke'
|
import { safeInvoke } from '@/utils/safe-invoke'
|
||||||
import { columns as defaultColumns, availableFields as defaultAvailableFields, presetTree as defaultPresetTree, qimenFormDefault, qimenFormItems, qimenTableColumns, adjustBalanceDialogDefault, adjustBalanceFormDefault, adjustBalanceFormItems, openAccountDialogDefault, openAccountFormDefault, openAccountFormItems, storeToolbarButtons } from './store-config.ts'
|
import { columns as defaultColumns, availableFields as defaultAvailableFields, presetTree as defaultPresetTree, qimenFormDefault, qimenFormItems, qimenTableColumns, adjustBalanceDialogDefault, adjustBalanceFormDefault, adjustBalanceFormItems, openAccountDialogDefault, openAccountFormDefault, openAccountFormItems, storeToolbarButtons } from './store-config.ts'
|
||||||
|
|
||||||
// ─── 列表 ───────────────────────────────────────────────────────────────────
|
// ─── 列表 ───────────────────────────────────────────────────────────────────
|
||||||
const settingsStore = useSettingsStore()
|
const settingsStore = useSettingsStore()
|
||||||
|
const userStore = useUserStore()
|
||||||
|
const hasPermission = (perm: string) => userStore.checkPermission(perm)
|
||||||
const shortcutExpanded = computed(() => settingsStore.shortcutExpanded)
|
const shortcutExpanded = computed(() => settingsStore.shortcutExpanded)
|
||||||
const containerHeight = computed(() => shortcutExpanded.value ? 'calc(100vh - 150px)' : 'calc(100vh - 100px)')
|
const containerHeight = computed(() => shortcutExpanded.value ? 'calc(100vh - 150px)' : 'calc(100vh - 100px)')
|
||||||
|
|
||||||
@ -964,6 +1014,63 @@ const balanceLogPagination = reactive({
|
|||||||
total: 0
|
total: 0
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/** 余额变动筛选:''=无, 'recharge'=充值(增加), 'consumption'=消费(减少) */
|
||||||
|
const balanceLogFilter = ref('')
|
||||||
|
|
||||||
|
/** 余额变动时间范围筛选 */
|
||||||
|
const balanceLogDateRange = ref<string[] | null>(null)
|
||||||
|
|
||||||
|
function handleBalanceLogFilterChange() {
|
||||||
|
balanceLogPagination.currentPage = 1
|
||||||
|
void loadBalanceLogs()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ─── 余额变动导出 ────────────────────────────────────────────────────────────
|
||||||
|
function buildBalanceLogExportPayload() {
|
||||||
|
const storeId = selectedStoreId.value
|
||||||
|
if (storeId === undefined || storeId === null) return null
|
||||||
|
const whereFilter: Record<string, any> = {}
|
||||||
|
if (balanceLogFilter.value === 'recharge') {
|
||||||
|
whereFilter.change_quantity = { operator: 'gt', value: 0 }
|
||||||
|
} else if (balanceLogFilter.value === 'consumption') {
|
||||||
|
whereFilter.change_quantity = { operator: 'lt', value: 0 }
|
||||||
|
}
|
||||||
|
if (balanceLogDateRange.value && balanceLogDateRange.value.length === 2) {
|
||||||
|
whereFilter.created_at = {
|
||||||
|
operator: 'between',
|
||||||
|
value: balanceLogDateRange.value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const payload: Record<string, any> = { store_id: storeId }
|
||||||
|
if (Object.keys(whereFilter).length > 0) {
|
||||||
|
payload.where = whereFilter
|
||||||
|
}
|
||||||
|
return payload
|
||||||
|
}
|
||||||
|
|
||||||
|
const {
|
||||||
|
exportLoading,
|
||||||
|
exportDialogVisible,
|
||||||
|
exportTaskProgress,
|
||||||
|
exportProgressPercent,
|
||||||
|
exportProgressStatus,
|
||||||
|
exportStatusLabel,
|
||||||
|
submitExportTaskWithMode
|
||||||
|
} = useAsyncExportTask({
|
||||||
|
storageKey: 'store:stores:balanceLogExportTaskId',
|
||||||
|
submitExport: (payload) => storeWarehouseExportPrintQuantityLogs(payload as any),
|
||||||
|
queryProgress: (params) => storeWarehouseExportPrintQuantityLogsTaskProgress(params as any)
|
||||||
|
})
|
||||||
|
|
||||||
|
async function handleExportBalanceLogs() {
|
||||||
|
const payload = buildBalanceLogExportPayload()
|
||||||
|
if (!payload) {
|
||||||
|
ElMessage.warning('请先选择一个货主')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
await submitExportTaskWithMode(payload, undefined)
|
||||||
|
}
|
||||||
|
|
||||||
const selectedStoreId = computed<number | string | undefined>(() => {
|
const selectedStoreId = computed<number | string | undefined>(() => {
|
||||||
return resolveStoreIdFromRow(selectedRow.value)
|
return resolveStoreIdFromRow(selectedRow.value)
|
||||||
})
|
})
|
||||||
@ -1263,13 +1370,39 @@ async function loadBalanceLogs() {
|
|||||||
|
|
||||||
balanceLogLoading.value = true
|
balanceLogLoading.value = true
|
||||||
try {
|
try {
|
||||||
const res = (await storeWarehouseQueryPrintQuantityLogs({
|
// 构建 where 筛选条件
|
||||||
|
const whereFilter: Record<string, any> = {}
|
||||||
|
if (balanceLogFilter.value === 'recharge') {
|
||||||
|
// 充值:change_quantity > 0
|
||||||
|
whereFilter.change_quantity = { operator: 'gt', value: 0 }
|
||||||
|
} else if (balanceLogFilter.value === 'consumption') {
|
||||||
|
// 消费:change_quantity < 0
|
||||||
|
whereFilter.change_quantity = { operator: 'lt', value: 0 }
|
||||||
|
}
|
||||||
|
// 时间范围筛选
|
||||||
|
if (balanceLogDateRange.value && balanceLogDateRange.value.length === 2) {
|
||||||
|
whereFilter.created_at = {
|
||||||
|
operator: 'between',
|
||||||
|
value: balanceLogDateRange.value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const requestData: {
|
||||||
|
store_id: number | string
|
||||||
|
pagination: { page: number; page_size: number }
|
||||||
|
where?: Record<string, any>
|
||||||
|
} = {
|
||||||
store_id: storeId,
|
store_id: storeId,
|
||||||
pagination: {
|
pagination: {
|
||||||
page: balanceLogPagination.currentPage,
|
page: balanceLogPagination.currentPage,
|
||||||
page_size: balanceLogPagination.pageSize
|
page_size: balanceLogPagination.pageSize
|
||||||
}
|
}
|
||||||
})) as any
|
}
|
||||||
|
if (Object.keys(whereFilter).length > 0) {
|
||||||
|
requestData.where = whereFilter
|
||||||
|
}
|
||||||
|
|
||||||
|
const res = (await storeWarehouseQueryPrintQuantityLogs(requestData)) as any
|
||||||
|
|
||||||
const payload = res?.data || {}
|
const payload = res?.data || {}
|
||||||
const nested = payload?.data && typeof payload.data === 'object' ? payload.data : null
|
const nested = payload?.data && typeof payload.data === 'object' ? payload.data : null
|
||||||
@ -2300,6 +2433,12 @@ onMounted(loadList)
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
margin-bottom: 8px;
|
margin-bottom: 8px;
|
||||||
|
|
||||||
|
&__left {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
&__meta {
|
&__meta {
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
gap: 14px;
|
gap: 14px;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user