From 042a962a2fb8c417694eede4d1d8516d8ba2d6d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E6=B0=B8=E9=A1=BA?= <971387674@qq.com> Date: Mon, 4 Dec 2023 14:17:11 +0800 Subject: [PATCH] =?UTF-8?q?feature/2.9.42310.01-=E8=96=AA=E8=B5=84?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E6=8B=93=E6=89=91=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...码.tsx => antdTable-适配中江columns2返回的数据.tsx} | 82 +++++++++++++++++-- src/pages/atdTable/components/antdTable.tsx | 78 ++---------------- src/pages/atdTable/index.tsx | 4 +- 3 files changed, 82 insertions(+), 82 deletions(-) rename src/pages/atdTable/components/{antdTable-修改适配中江前的源码.tsx => antdTable-适配中江columns2返回的数据.tsx} (80%) diff --git a/src/pages/atdTable/components/antdTable-修改适配中江前的源码.tsx b/src/pages/atdTable/components/antdTable-适配中江columns2返回的数据.tsx similarity index 80% rename from src/pages/atdTable/components/antdTable-修改适配中江前的源码.tsx rename to src/pages/atdTable/components/antdTable-适配中江columns2返回的数据.tsx index 9c542f6..eef20db 100644 --- a/src/pages/atdTable/components/antdTable-修改适配中江前的源码.tsx +++ b/src/pages/atdTable/components/antdTable-适配中江columns2返回的数据.tsx @@ -11,7 +11,7 @@ const { Text } = Typography; interface ITableProps { } -const AntdTable: FC = (props) => { +const AntdTableColumns2: FC = (props) => { const [selected, setSelected] = useState>([]); //列表选中的数据 const [tab, setTab] = useState(""); //顶部TAB变量 const [usertab, setUsertab] = useState(""); //底部TAB变量 @@ -58,9 +58,9 @@ const AntdTable: FC = (props) => { setPageParams({ ...pageParams, total, size, pageNum }); } } else { - const { columns = [], pageInfo = {} } = dataCopy; + const { columns = [], columns2 = [], pageInfo = {} } = dataCopy; const { list = [], total, pageSize: size, pageNum } = pageInfo; - setColumns(getColumns(columns, hasOperate)); + setColumns(getColumns(columns2, hasOperate)); setDataSource(list); setPageParams({ ...pageParams, total, size, pageNum }); const confCode: any = await API.CalculateService.getSysconfcode({ code: "OPEN_ACCT_RESULT_SUM" }); @@ -260,6 +260,67 @@ const AntdTable: FC = (props) => { } ; }; + if (child.children) { + child.children.map((grandSon: any) => { + grandSon.title = + { + window.parent.postMessage( + { + type: "PR", + data: { id: "COLUMNINDEX", data: grandSon.column } + }, + "*" + ); + }}>{grandSon.text} + { + grandSon.lockStatus && + + { + grandSon.lockStatus === "UNLOCK" && + { + window.parent.postMessage( + { + type: "PR", + data: { id: "COLUMNINDEX", data: grandSon.column, extraId: "LOCK" } + }, + "*" + ); + }} + /> + } + { + grandSon.lockStatus !== "UNLOCK" && + { + window.parent.postMessage( + { + type: "PR", + data: { id: "COLUMNINDEX", data: grandSon.column, extraId: "UNLOCK" } + }, + "*" + ); + }} + /> + } + + } + ; + grandSon.dataIndex = grandSon.column; + grandSon.width = "150px"; + grandSon.ellipsis = true; + grandSon.render = (text: string) => { + return + {text} + { + child.lockStatus === "LOCK" ? : null + } + ; + }; + }); + } }); } @@ -348,10 +409,16 @@ const AntdTable: FC = (props) => { if (tab !== "PR" || !showSumrow) return; let totalColumns: any[] = []; _.forEach(columns, it => { - if (!it.children) { + if (_.isEmpty(it.children)) { totalColumns.push(it); } else { - totalColumns = [...totalColumns, ...it.children]; + _.forEach(it.children, gt => { + if (_.isEmpty(gt.children)) { + totalColumns.push(gt); + } else { + totalColumns = [...totalColumns, ...gt.children]; + } + }); } }); return ( @@ -361,7 +428,8 @@ const AntdTable: FC = (props) => { _.isEmpty(sumRow) ? : _.map([{}, ...totalColumns], (item, index) => { if (index === 0) { - return 总计; + return 总计; } return {sumRow[item.dataIndex] || "-"} @@ -375,4 +443,4 @@ const AntdTable: FC = (props) => { />; }; -export default AntdTable; +export default AntdTableColumns2; diff --git a/src/pages/atdTable/components/antdTable.tsx b/src/pages/atdTable/components/antdTable.tsx index df2060e..9c542f6 100644 --- a/src/pages/atdTable/components/antdTable.tsx +++ b/src/pages/atdTable/components/antdTable.tsx @@ -58,9 +58,9 @@ const AntdTable: FC = (props) => { setPageParams({ ...pageParams, total, size, pageNum }); } } else { - const { columns = [], columns2 = [], pageInfo = {} } = dataCopy; + const { columns = [], pageInfo = {} } = dataCopy; const { list = [], total, pageSize: size, pageNum } = pageInfo; - setColumns(getColumns(columns2, hasOperate)); + setColumns(getColumns(columns, hasOperate)); setDataSource(list); setPageParams({ ...pageParams, total, size, pageNum }); const confCode: any = await API.CalculateService.getSysconfcode({ code: "OPEN_ACCT_RESULT_SUM" }); @@ -260,67 +260,6 @@ const AntdTable: FC = (props) => { } ; }; - if (child.children) { - child.children.map((grandSon: any) => { - grandSon.title = - { - window.parent.postMessage( - { - type: "PR", - data: { id: "COLUMNINDEX", data: grandSon.column } - }, - "*" - ); - }}>{grandSon.text} - { - grandSon.lockStatus && - - { - grandSon.lockStatus === "UNLOCK" && - { - window.parent.postMessage( - { - type: "PR", - data: { id: "COLUMNINDEX", data: grandSon.column, extraId: "LOCK" } - }, - "*" - ); - }} - /> - } - { - grandSon.lockStatus !== "UNLOCK" && - { - window.parent.postMessage( - { - type: "PR", - data: { id: "COLUMNINDEX", data: grandSon.column, extraId: "UNLOCK" } - }, - "*" - ); - }} - /> - } - - } - ; - grandSon.dataIndex = grandSon.column; - grandSon.width = "150px"; - grandSon.ellipsis = true; - grandSon.render = (text: string) => { - return - {text} - { - child.lockStatus === "LOCK" ? : null - } - ; - }; - }); - } }); } @@ -409,16 +348,10 @@ const AntdTable: FC = (props) => { if (tab !== "PR" || !showSumrow) return; let totalColumns: any[] = []; _.forEach(columns, it => { - if (_.isEmpty(it.children)) { + if (!it.children) { totalColumns.push(it); } else { - _.forEach(it.children, gt => { - if (_.isEmpty(gt.children)) { - totalColumns.push(gt); - } else { - totalColumns = [...totalColumns, ...gt.children]; - } - }); + totalColumns = [...totalColumns, ...it.children]; } }); return ( @@ -428,8 +361,7 @@ const AntdTable: FC = (props) => { _.isEmpty(sumRow) ? : _.map([{}, ...totalColumns], (item, index) => { if (index === 0) { - return 总计; + return 总计; } return {sumRow[item.dataIndex] || "-"} diff --git a/src/pages/atdTable/index.tsx b/src/pages/atdTable/index.tsx index 721d83b..ba966f9 100644 --- a/src/pages/atdTable/index.tsx +++ b/src/pages/atdTable/index.tsx @@ -1,9 +1,9 @@ import React, { FC } from 'react'; -import AntdTable from './components/antdTable'; +import AntdTableColumns2 from './components/antdTable'; const AtdTable: FC = (props) => { - return + return }; export default AtdTable;