模板管理新增时,获取选择模板接口增加type字段;
评价结果审批状态通过字典获取
This commit is contained in:
@ -79,7 +79,7 @@ const SupplierAnnualTemplateManageAdd: React.FC<PageProps> = ({ breadcrumb, disp
|
||||
const fetchTemplateList = async () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
const res = await getAllAnnualTemplates({ status: '1' });
|
||||
const res = await getAllAnnualTemplates({ status: '1', type: 'currentUnit' });
|
||||
if (res.success && res.data) {
|
||||
// 如果是修改,需要过滤掉自己
|
||||
if (location.state?.editData) {
|
||||
@ -144,7 +144,7 @@ const SupplierAnnualTemplateManageAdd: React.FC<PageProps> = ({ breadcrumb, disp
|
||||
if (location.state?.editData?.id && dispatch) {
|
||||
dispatch({
|
||||
type: 'breadcrumb/updateBreadcrumbName',
|
||||
payload: intl.formatMessage({ id: "supplierAnnualTemplateManage.add.edit" }),
|
||||
payload: intl.formatMessage({ id: 'supplierAnnualTemplateManage.add.edit' }),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -13,17 +13,17 @@ import {
|
||||
message,
|
||||
} from 'antd';
|
||||
import type { TablePaginationConfig } from 'antd';
|
||||
import {
|
||||
SearchOutlined,
|
||||
DeleteOutlined,
|
||||
} from '@ant-design/icons';
|
||||
import { SearchOutlined, DeleteOutlined } from '@ant-design/icons';
|
||||
import { TaskStatusText, TaskStatusColor } from '@/dicts/supplierTaskDict';
|
||||
import { history, useIntl } from 'umi';
|
||||
import { getEvaluateResultList, submitTaskForApproval, supplierChangeApprove } from '@/servers/api/supplierEvaluate';
|
||||
import {
|
||||
getEvaluateResultList,
|
||||
submitTaskForApproval,
|
||||
supplierChangeApprove,
|
||||
} from '@/servers/api/supplierEvaluate';
|
||||
import { getDictList } from '@/servers/api/dicts';
|
||||
import type { DictItem } from '@/servers/api/dicts';
|
||||
|
||||
|
||||
import { render } from 'react-dom';
|
||||
|
||||
// 扩展评价任务搜索参数类型
|
||||
interface EvaluateTaskSearchParams {
|
||||
@ -33,29 +33,26 @@ interface EvaluateTaskSearchParams {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
|
||||
const { Option } = Select;
|
||||
const { RangePicker } = DatePicker;
|
||||
|
||||
const SupplierEvaluateResult: React.FC = () => {
|
||||
const userId = sessionStorage.getItem('userId') || '';
|
||||
const intl = useIntl();
|
||||
const [loading, setLoading] = useState < boolean > (false);
|
||||
const [loading, setLoading] = useState<boolean>(false);
|
||||
const [form] = Form.useForm();
|
||||
const [resultData, setResultData] = useState < SupplierEvaluateResult.EvaluateTaskItem[] > ([]);
|
||||
const [pagination, setPagination] = useState < TablePaginationConfig > ({
|
||||
const [resultData, setResultData] = useState<SupplierEvaluateResult.EvaluateTaskItem[]>([]);
|
||||
const [pagination, setPagination] = useState<TablePaginationConfig>({
|
||||
current: 1,
|
||||
pageSize: 10,
|
||||
total: 0,
|
||||
showSizeChanger: true,
|
||||
showQuickJumper: true,
|
||||
showTotal: (total) => intl.formatMessage(
|
||||
{ id: 'supplierEvaluateResult.pagination.total' },
|
||||
{ total }
|
||||
),
|
||||
showTotal: (total) =>
|
||||
intl.formatMessage({ id: 'supplierEvaluateResult.pagination.total' }, { total }),
|
||||
});
|
||||
const [searchParams, setSearchParams] = useState < EvaluateTaskSearchParams > ({});
|
||||
const [evaluateStatus, setEvaluateStatus] = useState < DictItem[] > ([]);
|
||||
const [searchParams, setSearchParams] = useState<EvaluateTaskSearchParams>({});
|
||||
const [evaluateStatus, setEvaluateStatus] = useState<DictItem[]>([]);
|
||||
// 获取评价结果列表
|
||||
const fetchResultList = async (
|
||||
current = 1,
|
||||
@ -75,7 +72,7 @@ const SupplierEvaluateResult: React.FC = () => {
|
||||
pageNo: current,
|
||||
pageSize: pageSize,
|
||||
},
|
||||
selectBy: "create",
|
||||
selectBy: 'create',
|
||||
};
|
||||
|
||||
// 添加搜索条件
|
||||
@ -96,7 +93,7 @@ const SupplierEvaluateResult: React.FC = () => {
|
||||
const { records, total, current: currentPage, size } = response.data;
|
||||
|
||||
// 处理数据,增加表格需要的key属性
|
||||
const formattedData = records.map(record => ({
|
||||
const formattedData = records.map((record) => ({
|
||||
...record,
|
||||
key: record.id,
|
||||
}));
|
||||
@ -109,7 +106,10 @@ const SupplierEvaluateResult: React.FC = () => {
|
||||
total,
|
||||
});
|
||||
} else {
|
||||
message.error(response.message || intl.formatMessage({ id: 'supplierEvaluateResult.message.fetchFailed' }));
|
||||
message.error(
|
||||
response.message ||
|
||||
intl.formatMessage({ id: 'supplierEvaluateResult.message.fetchFailed' }),
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取评价结果列表失败:', error);
|
||||
@ -118,6 +118,7 @@ const SupplierEvaluateResult: React.FC = () => {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
const [approveTypeList, setApproveTypeList] = useState<DictItem[]>([]);
|
||||
|
||||
// 首次加载获取数据
|
||||
useEffect(() => {
|
||||
@ -127,6 +128,12 @@ const SupplierEvaluateResult: React.FC = () => {
|
||||
setEvaluateStatus(res.data);
|
||||
}
|
||||
});
|
||||
// 获取审批状态字典
|
||||
getDictList('approve_type').then((res) => {
|
||||
if (res.success) {
|
||||
setApproveTypeList(res.data);
|
||||
}
|
||||
});
|
||||
}, []);
|
||||
|
||||
// 处理表格分页变化
|
||||
@ -158,7 +165,7 @@ const SupplierEvaluateResult: React.FC = () => {
|
||||
title: intl.formatMessage({ id: 'supplierEvaluateResult.confirm.title' }),
|
||||
content: intl.formatMessage(
|
||||
{ id: 'supplierEvaluateResult.confirm.content' },
|
||||
{ theme: record.evaluateTheme }
|
||||
{ theme: record.evaluateTheme },
|
||||
),
|
||||
okText: intl.formatMessage({ id: 'supplierEvaluateResult.confirm.ok' }),
|
||||
cancelText: intl.formatMessage({ id: 'supplierEvaluateResult.confirm.cancel' }),
|
||||
@ -166,17 +173,22 @@ const SupplierEvaluateResult: React.FC = () => {
|
||||
try {
|
||||
const response = await submitTaskForApproval(record.id);
|
||||
if (response.success) {
|
||||
message.success(intl.formatMessage({ id: 'supplierEvaluateResult.message.approveSuccess' }));
|
||||
message.success(
|
||||
intl.formatMessage({ id: 'supplierEvaluateResult.message.approveSuccess' }),
|
||||
);
|
||||
// 刷新数据
|
||||
fetchResultList(pagination.current, pagination.pageSize, searchParams);
|
||||
} else {
|
||||
message.error(response.message || intl.formatMessage({ id: 'supplierEvaluateResult.message.approveFailed' }));
|
||||
message.error(
|
||||
response.message ||
|
||||
intl.formatMessage({ id: 'supplierEvaluateResult.message.approveFailed' }),
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('提交审批失败:', error);
|
||||
message.error(intl.formatMessage({ id: 'supplierEvaluateResult.message.approveError' }));
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
@ -184,11 +196,10 @@ const SupplierEvaluateResult: React.FC = () => {
|
||||
const handleViewDetail = (record: SupplierEvaluateResult.EvaluateTaskItem) => {
|
||||
history.push({
|
||||
pathname: 'supplierEvaluateResultInfo',
|
||||
state: { record }
|
||||
state: { record },
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
const columns = [
|
||||
{
|
||||
title: intl.formatMessage({ id: 'supplierEvaluateResult.column.index' }),
|
||||
@ -219,7 +230,10 @@ const SupplierEvaluateResult: React.FC = () => {
|
||||
showTitle: false,
|
||||
},
|
||||
render: (text: string) => (
|
||||
<Tooltip placement="topLeft" title={text || intl.formatMessage({ id: 'supplierEvaluateResult.text.unspecified' })}>
|
||||
<Tooltip
|
||||
placement="topLeft"
|
||||
title={text || intl.formatMessage({ id: 'supplierEvaluateResult.text.unspecified' })}
|
||||
>
|
||||
{text || intl.formatMessage({ id: 'supplierEvaluateResult.text.unspecified' })}
|
||||
</Tooltip>
|
||||
),
|
||||
@ -258,9 +272,12 @@ const SupplierEvaluateResult: React.FC = () => {
|
||||
},
|
||||
{
|
||||
title: intl.formatMessage({ id: 'supplierEvaluateResult.column.approveName' }),
|
||||
dataIndex: 'approveName',
|
||||
key: 'approveName',
|
||||
dataIndex: 'approveStatus',
|
||||
key: 'approveStatus',
|
||||
width: 100,
|
||||
render: (text: string, record: any) => (
|
||||
<div>{approveTypeList.find((item) => item.code === text)?.dicName || '-'}</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: intl.formatMessage({ id: 'supplierEvaluateResult.column.action' }),
|
||||
@ -278,11 +295,16 @@ const SupplierEvaluateResult: React.FC = () => {
|
||||
</Button>
|
||||
)}
|
||||
{record.approveStatus === '0' && userId == '8' && (
|
||||
<Button type="link" onClick={() => {
|
||||
supplierChangeApprove({ workFlowId: record.workFlowId, approveStatus: '1' }).then(() => {
|
||||
handleReset()
|
||||
})
|
||||
}}>
|
||||
<Button
|
||||
type="link"
|
||||
onClick={() => {
|
||||
supplierChangeApprove({ workFlowId: record.workFlowId, approveStatus: '1' }).then(
|
||||
() => {
|
||||
handleReset();
|
||||
},
|
||||
);
|
||||
}}
|
||||
>
|
||||
审批
|
||||
</Button>
|
||||
)}
|
||||
@ -294,27 +316,38 @@ const SupplierEvaluateResult: React.FC = () => {
|
||||
return (
|
||||
<div className="common-container">
|
||||
<div className="filter-action-row">
|
||||
<Form
|
||||
form={form}
|
||||
layout="inline"
|
||||
onFinish={handleSearch}
|
||||
className="filter-form"
|
||||
>
|
||||
<Form.Item name="evaluateTheme" label={intl.formatMessage({ id: 'supplierEvaluateResult.form.evaluateTheme' })}>
|
||||
<Input placeholder={intl.formatMessage({ id: 'supplierEvaluateResult.form.placeholder.evaluateTheme' })} allowClear />
|
||||
<Form form={form} layout="inline" onFinish={handleSearch} className="filter-form">
|
||||
<Form.Item
|
||||
name="evaluateTheme"
|
||||
label={intl.formatMessage({ id: 'supplierEvaluateResult.form.evaluateTheme' })}
|
||||
>
|
||||
<Input
|
||||
placeholder={intl.formatMessage({
|
||||
id: 'supplierEvaluateResult.form.placeholder.evaluateTheme',
|
||||
})}
|
||||
allowClear
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item name="timeRange" label={intl.formatMessage({ id: 'supplierEvaluateResult.form.evaluationTime' })}>
|
||||
<Form.Item
|
||||
name="timeRange"
|
||||
label={intl.formatMessage({ id: 'supplierEvaluateResult.form.evaluationTime' })}
|
||||
>
|
||||
<RangePicker
|
||||
placeholder={[
|
||||
intl.formatMessage({ id: 'supplierEvaluateResult.form.placeholder.startDate' }),
|
||||
intl.formatMessage({ id: 'supplierEvaluateResult.form.placeholder.endDate' })
|
||||
intl.formatMessage({ id: 'supplierEvaluateResult.form.placeholder.endDate' }),
|
||||
]}
|
||||
format="YYYY-MM-DD"
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item name="status" label={intl.formatMessage({ id: 'supplierEvaluateResult.form.status' })}>
|
||||
<Form.Item
|
||||
name="status"
|
||||
label={intl.formatMessage({ id: 'supplierEvaluateResult.form.status' })}
|
||||
>
|
||||
<Select
|
||||
placeholder={intl.formatMessage({ id: 'supplierEvaluateResult.form.placeholder.status' })}
|
||||
placeholder={intl.formatMessage({
|
||||
id: 'supplierEvaluateResult.form.placeholder.status',
|
||||
})}
|
||||
allowClear
|
||||
style={{ width: 150 }}
|
||||
>
|
||||
@ -329,12 +362,7 @@ const SupplierEvaluateResult: React.FC = () => {
|
||||
<Button type="primary" icon={<SearchOutlined />} onClick={() => form.submit()}>
|
||||
{intl.formatMessage({ id: 'supplierEvaluateResult.button.search' })}
|
||||
</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
danger
|
||||
icon={<DeleteOutlined />}
|
||||
onClick={handleReset}
|
||||
>
|
||||
<Button type="primary" danger icon={<DeleteOutlined />} onClick={handleReset}>
|
||||
{intl.formatMessage({ id: 'supplierEvaluateResult.button.reset' })}
|
||||
</Button>
|
||||
</Form.Item>
|
||||
|
@ -92,7 +92,7 @@ const SupplierTemplateManageAdd: React.FC<PageProps> = ({ breadcrumb, dispatch }
|
||||
// 获取所有模板列表
|
||||
const fetchTemplateList = async () => {
|
||||
try {
|
||||
const res = await getAllTemplates({ status: '1' });
|
||||
const res = await getAllTemplates({ status: '1', type: 'currentUnit' });
|
||||
if (res.success && res.data) {
|
||||
// 如果是修改,需要过滤掉自己
|
||||
if (location.state?.editData) {
|
||||
@ -234,10 +234,9 @@ const SupplierTemplateManageAdd: React.FC<PageProps> = ({ breadcrumb, dispatch }
|
||||
// 校验每个一级指标下的二级指标之和是否等于该一级指标分值
|
||||
for (const stItem of templateData) {
|
||||
const firstLevelScore = parseFloat(stItem.score || '0');
|
||||
const secondLevelTotal = stItem.indicatorNdList?.reduce(
|
||||
(acc, ndItem) => acc + parseFloat(ndItem.score || '0'),
|
||||
0,
|
||||
) || 0;
|
||||
const secondLevelTotal =
|
||||
stItem.indicatorNdList?.reduce((acc, ndItem) => acc + parseFloat(ndItem.score || '0'), 0) ||
|
||||
0;
|
||||
|
||||
if (secondLevelTotal !== firstLevelScore) {
|
||||
message.error(`二级指标分值之和必须等于其一级指标的分值`);
|
||||
@ -305,8 +304,8 @@ const SupplierTemplateManageAdd: React.FC<PageProps> = ({ breadcrumb, dispatch }
|
||||
message.error(intl.formatMessage({ id: 'supplierTemplateManage.message.addIndicator' }));
|
||||
return;
|
||||
}
|
||||
// 校验分数
|
||||
if (!validateScore()) {
|
||||
// 校验分数
|
||||
if (!validateScore()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ export async function getAnnualTemplateList(params: supplierAnnualTemplateManage
|
||||
* 获取所有供应商年度模板列表
|
||||
* @returns Promise
|
||||
*/
|
||||
export async function getAllAnnualTemplates(params?: {status: string}) {
|
||||
export async function getAllAnnualTemplates(params?: { status: string, type: string }) {
|
||||
return request<supplierAnnualTemplateManage.AllTemplatesResponse>('/annualreview/template/getAllList', {
|
||||
method: 'GET',
|
||||
params
|
||||
|
@ -3,7 +3,7 @@ import request from '@/utils/request';
|
||||
* 获取所有模板列表
|
||||
* @returns 所有模板列表
|
||||
*/
|
||||
export async function getAllTemplates(params?: {status: string}) {
|
||||
export async function getAllTemplates(params?: { status: string, type: string }) {
|
||||
return request('/coscoEvaluate/template/getAllList', {
|
||||
method: 'GET',
|
||||
params
|
||||
@ -362,4 +362,4 @@ export async function submitTaskForApproval(id: string) {
|
||||
});
|
||||
}
|
||||
|
||||
export const supplierChangeApprove = (data: { workFlowId:string; approveStatus:string }) => request.post('/synchronous/evaluateApprove', { data });
|
||||
export const supplierChangeApprove = (data: { workFlowId: string; approveStatus: string }) => request.post('/synchronous/evaluateApprove', { data });
|
||||
|
Reference in New Issue
Block a user