diff --git a/tenant-platform/src/api/license.ts b/tenant-platform/src/api/license.ts index 893904b..af63bfb 100644 --- a/tenant-platform/src/api/license.ts +++ b/tenant-platform/src/api/license.ts @@ -104,7 +104,7 @@ export const licenseApi = { ) }, - updateAppLicense(appKey: string, data: { maxDevices?: number; isActive?: boolean; remark?: string }) { + updateAppLicense(appKey: string, data: { maxDevices?: number; isActive?: boolean; remark?: string; expiresAt?: string }) { return licenseClient.patch<{ data: AppLicense }>( `/api/license/admin/apps/${encodeURIComponent(appKey)}`, data, diff --git a/tenant-platform/src/views/license/LicenseManagementView.vue b/tenant-platform/src/views/license/LicenseManagementView.vue index 22b54a8..dbe7d1f 100644 --- a/tenant-platform/src/views/license/LicenseManagementView.vue +++ b/tenant-platform/src/views/license/LicenseManagementView.vue @@ -64,7 +64,22 @@ {{ license?.registeredDevices ?? devices.length }} - {{ license?.expiresAt ? formatDate(license.expiresAt) : '永久' }} +
+ {{ license?.expiresAt ? formatDate(license.expiresAt) : '永久' }} + 修改 +
+
+ + 保存 + 取消 +
@@ -163,6 +178,9 @@ const loading = ref(false) const editingMaxDevices = ref(false) const editMaxDevicesValue = ref(1) const savingMaxDevices = ref(false) +const editingExpiresAt = ref(false) +const editExpiresAtValue = ref(null) +const savingExpiresAt = ref(false) const appName = computed(() => currentApp.value?.name || license.value?.name || appKey.value || '-') const activeDevices = computed(() => devices.value.filter(d => d.isActive).length) @@ -213,6 +231,28 @@ async function saveMaxDevices() { } } +function startEditExpiresAt() { + editExpiresAtValue.value = license.value?.expiresAt ? new Date(license.value.expiresAt) : null + editingExpiresAt.value = true +} + +async function saveExpiresAt() { + const key = appKey.value + if (!key) return + savingExpiresAt.value = true + try { + const expiresAt = editExpiresAtValue.value ? editExpiresAtValue.value.toISOString() : '' + const res = await licenseApi.updateAppLicense(key, { expiresAt }) + license.value = res.data.data + editingExpiresAt.value = false + ElMessage.success('过期时间已更新') + } catch { + ElMessage.error('更新失败') + } finally { + savingExpiresAt.value = false + } +} + async function revokeDevice(row: LicenseDevice) { try { await ElMessageBox.confirm('确认吊销该设备?', '吊销确认', { type: 'warning' })