政策启用禁用功能开发
Some checks failed
Node CI / build (14.x, macOS-latest) (push) Has been cancelled
Node CI / build (14.x, ubuntu-latest) (push) Has been cancelled
Node CI / build (14.x, windows-latest) (push) Has been cancelled
Node CI / build (16.x, macOS-latest) (push) Has been cancelled
Node CI / build (16.x, ubuntu-latest) (push) Has been cancelled
Node CI / build (16.x, windows-latest) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
coverage CI / build (push) Has been cancelled
Node pnpm CI / build (16.x, macOS-latest) (push) Has been cancelled
Node pnpm CI / build (16.x, ubuntu-latest) (push) Has been cancelled
Node pnpm CI / build (16.x, windows-latest) (push) Has been cancelled
Some checks failed
Node CI / build (14.x, macOS-latest) (push) Has been cancelled
Node CI / build (14.x, ubuntu-latest) (push) Has been cancelled
Node CI / build (14.x, windows-latest) (push) Has been cancelled
Node CI / build (16.x, macOS-latest) (push) Has been cancelled
Node CI / build (16.x, ubuntu-latest) (push) Has been cancelled
Node CI / build (16.x, windows-latest) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
coverage CI / build (push) Has been cancelled
Node pnpm CI / build (16.x, macOS-latest) (push) Has been cancelled
Node pnpm CI / build (16.x, ubuntu-latest) (push) Has been cancelled
Node pnpm CI / build (16.x, windows-latest) (push) Has been cancelled
This commit is contained in:
@@ -16,14 +16,14 @@ import {
|
||||
} from '@ant-design/icons';
|
||||
import { history, useSearchParams } from '@umijs/max';
|
||||
import JobPortalHeader from '@/components/JobPortalHeader';
|
||||
import { getPolicyInfoDetail } from '@/services/cms/policyInfo';
|
||||
import { getPortalPolicyDetail } from '@/services/cms/policyInfo';
|
||||
import { getDictValueEnum } from '@/services/system/dict';
|
||||
import DictTag, { DictValueEnumObj } from '@/components/DictTag';
|
||||
import './index.less';
|
||||
|
||||
const { Title, Paragraph, Text } = Typography;
|
||||
|
||||
/** 解析 GET /cms/policyInfo/{id} 响应 */
|
||||
/** 解析 GET /app/policyInfo/detail/{id} 响应 */
|
||||
const parsePolicyDetail = (
|
||||
response: API.PolicyInfo.PolicyInfoDetailResult | undefined,
|
||||
): API.PolicyInfo.PolicyInfoItem | null => {
|
||||
@@ -54,7 +54,7 @@ const PolicyDetailPage: React.FC = () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
setDetail(null);
|
||||
const response = await getPolicyInfoDetail(policyId);
|
||||
const response = await getPortalPolicyDetail(policyId);
|
||||
const policy = parsePolicyDetail(response);
|
||||
if (policy) {
|
||||
setDetail(policy);
|
||||
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
} from '@ant-design/icons';
|
||||
import { history } from '@umijs/max';
|
||||
import JobPortalHeader from '@/components/JobPortalHeader';
|
||||
import { getPolicyInfoList } from '@/services/cms/policyInfo';
|
||||
import { getPortalPolicyList } from '@/services/cms/policyInfo';
|
||||
import { getDictValueEnum } from '@/services/system/dict';
|
||||
import type { DictValueEnumObj } from '@/components/DictTag';
|
||||
import './index.less';
|
||||
@@ -74,7 +74,7 @@ const PolicyListPage: React.FC = () => {
|
||||
const fetchList = useCallback(async () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
const response = await getPolicyInfoList({
|
||||
const response = await getPortalPolicyList({
|
||||
pageNum,
|
||||
pageSize,
|
||||
searchValue: keyword || undefined,
|
||||
|
||||
@@ -24,6 +24,7 @@ const DetailModal: React.FC<DetailModalProps> = ({ open, data, onCancel }) => {
|
||||
<Descriptions.Item label="受理单位">{data?.acceptUnit}</Descriptions.Item>
|
||||
<Descriptions.Item label="发文时间">{data?.publishTime}</Descriptions.Item>
|
||||
<Descriptions.Item label="浏览数">{data?.viewNum}</Descriptions.Item>
|
||||
<Descriptions.Item label="状态">{data?.status === '1' ? '禁用' : '启用'}</Descriptions.Item>
|
||||
<Descriptions.Item label="政策内容" span={2}>{data?.zcContent}</Descriptions.Item>
|
||||
<Descriptions.Item label="补贴标准" span={2}>{data?.subsidyStandard}</Descriptions.Item>
|
||||
<Descriptions.Item label="经办渠道" span={2}>{data?.handleChannel}</Descriptions.Item>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { Modal, Form, Input, DatePicker, Upload, Button, message, Row, Col, Select } from 'antd';
|
||||
import { Modal, Form, Input, DatePicker, Upload, Button, message, Row, Col, Select, Switch } from 'antd';
|
||||
import { UploadOutlined, DeleteOutlined } from '@ant-design/icons';
|
||||
import type { UploadFile } from 'antd/es/upload/interface';
|
||||
import dayjs from 'dayjs';
|
||||
@@ -37,6 +37,7 @@ const EditModal: React.FC<EditModalProps> = ({ open, values, onCancel, onSubmit
|
||||
policyTag: values.policyTag
|
||||
? String(values.policyTag).split(',').filter(Boolean)
|
||||
: undefined,
|
||||
status: values.status !== '1',
|
||||
});
|
||||
// 如果有已上传的文件,显示在列表中
|
||||
if (values.fileUrl && values.fileName) {
|
||||
@@ -93,12 +94,13 @@ const EditModal: React.FC<EditModalProps> = ({ open, values, onCancel, onSubmit
|
||||
|
||||
const handleOk = async () => {
|
||||
const formValues = await form.validateFields();
|
||||
const { policyTag, publishTime, ...rest } = formValues;
|
||||
const { policyTag, publishTime, status, ...rest } = formValues;
|
||||
onSubmit({
|
||||
...rest,
|
||||
id: values?.id,
|
||||
publishTime: publishTime?.format('YYYY-MM-DD'),
|
||||
policyTag: Array.isArray(policyTag) ? policyTag.join(',') : policyTag,
|
||||
status: status ? '0' : '1',
|
||||
});
|
||||
};
|
||||
|
||||
@@ -206,6 +208,11 @@ const EditModal: React.FC<EditModalProps> = ({ open, values, onCancel, onSubmit
|
||||
)}
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Form.Item name="status" label="状态" valuePropName="checked" initialValue={true}>
|
||||
<Switch checkedChildren="启用" unCheckedChildren="禁用" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={24}>
|
||||
<Form.Item name="remark" label="备注">
|
||||
<TextArea rows={2} placeholder="请输入备注" />
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import { useAccess } from '@umijs/max';
|
||||
import { Button, message, Modal } from 'antd';
|
||||
import { Button, message, Modal, Switch } from 'antd';
|
||||
import { ActionType, PageContainer, ProColumns, ProTable } from '@ant-design/pro-components';
|
||||
import { PlusOutlined, DeleteOutlined, FormOutlined, EyeOutlined } from '@ant-design/icons';
|
||||
import {
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
addPolicyInfo,
|
||||
updatePolicyInfo,
|
||||
deletePolicyInfo,
|
||||
changePolicyStatus,
|
||||
} from '@/services/cms/policyInfo';
|
||||
import { getDictValueEnum } from '@/services/system/dict';
|
||||
import DictTag, { DictValueEnumObj } from '@/components/DictTag';
|
||||
@@ -47,6 +48,24 @@ const PolicyMgmt: React.FC = () => {
|
||||
});
|
||||
};
|
||||
|
||||
const handleStatusChange = async (id: number, checked: boolean) => {
|
||||
const newStatus = checked ? '0' : '1';
|
||||
const statusLabel = checked ? '启用' : '禁用';
|
||||
Modal.confirm({
|
||||
title: `确认${statusLabel}`,
|
||||
content: `确定要${statusLabel}该政策吗?`,
|
||||
onOk: async () => {
|
||||
const res = await changePolicyStatus(id, newStatus);
|
||||
if (res.code === 200) {
|
||||
message.success(`${statusLabel}成功`);
|
||||
actionRef.current?.reload();
|
||||
} else {
|
||||
message.error(res.msg || `${statusLabel}失败`);
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const columns: ProColumns<API.PolicyInfo.PolicyInfoItem>[] = [
|
||||
{
|
||||
title: '政策名称',
|
||||
@@ -108,6 +127,25 @@ const PolicyMgmt: React.FC = () => {
|
||||
hideInSearch: true,
|
||||
width: 80,
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
dataIndex: 'status',
|
||||
width: 80,
|
||||
valueType: 'select',
|
||||
valueEnum: {
|
||||
'0': { text: '启用', status: 'Success' },
|
||||
'1': { text: '禁用', status: 'Error' },
|
||||
},
|
||||
fixed: 'right',
|
||||
render: (_, record) => (
|
||||
<Switch
|
||||
checked={record.status === '0'}
|
||||
checkedChildren="启用"
|
||||
unCheckedChildren="禁用"
|
||||
onChange={(checked) => handleStatusChange(record.id, checked)}
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
|
||||
@@ -8,6 +8,14 @@ export async function getPolicyInfoList(params?: API.PolicyInfo.Params) {
|
||||
});
|
||||
}
|
||||
|
||||
// 查询政策列表(门户端公开接口,仅返回启用状态的政策)
|
||||
export async function getPortalPolicyList(params?: API.PolicyInfo.Params) {
|
||||
return request<API.PolicyInfo.PolicyInfoResult>('/api/app/policyInfo/portalList', {
|
||||
method: 'GET',
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
/** 获取政策详情 GET /cms/policyInfo/detail?id= */
|
||||
export async function getPolicyInfoDetail(id: number | string) {
|
||||
return request<API.PolicyInfo.PolicyInfoDetailResult>('/api/cms/policyInfo/detail', {
|
||||
@@ -16,6 +24,13 @@ export async function getPolicyInfoDetail(id: number | string) {
|
||||
});
|
||||
}
|
||||
|
||||
/** 获取政策详情(门户端公开接口)GET /app/policyInfo/detail/:id */
|
||||
export async function getPortalPolicyDetail(id: number | string) {
|
||||
return request<API.PolicyInfo.PolicyInfoDetailResult>(`/api/app/policyInfo/detail/${id}`, {
|
||||
method: 'GET',
|
||||
});
|
||||
}
|
||||
|
||||
// 新增政策
|
||||
export async function addPolicyInfo(data: Partial<API.PolicyInfo.PolicyInfoItem>) {
|
||||
return request<API.Result>('/api/cms/policyInfo', {
|
||||
@@ -39,6 +54,14 @@ export async function deletePolicyInfo(ids: string) {
|
||||
});
|
||||
}
|
||||
|
||||
// 更新政策状态(启用/禁用)
|
||||
export async function changePolicyStatus(id: number | string, status: string) {
|
||||
return request<API.Result>(`/api/cms/policyInfo/changeStatus`, {
|
||||
method: 'PUT',
|
||||
params: { id, status },
|
||||
});
|
||||
}
|
||||
|
||||
// 上传政策文件
|
||||
export async function uploadPolicyFile(file: File) {
|
||||
const formData = new FormData();
|
||||
|
||||
1
src/types/cms/policyInfo.d.ts
vendored
1
src/types/cms/policyInfo.d.ts
vendored
@@ -38,6 +38,7 @@ declare namespace API.PolicyInfo {
|
||||
fileUrl?: string;
|
||||
fileName?: string;
|
||||
viewNum: number;
|
||||
status?: string;
|
||||
createBy?: string;
|
||||
createTime?: string;
|
||||
updateBy?: string;
|
||||
|
||||
Reference in New Issue
Block a user