diff --git a/src/pages/Agency/AgencyManager/applyIndex.tsx b/src/pages/Agency/AgencyManager/applyIndex.tsx new file mode 100644 index 0000000..4415911 --- /dev/null +++ b/src/pages/Agency/AgencyManager/applyIndex.tsx @@ -0,0 +1,372 @@ +import React, { useState, useRef } from 'react'; +import {Radio, message, Modal, Input, Form, PageHeader, Button, Spin, Select, Tree, DatePicker } 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'; +import SelectProvider from './components/SelectProvider'; + +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 [selectProviderVisible, setSelectProviderVisible] = useState(false); + const [currentRecord, setCurrentRecord] = useState(null); + const [showEndDate, setShowEndDate] = 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: 'applyUser', search: false, },//, ellipsis: true//, ellipsis: true + { title: '开始服务时间', dataIndex: 'periodBegin', search: false, },//, ellipsis: true + { title: '准入人', dataIndex: 'accessUser', search: false, },//, ellipsis: true + { title: '失效时间', dataIndex: 'periodEnd', search: false,},//, ellipsis: true + { title: '状态', dataIndex: 'validityStatus', valueType: 'select', + valueEnum: { '1': { text: '有效', status: '1' },'2': { text: '失效', status: '2' }, }, + },//, 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) => [ + , + , + record.validityStatus === '1' && ( + + ), + record.validityStatus === '2' && ( + + ) + + ] + }, + ]; + // 删除操作 + 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 handleDisable = (id: string) => { + Modal.confirm({ + title: '确认失效该代理机构?', + onOk: async () => { + await disableAgency(id).then((r: any) => { + if (r?.code == 200) { + message.success('操作成功'); + } else { + message.error('操作失败'); + } + }) + .finally(() => actionRef.current?.reload()); + }, + }); + }; + + const handleAdd = async (record: any) => { + form.resetFields(); + form.setFieldsValue({ + //...record, + providerId: record.id, + providerName: record.name, + id: '', + }); + + setOpen(true); + setTitle('添加招标代理机构'); + }; + const handleReSelect = async (record: any) => { + form.resetFields(); + const agencyDetail = await getDataById(record.id); + if(agencyDetail&&(agencyDetail?.code == 200)&&agencyDetail.data&&agencyDetail.data.providerDetail) { + setCurrentRecord(agencyDetail.data.providerDetail); + setShowEndDate(agencyDetail.data.validity === '2'); + form.setFieldsValue({ + // ...currentRecord, + providerId: agencyDetail.data.providerDetail.id, + providerName: agencyDetail.data.providerDetail.name, + + }); + } + + + setOpen(true); + setTitle('添加招标代理机构'); + }; + const [menuOptions, setMenuOptions] = useState([]); + + + + const handleUpdate = async (record: any) => { + form.resetFields(); + const agencyDetail = await getDataById(record.id); + + if(agencyDetail&&(agencyDetail?.code == 200)&&agencyDetail.data&&agencyDetail.data.providerDetail) { + setCurrentRecord(agencyDetail.data.providerDetail); + setShowEndDate(agencyDetail.data.validity === '2'); + } + form.setFieldsValue({ + ...agencyDetail.data + }); + + 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.periodEnd) { + values.periodEnd = values.periodEnd.format('YYYY-MM-DD'); + } + + if (values.id) { + await updateAgency(values).then((r: any) => { + if (r?.code == 200) { + message.success('修改成功'); + } else { + message.error('修改失败'); + } + }); + } else { + await addAgency(values).then((r: any) => { + + if (r?.code == 200) { + message.success('新增成功'); + } else { + message.error('新增失败'); + } + }); + } + closeModal(); + } catch (error) { + console.error(error); + } + }; + const checkSupModal = ( + setOpen(false)}>关闭} + onOk={handleSubmit} + onCancel={() => closeModal()} + > + + + +
+ +
+ 供应商名称: + {currentRecord?.name || '-'} +
+ +
+ 供应商类型名称: + {currentRecord?.kindName || '-'} +
+
+ 准入时间: + {currentRecord?.accessTime || '-'} +
+
+ 商品品类: + {currentRecord?.goodsTypeName || '-'} +
+ +
+ +
+
+ 姓名: + {currentRecord?.applyUser || '-'} +
+
+ 工号: + {currentRecord?.name || '-'} +
+
+ 角色: + {currentRecord?.kindCode || '-'} +
+
+ 公司: + {currentRecord?.kindName || '-'} +
+
+ 部门: + {currentRecord?.goodsTypeCode || '-'} +
+ +
+
+ + + + + + + { + const value = e.target.value; + setShowEndDate(value === '2'); + if (value === '1') { + + } + }} + /> + + + {showEndDate && ( + + + + )} + + +
+ +
+ ); + 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 }) }} + /> + {checkSupModal} + { + console.log('Selected provider:', provider); + // 处理选中的供应商数据 + setCurrentRecord(provider); + // if (currentRecord && provider) { + handleAdd(provider); + // } + setSelectProviderVisible(false); + // setCurrentRecord(null); + }} + onCancel={() => { + setSelectProviderVisible(false); + setCurrentRecord(null); + }} + /> +
+ {/* 查看 */} +
+ ) +}; +export default agency; \ No newline at end of file diff --git a/src/pages/Agency/AgencyManager/index.tsx b/src/pages/Agency/AgencyManager/index.tsx index b139694..4415911 100644 --- a/src/pages/Agency/AgencyManager/index.tsx +++ b/src/pages/Agency/AgencyManager/index.tsx @@ -43,12 +43,12 @@ const agency: React.FC<{}> = () => { 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' }, }, + { title: '申请人', dataIndex: 'applyUser', search: false, },//, ellipsis: true//, ellipsis: true + { title: '开始服务时间', dataIndex: 'periodBegin', search: false, },//, ellipsis: true + { title: '准入人', dataIndex: 'accessUser', search: false, },//, ellipsis: true + { title: '失效时间', dataIndex: 'periodEnd', search: false,},//, ellipsis: true + { title: '状态', dataIndex: 'validityStatus', valueType: 'select', + valueEnum: { '1': { text: '有效', status: '1' },'2': { text: '失效', status: '2' }, }, },//, ellipsis: true { title: 'id', dataIndex: 'id', search: false,hideInTable:true,},//, ellipsis: true // { title: '创建时间', dataIndex: 'createDate', width: '10%', valueType: 'dateTime', search: false }, @@ -58,11 +58,13 @@ const agency: React.FC<{}> = () => { valueType: 'option', render: (_, record) => [ , - , - , - + , + record.validityStatus === '1' && ( + + ), + record.validityStatus === '2' && ( + + ) ] }, @@ -83,17 +85,53 @@ const agency: React.FC<{}> = () => { }, }); }; + + const handleDisable = (id: string) => { + Modal.confirm({ + title: '确认失效该代理机构?', + onOk: async () => { + await disableAgency(id).then((r: any) => { + if (r?.code == 200) { + message.success('操作成功'); + } else { + message.error('操作失败'); + } + }) + .finally(() => actionRef.current?.reload()); + }, + }); + }; + const handleAdd = async (record: any) => { form.resetFields(); form.setFieldsValue({ - ...record, - providerId: record.id + //...record, + providerId: record.id, + providerName: record.name, + id: '', }); setOpen(true); setTitle('添加招标代理机构'); }; - + const handleReSelect = async (record: any) => { + form.resetFields(); + const agencyDetail = await getDataById(record.id); + if(agencyDetail&&(agencyDetail?.code == 200)&&agencyDetail.data&&agencyDetail.data.providerDetail) { + setCurrentRecord(agencyDetail.data.providerDetail); + setShowEndDate(agencyDetail.data.validity === '2'); + form.setFieldsValue({ + // ...currentRecord, + providerId: agencyDetail.data.providerDetail.id, + providerName: agencyDetail.data.providerDetail.name, + + }); + } + + + setOpen(true); + setTitle('添加招标代理机构'); + }; const [menuOptions, setMenuOptions] = useState([]); @@ -101,9 +139,11 @@ const agency: React.FC<{}> = () => { const handleUpdate = async (record: any) => { form.resetFields(); const agencyDetail = await getDataById(record.id); - // const menus = await roleMenuTreeselect(record.roleId); - // setMenuOptions(menus.data.menus || []); - + + if(agencyDetail&&(agencyDetail?.code == 200)&&agencyDetail.data&&agencyDetail.data.providerDetail) { + setCurrentRecord(agencyDetail.data.providerDetail); + setShowEndDate(agencyDetail.data.validity === '2'); + } form.setFieldsValue({ ...agencyDetail.data }); @@ -122,7 +162,13 @@ const agency: React.FC<{}> = () => { const handleSubmit = async () => { try { const values = await form.validateFields(); - if (values.roleId) { + + // 处理日期,确保只保留日期部分 + if (values.periodEnd) { + values.periodEnd = values.periodEnd.format('YYYY-MM-DD'); + } + + if (values.id) { await updateAgency(values).then((r: any) => { if (r?.code == 200) { message.success('修改成功'); @@ -132,7 +178,7 @@ const agency: React.FC<{}> = () => { }); } else { await addAgency(values).then((r: any) => { - console.log("r?.code", r?.code) + if (r?.code == 200) { message.success('新增成功'); } else { @@ -220,7 +266,9 @@ const agency: React.FC<{}> = () => { - +