UPDATE: 1、重新修改激活逻辑;2、优化
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
import http from '@/api'
|
||||
import type { Activate } from '@/api/activate/interface'
|
||||
|
||||
export const generateApplicationCode = (params: Activate.ApplicationCodePlaintext) => {
|
||||
return http.post(`/activate/generateApplicationCode`, params)
|
||||
export const generateApplicationCode = () => {
|
||||
return http.post(`/activate/generateApplicationCode`)
|
||||
}
|
||||
|
||||
export const verifyActivationCode = (activationCode: string) => {
|
||||
|
||||
@@ -1,37 +1,14 @@
|
||||
//激活模块
|
||||
export namespace Activate {
|
||||
|
||||
export interface ApplicationModule {
|
||||
/**
|
||||
* 是否申请 1是 0否
|
||||
*/
|
||||
apply: number;
|
||||
}
|
||||
|
||||
export interface ActivateModule extends ApplicationModule {
|
||||
export interface ActivateModule {
|
||||
/**
|
||||
* 是否永久 1是 0否
|
||||
*/
|
||||
permanently: number;
|
||||
}
|
||||
|
||||
export interface ApplicationCodePlaintext {
|
||||
|
||||
/**
|
||||
* 模拟式模块
|
||||
*/
|
||||
simulate: ApplicationModule;
|
||||
|
||||
/**
|
||||
* 数字式模块
|
||||
*/
|
||||
digital: ApplicationModule;
|
||||
|
||||
/**
|
||||
* 比对式模块
|
||||
*/
|
||||
contrast: ApplicationModule;
|
||||
}
|
||||
export interface ActivationCodePlaintext {
|
||||
|
||||
/**
|
||||
|
||||
@@ -41,32 +41,23 @@ const modeList = [
|
||||
name: '模拟式模块',
|
||||
code: '模拟式',
|
||||
key: 'simulate',
|
||||
activated:
|
||||
isActivateOpen === 'true'
|
||||
? activateInfo.simulate.apply === 1 && activateInfo.simulate.permanently === 1
|
||||
: true
|
||||
activated: isActivateOpen === 'true' ? activateInfo.simulate.permanently === 1 : true
|
||||
},
|
||||
{
|
||||
name: '数字式模块',
|
||||
code: '数字式',
|
||||
key: 'digital',
|
||||
activated:
|
||||
isActivateOpen === 'true'
|
||||
? activateInfo.digital.apply === 1 && activateInfo.digital.permanently === 1
|
||||
: true
|
||||
activated: isActivateOpen === 'true' ? activateInfo.digital.permanently === 1 : true
|
||||
},
|
||||
{
|
||||
name: '比对式模块',
|
||||
code: '比对式',
|
||||
key: 'contrast',
|
||||
activated:
|
||||
isActivateOpen === 'true'
|
||||
? activateInfo.contrast.apply === 1 && activateInfo.contrast.permanently === 1
|
||||
: true
|
||||
activated: isActivateOpen === 'true' ? activateInfo.contrast.permanently === 1 : true
|
||||
}
|
||||
]
|
||||
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}模块未激活`)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -79,7 +79,22 @@ export const useAuthStore = defineStore({
|
||||
},
|
||||
async setActivateInfo() {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,30 +43,21 @@ const modeList = [
|
||||
code: '模拟式',
|
||||
subName: '未启用模拟式检测计划',
|
||||
img: new URL('/src/assets/images/dashboard/1.svg', import.meta.url).href,
|
||||
activated:
|
||||
isActivateOpen === 'true'
|
||||
? activateInfo.simulate.apply === 1 && activateInfo.simulate.permanently === 1
|
||||
: true
|
||||
activated: isActivateOpen === 'true' ? activateInfo.simulate.permanently === 1 : true
|
||||
},
|
||||
{
|
||||
name: '数字式模块',
|
||||
code: '数字式',
|
||||
subName: '启用数字检测计划',
|
||||
img: new URL('/src/assets/images/dashboard/2.svg', import.meta.url).href,
|
||||
activated:
|
||||
isActivateOpen === 'true'
|
||||
? activateInfo.digital.apply === 1 && activateInfo.digital.permanently === 1
|
||||
: true
|
||||
activated: isActivateOpen === 'true' ? activateInfo.digital.permanently === 1 : true
|
||||
},
|
||||
{
|
||||
name: '比对式模块',
|
||||
code: '比对式',
|
||||
subName: '启用比对式检测计划',
|
||||
img: new URL('/src/assets/images/dashboard/3.svg', import.meta.url).href,
|
||||
activated:
|
||||
isActivateOpen === 'true'
|
||||
? activateInfo.contrast.apply === 1 && activateInfo.contrast.permanently === 1
|
||||
: true
|
||||
activated: isActivateOpen === 'true' ? activateInfo.contrast.permanently === 1 : true
|
||||
}
|
||||
]
|
||||
const handelOpen = async (item: any) => {
|
||||
@@ -81,12 +72,8 @@ const handelOpen = async (item: any) => {
|
||||
await authStore.getAuthMenuList()
|
||||
return
|
||||
}
|
||||
const handleSelect = (key: string, keyPath: string[]) => {
|
||||
|
||||
}
|
||||
onMounted(() => {
|
||||
|
||||
})
|
||||
const handleSelect = (key: string, keyPath: string[]) => {}
|
||||
onMounted(() => {})
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.box {
|
||||
|
||||
@@ -294,37 +294,62 @@ const save = () => {
|
||||
}
|
||||
}
|
||||
}
|
||||
formContent.value.pt = `${ptPrimaryValue}:${ptSecondaryValue}`
|
||||
// CT 逻辑, CT 分母是否为 ['1', '5']
|
||||
if (!ctFinalValue.includes(ctSecondary.value)) {
|
||||
ctErrorTips = true
|
||||
}
|
||||
if (ptErrorTips && ctErrorTips) {
|
||||
ElMessage.error({ message: '请确认PT和CT无误!' })
|
||||
return
|
||||
await ElMessageBox.confirm('请确认PT和CT无误!', '提示', {
|
||||
confirmButtonText: '继续保存',
|
||||
cancelButtonText: '取消保存'
|
||||
})
|
||||
.then(() => {
|
||||
sendParameter()
|
||||
})
|
||||
.catch(() => {
|
||||
return
|
||||
})
|
||||
} else {
|
||||
if (ptErrorTips) {
|
||||
ElMessage.error({ message: '请确认PT无误!' })
|
||||
return
|
||||
await ElMessageBox.confirm('请确认PT无误!', '提示', {
|
||||
confirmButtonText: '继续保存',
|
||||
cancelButtonText: '取消保存'
|
||||
})
|
||||
.then(() => {
|
||||
sendParameter()
|
||||
})
|
||||
.catch(() => {
|
||||
return
|
||||
})
|
||||
}
|
||||
if (ctErrorTips) {
|
||||
ElMessage.error({ message: '请确认CT无误!' })
|
||||
return
|
||||
await ElMessageBox.confirm('请确认CT无误!', '提示', {
|
||||
confirmButtonText: '确认保存',
|
||||
cancelButtonText: '取消保存'
|
||||
})
|
||||
.then(() => {
|
||||
sendParameter()
|
||||
})
|
||||
.catch(() => {
|
||||
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) {
|
||||
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) => {
|
||||
// 重置表单
|
||||
|
||||
@@ -369,9 +369,7 @@ const columns = reactive<ColumnProps<Device.ResPqDev>[]>([
|
||||
fixed: 'right',
|
||||
render: (scope: { row: { checkState: number } }) => {
|
||||
return scope.row.checkState === 0 ? (
|
||||
<el-tag type="primary" effect="dark">
|
||||
未检
|
||||
</el-tag>
|
||||
<el-tag type="info">未检</el-tag>
|
||||
) : scope.row.checkState === 1 ? (
|
||||
<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) => {
|
||||
|
||||
dialogVisible.value = true
|
||||
title.value = textTitle
|
||||
planTitle.value = data.name
|
||||
@@ -585,7 +582,7 @@ const handleTableDataUpdate = async (newData: any[]) => {
|
||||
planFormContent.value = matchedItem
|
||||
//console.log('递归匹配成功:', planFormContent.value)
|
||||
} else {
|
||||
// console.warn('未找到匹配的 planId:', planId.value)
|
||||
// console.warn('未找到匹配的 planId:', planId.value)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -616,7 +613,7 @@ const handleRemove = async (row: any) => {
|
||||
ElMessage.warning(`当前设备已被子计划绑定,无法删除!`)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
proTable.value?.getTableList() // 刷新当前表格
|
||||
})
|
||||
.catch(() => {
|
||||
@@ -690,10 +687,6 @@ const exportPlan = async () => {
|
||||
ElMessageBox.confirm(`确认导出${subPlanFormContent.name}子计划元信息?`, '温馨提示', { type: 'warning' }).then(() =>
|
||||
useDownload(exportSubPlan, `${subPlanFormContent.name}_子计划元信息`, params, false, '.zip')
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
const exportPlanCheckResultData = async (selectedListIds: string[]) => {
|
||||
@@ -743,7 +736,6 @@ const initSSE = () => {
|
||||
eventSource.value = http.sse('/sse/createSse')
|
||||
|
||||
eventSource.value.onmessage = event => {
|
||||
|
||||
const res = JSON.parse(event.data)
|
||||
progressData.value.percentage = res.data
|
||||
progressData.value.message = res.message
|
||||
|
||||
@@ -338,9 +338,7 @@ const columns = reactive<ColumnProps<Plan.ReqPlan>[]>([
|
||||
fieldNames: { label: 'label', value: 'id' },
|
||||
render: scope => {
|
||||
return scope.row.testState === 0 ? (
|
||||
<el-tag type="primary" effect="dark">
|
||||
未检
|
||||
</el-tag>
|
||||
<el-tag type="info">未检</el-tag>
|
||||
) : scope.row.testState === 1 ? (
|
||||
<el-tag type="warning" effect="dark">
|
||||
检测中
|
||||
|
||||
@@ -13,84 +13,61 @@
|
||||
<el-text style="margin-left: 82%">{{ 'v' + versionNumber }}</el-text>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-descriptions
|
||||
class="mode-descriptions"
|
||||
v-if="!hadActivationCode"
|
||||
title="模块激活状态"
|
||||
size="small"
|
||||
></el-descriptions>
|
||||
<el-form
|
||||
ref="applicationFormRef"
|
||||
v-if="!hadActivationCode"
|
||||
:model="applicationForm"
|
||||
label-position="left"
|
||||
:label-width="100"
|
||||
>
|
||||
<el-form-item
|
||||
class="mode-item"
|
||||
v-if="activateInfo.simulate.apply !== 1 || activateInfo.simulate.permanently !== 1"
|
||||
label="模拟式模块"
|
||||
prop="simulate.apply"
|
||||
>
|
||||
<el-tag disable-transitions type="danger">未激活</el-tag>
|
||||
<el-checkbox
|
||||
:false-value="0"
|
||||
:true-value="1"
|
||||
class="apply-checkbox"
|
||||
v-model="applicationForm.simulate.apply"
|
||||
label="激活"
|
||||
/>
|
||||
<el-descriptions class="mode-descriptions" title="模块激活状态" size="small"></el-descriptions>
|
||||
<el-form label-position="left" :label-width="100">
|
||||
<el-form-item class="mode-item" label="模拟式模块">
|
||||
<el-tag
|
||||
v-if="activateInfo.simulate.permanently !== 1"
|
||||
class="activated-state"
|
||||
disable-transitions
|
||||
type="danger"
|
||||
>
|
||||
未激活
|
||||
</el-tag>
|
||||
<el-tag
|
||||
v-if="activateInfo.simulate.permanently === 1"
|
||||
class="activated-state"
|
||||
disable-transitions
|
||||
type="success"
|
||||
>
|
||||
已激活
|
||||
</el-tag>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
class="mode-item"
|
||||
v-if="activateInfo.simulate.apply === 1 && activateInfo.simulate.permanently === 1"
|
||||
label="模拟式模块"
|
||||
>
|
||||
<el-tag class="activated-tag" disable-transitions type="success">已激活</el-tag>
|
||||
<el-form-item class="mode-item" label="数字式模块">
|
||||
<el-tag
|
||||
v-if="activateInfo.digital.permanently !== 1"
|
||||
class="activated-state"
|
||||
disable-transitions
|
||||
type="danger"
|
||||
>
|
||||
未激活
|
||||
</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
|
||||
class="mode-item"
|
||||
v-if="activateInfo.digital.apply !== 1 || activateInfo.digital.permanently !== 1"
|
||||
label="数字式模块"
|
||||
prop="digital.apply"
|
||||
>
|
||||
<el-tag disable-transitions type="danger">未激活</el-tag>
|
||||
<el-checkbox
|
||||
:false-value="0"
|
||||
:true-value="1"
|
||||
class="apply-checkbox"
|
||||
v-model="applicationForm.digital.apply"
|
||||
label="激活"
|
||||
/>
|
||||
</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-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 class="mode-item" label="比对式模块">
|
||||
<el-tag
|
||||
v-if="activateInfo.contrast.permanently !== 1"
|
||||
class="activated-state"
|
||||
disable-transitions
|
||||
type="danger"
|
||||
>
|
||||
未激活
|
||||
</el-tag>
|
||||
<el-tag
|
||||
v-if="activateInfo.contrast.permanently === 1"
|
||||
class="activated-state"
|
||||
disable-transitions
|
||||
type="success"
|
||||
>
|
||||
已激活
|
||||
</el-tag>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-row v-if="applicationCode">
|
||||
@@ -137,25 +114,16 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { version } from '../../../../package.json'
|
||||
import type { Activate } from '@/api/activate/interface'
|
||||
import { generateApplicationCode, verifyActivationCode } from '@/api/activate'
|
||||
import { useAuthStore } from '@/stores/modules/auth'
|
||||
|
||||
const authStore = useAuthStore()
|
||||
const activateInfo = authStore.activateInfo
|
||||
const versionNumber = ref(version)
|
||||
const applicationForm = reactive<Activate.ApplicationCodePlaintext>({
|
||||
simulate: { apply: 0 },
|
||||
digital: { apply: 0 },
|
||||
contrast: { apply: 0 }
|
||||
})
|
||||
const activatedAll = computed(() => {
|
||||
return (
|
||||
activateInfo.simulate.apply === 1 &&
|
||||
activateInfo.simulate.permanently === 1 &&
|
||||
activateInfo.digital.apply === 1 &&
|
||||
activateInfo.digital.permanently === 1 &&
|
||||
activateInfo.contrast.apply === 1 &&
|
||||
activateInfo.contrast.permanently === 1
|
||||
)
|
||||
})
|
||||
@@ -166,25 +134,7 @@ const activationCode = ref('')
|
||||
const dialogVisible = ref(false)
|
||||
// 获取申请码
|
||||
const getApplicationCode = async () => {
|
||||
if (
|
||||
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)
|
||||
const res = await generateApplicationCode()
|
||||
if (res.code == 'A0000') {
|
||||
applicationCode.value = res.data as string
|
||||
}
|
||||
@@ -202,9 +152,6 @@ const openDialog = () => {
|
||||
hadActivationCode.value = false
|
||||
activationCode.value = ''
|
||||
applicationCode.value = ''
|
||||
applicationForm.simulate.apply = 0
|
||||
applicationForm.digital.apply = 0
|
||||
applicationForm.contrast.apply = 0
|
||||
dialogVisible.value = true
|
||||
}
|
||||
const beforeClose = (done: Function) => {
|
||||
@@ -228,15 +175,12 @@ const submitActivation = async () => {
|
||||
defineExpose({ openDialog })
|
||||
</script>
|
||||
<style scoped>
|
||||
.apply-checkbox {
|
||||
margin-left: 62%;
|
||||
}
|
||||
.activated-tag {
|
||||
.activated-state {
|
||||
margin-left: 80%;
|
||||
}
|
||||
.code-display,
|
||||
.code-input {
|
||||
font-family: consolas;
|
||||
font-family: consolas, sans-serif;
|
||||
}
|
||||
:deep(.el-tag) {
|
||||
user-select: none;
|
||||
|
||||
Reference in New Issue
Block a user