修改附加费
This commit is contained in:
@@ -197,6 +197,41 @@ export function updateSetDetail(data) {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit async batch write of detail surcharge snapshots and poll until done.
|
||||
* @returns {Promise<{ task: object }>}
|
||||
*/
|
||||
export async function updateSetDetailSurchargeAsync(details, onProgress) {
|
||||
const submitRes = await request({
|
||||
url: '/price/set/detail/surcharge/async',
|
||||
method: 'post',
|
||||
data: details || []
|
||||
})
|
||||
const taskId = pickSaveTaskId(submitRes)
|
||||
if (!taskId) {
|
||||
throw new Error('missing surcharge taskId')
|
||||
}
|
||||
const started = Date.now()
|
||||
const maxMs = 30 * 60 * 1000
|
||||
while (Date.now() - started < maxMs) {
|
||||
const res = await getPriceSetSaveTask(taskId)
|
||||
const task = res.data || {}
|
||||
if (typeof onProgress === 'function') {
|
||||
onProgress(task)
|
||||
}
|
||||
if (task.status === 'SUCCESS') {
|
||||
return { task }
|
||||
}
|
||||
if (task.status === 'FAIL') {
|
||||
const err = new Error(task.error || task.message || 'surcharge save failed')
|
||||
err.task = task
|
||||
throw err
|
||||
}
|
||||
await new Promise(resolve => setTimeout(resolve, 800))
|
||||
}
|
||||
throw new Error('surcharge save timeout')
|
||||
}
|
||||
|
||||
export function delSetDetail(psdIds) {
|
||||
return request({
|
||||
url: '/price/set/detail/' + psdIds,
|
||||
|
||||
Reference in New Issue
Block a user