Files
fe_supplier_frontend/src/pages/supplier/backend/changeProgressInquiry/index.tsx

203 lines
6.3 KiB
TypeScript
Raw Normal View History

2025-06-24 10:52:30 +08:00
import React, { useEffect, useState } from "react";
2025-06-24 11:08:51 +08:00
import { useIntl } from 'umi';
2025-06-24 10:52:30 +08:00
import { Form, Button, Table, Select, DatePicker, Input } from 'antd';
import type { ColumnsType, TablePaginationConfig } from 'antd/es/table';
2025-07-10 15:38:05 +08:00
import { SearchOutlined, DeleteOutlined } from '@ant-design/icons';
//时间转换
2025-06-24 10:52:30 +08:00
import moment from 'moment';
2025-07-10 15:38:05 +08:00
//查看组件
import DetailView from './components/DetailView';
//字典与接口
import { getSupplierChangePage } from './services';
2025-07-02 16:18:03 +08:00
import { getDictList } from '@/servers/api/dicts'
2025-07-10 15:38:05 +08:00
//统一列表分页
import tableProps from '@/utils/tableProps'
2025-06-24 10:52:30 +08:00
interface Data {
deptName: string;
categoryName: string;
createTime: string;
exitTime: string;
exitReason: string;
2025-07-02 16:18:03 +08:00
id?: string;
}
interface Dict {
dicName: string;
code: string;
2025-06-24 10:52:30 +08:00
}
const CooperateEnterprise: React.FC = () => {
//双语
const intl = useIntl();
//查询
const [searchForm] = Form.useForm();
//列表数据
const [data, setData] = useState<Data[]>([]);
2025-07-02 16:18:03 +08:00
//
const [enterpriseType, setEnterpriseType] = useState<Dict[]>();
2025-06-24 10:52:30 +08:00
//列表加载
const [loading, setLoading] = useState(false);
//列表分页
const [pagination, setPagination] = useState<TablePaginationConfig>({ current: 1, pageSize: 10, total: 0 });
//弹出组件开关状态
const [detailVisible, setDetailVisible] = useState(false);
//弹出组件参数
2025-07-02 16:18:03 +08:00
const [currentDetail, setCurrentDetail] = useState('');
2025-06-24 10:52:30 +08:00
//列表头部
const columns: ColumnsType<Data> = [
{
title: '序号',
dataIndex: 'index',
key: 'index',
width: 80,
align: 'center',
2025-07-02 16:18:03 +08:00
render: (_: any, __: any, idx: number) => (((pagination.current ?? 1) - 1) * (pagination.pageSize ?? 10)) + idx + 1,
2025-06-24 10:52:30 +08:00
},
{
title: '变更内容',
2025-07-02 16:18:03 +08:00
dataIndex: 'changeDesc',
key: 'changeDesc',
2025-06-24 10:52:30 +08:00
},
{
title: '提交时间',
2025-07-02 16:18:03 +08:00
dataIndex: 'updateTime',
key: 'updateTime',
2025-06-24 10:52:30 +08:00
},
{
title: '审批单位',
2025-07-02 16:18:03 +08:00
dataIndex: 'deptNames',
key: 'deptNames',
2025-06-24 10:52:30 +08:00
},
{
title: '审批状态',
2025-07-02 16:18:03 +08:00
dataIndex: 'enterpriseType',
key: 'enterpriseType',
2025-06-24 10:52:30 +08:00
},
{
title: '审批时间',
2025-07-02 16:18:03 +08:00
dataIndex: 'updateTime',
key: 'updateTime',
2025-06-24 10:52:30 +08:00
},
{
title: '操作',
key: 'action',
render: (text: string, record: Data) => (
<Button type="link" onClick={() => handleDetail(record)}>
</Button>
),
},
];
//重置
const handleReset = () => {
searchForm.resetFields();
2025-07-10 15:38:05 +08:00
getList({ pageNo: 1, pageSize: pagination.pageSize ?? 10 });
2025-06-24 10:52:30 +08:00
};
//搜索
2025-07-02 16:18:03 +08:00
const handleSearch = () => {
2025-06-24 10:52:30 +08:00
getList({
2025-07-02 16:18:03 +08:00
pageNo: 1,
2025-06-24 10:52:30 +08:00
pageSize: pagination.pageSize ?? 10,
});
};
//开启弹出
const handleDetail = (record: Data) => {
2025-07-02 16:18:03 +08:00
setCurrentDetail(record.id || '');
2025-06-24 10:52:30 +08:00
setDetailVisible(true);
};
//关闭演出
const handleDetailClose = () => {
setDetailVisible(false);
};
//列表数据请求
2025-07-02 16:18:03 +08:00
const getList = async (params: { pageNo: number; pageSize: number; }) => {
2025-06-24 10:52:30 +08:00
setLoading(true);
try {
2025-07-02 16:18:03 +08:00
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') : '';
2025-07-10 15:38:05 +08:00
const { code, data } = await getSupplierChangePage({ ...params, changeDesc, deptNames, enterpriseType, startTime, endTime });
2025-06-24 10:52:30 +08:00
if (code === 200) {
2025-07-02 16:18:03 +08:00
setData(data.records);
setPagination({ current: params.pageNo, pageSize: params.pageSize, total: data.total });
2025-06-24 10:52:30 +08:00
}
} catch (error) {
console.error('Failed to fetch data:', error);
} finally {
setLoading(false);
}
};
//初始化
useEffect(() => {
2025-07-02 16:18:03 +08:00
getDictList('approve_type').then((res) => {
2025-07-10 15:38:05 +08:00
if (res.code == 200) {
2025-07-02 16:18:03 +08:00
setEnterpriseType(res.data)
}
})
getList({ pageNo: 1, pageSize: 10 });
2025-06-24 10:52:30 +08:00
}, []);
return (
<>
2025-07-10 15:38:05 +08:00
<div className="common-container">
<div className="filter-action-row">
<Form
form={searchForm}
layout="inline"
onFinish={handleSearch}
className="filter-form"
>
<Form.Item name="changeDesc" label="变更内容">
<Input style={{ width: 160 }} placeholder="请输入变更内容" allowClear maxLength={50} />
</Form.Item>
<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={['开始时间', '结束时间']} allowClear />
</Form.Item>
<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>
<Button className="buttonSubmit" type="primary" htmlType="submit" icon={<SearchOutlined />}>
</Button>
</Form.Item>
<Form.Item>
<Button className="buttonReset" icon={<DeleteOutlined />} onClick={handleReset} ></Button>
</Form.Item>
</Form>
</div>
<Table
rowKey="id"
className="custom-table"
columns={columns}
dataSource={data}
pagination={{...tableProps.pagination, total: pagination.total }}
loading={loading}
onChange={(pagination) => getList({ pageNo: pagination.current!, pageSize: pagination.pageSize! })}
style={{ flex: 1, minHeight: 0 }}
scroll={{ y: 'calc(100vh - 350px)' }}
/>
<DetailView
visible={detailVisible}
onClose={handleDetailClose}
detailId={currentDetail}
/>
</div>
2025-06-24 10:52:30 +08:00
</>
);
};
2025-06-24 11:08:51 +08:00
export default CooperateEnterprise;