修改套餐价格

This commit is contained in:
wuweihua
2026-09-16 17:14:19 +08:00
parent 7172621fd3
commit 4441aa12bf
48 changed files with 4258 additions and 682 deletions
+68 -39
View File
@@ -3,62 +3,72 @@
<set-detail-header
:set="set"
@back="goList"
@edit="goEdit"
@submit="onSubmit"
@approve="onApprove"
@reject="onReject"
@disable="onDisable"
@copy="onCopy"
/>
<set-basic-info-card :set="set" />
<set-detail-table :set="set" :ref-data="refData" @refresh="load" />
<set-customer-table :set="set" />
<set-customer-table :set="set" @refresh="load" />
<set-version-table
v-model="currentPsvId"
:versions="set.versions || []"
@copy-version="onCopyVersion"
@open-details="onOpenVersionDetails"
@activate="onActivateVersion"
@edit="onEditVersion"
@remove="onRemoveVersion"
/>
<set-version-detail-drawer
v-model="detailDrawerVisible"
:version="detailVersion"
:set-type="set.setType"
/>
</div>
</template>
<script setup name="PriceSetDetail">
/**
* 套餐详情 · 页面编排
*
* 展示区拆到 components/:页头、基本信息、明细表(含明细弹窗)、客户表(含客户弹窗);
* 本页只负责:加载详情、状态流转操作、向子组件下发共享参考数据。
*/
import SetDetailHeader from './components/detail/SetDetailHeader.vue'
import SetBasicInfoCard from './components/detail/SetBasicInfoCard.vue'
import SetDetailTable from './components/detail/SetDetailTable.vue'
import SetCustomerTable from './components/detail/SetCustomerTable.vue'
import SetVersionTable from './components/detail/SetVersionTable.vue'
import SetVersionDetailDrawer from './components/detail/SetVersionDetailDrawer.vue'
import { usePriceSetRefData } from './composables/usePriceSetRefData'
import {
getPriceSet, submitPriceSet, approvePriceSet, rejectPriceSet, disablePriceSet, copyPriceSet
getPriceSet, disablePriceSet, copyPriceSet, activatePriceSetVersion, copyPriceSetVersion, deletePriceSetVersion
} from '@/api/price/set'
const { proxy } = getCurrentInstance()
const route = useRoute()
/** 产品 / 国家 / 附加费 参考数据与明细弹窗级联共用,与新建页同一套实现 */
const refData = usePriceSetRefData()
const loading = ref(false)
const set = ref({})
const currentPsvId = ref()
const detailDrawerVisible = ref(false)
const detailVersion = ref(null)
function onOpenVersionDetails(row) {
detailVersion.value = row || null
detailDrawerVisible.value = true
}
/** 拉取套餐详情,并预取明细涉及产品的附加费 */
function load() {
const id = route.query.priceSetId
if (!id) return
loading.value = true
getPriceSet(id).then(res => {
set.value = res.data || {}
const codes = [...new Set((set.value.details || []).map(d => d.productCode).filter(Boolean))]
codes.forEach(code => refData.ensureSurcharges(code))
const versions = set.value.versions || []
const cur = set.value.version || versions[0]
currentPsvId.value = cur ? cur.psvId : undefined
}).finally(() => {
loading.value = false
})
}
/** 二次确认 -> 调接口 -> 提示 -> 刷新(或跳转) */
function confirmAction(text, request, successText, done) {
proxy.$modal.confirm(text).then(() => request()).then(() => {
proxy.$modal.msgSuccess(successText)
@@ -66,30 +76,53 @@ function confirmAction(text, request, successText, done) {
}).catch(() => {})
}
function onSubmit() {
confirmAction('确认提交审核?', () => submitPriceSet(set.value.priceSetId), '已提交审核')
}
function onApprove() {
confirmAction('确认审批生效?', () => approvePriceSet(set.value.priceSetId), '套餐已生效')
}
function onReject() {
confirmAction('确认驳回该套餐?', () => rejectPriceSet(set.value.priceSetId), '已驳回')
}
function onDisable() {
confirmAction('停用后不再参与计费命中,确认停用?', () => disablePriceSet(set.value.priceSetId), '已停用')
}
/** 复用新建:复制为草稿后跳转到新建页 */
function onActivateVersion(row) {
if (!row || row.psvId == null) return
confirmAction(
'确认启动版本 ' + (row.versionNo || '') + '?启动后将以当前时间生效,上一版本自动失效。',
() => activatePriceSetVersion(row.psvId),
'版本已启动'
)
}
function onCopy() {
copyPriceSet(set.value.priceSetId).then(res => {
proxy.$modal.msgSuccess('已复制为草稿')
proxy.$router.push({ path: '/customer/setCreate', query: { priceSetId: res.data } })
})
}
function onCopyVersion(row) {
if (!row || row.psvId == null) return
proxy.$modal.confirm(
'确认复制版本 ' + (row.versionNo || '') + '为新草稿?将新增版本并拷贝全部明细。'
).then(() => copyPriceSetVersion(row.psvId)).then(res => {
proxy.$modal.msgSuccess('已复制为新版本')
const newPsvId = res.data
load()
if (newPsvId != null) {
proxy.$router.push({
path: '/customer/setCreate',
query: { priceSetId: set.value.priceSetId, psvId: newPsvId, step: '2' }
})
}
}).catch(() => {})
}
function onRemoveVersion(row) {
if (!row || row.psvId == null) return
proxy.$modal.confirm(
'确认删除草稿版本 ' + (row.versionNo || '') + '?其明细与附加费将一并删除。'
).then(() => deletePriceSetVersion(row.psvId)).then(() => {
proxy.$modal.msgSuccess('版本已删除')
load()
}).catch(() => {})
}
function onEditVersion(row) {
const q = { priceSetId: set.value.priceSetId, step: '2' }
if (row && row.psvId != null) q.psvId = row.psvId
proxy.$router.push({ path: '/customer/setCreate', query: q })
}
function goList() {
const obj = { path: '/customer/set' }
if (proxy.$tab) {
@@ -99,10 +132,6 @@ function goList() {
}
}
function goEdit() {
proxy.$router.push({ path: '/customer/setCreate', query: { priceSetId: set.value.priceSetId } })
}
onMounted(() => {
refData.loadProducts()
load()