diff --git a/src/views/configManage/configParamTree/index.vue b/src/views/configManage/configParamTree copy/index.vue similarity index 74% rename from src/views/configManage/configParamTree/index.vue rename to src/views/configManage/configParamTree copy/index.vue index cefd9d72..aeb27d58 100644 --- a/src/views/configManage/configParamTree/index.vue +++ b/src/views/configManage/configParamTree copy/index.vue @@ -737,6 +737,7 @@ function arrayChildDelete(row: Record) { /**多列表嵌套行新增单行 */ function arrayChildAdd() { const len = tableState.arrayChildData.length; + debugger let lastItme = {}; let newIndex = 0; // 无数据时生成临时记录 @@ -1044,7 +1045,9 @@ type StateType = { arrayChildData: Record[]; /**多列嵌套记录规则 */ arrayChildDataRule: Record; - /**多列嵌套新增行记录Index */ + /**多列嵌套新增行记录Index 查看-2/编辑-1/新增>=0 */ + arrayChildKey: number; + /**多列嵌套新增行记录Index 查看-2/编辑-1/新增>=0 */ arrayChildNewIndex: number; /**多列嵌套编辑行记录 */ arrayChildEditRecord: Record; @@ -1066,7 +1069,8 @@ let state: StateType = reactive({ arrayChildTitle: '', arrayChildData: [], arrayChildDataRule: {}, - arrayChildNewIndex: -1, + arrayChildKey: -1, + arrayChildNewIndex: -3, arrayChildEditRecord: {}, }); @@ -1173,6 +1177,7 @@ function fnLoadConfigNodeData(treeNode: EventDataNode): Promise { function fnSelectConfigNode(_: any, info: any) { console.log('fnSelectConfigNode ', info); state.editRecord = {}; + arrayChildExpandClose(); const node = info.node; // array类型的含子节点使用index子项 if (node.title.indexOf('Index-') === 0) { @@ -1239,6 +1244,7 @@ function arrayEdit2(record: Record[]) { /**多列表编辑关闭 */ function arrayEditClose2() { state.editRecord = {}; + arrayChildExpandClose(); } /**多列表编辑确认 */ @@ -1306,38 +1312,45 @@ function arrayChildExpand2(row: Record) { state.arrayChildData = dataArray; // 无数据时,需要临时数据用于新增 - if (dataArray.length === 0) { - let itemTemp: Record = {}; - for (const rule of ruleArr) { - itemTemp[rule.name] = rule; - } - state.arrayChildDataRule = itemTemp; - } + state.arrayChildDataRule = { title: `Index-0`, key: 0, record: ruleArr }; // 设置标题 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 arrayChildExpandClose() { + state.arrayChildTitle = ''; + state.arrayChildDataRule = {}; + state.arrayChildData = []; + state.arrayChildEditRecord = {}; + state.arrayChildKey = -1; + state.arrayChildNewIndex = -3; } /**多列表嵌套行编辑关闭 */ function arrayChildEditClose2() { - if (state.arrayChildNewIndex !== -1) { - state.arrayChildNewIndex = -1; + if (state.arrayChildNewIndex > -1) { + state.arrayChildData.pop(); } + state.arrayChildKey = -1; + state.arrayChildNewIndex = -3; state.arrayChildEditRecord = {}; } +/**多列表嵌套行编辑 */ +function arrayChildEdit2(item: Record, index: number) { + const row: Record = {}; + for (const r of item.record) { + row[r.name] = Object.assign({}, r); + } + state.arrayChildEditRecord = row; + state.arrayChildKey = item.key; + state.arrayChildNewIndex = index; +} + /**多列表嵌套行编辑确认 */ function arrayChildEditOk2() { - debugger; const from = toRaw(state.arrayChildEditRecord); const loc = `loc/${from['index']['value']}`; const neType = neTypeSelect.value[0]; @@ -1357,12 +1370,6 @@ function arrayChildEditOk2() { }); return; } - // UPF参数不统一 - // if (neType === 'UPF') { - // data[parseFirstUpper(key)] = from[key]['value']; - // } else { - // data[key] = from[key]['value']; - // } data[key] = from[key]['value']; } @@ -1373,11 +1380,19 @@ function arrayChildEditOk2() { loc, }); console.log(data); + + message.success({ + content: ` 成功 Index :${from['index']['value']} `, + duration: 3, + }); + //state.arrayChildData.pop(); + state.arrayChildKey = -1; + state.arrayChildNewIndex = -3; + state.arrayChildEditRecord = {}; } /**多列表嵌套行删除单行 */ function arrayChildDelete2(key: string) { - debugger; const loc = `${state.treeSelectNode.key}/${key}`; console.log({ neType: neTypeSelect.value[0], @@ -1385,11 +1400,17 @@ function arrayChildDelete2(key: string) { topTag: state.treeSelectKey, loc, }); + + state.arrayChildData = state.arrayChildData.filter( + (item: any) => item.key !== key + ); } /**多列表嵌套行新增单行 */ function arrayChildAdd2() { - debugger; + if (state.arrayChildNewIndex > -1) { + state.arrayChildData.pop(); + } const len = state.arrayChildData.length; let lastItme = {}; let newIndex = 0; @@ -1410,7 +1431,8 @@ function arrayChildAdd2() { newIndex = 0; } row.value = newIndex; - state.arrayChildNewIndex = newIndex; + from.key = newIndex; + from.title = `Index-${newIndex}`; continue; } // 子嵌套的不初始 @@ -1467,14 +1489,14 @@ function arrayChildAdd2() { } } - state.arrayChildEditRecord = from; + state.arrayChildData.push(from); + arrayChildEdit2(from, newIndex); } /**多列表新增单行确认 */ function arrayChildAddOk2() { - debugger; - const from = toRaw(tableState.arrayChildEditRecord); - const loc = `${tableState.arrayChildLoc}/${from['index']['value']}`; + const from = toRaw(state.arrayChildEditRecord); + const loc = `${state.treeSelectKey}/${from['index']['value']}`; const neType = neTypeSelect.value[0]; let data: Record = {}; @@ -1498,10 +1520,19 @@ function arrayChildAddOk2() { console.log({ neType: neType, neId: neTypeSelect.value[1], - topTag: tabState.tabActiveTopTag, + topTag: state.treeSelectKey, loc, }); console.log(data); + + message.success({ + content: ` 成功 Index :${from['index']['value']} `, + duration: 3, + }); + //state.arrayChildData.pop(); + state.arrayChildKey = -1; + state.arrayChildNewIndex = -3; + state.arrayChildEditRecord = {}; } @@ -1543,10 +1574,7 @@ function arrayChildAddOk2() { @@ -1792,75 +1809,296 @@ function arrayChildAddOk2() {
- {{ `${item.value || ' ' }` }} + {{ `${item.value || ' '}` }}
+ + -