增加icon图表;修改供应商评价新增是选择模板禁用和提示逻辑

This commit is contained in:
linxd
2025-07-03 15:45:21 +08:00
parent 307b16e61e
commit 815cf6b89e
13 changed files with 1418 additions and 260 deletions

View File

@ -1,30 +1,14 @@
import React, { useState, useEffect } from 'react';
import { history, useIntl } from 'umi';
import {
Button,
Table,
Space,
message,
Input,
Select,
Form,
Tooltip,
Tag,
} from 'antd';
import { Button, Table, Space, message, Input, Select, Form, Tooltip, Tag } from 'antd';
import type { TablePaginationConfig } from 'antd';
import {
PlusOutlined,
DeleteOutlined,
SearchOutlined,
} from '@ant-design/icons';
import { PlusOutlined, DeleteOutlined, SearchOutlined } from '@ant-design/icons';
import {
TemplateStatusText,
TemplateStatusColor,
TemplateStatus,
} from '@/dicts/supplierTemplateDict';
import {
getTemplateList,
} from '@/servers/api/supplierEvaluate';
import { getTemplateList } from '@/servers/api/supplierEvaluate';
import CategorySelector from '@/components/CategorySelector/CategorySelector';
const { Option } = Select;
@ -41,15 +25,13 @@ const SupplierTemplateManage: React.FC = () => {
total: 0,
showSizeChanger: true,
showQuickJumper: true,
showTotal: (total) => intl.formatMessage(
{ id: 'supplierTemplateManage.pagination.total' },
{ total }
),
showTotal: (total) =>
intl.formatMessage({ id: 'supplierTemplateManage.pagination.total' }, { total }),
});
const [searchParams, setSearchParams] = useState({});
// 部门下拉选项
const [companyOptions, setCompanyOptions] = useState<{ label: string, value: string }[]>([
const [companyOptions, setCompanyOptions] = useState<{ label: string; value: string }[]>([
{ label: '中山市合创展包装材料有限公司', value: '中山市合创展包装材料有限公司' },
{ label: '广州市科技发展有限公司', value: '广州市科技发展有限公司' },
{ label: '深圳市创新科技有限公司', value: '深圳市创新科技有限公司' },
@ -57,11 +39,7 @@ const SupplierTemplateManage: React.FC = () => {
]);
// 获取模板列表
const fetchTemplateList = async (
current = 1,
pageSize = 10,
params = searchParams,
) => {
const fetchTemplateList = async (current = 1, pageSize = 10, params = searchParams) => {
// 更新搜索参数状态
if (params !== searchParams) {
setSearchParams(params);
@ -81,7 +59,7 @@ const SupplierTemplateManage: React.FC = () => {
if (res.success && res.data) {
// 处理返回的数据
const records = res.data.records
const records = res.data.records;
setTemplateData(records);
setPagination({
@ -91,7 +69,9 @@ const SupplierTemplateManage: React.FC = () => {
total: res.data.total,
});
} else {
message.error(intl.formatMessage({ id: 'supplierTemplateManage.message.fetchFailed' }) || res.message);
message.error(
intl.formatMessage({ id: 'supplierTemplateManage.message.fetchFailed' }) || res.message,
);
}
} catch (error) {
console.error('获取模板列表失败:', error);
@ -113,7 +93,7 @@ const SupplierTemplateManage: React.FC = () => {
pathname: 'supplierTemplateManageDetail',
state: {
id: record.id,
}
},
});
};
@ -124,16 +104,19 @@ const SupplierTemplateManage: React.FC = () => {
pathname: 'supplierTemplateManageAdd',
state: {
isEdit: true,
editData: record
}
editData: record,
},
});
};
// 获取状态标签
const getStatusTag = (status: string | undefined) => {
if (!status) return <Tag>{intl.formatMessage({ id: 'supplierTemplateManage.status.unknown' })}</Tag>;
if (!status)
return <Tag>{intl.formatMessage({ id: 'supplierTemplateManage.status.unknown' })}</Tag>;
const color = TemplateStatusColor[status as keyof typeof TemplateStatusColor] || 'default';
const text = TemplateStatusText[status as keyof typeof TemplateStatusText] || intl.formatMessage({ id: 'supplierTemplateManage.status.unknown' });
const text =
TemplateStatusText[status as keyof typeof TemplateStatusText] ||
intl.formatMessage({ id: 'supplierTemplateManage.status.unknown' });
return <Tag color={color}>{text}</Tag>;
};
@ -209,9 +192,12 @@ const SupplierTemplateManage: React.FC = () => {
align: 'center' as const,
render: (_: unknown, record: SupplierTemplateManage.TemplateItem) => (
<Space size="middle">
<Button type="link" onClick={() => handleEdit(record)}>
{intl.formatMessage({ id: 'supplierTemplateManage.button.edit' })}
</Button>
{/* 只有草稿状态才可以编辑 */}
{record.status === TemplateStatus.DRAFT && (
<Button type="link" onClick={() => handleEdit(record)}>
{intl.formatMessage({ id: 'supplierTemplateManage.button.edit' })}
</Button>
)}
<Button type="link" onClick={() => handleView(record)}>
{intl.formatMessage({ id: 'supplierTemplateManage.button.view' })}
</Button>
@ -248,17 +234,39 @@ const SupplierTemplateManage: React.FC = () => {
layout="inline"
className="filter-form"
>
<Form.Item name="templateName" label={intl.formatMessage({ id: 'supplierTemplateManage.column.templateName' })}>
<Input placeholder={intl.formatMessage({ id: 'supplierTemplateManage.placeholder.templateName' })} allowClear />
<Form.Item
name="templateName"
label={intl.formatMessage({ id: 'supplierTemplateManage.column.templateName' })}
>
<Input
placeholder={intl.formatMessage({
id: 'supplierTemplateManage.placeholder.templateName',
})}
allowClear
/>
</Form.Item>
<Form.Item name="tenantName" label={intl.formatMessage({ id: 'supplierTemplateManage.column.tenantName' })}>
<Select placeholder={intl.formatMessage({ id: 'supplierTemplateManage.placeholder.tenantName' })} allowClear style={{ width: 200 }}>
{companyOptions.map(option => (
<Option key={option.value} value={option.value}>{option.label}</Option>
<Form.Item
name="tenantName"
label={intl.formatMessage({ id: 'supplierTemplateManage.column.tenantName' })}
>
<Select
placeholder={intl.formatMessage({
id: 'supplierTemplateManage.placeholder.tenantName',
})}
allowClear
style={{ width: 200 }}
>
{companyOptions.map((option) => (
<Option key={option.value} value={option.value}>
{option.label}
</Option>
))}
</Select>
</Form.Item>
<Form.Item name="categoryId" label={intl.formatMessage({ id: 'supplierTemplateManage.column.category' })}>
<Form.Item
name="categoryId"
label={intl.formatMessage({ id: 'supplierTemplateManage.column.category' })}
>
<CategorySelector multiple={false} style={{ width: 200 }} />
</Form.Item>
<Form.Item className="filter-btns">