feat(pl): allocate copy_seq_no on first driver plan share-to-group
Add ensure-copy-seq API and miniprogram clipboard prefix so each plan gets a tenant-scoped fixed serial on first copy; cover allocation with unit tests and refresh the backend graph. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
5357df1cc2
commit
811e6a129f
11 files changed
+21223
-13529
No files matched your search
@@ -148,6 +148,8 @@ export const driverPlanApi = {
|
||||
return data?.counts && typeof data.counts === 'object' ? data.counts : {}
|
||||
},
|
||||
get: async (planId) => unwrapData(await db.get(`/transport/driver-plan/${planId}`)),
|
||||
ensureCopySeq: async (planId) =>
|
||||
unwrapData(await db.post(`/transport/driver-plan/${planId}/ensure-copy-seq`, {})),
|
||||
saveFeedback: (planId, payload) =>
|
||||
db.post(`/transport/driver-plan/${planId}/feedback`, payload),
|
||||
saveDriverFeedback: (planId, payload) =>
|
||||
|
||||
@@ -281,9 +281,23 @@ function promptCopyAfterSave() {
|
||||
cancelText: '关闭',
|
||||
success: async (res) => {
|
||||
if (res.confirm) {
|
||||
const ok = await copyDriverPlanToClipboard(page.value || {})
|
||||
if (ok) {
|
||||
setTimeout(() => goList(), 400)
|
||||
try {
|
||||
const ensured = await driverPlanApi.ensureCopySeq(planId.value)
|
||||
const copySeqNo = ensured?.copySeqNo ?? ensured?.copy_seq_no
|
||||
if (copySeqNo == null || copySeqNo === '') {
|
||||
uni.showToast({ title: '复制失败', icon: 'none' })
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
const ok = await copyDriverPlanToClipboard({
|
||||
...(page.value || {}),
|
||||
copySeqNo
|
||||
})
|
||||
if (ok) {
|
||||
setTimeout(() => goList(), 400)
|
||||
}
|
||||
} catch (e) {
|
||||
uni.showToast({ title: '复制失败', icon: 'none' })
|
||||
}
|
||||
}
|
||||
resolve()
|
||||
|
||||
@@ -240,9 +240,14 @@ async function handleCopy(row) {
|
||||
}
|
||||
uni.showLoading({ title: '加载中...', mask: true })
|
||||
try {
|
||||
const page = await driverPlanApi.get(id)
|
||||
const page = (await driverPlanApi.get(id)) || {}
|
||||
const ensured = await driverPlanApi.ensureCopySeq(id)
|
||||
const copySeqNo = ensured?.copySeqNo ?? ensured?.copy_seq_no
|
||||
if (copySeqNo == null || copySeqNo === '') {
|
||||
throw new Error('no seq')
|
||||
}
|
||||
uni.hideLoading()
|
||||
await copyDriverPlanToClipboard(page || {})
|
||||
await copyDriverPlanToClipboard({ ...page, copySeqNo })
|
||||
} catch (e) {
|
||||
uni.hideLoading()
|
||||
uni.showToast({ title: '复制失败', icon: 'none' })
|
||||
|
||||
@@ -42,7 +42,11 @@ export function buildDriverPlanCopyText(page = {}) {
|
||||
const loadStop = stops.find((s) => stopTypeOf(s) === 'load')
|
||||
const deliveryStops = stops.filter((s) => stopTypeOf(s) === 'delivery')
|
||||
|
||||
const rawSeq = page?.copySeqNo ?? page?.copy_seq_no
|
||||
const seqText = rawSeq != null && rawSeq !== '' ? String(rawSeq) : DASH
|
||||
|
||||
const lines = [
|
||||
`序号:${seqText}`,
|
||||
`计划编号:${String(page?.planNo || page?.plan_no || '').trim() || DASH}`,
|
||||
`装货方:${loadStop ? customerNameOf(loadStop) : DASH}`
|
||||
]
|
||||
|
||||
Reference in new issue
Block a user