From b23629d01eddf6257ef5ff82eaeaa9f9ec19aa21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B6=E9=9B=B6=E9=9B=B6?= <1165844401@qq.com> Date: Thu, 10 Apr 2025 15:00:55 +0800 Subject: [PATCH] =?UTF-8?q?feat=E2=9C=A8:=20=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E8=A1=A8=E5=8D=95=20=E8=A1=A8=E6=A0=BC=E5=B8=83=E5=B1=80=20?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=E5=88=97=E6=8C=89=E9=92=AE=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E6=98=BE=E9=9A=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/LowForm/components/FormTable.vue | 15 ++++++++++++++- src/components/LowDesign/src/utils/example.ts | 17 +++++++++++++++++ src/components/LowDesign/src/utils/formUtil.ts | 5 +++++ .../components/config/LayoutTable.vue | 12 ++++++++---- 4 files changed, 44 insertions(+), 5 deletions(-) diff --git a/src/components/LowDesign/src/LowForm/components/FormTable.vue b/src/components/LowDesign/src/LowForm/components/FormTable.vue index 05f3839..13a5cff 100644 --- a/src/components/LowDesign/src/LowForm/components/FormTable.vue +++ b/src/components/LowDesign/src/LowForm/components/FormTable.vue @@ -61,7 +61,7 @@ index ) " - v-if="item.display" + v-if="item.display && menuBtnShow(item, scope.row, scope.index)" > @@ -332,6 +332,19 @@ const addTable = () => { } } +//按钮显隐处理 +const menuBtnShow = (btnItem, row, index) => { + if (index < 0) return true + const showStr = props.column.btnShowObj[btnItem.prop] + if (!showStr) return true + const bool = executeStrFunction( + showStr, + [row, index], + `${btnItem.label} 按钮显示/隐藏判断执行异常,请检查` + ) + return bool +} + // 按钮事件处理 const menuHandle = (menuData, btnIndex?) => { let { item, row, dataIndex, btnKey } = menuData diff --git a/src/components/LowDesign/src/utils/example.ts b/src/components/LowDesign/src/utils/example.ts index b3c4676..2d859fe 100644 --- a/src/components/LowDesign/src/utils/example.ts +++ b/src/components/LowDesign/src/utils/example.ts @@ -3,6 +3,7 @@ export interface exampleType { formJsEnhanceExample: string remoteExample: string buttonExample: string + formTableMenuButtonExample: string tabsEnhanceExample: string tableEnhanceExample: string tableConfigExample: string @@ -60,6 +61,22 @@ export const buttonExample = `return { } } ` +//表单开发 表格布局 操作列按钮 其他配置模板 +export const formTableMenuButtonExample = `return { + //其他配置请参考element-plus button配置 + type:'primary', + //当前按钮的点击事件 + handleClick: (obj) => { + if (obj.loading) obj.loading() //关闭loading方法 + }, + //当前按钮显示/隐藏判断 注:按钮需要先配置可见 + handleShow:(row)=>{ + //row 当前行数据 + return true + } +} +` + /* 组件配置模板 */ //选项卡布局 增强配置模板 export const tabsEnhanceExample = `return { diff --git a/src/components/LowDesign/src/utils/formUtil.ts b/src/components/LowDesign/src/utils/formUtil.ts index a79b1d2..cbb8c60 100644 --- a/src/components/LowDesign/src/utils/formUtil.ts +++ b/src/components/LowDesign/src/utils/formUtil.ts @@ -382,6 +382,7 @@ const initColumn = (column: object, control, ruleObj, componentData: Object, oth delete columnItem.params[key] }) columnItem.btnClickObj = {} + columnItem.btnShowObj = {} for (const key in columnItem.btnData) { columnItem.btnData[key] = columnItem.btnData[key].map((item) => { const config = handleStrObj(item.configStr, `【${item.label}】 按钮配置格式异常,请检查`) @@ -389,6 +390,10 @@ const initColumn = (column: object, control, ruleObj, componentData: Object, oth columnItem.btnClickObj[item.prop] = `${config['handleClick']}` delete config['handleClick'] } + if (config['handleShow']) { + columnItem.btnShowObj[item.prop] = `${config['handleShow']}` + delete config['handleShow'] + } delete item.configStr Object.assign(item, config) if (formType == 'view') { diff --git a/src/components/LowFormDesign/components/DesignConfig/components/config/LayoutTable.vue b/src/components/LowFormDesign/components/DesignConfig/components/config/LayoutTable.vue index 696b8a5..bb54b1c 100644 --- a/src/components/LowFormDesign/components/DesignConfig/components/config/LayoutTable.vue +++ b/src/components/LowFormDesign/components/DesignConfig/components/config/LayoutTable.vue @@ -122,7 +122,7 @@ size="small" v-model="element.configStr" placeholder="按钮配置" - @click="openBtnEditView(element, index)" + @click="openBtnEditView(element, index, tabItem.prop)" >
@@ -232,7 +232,8 @@ const handleRemoveBtn = (index, prop) => { } const exampleObj = { tableEnhanceStr: example.tableEnhanceExample, - configStr: example.buttonExample + configStr: example.buttonExample, + configMenuStr: example.formTableMenuButtonExample } const openEditView = (prop, label) => { @@ -251,7 +252,7 @@ const openEditView = (prop, label) => { } emit('open-med', { prop, label, params }) } -const openBtnEditView = (btnItem, index) => { +const openBtnEditView = (btnItem, index, tabProp?) => { openMEDialog( { prop: 'configStr', @@ -263,7 +264,10 @@ const openBtnEditView = (btnItem, index) => { name: `复制配置示例`, icon: 'solar:copy-outline', clickFun: () => { - emit('copy-text', exampleObj.configStr || '') + emit( + 'copy-text', + tabProp == 'menu' ? exampleObj.configMenuStr : exampleObj.configStr || '' + ) }, params: { size: 'small',