From 7f28a0c355afe5136a9f7cc3708c3249c02ab47e Mon Sep 17 00:00:00 2001 From: houjishuang <46269784@qq.com> Date: Tue, 27 May 2025 17:14:29 +0800 Subject: [PATCH] dailiku --- .../components/EntrustedProject.tsx | 0 .../components/SelectProvider.tsx | 133 +++++++++ src/pages/Agency/AgencyManager/index.tsx | 272 ++++++++++++++++++ src/pages/Agency/AgencyManager/service.ts | 37 +++ 4 files changed, 442 insertions(+) create mode 100644 src/pages/Agency/AgencyManager/components/EntrustedProject.tsx create mode 100644 src/pages/Agency/AgencyManager/components/SelectProvider.tsx create mode 100644 src/pages/Agency/AgencyManager/index.tsx create mode 100644 src/pages/Agency/AgencyManager/service.ts diff --git a/src/pages/Agency/AgencyManager/components/EntrustedProject.tsx b/src/pages/Agency/AgencyManager/components/EntrustedProject.tsx new file mode 100644 index 0000000..e69de29 diff --git a/src/pages/Agency/AgencyManager/components/SelectProvider.tsx b/src/pages/Agency/AgencyManager/components/SelectProvider.tsx new file mode 100644 index 0000000..bf61904 --- /dev/null +++ b/src/pages/Agency/AgencyManager/components/SelectProvider.tsx @@ -0,0 +1,133 @@ +import React, { useState, useRef } from 'react'; +import { message, Modal, Input, Form, PageHeader, Button, Spin, Select, Tree } from 'antd'; +import ProTable, { ProColumns, ActionType } from '@ant-design/pro-table'; +import { getPage, getDataById, deleteAgency, addAgency, updateAgency,disableAgency } from './service'; +// import './styles.less'; +import { getDicData } from '@/utils/session'; +import TextArea from 'antd/lib/input/TextArea'; + +const selectProvider: React.FC<{}> = () => { + //获取字典 + const getDict: any = getDicData(); + const [form] = Form.useForm(); + const [title, setTitle] = useState(''); + const [open, setOpen] = useState(false); + + const [checkedKeys, setCheckedKeys] = useState([]); + const [currentRoleId, setCurrentRoleId] = useState(null); + const dictData = JSON.parse(getDict); + const actionRef = useRef(); + const [spin, spinSet] = useState(false); + //查询分页数据 + const [pageData, pageDataSet] = useState({ + pageNo: 1, + pageSize: 10 + }); + const layout = { + labelCol: { span: 6 }, + wrapperCol: { span: 13 }, + }; + interface DictType { + value: string; + label: string; + } + const sys_normal_scope: DictType[] = [ + { value: 'EBTP', label: '招标采购中心' }, + ]; + + //委托列表 + const columns: ProColumns[] = [ + { title: '序号', valueType: 'index', width: 50, search: false, }, + { title: '供应商名称', dataIndex: 'providerName', },//, ellipsis: true + { title: '供应商分类', dataIndex: 'roleName', + valueEnum: { 'EBTP': { text: '招标采购中心', status: 'EBTP' }, }, + + },//, ellipsis: true//, ellipsis: true + { title: '品类', dataIndex: 'roleName', }, + { title: '准入时间', dataIndex: 'roleName', },//, ellipsis: true + { title: '准入人', dataIndex: 'roleName', search: false, hideInTable:true,},//, ellipsis: true + { title: '失效时间', dataIndex: 'roleName', search: false,},//, ellipsis: true + { title: '状态', dataIndex: 'status', },//, ellipsis: true + { title: 'id', dataIndex: 'id', search: false,hideInTable:true,},//, ellipsis: true + { title: 'providerId', dataIndex: 'providerId', search: false,hideInTable:true,}, + // { title: '创建时间', dataIndex: 'createDate', width: '10%', valueType: 'dateTime', search: false }, + + { + title: '操作', width: '9%', + valueType: 'option', + render: (_, record) => [ + + + + ] + }, + ]; + // 删除操作 + const handleSelect = (id: string) => { + Modal.confirm({ + title: '确认选择该供应商?', + onOk: async () => { + await deleteAgency(id).then((r: any) => { + if (r?.code == 200) { + message.success('删除成功'); + } else { + message.error('删除失败'); + } + }) + .finally(() => actionRef.current?.reload()); + }, + }); + }; + + + const [menuOptions, setMenuOptions] = useState([]); + + + return ( + + +
+ + actionRef={actionRef}//action触发后更新表格 + columns={columns}//表格 + options={false} + bordered={false} + className='tableSearch' + size='small' + search={{ labelWidth: 'auto', span: 6 }} + request={(params) => + getPage({ + ...params, + basePageRequest: { pageNo: pageData.pageNo, pageSize: pageData.pageSize }, + }).then((res) => { + const result = { + data: res.data.records, + total: res.data.total, + success: res.success, + pageSize: res.data.size, + current: res.data.current + } + return result; + }) + } + toolBarRender={() => [ + , + ] + } + pagination={{ + defaultPageSize: 10, + showSizeChanger: false, + onChange: (page, pageSize) => pageDataSet({ pageNo: page, pageSize: pageSize }), + onShowSizeChange: (current, size) => pageDataSet({ pageNo: current, pageSize: size }), + }} + onReset={() => { pageDataSet({ pageNo: 1, pageSize: 10 }) }} + /> + +
+ {/* 查看 */} +
+ ) +}; +export default selectProvider; \ No newline at end of file diff --git a/src/pages/Agency/AgencyManager/index.tsx b/src/pages/Agency/AgencyManager/index.tsx new file mode 100644 index 0000000..b693adf --- /dev/null +++ b/src/pages/Agency/AgencyManager/index.tsx @@ -0,0 +1,272 @@ +import React, { useState, useRef } from 'react'; +import { message, Modal, Input, Form, PageHeader, Button, Spin, Select, Tree } from 'antd'; +import ProTable, { ProColumns, ActionType } from '@ant-design/pro-table'; +import { getPage, getDataById, deleteAgency, addAgency, updateAgency,disableAgency } from './service'; +// import './styles.less'; +import { getDicData } from '@/utils/session'; +import TextArea from 'antd/lib/input/TextArea'; + +const agency: React.FC<{}> = () => { + //获取字典 + const getDict: any = getDicData(); + const [form] = Form.useForm(); + const [title, setTitle] = useState(''); + const [open, setOpen] = useState(false); + + const [checkedKeys, setCheckedKeys] = useState([]); + const [currentRoleId, setCurrentRoleId] = useState(null); + const dictData = JSON.parse(getDict); + const actionRef = useRef(); + const [spin, spinSet] = useState(false); + //查询分页数据 + const [pageData, pageDataSet] = useState({ + pageNo: 1, + pageSize: 10 + }); + const layout = { + labelCol: { span: 6 }, + wrapperCol: { span: 13 }, + }; + interface DictType { + value: string; + label: string; + } + const sys_normal_scope: DictType[] = [ + { value: 'EBTP', label: '招标采购中心' }, + ]; + + //委托列表 + const columns: ProColumns[] = [ + { title: '序号', valueType: 'index', width: 50, search: false, }, + { title: '代理机构名称', dataIndex: 'providerName', },//, ellipsis: true + { title: '申请人', dataIndex: 'roleName', search: false, },//, ellipsis: true//, ellipsis: true + { title: '准入时间', dataIndex: 'roleName', search: false, },//, ellipsis: true + { title: '准入人', dataIndex: 'roleName', search: false, },//, ellipsis: true + { title: '失效时间', dataIndex: 'roleName', search: false,},//, ellipsis: true + { title: '状态', dataIndex: 'status', valueType: 'select', + valueEnum: { '1': { text: '有效', status: '1' },'0': { text: '无效', status: '0' }, }, + },//, ellipsis: true + { title: 'id', dataIndex: 'id', search: false,hideInTable:true,},//, ellipsis: true + // { title: '创建时间', dataIndex: 'createDate', width: '10%', valueType: 'dateTime', search: false }, + { title: 'providerId', dataIndex: 'providerId', search: false,hideInTable:true,}, + { + title: '操作', width: '9%', + valueType: 'option', + render: (_, record) => [ + , + , + , + + + ] + }, + ]; + // 删除操作 + const handleDelete = (id: string) => { + Modal.confirm({ + title: '确认删除该角色?', + onOk: async () => { + await deleteAgency(id).then((r: any) => { + if (r?.code == 200) { + message.success('删除成功'); + } else { + message.error('删除失败'); + } + }) + .finally(() => actionRef.current?.reload()); + }, + }); + }; + const handleAdd = async () => { + form.resetFields(); + // const menus = await menuTreeselect(); + // setMenuOptions(menus.data || []); + // setMenuOptions(menu || []); + + // 使用时转换 + setMenuOptions(formatMenuOptions(menu) || []); + setOpen(true); + setTitle('添加角色'); + }; + + const [menuOptions, setMenuOptions] = useState([]); + let menu = [{ + "id": '1', "parentId": '0', "label": "系统管理", "weight": 1, + "children": [{ + "id": '101', "parentId": '1', "label": "角色管理", "weight": 2, + "children": [{ "id": '1008', "parentId": '101', "label": "角色查询", "weight": 1 }, + { "id": '1009', "parentId": '101', "label": "角色新增", "weight": 2 }, + { "id": '1010', "parentId": '101', "label": "角色修改", "weight": 3 }, + { "id": '1011', "parentId": '101', "label": "角色删除", "weight": 4 }, + { "id": '1012', "parentId": '101', "label": "角色导出", "weight": 5 }] + }, + { + "id": '105', "parentId": '1', "label": "字典管理", "weight": 6, + "children": [{ "id": '1026', "parentId": '105', "label": "字典查询", "weight": 1 }, + { "id": '1027', "parentId": '105', "label": "字典新增", "weight": 2 }, + { "id": '1028', "parentId": '105', "label": "字典修改", "weight": 3 }, + { "id": '1029', "parentId": '105', "label": "字典删除", "weight": 4 }, + { "id": '1030', "parentId": '105', "label": "字典导出", "weight": 5 }] + }] + }, + { "id": '4', "parentId": '0', "label": "PLUS官网", "weight": 4 }, + { + "id": "1494925781048545281", "parentId": '0', "label": "个人待办", "weight": 18, + "children": [{ "id": "1494926258733633538", "parentId": "1494925781048545281", "label": "待办任务", "weight": 1 }, + { "id": "1494926586677874690", "parentId": "1494925781048545281", "label": "已办任务", "weight": 2 }] + }]; + const formatMenuOptions = (data: any[]) => { + return data.map(item => ({ + title: item.label, + key: item.id, + children: item.children ? formatMenuOptions(item.children) : undefined, + })); + }; + + const handleUpdate = async (record: any) => { + form.resetFields(); + const role = await getDataById(record.roleId); + // const menus = await roleMenuTreeselect(record.roleId); + // setMenuOptions(menus.data.menus || []); + setMenuOptions(formatMenuOptions(menu) || []); + setCheckedKeys(role.data.menuIds || []); + form.setFieldsValue({ + ...role.data, + menuIds: role.data.menuIds || [], + }); + // form.setFieldsValue(role.data); + setCurrentRoleId(record.roleId); + setOpen(true); + setTitle('修改角色'); + }; + + const closeModal = async () => { + actionRef.current?.reload(); + form.resetFields(); + setCheckedKeys([]); + setOpen(false); + }; + + const handleSubmit = async () => { + try { + const values = await form.validateFields(); + if (values.roleId) { + await updateAgency(values).then((r: any) => { + if (r?.code == 200) { + message.success('修改成功'); + } else { + message.error('修改失败'); + } + }); + } else { + await addAgency(values).then((r: any) => { + console.log("r?.code", r?.code) + if (r?.code == 200) { + message.success('新增成功'); + } else { + message.error('新增失败'); + } + }); + } + closeModal(); + } catch (error) { + console.error(error); + } + }; + const checkSupModal = ( + setOpen(false)}>关闭} + onOk={handleSubmit} + onCancel={() => closeModal()} + > +
+ + + + + + + + + + + +