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

244 lines
6.4 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-07-14 11:29:29 +08:00
import {
CHONGQING_DISTRICTS,
QUALIFICATION_INDUSTRY_OPTIONS_MAP,
} from "~/enumerate/enterpriseOptions";
2026-06-30 17:32:29 +08:00
import {
FILING_FORM_MODE,
getFilingStatusOptions,
isQualFilingEditable,
QUAL_FILING_STATUS_COLOR,
} from "~/enumerate/qualFilingOptions";
2026-07-14 11:29:29 +08:00
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 17:12:07 +08:00
if (mode === FILING_FORM_MODE.CHANGE) {
2026-07-14 11:29:29 +08:00
return [1, 3, 5].includes(record.filingStatusCode);
2026-07-09 14:15:20 +08:00
}
2026-07-14 11:29:29 +08:00
return [3, 5].includes(record.filingStatusCode);
2026-06-30 17:32:29 +08:00
};
const columns = [
2026-07-14 11:29:29 +08:00
{
title: "备案属地",
dataIndex: "filingTerritoryName",
width: 120,
ellipsis: true,
},
2026-06-30 17:32:29 +08:00
{ title: "备案单位", dataIndex: "filingUnitName", ellipsis: true },
2026-07-14 11:29:29 +08:00
{ title: "备案编号", dataIndex: "filingNo", width: 200 },
{
title: "安全评价业务范围",
dataIndex: "businessScope",
ellipsis: true,
render: (_, record) => {
if (Array.isArray(record.businessScope)) {
return record.businessScope
.map((item) => QUALIFICATION_INDUSTRY_OPTIONS_MAP[item])
.join("、");
}
return record.businessScope || "-";
},
},
2026-06-30 17:32:29 +08:00
];
if (showChangeCount) {
columns.push({
title: "变更次数",
dataIndex: "changeCount",
width: 90,
render: (_, record) => {
const count = getChangeCount(record);
2026-07-14 11:29:29 +08:00
const style =
count > 0 ? CHANGE_COUNT_STYLE.active : CHANGE_COUNT_STYLE.zero;
2026-06-30 17:32:29 +08:00
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) => {
2026-07-14 11:29:29 +08:00
const obj = QUAL_FILING_STATUS_COLOR[record.filingStatusCode];
2026-07-02 16:58:07 +08:00
const color = obj?.color || "default";
2026-07-14 11:29:29 +08:00
const name = obj?.label || "-";
return obj ? <Tag color={color}>{name || "-"}</Tag> : "--";
2026-07-02 16:58:07 +08:00
},
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-14 11:29:29 +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)}
2026-07-14 11:29:29 +08:00
{canEditRow(record) && (
2026-06-30 17:32:29 +08:00
<Button
type="link"
size="small"
2026-07-14 11:29:29 +08:00
onClick={() =>
history.push(
`/container/qualApplication/filingForm?mode=${mode}&id=${record.id}`,
)
}
2026-06-30 17:32:29 +08:00
>
修改
</Button>
)}
2026-07-14 11:29:29 +08:00
{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-07-14 11:29:29 +08:00
extra={
onCreate && (
<Button type="primary" onClick={onCreate}>
{createLabel}
</Button>
)
}
2026-06-30 17:32:29 +08:00
>
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">
2026-07-14 11:29:29 +08:00
<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="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) => (
2026-07-14 11:29:29 +08:00
<Select.Option key={d.value} value={d.value}>
{d.label}
</Select.Option>
2026-07-01 10:10:11 +08:00
))}
</ControlWrapper.Select>
</Form.Item>,
2026-07-09 14:15:20 +08:00
<Form.Item key="filingNo" name="filingNo">
2026-07-14 11:29:29 +08:00
<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
showSearch={false}
2026-07-01 10:10:11 +08:00
style={{ width: "100%" }}
>
{statusOptions.map((opt) => (
2026-07-14 11:29:29 +08:00
<Select.Option key={opt.value} value={opt.value}>
{opt.label}
</Select.Option>
2026-07-01 10:10:11 +08:00
))}
</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>
);
}