增加 停用/启用 按钮对模板状态进行操作
This commit is contained in:
@ -16,7 +16,7 @@ export const AnnualTemplateStatusText = {
|
|||||||
|
|
||||||
// 年度模板状态颜色
|
// 年度模板状态颜色
|
||||||
export const AnnualTemplateStatusColor = {
|
export const AnnualTemplateStatusColor = {
|
||||||
[AnnualTemplateStatus.DRAFT]: 'processing',
|
[AnnualTemplateStatus.DRAFT]: 'default',
|
||||||
[AnnualTemplateStatus.ENABLED]: 'success',
|
[AnnualTemplateStatus.ENABLED]: 'green',
|
||||||
[AnnualTemplateStatus.DISABLED]: 'default',
|
[AnnualTemplateStatus.DISABLED]: 'red',
|
||||||
};
|
};
|
||||||
|
@ -283,29 +283,15 @@ const SupplierAnnualTemplateManage: React.FC = () => {
|
|||||||
{intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.view' })}
|
{intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.view' })}
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
{/* 草稿状态显示启用按钮 */}
|
{/* 禁用状态显示启用按钮 草稿状态显示启用按钮 */}
|
||||||
{record.status === AnnualTemplateStatus.DRAFT && (
|
{(record.status === AnnualTemplateStatus.DISABLED || record.status === AnnualTemplateStatus.DRAFT) && (
|
||||||
<Button type="link" onClick={() => handleEnableTemplate(record.id)} size="small">
|
<Button type="link" onClick={() => handleEnableTemplate(record.id)} size="small">
|
||||||
{intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.enable' })}
|
{intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.enable' })}
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* 草稿状态显示禁用按钮 */}
|
{/* 启用状态显示禁用按钮 草稿状态显示禁用按钮 */}
|
||||||
{record.status === AnnualTemplateStatus.DRAFT && (
|
{(record.status === AnnualTemplateStatus.ENABLED || record.status === AnnualTemplateStatus.DRAFT) && (
|
||||||
<Button type="link" danger onClick={() => handleDisableTemplate(record.id)} size="small">
|
|
||||||
{intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.disable' })}
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* 禁用状态显示启用按钮 */}
|
|
||||||
{record.status === AnnualTemplateStatus.DISABLED && (
|
|
||||||
<Button type="link" onClick={() => handleEnableTemplate(record.id)} size="small">
|
|
||||||
{intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.enable' })}
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* 启用状态显示禁用按钮 */}
|
|
||||||
{record.status === AnnualTemplateStatus.ENABLED && (
|
|
||||||
<Button type="link" danger onClick={() => handleDisableTemplate(record.id)} size="small">
|
<Button type="link" danger onClick={() => handleDisableTemplate(record.id)} size="small">
|
||||||
{intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.disable' })}
|
{intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.disable' })}
|
||||||
</Button>
|
</Button>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import { history, useIntl } from 'umi';
|
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, Modal } from 'antd';
|
||||||
import type { TablePaginationConfig } from 'antd';
|
import type { TablePaginationConfig } from 'antd';
|
||||||
import { PlusOutlined, DeleteOutlined, SearchOutlined } from '@ant-design/icons';
|
import { PlusOutlined, DeleteOutlined, SearchOutlined } from '@ant-design/icons';
|
||||||
import {
|
import {
|
||||||
@ -8,7 +8,7 @@ import {
|
|||||||
TemplateStatusColor,
|
TemplateStatusColor,
|
||||||
TemplateStatus,
|
TemplateStatus,
|
||||||
} from '@/dicts/supplierTemplateDict';
|
} from '@/dicts/supplierTemplateDict';
|
||||||
import { getTemplateList } from '@/servers/api/supplierEvaluate';
|
import { getTemplateList, enableTemplate, disableTemplate } from '@/servers/api/supplierEvaluate';
|
||||||
import CategorySelector from '@/components/CategorySelector/CategorySelector';
|
import CategorySelector from '@/components/CategorySelector/CategorySelector';
|
||||||
|
|
||||||
const { Option } = Select;
|
const { Option } = Select;
|
||||||
@ -124,7 +124,59 @@ const SupplierTemplateManage: React.FC = () => {
|
|||||||
const handleTableChange = (newPagination: TablePaginationConfig) => {
|
const handleTableChange = (newPagination: TablePaginationConfig) => {
|
||||||
fetchTemplateList(newPagination.current, newPagination.pageSize, searchParams);
|
fetchTemplateList(newPagination.current, newPagination.pageSize, searchParams);
|
||||||
};
|
};
|
||||||
|
// 处理启用模板
|
||||||
|
const handleEnableTemplate = (id: string) => {
|
||||||
|
Modal.confirm({
|
||||||
|
title: intl.formatMessage({ id: 'supplierAnnualTemplateManage.modal.enableConfirmTitle' }),
|
||||||
|
content: intl.formatMessage({ id: 'supplierAnnualTemplateManage.modal.enableConfirmContent' }),
|
||||||
|
okText: intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.confirm' }),
|
||||||
|
cancelText: intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.cancel' }),
|
||||||
|
onOk: async () => {
|
||||||
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
const res = await enableTemplate(id);
|
||||||
|
if (res.success) {
|
||||||
|
message.success(intl.formatMessage({ id: 'supplierAnnualTemplateManage.modal.enableSuccess' }));
|
||||||
|
fetchTemplateList(pagination.current, pagination.pageSize, searchParams);
|
||||||
|
} else {
|
||||||
|
message.error(res.message || intl.formatMessage({ id: 'supplierAnnualTemplateManage.modal.enableFailed' }));
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('启用模板失败:', error);
|
||||||
|
message.error(intl.formatMessage({ id: 'supplierAnnualTemplateManage.modal.enableFailed' }));
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// 处理禁用模板
|
||||||
|
const handleDisableTemplate = (id: string) => {
|
||||||
|
Modal.confirm({
|
||||||
|
title: intl.formatMessage({ id: 'supplierAnnualTemplateManage.modal.disableConfirmTitle' }),
|
||||||
|
content: intl.formatMessage({ id: 'supplierAnnualTemplateManage.modal.disableConfirmContent' }),
|
||||||
|
okText: intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.confirm' }),
|
||||||
|
cancelText: intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.cancel' }),
|
||||||
|
onOk: async () => {
|
||||||
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
const res = await disableTemplate(id);
|
||||||
|
if (res.success) {
|
||||||
|
message.success(intl.formatMessage({ id: 'supplierAnnualTemplateManage.modal.disableSuccess' }));
|
||||||
|
fetchTemplateList(pagination.current, pagination.pageSize, searchParams);
|
||||||
|
} else {
|
||||||
|
message.error(res.message || intl.formatMessage({ id: 'supplierAnnualTemplateManage.modal.disableFailed' }));
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('禁用模板失败:', error);
|
||||||
|
message.error(intl.formatMessage({ id: 'supplierAnnualTemplateManage.modal.disableFailed' }));
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
const columns = [
|
const columns = [
|
||||||
{
|
{
|
||||||
title: intl.formatMessage({ id: 'supplierTemplateManage.column.index' }),
|
title: intl.formatMessage({ id: 'supplierTemplateManage.column.index' }),
|
||||||
@ -188,7 +240,7 @@ const SupplierTemplateManage: React.FC = () => {
|
|||||||
{
|
{
|
||||||
title: intl.formatMessage({ id: 'supplierTemplateManage.column.action' }),
|
title: intl.formatMessage({ id: 'supplierTemplateManage.column.action' }),
|
||||||
key: 'action',
|
key: 'action',
|
||||||
width: 150,
|
width: 200,
|
||||||
align: 'center' as const,
|
align: 'center' as const,
|
||||||
render: (_: unknown, record: SupplierTemplateManage.TemplateItem) => (
|
render: (_: unknown, record: SupplierTemplateManage.TemplateItem) => (
|
||||||
<Space size="middle">
|
<Space size="middle">
|
||||||
@ -201,6 +253,27 @@ const SupplierTemplateManage: React.FC = () => {
|
|||||||
<Button type="link" onClick={() => handleView(record)}>
|
<Button type="link" onClick={() => handleView(record)}>
|
||||||
{intl.formatMessage({ id: 'supplierTemplateManage.button.view' })}
|
{intl.formatMessage({ id: 'supplierTemplateManage.button.view' })}
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
|
{/* 禁用状态显示启用按钮 草稿状态显示启用按钮 */}
|
||||||
|
{(record.status === TemplateStatus.DISABLED ||
|
||||||
|
record.status === TemplateStatus.DRAFT) && (
|
||||||
|
<Button type="link" onClick={() => handleEnableTemplate(record.id)} size="small">
|
||||||
|
{intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.enable' })}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* 启用状态显示禁用按钮 草稿状态显示禁用按钮 */}
|
||||||
|
{(record.status === TemplateStatus.ENABLED ||
|
||||||
|
record.status === TemplateStatus.DRAFT) && (
|
||||||
|
<Button
|
||||||
|
type="link"
|
||||||
|
danger
|
||||||
|
onClick={() => handleDisableTemplate(record.id)}
|
||||||
|
size="small"
|
||||||
|
>
|
||||||
|
{intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.disable' })}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
</Space>
|
</Space>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
@ -76,7 +76,7 @@ export async function deleteTemplate(id: string) {
|
|||||||
* @returns Promise
|
* @returns Promise
|
||||||
*/
|
*/
|
||||||
export async function enableTemplate(id: string) {
|
export async function enableTemplate(id: string) {
|
||||||
return request<API.APIResponse<any>>('/coscoEvaluate/template/enable', {
|
return request<API.APIResponse<any>>('/coscoEvaluate/template/up', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: { id },
|
data: { id },
|
||||||
});
|
});
|
||||||
@ -88,7 +88,7 @@ export async function enableTemplate(id: string) {
|
|||||||
* @returns Promise
|
* @returns Promise
|
||||||
*/
|
*/
|
||||||
export async function disableTemplate(id: string) {
|
export async function disableTemplate(id: string) {
|
||||||
return request<API.APIResponse<any>>('/coscoEvaluate/template/disable', {
|
return request<API.APIResponse<any>>('/coscoEvaluate/template/down', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: { id },
|
data: { id },
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user