政策
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:
@@ -15,8 +15,8 @@ export default {
|
||||
// localhost:8000/api/** -> https://preview.pro.ant.design/api/**
|
||||
'/api/': {
|
||||
// 要代理的地址
|
||||
// target: 'http://localhost:9091', // 本地代理
|
||||
target: 'http://wykj.cdwsx.com/api',// 后端
|
||||
target: 'http://localhost:9091', // 本地代理
|
||||
// target: 'http://wykj.cdwsx.com/api',// 后端
|
||||
// target: 'http://ks.zhaopinzao8dian.com/api/ks',
|
||||
// 配置了这个可以从 http 代理到 https
|
||||
// 依赖 origin 的功能可能需要这个,比如 cookie
|
||||
|
||||
46
src/pages/Policy/Mgmt/components/DetailModal.tsx
Normal file
46
src/pages/Policy/Mgmt/components/DetailModal.tsx
Normal file
@@ -0,0 +1,46 @@
|
||||
import React from 'react';
|
||||
import { Modal, Descriptions, Button } from 'antd';
|
||||
|
||||
interface DetailModalProps {
|
||||
open: boolean;
|
||||
data?: API.PolicyInfo.PolicyInfoItem;
|
||||
onCancel: () => void;
|
||||
}
|
||||
|
||||
const DetailModal: React.FC<DetailModalProps> = ({ open, data, onCancel }) => {
|
||||
return (
|
||||
<Modal
|
||||
title="政策详情"
|
||||
open={open}
|
||||
onCancel={onCancel}
|
||||
footer={<Button onClick={onCancel}>关闭</Button>}
|
||||
width={800}
|
||||
>
|
||||
<Descriptions column={2} bordered size="small">
|
||||
<Descriptions.Item label="政策名称" span={2}>{data?.zcmc}</Descriptions.Item>
|
||||
<Descriptions.Item label="政策类型">{data?.zclx}</Descriptions.Item>
|
||||
<Descriptions.Item label="政策级别">{data?.zcLevel}</Descriptions.Item>
|
||||
<Descriptions.Item label="发文单位">{data?.sourceUnit}</Descriptions.Item>
|
||||
<Descriptions.Item label="受理单位">{data?.acceptUnit}</Descriptions.Item>
|
||||
<Descriptions.Item label="发文时间">{data?.publishTime}</Descriptions.Item>
|
||||
<Descriptions.Item label="浏览数">{data?.viewNum}</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>
|
||||
<Descriptions.Item label="申报条件" span={2}>{data?.applyCondition}</Descriptions.Item>
|
||||
<Descriptions.Item label="政策文件" span={2}>
|
||||
{data?.fileUrl && (
|
||||
<a href={data.fileUrl} target="_blank" rel="noopener noreferrer">
|
||||
{data.fileName || '查看文件'}
|
||||
</a>
|
||||
)}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="创建时间">{data?.createTime}</Descriptions.Item>
|
||||
<Descriptions.Item label="更新时间">{data?.updateTime}</Descriptions.Item>
|
||||
<Descriptions.Item label="备注" span={2}>{data?.remark}</Descriptions.Item>
|
||||
</Descriptions>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default DetailModal;
|
||||
171
src/pages/Policy/Mgmt/components/EditModal.tsx
Normal file
171
src/pages/Policy/Mgmt/components/EditModal.tsx
Normal file
@@ -0,0 +1,171 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { Modal, Form, Input, DatePicker, Upload, Button, message } from 'antd';
|
||||
import { UploadOutlined, DeleteOutlined } from '@ant-design/icons';
|
||||
import type { UploadFile } from 'antd/es/upload/interface';
|
||||
import dayjs from 'dayjs';
|
||||
import { uploadPolicyFile } from '@/services/cms/policyInfo';
|
||||
|
||||
const { TextArea } = Input;
|
||||
|
||||
interface EditModalProps {
|
||||
open: boolean;
|
||||
values?: API.PolicyInfo.PolicyInfoItem;
|
||||
onCancel: () => void;
|
||||
onSubmit: (values: Partial<API.PolicyInfo.PolicyInfoItem>) => void;
|
||||
}
|
||||
|
||||
const EditModal: React.FC<EditModalProps> = ({ open, values, onCancel, onSubmit }) => {
|
||||
const [form] = Form.useForm();
|
||||
const [fileList, setFileList] = useState<UploadFile[]>([]);
|
||||
const [uploading, setUploading] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (open) {
|
||||
if (values) {
|
||||
form.setFieldsValue({
|
||||
...values,
|
||||
publishTime: values.publishTime ? dayjs(values.publishTime) : undefined,
|
||||
});
|
||||
// 如果有已上传的文件,显示在列表中
|
||||
if (values.fileUrl && values.fileName) {
|
||||
setFileList([{
|
||||
uid: '-1',
|
||||
name: values.fileName,
|
||||
status: 'done',
|
||||
url: values.fileUrl,
|
||||
}]);
|
||||
} else {
|
||||
setFileList([]);
|
||||
}
|
||||
} else {
|
||||
form.resetFields();
|
||||
setFileList([]);
|
||||
}
|
||||
}
|
||||
}, [open, values, form]);
|
||||
|
||||
const handleUpload = async (file: File) => {
|
||||
setUploading(true);
|
||||
try {
|
||||
const res = await uploadPolicyFile(file);
|
||||
if (res.code === 200) {
|
||||
form.setFieldsValue({
|
||||
fileUrl: res.data.fileUrl,
|
||||
fileName: res.data.fileName,
|
||||
});
|
||||
setFileList([{
|
||||
uid: '-1',
|
||||
name: res.data.fileName,
|
||||
status: 'done',
|
||||
url: res.data.fileUrl,
|
||||
}]);
|
||||
message.success('文件上传成功');
|
||||
} else {
|
||||
message.error(res.msg || '文件上传失败');
|
||||
}
|
||||
} catch {
|
||||
message.error('文件上传失败');
|
||||
} finally {
|
||||
setUploading(false);
|
||||
}
|
||||
return false; // 阻止默认上传行为
|
||||
};
|
||||
|
||||
const handleRemoveFile = () => {
|
||||
setFileList([]);
|
||||
form.setFieldsValue({
|
||||
fileUrl: undefined,
|
||||
fileName: undefined,
|
||||
});
|
||||
};
|
||||
|
||||
const handleOk = async () => {
|
||||
const formValues = await form.validateFields();
|
||||
onSubmit({
|
||||
...formValues,
|
||||
id: values?.id,
|
||||
publishTime: formValues.publishTime?.format('YYYY-MM-DD'),
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title={values ? '编辑政策' : '新增政策'}
|
||||
open={open}
|
||||
onCancel={onCancel}
|
||||
onOk={handleOk}
|
||||
width={700}
|
||||
destroyOnClose
|
||||
>
|
||||
<Form form={form} layout="vertical">
|
||||
<Form.Item name="zcmc" label="政策名称" rules={[{ required: true, message: '请输入政策名称' }]}>
|
||||
<Input placeholder="请输入政策名称" />
|
||||
</Form.Item>
|
||||
<Form.Item name="zclx" label="政策类型">
|
||||
<Input placeholder="请输入政策类型" />
|
||||
</Form.Item>
|
||||
<Form.Item name="zcLevel" label="政策级别">
|
||||
<Input placeholder="请输入政策级别" />
|
||||
</Form.Item>
|
||||
<Form.Item name="sourceUnit" label="发文单位">
|
||||
<Input placeholder="请输入发文单位" />
|
||||
</Form.Item>
|
||||
<Form.Item name="acceptUnit" label="受理单位">
|
||||
<Input placeholder="请输入受理单位" />
|
||||
</Form.Item>
|
||||
<Form.Item name="publishTime" label="发文时间">
|
||||
<DatePicker style={{ width: '100%' }} />
|
||||
</Form.Item>
|
||||
<Form.Item name="zcContent" label="政策内容">
|
||||
<TextArea rows={4} placeholder="请输入政策内容" />
|
||||
</Form.Item>
|
||||
<Form.Item name="subsidyStandard" label="补贴标准">
|
||||
<TextArea rows={2} placeholder="请输入补贴标准" />
|
||||
</Form.Item>
|
||||
<Form.Item name="handleChannel" label="经办渠道">
|
||||
<Input placeholder="请输入经办渠道" />
|
||||
</Form.Item>
|
||||
<Form.Item name="applyCondition" label="申报条件">
|
||||
<TextArea rows={2} placeholder="请输入申报条件" />
|
||||
</Form.Item>
|
||||
<Form.Item label="政策文件">
|
||||
{fileList.length > 0 ? (
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||
<a href={fileList[0].url} target="_blank" rel="noopener noreferrer">
|
||||
{fileList[0].name}
|
||||
</a>
|
||||
<Button
|
||||
type="text"
|
||||
danger
|
||||
size="small"
|
||||
icon={<DeleteOutlined />}
|
||||
onClick={handleRemoveFile}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<Upload
|
||||
beforeUpload={handleUpload}
|
||||
showUploadList={false}
|
||||
maxCount={1}
|
||||
>
|
||||
<Button icon={<UploadOutlined />} loading={uploading}>
|
||||
上传文件
|
||||
</Button>
|
||||
</Upload>
|
||||
)}
|
||||
</Form.Item>
|
||||
<Form.Item name="fileUrl" hidden>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item name="fileName" hidden>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item name="remark" label="备注">
|
||||
<TextArea rows={2} placeholder="请输入备注" />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default EditModal;
|
||||
220
src/pages/Policy/Mgmt/index.tsx
Normal file
220
src/pages/Policy/Mgmt/index.tsx
Normal file
@@ -0,0 +1,220 @@
|
||||
import React, { useRef, useState } from 'react';
|
||||
import { useAccess } from '@umijs/max';
|
||||
import { Button, message, Modal } from 'antd';
|
||||
import { ActionType, PageContainer, ProColumns, ProTable } from '@ant-design/pro-components';
|
||||
import { PlusOutlined, DeleteOutlined, FormOutlined, EyeOutlined } from '@ant-design/icons';
|
||||
import {
|
||||
getPolicyInfoList,
|
||||
getPolicyInfoDetail,
|
||||
addPolicyInfo,
|
||||
updatePolicyInfo,
|
||||
deletePolicyInfo,
|
||||
} from '@/services/cms/policyInfo';
|
||||
import EditModal from './components/EditModal';
|
||||
import DetailModal from './components/DetailModal';
|
||||
|
||||
const PolicyMgmt: React.FC = () => {
|
||||
const access = useAccess();
|
||||
const actionRef = useRef<ActionType>();
|
||||
const [editModalVisible, setEditModalVisible] = useState(false);
|
||||
const [detailModalVisible, setDetailModalVisible] = useState(false);
|
||||
const [currentRow, setCurrentRow] = useState<API.PolicyInfo.PolicyInfoItem>();
|
||||
const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([]);
|
||||
|
||||
const handleDelete = async (ids: string) => {
|
||||
Modal.confirm({
|
||||
title: '确认删除',
|
||||
content: '确定要删除选中的政策信息吗?',
|
||||
onOk: async () => {
|
||||
const res = await deletePolicyInfo(ids);
|
||||
if (res.code === 200) {
|
||||
message.success('删除成功');
|
||||
actionRef.current?.reload();
|
||||
setSelectedRowKeys([]);
|
||||
} else {
|
||||
message.error(res.msg || '删除失败');
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const columns: ProColumns<API.PolicyInfo.PolicyInfoItem>[] = [
|
||||
{
|
||||
title: '政策名称',
|
||||
dataIndex: 'zcmc',
|
||||
ellipsis: true,
|
||||
},
|
||||
{
|
||||
title: '政策类型',
|
||||
dataIndex: 'zclx',
|
||||
hideInSearch: true,
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
title: '政策级别',
|
||||
dataIndex: 'zcLevel',
|
||||
hideInSearch: true,
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
title: '发文单位',
|
||||
dataIndex: 'sourceUnit',
|
||||
hideInSearch: true,
|
||||
ellipsis: true,
|
||||
},
|
||||
{
|
||||
title: '受理单位',
|
||||
dataIndex: 'acceptUnit',
|
||||
hideInSearch: true,
|
||||
ellipsis: true,
|
||||
},
|
||||
{
|
||||
title: '发文时间',
|
||||
dataIndex: 'publishTime',
|
||||
hideInSearch: true,
|
||||
width: 110,
|
||||
},
|
||||
{
|
||||
title: '浏览数',
|
||||
dataIndex: 'viewNum',
|
||||
hideInSearch: true,
|
||||
width: 80,
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
hideInSearch: true,
|
||||
width: 160,
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
valueType: 'option',
|
||||
width: 200,
|
||||
fixed: 'right',
|
||||
render: (_, record) => [
|
||||
<Button
|
||||
key="detail"
|
||||
type="link"
|
||||
size="small"
|
||||
icon={<EyeOutlined />}
|
||||
onClick={async () => {
|
||||
const res = await getPolicyInfoDetail(record.id);
|
||||
if (res.code === 200) {
|
||||
setCurrentRow(res.data);
|
||||
setDetailModalVisible(true);
|
||||
}
|
||||
}}
|
||||
>
|
||||
详情
|
||||
</Button>,
|
||||
<Button
|
||||
key="edit"
|
||||
type="link"
|
||||
size="small"
|
||||
icon={<FormOutlined />}
|
||||
hidden={!access.hasPerms('cms:policyInfo:edit')}
|
||||
onClick={async () => {
|
||||
const res = await getPolicyInfoDetail(record.id);
|
||||
if (res.code === 200) {
|
||||
setCurrentRow(res.data);
|
||||
setEditModalVisible(true);
|
||||
}
|
||||
}}
|
||||
>
|
||||
编辑
|
||||
</Button>,
|
||||
<Button
|
||||
key="delete"
|
||||
type="link"
|
||||
size="small"
|
||||
danger
|
||||
icon={<DeleteOutlined />}
|
||||
hidden={!access.hasPerms('cms:policyInfo:remove')}
|
||||
onClick={() => handleDelete(String(record.id))}
|
||||
>
|
||||
删除
|
||||
</Button>,
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<PageContainer>
|
||||
<ProTable<API.PolicyInfo.PolicyInfoItem>
|
||||
headerTitle="政策信息列表"
|
||||
actionRef={actionRef}
|
||||
rowKey="id"
|
||||
columns={columns}
|
||||
scroll={{ x: 'max-content' }}
|
||||
rowSelection={{
|
||||
selectedRowKeys,
|
||||
onChange: setSelectedRowKeys,
|
||||
}}
|
||||
request={async (params) => {
|
||||
const res = await getPolicyInfoList({
|
||||
pageNum: params.current,
|
||||
pageSize: params.pageSize,
|
||||
searchValue: params.zcmc,
|
||||
});
|
||||
return { data: res.rows, total: res.total, success: true };
|
||||
}}
|
||||
toolBarRender={() => [
|
||||
<Button
|
||||
key="add"
|
||||
type="primary"
|
||||
icon={<PlusOutlined />}
|
||||
hidden={!access.hasPerms('cms:policyInfo:add')}
|
||||
onClick={() => {
|
||||
setCurrentRow(undefined);
|
||||
setEditModalVisible(true);
|
||||
}}
|
||||
>
|
||||
新增
|
||||
</Button>,
|
||||
selectedRowKeys.length > 0 && (
|
||||
<Button
|
||||
key="batchDelete"
|
||||
danger
|
||||
icon={<DeleteOutlined />}
|
||||
hidden={!access.hasPerms('cms:policyInfo:remove')}
|
||||
onClick={() => handleDelete(selectedRowKeys.join(','))}
|
||||
>
|
||||
批量删除
|
||||
</Button>
|
||||
),
|
||||
]}
|
||||
/>
|
||||
<EditModal
|
||||
open={editModalVisible}
|
||||
values={currentRow}
|
||||
onCancel={() => {
|
||||
setEditModalVisible(false);
|
||||
setCurrentRow(undefined);
|
||||
}}
|
||||
onSubmit={async (values) => {
|
||||
const res = values.id
|
||||
? await updatePolicyInfo(values)
|
||||
: await addPolicyInfo(values);
|
||||
if (res.code === 200) {
|
||||
message.success(values.id ? '修改成功' : '新增成功');
|
||||
setEditModalVisible(false);
|
||||
setCurrentRow(undefined);
|
||||
actionRef.current?.reload();
|
||||
} else {
|
||||
message.error(res.msg || '操作失败');
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<DetailModal
|
||||
open={detailModalVisible}
|
||||
data={currentRow}
|
||||
onCancel={() => {
|
||||
setDetailModalVisible(false);
|
||||
setCurrentRow(undefined);
|
||||
}}
|
||||
/>
|
||||
</PageContainer>
|
||||
);
|
||||
};
|
||||
|
||||
export default PolicyMgmt;
|
||||
49
src/services/cms/policyInfo.ts
Normal file
49
src/services/cms/policyInfo.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import { request } from '@umijs/max';
|
||||
|
||||
// 查询政策列表
|
||||
export async function getPolicyInfoList(params?: API.PolicyInfo.Params) {
|
||||
return request<API.PolicyInfo.PolicyInfoResult>('/api/cms/policyInfo/list', {
|
||||
method: 'GET',
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
// 获取政策详情
|
||||
export async function getPolicyInfoDetail(id: number) {
|
||||
return request<API.PolicyInfo.PolicyInfoDetailResult>(`/api/cms/policyInfo/${id}`, {
|
||||
method: 'GET',
|
||||
});
|
||||
}
|
||||
|
||||
// 新增政策
|
||||
export async function addPolicyInfo(data: Partial<API.PolicyInfo.PolicyInfoItem>) {
|
||||
return request<API.Result>('/api/cms/policyInfo', {
|
||||
method: 'POST',
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
// 修改政策
|
||||
export async function updatePolicyInfo(data: Partial<API.PolicyInfo.PolicyInfoItem>) {
|
||||
return request<API.Result>('/api/cms/policyInfo', {
|
||||
method: 'PUT',
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
// 删除政策
|
||||
export async function deletePolicyInfo(ids: string) {
|
||||
return request<API.Result>(`/api/cms/policyInfo/${ids}`, {
|
||||
method: 'DELETE',
|
||||
});
|
||||
}
|
||||
|
||||
// 上传政策文件
|
||||
export async function uploadPolicyFile(file: File) {
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
return request<API.PolicyInfo.UploadResult>('/api/cms/policyInfo/upload', {
|
||||
method: 'POST',
|
||||
data: formData,
|
||||
});
|
||||
}
|
||||
52
src/types/cms/policyInfo.d.ts
vendored
Normal file
52
src/types/cms/policyInfo.d.ts
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
declare namespace API.PolicyInfo {
|
||||
export interface PolicyInfoResult {
|
||||
total: number;
|
||||
rows: PolicyInfoItem[];
|
||||
code: number;
|
||||
msg: string;
|
||||
}
|
||||
|
||||
export interface PolicyInfoDetailResult {
|
||||
code: number;
|
||||
msg: string;
|
||||
data: PolicyInfoItem;
|
||||
}
|
||||
|
||||
export interface UploadResult {
|
||||
code: number;
|
||||
msg: string;
|
||||
data: {
|
||||
fileUrl: string;
|
||||
fileName: string;
|
||||
filePath: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface PolicyInfoItem {
|
||||
id: number;
|
||||
zcmc: string;
|
||||
zclx: string;
|
||||
zcLevel: string;
|
||||
sourceUnit: string;
|
||||
acceptUnit: string;
|
||||
publishTime: string;
|
||||
zcContent?: string;
|
||||
subsidyStandard?: string;
|
||||
handleChannel?: string;
|
||||
applyCondition?: string;
|
||||
fileUrl?: string;
|
||||
fileName?: string;
|
||||
viewNum: number;
|
||||
createBy?: string;
|
||||
createTime?: string;
|
||||
updateBy?: string;
|
||||
updateTime?: string;
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
export interface Params {
|
||||
pageNum?: number;
|
||||
pageSize?: number;
|
||||
searchValue?: string;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user