应付计费邮编改造
This commit is contained in:
@@ -420,6 +420,7 @@ const keyword = ref('')
|
||||
const found = ref([])
|
||||
const products = ref([])
|
||||
const feeOptions = ref([])
|
||||
const feeCounts = ref({})
|
||||
const zoneOptions = ref([])
|
||||
const enabled = reactive({})
|
||||
const groups = reactive({})
|
||||
@@ -455,6 +456,7 @@ function reset() {
|
||||
found.value = []
|
||||
products.value = []
|
||||
feeOptions.value = []
|
||||
feeCounts.value = {}
|
||||
zoneOptions.value = []
|
||||
blankGroups()
|
||||
saving.value = false
|
||||
@@ -504,24 +506,32 @@ function loadFees() {
|
||||
const bound = products.value.slice()
|
||||
if (!bound.length) {
|
||||
feeOptions.value = []
|
||||
feeCounts.value = {}
|
||||
zoneOptions.value = keepZones([])
|
||||
return
|
||||
return Promise.resolve()
|
||||
}
|
||||
Promise.all(bound.map(item => getPay(item.feeProductId || item.productId).catch(() => null))).then(results => {
|
||||
return Promise.all(bound.map(item => getPay(item.feeProductId || item.productId).catch(() => null))).then(results => {
|
||||
if (token !== feeToken) return
|
||||
const map = new Map()
|
||||
const counts = {}
|
||||
const zones = new Set()
|
||||
results.forEach(res => {
|
||||
const local = {}
|
||||
const rows = res?.data?.surcharges || []
|
||||
rows.forEach(fee => {
|
||||
const name = String(fee.feeName || '').trim()
|
||||
const zone = String(fee.zoneName || '').trim()
|
||||
if (zone) zones.add(zone)
|
||||
if (!name || map.has(name)) return
|
||||
map.set(name, { feeName: name, scId: fee.scId || '' })
|
||||
if (!name) return
|
||||
local[name] = (local[name] || 0) + 1
|
||||
if (!map.has(name)) map.set(name, { feeName: name, scId: fee.scId || '' })
|
||||
})
|
||||
Object.keys(local).forEach(name => {
|
||||
counts[name] = Math.max(counts[name] || 0, local[name])
|
||||
})
|
||||
})
|
||||
zoneOptions.value = keepZones([...zones])
|
||||
feeCounts.value = counts
|
||||
for (const row of groups.ALWAYS || []) {
|
||||
const name = String(row.feeName || '').trim()
|
||||
if (name && !map.has(name)) map.set(name, { feeName: name, scId: row.scId || '' })
|
||||
@@ -659,35 +669,48 @@ function save() {
|
||||
}
|
||||
}
|
||||
if (enabled.ALWAYS) {
|
||||
const names = new Set()
|
||||
for (const row of groups.ALWAYS) {
|
||||
const name = String(row.feeName || '').trim()
|
||||
if (!name) {
|
||||
if (!String(row.feeName || '').trim()) {
|
||||
proxy.$modal.msgError('每票都收要选择费用项')
|
||||
return
|
||||
}
|
||||
if (names.has(name)) {
|
||||
proxy.$modal.msgError('每票都收的费用项不能重复:' + name)
|
||||
return
|
||||
}
|
||||
names.add(name)
|
||||
}
|
||||
}
|
||||
saving.value = true
|
||||
savePaySurchargeRule({
|
||||
products: products.value.map(item => ({
|
||||
productId: item.productId,
|
||||
productName: item.productName
|
||||
})),
|
||||
rules: payloadRules()
|
||||
}).then(() => {
|
||||
proxy.$modal.msgSuccess('已保存,计算时按当前生效版本上的附加费执行')
|
||||
visible.value = false
|
||||
loadFees().then(() => {
|
||||
const duplicated = sameTypeFees()
|
||||
if (duplicated.length) {
|
||||
proxy.$modal.alert('存在两笔同类型的附加费:' + duplicated.join('、'))
|
||||
return
|
||||
}
|
||||
return savePaySurchargeRule({
|
||||
products: products.value.map(item => ({
|
||||
productId: item.productId,
|
||||
productName: item.productName
|
||||
})),
|
||||
rules: payloadRules()
|
||||
}).then(() => {
|
||||
proxy.$modal.msgSuccess('已保存,计算时按当前生效版本上的附加费执行')
|
||||
visible.value = false
|
||||
})
|
||||
}).finally(() => {
|
||||
saving.value = false
|
||||
})
|
||||
}
|
||||
|
||||
function sameTypeFees() {
|
||||
if (!enabled.ALWAYS) return []
|
||||
const seen = new Set()
|
||||
const duplicated = []
|
||||
for (const row of groups.ALWAYS) {
|
||||
const name = String(row.feeName || '').trim()
|
||||
if (!name) continue
|
||||
if (seen.has(name) || Number(feeCounts.value[name] || 0) >= 2) duplicated.push(name)
|
||||
seen.add(name)
|
||||
}
|
||||
return [...new Set(duplicated)]
|
||||
}
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user