优化邮编分区管理,新增匹配类型字段及相关逻辑
This commit is contained in:
@@ -171,13 +171,20 @@ function scheduleAutoCollapse() {
|
||||
}
|
||||
|
||||
function open(filterQuery, autoStart) {
|
||||
// Already running / finished: just reopen progress view (same as order-list rebill).
|
||||
if (loading.value || finished.value) {
|
||||
// Still running: only reopen progress (do not start another task).
|
||||
if (loading.value) {
|
||||
visible.value = true
|
||||
return
|
||||
}
|
||||
// Finished + reopen only (float click): show last result.
|
||||
if (finished.value && !autoStart && filterQuery == null) {
|
||||
visible.value = true
|
||||
return
|
||||
}
|
||||
// New sync: clear previous result first.
|
||||
query.value = { ...(filterQuery || {}) }
|
||||
asyncTaskIdRef.value = ''
|
||||
pollGeneration.value += 1
|
||||
progress.value = {
|
||||
percent: 0,
|
||||
message: '',
|
||||
@@ -357,7 +364,11 @@ onBeforeUnmount(() => {
|
||||
pollGeneration.value += 1
|
||||
})
|
||||
|
||||
defineExpose({ open })
|
||||
function reopen() {
|
||||
visible.value = true
|
||||
}
|
||||
|
||||
defineExpose({ open, reopen })
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<div class="app-container order-source-page">
|
||||
<div v-if="syncFloatVisible" class="retry-status-float">
|
||||
<el-tooltip :content="syncFloatTooltip" placement="bottom">
|
||||
<el-button class="retry-status-button" type="primary" plain size="small" @click="openFilterSync()">
|
||||
<el-button class="retry-status-button" type="primary" plain size="small" @click="reopenSyncProgress()">
|
||||
<span class="retry-progress-ring" :style="{ '--retry-progress': syncProgressDegree + 'deg' }" aria-hidden="true">
|
||||
<span class="retry-progress-value">{{ syncProgressText }}</span>
|
||||
</span>
|
||||
@@ -458,12 +458,28 @@ function onCompareFillSearch(payload) {
|
||||
tableRef.value?.handleQuery?.()
|
||||
}
|
||||
|
||||
function reopenSyncProgress() {
|
||||
const dlg = syncDialogRef.value
|
||||
if (dlg && typeof dlg.reopen === 'function') {
|
||||
dlg.reopen()
|
||||
} else {
|
||||
dlg?.open(null, false)
|
||||
}
|
||||
}
|
||||
|
||||
function openFilterSync() {
|
||||
// Running / just finished: reopen progress dialog (same as order-list float click).
|
||||
if (syncFloat.value && (syncFloat.value.loading || syncFloat.value.finished)) {
|
||||
syncDialogRef.value?.open(null, false)
|
||||
// Running: reopen progress; finished result must not block a new sync.
|
||||
if (syncFloat.value?.loading) {
|
||||
reopenSyncProgress()
|
||||
return
|
||||
}
|
||||
if (syncFloat.value?.finished) {
|
||||
if (syncFloatHideTimer) {
|
||||
clearTimeout(syncFloatHideTimer)
|
||||
syncFloatHideTimer = null
|
||||
}
|
||||
syncFloat.value = null
|
||||
}
|
||||
const q = buildFilterQuery()
|
||||
const identifierCount = (q.orderIdentifiers || []).length
|
||||
const hasIdentifier = identifierCount > 0
|
||||
|
||||
@@ -25,6 +25,11 @@
|
||||
<el-table v-loading="loading" :data="list" border row-key="detailId" empty-text="暂无邮编">
|
||||
<el-table-column label="ID" prop="detailId" align="center" width="90" />
|
||||
<el-table-column label="邮编" prop="postcode" align="center" min-width="140" />
|
||||
<el-table-column label="匹配类型" prop="matchType" align="center" min-width="140">
|
||||
<template #default="{ row }">
|
||||
{{ matchTypeText(row.matchType) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" width="160">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" icon="Edit" @click="handleUpdate(row)" v-hasPermi="['price:zone:edit']">编辑</el-button>
|
||||
@@ -96,6 +101,11 @@ function loadList() {
|
||||
})
|
||||
}
|
||||
|
||||
function matchTypeText(type) {
|
||||
if (String(type || '').toUpperCase() === 'PREFIX') return '匹配邮编开头'
|
||||
return '全匹配'
|
||||
}
|
||||
|
||||
function handleAdd() {
|
||||
postcodeFormRef.value.open(selectedZone.value)
|
||||
}
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
<template>
|
||||
<el-dialog :title="title" v-model="visible" width="420px" append-to-body>
|
||||
<el-form ref="postcodeFormRef" :model="form" :rules="rules" label-width="80px">
|
||||
<el-dialog :title="title" v-model="visible" width="480px" append-to-body>
|
||||
<el-form ref="postcodeFormRef" :model="form" :rules="rules" label-width="100px">
|
||||
<el-form-item label="邮编" prop="postcode">
|
||||
<el-input v-model="form.postcode" placeholder="请输入邮编" maxlength="32" />
|
||||
</el-form-item>
|
||||
<el-form-item label="匹配类型" prop="matchType">
|
||||
<el-radio-group v-model="form.matchType">
|
||||
<el-radio label="FULL">全匹配</el-radio>
|
||||
<el-radio label="PREFIX">匹配邮编开头</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
@@ -26,17 +32,19 @@ const title = ref('')
|
||||
const postcodeFormRef = ref()
|
||||
const form = ref({})
|
||||
const rules = {
|
||||
postcode: [{ required: true, message: '邮编不能为空', trigger: 'blur' }]
|
||||
postcode: [{ required: true, message: '邮编不能为空', trigger: 'blur' }],
|
||||
matchType: [{ required: true, message: '请选择匹配类型', trigger: 'change' }]
|
||||
}
|
||||
|
||||
/** zone 为所属分区;row 传空为新增,传邮编行为编辑 */
|
||||
function open(zone, row) {
|
||||
form.value = row
|
||||
? { ...row }
|
||||
? { ...row, matchType: row.matchType || 'FULL' }
|
||||
: {
|
||||
detailId: undefined,
|
||||
zoneId: zone?.zoneId,
|
||||
postcode: undefined
|
||||
postcode: undefined,
|
||||
matchType: 'FULL'
|
||||
}
|
||||
title.value = row ? '编辑邮编' : '新增邮编'
|
||||
visible.value = true
|
||||
@@ -48,7 +56,8 @@ function submitForm() {
|
||||
if (!valid) return
|
||||
const payload = {
|
||||
...form.value,
|
||||
postcode: String(form.value.postcode || '').trim()
|
||||
postcode: String(form.value.postcode || '').trim(),
|
||||
matchType: form.value.matchType || 'FULL'
|
||||
}
|
||||
const req = payload.detailId != null ? updateDetail(payload) : addDetail(payload)
|
||||
req.then(() => {
|
||||
|
||||
@@ -166,7 +166,7 @@ const pageBanner = computed(() => {
|
||||
return `新建版本:${name}(${code})`
|
||||
})
|
||||
const headerTip = computed(() => {
|
||||
if (editVersionMode.value) return '可重新导入或修改明细;完成后按ID更新/新增/删除,不新增版本号'
|
||||
if (editVersionMode.value) return '可重新导入或修改明细;再导入按产品合并(同名覆盖、其余保留),完成后按ID更新/新增/删除,不新增版本号'
|
||||
if (newVersionMode.value) return '导入后生成待生效新版本;生效时间请回详情页设置'
|
||||
return '打单价卡与应付独立;解析后回填到此表,可删除不需要的产品,编辑明细后点完成保存'
|
||||
})
|
||||
@@ -246,6 +246,23 @@ function productKey(row) {
|
||||
return row?.rowKey || `${row?.sheetName || ''}-${row?.productName || ''}`
|
||||
}
|
||||
|
||||
/** 用于编辑再导入时判断同一产品(dict/名称/表名任一相等即命中) */
|
||||
function productTokens(row) {
|
||||
return [row?.dictValue, row?.productName, row?.sheetName]
|
||||
.map(s => String(s || '').toLowerCase().replace(/[^a-z0-9\u4e00-\u9fa5]/g, ''))
|
||||
.filter(Boolean)
|
||||
}
|
||||
|
||||
function productIdentity(row) {
|
||||
return productTokens(row)[0] || ''
|
||||
}
|
||||
|
||||
function sameProduct(left, right) {
|
||||
const a = new Set(productTokens(left))
|
||||
const b = productTokens(right)
|
||||
return b.some(token => a.has(token))
|
||||
}
|
||||
|
||||
function aliveDetailRows(list) {
|
||||
return (list || []).filter(row => row && row.deleted !== true)
|
||||
}
|
||||
@@ -319,14 +336,43 @@ async function removeSelectedProducts() {
|
||||
}
|
||||
|
||||
function onImportConfirm(payload) {
|
||||
const incoming = (payload?.products || []).filter(Boolean)
|
||||
if (editVersionMode.value) {
|
||||
for (const row of productRows.value || []) {
|
||||
if (row?.versionId || row?.productId) markProductRemoved(row)
|
||||
// 编辑再导入:按产品合并,不清空其它产品;同名则用新价卡覆盖
|
||||
const matched = new Set()
|
||||
const replaced = []
|
||||
for (const neu of incoming) {
|
||||
const key = productIdentity(neu)
|
||||
if (!key) {
|
||||
replaced.push(neu)
|
||||
continue
|
||||
}
|
||||
const old = (productRows.value || []).find(row => sameProduct(row, neu))
|
||||
if (old) {
|
||||
for (const token of productTokens(old)) matched.add(token)
|
||||
for (const token of productTokens(neu)) matched.add(token)
|
||||
if (old.versionId || old.productId) {
|
||||
markProductRemoved(old)
|
||||
}
|
||||
replaced.push({
|
||||
...neu,
|
||||
productId: old.productId ?? neu.productId,
|
||||
versionId: null,
|
||||
termId: null,
|
||||
rowKey: `${neu.sheetName || ''}-${neu.productName || ''}-${old.productId || old.versionId || ''}`,
|
||||
duplicated: true
|
||||
})
|
||||
} else {
|
||||
for (const token of productTokens(neu)) matched.add(token)
|
||||
replaced.push(neu)
|
||||
}
|
||||
}
|
||||
const kept = (productRows.value || []).filter(row => !productTokens(row).some(token => matched.has(token)))
|
||||
productRows.value = [...kept, ...replaced]
|
||||
} else {
|
||||
removedProducts.value = []
|
||||
productRows.value = incoming
|
||||
}
|
||||
productRows.value = payload?.products || []
|
||||
selectedProducts.value = []
|
||||
importMeta.sourceFile = payload?.sourceFile || ''
|
||||
importMeta.supplierName = payload?.supplierName || ''
|
||||
|
||||
Reference in New Issue
Block a user