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 网元类型 * @param neType 网元类型

View File

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