合并代码

This commit is contained in:
孙景学
2025-07-02 16:18:03 +08:00
parent 2b3eb5672d
commit 3ae57eb23b
87 changed files with 3852 additions and 19276 deletions

View File

@ -3,9 +3,10 @@ import { useIntl } from 'umi';
import { Form, Button, Table, Select, DatePicker, Input } from 'antd';
import type { ColumnsType, TablePaginationConfig } from 'antd/es/table';
import { SearchOutlined } from '@ant-design/icons';
import { getPage } from './services';
import { getSupplierChangePage } from './services';
import moment from 'moment';
import DetailView from './components/DetailView';
import { getDictList } from '@/servers/api/dicts'
interface Data {
deptName: string;
@ -13,6 +14,12 @@ interface Data {
createTime: string;
exitTime: string;
exitReason: string;
id?: string;
}
interface Dict {
dicName: string;
code: string;
}
const CooperateEnterprise: React.FC = () => {
@ -22,6 +29,8 @@ const CooperateEnterprise: React.FC = () => {
const [searchForm] = Form.useForm();
//列表数据
const [data, setData] = useState<Data[]>([]);
//
const [enterpriseType, setEnterpriseType] = useState<Dict[]>();
//列表加载
const [loading, setLoading] = useState(false);
//列表分页
@ -29,7 +38,7 @@ const CooperateEnterprise: React.FC = () => {
//弹出组件开关状态
const [detailVisible, setDetailVisible] = useState(false);
//弹出组件参数
const [currentDetail, setCurrentDetail] = useState<Data | null>(null);
const [currentDetail, setCurrentDetail] = useState('');
//列表头部
const columns: ColumnsType<Data> = [
{
@ -38,32 +47,32 @@ const CooperateEnterprise: React.FC = () => {
key: 'index',
width: 80,
align: 'center',
render: (_: any, __: any, index: number) => index + 1,
render: (_: any, __: any, idx: number) => (((pagination.current ?? 1) - 1) * (pagination.pageSize ?? 10)) + idx + 1,
},
{
title: '变更内容',
dataIndex: 'deptName',
key: 'deptName',
dataIndex: 'changeDesc',
key: 'changeDesc',
},
{
title: '提交时间',
dataIndex: 'categoryName',
key: 'categoryName',
dataIndex: 'updateTime',
key: 'updateTime',
},
{
title: '审批单位',
dataIndex: 'createTime',
key: 'createTime',
dataIndex: 'deptNames',
key: 'deptNames',
},
{
title: '审批状态',
dataIndex: 'exitTime',
key: 'exitTime',
dataIndex: 'enterpriseType',
key: 'enterpriseType',
},
{
title: '审批时间',
dataIndex: 'exitReason',
key: 'exitReason',
dataIndex: 'updateTime',
key: 'updateTime',
},
{
title: '操作',
@ -78,24 +87,18 @@ const CooperateEnterprise: React.FC = () => {
//重置
const handleReset = () => {
searchForm.resetFields();
getList({ page: 1, pageSize: pagination.pageSize ?? 10, parentCode: '', startTime: '', endTime: '' });
getList({ pageNo: 1, pageSize: pagination.pageSize ?? 10 });
};
//搜索
const handleSearch = (values: any) => {
const { parentCode, createTime } = values;
const startTime = createTime ? moment(createTime[0]).format('YYYY-MM-DD') : '';
const endTime = createTime ? moment(createTime[1]).format('YYYY-MM-DD') : '';
const handleSearch = () => {
getList({
page: 1,
pageNo: 1,
pageSize: pagination.pageSize ?? 10,
parentCode: parentCode || '',
startTime,
endTime,
});
};
//开启弹出
const handleDetail = (record: Data) => {
setCurrentDetail(record);
setCurrentDetail(record.id || '');
setDetailVisible(true);
};
//关闭演出
@ -103,13 +106,17 @@ const CooperateEnterprise: React.FC = () => {
setDetailVisible(false);
};
//列表数据请求
const getList = async (params: { page: number; pageSize: number; parentCode: string; startTime: string; endTime: string }) => {
const getList = async (params: { pageNo: number; pageSize: number; }) => {
setLoading(true);
try {
const { code , data, total } = await getPage(params);
const values = searchForm.getFieldsValue();
const { changeDesc, createTime, deptNames, enterpriseType } = values;
const startTime = createTime ? moment(createTime[0]).format('YYYY-MM-DD') : '';
const endTime = createTime ? moment(createTime[1]).format('YYYY-MM-DD') : '';
const { code , data } = await getSupplierChangePage({...params, changeDesc, deptNames, enterpriseType,startTime,endTime});
if (code === 200) {
setData(data);
setPagination({ current: params.page, pageSize: params.pageSize, total });
setData(data.records);
setPagination({ current: params.pageNo, pageSize: params.pageSize, total: data.total });
}
} catch (error) {
console.error('Failed to fetch data:', error);
@ -119,7 +126,13 @@ const CooperateEnterprise: React.FC = () => {
};
//初始化
useEffect(() => {
getList({ page: 1, pageSize: 10, parentCode: '', startTime: '', endTime: '' });
getDictList('approve_type').then((res) => {
if(res.code == 200) {
setEnterpriseType(res.data)
}
})
getList({ pageNo: 1, pageSize: 10 });
}, []);
return (
@ -130,24 +143,24 @@ const CooperateEnterprise: React.FC = () => {
onFinish={handleSearch}
style={{ marginBottom: 16 }}
>
<Form.Item name="parentCode" label="变更内容">
<Input placeholder="请输入变更内容" />
<Form.Item name="changeDesc" label="变更内容">
<Input style={{ width: 160 }} placeholder="请输入变更内容" allowClear maxLength={50} />
</Form.Item>
<Form.Item name="parentCode" label="审批单位">
<Select placeholder="请选择审批单位">
<Form.Item name="deptNames" label="审批单位">
<Select style={{ width: 160 }} placeholder="请选择审批单位" allowClear>
<Select.Option value="品类1">1</Select.Option>
<Select.Option value="品类2">2</Select.Option>
<Select.Option value="品类3">3</Select.Option>
</Select>
</Form.Item>
<Form.Item name="createTime" label="提交时间">
<DatePicker.RangePicker placeholder={['开始时间', '结束时间']} />
<DatePicker.RangePicker placeholder={['开始时间', '结束时间']} allowClear />
</Form.Item>
<Form.Item name="parentCode" label="审批状态">
<Select placeholder="请选择审批状态">
<Select.Option value="品类1">1</Select.Option>
<Select.Option value="品类2">2</Select.Option>
<Select.Option value="品类3">3</Select.Option>
<Form.Item name="enterpriseType" label="审批状态">
<Select style={{ width: 160 }} placeholder="请选择审批状态" allowClear>
{enterpriseType?.map(item => (
<Select.Option key={item.code} value={item.code}>{item.dicName}</Select.Option>
))}
</Select>
</Form.Item>
<Form.Item>
@ -166,12 +179,12 @@ const CooperateEnterprise: React.FC = () => {
dataSource={data}
pagination={pagination}
loading={loading}
onChange={(pagination) => getList({ page: pagination.current!, pageSize: pagination.pageSize!, parentCode: '', startTime: '', endTime: '' })}
onChange={(pagination) => getList({ pageNo: pagination.current!, pageSize: pagination.pageSize! })}
/>
<DetailView
visible={detailVisible}
onClose={handleDetailClose}
detailId={10}
detailId={currentDetail}
/>
</>
);