|
|
@ -9,7 +9,7 @@ |
|
|
|
> |
|
|
|
> |
|
|
|
<BasicForm @register="registerForm"/> |
|
|
|
<BasicForm @register="registerForm"/> |
|
|
|
<ATabs v-model:activeKey="state.typeActiveKey" type="card"> |
|
|
|
<ATabs v-model:activeKey="state.typeActiveKey" type="card"> |
|
|
|
<ATabPane key="1" tab="主表"> |
|
|
|
<ATabPane key="0" tab="主表"> |
|
|
|
<div class="tool-bar"> |
|
|
|
<div class="tool-bar"> |
|
|
|
<a-button type="primary" @click="handleAddTab">新增</a-button> |
|
|
|
<a-button type="primary" @click="handleAddTab">新增</a-button> |
|
|
|
<a-button type="primary" @click="handleEditTab">编辑</a-button> |
|
|
|
<a-button type="primary" @click="handleEditTab">编辑</a-button> |
|
|
@ -29,7 +29,7 @@ |
|
|
|
</ATabPane> |
|
|
|
</ATabPane> |
|
|
|
</ATabs> |
|
|
|
</ATabs> |
|
|
|
</ATabPane> |
|
|
|
</ATabPane> |
|
|
|
<ATabPane key="2" tab="附表"> |
|
|
|
<ATabPane v-if="state.childrenTabVisible" key="1" tab="附表"> |
|
|
|
<div class="tool-bar"> |
|
|
|
<div class="tool-bar"> |
|
|
|
<a-button type="primary" @click="handleAddTab">新增</a-button> |
|
|
|
<a-button type="primary" @click="handleAddTab">新增</a-button> |
|
|
|
<a-button type="primary" @click="handleEditTab">编辑</a-button> |
|
|
|
<a-button type="primary" @click="handleEditTab">编辑</a-button> |
|
|
@ -42,7 +42,10 @@ |
|
|
|
@edit="handleRemoveTab" |
|
|
|
@edit="handleRemoveTab" |
|
|
|
> |
|
|
|
> |
|
|
|
<ATabPane v-for="childTemplateObj in childTemplateObjs" :key="childTemplateObj.index || childTemplateObj.id" :tab="childTemplateObj.name"> |
|
|
|
<ATabPane v-for="childTemplateObj in childTemplateObjs" :key="childTemplateObj.index || childTemplateObj.id" :tab="childTemplateObj.name"> |
|
|
|
<AceEditor v-model:value="childTemplateObj.contents" @register="registerAceEditor"/> |
|
|
|
<AceEditor v-model:value="childTemplateObj.contents" |
|
|
|
|
|
|
|
class="vue-ace-editor" |
|
|
|
|
|
|
|
@register="registerAceEditor" |
|
|
|
|
|
|
|
/> |
|
|
|
</ATabPane> |
|
|
|
</ATabPane> |
|
|
|
</ATabs> |
|
|
|
</ATabs> |
|
|
|
</ATabPane> |
|
|
|
</ATabPane> |
|
|
@ -69,6 +72,7 @@ |
|
|
|
type templateTypePartial = Partial<GencodeTemplateObj>; |
|
|
|
type templateTypePartial = Partial<GencodeTemplateObj>; |
|
|
|
interface WindowState { |
|
|
|
interface WindowState { |
|
|
|
tag: string; |
|
|
|
tag: string; |
|
|
|
|
|
|
|
childrenTabVisible: boolean; |
|
|
|
templateObjs: templateTypePartial[]; |
|
|
|
templateObjs: templateTypePartial[]; |
|
|
|
mainActiveKey: string; |
|
|
|
mainActiveKey: string; |
|
|
|
childActiveKey: string; |
|
|
|
childActiveKey: string; |
|
|
@ -77,10 +81,11 @@ |
|
|
|
|
|
|
|
|
|
|
|
const state = reactive<WindowState>({ |
|
|
|
const state = reactive<WindowState>({ |
|
|
|
tag: '', |
|
|
|
tag: '', |
|
|
|
|
|
|
|
childrenTabVisible: false, |
|
|
|
templateObjs: [], |
|
|
|
templateObjs: [], |
|
|
|
mainActiveKey: '', |
|
|
|
mainActiveKey: '', |
|
|
|
childActiveKey: '', |
|
|
|
childActiveKey: '', |
|
|
|
typeActiveKey: '' |
|
|
|
typeActiveKey: '0' |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const mainTemplateObjs = computed(() => state.templateObjs.filter(item => item.isChild === '0')); |
|
|
|
const mainTemplateObjs = computed(() => state.templateObjs.filter(item => item.isChild === '0')); |
|
|
@ -108,6 +113,14 @@ |
|
|
|
await resetFields(); |
|
|
|
await resetFields(); |
|
|
|
await clearValidate(); |
|
|
|
await clearValidate(); |
|
|
|
await setProps({ disabled: false }); |
|
|
|
await setProps({ disabled: false }); |
|
|
|
|
|
|
|
await updateSchema([ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
field: 'type', |
|
|
|
|
|
|
|
componentProps: { |
|
|
|
|
|
|
|
onChange: (value: string) => (state.childrenTabVisible = value == '2') |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
]); |
|
|
|
// 处理设置数据 |
|
|
|
// 处理设置数据 |
|
|
|
state.tag = data._tag; |
|
|
|
state.tag = data._tag; |
|
|
|
const id = data.record?.id; |
|
|
|
const id = data.record?.id; |
|
|
@ -135,14 +148,14 @@ |
|
|
|
|
|
|
|
|
|
|
|
function handleRemoveTab(targetKey: string) { |
|
|
|
function handleRemoveTab(targetKey: string) { |
|
|
|
let lastIndex = 0; |
|
|
|
let lastIndex = 0; |
|
|
|
(state.typeActiveKey == '1' ? mainTemplateObjs : childTemplateObjs).value.forEach((item, i) => { |
|
|
|
(state.typeActiveKey == '0' ? mainTemplateObjs : childTemplateObjs).value.forEach((item, i) => { |
|
|
|
if ((item.index || item.id) == targetKey) { |
|
|
|
if ((item.index || item.id) == targetKey) { |
|
|
|
lastIndex = i - 1; |
|
|
|
lastIndex = i - 1; |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
state.templateObjs = state.templateObjs.filter(item => (item.index || item.id) != targetKey); |
|
|
|
state.templateObjs = state.templateObjs.filter(item => (item.index || item.id) != targetKey); |
|
|
|
// 当前选择需要删除的tab时候设置自动选择上一个tab |
|
|
|
// 当前选择需要删除的tab时候设置自动选择上一个tab |
|
|
|
if (state.typeActiveKey == '1') { |
|
|
|
if (state.typeActiveKey == '0') { |
|
|
|
if (mainTemplateObjs.value.length && state.mainActiveKey === targetKey) { |
|
|
|
if (mainTemplateObjs.value.length && state.mainActiveKey === targetKey) { |
|
|
|
if (lastIndex >= 0) { |
|
|
|
if (lastIndex >= 0) { |
|
|
|
const mainTemplate = mainTemplateObjs.value[lastIndex]; |
|
|
|
const mainTemplate = mainTemplateObjs.value[lastIndex]; |
|
|
@ -166,11 +179,11 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function handlePrompt({ name }) { |
|
|
|
function handlePrompt({ name }) { |
|
|
|
const index = state.templateObjs.findIndex(item => (item.index || item.id) == (state.typeActiveKey == '1' ? state.mainActiveKey : state.childActiveKey)); |
|
|
|
const index = state.templateObjs.findIndex(item => (item.index || item.id) == (state.typeActiveKey == '0' ? state.mainActiveKey : state.childActiveKey)); |
|
|
|
let template: templateTypePartial = { |
|
|
|
let template: templateTypePartial = { |
|
|
|
name, |
|
|
|
name, |
|
|
|
contents: '', |
|
|
|
contents: '', |
|
|
|
isChild: state.typeActiveKey == '1' ? '0' : '1', |
|
|
|
isChild: state.typeActiveKey, |
|
|
|
index: `t${Date.now()}` |
|
|
|
index: `t${Date.now()}` |
|
|
|
}; |
|
|
|
}; |
|
|
|
if (index != -1) { |
|
|
|
if (index != -1) { |
|
|
@ -178,7 +191,7 @@ |
|
|
|
state.templateObjs.splice(index, 1, template); |
|
|
|
state.templateObjs.splice(index, 1, template); |
|
|
|
} else state.templateObjs.push(template); |
|
|
|
} else state.templateObjs.push(template); |
|
|
|
// 设置自动选择tab |
|
|
|
// 设置自动选择tab |
|
|
|
if (state.typeActiveKey == '1'){ |
|
|
|
if (state.typeActiveKey == '0'){ |
|
|
|
state.mainActiveKey = (template.index || template.id)!; |
|
|
|
state.mainActiveKey = (template.index || template.id)!; |
|
|
|
} else state.childActiveKey = (template.index || template.id)!; |
|
|
|
} else state.childActiveKey = (template.index || template.id)!; |
|
|
|
} |
|
|
|
} |
|
|
|