增加专属报价功能
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
@click="handlePullLibrary"
|
||||
>拉取产品列表</el-button>
|
||||
<el-dropdown
|
||||
v-if="showImportAction && !isModifyImport"
|
||||
v-if="showImportAction && !isModifyImport && showCountryImport"
|
||||
trigger="click"
|
||||
@command="handleImportCommand"
|
||||
>
|
||||
@@ -48,6 +48,7 @@
|
||||
<p class="build-choice__tip">创建价格方式</p>
|
||||
<div class="build-choice__cards">
|
||||
<button
|
||||
v-if="!onlyImportFresh"
|
||||
type="button"
|
||||
class="build-card build-card--pull"
|
||||
:class="{ selected: isPullBuildMode(priceBuildMode) }"
|
||||
@@ -58,7 +59,7 @@
|
||||
<div class="build-card__desc">按产品库基础价生成套餐产品列表,可再导入 Excel 修改价格</div>
|
||||
</button>
|
||||
<button
|
||||
v-if="showImportInherit"
|
||||
v-if="showImportInherit && !onlyImportFresh"
|
||||
type="button"
|
||||
class="build-card build-card--import"
|
||||
:class="{ selected: isImportBuildMode(priceBuildMode) }"
|
||||
@@ -76,7 +77,7 @@
|
||||
@click="chooseBuildMode('IMPORT_FRESH')"
|
||||
>
|
||||
<div class="build-card__title">Excel 新建价</div>
|
||||
<div class="build-card__desc">不延用以前的产品价格,不带出上一版,上传 Excel 直接生成套餐销售价</div>
|
||||
<div class="build-card__desc">{{ importFreshCardDesc }}</div>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -227,9 +228,14 @@ import {
|
||||
surchargeAppliesToRow,
|
||||
toDetailPayload
|
||||
} from '../../utils/priceSet'
|
||||
import { getPriceSet, listSetDetailByProduct, listSetDetailByVersion, importSetDetailPricesAsync, pullSetDetailsFromLibraryAsync, previewPullFromLibrary, previewImportDetailPrices, updateSetDetail, updateSetDetailSurchargeAsync, delSetDetail } from '@/api/price/set'
|
||||
import { usePriceSetModule } from '../../composables/usePriceSetModule'
|
||||
import { listRegionOptions } from '@/api/data/region'
|
||||
|
||||
const mod = usePriceSetModule()
|
||||
const { api } = mod
|
||||
const onlyImportFresh = computed(() => !!mod.onlyImportFresh)
|
||||
const showCountryImport = computed(() => !mod.exclusiveQuote)
|
||||
|
||||
const props = defineProps({
|
||||
details: { type: Array, required: true },
|
||||
products: { type: Array, default: () => [] },
|
||||
@@ -326,7 +332,18 @@ const importActionLabel = computed(() =>
|
||||
isModifyImport.value ? '导入修改价格' : '导入 Excel 建价'
|
||||
)
|
||||
const importDialogTitle = computed(() => importActionLabel.value)
|
||||
const importFreshCardDesc = computed(() => onlyImportFresh.value
|
||||
? '仅支持大客折扣报价表(目的地/运费/操作费),导入后直接生成专属报价明细'
|
||||
: '不延用以前的产品价格,不带出上一版,上传 Excel 直接生成套餐销售价'
|
||||
)
|
||||
const importDesc = computed(() => {
|
||||
if (onlyImportFresh.value) {
|
||||
return [
|
||||
'\u4e13\u5c5e\u62a5\u4ef7\u4ec5\u652f\u6301\u5927\u5ba2\u6298\u6263\u62a5\u4ef7\u8868\uff08\u542b\u300c\u4ea7\u54c1\u76ee\u5f55\u300d\u4e0e\u5404\u56fd\u4ef7\u8868\uff09\u3002',
|
||||
'\u8868\u5934\u4e3a\u76ee\u7684\u5730 / \u91cd\u91cf\u6bb5 / \u8fd0\u8d39(CNY/KG) / \u64cd\u4f5c\u8d39(CNY/PCS)\uff0c\u4e0e\u666e\u901a\u5957\u9910 Excel \u6a21\u677f\u4e0d\u540c\u3002',
|
||||
'\u4ec5\u300cExcel \u65b0\u5efa\u4ef7\u300d\uff1a\u4e0d\u62c9\u53d6\u4ea7\u54c1\u5e93\u3001\u4e0d\u5ef6\u7528\u4e0a\u4e00\u7248\uff0c\u5bfc\u5165\u540e\u76f4\u63a5\u751f\u6210\u9500\u552e\u4ef7\u660e\u7ec6\u3002'
|
||||
]
|
||||
}
|
||||
if (isModifyImport.value) {
|
||||
return [
|
||||
'适用威狮B2C小包价表(含「产品目录」)。',
|
||||
@@ -377,7 +394,7 @@ async function resolvePsvId(force) {
|
||||
return resolvedPsvId.value
|
||||
}
|
||||
if (!props.priceSetId) return null
|
||||
const res = await getPriceSet(props.priceSetId)
|
||||
const res = await api.getPriceSet(props.priceSetId)
|
||||
const data = res.data || {}
|
||||
const versions = data.versions || []
|
||||
const fromData = (data.version && data.version.psvId) ? data.version : null
|
||||
@@ -420,7 +437,7 @@ async function loadLatestPriorVersionDraft() {
|
||||
if (!props.priceSetId) return false
|
||||
pulling.value = true
|
||||
try {
|
||||
const res = await getPriceSet(props.priceSetId)
|
||||
const res = await api.getPriceSet(props.priceSetId)
|
||||
const data = res.data || {}
|
||||
const versions = data.versions || []
|
||||
// Only exclude the draft being edited. Do NOT use resolvedPsvId — it may
|
||||
@@ -437,7 +454,7 @@ async function loadLatestPriorVersionDraft() {
|
||||
return row
|
||||
})
|
||||
if (!products.length) return false
|
||||
const detailRes = await listSetDetailByVersion(prior.psvId)
|
||||
const detailRes = await api.listSetDetailByVersion(prior.psvId)
|
||||
applyLocalDraft(products, detailRes.data || [])
|
||||
return true
|
||||
} finally {
|
||||
@@ -455,7 +472,7 @@ async function loadProductDetails(productCode, force) {
|
||||
}
|
||||
const psvId = await resolvePsvId(false)
|
||||
if (!psvId) return []
|
||||
const res = await listSetDetailByProduct(psvId, productCode)
|
||||
const res = await api.listSetDetailByProduct(psvId, productCode)
|
||||
const rows = (res.data || []).map(d => hydrateRow(d, props.setType))
|
||||
detailByProduct[productCode] = rows
|
||||
// keep parent details array in sync for any legacy callers
|
||||
@@ -586,6 +603,18 @@ async function canOpenImport() {
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
watch(
|
||||
() => [onlyImportFresh.value, props.priceBuildMode, props.buildModeReady],
|
||||
() => {
|
||||
if (!onlyImportFresh.value || !props.buildModeReady) return
|
||||
if (props.priceBuildMode) return
|
||||
if (buildModeLocked.value) return
|
||||
emit('update:priceBuildMode', 'IMPORT_FRESH')
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
async function openImport() {
|
||||
if (!(await canOpenImport())) return
|
||||
importRef.value && importRef.value.open()
|
||||
@@ -625,7 +654,7 @@ async function runImportAsync(uploadFile, countryCode) {
|
||||
}
|
||||
const replaceByProductCountry = !isModifyImport.value || !!countryCode
|
||||
if (!props.livePersist) {
|
||||
const res = await previewImportDetailPrices(files, {
|
||||
const res = await api.previewImportDetailPrices(files, {
|
||||
updateOnly: isModifyImport.value && !countryCode,
|
||||
replaceByProductCountry,
|
||||
countryCode: countryCode || undefined,
|
||||
@@ -640,7 +669,7 @@ async function runImportAsync(uploadFile, countryCode) {
|
||||
applyLocalDraft(products, data.details || [])
|
||||
return data.message || '导入完成'
|
||||
}
|
||||
const { task } = await importSetDetailPricesAsync(
|
||||
const { task } = await api.importSetDetailPricesAsync(
|
||||
files,
|
||||
{
|
||||
priceSetId: props.priceSetId,
|
||||
@@ -693,7 +722,7 @@ async function reloadDetailsFromServer() {
|
||||
if (!props.priceSetId) return
|
||||
try {
|
||||
clearDetailCache()
|
||||
const res = await getPriceSet(props.priceSetId)
|
||||
const res = await api.getPriceSet(props.priceSetId)
|
||||
const data = res.data || {}
|
||||
const versions = data.versions || []
|
||||
const qPsv = resolvedPsvId.value || props.psvId
|
||||
@@ -754,7 +783,7 @@ async function pullAllFromLibrary(opts = {}) {
|
||||
if (!props.livePersist) {
|
||||
importProgressMessage.value = '正在拉取产品库…'
|
||||
importProgressPercent.value = 40
|
||||
const res = await previewPullFromLibrary()
|
||||
const res = await api.previewPullFromLibrary()
|
||||
const data = res.data || {}
|
||||
applyLocalDraft(data.products || [], data.details || [])
|
||||
importProgressPercent.value = 100
|
||||
@@ -764,7 +793,7 @@ async function pullAllFromLibrary(opts = {}) {
|
||||
}
|
||||
return { added: (props.products || []).length }
|
||||
}
|
||||
const { task } = await pullSetDetailsFromLibraryAsync(
|
||||
const { task } = await api.pullSetDetailsFromLibraryAsync(
|
||||
{ priceSetId: props.priceSetId, psvId: await resolvePsvId(false), force },
|
||||
applyBuildProgress
|
||||
)
|
||||
@@ -864,7 +893,7 @@ async function persistDetail(row, withSurcharge) {
|
||||
const payload = toDetailPayload(row)
|
||||
payload.priceSetId = props.priceSetId
|
||||
if (!withSurcharge) delete payload.surcharges
|
||||
await updateSetDetail(payload)
|
||||
await api.updateSetDetail(payload)
|
||||
}
|
||||
|
||||
/** drawer hover remove surcharge -> write snapshot for this row */
|
||||
@@ -1035,7 +1064,7 @@ function onSurchargeConfirm(picked) {
|
||||
return
|
||||
}
|
||||
proxy.$modal.msgSuccess(okText + ',正在后台写入…')
|
||||
updateSetDetailSurchargeAsync(payload).then(() => {
|
||||
api.updateSetDetailSurchargeAsync(payload).then(() => {
|
||||
proxy.$modal.msgSuccess(okText + ',已写入数据库')
|
||||
}).catch(e => {
|
||||
proxy.$modal.msgError((e && e.message) ? e.message : '附加费后台写入失败')
|
||||
@@ -1048,7 +1077,7 @@ async function removeProduct(code) {
|
||||
const rows = await loadProductDetails(code)
|
||||
const ids = rows.filter(d => d && d.psdId).map(d => d.psdId)
|
||||
if (ids.length) {
|
||||
await delSetDetail(ids.join(','))
|
||||
await api.delSetDetail(ids.join(','))
|
||||
}
|
||||
} catch (e) {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user