订单列表优化
This commit is contained in:
+8
-2
@@ -138,6 +138,8 @@ function openOrders(row) {
|
||||
}
|
||||
const q = {
|
||||
...lastQuery.value,
|
||||
// 下钻到具体客户代码时,去掉客户名称/代码混合条件,避免 OR 扩大范围
|
||||
customerKeywords: undefined,
|
||||
customerCodes: row.customerCode ? [row.customerCode] : lastQuery.value.customerCodes,
|
||||
productCode: row.upstreamCode
|
||||
}
|
||||
@@ -156,8 +158,12 @@ function openOrders(row) {
|
||||
}
|
||||
|
||||
function open(query) {
|
||||
if (!query || !query.customerCodes || !query.beginTime || !query.endTime) {
|
||||
ElMessage.warning('请先选择客户和提货时间')
|
||||
const hasCustomer = !!(query && (
|
||||
(Array.isArray(query.customerKeywords) && query.customerKeywords.length)
|
||||
|| (Array.isArray(query.customerCodes) && query.customerCodes.length)
|
||||
))
|
||||
if (!query || !hasCustomer || !query.beginTime || !query.endTime) {
|
||||
ElMessage.warning('请先输入客户并选择提货时间')
|
||||
return
|
||||
}
|
||||
lastQuery.value = { ...query }
|
||||
|
||||
@@ -86,12 +86,15 @@ const progress = ref({
|
||||
const filterText = computed(() => {
|
||||
const q = query.value || {}
|
||||
const codes = Array.isArray(q.customerCodes) ? q.customerCodes.filter(Boolean) : []
|
||||
const keywords = Array.isArray(q.customerKeywords) ? q.customerKeywords.filter(Boolean) : []
|
||||
const identifiers = Array.isArray(q.orderIdentifiers) ? q.orderIdentifiers.filter(Boolean) : []
|
||||
const nos = []
|
||||
if (identifiers.length) nos.push('单号 ' + identifiers.join(', '))
|
||||
if (q.orderId) nos.push('订单号 ' + q.orderId)
|
||||
if (q.orgOrderId) nos.push('运单号 ' + q.orgOrderId)
|
||||
if (q.transferOrderId) nos.push('转单号 ' + q.transferOrderId)
|
||||
return {
|
||||
customers: codes.join(', ') || '-',
|
||||
customers: keywords.join(', ') || codes.join(', ') || '-',
|
||||
time: (q.beginTime || '-') + ' ~ ' + (q.endTime || '-'),
|
||||
nos: nos.join(' / ')
|
||||
}
|
||||
@@ -178,8 +181,9 @@ function onClosed() {
|
||||
function submit(skipConfirm) {
|
||||
const q = query.value || {}
|
||||
const codes = Array.isArray(q.customerCodes) ? q.customerCodes.filter(v => v != null && String(v).trim() !== '') : []
|
||||
if (!codes.length || !q.beginTime || !q.endTime) {
|
||||
proxy.$modal.msgError('请先选择客户和提货时间')
|
||||
const keywords = Array.isArray(q.customerKeywords) ? q.customerKeywords.filter(v => v != null && String(v).trim() !== '') : []
|
||||
if ((!codes.length && !keywords.length) || !q.beginTime || !q.endTime) {
|
||||
proxy.$modal.msgError('请先输入客户并选择提货时间')
|
||||
return
|
||||
}
|
||||
const start = () => {
|
||||
@@ -197,7 +201,9 @@ function submit(skipConfirm) {
|
||||
}
|
||||
emitProgress()
|
||||
return syncOrderSourceByFilter({
|
||||
customerCodes: codes,
|
||||
customerCodes: codes.length ? codes : undefined,
|
||||
customerKeywords: keywords.length ? keywords : undefined,
|
||||
orderIdentifiers: Array.isArray(q.orderIdentifiers) && q.orderIdentifiers.length ? q.orderIdentifiers : undefined,
|
||||
beginTime: q.beginTime,
|
||||
endTime: q.endTime,
|
||||
orderId: q.orderId || undefined,
|
||||
|
||||
@@ -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