Implement product Excel file import functionality, including new service methods for handling Excel attachments. Update the ProductController to list imported Excel files by product code. Enhance BmsProduct and related entities to store references to the imported Excel files. Update front-end components to support displaying and managing Excel file attachments for products.
This commit is contained in:
@@ -182,7 +182,7 @@ const props = defineProps({
|
||||
buildModeDirty: { type: Boolean, default: false }
|
||||
})
|
||||
|
||||
const emit = defineEmits(['update:psvId', 'update:priceBuildMode'])
|
||||
const emit = defineEmits(['update:psvId', 'update:priceBuildMode', 'update:pefId'])
|
||||
const { proxy } = getCurrentInstance()
|
||||
const { bms_tax_mode } = useDict('bms_tax_mode')
|
||||
const { hydrateRow } = useDetailCascade(props.refData)
|
||||
@@ -447,6 +447,9 @@ async function runImportAsync(uploadFile) {
|
||||
details: isModifyImport.value ? (props.details || []) : undefined
|
||||
})
|
||||
const data = res.data || {}
|
||||
if (data.pefId != null) {
|
||||
emit('update:pefId', data.pefId)
|
||||
}
|
||||
const products = isModifyImport.value ? (props.products || []) : (data.products || [])
|
||||
applyLocalDraft(products, data.details || [])
|
||||
importProgressPercent.value = 100
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
:set-type="form.basic.setType"
|
||||
:price-build-mode="form.version.priceBuildMode"
|
||||
@update:price-build-mode="onPriceBuildModeUpdate"
|
||||
@update:pef-id="v => { draftPefId.value = v }"
|
||||
:version-no="form.version.versionNo"
|
||||
:version-status="form.version.status"
|
||||
:ref-data="refData"
|
||||
@@ -110,6 +111,8 @@ const form = reactive({
|
||||
products: [],
|
||||
customers: []
|
||||
})
|
||||
/** Draft IMPORT Excel attachment id; stamped onto prc_price_set_product on finish */
|
||||
const draftPefId = ref(undefined)
|
||||
const savedPriceBuildMode = ref(undefined)
|
||||
const savedProductsSnapshot = ref([])
|
||||
const buildModeDirty = computed(() =>
|
||||
@@ -298,6 +301,9 @@ function buildPayload(opts = {}) {
|
||||
priceBuildMode: version.priceBuildMode || undefined
|
||||
}
|
||||
}
|
||||
if (draftPefId.value != null) {
|
||||
payload.pefId = draftPefId.value
|
||||
}
|
||||
if (opts.forceDetails || hasUnsavedDetail) {
|
||||
payload.details = detailRows.map(d => {
|
||||
const p = toDetailPayload(d)
|
||||
@@ -343,6 +349,9 @@ function onPriceBuildModeUpdate(mode) {
|
||||
savedProductsSnapshot.value = (form.products || []).map(p => ({ ...p }))
|
||||
}
|
||||
form.version.priceBuildMode = mode
|
||||
if (mode !== 'IMPORT') {
|
||||
draftPefId.value = undefined
|
||||
}
|
||||
form.details.splice(0, form.details.length)
|
||||
if (detailsRef.value && detailsRef.value.clearLocalDraft) {
|
||||
detailsRef.value.clearLocalDraft()
|
||||
@@ -408,6 +417,7 @@ function applySetData(data, asCopy, asNewVersion) {
|
||||
form.version.expireTime = undefined
|
||||
form.version.status = undefined
|
||||
form.version.priceBuildMode = undefined
|
||||
draftPefId.value = undefined
|
||||
savedPriceBuildMode.value = undefined
|
||||
form.details = []
|
||||
form.products = []
|
||||
@@ -419,6 +429,7 @@ function applySetData(data, asCopy, asNewVersion) {
|
||||
form.version.expireTime = undefined
|
||||
form.version.status = current.status || '0'
|
||||
form.version.priceBuildMode = undefined
|
||||
draftPefId.value = undefined
|
||||
savedPriceBuildMode.value = undefined
|
||||
form.details = []
|
||||
form.products = []
|
||||
@@ -429,6 +440,7 @@ function applySetData(data, asCopy, asNewVersion) {
|
||||
form.version.expireTime = current.expireTime
|
||||
form.version.status = current.status
|
||||
form.version.priceBuildMode = current.priceBuildMode || undefined
|
||||
draftPefId.value = undefined
|
||||
savedPriceBuildMode.value = current.priceBuildMode || undefined
|
||||
form.details = []
|
||||
form.products = (current.products || []).map(p => ({ ...p }))
|
||||
|
||||
Reference in New Issue
Block a user