Commit eb63b2be authored by 王纵's avatar 王纵

增加表格表单按钮自定义方法

parent ad09e035
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: zong.wang01@hand-china.com * @Author: zong.wang01@hand-china.com
* @Date: 2024-07-29 10:51:56 * @Date: 2024-07-29 10:51:56
* @LastEditors: zong.wang01@hand-china.com * @LastEditors: zong.wang01@hand-china.com
* @LastEditTime: 2024-08-15 17:48:20 * @LastEditTime: 2024-08-16 10:12:21
* @Version: 1.0.0 * @Version: 1.0.0
* @Description: 表单渲染 * @Description: 表单渲染
* @Copyright: Copyright (c) 2021, Hand-RongJing * @Copyright: Copyright (c) 2021, Hand-RongJing
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
:title="tabInfo.description" :title="tabInfo.description"
:tabButtons="tabInfo.tabButtons || []" :tabButtons="tabInfo.tabButtons || []"
:showBtns="!readOnly" :showBtns="!readOnly"
:buttonsFun="buttonsClick"
/> />
<van-form ref="formRef" error-message-align="right" input-align="right"> <van-form ref="formRef" error-message-align="right" input-align="right">
...@@ -181,6 +182,10 @@ export default { ...@@ -181,6 +182,10 @@ export default {
originFields: { originFields: {
type: Array, type: Array,
default: () => [] default: () => []
},
componentButtons: {
type: Array,
default: () => []
} }
}, },
inject: ['dynamicInfo', 'addFormRef', 'setDataSetData', 'dataLoadHandle'], inject: ['dynamicInfo', 'addFormRef', 'setDataSetData', 'dataLoadHandle'],
...@@ -332,6 +337,12 @@ export default { ...@@ -332,6 +337,12 @@ export default {
}, },
getCurrentRecord() { getCurrentRecord() {
return this.fieldsObj; return this.fieldsObj;
},
buttonsClick(btn) {
const customBtn = this.componentButtons.find(o => o.name === btn.name); // 采用页面传入的方法
if (customBtn && customBtn.clickFunction) {
customBtn.clickFunction();
}
} }
}, },
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: zong.wang01@hand-china.com * @Author: zong.wang01@hand-china.com
* @Date: 2024-07-29 10:51:56 * @Date: 2024-07-29 10:51:56
* @LastEditors: zong.wang01@hand-china.com * @LastEditors: zong.wang01@hand-china.com
* @LastEditTime: 2024-08-15 17:42:48 * @LastEditTime: 2024-08-16 10:12:01
* @Version: 1.0.0 * @Version: 1.0.0
* @Description: 表格渲染 * @Description: 表格渲染
* @Copyright: Copyright (c) 2021, Hand-RongJing * @Copyright: Copyright (c) 2021, Hand-RongJing
...@@ -112,9 +112,9 @@ export default { ...@@ -112,9 +112,9 @@ export default {
type: Object, type: Object,
default: () => {} default: () => {}
}, },
buttons: { componentButtons: {
type: Array, type: Array,
default: () => [], default: () => []
}, },
columns: { columns: {
type: Array, type: Array,
...@@ -255,26 +255,30 @@ export default { ...@@ -255,26 +255,30 @@ export default {
}) })
}, },
buttonsClick(btn) { buttonsClick(btn) {
switch (btn.name) { const customBtn = this.componentButtons.find(o => o.name === btn.name); // 采用页面传入的方法
case 'create': if (customBtn && customBtn.clickFunction) {
this.showRecord({}, -1); customBtn.clickFunction();
break; } else {
case 'query': switch (btn.name) {
console.log('查询') case 'create':
break; this.showRecord({}, -1);
case 'export': break;
console.log('导出') case 'query':
break; console.log('查询')
case 'remove': break;
this.deleteRecords(); case 'export':
break; console.log('导出')
case 'save': break;
console.log('保存') case 'remove':
break; this.deleteRecords();
default: break;
case 'save':
console.log('保存')
break;
default:
}
} }
} }
}, },
} }
</script> </script>
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: zong.wang01@hand-china.com * @Author: zong.wang01@hand-china.com
* @Date: 2024-08-02 15:32:36 * @Date: 2024-08-02 15:32:36
* @LastEditors: zong.wang01@hand-china.com * @LastEditors: zong.wang01@hand-china.com
* @LastEditTime: 2024-08-15 16:00:59 * @LastEditTime: 2024-08-16 10:08:37
* @Version: 1.0.0 * @Version: 1.0.0
* @Description: 组件头部渲染 * @Description: 组件头部渲染
* @Copyright: Copyright (c) 2021, Hand-RongJing * @Copyright: Copyright (c) 2021, Hand-RongJing
...@@ -86,9 +86,9 @@ export default { ...@@ -86,9 +86,9 @@ export default {
mounted() { mounted() {
this.init(); this.init();
}, },
// activated() { activated() {
// this.init(); this.init();
// }, },
methods: { methods: {
init() { init() {
if(this.tabButtons.length > this.num) { if(this.tabButtons.length > this.num) {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: zong.wang01@hand-china.com * @Author: zong.wang01@hand-china.com
* @Date: 2024-07-30 21:21:37 * @Date: 2024-07-30 21:21:37
* @LastEditors: zong.wang01@hand-china.com * @LastEditors: zong.wang01@hand-china.com
* @LastEditTime: 2024-08-15 17:34:58 * @LastEditTime: 2024-08-16 10:01:26
* @Version: 1.0.0 * @Version: 1.0.0
* @Description: * @Description:
* @Copyright: Copyright (c) 2021, Hand-RongJing * @Copyright: Copyright (c) 2021, Hand-RongJing
...@@ -354,6 +354,8 @@ class BaseComponentBuilder extends BaseBuilder { ...@@ -354,6 +354,8 @@ class BaseComponentBuilder extends BaseBuilder {
this.staticComponents = []; this.staticComponents = [];
this.componentButtons = [];
this.setTabRef = null; this.setTabRef = null;
this.routeParams = {}; // 路由信息 this.routeParams = {}; // 路由信息
...@@ -476,9 +478,10 @@ class BaseComponentBuilder extends BaseBuilder { ...@@ -476,9 +478,10 @@ class BaseComponentBuilder extends BaseBuilder {
props: { props: {
key: refKey, key: refKey,
tabInfo: this.props, tabInfo: this.props,
buttons: this.buttons, // buttons: this.buttons,
columns: this.columns.fields, columns: this.columns.fields,
originColumns: this.columns._originFields originColumns: this.columns._originFields,
componentButtons: this.componentButtons
}, },
ref:`DTABLE_${this.tabCode}`, ref:`DTABLE_${this.tabCode}`,
}, },
...@@ -498,6 +501,7 @@ class BaseComponentBuilder extends BaseBuilder { ...@@ -498,6 +501,7 @@ class BaseComponentBuilder extends BaseBuilder {
fields: newFields.fields, fields: newFields.fields,
originFields: newFields._originFields, originFields: newFields._originFields,
tabInfo: this.props, tabInfo: this.props,
componentButtons: this.componentButtons
}, },
ref:`DFORM_${this.tabCode}`, ref:`DFORM_${this.tabCode}`,
} }
...@@ -509,8 +513,9 @@ class BaseComponentBuilder extends BaseBuilder { ...@@ -509,8 +513,9 @@ class BaseComponentBuilder extends BaseBuilder {
props: { props: {
fields: newFields.fields, fields: newFields.fields,
originFields: newFields._originFields, originFields: newFields._originFields,
buttons: this.props.tabButtons, // buttons: this.props.tabButtons,
tabInfo: this.props, tabInfo: this.props,
componentButtons: this.componentButtons
} }
} }
); );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: zong.wang01@hand-china.com * @Author: zong.wang01@hand-china.com
* @Date: 2024-07-29 10:51:56 * @Date: 2024-07-29 10:51:56
* @LastEditors: zong.wang01@hand-china.com * @LastEditors: zong.wang01@hand-china.com
* @LastEditTime: 2024-08-15 17:07:36 * @LastEditTime: 2024-08-16 10:07:52
* @Version: 1.0.0 * @Version: 1.0.0
* @Description: 查询表单渲染 * @Description: 查询表单渲染
* @Copyright: Copyright (c) 2021, Hand-RongJing * @Copyright: Copyright (c) 2021, Hand-RongJing
...@@ -68,6 +68,10 @@ export default { ...@@ -68,6 +68,10 @@ export default {
originFields: { originFields: {
type: Array, type: Array,
default: () => [] default: () => []
},
componentButtons: {
type: Array,
default: () => []
} }
}, },
data () { data () {
...@@ -92,10 +96,15 @@ export default { ...@@ -92,10 +96,15 @@ export default {
this.show = true; this.show = true;
}, },
btnFun(btn) { btnFun(btn) {
if (btn.name === 'query') { const customBtn = this.componentButtons.find(o => o.name === btn.name);
this.query(); if (customBtn && customBtn.clickFunction) {
} else if (btn.name === 'reset') { customBtn.clickFunction();
this.reset(); } else {
if (btn.name === 'query') {
this.query();
} else if (btn.name === 'reset') {
this.reset();
}
} }
}, },
async query() { async query() {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: zong.wang01@hand-china.com * @Author: zong.wang01@hand-china.com
* @Date: 2024-07-30 09:41:54 * @Date: 2024-07-30 09:41:54
* @LastEditors: zong.wang01@hand-china.com * @LastEditors: zong.wang01@hand-china.com
* @LastEditTime: 2024-08-15 16:44:45 * @LastEditTime: 2024-08-16 09:59:16
* @Version: 1.0.0 * @Version: 1.0.0
* @Description: * @Description:
* @Copyright: Copyright (c) 2021, Hand-RongJing * @Copyright: Copyright (c) 2021, Hand-RongJing
...@@ -35,7 +35,11 @@ const ConfigRenderComponent = { ...@@ -35,7 +35,11 @@ const ConfigRenderComponent = {
staticLayoutTabs: { staticLayoutTabs: {
type: Array, type: Array,
default: () => [], default: () => [],
} },
componentButtons: {
type: Array,
default: () => [],
},
}, },
data () { data () {
return { return {
...@@ -106,6 +110,7 @@ const ConfigRenderComponent = { ...@@ -106,6 +110,7 @@ const ConfigRenderComponent = {
.withTabCode(childrenTab.tabCode) .withTabCode(childrenTab.tabCode)
.withProps(childrenTab) .withProps(childrenTab)
.withStaticComponents(this.staticLayoutTabs) .withStaticComponents(this.staticLayoutTabs)
.withComponentButtons(this.componentButtons)
.withParentProps(this) .withParentProps(this)
.build(); .build();
}); });
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: zong.wang01@hand-china.com * @Author: zong.wang01@hand-china.com
* @Date: 2024-07-29 10:51:56 * @Date: 2024-07-29 10:51:56
* @LastEditors: zong.wang01@hand-china.com * @LastEditors: zong.wang01@hand-china.com
* @LastEditTime: 2024-08-15 17:42:29 * @LastEditTime: 2024-08-16 09:56:40
* @Version: 1.0.0 * @Version: 1.0.0
* @Description: * @Description:
* @Copyright: Copyright (c) 2021, Hand-RongJing * @Copyright: Copyright (c) 2021, Hand-RongJing
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
v-if="configDatas.id && !loading" v-if="configDatas.id && !loading"
:componentRenderers="componentRenderers" :componentRenderers="componentRenderers"
:staticLayoutTabs="staticLayoutTabs" :staticLayoutTabs="staticLayoutTabs"
:componentButtons="componentButtons"
/> />
</h-content> </h-content>
<layout-buttons <layout-buttons
...@@ -66,6 +67,10 @@ export default { ...@@ -66,6 +67,10 @@ export default {
type: Object, type: Object,
default: () => ({}) default: () => ({})
}, },
componentButtons: { // 组件按钮方法
type: Array,
default: () => []
},
staticLayoutTabs: { // 静态布局内容 staticLayoutTabs: { // 静态布局内容
type: Array, type: Array,
default: () => [] default: () => []
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment