✨ 单号筛选改为多行输入并限制1000个
This commit is contained in:
@@ -60,12 +60,16 @@
|
||||
</el-col>
|
||||
</template>
|
||||
<template #search-orderIdentifiers="{ model }">
|
||||
<multi-value-input
|
||||
v-model="model.orderIdentifiers"
|
||||
placeholder="订单号/运单号/转单号"
|
||||
width="100%"
|
||||
:search-method="searchOrderIdentifiers"
|
||||
/>
|
||||
<div class="order-identifier-search">
|
||||
<el-input
|
||||
v-model="model.orderIdentifiers"
|
||||
type="textarea"
|
||||
:rows="1"
|
||||
resize="none"
|
||||
placeholder="请输入订单号、运单号或转单号"
|
||||
clearable
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<template #search-customerCodes="{ model }">
|
||||
<customer-select
|
||||
@@ -163,7 +167,7 @@
|
||||
|
||||
<script setup name="OrderBillQuery">
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { listOrderBill, listOrderNoOptions, listTrackingNoOptions, listTransferNoOptions, localRebillAsync } from '@/api/price/billing'
|
||||
import { listOrderBill, localRebillAsync } from '@/api/price/billing'
|
||||
import { exportAsyncFromTable } from '@/utils/excelExport'
|
||||
import OrderSourceSyncLogDrawer from '../../monitor/orderSource/components/OrderSourceSyncLogDrawer.vue'
|
||||
import OrderBillProductCheckDrawer from './components/OrderBillProductCheckDrawer.vue'
|
||||
@@ -182,6 +186,7 @@ const rebillProgressSuccess = ref(0)
|
||||
const rebillProgressFail = ref(0)
|
||||
const tableHeight = ref(480)
|
||||
let tableResizeObserver = null
|
||||
const MAX_ORDER_IDENTIFIERS = 1000
|
||||
|
||||
const defaultParams = {
|
||||
orderStatuses: [3, 4, 5, 6, 7, 8, 11],
|
||||
@@ -330,8 +335,10 @@ const searchColumns = [
|
||||
]
|
||||
|
||||
function applySearchRanges(params) {
|
||||
const { bizDateRange, pickupDateRange, ...rest } = params
|
||||
const { bizDateRange, pickupDateRange, orderIdentifiers: rawOrderIdentifiers, ...rest } = params || {}
|
||||
const query = { ...rest }
|
||||
const orderIdentifiers = parseOrderIdentifiers(rawOrderIdentifiers)
|
||||
if (orderIdentifiers.length) query.orderIdentifiers = orderIdentifiers
|
||||
const rangeParams = {}
|
||||
if (Array.isArray(bizDateRange) && (bizDateRange[0] || bizDateRange[1])) {
|
||||
rangeParams.beginBizDate = bizDateRange[0] || null
|
||||
@@ -347,11 +354,36 @@ function applySearchRanges(params) {
|
||||
return query
|
||||
}
|
||||
|
||||
function parseOrderIdentifiers(raw) {
|
||||
const values = Array.isArray(raw) ? raw : [raw]
|
||||
const identifiers = values
|
||||
.filter(v => v !== null && v !== undefined)
|
||||
.flatMap(v => String(v).split(/[\s,,;;]+/))
|
||||
.map(v => v.trim())
|
||||
.filter(Boolean)
|
||||
return [...new Set(identifiers)]
|
||||
}
|
||||
|
||||
function getUniqueOrderIdentifierCount(raw) {
|
||||
return parseOrderIdentifiers(raw).length
|
||||
}
|
||||
|
||||
function validateOrderIdentifierLimit(raw) {
|
||||
const count = getUniqueOrderIdentifierCount(raw)
|
||||
if (count <= MAX_ORDER_IDENTIFIERS) return true
|
||||
ElMessage.warning(`单号去重后最多输入 ${MAX_ORDER_IDENTIFIERS} 个,当前 ${count} 个`)
|
||||
return false
|
||||
}
|
||||
|
||||
function queryList(params) {
|
||||
return listOrderBill(applySearchRanges(params))
|
||||
const query = applySearchRanges(params)
|
||||
if (!validateOrderIdentifierLimit(query.orderIdentifiers)) return Promise.reject(new Error('order identifier limit exceeded'))
|
||||
return listOrderBill(query)
|
||||
}
|
||||
|
||||
function handleExport() {
|
||||
const params = tableRef.value?.getQueryParams?.() || {}
|
||||
if (!validateOrderIdentifierLimit(params.orderIdentifiers)) return
|
||||
return exportAsyncFromTable({
|
||||
baseUrl: '/price/billing/orderBill/export',
|
||||
tableRef: tableRef.value,
|
||||
@@ -365,9 +397,7 @@ const MAX_REBILL = 10000
|
||||
|
||||
function currentIdentifiers() {
|
||||
const q = tableRef.value?.getQueryParams?.() || {}
|
||||
return (Array.isArray(q.orderIdentifiers) ? q.orderIdentifiers : [])
|
||||
.map(v => String(v || '').trim())
|
||||
.filter(Boolean)
|
||||
return parseOrderIdentifiers(q.orderIdentifiers)
|
||||
}
|
||||
|
||||
function buildRebillFilter() {
|
||||
@@ -400,6 +430,7 @@ function buildCheckQuery() {
|
||||
|
||||
function handleCheckProducts() {
|
||||
const q = buildCheckQuery()
|
||||
if (!validateOrderIdentifierLimit(q.orderIdentifiers)) return
|
||||
const hasCustomer = Array.isArray(q.customerCodes) && q.customerCodes.length > 0
|
||||
const begin = q.params?.beginBizDate
|
||||
const end = q.params?.endBizDate
|
||||
@@ -474,6 +505,7 @@ async function runLocalRebill(payload, confirmText) {
|
||||
function openFilterRebill() {
|
||||
const filter = buildRebillFilter()
|
||||
const identifiers = filter.orderIdentifiers || []
|
||||
if (!validateOrderIdentifierLimit(identifiers)) return
|
||||
if (!hasRebillFilter(filter)) {
|
||||
ElMessage.warning('请输入单号,或选择客户并选择计费时间后再重新计费;也可勾选订单后点重新计费选中')
|
||||
return
|
||||
@@ -514,14 +546,6 @@ function handleBatchRebill(selection) {
|
||||
)
|
||||
}
|
||||
|
||||
function searchOrderIdentifiers(keyword) {
|
||||
return Promise.all([
|
||||
listOrderNoOptions(keyword).then(res => res.data || []),
|
||||
listTrackingNoOptions(keyword).then(res => res.data || []),
|
||||
listTransferNoOptions(keyword).then(res => res.data || [])
|
||||
]).then(groups => [...new Set(groups.flat().map(v => String(v)))])
|
||||
}
|
||||
|
||||
function formatWeight(val) {
|
||||
if (val == null || val === '') return '-'
|
||||
const num = Number(val)
|
||||
@@ -581,6 +605,7 @@ onBeforeUnmount(() => {
|
||||
.order-bill-query :deep(.basic-form .el-form-item .el-date-editor) {
|
||||
width: 100%;
|
||||
}
|
||||
.order-identifier-search { width: 100%; }
|
||||
.rebill-progress__msg { margin-top: 12px; color: var(--el-text-color-regular); }
|
||||
.rebill-progress__text { margin-top: 8px; font-size: 13px; color: var(--el-text-color-secondary); }
|
||||
.rebill-progress__hint { margin-top: 12px; font-size: 12px; color: var(--el-color-warning); }
|
||||
|
||||
Reference in New Issue
Block a user