|
|
@ -149,7 +149,9 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function handleEditTab() { |
|
|
|
function handleEditTab() { |
|
|
|
openPromptModal(true, { _tag: 'edit' }); |
|
|
|
if (state.typeActiveKey == '0' ? state.mainActiveKey : state.childActiveKey) { |
|
|
|
|
|
|
|
openPromptModal(true, { _tag: 'edit' }); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function handleRemoveTab(targetKey: string) { |
|
|
|
function handleRemoveTab(targetKey: string) { |
|
|
@ -184,22 +186,23 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function handlePrompt({ name }) { |
|
|
|
function handlePrompt({ name, tag }) { |
|
|
|
const index = state.templateObjs.findIndex(item => (item.index || item.id) == (state.typeActiveKey == '0' ? state.mainActiveKey : state.childActiveKey)); |
|
|
|
if (tag === 'add') { |
|
|
|
let template: templateTypePartial = { |
|
|
|
const template: templateTypePartial = { |
|
|
|
name, |
|
|
|
name, |
|
|
|
contents: '', |
|
|
|
contents: '', |
|
|
|
isChild: state.typeActiveKey, |
|
|
|
isChild: state.typeActiveKey, |
|
|
|
index: `t${Date.now()}` |
|
|
|
index: `t${Date.now()}` |
|
|
|
}; |
|
|
|
}; |
|
|
|
if (index != -1) { |
|
|
|
state.templateObjs.push(template); |
|
|
|
template = Object.assign({}, state.templateObjs[index], { name }); |
|
|
|
// 设置新增后自动选择tab |
|
|
|
state.templateObjs.splice(index, 1, template); |
|
|
|
state.typeActiveKey == '0' ? (state.mainActiveKey = template.index!) : (state.childActiveKey = template.index!); |
|
|
|
} else state.templateObjs.push(template); |
|
|
|
} else { |
|
|
|
// 设置自动选择tab |
|
|
|
const index = state.templateObjs.findIndex(item => (item.index || item.id) == (state.typeActiveKey == '0' ? state.mainActiveKey : state.childActiveKey)); |
|
|
|
if (state.typeActiveKey == '0'){ |
|
|
|
if (index != -1) { |
|
|
|
state.mainActiveKey = (template.index || template.id)!; |
|
|
|
state.templateObjs.splice(index, 1, Object.assign({}, state.templateObjs[index], { name })); |
|
|
|
} else state.childActiveKey = (template.index || template.id)!; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** 处理弹出框提交 */ |
|
|
|
/** 处理弹出框提交 */ |
|
|
|