重构打单套餐相关逻辑,更新服务接口,优化保存和查询功能
This commit is contained in:
@@ -7,6 +7,28 @@
|
||||
<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
|
||||
v-if="canStartPackage"
|
||||
type="success"
|
||||
v-hasPermi="['price:label:edit']"
|
||||
@click="startPackage"
|
||||
>启动套餐</el-button>
|
||||
<el-button
|
||||
v-if="setInfo.status === 'E'"
|
||||
type="danger"
|
||||
plain
|
||||
v-hasPermi="['price:label:edit']"
|
||||
@click="onDisablePackage"
|
||||
>停用</el-button>
|
||||
<el-button
|
||||
v-if="setInfo.status === 'S'"
|
||||
type="success"
|
||||
plain
|
||||
v-hasPermi="['price:label:edit']"
|
||||
@click="onEnablePackage"
|
||||
>启用</el-button>
|
||||
</template>
|
||||
</el-page-header>
|
||||
|
||||
<set-customer-table :set="setInfo" @refresh="loadHeader" />
|
||||
@@ -14,6 +36,7 @@
|
||||
<label-version-table
|
||||
:versions="versions"
|
||||
@edit="openEditVersion"
|
||||
@activate="openActivate"
|
||||
@reschedule="openReschedule"
|
||||
@remove="removeVersion"
|
||||
@open-details="openVersionDetails"
|
||||
@@ -29,7 +52,7 @@
|
||||
|
||||
<el-dialog
|
||||
v-model="activateVisible"
|
||||
title="修改生效时间"
|
||||
:title="activateDialogTitle"
|
||||
width="460px"
|
||||
append-to-body
|
||||
@closed="onActivateClosed"
|
||||
@@ -48,11 +71,11 @@
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
<div class="activate-hint">仅待生效版本可修改;精确到小时。未到生效时间仍为待生效,到时自动按生效处理。</div>
|
||||
<div class="activate-hint">{{ activateDialogHint }}</div>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="activateVisible = false">取消</el-button>
|
||||
<el-button type="primary" :loading="activateSubmitting" @click="submitActivate">确认修改</el-button>
|
||||
<el-button type="primary" :loading="activateSubmitting" @click="submitActivate">{{ activateConfirmText }}</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
@@ -64,6 +87,8 @@ import {
|
||||
listLabelVersions,
|
||||
activateLabelVersion,
|
||||
deleteLabelVersion,
|
||||
enableLabelPackage,
|
||||
disableLabelPackage,
|
||||
listLabelCustomer,
|
||||
addLabelCustomer,
|
||||
batchAddLabelCustomer,
|
||||
@@ -135,14 +160,66 @@ const setStatusTag = computed(() => {
|
||||
return map[setInfo.status] || 'info'
|
||||
})
|
||||
|
||||
/** 待启动:有待生效且未设生效时间的版本 */
|
||||
const startableVersion = computed(() =>
|
||||
(versions.value || []).find(v => v && String(v.status) === '0' && !v.effectiveTime)
|
||||
)
|
||||
const canStartPackage = computed(() =>
|
||||
setInfo.status !== 'E' && setInfo.status !== 'S' && !!startableVersion.value
|
||||
)
|
||||
|
||||
function startPackage() {
|
||||
const row = startableVersion.value
|
||||
if (!row) {
|
||||
proxy.$modal.msgWarning('没有可启动的版本,请先导入价卡')
|
||||
return
|
||||
}
|
||||
openActivate(row)
|
||||
}
|
||||
|
||||
function onDisablePackage() {
|
||||
if (!priceSetId.value) return
|
||||
const name = setInfo.priceSetName || ''
|
||||
proxy.$modal.confirm('停用后该打单套餐不再参与计费命中,确认停用【' + name + '】?').then(() => {
|
||||
return disableLabelPackage(priceSetId.value)
|
||||
}).then(() => {
|
||||
proxy.$modal.msgSuccess('已停用')
|
||||
reloadAll()
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
function onEnablePackage() {
|
||||
if (!priceSetId.value) return
|
||||
const name = setInfo.priceSetName || ''
|
||||
proxy.$modal.confirm('启用后该打单套餐将重新参与计费命中,确认启用【' + name + '】?').then(() => {
|
||||
return enableLabelPackage(priceSetId.value)
|
||||
}).then(() => {
|
||||
proxy.$modal.msgSuccess('已启用')
|
||||
reloadAll()
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
const activateVisible = ref(false)
|
||||
const activateSubmitting = ref(false)
|
||||
const activateFormRef = ref()
|
||||
/** activate=启动(首次设生效时间);reschedule=修改已设时间 */
|
||||
const activateMode = ref('activate')
|
||||
const activateForm = reactive({
|
||||
versionNo: null,
|
||||
versionLabel: '',
|
||||
effectiveTime: undefined
|
||||
})
|
||||
const activateDialogTitle = computed(() =>
|
||||
activateMode.value === 'reschedule' ? '修改生效时间' : '启动版本'
|
||||
)
|
||||
const activateConfirmText = computed(() =>
|
||||
activateMode.value === 'reschedule' ? '确认修改' : '确认启动'
|
||||
)
|
||||
const activateDialogHint = computed(() =>
|
||||
activateMode.value === 'reschedule'
|
||||
? '仅待生效版本可修改;精确到小时。未到生效时间仍为待生效,到时自动按生效处理。'
|
||||
: '启动时设置生效时间;精确到小时。若晚于当前则为待生效,到时自动生效并使套餐进入生效状态。'
|
||||
)
|
||||
const activateRules = {
|
||||
effectiveTime: [{ required: true, message: '请选择生效时间', trigger: 'change' }]
|
||||
}
|
||||
@@ -223,18 +300,41 @@ function toHourValue(val) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
function openReschedule(row) {
|
||||
function formatNowHour() {
|
||||
const d = new Date()
|
||||
const pad = n => String(n).padStart(2, '0')
|
||||
return d.getFullYear() + '-' + pad(d.getMonth() + 1) + '-' + pad(d.getDate())
|
||||
+ ' ' + pad(d.getHours()) + ':00:00'
|
||||
}
|
||||
|
||||
function openActivateDialog(row, mode) {
|
||||
activateMode.value = mode
|
||||
activateForm.versionNo = row.versionNo
|
||||
activateForm.versionLabel = row.versionLabel || ('V' + row.versionNo)
|
||||
activateForm.effectiveTime = row.effectiveTime ? toHourValue(row.effectiveTime) : undefined
|
||||
if (mode === 'reschedule' && row.effectiveTime) {
|
||||
activateForm.effectiveTime = toHourValue(row.effectiveTime)
|
||||
} else {
|
||||
activateForm.effectiveTime = formatNowHour()
|
||||
}
|
||||
activateVisible.value = true
|
||||
}
|
||||
|
||||
/** 首次启动:设置生效时间 */
|
||||
function openActivate(row) {
|
||||
openActivateDialog(row, 'activate')
|
||||
}
|
||||
|
||||
/** 已设生效时间后修改 */
|
||||
function openReschedule(row) {
|
||||
openActivateDialog(row, 'reschedule')
|
||||
}
|
||||
|
||||
function onActivateClosed() {
|
||||
activateForm.versionNo = null
|
||||
activateForm.versionLabel = ''
|
||||
activateForm.effectiveTime = undefined
|
||||
activateSubmitting.value = false
|
||||
activateMode.value = 'activate'
|
||||
}
|
||||
|
||||
function submitActivate() {
|
||||
@@ -245,7 +345,8 @@ function submitActivate() {
|
||||
effectiveTime: activateForm.effectiveTime
|
||||
}).then(res => {
|
||||
const data = res.data || {}
|
||||
proxy.$modal.msgSuccess(data.message || res.msg || '操作成功')
|
||||
const fallback = activateMode.value === 'reschedule' ? '生效时间已修改' : '版本已启动'
|
||||
proxy.$modal.msgSuccess(data.message || res.msg || fallback)
|
||||
activateVisible.value = false
|
||||
reloadAll()
|
||||
}).finally(() => {
|
||||
@@ -262,6 +363,9 @@ watch(priceSetId, async (id) => {
|
||||
|
||||
<style scoped>
|
||||
.page-header { margin-bottom: 16px; }
|
||||
.page-header :deep(.el-page-header__extra) {
|
||||
margin-left: auto;
|
||||
}
|
||||
.title { font-weight: 600; margin-right: 8px; }
|
||||
.code-tag { margin-right: 8px; }
|
||||
.status-tag { margin-left: 8px; }
|
||||
|
||||
Reference in New Issue
Block a user