perf: 参数配置页面函数重构

This commit is contained in:
TsMask
2024-07-11 14:49:26 +08:00
parent ecaa0ce077
commit 65c8c6f809
7 changed files with 1077 additions and 835 deletions

View File

@@ -1,13 +1,17 @@
import { getNeConfigData } from '@/api/ne/neConfig';
import { ptResetAsDefault, ptSaveAsDefault } from '@/api/pt/neConfig';
import { stuPtNeConfigApply } from '@/api/pt/neConfigApply';
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
import useI18n from '@/hooks/useI18n';
import { regExpIPv4, regExpIPv6, validURL } from '@/utils/regular-utils';
import message from 'ant-design-vue/lib/message';
import { ref } from 'vue';
export default function useOptions() {
const { t } = useI18n();
/**
* 参数公共函数
* @param param 父级传入 {t}
* @returns
*/
export default function useOptions({ t }: any) {
/**规则校验 */
function ruleVerification(row: Record<string, any>): (string | boolean)[] {
let result = [true, ''];
@@ -165,56 +169,28 @@ export default function useOptions() {
return result;
}
/**保存网元下所有配置为示例配置 */
function ptSaveConfig(neType: string) {
ptSaveAsDefault(neType, '001').then(res => {
if (res.code === RESULT_CODE_SUCCESS) {
message.success({
content: t('common.operateOk'),
duration: 3,
});
} else {
message.error({
content: `${res.msg}`,
duration: 3,
/**upfId可选择 */
const SMFByUPFIdOptions = ref<{ value: string; label: string }[]>([]);
/**加载smf配置的upfId */
function getConfigSMFByUPFIds(neId: string) {
getNeConfigData({
neType: 'SMF',
neId: neId,
paramName: 'upfConfig',
}).then(res => {
SMFByUPFIdOptions.value = [];
for (const s of res.data) {
SMFByUPFIdOptions.value.push({
value: s.id,
label: s.id,
});
}
});
}
/**重置网元下所有配置 */
function ptResetConfig(neType: string) {
ptResetAsDefault(neType).then(res => {
if (res.code === RESULT_CODE_SUCCESS) {
message.success({
content: t('common.operateOk'),
duration: 3,
});
} else {
message.error({
content: `${res.msg}`,
duration: 3,
});
}
});
}
/**配置下方应用申请和撤回 */
function ptConfigApply(neType: string, status: string) {
stuPtNeConfigApply({ neType, status }).then(res => {
if (res.code === RESULT_CODE_SUCCESS) {
message.success({
content: t('common.operateOk'),
duration: 3,
});
} else {
message.error({
content: `${res.msg}`,
duration: 3,
});
}
});
}
return { ruleVerification, ptSaveConfig, ptResetConfig, ptConfigApply };
return {
ruleVerification,
getConfigSMFByUPFIds,
SMFByUPFIdOptions,
};
}