增加一个打单功能套餐

This commit is contained in:
wuweihua
2026-11-09 23:00:48 +08:00
parent 2632e5aa78
commit 16afa0d590
30 changed files with 3418 additions and 132 deletions
+255
View File
@@ -0,0 +1,255 @@
<template>
<div class="app-container">
<el-page-header class="page-header" @back="goBack">
<template #content>
<span class="title">{{ setInfo.priceSetName || '打单套餐详情' }}</span>
<el-tag v-if="setInfo.priceSetCode" size="small" class="code-tag">{{ setInfo.priceSetCode }}</el-tag>
<el-tag size="small" type="warning" effect="plain">打单 / LABEL</el-tag>
<el-tag v-if="setInfo.status" size="small" :type="setStatusTag" effect="plain" class="status-tag">{{ setStatusText }}</el-tag>
</template>
<template #extra>
<el-button type="primary" plain icon="Upload" @click="importRef.open()" v-hasPermi="['price:label:import']">导入价卡</el-button>
</template>
</el-page-header>
<set-customer-table :set="setInfo" @refresh="loadHeader" />
<label-version-table
:versions="versions"
@edit="openEditVersion"
@reschedule="openReschedule"
@open-details="openVersionDetails"
@create-version="openCreateVersion"
/>
<label-import-dialog ref="importRef" :price-set-id="priceSetId" @saved="reloadAll" />
<label-version-product-drawer
v-model:visible="productDrawerVisible"
:price-set-id="priceSetId"
:version="activeVersion"
@changed="reloadAll"
/>
<el-dialog
v-model="activateVisible"
title="修改生效时间"
width="460px"
append-to-body
@closed="onActivateClosed"
>
<el-form ref="activateFormRef" :model="activateForm" :rules="activateRules" label-width="100px">
<el-form-item label="版本号">
<span>{{ activateForm.versionLabel }}</span>
</el-form-item>
<el-form-item label="生效时间" prop="effectiveTime">
<el-date-picker
v-model="activateForm.effectiveTime"
type="date"
value-format="YYYY-MM-DD"
placeholder="请选择生效时间"
style="width: 100%"
/>
</el-form-item>
<div class="activate-hint">仅待生效版本可修改;未到生效日仍为待生效,到日后自动按生效处理。</div>
</el-form>
<template #footer>
<el-button @click="activateVisible = false">取消</el-button>
<el-button type="primary" :loading="activateSubmitting" @click="submitActivate">确认修改</el-button>
</template>
</el-dialog>
</div>
</template>
<script setup name="LabelPackageDetail">
import {
getLabelPackage,
listLabelVersions,
activateLabelVersion,
listLabelCustomer,
addLabelCustomer,
batchAddLabelCustomer,
updateLabelCustomer,
delLabelCustomer
} from '@/api/price/label'
import { priceSetApi } from '@/api/price/set'
import { providePriceSetModule } from '../set/composables/usePriceSetModule'
import SetCustomerTable from '../set/components/detail/SetCustomerTable.vue'
import LabelImportDialog from './components/LabelImportDialog.vue'
import LabelVersionTable from './components/LabelVersionTable.vue'
import LabelVersionProductDrawer from './components/LabelVersionProductDrawer.vue'
const labelModuleApi = {
...priceSetApi,
listSetCustomer: listLabelCustomer,
addSetCustomer: addLabelCustomer,
batchAddSetCustomer: batchAddLabelCustomer,
updateSetCustomer: updateLabelCustomer,
delSetCustomer: delLabelCustomer
}
providePriceSetModule({
api: labelModuleApi,
permPrefix: 'price:label',
exclusiveQuote: false,
onlyImportFresh: false,
routes: Object.freeze({
list: '/customer/label',
create: '/customer/labelCreate',
detail: '/customer/labelDetail'
}),
labels: Object.freeze({
entity: '打单套餐',
entityCode: '套餐编码',
entityName: '套餐名称',
createButton: '新建打单套餐',
saveProgressTitle: '正在保存打单套餐',
savedSuccess: '打单套餐已保存',
noActiveVersion: '该打单套餐暂无生效版本',
disableConfirm: '停用后该打单套餐不再参与计费命中,确认停用【{name}】?',
enableConfirm: '启用后该打单套餐将重新参与计费命中,确认启用【{name}】?',
basicEditTitle: '修改打单套餐基本信息',
keywordPlaceholder: '套餐编码 / 名称',
detailTitleFallback: '打单套餐详情'
})
})
const { proxy } = getCurrentInstance()
const route = useRoute()
const priceSetId = computed(() => Number(route.query.priceSetId) || null)
const setInfo = reactive({
priceSetId: null,
priceSetCode: '',
priceSetName: '',
priceSetNote: '',
status: '',
customers: []
})
const versions = ref([])
const importRef = ref()
const productDrawerVisible = ref(false)
const activeVersion = ref(null)
const setStatusText = computed(() => {
const map = { D: '待启用', A: '审核中', E: '生效', R: '驳回', S: '已停用' }
return map[setInfo.status] || setInfo.status || '-'
})
const setStatusTag = computed(() => {
const map = { D: 'info', A: 'warning', E: 'success', R: 'danger', S: 'info' }
return map[setInfo.status] || 'info'
})
const activateVisible = ref(false)
const activateSubmitting = ref(false)
const activateFormRef = ref()
const activateForm = reactive({
versionNo: null,
versionLabel: '',
effectiveTime: undefined
})
const activateRules = {
effectiveTime: [{ required: true, message: '请选择生效时间', trigger: 'change' }]
}
function goBack() {
proxy.$router.push('/customer/label')
}
async function loadHeader() {
if (!priceSetId.value) return
const res = await getLabelPackage(priceSetId.value)
const data = res.data || {}
setInfo.priceSetId = data.priceSetId
setInfo.priceSetCode = data.priceSetCode || ''
setInfo.priceSetName = data.priceSetName || ''
setInfo.priceSetNote = data.priceSetNote || ''
setInfo.status = data.status || ''
setInfo.customers = data.customers || []
}
async function loadVersions() {
if (!priceSetId.value) return
const res = await listLabelVersions(priceSetId.value)
versions.value = res.data || []
}
async function reloadAll() {
await loadHeader()
await loadVersions()
}
function openVersionDetails(row) {
activeVersion.value = row || null
productDrawerVisible.value = true
}
/** 跳转新建版本页;已有待生效版时按钮会禁用 */
function openCreateVersion() {
if (!priceSetId.value) return
if ((versions.value || []).some(v => String(v.status) === '0')) {
proxy.$modal.msgWarning('已有待生效版本,请先处理后再新建')
return
}
proxy.$router.push({
path: '/customer/labelCreate',
query: { priceSetId: priceSetId.value, newVersion: '1' }
})
}
/** 编辑待生效版本价卡 */
function openEditVersion(row) {
if (!priceSetId.value || !row?.versionNo) return
proxy.$router.push({
path: '/customer/labelCreate',
query: {
priceSetId: priceSetId.value,
versionNo: row.versionNo,
editVersion: '1'
}
})
}
function openReschedule(row) {
activateForm.versionNo = row.versionNo
activateForm.versionLabel = row.versionLabel || ('V' + row.versionNo)
activateForm.effectiveTime = row.effectiveTime ? String(row.effectiveTime).slice(0, 10) : undefined
activateVisible.value = true
}
function onActivateClosed() {
activateForm.versionNo = null
activateForm.versionLabel = ''
activateForm.effectiveTime = undefined
activateSubmitting.value = false
}
function submitActivate() {
activateFormRef.value?.validate(valid => {
if (!valid) return
activateSubmitting.value = true
activateLabelVersion(priceSetId.value, activateForm.versionNo, {
effectiveTime: activateForm.effectiveTime
}).then(res => {
const data = res.data || {}
proxy.$modal.msgSuccess(data.message || res.msg || '操作成功')
activateVisible.value = false
reloadAll()
}).finally(() => {
activateSubmitting.value = false
})
})
}
watch(priceSetId, async (id) => {
if (!id) return
await reloadAll()
}, { immediate: true })
</script>
<style scoped>
.page-header { margin-bottom: 16px; }
.title { font-weight: 600; margin-right: 8px; }
.code-tag { margin-right: 8px; }
.status-tag { margin-left: 8px; }
.activate-hint { margin: -4px 0 0 100px; color: #909399; font-size: 12px; line-height: 1.5; }
</style>