419 lines
10 KiB
TypeScript
419 lines
10 KiB
TypeScript
|
|
// 组织机构接口
|
|||
|
|
export interface Organization {
|
|||
|
|
id: string
|
|||
|
|
orgName: string
|
|||
|
|
orgType: 'SCHOOL' | 'ENTERPRISE' | 'RESEARCH_INSTITUTE' | 'GOVERNMENT' | 'OTHER'
|
|||
|
|
orgCode?: string
|
|||
|
|
orgStatus?: string
|
|||
|
|
legalRepresentative?: string
|
|||
|
|
establishmentDate?: string
|
|||
|
|
province?: string
|
|||
|
|
city?: string
|
|||
|
|
district?: string
|
|||
|
|
address?: string
|
|||
|
|
contactPhone?: string
|
|||
|
|
contactEmail?: string
|
|||
|
|
website?: string
|
|||
|
|
employeeCount?: number
|
|||
|
|
introduction?: string
|
|||
|
|
registeredCapital?: string
|
|||
|
|
businessScope?: string
|
|||
|
|
industry?: string
|
|||
|
|
isHighTech?: number
|
|||
|
|
schoolType?: string
|
|||
|
|
schoolLevel?: string
|
|||
|
|
qualificationCertificates?: string
|
|||
|
|
flag: number
|
|||
|
|
createTime: string
|
|||
|
|
updateTime: string
|
|||
|
|
createBy?: string
|
|||
|
|
updateBy?: string
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 分页查询参数
|
|||
|
|
export interface OrganizationPageParams {
|
|||
|
|
pageNum: number
|
|||
|
|
pageSize: number
|
|||
|
|
orgName?: string
|
|||
|
|
orgType?: string
|
|||
|
|
orgStatus?: string
|
|||
|
|
province?: string
|
|||
|
|
city?: string
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 新增/更新参数
|
|||
|
|
export interface OrganizationFormData {
|
|||
|
|
id?: string
|
|||
|
|
orgName: string
|
|||
|
|
orgType: string
|
|||
|
|
orgCode?: string
|
|||
|
|
orgStatus?: string
|
|||
|
|
legalRepresentative?: string
|
|||
|
|
establishmentDate?: string
|
|||
|
|
province?: string
|
|||
|
|
city?: string
|
|||
|
|
district?: string
|
|||
|
|
address?: string
|
|||
|
|
contactPhone?: string
|
|||
|
|
contactEmail?: string
|
|||
|
|
website?: string
|
|||
|
|
employeeCount?: number
|
|||
|
|
introduction?: string
|
|||
|
|
registeredCapital?: string
|
|||
|
|
businessScope?: string
|
|||
|
|
industry?: string
|
|||
|
|
isHighTech?: number
|
|||
|
|
schoolType?: string
|
|||
|
|
schoolLevel?: string
|
|||
|
|
qualificationCertificates?: string
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// API响应接口
|
|||
|
|
export interface ApiResponse<T = unknown> {
|
|||
|
|
code: number
|
|||
|
|
message: string
|
|||
|
|
data: T
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
export interface PageResponse<T> {
|
|||
|
|
records: T[]
|
|||
|
|
total: number
|
|||
|
|
size: number
|
|||
|
|
current: number
|
|||
|
|
pages: number
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// ==================== Mock 数据 ====================
|
|||
|
|
const mockOrganizations: Organization[] = [
|
|||
|
|
{
|
|||
|
|
id: '1',
|
|||
|
|
orgName: '清华大学',
|
|||
|
|
orgType: 'SCHOOL',
|
|||
|
|
orgCode: '12100000400000846E',
|
|||
|
|
orgStatus: 'ACTIVE',
|
|||
|
|
legalRepresentative: '李校长',
|
|||
|
|
establishmentDate: '1911-04-26',
|
|||
|
|
province: '北京市',
|
|||
|
|
city: '北京市',
|
|||
|
|
district: '海淀区',
|
|||
|
|
address: '清华园1号',
|
|||
|
|
contactPhone: '010-62793001',
|
|||
|
|
contactEmail: 'info@tsinghua.edu.cn',
|
|||
|
|
website: 'https://www.tsinghua.edu.cn',
|
|||
|
|
employeeCount: 15000,
|
|||
|
|
introduction: '清华大学是中国著名高等学府,坐落于北京西北郊风景秀丽的清华园。',
|
|||
|
|
schoolType: '985',
|
|||
|
|
schoolLevel: '本科',
|
|||
|
|
flag: 0,
|
|||
|
|
createTime: '2024-01-01 10:00:00',
|
|||
|
|
updateTime: '2024-01-15 14:30:00',
|
|||
|
|
createBy: 'admin',
|
|||
|
|
updateBy: 'admin'
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
id: '2',
|
|||
|
|
orgName: '华为技术有限公司',
|
|||
|
|
orgType: 'ENTERPRISE',
|
|||
|
|
orgCode: '91440300279860880E',
|
|||
|
|
orgStatus: 'ACTIVE',
|
|||
|
|
legalRepresentative: '任正非',
|
|||
|
|
establishmentDate: '1987-09-15',
|
|||
|
|
province: '广东省',
|
|||
|
|
city: '深圳市',
|
|||
|
|
district: '龙岗区',
|
|||
|
|
address: '坂田华为基地',
|
|||
|
|
contactPhone: '0755-28780808',
|
|||
|
|
contactEmail: 'contact@huawei.com',
|
|||
|
|
website: 'https://www.huawei.com',
|
|||
|
|
employeeCount: 195000,
|
|||
|
|
introduction: '华为是全球领先的ICT(信息与通信)基础设施和智能终端提供商。',
|
|||
|
|
registeredCapital: '403.08亿元',
|
|||
|
|
businessScope: '通信设备、智能终端、云计算、人工智能等',
|
|||
|
|
industry: '信息技术',
|
|||
|
|
isHighTech: 1,
|
|||
|
|
flag: 0,
|
|||
|
|
createTime: '2024-01-02 09:00:00',
|
|||
|
|
updateTime: '2024-01-16 11:20:00',
|
|||
|
|
createBy: 'admin',
|
|||
|
|
updateBy: 'admin'
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
id: '3',
|
|||
|
|
orgName: '中国科学院计算技术研究所',
|
|||
|
|
orgType: 'RESEARCH_INSTITUTE',
|
|||
|
|
orgCode: '12100000400001234X',
|
|||
|
|
orgStatus: 'ACTIVE',
|
|||
|
|
legalRepresentative: '孙凝晖',
|
|||
|
|
establishmentDate: '1956-06-01',
|
|||
|
|
province: '北京市',
|
|||
|
|
city: '北京市',
|
|||
|
|
district: '海淀区',
|
|||
|
|
address: '中关村科学院南路6号',
|
|||
|
|
contactPhone: '010-62600114',
|
|||
|
|
contactEmail: 'office@ict.ac.cn',
|
|||
|
|
website: 'http://www.ict.ac.cn',
|
|||
|
|
employeeCount: 800,
|
|||
|
|
introduction: '中国科学院计算技术研究所创建于1956年,是中国第一个专门从事计算机科学技术综合性研究的学术机构。',
|
|||
|
|
flag: 0,
|
|||
|
|
createTime: '2024-01-03 08:30:00',
|
|||
|
|
updateTime: '2024-01-17 16:45:00',
|
|||
|
|
createBy: 'admin',
|
|||
|
|
updateBy: 'admin'
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
id: '4',
|
|||
|
|
orgName: '北京市科学技术委员会',
|
|||
|
|
orgType: 'GOVERNMENT',
|
|||
|
|
orgCode: '11000000MB0109876Y',
|
|||
|
|
orgStatus: 'ACTIVE',
|
|||
|
|
legalRepresentative: '张主任',
|
|||
|
|
establishmentDate: '1978-03-01',
|
|||
|
|
province: '北京市',
|
|||
|
|
city: '北京市',
|
|||
|
|
district: '西城区',
|
|||
|
|
address: '西城区西直门南大街16号',
|
|||
|
|
contactPhone: '010-66415555',
|
|||
|
|
contactEmail: 'bjkw@beijing.gov.cn',
|
|||
|
|
website: 'http://kw.beijing.gov.cn',
|
|||
|
|
employeeCount: 300,
|
|||
|
|
introduction: '北京市科学技术委员会是北京市人民政府组成部门,负责全市科技工作的统筹规划和综合协调。',
|
|||
|
|
flag: 0,
|
|||
|
|
createTime: '2024-01-04 10:15:00',
|
|||
|
|
updateTime: '2024-01-18 09:30:00',
|
|||
|
|
createBy: 'admin',
|
|||
|
|
updateBy: 'admin'
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
id: '5',
|
|||
|
|
orgName: '北京大学',
|
|||
|
|
orgType: 'SCHOOL',
|
|||
|
|
orgCode: '12100000400000123A',
|
|||
|
|
orgStatus: 'ACTIVE',
|
|||
|
|
legalRepresentative: '郝平',
|
|||
|
|
establishmentDate: '1898-07-03',
|
|||
|
|
province: '北京市',
|
|||
|
|
city: '北京市',
|
|||
|
|
district: '海淀区',
|
|||
|
|
address: '颐和园路5号',
|
|||
|
|
contactPhone: '010-62751234',
|
|||
|
|
contactEmail: 'xxb@pku.edu.cn',
|
|||
|
|
website: 'https://www.pku.edu.cn',
|
|||
|
|
employeeCount: 12000,
|
|||
|
|
introduction: '北京大学创办于1898年,初名京师大学堂,是中国第一所国立综合性大学。',
|
|||
|
|
schoolType: '985',
|
|||
|
|
schoolLevel: '本科',
|
|||
|
|
flag: 0,
|
|||
|
|
createTime: '2024-01-05 11:00:00',
|
|||
|
|
updateTime: '2024-01-19 10:15:00',
|
|||
|
|
createBy: 'admin',
|
|||
|
|
updateBy: 'admin'
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
id: '6',
|
|||
|
|
orgName: '腾讯科技(深圳)有限公司',
|
|||
|
|
orgType: 'ENTERPRISE',
|
|||
|
|
orgCode: '91440300708461136T',
|
|||
|
|
orgStatus: 'ACTIVE',
|
|||
|
|
legalRepresentative: '马化腾',
|
|||
|
|
establishmentDate: '1998-11-11',
|
|||
|
|
province: '广东省',
|
|||
|
|
city: '深圳市',
|
|||
|
|
district: '南山区',
|
|||
|
|
address: '科技园中区一路腾讯大厦',
|
|||
|
|
contactPhone: '0755-86013388',
|
|||
|
|
contactEmail: 'service@tencent.com',
|
|||
|
|
website: 'https://www.tencent.com',
|
|||
|
|
employeeCount: 110000,
|
|||
|
|
introduction: '腾讯以技术丰富互联网用户的生活,致力成为最受尊敬的互联网企业。',
|
|||
|
|
registeredCapital: '65000万元',
|
|||
|
|
businessScope: '互联网服务、社交网络、游戏、金融科技等',
|
|||
|
|
industry: '互联网',
|
|||
|
|
isHighTech: 1,
|
|||
|
|
flag: 0,
|
|||
|
|
createTime: '2024-01-06 14:20:00',
|
|||
|
|
updateTime: '2024-01-20 15:40:00',
|
|||
|
|
createBy: 'admin',
|
|||
|
|
updateBy: 'admin'
|
|||
|
|
}
|
|||
|
|
]
|
|||
|
|
|
|||
|
|
let mockIdCounter = 7
|
|||
|
|
|
|||
|
|
// 模拟延迟
|
|||
|
|
const mockDelay = () => new Promise(resolve => setTimeout(resolve, 300))
|
|||
|
|
|
|||
|
|
// 分页查询组织机构列表
|
|||
|
|
export async function getOrganizationPage(params: OrganizationPageParams) {
|
|||
|
|
await mockDelay()
|
|||
|
|
|
|||
|
|
let filteredData = [...mockOrganizations]
|
|||
|
|
|
|||
|
|
// 过滤条件
|
|||
|
|
if (params.orgName) {
|
|||
|
|
filteredData = filteredData.filter(item =>
|
|||
|
|
item.orgName.includes(params.orgName!)
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
if (params.orgType) {
|
|||
|
|
filteredData = filteredData.filter(item => item.orgType === params.orgType)
|
|||
|
|
}
|
|||
|
|
if (params.province) {
|
|||
|
|
filteredData = filteredData.filter(item =>
|
|||
|
|
item.province?.includes(params.province!)
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
if (params.city) {
|
|||
|
|
filteredData = filteredData.filter(item =>
|
|||
|
|
item.city?.includes(params.city!)
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 分页
|
|||
|
|
const start = (params.pageNum - 1) * params.pageSize
|
|||
|
|
const end = start + params.pageSize
|
|||
|
|
const records = filteredData.slice(start, end)
|
|||
|
|
|
|||
|
|
return {
|
|||
|
|
data: {
|
|||
|
|
code: 200,
|
|||
|
|
message: '查询成功',
|
|||
|
|
data: {
|
|||
|
|
records,
|
|||
|
|
total: filteredData.length,
|
|||
|
|
size: params.pageSize,
|
|||
|
|
current: params.pageNum,
|
|||
|
|
pages: Math.ceil(filteredData.length / params.pageSize)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 获取组织机构详情
|
|||
|
|
export async function getOrganizationDetail(id: string) {
|
|||
|
|
await mockDelay()
|
|||
|
|
|
|||
|
|
const organization = mockOrganizations.find(item => item.id === id)
|
|||
|
|
|
|||
|
|
if (organization) {
|
|||
|
|
return {
|
|||
|
|
data: {
|
|||
|
|
code: 200,
|
|||
|
|
message: '查询成功',
|
|||
|
|
data: organization
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
return {
|
|||
|
|
data: {
|
|||
|
|
code: 404,
|
|||
|
|
message: '未找到该机构',
|
|||
|
|
data: null
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 新增组织机构
|
|||
|
|
export async function addOrganization(data: OrganizationFormData) {
|
|||
|
|
await mockDelay()
|
|||
|
|
|
|||
|
|
const newOrganization: Organization = {
|
|||
|
|
...data,
|
|||
|
|
id: String(mockIdCounter++),
|
|||
|
|
flag: 0,
|
|||
|
|
createTime: new Date().toISOString().replace('T', ' ').substring(0, 19),
|
|||
|
|
updateTime: new Date().toISOString().replace('T', ' ').substring(0, 19),
|
|||
|
|
createBy: 'admin',
|
|||
|
|
updateBy: 'admin'
|
|||
|
|
} as Organization
|
|||
|
|
|
|||
|
|
mockOrganizations.unshift(newOrganization)
|
|||
|
|
|
|||
|
|
return {
|
|||
|
|
data: {
|
|||
|
|
code: 200,
|
|||
|
|
message: '新增成功',
|
|||
|
|
data: null
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 修改组织机构
|
|||
|
|
export async function updateOrganization(data: OrganizationFormData) {
|
|||
|
|
await mockDelay()
|
|||
|
|
|
|||
|
|
const index = mockOrganizations.findIndex(item => item.id === data.id)
|
|||
|
|
|
|||
|
|
if (index !== -1) {
|
|||
|
|
mockOrganizations[index] = {
|
|||
|
|
...mockOrganizations[index],
|
|||
|
|
...data,
|
|||
|
|
updateTime: new Date().toISOString().replace('T', ' ').substring(0, 19),
|
|||
|
|
updateBy: 'admin'
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return {
|
|||
|
|
data: {
|
|||
|
|
code: 200,
|
|||
|
|
message: '修改成功',
|
|||
|
|
data: null
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
return {
|
|||
|
|
data: {
|
|||
|
|
code: 404,
|
|||
|
|
message: '未找到该机构',
|
|||
|
|
data: null
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 删除组织机构
|
|||
|
|
export async function deleteOrganization(id: string) {
|
|||
|
|
await mockDelay()
|
|||
|
|
|
|||
|
|
const index = mockOrganizations.findIndex(item => item.id === id)
|
|||
|
|
|
|||
|
|
if (index !== -1) {
|
|||
|
|
mockOrganizations.splice(index, 1)
|
|||
|
|
|
|||
|
|
return {
|
|||
|
|
data: {
|
|||
|
|
code: 200,
|
|||
|
|
message: '删除成功',
|
|||
|
|
data: null
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
return {
|
|||
|
|
data: {
|
|||
|
|
code: 404,
|
|||
|
|
message: '未找到该机构',
|
|||
|
|
data: null
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 批量删除组织机构
|
|||
|
|
export async function batchDeleteOrganization(ids: string[]) {
|
|||
|
|
await mockDelay()
|
|||
|
|
|
|||
|
|
ids.forEach(id => {
|
|||
|
|
const index = mockOrganizations.findIndex(item => item.id === id)
|
|||
|
|
if (index !== -1) {
|
|||
|
|
mockOrganizations.splice(index, 1)
|
|||
|
|
}
|
|||
|
|
})
|
|||
|
|
|
|||
|
|
return {
|
|||
|
|
data: {
|
|||
|
|
code: 200,
|
|||
|
|
message: '批量删除成功',
|
|||
|
|
data: null
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|