diff --git a/.prettierrc b/.prettierrc index 94beb14..d6aa589 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,11 +1,13 @@ { - "singleQuote": true, - "trailingComma": "all", - "printWidth": 80, + "singleQuote": false, + "trailingComma": "none", + "printWidth": 200, "overrides": [ { "files": ".prettierrc", - "options": { "parser": "json" } + "options": { + "parser": "json" + } } ] } diff --git a/config/config.dev.ts b/config/config.dev.ts index 436ada0..5da1ba9 100644 --- a/config/config.dev.ts +++ b/config/config.dev.ts @@ -13,7 +13,7 @@ export default defineConfig({ // changeOrigin: true, // }, '/api': { - target: 'http://192.168.0.114:7603/api', + target: 'http://192.168.1.78:7603/api', changeOrigin: true, pathRewrite: { '^/api': '', diff --git a/src/global.less b/src/global.less index efe5926..845e097 100644 --- a/src/global.less +++ b/src/global.less @@ -140,7 +140,7 @@ input:-webkit-autofill { -webkit-box-shadow: 0 0 0px 1000px white inset !important; } -.ant-dropdown-menu { - max-height: calc(100vh - 300px); - overflow-y: auto; -} +//.ant-dropdown-menu { +// max-height: calc(100vh - 300px); +// overflow-y: auto; +//} diff --git a/src/pages/atdTable/components/index.less b/src/pages/atdTable/components/index.less index bed55a6..4de9ec0 100644 --- a/src/pages/atdTable/components/index.less +++ b/src/pages/atdTable/components/index.less @@ -30,6 +30,7 @@ display: flex; justify-content: space-between; align-items: center; + min-height: 22px; .contentTitle { flex: 1; @@ -388,3 +389,44 @@ overflow-y: hidden; } +//右键菜单样式 +.contextMenu { + min-width: 120px; + + :global { + .ant-dropdown-menu { + padding: 0; + + .ant-dropdown-menu-item:hover { + background-color: #57c5f7; + color: #fff; + + .ant-dropdown-menu-item-icon { + background-color: #57c5f7; + color: #fff; + } + } + + .ant-dropdown-menu-item { + height: 30px; + line-height: 30px; + padding: 0 5px 0 0; + overflow: hidden; + white-space: nowrap; + -o-text-overflow: ellipsis; + text-overflow: ellipsis; + color: #333; + + .ant-dropdown-menu-item-icon { + display: flex; + justify-content: center; + width: 36px; + height: 100%; + margin-right: 6px; + text-align: center; + background: #f2f5f7; + } + } + } + } +} diff --git a/src/pages/calcTable/index.tsx b/src/pages/calcTable/index.tsx index 7aedce1..b5330ca 100644 --- a/src/pages/calcTable/index.tsx +++ b/src/pages/calcTable/index.tsx @@ -4,20 +4,20 @@ * Description: * Date: 2023/9/14 */ -import React, { FunctionComponent, useEffect, useState } from "react"; -import { Button, Space, Table, Typography } from "antd"; -import { LockOutlined } from "@ant-design/icons"; -import CustomTableTitle from "@/pages/calcTable/customTableTitle"; -import CalcExplainFooter from "@/pages/calcTable/calcExplainFooter"; -import CaclFixedTotal from "./calcFixedTotal"; -import type { ColumnType } from "antd/lib/table"; -import type { PaginationData } from "rc-pagination"; -import { exceptStr, paginationFun } from "@/utils/common"; -import { IPage } from "@/common/types"; -import styles from "@/pages/atdTable/components/index.less"; +import React, { FunctionComponent, useEffect, useState } from 'react'; +import type { MenuProps } from 'antd'; +import { Button, Dropdown, Space, Table, Typography } from 'antd'; +import { LockOutlined } from '@ant-design/icons'; +import CustomTableTitle from '@/pages/calcTable/customTableTitle'; +import CalcExplainFooter from '@/pages/calcTable/calcExplainFooter'; +import CaclFixedTotal from './calcFixedTotal'; +import type { ColumnType } from 'antd/lib/table'; +import type { PaginationData } from 'rc-pagination'; +import { exceptStr, paginationFun } from '@/utils/common'; +import { IPage } from '@/common/types'; +import styles from '@/pages/atdTable/components/index.less'; -interface OwnProps { -} +interface OwnProps {} type Props = OwnProps; type fixedProps = boolean | "top" | "bottom"; @@ -35,7 +35,7 @@ const index: FunctionComponent = (props) => { const [tableScrollHeight, setTableScrollHeight] = useState(0); const [payload, setPayload] = useState(""); const [fixed, setFixed] = useState(true); - const [sumRow, setSumRow] = useState>({});//总计行数据 + const [sumRow, setSumRow] = useState>({}); //总计行数据 useEffect(() => { window.parent.postMessage({ type: "init" }, "*"); @@ -48,9 +48,19 @@ const index: FunctionComponent = (props) => { const data: any = exceptStr(event.data); if (!_.isEmpty(data)) { const { - columns, dataSource, pageInfo, selectedRowKeys: rowKeys = [], i18n: i18nRes = {}, - showTotalCell = false, sumRowlistUrl = "", payload = {}, calcDetail, - fixed = true, tableScrollHeight, sumRow, optWidth + columns, + dataSource, + pageInfo, + selectedRowKeys: rowKeys = [], + i18n: i18nRes = {}, + showTotalCell = false, + sumRowlistUrl = "", + payload = {}, + calcDetail, + fixed = true, + tableScrollHeight, + sumRow, + optWidth } = data; setSumRowlistUrl(sumRowlistUrl); setShowTotalCell(showTotalCell); @@ -63,69 +73,91 @@ const index: FunctionComponent = (props) => { setDataSource(dataSource); setSelectedRowKeys([...selectedRowKeys, ...rowKeys]); setTableScrollHeight(tableScrollHeight); - setColumns([...convertColumns(_.map(columns, o => ({ ...o, i18n: i18nRes }))), { - title: i18nRes["操作"], dataIndex: "operate", fixed: "right", width: optWidth || 120, - render: (__, record) => ( - - - {record?.lockStatus === "LOCK" && {record?.lockTime}} - ) - }]); + setColumns([ + ...convertColumns(_.map(columns, (o) => ({ ...o, i18n: i18nRes }))), + { + title: i18nRes["操作"], + dataIndex: "operate", + fixed: "right", + width: optWidth || 120, + render: (__, record) => ( + + + {record?.lockTime && {record?.lockTime}} + + ) + } + ]); } }; const convertColumns: any = (cols: any[]) => { - return _.map(cols, item => { + return _.map(cols, (item) => { if (_.isNaN(parseInt(item.dataIndex))) { return { ...item }; } else { return { - ...item, title: , - children: convertColumns(_.map(item.children, o => ({ ...o, i18n: item.i18n }))), - className: styles["td_odd"], i18n: item.i18n, - render: (text: string, record: any) => ( - - {text} + ...item, + title: , + children: convertColumns(_.map(item.children, (o) => ({ ...o, i18n: item.i18n }))), + className: styles["td_odd"], + i18n: item.i18n, + onCell: (record: any) => ({ + onContextMenu: (e: any) => { + e.preventDefault(); + } + }), + render: (text: string, record: any) => { + const items: MenuProps["items"] = [ + { + label: item.i18n["锁定"], + key: "LOCK", + icon: , + onClick: () => + handleLockEmp({ + lockStatus: "LOCK", + acctEmpId: record?.id, + salaryItemId: item?.dataIndex + }) + }, { - (item.lockStatus === "LOCK" || record.lockStatus === "LOCK") ? - : null + label: item.i18n["解锁"], + key: "UNLOCK", + icon: , + onClick: () => + handleLockEmp({ + lockStatus: "UNLOCK", + acctEmpId: record?.id, + salaryItemId: item?.dataIndex + }) } - - ) + ]; + return ( + + + + {text} + + {record.lockItems.includes(item.dataIndex) ? : null} + + + ); + } }; } }); }; const handleFormulaTd = (dataIndex: string) => { - window.parent.postMessage( - { - type: "turn", - payload: { id: "FORMULA", params: { dataIndex } } - }, - "*" - ); + window.parent.postMessage({ type: "turn", payload: { id: "FORMULA", params: { dataIndex } } }, "*"); }; const handleEdit = (id: string) => { - window.parent.postMessage( - { - type: "turn", - payload: { id: "EDIT", params: { id } } - }, - "*" - ); - }; - const handleLockEmp = (record: any) => { - const { id, lockStatus } = record; - window.parent.postMessage({ - type: "turn", - payload: { id: "LOCKEMP", params: { lockStatus: lockStatus === "UNLOCK" ? "LOCK" : "UNLOCK", acctEmpIds: [id] } } - }, - "*" - ); + window.parent.postMessage({ type: "turn", payload: { id: "EDIT", params: { id } } }, "*"); }; - const sizeChange = (pageobj: IPage) => { + const handleLockEmp = (params: any) => { + window.parent.postMessage({ type: "turn", payload: { id: "LOCKEMP", params } }, "*"); }; + const sizeChange = (pageobj: IPage) => {}; const onChange = (pageobj: IPage) => { setPageInfo(() => { window.parent.postMessage( @@ -139,38 +171,60 @@ const index: FunctionComponent = (props) => { }); }; const rowSelection = { - columnWidth: 60, columnTitle: (isDetailTable && !showTotalCell) ? "序号" : "", - renderCell: (value: boolean, record: any, index: number, originNode: React.ReactNode) => ((isDetailTable && !showTotalCell) ? - {index + 1} : originNode), - selectedRowKeys, preserveSelectedRowKeys: true, + columnWidth: 60, + columnTitle: isDetailTable && !showTotalCell ? "序号" : "", + renderCell: (value: boolean, record: any, index: number, originNode: React.ReactNode) => (isDetailTable && !showTotalCell ? {index + 1} : originNode), + selectedRowKeys, + preserveSelectedRowKeys: true, onChange: (rowKeys: React.Key[]) => { setSelectedRowKeys(rowKeys); window.parent.postMessage( - { type: "turn", payload: { id: "CHECKBOX", params: { selectedRowKeys: rowKeys } } }, + { + type: "turn", + payload: { id: "CHECKBOX", params: { selectedRowKeys: rowKeys } } + }, "*" ); } }; - return ( o.dataIndex !== "operate")} - footer={() => !isDetailTable ? : null} - pagination={!_.isNil(pageInfo) ? { - ...paginationFun(pageInfo, sizeChange, onChange, i18n), - size: "default" - } : false} - summary={() => ( - !showTotalCell ? <> : - - - {i18n["总计"]} - - - - )} - />); + return ( +
o.dataIndex !== "operate")} + footer={() => (!isDetailTable ? : null)} + pagination={ + !_.isNil(pageInfo) + ? { + ...paginationFun(pageInfo, sizeChange, onChange, i18n), + size: "default" + } + : false + } + summary={() => + !showTotalCell ? ( + <> + ) : ( + + + + {i18n["总计"]} + + + + + ) + } + /> + ); }; export default index;