导入批量修改价格明细

This commit is contained in:
wuweihua
2026-09-28 18:01:26 +08:00
parent c278ed76f7
commit b247bc2fd2
19 changed files with 777 additions and 54 deletions
+45
View File
@@ -189,6 +189,51 @@ export function addSetDetail(data) {
})
}
/**
* Async import quote Excel into FIXED package detail prices; poll until done.
* @param {File|Blob} file
* @param {{ priceSetId: string|number, psvId?: string|number }} query
* @param {(task: object) => void} [onProgress]
* @returns {Promise<{ task: object }>}
*/
export async function importSetDetailPricesAsync(file, query, onProgress) {
const formData = new FormData()
formData.append('file', file)
const params = new URLSearchParams()
if (query && query.priceSetId != null) params.set('priceSetId', query.priceSetId)
if (query && query.psvId != null && query.psvId !== '') params.set('psvId', query.psvId)
const submitRes = await request({
url: '/price/set/detail/importPrices?' + params.toString(),
method: 'post',
data: formData,
headers: { 'Content-Type': 'multipart/form-data' }
})
const taskId = pickSaveTaskId(submitRes)
if (!taskId) {
throw new Error('missing import 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 || 'import failed')
err.task = task
throw err
}
await new Promise(resolve => setTimeout(resolve, 800))
}
throw new Error('import timeout')
}
export function updateSetDetail(data) {
return request({
url: '/price/set/detail',