fix: 网元授权编辑弹出窗优化支持类型查询

This commit is contained in:
TsMask
2024-04-30 19:58:22 +08:00
parent 83bdf289fa
commit 21ab066761
2 changed files with 76 additions and 44 deletions

View File

@@ -26,6 +26,20 @@ export function getNeLicense(licenseId: string | number) {
});
}
/**
* 网元neType和neID查询
* @param neType 网元类型
* @param neId 网元ID
* @returns object
*/
export function getNeLicenseByTypeAndID(neType: string, neId: string) {
return request({
url: `/ne/license/byTypeAndID`,
method: 'get',
params: { neType, neId },
});
}
/**
* 网元授权激活授权申请码
* @param neType 网元类型

View File

@@ -1,28 +1,13 @@
<script setup lang="ts">
import { reactive, ref, onMounted, toRaw, watch } from 'vue';
import { PageContainer } from 'antdv-pro-layout';
import {
Form,
Modal,
TableColumnsType,
Upload,
message,
} from 'ant-design-vue/lib';
import { SizeType } from 'ant-design-vue/lib/config-provider';
import { MenuInfo } from 'ant-design-vue/lib/menu/src/interface';
import useNeInfoStore from '@/store/modules/neinfo';
import { reactive, onMounted, toRaw, watch } from 'vue';
import { Form, Modal, Upload, message } from 'ant-design-vue/lib';
import useI18n from '@/hooks/useI18n';
import useDictStore from '@/store/modules/dict';
import { NE_TYPE_LIST } from '@/constants/ne-constants';
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
import {
changeNeLicense,
getNeLicense,
listNeLicense,
stateNeLicense,
getNeLicenseByTypeAndID,
} from '@/api/ne/neLicense';
import { parseDateToStr } from '@/utils/date-utils';
import { UploadRequestOption } from 'ant-design-vue/lib/vc-upload/interface';
import { FileType } from 'ant-design-vue/lib/upload/interface';
import { uploadFile } from '@/api/tool/file';
@@ -30,17 +15,26 @@ import { useClipboard } from '@vueuse/core';
import saveAs from 'file-saver';
const { copy } = useClipboard({ legacy: true });
const { t } = useI18n();
const { getDict } = useDictStore();
const emit = defineEmits(['ok', 'cancel', 'update:visible']);
const props = defineProps({
visible: {
type: Boolean,
default: false,
},
/**记录ID 优先级高于neId */
editId: {
type: String,
default: '',
},
/**网元ID */
neId: {
type: String,
default: '',
},
neType: {
type: String,
default: '',
},
});
/**对话框对象信息状态类型 */
@@ -112,7 +106,7 @@ const modalStateFrom = Form.useForm(
* 进行表达规则校验
*/
function fnModalOk() {
if (modalState.confirmLoading) return;
if (modalState.confirmLoading || !modalState.from.id) return;
modalStateFrom
.validate()
@@ -226,11 +220,10 @@ function fnDownCode() {
}
/**
* 对话框弹出显示为 新增或者修改
* 对话框弹出显示为 ID编辑
* @param id id
*/
function fnModalVisibleByEdit(id?: string) {
if (id) {
function fnModalVisibleById(id: string) {
const hide = message.loading(t('common.loading'), 0);
getNeLicense(id)
.then(res => {
@@ -247,18 +240,43 @@ function fnModalVisibleByEdit(id?: string) {
modalState.confirmLoading = false;
hide();
});
}
return;
}
modalState.title = 'Upload License';
/**
* 对话框弹出显示为 新增或者修改
* @param id id
*/
function fnModalVisibleByTypeAndId(neType: string, neId: string) {
const hide = message.loading(t('common.loading'), 0);
getNeLicenseByTypeAndID(neType, neId)
.then(res => {
if (res.code === RESULT_CODE_SUCCESS) {
Object.assign(modalState.from, res.data);
modalState.from.licensePath = '';
modalState.title = 'Update License';
modalState.visibleByEdit = true;
} else {
message.error(res.msg, 3);
}
})
.finally(() => {
modalState.confirmLoading = false;
hide();
});
}
/**监听是否显示,初始数据 */
watch(
() => props.visible,
val => {
if (val) fnModalVisibleByEdit(props.editId);
if (val) {
if (props.editId) {
fnModalVisibleById(props.editId);
}
if (props.neType && props.neId) {
fnModalVisibleByTypeAndId(props.neType, props.neId);
}
}
}
);