diff --git a/src/pages/Usermgmt/Companyuser/index.tsx b/src/pages/Usermgmt/Companyuser/index.tsx new file mode 100644 index 0000000..bf3e9cd --- /dev/null +++ b/src/pages/Usermgmt/Companyuser/index.tsx @@ -0,0 +1,254 @@ +import React, { useEffect, useRef, useState } from 'react'; +import { Form, Input, Modal, Switch, Tag, message } from 'antd'; +import { ActionType, ProColumns, ProTable } from '@ant-design/pro-components'; +import { changeLcCompanyStatus, getAdminCompanyList, resetLcPsw } from '@/services/cms/company'; +import { getDictValueEnum } from '@/services/system/dict'; +import DictTag from '@/components/DictTag'; + +function CompanyUserList() { + const actionRef = useRef(); + const [scaleEnum, setScaleEnum] = useState>({}); + const [natureEnum, setNatureEnum] = useState>({}); + const [passwordModalOpen, setPasswordModalOpen] = useState(false); + const [currentRecord, setCurrentRecord] = useState(null); + const [passwordForm] = Form.useForm(); + + useEffect(() => { + getDictValueEnum('scale', true, true).then(setScaleEnum); + getDictValueEnum('company_nature', true, true).then(setNatureEnum); + }, []); + + const columns: ProColumns[] = [ + { + title: '企业名称', + dataIndex: 'name', + valueType: 'text', + align: 'center', + width: 200, + }, + { + title: '企业编号', + dataIndex: 'code', + valueType: 'text', + align: 'center', + width: 160, + }, + { + title: '企业性质', + dataIndex: 'nature', + valueType: 'select', + align: 'center', + width: 100, + valueEnum: natureEnum, + render: (_, record) => , + }, + { + title: '企业规模', + dataIndex: 'scale', + valueType: 'select', + align: 'center', + width: 100, + valueEnum: scaleEnum, + render: (_, record) => , + }, + { + title: '注册地址', + dataIndex: 'registeredAddress', + valueType: 'text', + hideInSearch: true, + align: 'center', + width: 200, + ellipsis: true, + }, + { + title: '法定代表人', + dataIndex: 'legalPerson', + valueType: 'text', + align: 'center', + width: 100, + }, + { + title: '联系人', + dataIndex: 'contactPerson', + valueType: 'text', + align: 'center', + width: 100, + render: (_, record) => record.contactPerson || '-', + }, + { + title: '联系电话', + dataIndex: 'contactPersonPhone', + valueType: 'text', + align: 'center', + width: 130, + render: (_, record) => record.contactPersonPhone || '-', + }, + { + title: '状态', + dataIndex: 'status', + valueType: 'select', + align: 'center', + width: 90, + valueEnum: { + 0: { text: '待审核', status: 'Processing' }, + 1: { text: '通过', status: 'Success' }, + 2: { text: '驳回', status: 'Error' }, + }, + render: (_, record) => { + if (record.status === 1) return 通过; + if (record.status === 2) return 驳回; + return 待审核; + }, + }, + { + title: '创建时间', + dataIndex: 'createTime', + valueType: 'dateTime', + hideInSearch: true, + align: 'center', + width: 160, + }, + { + title: '更新时间', + dataIndex: 'updateTime', + valueType: 'dateTime', + hideInSearch: true, + align: 'center', + width: 160, + }, + { + title: '是否启用', + dataIndex: 'enableStatus', + align: 'center', + width: 100, + fixed: 'right', + hideInSearch: true, + render: (_, record) => ( + { + try { + await changeLcCompanyStatus({ + userId: record.lcUserid, + status: checked ? '0' : '1', + }); + message.success(checked ? '已启用' : '已停用'); + actionRef.current?.reload(); + } catch { + message.error('操作失败'); + } + }} + /> + ), + }, + { + title: '操作', + align: 'center', + width: 120, + fixed: 'right', + hideInSearch: true, + render: (_, record) => ( + { + setCurrentRecord(record); + passwordForm.resetFields(); + setPasswordModalOpen(true); + }} + > + 修改密码 + + ), + }, + ]; + + return ( +
+ + actionRef={actionRef} + rowKey="companyId" + columns={columns} + request={(params) => + getAdminCompanyList({ ...params } as API.CmsCompany.Params).then((res) => ({ + data: res.rows || [], + total: res.total, + success: true, + })) + } + search={{ labelWidth: 'auto' }} + scroll={{ x: 'max-content' }} + pagination={{ defaultPageSize: 10, showSizeChanger: true }} + headerTitle="企业用户管理" + /> + setPasswordModalOpen(false)} + onOk={() => passwordForm.submit()} + destroyOnHidden + > +
{ + try { + await resetLcPsw({ + userId: currentRecord!.lcUserid, + password: values.password, + }); + message.success('密码修改成功'); + setPasswordModalOpen(false); + } catch { + message.error('密码修改失败'); + } + }} + > + { + if (!value) return Promise.resolve(); + const hasUpper = /[A-Z]/.test(value); + const hasLower = /[a-z]/.test(value); + const hasDigit = /\d/.test(value); + const specialChars = value.match(/[^a-zA-Z0-9]/g); + const hasTwoSpecial = specialChars && specialChars.length >= 2; + if (!hasUpper) return Promise.reject(new Error('密码需包含大写字母')); + if (!hasLower) return Promise.reject(new Error('密码需包含小写字母')); + if (!hasDigit) return Promise.reject(new Error('密码需包含数字')); + if (!hasTwoSpecial) return Promise.reject(new Error('密码需包含至少2个特殊字符')); + return Promise.resolve(); + }, + }, + ]} + > + + + ({ + validator(_, value) { + if (!value || getFieldValue('password') === value) { + return Promise.resolve(); + } + return Promise.reject(new Error('两次输入的密码不一致')); + }, + }), + ]} + > + + +
+
+
+ ); +} + +export default CompanyUserList; diff --git a/src/services/cms/company.ts b/src/services/cms/company.ts new file mode 100644 index 0000000..85140d4 --- /dev/null +++ b/src/services/cms/company.ts @@ -0,0 +1,48 @@ +import { request } from '@umijs/max'; + +/** + * 分页查询企业用户管理列表 + * GET /cms/company/adminCompanyList + */ +export async function getAdminCompanyList( + params?: API.CmsCompany.Params & { + current?: number; + pageSize?: number; + }, +) { + return request( + '/api/cms/company/adminCompanyList', + { + method: 'GET', + params, + }, + ); +} + +/** + * 切换企业用户启用/停用状态 + * POST /cms/appUser/changeLcCompanyStatus + */ +export async function changeLcCompanyStatus(data: { + userId: number; + status: string; +}) { + return request('/api/cms/appUser/changeLcCompanyStatus', { + method: 'POST', + data, + }); +} + +/** + * 浪潮修改密码 + * POST /cms/appUser/resetLcPsw + */ +export async function resetLcPsw(data: { + userId: number; + password: string; +}) { + return request('/api/cms/appUser/resetLcPsw', { + method: 'POST', + data, + }); +} diff --git a/src/types/cms/company.d.ts b/src/types/cms/company.d.ts new file mode 100644 index 0000000..55e38cb --- /dev/null +++ b/src/types/cms/company.d.ts @@ -0,0 +1,58 @@ +declare namespace API.CmsCompany { + export interface CompanyUserResult { + total: number; + rows: CompanyUser[]; + code: number; + msg: string; + data?: any; + } + + export interface CompanyUser { + createTime: string; + updateTime: string; + companyId: number; + name: string; + location?: string | null; + industry: string; + scale?: string | null; + code: string; + description?: string | null; + nature: string; + totalRecruitment?: string | null; + isCollection?: any; + userId?: number | null; + businessLicenseUrl?: string | null; + idCardPictureUrl?: string | null; + idCardPictureBackUrl?: string | null; + powerOfAttorneyUrl?: string | null; + contactPerson?: string | null; + contactPersonPhone?: string | null; + status: number; // 0 待审核, 1 通过, 2 驳回 + notPassReason?: string | null; + companyContactList?: any; + registeredAddress: string; + isAbnormal?: any; + rejectTime?: string | null; + isImpCompany?: any; + impCompanyType?: any; + enterpriseType?: string | null; + legalPerson: string; + legalIdCard: string; + legalPhone: string; + companyStatus?: any; + isHrs: string; + jobList?: any; + lcUserid: number; + } + + export interface Params { + pageNum?: number; + pageSize?: number; + name?: string; + status?: number; + code?: string; + legalPerson?: string; + contactPerson?: string; + contactPersonPhone?: string; + } +}