重构产品价和红线价功能
This commit is contained in:
@@ -26,7 +26,8 @@ export function savePriceSet(data) {
|
||||
export function getPriceSetSaveTask(taskId) {
|
||||
return request({
|
||||
url: '/price/set/save/task/' + taskId,
|
||||
method: 'get'
|
||||
method: 'get',
|
||||
timeout: 10 * 60 * 1000
|
||||
})
|
||||
}
|
||||
|
||||
@@ -222,9 +223,17 @@ export function addSetDetail(data) {
|
||||
* @param {(task: object) => void} [onProgress]
|
||||
* @returns {Promise<{ task: object }>}
|
||||
*/
|
||||
function appendUploadFiles(formData, file) {
|
||||
const list = Array.isArray(file) ? file : [file]
|
||||
for (const item of list) {
|
||||
const raw = item && (item.raw || item)
|
||||
if (raw) formData.append('files', raw)
|
||||
}
|
||||
}
|
||||
|
||||
export async function importSetDetailPricesAsync(file, query, onProgress) {
|
||||
const formData = new FormData()
|
||||
formData.append('file', file)
|
||||
appendUploadFiles(formData, 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)
|
||||
@@ -236,7 +245,7 @@ export async function importSetDetailPricesAsync(file, query, onProgress) {
|
||||
url: '/price/set/detail/importPrices?' + params.toString(),
|
||||
method: 'post',
|
||||
data: formData,
|
||||
headers: { 'Content-Type': 'multipart/form-data' }
|
||||
headers: { 'Content-Type': 'multipart/form-data', repeatSubmit: false }
|
||||
})
|
||||
const taskId = pickSaveTaskId(submitRes)
|
||||
if (!taskId) {
|
||||
@@ -262,7 +271,7 @@ export function previewPullFromLibrary() {
|
||||
*/
|
||||
export function previewImportDetailPrices(file, opts = {}) {
|
||||
const formData = new FormData()
|
||||
formData.append('file', file)
|
||||
appendUploadFiles(formData, file)
|
||||
if (opts.updateOnly) formData.append('updateOnly', 'true')
|
||||
if (opts.replaceByProductCountry) formData.append('replaceByProductCountry', 'true')
|
||||
if (opts.countryCode) formData.append('countryCode', opts.countryCode)
|
||||
|
||||
Reference in New Issue
Block a user