UPDATE: 1、重新修改激活逻辑;2、优化

This commit is contained in:
贾同学
2025-10-22 11:40:57 +08:00
parent ac11af35df
commit 91b2a939b9
9 changed files with 127 additions and 199 deletions

View File

@@ -1,8 +1,7 @@
import http from '@/api' import http from '@/api'
import type { Activate } from '@/api/activate/interface'
export const generateApplicationCode = (params: Activate.ApplicationCodePlaintext) => { export const generateApplicationCode = () => {
return http.post(`/activate/generateApplicationCode`, params) return http.post(`/activate/generateApplicationCode`)
} }
export const verifyActivationCode = (activationCode: string) => { export const verifyActivationCode = (activationCode: string) => {

View File

@@ -1,37 +1,14 @@
//激活模块 //激活模块
export namespace Activate { export namespace Activate {
export interface ApplicationModule {
/**
* 是否申请 1是 0否
*/
apply: number;
}
export interface ActivateModule extends ApplicationModule { export interface ActivateModule {
/** /**
* 是否永久 1是 0否 * 是否永久 1是 0否
*/ */
permanently: number; permanently: number;
} }
export interface ApplicationCodePlaintext {
/**
* 模拟式模块
*/
simulate: ApplicationModule;
/**
* 数字式模块
*/
digital: ApplicationModule;
/**
* 比对式模块
*/
contrast: ApplicationModule;
}
export interface ActivationCodePlaintext { export interface ActivationCodePlaintext {
/** /**

View File

@@ -41,32 +41,23 @@ const modeList = [
name: '模拟式模块', name: '模拟式模块',
code: '模拟式', code: '模拟式',
key: 'simulate', key: 'simulate',
activated: activated: isActivateOpen === 'true' ? activateInfo.simulate.permanently === 1 : true
isActivateOpen === 'true'
? activateInfo.simulate.apply === 1 && activateInfo.simulate.permanently === 1
: true
}, },
{ {
name: '数字式模块', name: '数字式模块',
code: '数字式', code: '数字式',
key: 'digital', key: 'digital',
activated: activated: isActivateOpen === 'true' ? activateInfo.digital.permanently === 1 : true
isActivateOpen === 'true'
? activateInfo.digital.apply === 1 && activateInfo.digital.permanently === 1
: true
}, },
{ {
name: '比对式模块', name: '比对式模块',
code: '比对式', code: '比对式',
key: 'contrast', key: 'contrast',
activated: activated: isActivateOpen === 'true' ? activateInfo.contrast.permanently === 1 : true
isActivateOpen === 'true'
? activateInfo.contrast.apply === 1 && activateInfo.contrast.permanently === 1
: true
} }
] ]
const handelOpen = async (item: string, key: string) => { const handelOpen = async (item: string, key: string) => {
if (isActivateOpen === 'true' && (activateInfo[key].apply !== 1 || activateInfo[key].permanently !== 1)) { if (isActivateOpen === 'true' && activateInfo[key].permanently !== 1) {
ElMessage.warning(`${item}模块未激活`) ElMessage.warning(`${item}模块未激活`)
return return
} }

View File

@@ -79,7 +79,22 @@ export const useAuthStore = defineStore({
}, },
async setActivateInfo() { async setActivateInfo() {
const license_result = await getLicense() const license_result = await getLicense()
const licenseData = license_result.data as unknown as Activate.ActivationCodePlaintext const licenseData = license_result.data as Activate.ActivationCodePlaintext
if (!licenseData.simulate) {
licenseData.simulate = {
permanently: 0
}
}
if (!licenseData.digital) {
licenseData.digital = {
permanently: 0
}
}
if (!licenseData.contrast) {
licenseData.contrast = {
permanently: 0
}
}
this.activateInfo = licenseData this.activateInfo = licenseData
} }
} }

View File

@@ -43,30 +43,21 @@ const modeList = [
code: '模拟式', code: '模拟式',
subName: '未启用模拟式检测计划', subName: '未启用模拟式检测计划',
img: new URL('/src/assets/images/dashboard/1.svg', import.meta.url).href, img: new URL('/src/assets/images/dashboard/1.svg', import.meta.url).href,
activated: activated: isActivateOpen === 'true' ? activateInfo.simulate.permanently === 1 : true
isActivateOpen === 'true'
? activateInfo.simulate.apply === 1 && activateInfo.simulate.permanently === 1
: true
}, },
{ {
name: '数字式模块', name: '数字式模块',
code: '数字式', code: '数字式',
subName: '启用数字检测计划', subName: '启用数字检测计划',
img: new URL('/src/assets/images/dashboard/2.svg', import.meta.url).href, img: new URL('/src/assets/images/dashboard/2.svg', import.meta.url).href,
activated: activated: isActivateOpen === 'true' ? activateInfo.digital.permanently === 1 : true
isActivateOpen === 'true'
? activateInfo.digital.apply === 1 && activateInfo.digital.permanently === 1
: true
}, },
{ {
name: '比对式模块', name: '比对式模块',
code: '比对式', code: '比对式',
subName: '启用比对式检测计划', subName: '启用比对式检测计划',
img: new URL('/src/assets/images/dashboard/3.svg', import.meta.url).href, img: new URL('/src/assets/images/dashboard/3.svg', import.meta.url).href,
activated: activated: isActivateOpen === 'true' ? activateInfo.contrast.permanently === 1 : true
isActivateOpen === 'true'
? activateInfo.contrast.apply === 1 && activateInfo.contrast.permanently === 1
: true
} }
] ]
const handelOpen = async (item: any) => { const handelOpen = async (item: any) => {
@@ -81,12 +72,8 @@ const handelOpen = async (item: any) => {
await authStore.getAuthMenuList() await authStore.getAuthMenuList()
return return
} }
const handleSelect = (key: string, keyPath: string[]) => { const handleSelect = (key: string, keyPath: string[]) => {}
onMounted(() => {})
}
onMounted(() => {
})
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.box { .box {

View File

@@ -294,37 +294,62 @@ const save = () => {
} }
} }
} }
formContent.value.pt = `${ptPrimaryValue}:${ptSecondaryValue}`
// CT 逻辑, CT 分母是否为 ['1', '5'] // CT 逻辑, CT 分母是否为 ['1', '5']
if (!ctFinalValue.includes(ctSecondary.value)) { if (!ctFinalValue.includes(ctSecondary.value)) {
ctErrorTips = true ctErrorTips = true
} }
if (ptErrorTips && ctErrorTips) { if (ptErrorTips && ctErrorTips) {
ElMessage.error({ message: '请确认PT和CT无误' }) await ElMessageBox.confirm('请确认PT和CT无误', '提示', {
confirmButtonText: '继续保存',
cancelButtonText: '取消保存'
})
.then(() => {
sendParameter()
})
.catch(() => {
return return
})
} else { } else {
if (ptErrorTips) { if (ptErrorTips) {
ElMessage.error({ message: '请确认PT无误' }) await ElMessageBox.confirm('请确认PT无误', '提示', {
confirmButtonText: '继续保存',
cancelButtonText: '取消保存'
})
.then(() => {
sendParameter()
})
.catch(() => {
return return
})
} }
if (ctErrorTips) { if (ctErrorTips) {
ElMessage.error({ message: '请确认CT无误' }) await ElMessageBox.confirm('请确认CT无误', '提示', {
confirmButtonText: '确认保存',
cancelButtonText: '取消保存'
})
.then(() => {
sendParameter()
})
.catch(() => {
return return
})
} }
} }
formContent.value.pt = `${ptPrimaryValue}:${ptSecondaryValue}`
if (titleType.value != 'edit') {
formContent.value.id = generateUUID().replaceAll('-', '')
}
emit('get-parameter', formContent.value)
//ElMessage.success({ message: `${dialogTitle.value}成功!` })
close()
} }
}) })
} catch (err) { } catch (err) {
console.error('验证过程中出现错误', err) console.error('验证过程中出现错误', err)
} }
} }
const sendParameter = () => {
if (titleType.value != 'edit') {
formContent.value.id = generateUUID().replaceAll('-', '')
}
emit('get-parameter', formContent.value)
//ElMessage.success({ message: `${dialogTitle.value}成功!` })
close()
}
// 打开弹窗,可能是新增,也可能是编辑 // 打开弹窗,可能是新增,也可能是编辑
const open = async (sign: string, data: Monitor.ResPqMon, device: Device.ResPqDev, table: any[], options: any) => { const open = async (sign: string, data: Monitor.ResPqMon, device: Device.ResPqDev, table: any[], options: any) => {
// 重置表单 // 重置表单

View File

@@ -369,9 +369,7 @@ const columns = reactive<ColumnProps<Device.ResPqDev>[]>([
fixed: 'right', fixed: 'right',
render: (scope: { row: { checkState: number } }) => { render: (scope: { row: { checkState: number } }) => {
return scope.row.checkState === 0 ? ( return scope.row.checkState === 0 ? (
<el-tag type="primary" effect="dark"> <el-tag type="info">未检</el-tag>
未检
</el-tag>
) : scope.row.checkState === 1 ? ( ) : scope.row.checkState === 1 ? (
<el-tag type="warning" effect="dark"> <el-tag type="warning" effect="dark">
检测中 检测中
@@ -531,7 +529,6 @@ const removeTab = async (targetName: TabPaneName) => {
} }
// 弹窗打开方法 // 弹窗打开方法
const open = async (textTitle: string, data: Plan.ReqPlan, pattern: string) => { const open = async (textTitle: string, data: Plan.ReqPlan, pattern: string) => {
dialogVisible.value = true dialogVisible.value = true
title.value = textTitle title.value = textTitle
planTitle.value = data.name planTitle.value = data.name
@@ -690,10 +687,6 @@ const exportPlan = async () => {
ElMessageBox.confirm(`确认导出${subPlanFormContent.name}子计划元信息?`, '温馨提示', { type: 'warning' }).then(() => ElMessageBox.confirm(`确认导出${subPlanFormContent.name}子计划元信息?`, '温馨提示', { type: 'warning' }).then(() =>
useDownload(exportSubPlan, `${subPlanFormContent.name}_子计划元信息`, params, false, '.zip') useDownload(exportSubPlan, `${subPlanFormContent.name}_子计划元信息`, params, false, '.zip')
) )
} }
const exportPlanCheckResultData = async (selectedListIds: string[]) => { const exportPlanCheckResultData = async (selectedListIds: string[]) => {
@@ -743,7 +736,6 @@ const initSSE = () => {
eventSource.value = http.sse('/sse/createSse') eventSource.value = http.sse('/sse/createSse')
eventSource.value.onmessage = event => { eventSource.value.onmessage = event => {
const res = JSON.parse(event.data) const res = JSON.parse(event.data)
progressData.value.percentage = res.data progressData.value.percentage = res.data
progressData.value.message = res.message progressData.value.message = res.message

View File

@@ -338,9 +338,7 @@ const columns = reactive<ColumnProps<Plan.ReqPlan>[]>([
fieldNames: { label: 'label', value: 'id' }, fieldNames: { label: 'label', value: 'id' },
render: scope => { render: scope => {
return scope.row.testState === 0 ? ( return scope.row.testState === 0 ? (
<el-tag type="primary" effect="dark"> <el-tag type="info">未检</el-tag>
未检
</el-tag>
) : scope.row.testState === 1 ? ( ) : scope.row.testState === 1 ? (
<el-tag type="warning" effect="dark"> <el-tag type="warning" effect="dark">
检测中 检测中

View File

@@ -13,84 +13,61 @@
<el-text style="margin-left: 82%">{{ 'v' + versionNumber }}</el-text> <el-text style="margin-left: 82%">{{ 'v' + versionNumber }}</el-text>
</el-form-item> </el-form-item>
</el-form> </el-form>
<el-descriptions <el-descriptions class="mode-descriptions" title="模块激活状态" size="small"></el-descriptions>
class="mode-descriptions" <el-form label-position="left" :label-width="100">
v-if="!hadActivationCode" <el-form-item class="mode-item" label="模拟式模块">
title="模块激活状态" <el-tag
size="small" v-if="activateInfo.simulate.permanently !== 1"
></el-descriptions> class="activated-state"
<el-form disable-transitions
ref="applicationFormRef" type="danger"
v-if="!hadActivationCode"
:model="applicationForm"
label-position="left"
:label-width="100"
> >
<el-form-item 未激活
class="mode-item" </el-tag>
v-if="activateInfo.simulate.apply !== 1 || activateInfo.simulate.permanently !== 1" <el-tag
label="模拟式模块" v-if="activateInfo.simulate.permanently === 1"
prop="simulate.apply" class="activated-state"
disable-transitions
type="success"
> >
<el-tag disable-transitions type="danger">未激活</el-tag> 已激活
<el-checkbox </el-tag>
:false-value="0"
:true-value="1"
class="apply-checkbox"
v-model="applicationForm.simulate.apply"
label="激活"
/>
</el-form-item> </el-form-item>
<el-form-item <el-form-item class="mode-item" label="数字式模块">
class="mode-item" <el-tag
v-if="activateInfo.simulate.apply === 1 && activateInfo.simulate.permanently === 1" v-if="activateInfo.digital.permanently !== 1"
label="模拟式模块" class="activated-state"
disable-transitions
type="danger"
> >
<el-tag class="activated-tag" disable-transitions type="success">已激活</el-tag> 未激活
</el-tag>
<el-tag
v-if="activateInfo.digital.permanently === 1"
class="activated-state"
disable-transitions
type="success"
>
已激活
</el-tag>
</el-form-item> </el-form-item>
<el-form-item <el-form-item class="mode-item" label="比对式模块">
class="mode-item" <el-tag
v-if="activateInfo.digital.apply !== 1 || activateInfo.digital.permanently !== 1" v-if="activateInfo.contrast.permanently !== 1"
label="数字式模块" class="activated-state"
prop="digital.apply" disable-transitions
type="danger"
> >
<el-tag disable-transitions type="danger">未激活</el-tag> 未激活
<el-checkbox </el-tag>
:false-value="0" <el-tag
:true-value="1" v-if="activateInfo.contrast.permanently === 1"
class="apply-checkbox" class="activated-state"
v-model="applicationForm.digital.apply" disable-transitions
label="激活" type="success"
/>
</el-form-item>
<el-form-item
class="mode-item"
v-if="activateInfo.digital.apply === 1 && activateInfo.digital.permanently === 1"
label="数字式模块"
> >
<el-tag class="activated-tag" disable-transitions type="success">已激活</el-tag> 已激活
</el-form-item> </el-tag>
<el-form-item
class="mode-item"
v-if="activateInfo.contrast.apply !== 1 || activateInfo.contrast.permanently !== 1"
label="比对式模块"
prop="contrast.apply"
>
<el-tag disable-transitions type="danger">未激活</el-tag>
<el-checkbox
:false-value="0"
:true-value="1"
class="apply-checkbox"
v-model="applicationForm.contrast.apply"
label="激活"
/>
</el-form-item>
<el-form-item
class="mode-item"
v-if="activateInfo.contrast.apply === 1 && activateInfo.contrast.permanently === 1"
label="比对式模块"
>
<el-tag class="activated-tag" disable-transitions type="success">已激活</el-tag>
</el-form-item> </el-form-item>
</el-form> </el-form>
<el-row v-if="applicationCode"> <el-row v-if="applicationCode">
@@ -137,25 +114,16 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref } from 'vue' import { ref } from 'vue'
import { version } from '../../../../package.json' import { version } from '../../../../package.json'
import type { Activate } from '@/api/activate/interface'
import { generateApplicationCode, verifyActivationCode } from '@/api/activate' import { generateApplicationCode, verifyActivationCode } from '@/api/activate'
import { useAuthStore } from '@/stores/modules/auth' import { useAuthStore } from '@/stores/modules/auth'
const authStore = useAuthStore() const authStore = useAuthStore()
const activateInfo = authStore.activateInfo const activateInfo = authStore.activateInfo
const versionNumber = ref(version) const versionNumber = ref(version)
const applicationForm = reactive<Activate.ApplicationCodePlaintext>({
simulate: { apply: 0 },
digital: { apply: 0 },
contrast: { apply: 0 }
})
const activatedAll = computed(() => { const activatedAll = computed(() => {
return ( return (
activateInfo.simulate.apply === 1 &&
activateInfo.simulate.permanently === 1 && activateInfo.simulate.permanently === 1 &&
activateInfo.digital.apply === 1 &&
activateInfo.digital.permanently === 1 && activateInfo.digital.permanently === 1 &&
activateInfo.contrast.apply === 1 &&
activateInfo.contrast.permanently === 1 activateInfo.contrast.permanently === 1
) )
}) })
@@ -166,25 +134,7 @@ const activationCode = ref('')
const dialogVisible = ref(false) const dialogVisible = ref(false)
// 获取申请码 // 获取申请码
const getApplicationCode = async () => { const getApplicationCode = async () => {
if ( const res = await generateApplicationCode()
applicationForm.simulate.apply == 0 &&
applicationForm.digital.apply == 0 &&
applicationForm.contrast.apply == 0
) {
ElMessage.warning('请选择需要激活的模块')
return
}
if (activateInfo.simulate.apply === 1) {
applicationForm.simulate.apply = 1
}
if (activateInfo.digital.apply === 1) {
applicationForm.digital.apply = 1
}
if (activateInfo.contrast.apply === 1) {
applicationForm.contrast.apply = 1
}
const res = await generateApplicationCode(applicationForm)
if (res.code == 'A0000') { if (res.code == 'A0000') {
applicationCode.value = res.data as string applicationCode.value = res.data as string
} }
@@ -202,9 +152,6 @@ const openDialog = () => {
hadActivationCode.value = false hadActivationCode.value = false
activationCode.value = '' activationCode.value = ''
applicationCode.value = '' applicationCode.value = ''
applicationForm.simulate.apply = 0
applicationForm.digital.apply = 0
applicationForm.contrast.apply = 0
dialogVisible.value = true dialogVisible.value = true
} }
const beforeClose = (done: Function) => { const beforeClose = (done: Function) => {
@@ -228,15 +175,12 @@ const submitActivation = async () => {
defineExpose({ openDialog }) defineExpose({ openDialog })
</script> </script>
<style scoped> <style scoped>
.apply-checkbox { .activated-state {
margin-left: 62%;
}
.activated-tag {
margin-left: 80%; margin-left: 80%;
} }
.code-display, .code-display,
.code-input { .code-input {
font-family: consolas; font-family: consolas, sans-serif;
} }
:deep(.el-tag) { :deep(.el-tag) {
user-select: none; user-select: none;