套餐启用增加生效时间

This commit is contained in:
wuweihua
2026-09-17 14:42:48 +08:00
parent 51c8013cd9
commit f3ef2df949
25 changed files with 684 additions and 287 deletions
+93 -5
View File
@@ -35,6 +35,34 @@
:version="detailVersion"
:set-type="set.setType"
/>
<el-dialog
v-model="activateVisible"
:title="activateTitle"
width="460px"
append-to-body
@closed="onActivateClosed"
>
<el-form ref="activateFormRef" :model="activateForm" :rules="activateRules" label-width="100px">
<el-form-item label="版本号">
<span>{{ activateForm.versionNo || '-' }}</span>
</el-form-item>
<el-form-item label="生效时间" prop="effectiveTime">
<el-date-picker
v-model="activateForm.effectiveTime"
type="datetime"
value-format="YYYY-MM-DD HH:mm:ss"
:placeholder="activatePh"
style="width: 100%"
/>
</el-form-item>
<div class="activate-hint">{{ activateHint }}</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>
</template>
</div>
</template>
@@ -92,13 +120,59 @@ function confirmAction(text, request, successText, done) {
function onDisable() {
confirmAction('停用后不再参与计费命中,确认停用?', () => disablePriceSet(set.value.priceSetId), '已停用')
}
function formatNow() {
const d = new Date()
const p = n => String(n).padStart(2, '0')
return d.getFullYear() + '-' + p(d.getMonth() + 1) + '-' + p(d.getDate())
+ ' ' + p(d.getHours()) + ':' + p(d.getMinutes()) + ':' + p(d.getSeconds())
}
const activateVisible = ref(false)
const activateSubmitting = ref(false)
const activateFormRef = ref()
const activateTitle = '启动版本'
const activatePh = '请选择生效时间'
const activateHint = '若生效时间晚于当前,版本将进入「待生效」;到时自动生效并使上一版本失效。'
const activateForm = reactive({
psvId: undefined,
versionNo: '',
effectiveTime: undefined
})
const activateRules = {
effectiveTime: [{ required: true, message: '请选择生效时间', trigger: 'change' }]
}
function onActivateVersion(row) {
if (!row || row.psvId == null) return
confirmAction(
'确认启动版本 ' + (row.versionNo || '') + '?启动后将以当前时间生效,上一版本自动失效。',
() => activatePriceSetVersion(row.psvId),
'版本已启动'
)
activateForm.psvId = row.psvId
activateForm.versionNo = row.versionNo || ''
activateForm.effectiveTime = formatNow()
activateVisible.value = true
}
function onActivateClosed() {
activateForm.psvId = undefined
activateForm.versionNo = ''
activateForm.effectiveTime = undefined
activateFormRef.value && activateFormRef.value.clearValidate()
}
function submitActivate() {
activateFormRef.value.validate(valid => {
if (!valid) return
activateSubmitting.value = true
activatePriceSetVersion(activateForm.psvId, { effectiveTime: activateForm.effectiveTime })
.then(() => {
const eff = activateForm.effectiveTime
const pending = eff && new Date(eff.replace(/-/g, '/')).getTime() > Date.now()
proxy.$modal.msgSuccess(pending ? '已设为待生效' : '版本已启动')
activateVisible.value = false
load()
})
.finally(() => {
activateSubmitting.value = false
})
})
}
function onCopy() {
copyPriceSet(set.value.priceSetId).then(res => {
@@ -108,6 +182,11 @@ function onCopy() {
}
function onCopyVersion(row) {
if (!row || row.psvId == null) return
const hasDraft = (set.value.versions || []).some(v => v && String(v.status) === '0')
if (hasDraft) {
proxy.$modal.msgWarning('已有草稿版本,请先启动或删除后再复制')
return
}
proxy.$modal.confirm(
'确认复制版本 ' + (row.versionNo || '') + '为新草稿?将新增版本并拷贝全部明细。'
).then(() => copyPriceSetVersion(row.psvId)).then(res => {
@@ -153,3 +232,12 @@ onMounted(() => {
load()
})
</script>
<style scoped>
.activate-hint {
margin: -4px 0 0 100px;
color: #909399;
font-size: 12px;
line-height: 1.5;
}
</style>