safety-eval-service-frontend/src/pages/Container/QualApplication/FilingListTable.jsx

195 lines
5.7 KiB
React
Raw Normal View History

2026-07-01 10:10:11 +08:00
import { Button, Form, Tag, Table, Typography, Select } from "antd";
import SearchForm from "@cqsjjb/jjb-react-admin-component/SearchForm";
import ControlWrapper from "@cqsjjb/jjb-react-admin-component/ControlWrapper";
import TableAction from "@cqsjjb/jjb-react-admin-component/TableAction";
2026-06-30 17:32:29 +08:00
import { CHONGQING_DISTRICTS } from "~/enumerate/enterpriseOptions";
import {
FILING_FORM_MODE,
getFilingStatusOptions,
2026-07-09 14:15:20 +08:00
2026-06-30 17:32:29 +08:00
isQualFilingEditable,
QUAL_FILING_STATUS_COLOR,
} from "~/enumerate/qualFilingOptions";
2026-07-01 10:10:11 +08:00
import { CHANGE_COUNT_STYLE, getChangeCount } from "~/utils/enterpriseForm";
2026-06-30 17:32:29 +08:00
export default function FilingListTable({
2026-07-01 10:10:11 +08:00
dataSource,
total,
loading,
2026-06-30 17:32:29 +08:00
searchForm,
onSearch,
2026-07-01 10:10:11 +08:00
onPageChange,
scrollY,
2026-06-30 17:32:29 +08:00
mode,
showChangeCount = false,
onChangeCountClick,
onCreate,
createLabel,
listTitle,
listDesc,
PageLayout,
onDelete,
extraActions,
2026-07-09 14:15:20 +08:00
history,
2026-06-30 17:32:29 +08:00
}) {
const statusOptions = getFilingStatusOptions(mode);
const canEditRow = (record) => {
2026-07-09 14:15:20 +08:00
if (mode === FILING_FORM_MODE.FILED) {
return record.filingStatusCode === 2;
}
2026-06-30 17:32:29 +08:00
return isQualFilingEditable(record.filingStatusCode);
};
const columns = [
{ title: "备案属地", dataIndex: "filingTerritoryName", width: 120, ellipsis: true },
{ title: "备案单位", dataIndex: "filingUnitName", ellipsis: true },
2026-07-09 14:15:20 +08:00
{ title: "备案编号", dataIndex: "filingNo", width: 200},
2026-06-30 17:32:29 +08:00
{ title: "安全评价业务范围", dataIndex: "businessScope", ellipsis: true },
];
if (showChangeCount) {
columns.push({
title: "变更次数",
dataIndex: "changeCount",
width: 90,
render: (_, record) => {
const count = getChangeCount(record);
const style = count > 0 ? CHANGE_COUNT_STYLE.active : CHANGE_COUNT_STYLE.zero;
if (count <= 0) {
return <span style={style}>{count}</span>;
}
return (
<Typography.Link
style={style}
onClick={() => onChangeCountClick?.(record)}
>
{count}
</Typography.Link>
);
},
});
}
columns.push({
title: "备案状态",
dataIndex: "filingStatusName",
width: 110,
2026-07-02 16:58:07 +08:00
render: (_, record) => {
const obj= QUAL_FILING_STATUS_COLOR[record.filingStatusCode]
const color = obj?.color || "default";
const name= obj?.label || "-";
return (
obj?<Tag color={color}>
{name || "-"}
</Tag>:"--"
);
},
2026-06-30 17:32:29 +08:00
});
columns.push({
title: "操作",
width: 180,
2026-07-01 10:10:11 +08:00
fixed: "right",
2026-06-30 17:32:29 +08:00
render: (_, record) => (
2026-07-01 10:10:11 +08:00
<TableAction>
2026-06-30 17:32:29 +08:00
<Button
type="link"
size="small"
2026-07-09 14:15:20 +08:00
onClick={() => history.push(`/container/qualApplication/filingForm?mode=${mode}&id=${record.id}&readOnly=1`)}
2026-06-30 17:32:29 +08:00
>
查看
</Button>
{extraActions?.(record)}
{canEditRow(record) && mode !== FILING_FORM_MODE.CHANGE && (
<Button
type="link"
size="small"
2026-07-09 14:15:20 +08:00
onClick={() => history.push(`/container/qualApplication/filingForm?mode=${mode}&id=${record.id}`)}
2026-06-30 17:32:29 +08:00
>
修改
</Button>
)}
{mode === FILING_FORM_MODE.APPLICATION && isQualFilingEditable(record.filingStatusCode) && onDelete && (
<Button type="link" size="small" danger onClick={() => onDelete(record)}>删除</Button>
)}
2026-07-01 10:10:11 +08:00
</TableAction>
2026-06-30 17:32:29 +08:00
),
});
return (
<PageLayout
2026-07-01 10:10:11 +08:00
title={
listDesc ? (
<div>
<span>{listTitle}</span>
<div className="pageLayout-extra">{listDesc}</div>
</div>
) : (
listTitle
)
}
2026-06-30 17:32:29 +08:00
extra={onCreate && (
<Button type="primary" onClick={onCreate}>{createLabel}</Button>
)}
>
2026-07-01 10:10:11 +08:00
<SearchForm
style={{ marginBottom: 24 }}
2026-06-30 17:32:29 +08:00
form={searchForm}
2026-07-01 10:10:11 +08:00
loading={loading}
formLine={[
<Form.Item key="filingUnitName" name="filingUnitName">
<ControlWrapper.Input label="备案单位" placeholder="关键字搜索" allowClear />
</Form.Item>,
2026-07-09 14:15:20 +08:00
<Form.Item key="filingTerritoryCode" name="filingTerritoryCode">
2026-07-01 10:10:11 +08:00
<ControlWrapper.Select
label="备案属地"
2026-07-01 11:55:19 +08:00
placeholder="请输入"
2026-07-01 10:10:11 +08:00
allowClear
style={{ width: "100%" }}
>
{CHONGQING_DISTRICTS.map((d) => (
<Select.Option key={d.value} value={d.value}>{d.label}</Select.Option>
))}
</ControlWrapper.Select>
</Form.Item>,
2026-07-09 14:15:20 +08:00
<Form.Item key="filingNo" name="filingNo">
<ControlWrapper.Input label="备案编号" placeholder="关键字搜索" allowClear />
2026-07-01 10:10:11 +08:00
</Form.Item>,
2026-07-09 14:15:20 +08:00
<Form.Item key="filingStatusCode" name="filingStatusCode">
2026-07-01 10:10:11 +08:00
<ControlWrapper.Select
label="备案状态"
placeholder="全部"
2026-07-09 14:15:20 +08:00
allowClear={false}
showSearch={false}
2026-07-01 10:10:11 +08:00
style={{ width: "100%" }}
>
{statusOptions.map((opt) => (
<Select.Option key={opt.value} value={opt.value}>{opt.label}</Select.Option>
))}
</ControlWrapper.Select>
</Form.Item>,
2026-06-30 17:32:29 +08:00
]}
2026-07-01 10:10:11 +08:00
onFinish={(values) => onSearch(values)}
onReset={(values) => onSearch(values)}
/>
<Table
rowKey="id"
columns={columns}
dataSource={dataSource}
loading={loading}
scroll={{ y: scrollY }}
pagination={{
total,
showSizeChanger: true,
showQuickJumper: true,
showTotal: (t) => `${t}`,
}}
onChange={(pagination) => {
if (onPageChange) onPageChange(pagination);
}}
2026-06-30 17:32:29 +08:00
/>
</PageLayout>
);
}