fix: 有效账号格式不少于5位

This commit is contained in:
TsMask
2023-11-07 16:43:57 +08:00
parent 50cef777d5
commit 21c702ce9b
3 changed files with 493 additions and 73 deletions

View File

@@ -11,7 +11,7 @@ VITE_APP_NAME = "核心网管理平台"
VITE_APP_CODE = "CoreNet"
# 应用版本
VITE_APP_VERSION = "2.231106.7"
VITE_APP_VERSION = "2.231107.7"
# 接口基础URL地址-不带/后缀
VITE_API_BASE_URL = "/omc-api"

View File

@@ -21,7 +21,7 @@ export const regExpPort =
*
* 账号不能以数字开头可包含大写小写字母数字且不少于5位
*/
export const regExpUserName = /^[a-zA-Z][a-z0-9A-Z]{5,}$/;
export const regExpUserName = /^[a-zA-Z][a-z0-9A-Z]{4,}$/;
/**
* 有效密码格式

View File

@@ -1029,26 +1029,45 @@ type StateType = {
treeLoading: boolean;
/**网元配置 tree */
treeData: DataNode[];
/**选择对应Node tree */
/**选择对应Node的Key tree */
treeSelectKey: string;
/**选择对应Node一级 tree */
treeSelectNode: Record<string, any>;
/**表单标题 */
/**编辑行标题 */
title: string;
/**编辑行记录 */
editRecord: Record<string, any>;
/**多列嵌套编辑行标题 */
arrayChildTitle: string;
/**多列嵌套记录数据 */
arrayChildData: Record<string, any>[];
/**多列嵌套记录规则 */
arrayChildDataRule: Record<string, any>;
/**多列嵌套新增行记录Index */
arrayChildNewIndex: number;
/**多列嵌套编辑行记录 */
arrayChildEditRecord: Record<string, any>;
};
/**对象信息状态 */
let state: StateType = reactive({
treeLoading: true,
treeData: [],
treeSelectKey: '',
treeSelectNode: {
key: 0,
title: '',
keyType: '',
},
title: '',
editRecord: {},
arrayChildTitle: '',
arrayChildData: [],
arrayChildDataRule: {},
arrayChildNewIndex: -1,
arrayChildEditRecord: {},
});
/**表格字段列 */
@@ -1155,6 +1174,7 @@ function fnSelectConfigNode(_: any, info: any) {
console.log('fnSelectConfigNode ', info);
state.editRecord = {};
const node = info.node;
// array类型的含子节点使用index子项
if (node.title.indexOf('Index-') === 0) {
const parentNode = Object.assign(
{},
@@ -1164,11 +1184,12 @@ function fnSelectConfigNode(_: any, info: any) {
return item.title === node.title;
});
state.treeSelectNode = Object.assign({}, child);
state.title = node.title;
} else {
state.treeSelectNode = Object.assign({}, node.dataRef);
state.title = node.title;
}
state.treeSelectKey = node.key;
state.title = node.title;
}
/**单列表编辑 */
@@ -1244,6 +1265,107 @@ function arrayEditOk2() {
data[key] = from[key]['value'];
}
console.log({
neType: neType,
neId: neTypeSelect.value[1],
topTag: state.treeSelectNode.key,
loc,
});
console.log(data);
}
/**多列表展开嵌套行 */
function arrayChildExpand2(row: Record<string, any>) {
const from = Object.assign({}, JSON.parse(JSON.stringify(row)));
// 新增时无数据
if (!Array.isArray(from.value)) {
from.value = [];
}
const dataArr = Object.freeze(from.value);
const ruleArr = Object.freeze(from.array);
// 列表项数据
const dataArray = [];
for (const item of dataArr) {
const index = item['index'];
let record: Record<string, any>[] = [];
for (const key of Object.keys(item)) {
// 规则为准
for (const rule of ruleArr) {
if (rule['name'] === key) {
const ruleItem = Object.assign({ optional: 'true' }, rule, {
value: item[key],
});
record.push(ruleItem);
break;
}
}
}
dataArray.push({ title: `Index-${index}`, key: index, record });
}
state.arrayChildData = dataArray;
// 无数据时,需要临时数据用于新增
if (dataArray.length === 0) {
let itemTemp: Record<string, any> = {};
for (const rule of ruleArr) {
itemTemp[rule.name] = rule;
}
state.arrayChildDataRule = itemTemp;
}
// 设置标题
state.arrayChildTitle = from['display'];
}
/**多列表嵌套行编辑 */
function arrayChildEdit2(records: Record<string, any>[]) {
const row: Record<string, any> = {};
for (const item of records) {
row[item.name] = Object.assign({}, item);
}
state.arrayChildEditRecord = row;
}
/**多列表嵌套行编辑关闭 */
function arrayChildEditClose2() {
if (state.arrayChildNewIndex !== -1) {
state.arrayChildNewIndex = -1;
}
state.arrayChildEditRecord = {};
}
/**多列表嵌套行编辑确认 */
function arrayChildEditOk2() {
debugger;
const from = toRaw(state.arrayChildEditRecord);
const loc = `loc/${from['index']['value']}`;
const neType = neTypeSelect.value[0];
let data: Record<string, any> = {};
for (const key in from) {
// 子嵌套的不插入
if (from[key]['array']) {
continue;
}
// 检查规则
const [ok, msg] = ruleVerification(from[key]);
if (!ok) {
message.warning({
content: `${msg}`,
duration: 3,
});
return;
}
// UPF参数不统一
// if (neType === 'UPF') {
// data[parseFirstUpper(key)] = from[key]['value'];
// } else {
// data[key] = from[key]['value'];
// }
data[key] = from[key]['value'];
}
console.log({
neType: neType,
neId: neTypeSelect.value[1],
@@ -1253,22 +1375,134 @@ function arrayEditOk2() {
console.log(data);
}
/**对话框对象信息状态类型 */
type ModalArrayChildStateType = {
/**框是否显示 */
visible: boolean;
/**标题 */
title: string;
/**array数据 */
data: Record<string, any>[];
};
/**多列表嵌套行删除单行 */
function arrayChildDelete2(key: string) {
debugger;
const loc = `${state.treeSelectNode.key}/${key}`;
console.log({
neType: neTypeSelect.value[0],
neId: neTypeSelect.value[1],
topTag: state.treeSelectKey,
loc,
});
}
/**对话框对象信息状态 */
let modalArrayChildState: ModalArrayChildStateType = reactive({
visible: false,
title: '上传更新',
data: [],
});
/**多列表嵌套行新增单行 */
function arrayChildAdd2() {
debugger;
const len = state.arrayChildData.length;
let lastItme = {};
let newIndex = 0;
// 无数据时生成临时记录
if (len === 0) {
lastItme = state.arrayChildDataRule;
} else {
lastItme = state.arrayChildData[len - 1];
}
const from = Object.assign({}, JSON.parse(JSON.stringify(lastItme)));
for (const row of from.record) {
const value = row.value;
if (row.name === 'index') {
if (value !== '') {
newIndex = parseInt(value) + 1;
}
if (isNaN(newIndex)) {
newIndex = 0;
}
row.value = newIndex;
state.arrayChildNewIndex = newIndex;
continue;
}
// 子嵌套的不初始
if (row.array) {
row.value = null;
continue;
}
const type = row.type;
const filter = row.filter;
switch (type) {
case 'int':
if (filter && filter.indexOf('~') !== -1) {
const filterArr = filter.split('~');
const minInt = parseInt(filterArr[0]);
row.value = minInt;
} else {
row.value = 0;
}
break;
case 'enum':
if (filter && filter.indexOf('{') === 0) {
let filterJson: Record<string, any> = {};
try {
filterJson = JSON.parse(filter); //string---json
} catch (error) {
console.error(error);
}
row.value = Object.keys(filterJson)[0];
} else {
row.value = '0';
}
break;
case 'bool':
if (filter && filter.indexOf('{') === 0) {
let filterJson: Record<string, any> = {};
try {
filterJson = JSON.parse(filter); //string---json
} catch (error) {
console.error(error);
}
row.value = Object.keys(filterJson)[0];
} else {
row.value = false;
}
break;
case 'ipv4':
case 'ipv6':
case 'regex':
default:
row.value = '';
break;
}
}
state.arrayChildEditRecord = from;
}
/**多列表新增单行确认 */
function arrayChildAddOk2() {
debugger;
const from = toRaw(tableState.arrayChildEditRecord);
const loc = `${tableState.arrayChildLoc}/${from['index']['value']}`;
const neType = neTypeSelect.value[0];
let data: Record<string, any> = {};
for (const key in from) {
// 子嵌套的不插入
if (from[key]['array']) {
continue;
}
// 检查规则
const [ok, msg] = ruleVerification(from[key]);
if (!ok) {
message.warning({
content: `${msg}`,
duration: 3,
});
return;
}
data[key] = from[key]['value'];
}
console.log({
neType: neType,
neId: neTypeSelect.value[1],
topTag: tabState.tabActiveTopTag,
loc,
});
console.log(data);
}
</script>
<template>
@@ -1309,7 +1543,10 @@ let modalArrayChildState: ModalArrayChildStateType = reactive({
<!-- 配置参数显示内容 -->
<a-card :bordered="false" :loading="!state.title">
<template #title>
<a-typography-text strong v-if="state.title">
<a-typography-text strong v-if="state.arrayChildTitle">
{{ state.arrayChildTitle }}
</a-typography-text>
<a-typography-text strong v-else-if="state.title">
{{ state.title }}
</a-typography-text>
<a-typography-text type="danger" v-else>
@@ -1318,26 +1555,27 @@ let modalArrayChildState: ModalArrayChildStateType = reactive({
</template>
<!-- 插槽-卡片右侧 -->
<template #extra>
<!-- array类型显示提示内容 -->
<a-space
:size="8"
v-show="state.treeSelectNode.keyType === 'array'"
>
<a-button
type="primary"
@click.prevent="arrayEditClose2"
size="small"
>
<a-button type="primary" @click.prevent="arrayEditClose2">
<template #icon> <PlusOutlined /> </template>
{{ t('common.addText') }}
</a-button>
</a-space>
<!-- array类型数据项显示表单项 -->
<a-space
:size="8"
v-show="state.treeSelectNode.title.indexOf('Index-') === 0"
v-show="
state.treeSelectNode.title.indexOf('Index-') === 0 &&
!state.arrayChildTitle
"
>
<a-button type="default" @click.prevent="arrayEditClose2">
<template #icon> <ClearOutlined /> </template>
<template #icon> <CloseOutlined /> </template>
关闭
</a-button>
<a-button
@@ -1348,8 +1586,16 @@ let modalArrayChildState: ModalArrayChildStateType = reactive({
{{ t('common.editText') }}
</a-button>
<a-button type="primary" @click.prevent="arrayEditOk2">
<template #icon> <SendOutlined /> </template>
发送
<template #icon> <CheckOutlined /> </template>
保存
</a-button>
</a-space>
<!-- array类型数据项显示表单项 -->
<a-space :size="8" v-show="!!state.arrayChildTitle">
<a-button type="default" @click.prevent="arrayEditClose2">
<template #icon> <CloseOutlined /> </template>
返回
</a-button>
</a-space>
</template>
@@ -1377,55 +1623,63 @@ let modalArrayChildState: ModalArrayChildStateType = reactive({
v-if="state.editRecord['display'] === record['display']"
class="editable-cell__input-wrapper"
>
<a-space :size="16" align="center" direction="horizontal">
<a-input
v-if="
['string', 'ipv6', 'ipv4', 'regex'].includes(
record['type']
)
"
v-model:value="state.editRecord['value']"
style="min-width: 200px"
></a-input>
<a-input-number
v-else-if="record['type'] === 'int'"
v-model:value="state.editRecord['value']"
:min="0"
:max="65535"
style="min-width: 200px"
></a-input-number>
<a-switch
v-else-if="record['type'] === 'bool'"
v-model:checked="state.editRecord['value']"
:checked-children="t('common.switch.open')"
:un-checked-children="t('common.switch.shut')"
></a-switch>
<a-select
v-else-if="record['type'] === 'enum'"
v-model:value="state.editRecord['value']"
:allow-clear="true"
style="min-width: 200px"
<a-input
v-if="
['string', 'ipv6', 'ipv4', 'regex'].includes(
record['type']
)
"
v-model:value="state.editRecord['value']"
style="width: 100%"
></a-input>
<a-input-number
v-else-if="record['type'] === 'int'"
v-model:value="state.editRecord['value']"
:min="0"
:max="65535"
style="width: 100%"
></a-input-number>
<a-switch
v-else-if="record['type'] === 'bool'"
v-model:checked="state.editRecord['value']"
:checked-children="t('common.switch.open')"
:un-checked-children="t('common.switch.shut')"
></a-switch>
<a-select
v-else-if="record['type'] === 'enum'"
v-model:value="state.editRecord['value']"
:allow-clear="true"
style="width: 100%"
>
<a-select-option
:value="+v"
:key="+v"
v-for="(k, v) in JSON.parse(record['filter'])"
>
<a-select-option
:value="+v"
:key="+v"
v-for="(k, v) in JSON.parse(record['filter'])"
>
{{ k }}
</a-select-option>
</a-select>
{{ k }}
</a-select-option>
</a-select>
<a-space :size="16" align="center" direction="horizontal">
<a-popconfirm
title="确认更新该属性值吗?"
placement="top"
@confirm="listEditOk2()"
>
<CheckOutlined class="editable-cell__icon-edit" />
<a-button
type="text"
class="editable-cell__icon-edit"
>
<template #icon><CheckOutlined /></template>
</a-button>
</a-popconfirm>
<CloseOutlined
<a-button
type="text"
class="editable-cell__icon-edit"
@click="listEditClose2()"
/>
@click.prevent="listEditClose2()"
>
<template #icon><CloseOutlined /></template>
</a-button>
</a-space>
</div>
<div v-else class="editable-cell__text-wrapper">
@@ -1527,21 +1781,182 @@ let modalArrayChildState: ModalArrayChildStateType = reactive({
</a-select-option>
</a-select>
</div>
<a-button
type="link"
size="small"
@click.prevent=""
@click.prevent="arrayChildExpand2(item)"
v-else-if="Array.isArray(item.array)"
>
详情
</a-button>
<div v-else class="editable-cell__text-wrapper">
{{ `${item.value}` }}
{{ `${item.value || '&nbsp;' }` }}
</div>
</div>
</a-tooltip>
</a-form-item>
</a-form>
<!-- array类型多列嵌套数据项显示表单项 -->
<template v-if="state.arrayChildTitle">
<!-- array类型显示提示内容 -->
<a-typography>
<a-typography-title :level="3">
{{ state.arrayChildTitle }}
</a-typography-title>
<a-typography-paragraph>
可通过右上角操作当前到 {{ state.arrayChildTitle }} 配置
<br />
当前存在以下配置项:
</a-typography-paragraph>
<a-typography-text strong v-for="item in state.arrayChildData">
<a-space :size="16">
<div>{{ item.title }}</div>
<a-tooltip>
<template #title>新增</template>
<a-button
type="text"
class="editable-cell__icon-edit"
size="small"
@click.prevent="arrayChildAdd2()"
>
<template #icon><PlusOutlined /></template>
</a-button>
</a-tooltip>
<a-tooltip>
<template #title>提交</template>
<a-popconfirm
:title="`确认提交更新 Index 为 【 ${tableState.arrayChildNewIndex} 】 的记录吗?确认提交新增 Index 为 的记录吗?`"
placement="left"
@confirm="
tableState.arrayChildNewIndex === -1
? arrayChildEditOk2()
: arrayChildAddOk2()
"
>
<a-button
type="text"
class="editable-cell__icon-edit"
size="small"
>
<template #icon><CheckOutlined /></template>
</a-button>
</a-popconfirm>
</a-tooltip>
<a-tooltip>
<template #title>取消</template>
<a-button
type="text"
class="editable-cell__icon-edit"
size="small"
@click.prevent="arrayChildEditClose2()"
>
<template #icon><CloseOutlined /></template>
</a-button>
</a-tooltip>
<a-tooltip>
<template #title>删除</template>
<a-button
type="text"
danger
size="small"
@click.prevent="arrayChildDelete2(item.key)"
>
<template #icon><DeleteOutlined /></template>
</a-button>
</a-tooltip>
</a-space>
</a-typography-text>
</a-typography>
{{ state.arrayChildData }}
====
{{ state.arrayChildEditRecord }}
<a-form
class="form"
layout="horizontal"
autocomplete="off"
:validate-on-rule-change="false"
:validateTrigger="[]"
>
<a-form-item
v-for="item in state.arrayChildData"
:label="item.display"
:name="item.name"
:required="item.optional === 'false'"
>
<a-tooltip placement="topLeft">
<template #title v-if="item.comment">
{{ item.comment }}
</template>
<div class="editable-cell">
{{ state.editRecord[item.name] }}
<div
v-if="
!Array.isArray(item.array) &&
state.editRecord[item.name] !== undefined
"
class="editable-cell__input-wrapper"
>
<a-input
v-if="
['string', 'ipv6', 'ipv4', 'regex'].includes(
item['type']
)
"
v-model:value="state.editRecord[item.name]['value']"
style="width: 100%"
></a-input>
<a-input-number
v-else-if="item['type'] === 'int'"
v-model:value="state.editRecord[item.name]['value']"
:min="0"
:max="65535"
style="width: 100%"
></a-input-number>
<a-switch
v-else-if="item['type'] === 'bool'"
v-model:checked="state.editRecord[item.name]['value']"
:checked-children="t('common.switch.open')"
:un-checked-children="t('common.switch.shut')"
></a-switch>
<a-select
v-else-if="item['type'] === 'enum'"
v-model:value="state.editRecord[item.name]['value']"
:allow-clear="true"
style="width: 100%"
>
<a-select-option
:value="+v"
:key="+v"
v-for="(k, v) in JSON.parse(item['filter'])"
>
{{ k }}
</a-select-option>
</a-select>
</div>
<a-button
type="link"
size="small"
@click.prevent="arrayChildExpand2(item)"
v-else-if="Array.isArray(item.array)"
>
详情
</a-button>
<div v-else class="editable-cell__text-wrapper">
{{ `${item.value}` }}
</div>
</div>
</a-tooltip>
</a-form-item>
</a-form>
</template>
</a-card>
</a-col>
</a-row>
@@ -2069,5 +2484,10 @@ let modalArrayChildState: ModalArrayChildStateType = reactive({
&__text-wrapper:hover &__icon {
display: inline-block;
}
&__input-wrapper {
display: flex;
justify-content: start;
align-items: center;
}
}
</style>