订单列表优化
This commit is contained in:
@@ -25,19 +25,6 @@
|
||||
search-action-align="center"
|
||||
:search-per-row="4"
|
||||
>
|
||||
<template #search-customerCodes="{ model }">
|
||||
<customer-select
|
||||
v-model="model.customerCodes"
|
||||
type="customer"
|
||||
value-key="customerCode"
|
||||
label-key="customerName"
|
||||
code-key="customerCode"
|
||||
placeholder="请输入客户名称或代码搜索"
|
||||
:remote-search="true"
|
||||
:page-size="20"
|
||||
multiple
|
||||
/>
|
||||
</template>
|
||||
<template #toolbar="{ selection }">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
@@ -127,7 +114,30 @@ const batchLoading = ref(false)
|
||||
const syncFloat = ref(null)
|
||||
|
||||
const searchColumns = [
|
||||
{ label: '客户', prop: 'customerCodes', placeholder: '请输入客户名称或代码搜索' },
|
||||
{
|
||||
// 客户名称或客户代码混合录入,一行一个
|
||||
label: '客户',
|
||||
prop: 'customerKeywords',
|
||||
component: 'textarea',
|
||||
placeholder: '客户名称/客户代码,一行一个',
|
||||
props: {
|
||||
rows: 2,
|
||||
autosize: { minRows: 1, maxRows: 4 },
|
||||
clearable: true
|
||||
}
|
||||
},
|
||||
{
|
||||
// 订单号/运单号/转单号混合录入,一行一个;有单号即可查询,不要求客户+提货时间
|
||||
label: '单号',
|
||||
prop: 'orderIdentifiers',
|
||||
component: 'textarea',
|
||||
placeholder: '订单号/运单号/转单号,一行一个',
|
||||
props: {
|
||||
rows: 2,
|
||||
autosize: { minRows: 1, maxRows: 4 },
|
||||
clearable: true
|
||||
}
|
||||
},
|
||||
{
|
||||
label: '提货时间',
|
||||
prop: 'dateRange',
|
||||
@@ -137,10 +147,7 @@ const searchColumns = [
|
||||
clearable: true,
|
||||
defaultTime: [new Date(2000, 0, 1, 0, 0, 0), new Date(2000, 0, 1, 23, 59, 59)]
|
||||
}
|
||||
},
|
||||
{ label: '订单号', prop: 'orderId', component: 'input', placeholder: '订单号', width: '180px' },
|
||||
{ label: '运单号', prop: 'orgOrderId', component: 'input', placeholder: '运单号', width: '180px' },
|
||||
{ label: '转单号', prop: 'transferOrderId', component: 'input', placeholder: '转单号', width: '180px' }
|
||||
}
|
||||
]
|
||||
|
||||
const columns = [
|
||||
@@ -208,18 +215,22 @@ function rowKey(row) {
|
||||
return (row && (row.orderId || row.transferOrderId || row.orgOrderId)) || ''
|
||||
}
|
||||
|
||||
function hasRequiredFilters(params) {
|
||||
const codes = params && params.customerCodes
|
||||
const hasCustomer = Array.isArray(codes) && codes.some(v => v != null && String(v).trim() !== '')
|
||||
const range = params && params.dateRange
|
||||
const hasTime = Array.isArray(range) && !!(range[0] && range[1])
|
||||
return hasCustomer && hasTime
|
||||
/** 长文本拆成数组:一行一条,兼容逗号/分号/顿号分隔;不按空格拆(客户名称可能含空格) */
|
||||
function splitLines(text) {
|
||||
return String(text || '')
|
||||
.split(/[\r\n,;,;、]+/)
|
||||
.map(s => s.trim())
|
||||
.filter(Boolean)
|
||||
}
|
||||
|
||||
function buildFilterQuery(params) {
|
||||
const src = params || tableRef.value?.getQueryParams?.() || {}
|
||||
const { dateRange, pageNum, pageSize, ...rest } = src
|
||||
const { dateRange, pageNum, pageSize, orderIdentifiers, customerKeywords, ...rest } = src
|
||||
const query = { ...rest }
|
||||
const identifiers = splitLines(orderIdentifiers)
|
||||
const customers = splitLines(customerKeywords)
|
||||
if (identifiers.length) query.orderIdentifiers = identifiers
|
||||
if (customers.length) query.customerKeywords = customers
|
||||
if (Array.isArray(dateRange) && dateRange[0] && dateRange[1]) {
|
||||
query.beginTime = dateRange[0]
|
||||
query.endTime = dateRange[1]
|
||||
@@ -228,11 +239,15 @@ function buildFilterQuery(params) {
|
||||
}
|
||||
|
||||
function queryList(params) {
|
||||
if (!hasRequiredFilters(params)) {
|
||||
ElMessage.warning('请先选择客户和提货时间')
|
||||
const query = buildFilterQuery(params)
|
||||
const hasIdentifier = !!(query.orderIdentifiers && query.orderIdentifiers.length)
|
||||
const hasCustomer = !!(query.customerKeywords && query.customerKeywords.length)
|
||||
const hasTime = !!query.beginTime && !!query.endTime
|
||||
// 有任一单号即可查询;无单号时必须客户+提货时间
|
||||
if (!hasIdentifier && !(hasCustomer && hasTime)) {
|
||||
ElMessage.warning('请输入单号,或选择客户和提货时间')
|
||||
return Promise.resolve({ rows: [], total: 0 })
|
||||
}
|
||||
const query = buildFilterQuery(params)
|
||||
query.pageNum = params.pageNum
|
||||
query.pageSize = params.pageSize
|
||||
return listOrderSource(query)
|
||||
@@ -240,16 +255,10 @@ function queryList(params) {
|
||||
|
||||
function openFilterSync() {
|
||||
const q = buildFilterQuery()
|
||||
if (!q.customerCodes || !q.beginTime || !q.endTime) {
|
||||
ElMessage.warning('请先选择客户和提货时间')
|
||||
if (!(q.customerKeywords && q.customerKeywords.length) || !q.beginTime || !q.endTime) {
|
||||
ElMessage.warning('按条件同步计费需先输入客户并选择提货时间')
|
||||
return
|
||||
}
|
||||
const codes = Array.isArray(q.customerCodes) ? q.customerCodes.filter(v => v != null && String(v).trim() !== '') : []
|
||||
if (!codes.length) {
|
||||
ElMessage.warning('请先选择客户和提货时间')
|
||||
return
|
||||
}
|
||||
q.customerCodes = codes
|
||||
proxy.$modal.confirm('确认按当前筛选分页查询并异步同步计费?', '二次确认').then(() => {
|
||||
syncDialogRef.value?.open(q, true)
|
||||
}).catch(() => {})
|
||||
@@ -301,16 +310,10 @@ function handleSyncOne(row) {
|
||||
|
||||
function handleCheckProducts() {
|
||||
const q = buildFilterQuery()
|
||||
if (!q.customerCodes || !q.beginTime || !q.endTime) {
|
||||
ElMessage.warning('请先选择客户和提货时间')
|
||||
if (!(q.customerKeywords && q.customerKeywords.length) || !q.beginTime || !q.endTime) {
|
||||
ElMessage.warning('检测产品需先输入客户并选择提货时间')
|
||||
return
|
||||
}
|
||||
const codes = Array.isArray(q.customerCodes) ? q.customerCodes.filter(v => v != null && String(v).trim() !== '') : []
|
||||
if (!codes.length) {
|
||||
ElMessage.warning('请先选择客户和提货时间')
|
||||
return
|
||||
}
|
||||
q.customerCodes = codes
|
||||
checkLoading.value = true
|
||||
productCheckDrawerRef.value?.open(q)
|
||||
window.setTimeout(() => { checkLoading.value = false }, 300)
|
||||
|
||||
Reference in New Issue
Block a user