Commit eb63b2be authored by 王纵's avatar 王纵

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

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