From 3a40d2cc7d4dc05795e46c94ff9774352bb6c695 Mon Sep 17 00:00:00 2001 From: zhangpingchuan <228939628@qq.com> Date: Sun, 18 Feb 2024 21:57:38 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=20=E6=9B=B4=E6=96=B0=E7=94=98?= =?UTF-8?q?=E7=89=B9=E5=9B=BE=E9=83=A8=E4=BB=B6=EF=BC=88=E6=8B=96=E5=8A=A8?= =?UTF-8?q?=E6=BB=91=E5=9D=97=E6=9B=B4=E6=96=B0=E6=97=B6=E9=97=B4=E3=80=81?= =?UTF-8?q?=E8=AF=86=E5=88=AB=E5=8F=B6=E5=AD=90=E8=8A=82=E7=82=B9=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/control/gantt/gantt.tsx | 80 +++++++++++++------------------------ 2 files changed, 29 insertions(+), 53 deletions(-) diff --git a/package.json b/package.json index 516be0fc..e5c7024e 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "dependencies": { "@floating-ui/dom": "^1.5.3", "@ibiz-template-plugin/ai-chat": "^0.0.1", - "@ibiz-template-plugin/gantt": "0.1.1", + "@ibiz-template-plugin/gantt": "0.1.3-alpha.23", "@ibiz-template/core": "^0.6.0", "@ibiz-template/devtool": "0.0.1-alpha.1", "@ibiz-template/model-helper": "^0.6.0", diff --git a/src/control/gantt/gantt.tsx b/src/control/gantt/gantt.tsx index da8d38fd..b32da7c2 100644 --- a/src/control/gantt/gantt.tsx +++ b/src/control/gantt/gantt.tsx @@ -49,6 +49,9 @@ export const GanttControl = defineComponent({ const c = useControlController( (...args) => new GanttController(...args), ); + + const ganttRef: Ref = ref(); + // 是否初始化 const isInited: Ref = ref(false); const ns = useNamespace(`control-${c.model.controlType!.toLowerCase()}`); @@ -156,31 +159,6 @@ export const GanttControl = defineComponent({ return ibiz.i18n.getLang().toLowerCase(); }); - /** - * 根据id查找树节点数据 - * - * @param {string} id - * @param {IGanttNodeData[]} nodes - * @return {*} {(IGanttNodeData | null)} - */ - const findDataById = ( - id: string, - nodes: IGanttNodeData[], - ): IGanttNodeData | null => { - for (const node of nodes) { - if (node._id === id) { - return node; - } - if (node._children) { - const result = findDataById(id, node._children); - if (result) { - return result; - } - } - } - return null; - }; - /** * 查找对应节点的布局面板 * @@ -256,33 +234,29 @@ export const GanttControl = defineComponent({ } }; + c.evt.on('onNewRow', event => { + if (ganttRef.value) { + const nodeData = event.row.data; + ganttRef.value.setExpand(nodeData); + } + }); + /** * 滑块移动 * * @param {IData[]} sliders */ const onSliderMove = (sliders: IData[]) => { - const nodeData: IGanttNodeData | undefined = sliders[0]?.row; - if (nodeData) { - const newValue: IData = {}; - if (c.model.beginDataItemName) { - Object.assign(newValue, { - [c.model.beginDataItemName]: nodeData._beginDataItemValue - ? dayjs(nodeData._beginDataItemValue).format( - 'YYYY-MM-DD HH:mm:ss', - ) - : null, - }); - } - if (c.model.endDataItemName) { - Object.assign(newValue, { - [c.model.endDataItemName]: nodeData._endDataItemValue - ? dayjs(nodeData._endDataItemValue).format('YYYY-MM-DD HH:mm:ss') - : null, - }); - } - c.updateNodeData(nodeData, newValue, true); - } + const nodeData: IGanttNodeData = sliders[0]?.row; + const newValue = { + begin: nodeData._beginDataItemValue + ? dayjs(nodeData._beginDataItemValue).format('YYYY-MM-DD HH:mm:ss') + : undefined, + end: nodeData._endDataItemValue + ? dayjs(nodeData._endDataItemValue).format('YYYY-MM-DD HH:mm:ss') + : undefined, + }; + c.modifyNodeTime(nodeData, newValue); }; /** @@ -591,6 +565,7 @@ export const GanttControl = defineComponent({ return { c, ns, + ganttRef, isInited, data, locale, @@ -625,13 +600,14 @@ export const GanttControl = defineComponent({ start-key='_beginDataItemValue' end-key='_endDataItemValue' children='_children' + leaf='_leaf' locale={this.locale} - show-checkbox={!this.c.state.singleSelect} - onNode-expand={this.onNodeExpand} - onRow-click={this.onNodeClick} - onRow-dbl-click={this.onNodeDbClick} - onRow-checked={this.onCheck} - onMove-slider={this.onSliderMove} + showCheckbox={!this.c.state.singleSelect} + onNodeExpand={this.onNodeExpand} + onRowClick={this.onNodeClick} + onRowDblClick={this.onNodeDbClick} + onRowChecked={this.onCheck} + onMoveSlider={this.onSliderMove} primaryColor={this.ganttStyle.primaryColor} headerStyle={{ textColor: this.ganttStyle.textColor }} > -- Gitee From 1237ecbda53cedc043db92d1530ebed89ca2ae1a Mon Sep 17 00:00:00 2001 From: zhangpingchuan <228939628@qq.com> Date: Mon, 19 Feb 2024 09:06:40 +0800 Subject: [PATCH 2/2] =?UTF-8?q?docs:=20=20=E6=9B=B4=E6=96=B0=E6=97=A5?= =?UTF-8?q?=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa134e8f..6ae11300 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ - 树部件支持配置部件参数cascadeselect,选中父节点可以同时选中所有子节点 - 新增数据选择下拉视图导航上下文参数计算、编辑器参数multiple控制多选、抛值关闭下拉时机调整 +- 新增甘特图部件能力(拖动滑块更新时间、识别叶子节点) ### Fixed -- Gitee