diff --git a/src/views/system/jd-instruction/fadan-quick-record.vue b/src/views/system/jd-instruction/fadan-quick-record.vue
index 9e95127..055c902 100644
--- a/src/views/system/jd-instruction/fadan-quick-record.vue
+++ b/src/views/system/jd-instruction/fadan-quick-record.vue
@@ -205,6 +205,8 @@
待填写
已落库
{{ row.distributionMark }}
+ {{ row.remark }}
+ {{ row.thirdPartyOrderNo }}
{{ row.buyer }}
付款 {{ formatHistoryMoney(row.paymentAmount) }}
{{ row.orderId }}
@@ -857,34 +859,68 @@ export default {
].join(' ').toLowerCase()
return blob.includes(kw.toLowerCase())
},
- normalizeDraftItem(rawItem) {
- const parts = this.extractHistoryParts(rawItem)
- const body = this.extractFormBody(parts.text)
+ splitOrderFormBodies(text) {
+ const raw = this.extractFormBody(text).replace(/\r\n/g, '\n').trim()
+ if (!raw) return []
+ const idxs = []
+ const re = /^单:/gm
+ let m
+ while ((m = re.exec(raw)) !== null) {
+ idxs.push(m.index)
+ }
+ if (!idxs.length) {
+ return this.formBodyLooksPersistable(raw) ? [raw] : []
+ }
+ const out = []
+ for (let i = 0; i < idxs.length; i++) {
+ const chunk = raw.slice(idxs[i], i + 1 < idxs.length ? idxs[i + 1] : raw.length).trim()
+ if (this.formBodyLooksPersistable(chunk)) out.push(chunk)
+ }
+ return out
+ },
+ draftDedupeKey(item) {
+ const third = String((item && item.thirdPartyOrderNo) || '').trim()
+ if (third) return 't:' + third
+ const remark = String((item && item.remark) || '').trim()
+ const addr = this.compressAddressOneLine((item && item.address) || '')
+ if (remark || addr) return 'r:' + remark + '|' + addr
+ return String((item && item.key) || '')
+ },
+ normalizeDraftItemFromBody(body, time, seq) {
if (!this.formBodyLooksPersistable(body)) return null
const parsed = this.parseOrderFormText(body)
const modelFull = String(parsed.model || '').split('\n')[0].trim()
const shopParsed = this.parseModelWithShop(modelFull)
+ const third = String(parsed.thirdParty || '').trim()
+ const remark = String(parsed.remark || '').trim()
+ const addr = this.compressAddressOneLine(parsed.address)
return {
- key: 'draft-' + (parsed.remark || parts.time || modelFull),
+ key: 'draft-' + (third || [remark, addr, time, seq].filter(Boolean).join('|')),
source: 'draft',
filled: this.isPersistFilledText(parsed),
- remark: String(parsed.remark || '').trim(),
+ remark,
distributionMark: String(parsed.mark || '').trim(),
modelNumber: shopParsed.base || modelFull,
modelShop: shopParsed.prefix,
- address: this.compressAddressOneLine(parsed.address),
+ address: addr,
link: String(parsed.link || '').trim(),
- thirdPartyOrderNo: String(parsed.thirdParty || '').trim(),
+ thirdPartyOrderNo: third,
buyer: String(parsed.buyer || '').trim(),
paymentAmount: String(parsed.payment || '').trim(),
rebateAmount: String(parsed.rebate || '').trim(),
orderId: String(parsed.orderId || '').trim(),
logisticsLink: String(parsed.logistics || '').trim(),
waybillNo: String(parsed.waybill || '').trim(),
- orderTime: parts.time,
+ orderTime: time,
rawText: body
}
},
+ normalizeDraftItems(rawItem) {
+ const parts = this.extractHistoryParts(rawItem)
+ return this.splitOrderFormBodies(parts.text)
+ .map((body, i) => this.normalizeDraftItemFromBody(body, parts.time, i))
+ .filter(Boolean)
+ },
normalizeOrderItem(row) {
if (!row) return null
return {
@@ -938,20 +974,16 @@ export default {
})
])
const orders = ((orderRes && orderRes.rows) || []).map(this.normalizeOrderItem).filter(Boolean)
- const persistedRemarks = new Set(
- orders.map(o => String(o.remark || '').trim()).filter(Boolean)
- )
+ const persistedKeys = new Set(orders.map(o => this.draftDedupeKey(o)).filter(Boolean))
const draftMap = new Map()
;((histRes && histRes.data) || []).forEach(raw => {
- const draft = this.normalizeDraftItem(raw)
- if (!draft) return
- if (kw && !this.historyItemMatchesKeyword(draft, kw)) return
- const remark = draft.remark
- if (remark && persistedRemarks.has(remark)) return
- if (remark && draftMap.has(remark)) return
- const fallbackKey = draft.key
- if (!remark && draftMap.has(fallbackKey)) return
- draftMap.set(remark || fallbackKey, draft)
+ this.normalizeDraftItems(raw).forEach(draft => {
+ if (kw && !this.historyItemMatchesKeyword(draft, kw)) return
+ const dk = this.draftDedupeKey(draft)
+ if (dk && persistedKeys.has(dk)) return
+ if (draftMap.has(draft.key) || (dk && draftMap.has(dk))) return
+ draftMap.set(dk || draft.key, draft)
+ })
})
const drafts = Array.from(draftMap.values()).filter(d => !d.filled)
const unfilledOrders = orders.filter(o => !o.filled)