本文摘要
泛微E9 ecode 中尝试把批量增加选项的思路搬到批量新增字段,目标是在表单字段管理页面每行输入一个字段名、用回车分隔,一次添加多个字段。作者借助 ecodeSDK 覆写弹窗和搜索组组件,注入批量添加按钮与输入框,但目前只复用了原有添加按钮的点击逻辑,功能仍是半成品,提醒不要直接在 ecode 中运行,适合二次开发人员交流与继续完善。
我希望的Ecode目的:每行1个字段,请用回车分隔
昨晚心血来潮搞了一半,感觉功能还是有用的,能节省字段维护不少的时间,不知有没有大佬继续完成这个功能~

⚠️ 代码请勿直接运行
以下ecode代码为半成品,仅供交流,非技术人员请勿直接在ecode运行~
// 我计划用WeaDialog,1.锁定弹窗范围,防止污染,并且newProps.children.props.wfFormSetCusBatchOpsStore中似乎可以直接修改表单中的数据ecodeSDK.overwritePropsFnQueueMapSet('WeaDialog', { fn: (newProps) => { if (!ecodeSDK.checkLPath('/wui/engine.html#/workflowengine/path/pathSet/pathDetail/formManage/editField')) return;
if (newProps.title === "批量添加字段") { console.log(newProps.children.props.wfFormSetCusBatchOpsStore);
} },});
let textValue = '';// 我计划复写WeaSearchGroup 来获取原有添加按钮的动作,并添加新的按钮ecodeSDK.overwritePropsFnQueueMapSet('WeaSearchGroup', { fn: (newProps) => {
var addClickHandler = null; for (var i = 0; i < newProps.customComponent.props.children.length; i++) { var child = newProps.customComponent.props.children[i]; if (child && child.props && child.props.title === "添加") { addClickHandler = child.props.onClick; break; } }
const {Button,Input} = antd; const content = ( <div> <Input type="textarea" placeholder="每行1个字段,请用回车分隔" autosize={{ minRows: 2, maxRows: 6 }} onChange={event => { textValue = event.target.value;}} /> </div> ); const batchAddButton = ( <Button title="批量添加" type="primary" size="small" style={{ marginRight: '8px' }} // style={{"border": "none","padding": "0px","fontSize": "20px","lineHeight": "1","color": "#55a1f8","backgroundColor": "#fff","marginLeft": "10px"}} onClick={() => { window.antd.Modal.info({ title: '批量添加字段', content: content, okText: '确认添加', cancelText: '取消操作', onOk: () => { // console.log("?????????",textValue); addClickHandler(); addClickHandler(); addClickHandler(); }, });
}} >批量添加 </Button> );
newProps.customComponent.props.children.unshift(batchAddButton); },});