From 876a5e6657d67df66bb525d02dd6d147ba81cae5 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 05 一月 2023 09:53:37 +0800 Subject: [PATCH] 2023-01-05 --- src/menu/tablenodes/index.jsx | 55 +++++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 39 insertions(+), 16 deletions(-) diff --git a/src/menu/tablenodes/index.jsx b/src/menu/tablenodes/index.jsx index 2b5eed1..36281b2 100644 --- a/src/menu/tablenodes/index.jsx +++ b/src/menu/tablenodes/index.jsx @@ -173,6 +173,7 @@ if (result.tb_list) { result.tb_list.sort((a, b) => a.tbname > b.tbname ? 1 : -1) + let length = result.tb_list.length result.tb_list.forEach((item, i) => { let cell = { label: item.tbname, @@ -180,6 +181,8 @@ id: 'table' + i, direction: 'right', color: '#1890ff', + collapsed: false, + collable: true, children: [] } @@ -198,10 +201,17 @@ id: item.tbname + 'menu' + i, direction: 'right', color: '#1890ff', + type: 'dice-mind-map-leaf', param: _param }) } }) + } + + if (cell.children.length > 5 && length > 1) { + cell.collapsed = true + } else if (cell.children.length === 0) { + cell.collable = false } data.children.push(cell) @@ -284,12 +294,12 @@ const stroke = cfg.style.stroke || '#096dd9'; return ` - <group> - <rect draggable="true" style={{width: ${width}, height: 30, stroke: ${stroke}, radius: 4}} keyshape> - <text style={{ fontSize: 14, marginLeft: 6, marginTop: 6 }}>${cfg.label}</text> - </rect> - </group> - `; + <group> + <rect draggable="true" style={{width: ${width}, height: 30, stroke: ${stroke}, radius: 4}} keyshape> + <text style={{ fontSize: 14, marginLeft: 6, marginTop: 6 }}>${cfg.label}</text> + </rect> + </group> + `; }, getAnchorPoints() { return [ @@ -308,13 +318,13 @@ const color = cfg.color; return ` - <group> - <rect draggable="true" style={{width: ${width}, height: 26, cursor: ${cfg.direction !== 'left' ? 'pointer' : 'default'}, fill: 'transparent' }}> - <text style={{ fontSize: 12, fill: ${cfg.fontcolor ? cfg.fontcolor : 'black'}, cursor: ${cfg.direction !== 'left' ? 'pointer' : 'default'}, marginLeft: 12, marginTop: 6 }}>${cfg.label}</text> - </rect> - <rect style={{ fill: ${color}, width: ${width}, cursor: ${cfg.direction !== 'left' ? 'pointer' : 'default'}, height: 2, x: 0, y: 32 }} /> - </group> - `; + <group> + <rect draggable="true" style={{width: ${width}, height: 26, cursor: ${cfg.direction !== 'left' ? 'pointer' : 'default'}, fill: 'transparent' }}> + <text style={{ fontSize: 12, fill: ${cfg.fontcolor ? cfg.fontcolor : 'black'}, cursor: ${cfg.direction !== 'left' ? 'pointer' : 'default'}, marginLeft: 12, marginTop: 6 }}>${cfg.label} ${cfg.collable ? '+' : ''}</text> + </rect> + <rect style={{ fill: ${color}, width: ${width}, cursor: ${cfg.direction !== 'left' ? 'pointer' : 'default'}, height: 2, x: 0, y: 32 }} /> + </group> + `; }, getAnchorPoints() { return [ @@ -406,7 +416,7 @@ data.color = color; } - if (d.children) { + if (d.children && !d.collapsed) { data.children = d.children.map((child) => changeData(child, level + 1, data.color)); } return data; @@ -447,9 +457,21 @@ lineWidth: 2, }, }, - minZoom: 0.5, + minZoom: 0.3, modes: { - default: ['drag-canvas', 'zoom-canvas', 'dice-mindmap'], + default: [ + { + type: 'collapse-expand', + trigger: 'click', + shouldBegin: (e, self) => { + if (e.item && e.item.getModel().collable) return true; + return false; + }, + }, + 'drag-canvas', + 'zoom-canvas', + 'dice-mindmap' + ], }, }); @@ -483,6 +505,7 @@ </div> <div className="footer"> <Button key="cancel" onClick={() => { this.setState({ visible: false })}}>鍏抽棴</Button> + <span className="tip">娉細鐐瑰嚮琛ㄥ悕鍙睍寮�/鏀惰捣鑿滃崟</span> </div> </Modal> </div> -- Gitblit v1.8.0