修改套餐导入功能
This commit is contained in:
@@ -210,7 +210,7 @@ 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, updateOnly?: boolean }} query
|
||||
* @param {{ priceSetId: string|number, psvId?: string|number, updateOnly?: boolean, replaceByProductCountry?: boolean, countryCode?: string }} query
|
||||
* @param {(task: object) => void} [onProgress]
|
||||
* @returns {Promise<{ task: object }>}
|
||||
*/
|
||||
@@ -221,6 +221,9 @@ export async function importSetDetailPricesAsync(file, query, onProgress) {
|
||||
if (query && query.priceSetId != null) params.set('priceSetId', query.priceSetId)
|
||||
if (query && query.psvId != null && query.psvId !== '') params.set('psvId', query.psvId)
|
||||
if (query && query.updateOnly) params.set('updateOnly', 'true')
|
||||
// Package Excel build-price only (product+country replace scope)
|
||||
if (query && query.replaceByProductCountry) params.set('replaceByProductCountry', 'true')
|
||||
if (query && query.countryCode) params.set('countryCode', query.countryCode)
|
||||
const submitRes = await request({
|
||||
url: '/price/set/detail/importPrices?' + params.toString(),
|
||||
method: 'post',
|
||||
@@ -247,20 +250,24 @@ export function previewPullFromLibrary() {
|
||||
/**
|
||||
* Preview Excel import (no DB write).
|
||||
* @param {File|Blob} file
|
||||
* @param {{ updateOnly?: boolean, details?: Array }} [opts]
|
||||
* @param {{ updateOnly?: boolean, replaceByProductCountry?: boolean, countryCode?: string, details?: Array }} [opts]
|
||||
*/
|
||||
export function previewImportDetailPrices(file, opts = {}) {
|
||||
const formData = new FormData()
|
||||
formData.append('file', file)
|
||||
if (opts.updateOnly) formData.append('updateOnly', 'true')
|
||||
if (opts.updateOnly && Array.isArray(opts.details)) {
|
||||
if (opts.replaceByProductCountry) formData.append('replaceByProductCountry', 'true')
|
||||
if (opts.countryCode) formData.append('countryCode', opts.countryCode)
|
||||
// updateOnly / Excel build-price merge need current draft details
|
||||
if ((opts.updateOnly || opts.replaceByProductCountry || opts.countryCode) && Array.isArray(opts.details)) {
|
||||
formData.append('detailsJson', JSON.stringify(opts.details))
|
||||
}
|
||||
return request({
|
||||
url: '/price/set/detail/previewImportPrices',
|
||||
method: 'post',
|
||||
data: formData,
|
||||
headers: { 'Content-Type': 'multipart/form-data' },
|
||||
// FormData must not go through repeat-submit JSON.stringify (collapses to "{}")
|
||||
headers: { 'Content-Type': 'multipart/form-data', repeatSubmit: false },
|
||||
timeout: 10 * 60 * 1000
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user