增加专属报价功能
This commit is contained in:
@@ -34,7 +34,7 @@
|
||||
|
||||
<el-dialog
|
||||
v-model="progressVisible"
|
||||
:title="'正在保存套餐'"
|
||||
:title="mod.labels.saveProgressTitle"
|
||||
width="420px"
|
||||
:close-on-click-modal="false"
|
||||
:close-on-press-escape="false"
|
||||
@@ -61,7 +61,9 @@ import {
|
||||
toCustomerPayload,
|
||||
toDetailPayload
|
||||
} from './utils/priceSet'
|
||||
import { getPriceSet, savePriceSetAsync, createPriceSetVersion, deletePriceSetVersion } from '@/api/price/set'
|
||||
import { usePriceSetModule } from './composables/usePriceSetModule'
|
||||
|
||||
const mod = usePriceSetModule()
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
const route = useRoute()
|
||||
@@ -131,7 +133,7 @@ async function runSaveWithProgress(payload) {
|
||||
progressMessage.value = ''
|
||||
progressStatus.value = undefined
|
||||
try {
|
||||
const result = await savePriceSetAsync(payload, (task) => {
|
||||
const result = await mod.api.savePriceSetAsync(payload, (task) => {
|
||||
progressPercent.value = Math.min(100, Number(task.percent) || 0)
|
||||
progressMessage.value = mapSaveProgressMessage(task.message)
|
||||
if (task.status === 'FAIL') {
|
||||
@@ -204,7 +206,7 @@ async function finishEdit() {
|
||||
proxy.$modal.msgSuccess("修改已实时落库")
|
||||
}
|
||||
const obj = {
|
||||
path: '/customer/setDetail',
|
||||
path: mod.routes.detail,
|
||||
query: { priceSetId: form.priceSetId }
|
||||
}
|
||||
if (proxy.$tab) {
|
||||
@@ -230,7 +232,7 @@ async function finishEdit() {
|
||||
creating.value = true
|
||||
try {
|
||||
if (newVersionMode.value && form.version.psvId == null && form.priceSetId) {
|
||||
const verRes = await createPriceSetVersion(form.priceSetId)
|
||||
const verRes = await mod.api.createPriceSetVersion(form.priceSetId)
|
||||
if (verRes.data != null) {
|
||||
form.version.psvId = verRes.data
|
||||
}
|
||||
@@ -238,9 +240,9 @@ async function finishEdit() {
|
||||
const payload = buildPayload({ forceDetails: true })
|
||||
const priceSetId = await runSaveWithProgress(payload)
|
||||
form.priceSetId = priceSetId
|
||||
proxy.$modal.msgSuccess('套餐已保存')
|
||||
proxy.$modal.msgSuccess(mod.labels.savedSuccess)
|
||||
const obj = {
|
||||
path: '/customer/setDetail',
|
||||
path: mod.routes.detail,
|
||||
query: { priceSetId }
|
||||
}
|
||||
if (proxy.$tab) {
|
||||
@@ -305,14 +307,14 @@ async function tryDeleteEmptyNewVersionDraft() {
|
||||
if (!newVersionMode.value || !form.priceSetId || form.version.psvId == null) return
|
||||
const psvId = form.version.psvId
|
||||
try {
|
||||
const res = await getPriceSet(form.priceSetId)
|
||||
const res = await mod.api.getPriceSet(form.priceSetId)
|
||||
const versions = (res.data || {}).versions || []
|
||||
const v = versions.find(x => x && String(x.psvId) === String(psvId))
|
||||
if (!v || String(v.status) !== '0') return
|
||||
const noMode = !v.priceBuildMode
|
||||
const noDetails = !(Number(v.detailCount) > 0) && !(v.details || []).length
|
||||
if (noMode && noDetails) {
|
||||
await deletePriceSetVersion(psvId)
|
||||
await mod.api.deletePriceSetVersion(psvId)
|
||||
}
|
||||
} catch (e) {
|
||||
// ignore cleanup errors; still navigate back
|
||||
@@ -322,8 +324,8 @@ async function tryDeleteEmptyNewVersionDraft() {
|
||||
async function goBack() {
|
||||
await tryDeleteEmptyNewVersionDraft()
|
||||
const obj = (newVersionMode.value || copyMode.value) && form.priceSetId
|
||||
? { path: '/customer/setDetail', query: { priceSetId: form.priceSetId } }
|
||||
: { path: '/customer/set' }
|
||||
? { path: mod.routes.detail, query: { priceSetId: form.priceSetId } }
|
||||
: { path: mod.routes.list }
|
||||
if (proxy.$tab) {
|
||||
proxy.$tab.closeOpenPage(obj)
|
||||
} else {
|
||||
@@ -418,7 +420,7 @@ function onPriceBuildModeUpdate(mode) {
|
||||
}
|
||||
|
||||
function reloadSavedProductsForCreate() {
|
||||
getPriceSet(form.priceSetId).then(res => {
|
||||
mod.api.getPriceSet(form.priceSetId).then(res => {
|
||||
const data = res.data || {}
|
||||
const versions = data.versions || []
|
||||
const qPsv = form.version.psvId
|
||||
@@ -433,7 +435,7 @@ function reloadSavedProductsForCreate() {
|
||||
|
||||
async function refreshProductsFromCurrentVersion() {
|
||||
if (!form.priceSetId) return
|
||||
const res = await getPriceSet(form.priceSetId)
|
||||
const res = await mod.api.getPriceSet(form.priceSetId)
|
||||
const data = res.data || {}
|
||||
const versions = data.versions || []
|
||||
const qPsv = form.version.psvId
|
||||
@@ -520,7 +522,7 @@ function applySetData(data, asCopy, asNewVersion) {
|
||||
|
||||
function loadExisting(id, asCopy, asNewVersion) {
|
||||
pageReady.value = false
|
||||
return getPriceSet(id).then(res => {
|
||||
return mod.api.getPriceSet(id).then(res => {
|
||||
applySetData(res.data || {}, asCopy, asNewVersion)
|
||||
}).finally(() => {
|
||||
pageReady.value = true
|
||||
|
||||
Reference in New Issue
Block a user