diff --git a/.env.production b/.env.production index e353af64..63b07183 100644 --- a/.env.production +++ b/.env.production @@ -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" diff --git a/src/utils/regular-utils.ts b/src/utils/regular-utils.ts index 958c1337..44f388ef 100644 --- a/src/utils/regular-utils.ts +++ b/src/utils/regular-utils.ts @@ -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,}$/; /** * 有效密码格式 diff --git a/src/views/configManage/configParamTree/index.vue b/src/views/configManage/configParamTree/index.vue index 9258744e..e6f5f0c6 100644 --- a/src/views/configManage/configParamTree/index.vue +++ b/src/views/configManage/configParamTree/index.vue @@ -1029,26 +1029,45 @@ type StateType = { treeLoading: boolean; /**网元配置 tree */ treeData: DataNode[]; - /**选择对应Node tree */ + /**选择对应Node的Key tree */ + treeSelectKey: string; + /**选择对应Node一级 tree */ treeSelectNode: Record; - /**表单标题 */ + /**编辑行标题 */ title: string; /**编辑行记录 */ editRecord: Record; + /**多列嵌套编辑行标题 */ + arrayChildTitle: string; + /**多列嵌套记录数据 */ + arrayChildData: Record[]; + /**多列嵌套记录规则 */ + arrayChildDataRule: Record; + /**多列嵌套新增行记录Index */ + arrayChildNewIndex: number; + /**多列嵌套编辑行记录 */ + arrayChildEditRecord: Record; }; /**对象信息状态 */ 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) { + 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[] = []; + 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 = {}; + for (const rule of ruleArr) { + itemTemp[rule.name] = rule; + } + state.arrayChildDataRule = itemTemp; + } + + // 设置标题 + state.arrayChildTitle = from['display']; +} + +/**多列表嵌套行编辑 */ +function arrayChildEdit2(records: Record[]) { + const row: Record = {}; + 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 = {}; + 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[]; -}; +/**多列表嵌套行删除单行 */ +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 = {}; + 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 = {}; + 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 = {}; + 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); +}