feat: 参考原型图 ui优化提交 企业端-企业中心 相关的页面
This commit is contained in:
@@ -18,21 +18,14 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
Table,
|
||||
Button,
|
||||
Tag,
|
||||
Toast,
|
||||
Input,
|
||||
Empty,
|
||||
Popconfirm,
|
||||
} from '@/components/ui';
|
||||
import { RefreshCw, Check, X } from 'lucide-react';
|
||||
import { Form as AntForm, Tabs as AntTabs } from 'antd';
|
||||
import { Table, Button, Tag, Toast, Input, Popconfirm } from '@/components/ui';
|
||||
import { RefreshCw } from 'lucide-react';
|
||||
import { API } from '../../helpers/api';
|
||||
import { showError, collectPagedItems } from '../../helpers';
|
||||
import { renderQuota } from '../../helpers/render';
|
||||
import OrgPageHeader from './components/OrgPageHeader';
|
||||
import OrgPanel from './components/OrgPanel';
|
||||
import { OrgListCard, OrgRowActions } from './components/OrgListCard';
|
||||
import OrgModal from './components/OrgModal';
|
||||
import { orgStatusColor } from './components/orgStatus';
|
||||
|
||||
@@ -56,7 +49,11 @@ const statusTag = (t, s) => {
|
||||
expired: { x: t('已过期') },
|
||||
};
|
||||
const v = m[s] || { x: s };
|
||||
return <Tag color={orgStatusColor(s)}>{v.x}</Tag>;
|
||||
return (
|
||||
<Tag color={orgStatusColor(s)} bordered={false}>
|
||||
{v.x}
|
||||
</Tag>
|
||||
);
|
||||
};
|
||||
|
||||
const parseDelta = (payload) => {
|
||||
@@ -135,8 +132,9 @@ const OrgRequests = ({ orgId, orgRole, featureFlags }) => {
|
||||
}
|
||||
};
|
||||
|
||||
// 列宽与渲染对齐原型 EnterpriseApprovals(80/90/210/140/300/120/130,scroll.x 1080)
|
||||
const columns = [
|
||||
{ title: 'ID', dataIndex: 'id', width: 60 },
|
||||
{ title: 'ID', dataIndex: 'id', width: 80 },
|
||||
{
|
||||
title: t('类型'),
|
||||
dataIndex: 'request_type',
|
||||
@@ -145,7 +143,7 @@ const OrgRequests = ({ orgId, orgRole, featureFlags }) => {
|
||||
},
|
||||
{
|
||||
title: t('对象'),
|
||||
width: 160,
|
||||
width: 210,
|
||||
ellipsis: true,
|
||||
render: (_, r) => {
|
||||
const label =
|
||||
@@ -153,7 +151,7 @@ const OrgRequests = ({ orgId, orgRole, featureFlags }) => {
|
||||
project: t('项目'),
|
||||
department: t('部门'),
|
||||
member: t('成员'),
|
||||
token: t('令牌'),
|
||||
token: t('密钥'),
|
||||
org: t('企业'),
|
||||
}[r.subject_type] || r.subject_type;
|
||||
// 后端已富化 subject_name;主体被删除等极端情况回退为 #ID
|
||||
@@ -164,25 +162,34 @@ const OrgRequests = ({ orgId, orgRole, featureFlags }) => {
|
||||
},
|
||||
{
|
||||
title: t('提额'),
|
||||
width: 110,
|
||||
render: (_, r) =>
|
||||
r.request_type === 'quota'
|
||||
? renderQuota(parseDelta(r.payload), 2)
|
||||
: '-',
|
||||
width: 140,
|
||||
render: (_, r) => (
|
||||
<span className='oc-number'>
|
||||
{r.request_type === 'quota'
|
||||
? renderQuota(parseDelta(r.payload), 2)
|
||||
: '-'}
|
||||
</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t('理由'),
|
||||
dataIndex: 'reason',
|
||||
width: 300,
|
||||
ellipsis: true,
|
||||
render: (v) => v || '-',
|
||||
},
|
||||
{ title: t('理由'), dataIndex: 'reason', ellipsis: true },
|
||||
{
|
||||
title: t('状态'),
|
||||
dataIndex: 'status',
|
||||
width: 90,
|
||||
width: 120,
|
||||
render: (v) => statusTag(t, v),
|
||||
},
|
||||
{
|
||||
title: t('操作'),
|
||||
width: 220,
|
||||
width: 130,
|
||||
render: (_, r) =>
|
||||
isApprover && r.status === 'pending' ? (
|
||||
<div className='flex items-center gap-2'>
|
||||
<OrgRowActions>
|
||||
<Popconfirm
|
||||
title={t('确认通过该提额申请?')}
|
||||
content={
|
||||
@@ -206,27 +213,14 @@ const OrgRequests = ({ orgId, orgRole, featureFlags }) => {
|
||||
position='topRight'
|
||||
onConfirm={() => decide(r.id, 'approved')}
|
||||
>
|
||||
<Button
|
||||
size='small'
|
||||
theme='solid'
|
||||
type='primary'
|
||||
icon={<Check size={14} />}
|
||||
>
|
||||
{t('通过')}
|
||||
</Button>
|
||||
<Button type='link'>{t('通过')}</Button>
|
||||
</Popconfirm>
|
||||
<Button
|
||||
size='small'
|
||||
theme='light'
|
||||
type='danger'
|
||||
icon={<X size={14} />}
|
||||
onClick={() => setRejectFor(r.id)}
|
||||
>
|
||||
<Button type='link' danger onClick={() => setRejectFor(r.id)}>
|
||||
{t('拒绝')}
|
||||
</Button>
|
||||
</div>
|
||||
</OrgRowActions>
|
||||
) : (
|
||||
<span className='text-xs text-gray-400'>-</span>
|
||||
'-'
|
||||
),
|
||||
},
|
||||
];
|
||||
@@ -234,56 +228,60 @@ const OrgRequests = ({ orgId, orgRole, featureFlags }) => {
|
||||
const filters = ['pending', 'approved', 'rejected', ''];
|
||||
|
||||
return (
|
||||
<div className='uc-page'>
|
||||
<div className='uc-page oc-page'>
|
||||
<OrgPageHeader
|
||||
title={isApprover ? t('审批中心') : t('我的申请')}
|
||||
subtitle={t('提额申请与审批')}
|
||||
actions={
|
||||
/>
|
||||
|
||||
{/* 原型 platform-list-tabs:状态筛选页签(只切换筛选,不承载内容),回调沿用 setStatusFilter */}
|
||||
<AntTabs
|
||||
className='oc-list-tabs oc-tabs-nav-only'
|
||||
activeKey={statusFilter || 'all'}
|
||||
onChange={(key) => setStatusFilter(key === 'all' ? '' : key)}
|
||||
items={filters.map((f) => ({
|
||||
key: f || 'all',
|
||||
label:
|
||||
f === 'pending'
|
||||
? t('待审批')
|
||||
: f === 'approved'
|
||||
? t('已通过')
|
||||
: f === 'rejected'
|
||||
? t('已拒绝')
|
||||
: t('全部'),
|
||||
}))}
|
||||
/>
|
||||
|
||||
<OrgListCard
|
||||
title={t('申请列表')}
|
||||
tools={
|
||||
<Button
|
||||
theme='light'
|
||||
icon={<RefreshCw size={14} />}
|
||||
icon={<RefreshCw size={16} />}
|
||||
loading={loading}
|
||||
onClick={fetchList}
|
||||
>
|
||||
{t('刷新')}
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
|
||||
<div className='flex items-center gap-2 mb-3'>
|
||||
{filters.map((f) => (
|
||||
<Button
|
||||
key={f || 'all'}
|
||||
size='small'
|
||||
theme={statusFilter === f ? 'solid' : 'light'}
|
||||
onClick={() => setStatusFilter(f)}
|
||||
>
|
||||
{f === 'pending'
|
||||
? t('待审批')
|
||||
: f === 'approved'
|
||||
? t('已通过')
|
||||
: f === 'rejected'
|
||||
? t('已拒绝')
|
||||
: t('全部')}
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<OrgPanel padding='p-2'>
|
||||
{list.length === 0 && !loading ? (
|
||||
<Empty description={t('暂无申请')} style={{ padding: 40 }} />
|
||||
) : (
|
||||
<Table
|
||||
columns={columns}
|
||||
dataSource={list}
|
||||
loading={loading}
|
||||
pagination={{ pageSize: 15, showSizeChanger: false }}
|
||||
rowKey='id'
|
||||
/>
|
||||
)}
|
||||
</OrgPanel>
|
||||
>
|
||||
<Table
|
||||
columns={columns}
|
||||
dataSource={list}
|
||||
loading={loading}
|
||||
empty={t('暂无申请')}
|
||||
pagination={{
|
||||
pageSize: 15,
|
||||
showSizeChanger: false,
|
||||
showTotal: (total) => t('共 {{total}} 条', { total }),
|
||||
}}
|
||||
rowKey='id'
|
||||
scroll={{ x: 1080 }}
|
||||
/>
|
||||
</OrgListCard>
|
||||
|
||||
<OrgModal
|
||||
className='oc-dialog oc-reject-dialog'
|
||||
width={520}
|
||||
title={t('拒绝申请')}
|
||||
visible={!!rejectFor}
|
||||
onOk={() => decide(rejectFor, 'rejected', rejectComment)}
|
||||
@@ -294,11 +292,16 @@ const OrgRequests = ({ orgId, orgRole, featureFlags }) => {
|
||||
okText={t('确认拒绝')}
|
||||
cancelText={t('取消')}
|
||||
>
|
||||
<Input
|
||||
placeholder={t('拒绝理由(可选)')}
|
||||
value={rejectComment}
|
||||
onChange={setRejectComment}
|
||||
/>
|
||||
{/* 原型:竖排表单项“拒绝理由(可选)”;仅布局,取值与提交沿用 rejectComment / decide */}
|
||||
<AntForm layout='vertical' requiredMark={false} component='div'>
|
||||
<AntForm.Item label={t('拒绝理由(可选)')}>
|
||||
<Input
|
||||
placeholder={t('请输入拒绝理由')}
|
||||
value={rejectComment}
|
||||
onChange={setRejectComment}
|
||||
/>
|
||||
</AntForm.Item>
|
||||
</AntForm>
|
||||
</OrgModal>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user