From 0b90547ceb4ce324d939a34bcc86ecf8f15b43d0 Mon Sep 17 00:00:00 2001 From: francis-fh Date: Fri, 24 Jul 2026 16:19:41 +0800 Subject: [PATCH] 11 --- src/pages/Usermgmt/Companyuser/index.tsx | 342 ++++++++++++++++++++++- 1 file changed, 334 insertions(+), 8 deletions(-) diff --git a/src/pages/Usermgmt/Companyuser/index.tsx b/src/pages/Usermgmt/Companyuser/index.tsx index 583c487..392feb0 100644 --- a/src/pages/Usermgmt/Companyuser/index.tsx +++ b/src/pages/Usermgmt/Companyuser/index.tsx @@ -1,14 +1,81 @@ import React, { useEffect, useRef, useState } from 'react'; -import { Form, Input, Modal, Switch, Tag, message } from 'antd'; +import { Form, Input, Modal, Switch, Tag, Button, message } from 'antd'; import { ActionType, ProColumns, ProTable } from '@ant-design/pro-components'; +import { useAccess } from '@umijs/max'; +import { + DeleteOutlined, + FormOutlined, + AlignLeftOutlined, + AuditOutlined, + PlusOutlined, +} from '@ant-design/icons'; +import EditCompanyListRow, { CompanyDetailView } from '@/pages/Company/List/edit'; +import { + addCmsCompanyList, + delCmsCompanyList, + getCmsCompanyDetail, + parseCmsCompanyDetailResponse, + putCmsCompanyList, +} from '@/services/company/list'; +import { postCompanyApproval } from '@/services/company/review'; import { changeLcCompanyStatus, getAdminCompanyList, resetLcPsw } from '@/services/cms/company'; import { getDictValueEnum } from '@/services/system/dict'; -import DictTag from '@/components/DictTag'; +import { getCmsIndustryTreeList } from '@/services/classify/industry'; +import DictTag, { DictValueEnumObj } from '@/components/DictTag'; + +/** 将行业树数据展平为 DictValueEnumObj */ +const flattenIndustryTree = (tree: { id: number; label: string; children?: any[] }[]): DictValueEnumObj => { + const map: DictValueEnumObj = {}; + const walk = (nodes: { id: number; label: string; children?: any[] }[]) => { + nodes?.forEach((node) => { + map[node.id] = { + text: node.label, + label: node.label, + value: node.id, + }; + if (node.children?.length) { + walk(node.children); + } + }); + }; + walk(tree); + return map; +}; + +const loadCompanyDetail = async (record: API.CmsCompany.CompanyUser) => { + const resp = await getCmsCompanyDetail(record.companyId); + const detail = parseCmsCompanyDetailResponse(resp); + if (!detail) { + return { ...record } as any; + } + return { ...record, ...detail } as any; +}; function CompanyUserList() { + const access = useAccess(); const actionRef = useRef(); + + // ---- 字典数据 ---- const [scaleEnum, setScaleEnum] = useState>({}); const [natureEnum, setNatureEnum] = useState>({}); + const [companyNatureEnum, setCompanyNatureEnum] = useState({}); + const [industryEnum, setIndustryEnum] = useState({}); + + // ---- 编辑弹窗 ---- + const [currentRow, setCurrentRow] = useState(); + const [modalVisible, setModalVisible] = useState(false); + + // ---- 详情弹窗 ---- + const [detailVisible, setDetailVisible] = useState(false); + const [detailLoading, setDetailLoading] = useState(false); + const [detailData, setDetailData] = useState(); + + // ---- 审核弹窗 ---- + const [approvalVisible, setApprovalVisible] = useState(false); + const [approvalStatus, setApprovalStatus] = useState<1 | 2>(1); + const [approvalReason, setApprovalReason] = useState(''); + + // ---- 密码修改弹窗 ---- const [passwordModalOpen, setPasswordModalOpen] = useState(false); const [currentRecord, setCurrentRecord] = useState(null); const [passwordForm] = Form.useForm(); @@ -16,8 +83,34 @@ function CompanyUserList() { useEffect(() => { getDictValueEnum('scale', true, true).then(setScaleEnum); getDictValueEnum('company_nature', true, true).then(setNatureEnum); + getDictValueEnum('company_nature', false, true).then(setCompanyNatureEnum); + getCmsIndustryTreeList().then((res) => { + if (res?.data) { + setIndustryEnum(flattenIndustryTree(res.data)); + } + }); }, []); + // ---- 删除处理 ---- + const handleRemoveOne = async (companyId: string) => { + const hide = message.loading('正在删除'); + if (!companyId) return true; + try { + const resp = await delCmsCompanyList(companyId); + hide(); + if (resp.code === 200) { + message.success('删除成功,即将刷新'); + } else { + message.error(resp.msg); + } + return true; + } catch (error) { + hide(); + message.error('删除失败,请重试'); + return false; + } + }; + const columns: ProColumns[] = [ { title: '企业名称', @@ -49,7 +142,7 @@ function CompanyUserList() { align: 'center', width: 100, valueEnum: scaleEnum, - render: (_, record) => , + render: (_, record) => , }, { title: '注册地址', @@ -148,11 +241,96 @@ function CompanyUserList() { { title: '操作', align: 'center', - width: 120, + width: 320, fixed: 'right', hideInSearch: true, - render: (_, record) => ( - [ + , + , + , + , + , + ], }, ]; @@ -182,7 +360,155 @@ function CompanyUserList() { scroll={{ x: 'max-content' }} pagination={{ defaultPageSize: 10, showSizeChanger: true }} headerTitle="企业用户管理" + toolBarRender={() => [ + , + ]} /> + + {/* 编辑/新增弹窗 */} + { + let resData; + if (values.companyId) { + resData = await putCmsCompanyList({ + ...values, + companyNature: values.companyNature || '', + }); + } else { + resData = await addCmsCompanyList({ + ...values, + companyNature: values.companyNature || '', + }); + } + if (resData.code === 200) { + setModalVisible(false); + setCurrentRow(undefined); + message.success(values.companyId ? '修改成功' : '新增成功'); + actionRef.current?.reload(); + } + }} + onCancel={() => { + setModalVisible(false); + setCurrentRow(undefined); + }} + values={currentRow} + scaleEnum={scaleEnum} + companyNatureEnum={companyNatureEnum} + /> + + {/* 详情弹窗 */} + { + setDetailVisible(false); + setDetailData(undefined); + }} + record={detailData} + scaleEnum={scaleEnum} + companyNatureEnum={companyNatureEnum} + industryEnum={industryEnum} + /> + + {/* 审核弹窗 */} + { + setApprovalVisible(false); + setApprovalReason(''); + }} + footer={null} + > +
+
+ 审核结果: + + +
+ {approvalStatus === 2 && ( +
+
驳回原因(必填):
+