修改首页
This commit is contained in:
@@ -28,21 +28,14 @@
|
||||
<el-table-column :label="colRows" width="100" align="center">
|
||||
<template #default="{ row }">{{ detailCount(row) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="colAction" width="360" align="center" fixed="right">
|
||||
<el-table-column :label="colAction" width="380" align="center" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" @click="openDetails(row)">查看详情</el-button>
|
||||
<el-button
|
||||
v-if="isPriceEditableVersion(row)"
|
||||
v-if="showEditButton(row)"
|
||||
link
|
||||
type="primary"
|
||||
@click="emit('edit', row)"
|
||||
v-hasPermi="['price:set:edit']"
|
||||
>继续配置</el-button>
|
||||
<el-button
|
||||
link
|
||||
type="warning"
|
||||
@click="emit('edit', row)"
|
||||
v-hasPermi="['price:set:forceEdit']"
|
||||
>编辑</el-button>
|
||||
<el-button
|
||||
v-if="isDraftVersion(row)"
|
||||
@@ -51,6 +44,13 @@
|
||||
@click="emit('activate', row)"
|
||||
v-hasPermi="['price:set:edit']"
|
||||
>启动</el-button>
|
||||
<el-button
|
||||
v-if="isPendingVersion(row)"
|
||||
link
|
||||
type="primary"
|
||||
@click="emit('reschedule', row)"
|
||||
v-hasPermi="['price:set:edit']"
|
||||
>修改生效时间</el-button>
|
||||
<el-button
|
||||
v-if="isDraftVersion(row)"
|
||||
link
|
||||
@@ -73,13 +73,14 @@
|
||||
|
||||
<script setup name="SetVersionTable">
|
||||
import SetSectionCard from './SetSectionCard.vue'
|
||||
import { versionStatusLabel, versionStatusTag, isDraftVersion, isPriceEditableVersion } from '../../utils/priceSet'
|
||||
import { versionStatusLabel, versionStatusTag, isDraftVersion, isPendingVersion, isPriceEditableVersion } from '../../utils/priceSet'
|
||||
import { checkPermi } from '@/utils/permission'
|
||||
|
||||
const props = defineProps({
|
||||
versions: { type: Array, default: () => [] },
|
||||
modelValue: { type: [Number, String], default: undefined }
|
||||
})
|
||||
const emit = defineEmits(['update:modelValue', 'copy-version', 'open-details', 'activate', 'edit', 'remove'])
|
||||
const emit = defineEmits(['update:modelValue', 'copy-version', 'open-details', 'activate', 'reschedule', 'edit', 'remove'])
|
||||
|
||||
const title = '套餐版本'
|
||||
const colNo = '版本号'
|
||||
@@ -124,6 +125,11 @@ function detailCount(row) {
|
||||
return (row && row.details || []).length
|
||||
}
|
||||
|
||||
function showEditButton(row) {
|
||||
if (checkPermi(['price:set:forceEdit'])) return true
|
||||
return isPriceEditableVersion(row) && checkPermi(['price:set:edit'])
|
||||
}
|
||||
|
||||
function openDetails(row) {
|
||||
if (!row || row.psvId == null) return
|
||||
emit('update:modelValue', row.psvId)
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
@copy-version="onCopyVersion"
|
||||
@open-details="onOpenVersionDetails"
|
||||
@activate="onActivateVersion"
|
||||
@reschedule="onRescheduleVersion"
|
||||
@edit="onEditVersion"
|
||||
@remove="onRemoveVersion"
|
||||
/>
|
||||
@@ -38,7 +39,7 @@
|
||||
|
||||
<el-dialog
|
||||
v-model="activateVisible"
|
||||
:title="activateTitle"
|
||||
:title="activateDialogTitle"
|
||||
width="460px"
|
||||
append-to-body
|
||||
@closed="onActivateClosed"
|
||||
@@ -56,11 +57,11 @@
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
<div class="activate-hint">{{ activateHint }}</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>
|
||||
</template>
|
||||
@@ -130,27 +131,48 @@ function formatNow() {
|
||||
const activateVisible = ref(false)
|
||||
const activateSubmitting = ref(false)
|
||||
const activateFormRef = ref()
|
||||
const activateTitle = '启动版本'
|
||||
const activateMode = ref('activate')
|
||||
const activatePh = '请选择生效时间'
|
||||
const activateHint = '若生效时间晚于当前,版本将进入「待生效」;到时自动生效并使上一版本失效。'
|
||||
const activateForm = reactive({
|
||||
psvId: undefined,
|
||||
versionNo: '',
|
||||
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' }]
|
||||
}
|
||||
|
||||
function onActivateVersion(row) {
|
||||
if (!row || row.psvId == null) return
|
||||
activateMode.value = 'activate'
|
||||
activateForm.psvId = row.psvId
|
||||
activateForm.versionNo = row.versionNo || ''
|
||||
activateForm.effectiveTime = formatNow()
|
||||
activateVisible.value = true
|
||||
}
|
||||
|
||||
function onRescheduleVersion(row) {
|
||||
if (!row || row.psvId == null) return
|
||||
activateMode.value = 'reschedule'
|
||||
activateForm.psvId = row.psvId
|
||||
activateForm.versionNo = row.versionNo || ''
|
||||
activateForm.effectiveTime = row.effectiveTime || formatNow()
|
||||
activateVisible.value = true
|
||||
}
|
||||
|
||||
function onActivateClosed() {
|
||||
activateMode.value = 'activate'
|
||||
activateForm.psvId = undefined
|
||||
activateForm.versionNo = ''
|
||||
activateForm.effectiveTime = undefined
|
||||
@@ -165,7 +187,10 @@ function submitActivate() {
|
||||
.then(() => {
|
||||
const eff = activateForm.effectiveTime
|
||||
const pending = eff && new Date(eff.replace(/-/g, '/')).getTime() > Date.now()
|
||||
proxy.$modal.msgSuccess(pending ? '已设为待生效' : '版本已启动')
|
||||
const okMsg = activateMode.value === 'reschedule'
|
||||
? (pending ? '已更新为待生效' : '生效时间已更新,版本已生效')
|
||||
: (pending ? '已设为待生效' : '版本已启动')
|
||||
proxy.$modal.msgSuccess(okMsg)
|
||||
activateVisible.value = false
|
||||
load()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user