From ec00312701df785a20bf827636b1a6d8325582cc Mon Sep 17 00:00:00 2001 From: uiujun Date: Tue, 1 Jul 2025 10:40:00 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9B=E5=B2=97=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../asset_projects/modals/GridCreate.tsx | 2 +- src/pages/company/companies/$id.tsx | 22 ++++- .../companies/components/Positions.tsx | 76 +++++++++++++++++ .../company/companies/components/Projects.tsx | 82 +++++++++++++++++++ .../companies/modals/PositionsCreate.tsx | 62 ++++++++++++++ src/pages/company/employees/index.tsx | 12 +-- src/pages/company/employees/modals/Create.tsx | 10 +-- src/pages/company/employees/modals/Update.tsx | 8 +- src/pages/company/positions/index.tsx | 74 +++++++++++++++++ src/pages/company/positions/modals/Create.tsx | 62 ++++++++++++++ src/pages/company/positions/modals/Update.tsx | 74 +++++++++++++++++ 11 files changed, 467 insertions(+), 17 deletions(-) create mode 100644 src/pages/company/companies/components/Positions.tsx create mode 100644 src/pages/company/companies/components/Projects.tsx create mode 100644 src/pages/company/companies/modals/PositionsCreate.tsx create mode 100644 src/pages/company/positions/index.tsx create mode 100644 src/pages/company/positions/modals/Create.tsx create mode 100644 src/pages/company/positions/modals/Update.tsx diff --git a/src/pages/asset/asset_projects/modals/GridCreate.tsx b/src/pages/asset/asset_projects/modals/GridCreate.tsx index 11554fd..86a7ab9 100644 --- a/src/pages/asset/asset_projects/modals/GridCreate.tsx +++ b/src/pages/asset/asset_projects/modals/GridCreate.tsx @@ -29,7 +29,7 @@ export default function Create(props: MyBetaModalFormProps) { values?.grid_ranges?.map((res: { asset_projects_id: string }) => { res.asset_projects_id = props?.item?.id; }); - Apis.Grid.Grids.Store({ + return Apis.Grid.Grids.Store({ ...values, asset_projects_id: props?.item?.id, }) diff --git a/src/pages/company/companies/$id.tsx b/src/pages/company/companies/$id.tsx index 6928045..cc5ebfc 100644 --- a/src/pages/company/companies/$id.tsx +++ b/src/pages/company/companies/$id.tsx @@ -6,6 +6,8 @@ import { Tabs } from 'antd'; import { useEffect, useState } from 'react'; import ComponentsInfo from './components/ComponentsInfo'; import Organizations from './components/Organizations'; +import Positions from './components/Positions'; +import Projects from './components/Projects'; export default function Show({ title = '机构详情' }) { const { id } = useParams<{ id: string }>(); const [data, setShow] = useState({}); @@ -28,11 +30,29 @@ export default function Show({ title = '机构详情' }) { children: loadShow()} />, }, { - label: '组织', + label: '项目管理', key: '2', closable: false, + children: , + }, + { + label: '组织管理', + key: '3', + closable: false, children: , }, + { + label: '员工管理', + key: '4', + closable: false, + // children: , + }, + { + label: '岗位管理', + key: '5', + closable: false, + children: , + }, ]; return ( diff --git a/src/pages/company/companies/components/Positions.tsx b/src/pages/company/companies/components/Positions.tsx new file mode 100644 index 0000000..561ba00 --- /dev/null +++ b/src/pages/company/companies/components/Positions.tsx @@ -0,0 +1,76 @@ +import { + MyBetaModalFormProps, + MyButtons, + MyColumns, + MyProTableProps, +} from '@/common'; +import { Apis } from '@/gen/Apis'; +import { ProTable } from '@ant-design/pro-components'; +import { Space } from 'antd'; +import OrganizationsCreate from '../modals/OrganizationsCreate'; + +export default function Organizations(props: MyBetaModalFormProps) { + return ( + <> + + MyProTableProps.request( + { ...params, companies_id: props?.item?.id }, + sort, + Apis.Company.CompanyPositions.List, + ) + } + toolBarRender={(action) => [ + , + ]} + options={false} + columns={[ + MyColumns.ID(), + + { + title: '岗位名称', + dataIndex: 'name', + }, + { + title: '岗位编号', + dataIndex: 'code', + search: false, + }, + { + title: '岗位排序', + dataIndex: 'sort', + search: false, + }, + { + title: '备注', + dataIndex: 'remark', + search: false, + }, + MyColumns.UpdatedAt(), + MyColumns.CreatedAt(), + MyColumns.Option({ + render: (_, item: any, index, action) => ( + + {/* */} + + Apis.Common.Admins.Delete({ id: item.id }).then(() => + action?.reload(), + ) + } + /> + + ), + }), + ]} + /> + + ); +} diff --git a/src/pages/company/companies/components/Projects.tsx b/src/pages/company/companies/components/Projects.tsx new file mode 100644 index 0000000..87afca4 --- /dev/null +++ b/src/pages/company/companies/components/Projects.tsx @@ -0,0 +1,82 @@ +import { + MyBetaModalFormProps, + MyButtons, + MyColumns, + MyProTableProps, +} from '@/common'; +import { Apis } from '@/gen/Apis'; +import { OrganizationsTypeEnum } from '@/gen/Enums'; +import { ProTable } from '@ant-design/pro-components'; +import { Space } from 'antd'; +import OrganizationsCreate from '../modals/OrganizationsCreate'; +import OrganizationsUpdate from '../modals/OrganizationsUpdate'; + +export default function Organizations(props: MyBetaModalFormProps) { + return ( + <> + + MyProTableProps.request( + { ...params, companies_id: props?.item?.id }, + sort, + Apis.Company.Organizations.List, + ) + } + toolBarRender={(action) => [ + , + ]} + options={false} + columns={[ + MyColumns.ID(), + { + title: '上级组织', + dataIndex: ['organization_parent', 'name'], + }, + { + title: '组织', + dataIndex: 'name', + }, + MyColumns.EnumTag({ + title: '类型', + dataIndex: 'type', + valueEnum: OrganizationsTypeEnum, + }), + { + title: '负责人', + dataIndex: ['manager', 'name'], + }, + { + title: '联系电话', + dataIndex: 'manager_phone', + }, + + MyColumns.Option({ + render: (_, item: any, index, action) => ( + + + + Apis.Company.Organizations.Delete({ id: item.id }).then( + () => action?.reload(), + ) + } + /> + + ), + }), + ]} + /> + + ); +} diff --git a/src/pages/company/companies/modals/PositionsCreate.tsx b/src/pages/company/companies/modals/PositionsCreate.tsx new file mode 100644 index 0000000..f8aa8a3 --- /dev/null +++ b/src/pages/company/companies/modals/PositionsCreate.tsx @@ -0,0 +1,62 @@ +import { + MyBetaModalFormProps, + MyButtons, + MyModalFormProps, + rulesHelper, +} from '@/common'; +import { Selects } from '@/components/Select'; +import { Apis } from '@/gen/Apis'; +import { BetaSchemaForm } from '@ant-design/pro-components'; +import { message } from 'antd'; + +export default function Create(props: MyBetaModalFormProps) { + return ( + + {...MyModalFormProps.props} + title={`添加${props.title}`} + wrapperCol={{ span: 24 }} + width="500px" + trigger={} + onFinish={async (values) => + Apis.Company.CompanyPositions.Store(values) + .then(() => { + props.reload?.(); + message.success(props.title + '成功'); + return true; + }) + .catch(() => false) + } + columns={[ + Selects?.Companies({ + title: '机构', + key: 'companies_id', + formItemProps: { ...rulesHelper.text }, + }), + { + key: 'name', + title: '岗位名称', + colProps: { span: 12 }, + formItemProps: { ...rulesHelper.text }, + }, + { + key: 'code', + title: '岗位编号', + colProps: { span: 12 }, + // formItemProps: { ...rulesHelper.text }, + }, + // { + // key: 'sort', + // title: '岗位排序', + // colProps: { span: 24 }, + // valueType: 'number', + // }, + { + key: 'remark', + title: '备注', + colProps: { span: 24 }, + valueType: 'textarea', + }, + ]} + /> + ); +} diff --git a/src/pages/company/employees/index.tsx b/src/pages/company/employees/index.tsx index 8a48043..08b18f9 100644 --- a/src/pages/company/employees/index.tsx +++ b/src/pages/company/employees/index.tsx @@ -10,12 +10,12 @@ import { Space } from 'antd'; import Create from './modals/Create'; import Update from './modals/Update'; -export default function Index({ title = '管理员' }) { +export default function Index({ title = '员工管理' }) { return ( MyProTableProps.request( params, @@ -40,10 +40,10 @@ export default function Index({ title = '管理员' }) { title: '机构', dataIndex: ['company', 'name'], }, - { - title: '组织', - dataIndex: ['organization', 'name'], - }, + // { + // title: '组织', + // dataIndex: ['organization', 'name'], + // }, MyColumns.UpdatedAt(), MyColumns.CreatedAt(), MyColumns.Option({ diff --git a/src/pages/company/employees/modals/Create.tsx b/src/pages/company/employees/modals/Create.tsx index 89cdbea..5cb299a 100644 --- a/src/pages/company/employees/modals/Create.tsx +++ b/src/pages/company/employees/modals/Create.tsx @@ -15,10 +15,10 @@ export default function Create(props: MyBetaModalFormProps) { return ( {...MyModalFormProps.props} - title={`添加${props.title}`} + title={`添加员工`} wrapperCol={{ span: 24 }} width="500px" - trigger={} + trigger={} onFinish={async (values) => Apis.Company.CompanyEmployees.Store(values) .then(() => { @@ -30,7 +30,7 @@ export default function Create(props: MyBetaModalFormProps) { } columns={[ Selects?.Companies({ - title: '机构', + title: '所属机构', key: 'companies_id', formItemProps: { ...rulesHelper.text }, }), @@ -49,7 +49,7 @@ export default function Create(props: MyBetaModalFormProps) { { key: 'name', title: '姓名', - colProps: { span: 12 }, + colProps: { span: 6 }, formItemProps: { ...rulesHelper.text }, }, { @@ -65,7 +65,7 @@ export default function Create(props: MyBetaModalFormProps) { MyFormItems.EnumRadio({ key: 'sex', title: '性别', - colProps: { span: 24 }, + colProps: { span: 6 }, valueEnum: SexEnum, required: true, }), diff --git a/src/pages/company/employees/modals/Update.tsx b/src/pages/company/employees/modals/Update.tsx index 4cd4497..30237bf 100644 --- a/src/pages/company/employees/modals/Update.tsx +++ b/src/pages/company/employees/modals/Update.tsx @@ -16,7 +16,7 @@ export default function Update(props: MyBetaModalFormProps) { return ( {...MyModalFormProps.props} - title={`编辑${props.title}`} + title={`编辑员工`} trigger={} wrapperCol={{ span: 24 }} width="500px" @@ -43,7 +43,7 @@ export default function Update(props: MyBetaModalFormProps) { } columns={[ Selects?.Companies({ - title: '机构', + title: '所属机构', key: 'companies_id', formItemProps: { ...rulesHelper.text }, }), @@ -62,7 +62,7 @@ export default function Update(props: MyBetaModalFormProps) { { key: 'name', title: '姓名', - colProps: { span: 12 }, + colProps: { span: 6 }, formItemProps: { ...rulesHelper.text }, }, { @@ -78,7 +78,7 @@ export default function Update(props: MyBetaModalFormProps) { MyFormItems.EnumRadio({ key: 'sex', title: '性别', - colProps: { span: 24 }, + colProps: { span: 6 }, valueEnum: SexEnum, required: true, }), diff --git a/src/pages/company/positions/index.tsx b/src/pages/company/positions/index.tsx new file mode 100644 index 0000000..4701cf8 --- /dev/null +++ b/src/pages/company/positions/index.tsx @@ -0,0 +1,74 @@ +import { + MyButtons, + MyColumns, + MyPageContainer, + MyProTableProps, +} from '@/common'; +import { Apis } from '@/gen/Apis'; +import { ProTable } from '@ant-design/pro-components'; +import { Space } from 'antd'; +import Create from './modals/Create'; +import Update from './modals/Update'; + +export default function Index({ title = '岗位管理' }) { + return ( + + + MyProTableProps.request( + params, + sort, + Apis.Company.CompanyPositions.List, + ) + } + toolBarRender={(action) => [ + , + ]} + columns={[ + MyColumns.ID(), + { + title: '机构', + dataIndex: ['company', 'name'], + }, + { + title: '岗位名称', + dataIndex: 'name', + }, + { + title: '岗位编号', + dataIndex: 'code', + search: false, + }, + { + title: '岗位排序', + dataIndex: 'sort', + search: false, + }, + { + title: '备注', + dataIndex: 'remark', + search: false, + }, + MyColumns.UpdatedAt(), + MyColumns.CreatedAt(), + MyColumns.Option({ + render: (_, item: any, index, action) => ( + + + + Apis.Common.Admins.Delete({ id: item.id }).then(() => + action?.reload(), + ) + } + /> + + ), + }), + ]} + /> + + ); +} diff --git a/src/pages/company/positions/modals/Create.tsx b/src/pages/company/positions/modals/Create.tsx new file mode 100644 index 0000000..f8aa8a3 --- /dev/null +++ b/src/pages/company/positions/modals/Create.tsx @@ -0,0 +1,62 @@ +import { + MyBetaModalFormProps, + MyButtons, + MyModalFormProps, + rulesHelper, +} from '@/common'; +import { Selects } from '@/components/Select'; +import { Apis } from '@/gen/Apis'; +import { BetaSchemaForm } from '@ant-design/pro-components'; +import { message } from 'antd'; + +export default function Create(props: MyBetaModalFormProps) { + return ( + + {...MyModalFormProps.props} + title={`添加${props.title}`} + wrapperCol={{ span: 24 }} + width="500px" + trigger={} + onFinish={async (values) => + Apis.Company.CompanyPositions.Store(values) + .then(() => { + props.reload?.(); + message.success(props.title + '成功'); + return true; + }) + .catch(() => false) + } + columns={[ + Selects?.Companies({ + title: '机构', + key: 'companies_id', + formItemProps: { ...rulesHelper.text }, + }), + { + key: 'name', + title: '岗位名称', + colProps: { span: 12 }, + formItemProps: { ...rulesHelper.text }, + }, + { + key: 'code', + title: '岗位编号', + colProps: { span: 12 }, + // formItemProps: { ...rulesHelper.text }, + }, + // { + // key: 'sort', + // title: '岗位排序', + // colProps: { span: 24 }, + // valueType: 'number', + // }, + { + key: 'remark', + title: '备注', + colProps: { span: 24 }, + valueType: 'textarea', + }, + ]} + /> + ); +} diff --git a/src/pages/company/positions/modals/Update.tsx b/src/pages/company/positions/modals/Update.tsx new file mode 100644 index 0000000..4be6b58 --- /dev/null +++ b/src/pages/company/positions/modals/Update.tsx @@ -0,0 +1,74 @@ +import { + MyBetaModalFormProps, + MyButtons, + MyModalFormProps, + rulesHelper, +} from '@/common'; + +import { Selects } from '@/components/Select'; +import { Apis } from '@/gen/Apis'; +import { BetaSchemaForm } from '@ant-design/pro-components'; +import { Form, message } from 'antd'; +export default function Update(props: MyBetaModalFormProps) { + const [form] = Form.useForm(); + return ( + + {...MyModalFormProps.props} + title={`编辑${props.title}`} + trigger={} + wrapperCol={{ span: 24 }} + width="500px" + form={form} + onOpenChange={(open: any) => { + if (open && props.item) { + form.setFieldsValue({ + ...props.item, + }); + } + }} + onFinish={async (values) => + Apis.Company.CompanyPositions.Update({ + ...values, + id: props.item?.id ?? 0, + }) + .then(() => { + props.reload?.(); + message.success(props.title + '成功'); + return true; + }) + .catch(() => false) + } + columns={[ + Selects?.Companies({ + title: '机构', + key: 'companies_id', + formItemProps: { ...rulesHelper.text }, + }), + { + key: 'name', + title: '岗位名称', + colProps: { span: 12 }, + formItemProps: { ...rulesHelper.text }, + }, + { + key: 'code', + title: '岗位编号', + colProps: { span: 12 }, + // formItemProps: { ...rulesHelper.text }, + }, + // { + // key: 'sort', + // title: '岗位排序', + // colProps: { span: 24 }, + // valueType: 'number', + // }, + { + key: 'remark', + title: '备注', + colProps: { span: 24 }, + valueType: 'textarea', + }, + ]} + /> + ); +}