diff --git a/dev_tools/template_extend.js b/dev_tools/template_extend.js
index 89ac59a..4abf138 100644
--- a/dev_tools/template_extend.js
+++ b/dev_tools/template_extend.js
@@ -37,6 +37,7 @@ let tmpl = '';
let tabCount = 0;
let tableCount = 0;
const refList = [];
+const refExportList = [];
const importList = [];
const components = [];
@@ -57,11 +58,11 @@ function appendTmpl(prop) {
});
return;
} else if (prop.component == 'Tab') {
- appendTabTmpl(prop);
+ return appendTabTmpl(prop);
} else if (prop.component == 'TableLayout') {
- appendTableLayoutTmpl(prop);
+ return appendTableLayoutTmpl(prop);
} else if (prop.component == 'Card') {
- appendCardTmpl(prop);
+ return appendCardTmpl(prop);
} else if (prop.component == 'SubForm') {
return appendSubFormTmpl(prop);
}
@@ -74,22 +75,22 @@ function appendTmpl(prop) {
`;
}
-function appendSubFormTmpl(prop){
+function appendSubFormTmpl(prop) {
let schema = `schemaMap['${prop.key}']`;
tableCount += 1;
createSubFormFile();
tmpl += `
-
+
- `
+ `;
importList.push(`import CustomDevTableItem${tableCount} from './CustomDevTableItem${tableCount}.vue';`);
components.push(`CustomDevTableItem${tableCount}`);
}
-function createSubFormFile(){
+function createSubFormFile() {
const subFormStr = templates.subFormTmpl;
fs.writeFile(`./CustomDevSubForm${tableCount}.vue`, subFormStr, (err) => {
if (err) throw err;
@@ -106,28 +107,38 @@ function appendTabTmpl(prop) {
let schema = `schemaMap['${prop.key}']`;
tabCount += 1;
refList.push(`const activeKey${tabCount} = ref(0);`);
+ refExportList.push(`activeKey${tabCount}`);
tmpl += `\n`;
- prop.children.forEach((tabChild) => {
- tmpl += `\n`;
+ prop.children.forEach((tabChild, index) => {
+ tmpl += `\n`;
tabChild.list.forEach((listChild) => {
appendTmpl(listChild);
});
tmpl += `\n`;
});
tmpl += `\n`;
+ if(components.indexOf('TabPane') < 0){
+ components.push('TabPane');
+ components.push('Tabs');
+ importList.push(`import { TabPane, Tabs } from 'ant-design-vue';`);
+ }
}
function appendTableLayoutTmpl(prop) {
+ if (components.indexOf('TableLayoutPreview') < 0) {
+ components.push('TableLayoutPreview');
+ importList.push(`import TableLayoutPreview from '/@/components/Form/src/components/TableLayoutPreview.vue';`);
+ }
let schema = `schemaMap['${prop.key}']`;
tmpl += `\n`;
tmpl += ` \n`;
tmpl += ` \n`;
tmpl += `
\n`;
- prop.children[0].list.forEach((lChild) => {
- lChild.children.forEach((child) => {
- appendTmpl(child);
- });
- });
+ tmpl += `
+
+
+
+ `;
tmpl += `
\n`;
tmpl += `
\n`;
tmpl += ` \n`;
@@ -141,6 +152,10 @@ function appendCardTmpl(prop) {
appendTmpl(lChild);
});
tmpl += `\n`;
+ if (components.indexOf('CollapseContainer') < 0) {
+ components.push('CollapseContainer');
+ importList.push(`import { CollapseContainer } from '/@/components/Container';`);
+ }
}
const fullVue = `
@@ -180,19 +195,17 @@ const fullVue = `
Col,
SimpleFormItem,
Row,
- FormItem,
- ${components.join('\n')}
+ FormItem
+ ${components.length ? (',' + components.join(',\n')) : ''}
},
mixins: [SimpleFormSetup],
setup(props, ctx) {
const ret = SimpleFormSetup.setup(props, ctx);
const expose = ctx.expose;
${refList.join('\n')}
- expose({
- ...ret.formApi,
- });
-
+
return {
+ ${refExportList.length ? refExportList.join(',\n') + ',' : ''}
...ret
};
},
diff --git a/dev_tools/templates.js b/dev_tools/templates.js
index 7717f8f..a5e8301 100644
--- a/dev_tools/templates.js
+++ b/dev_tools/templates.js
@@ -99,9 +99,17 @@ const subFormTmpl = `