safety-eval-service-frontend/src/pages/Container/QualApplication/FilingForm/components/EquipmentStep.jsx

72 lines
2.2 KiB
React
Raw Normal View History

2026-06-30 17:32:29 +08:00
import { Button, Space, Table } from "antd";
import { useState } from "react";
import { resolveUploadFileId } from "~/utils/mockUpload";
import OrgEquipmentSelectModal from "./OrgEquipmentSelectModal";
export default function EquipmentStep({
equipmentList = [],
disabled,
onAdd,
onRemove,
onUploadCalibration,
}) {
const [selectOpen, setSelectOpen] = useState(false);
const existingIds = equipmentList.map((item) => String(item.sourceEquipmentId || ""));
return (
<>
<div style={{ display: "flex", justifyContent: "space-between", marginBottom: 12 }}>
<span style={{ fontWeight: 600 }}>申请单位装备清单</span>
{!disabled && (
<Button size="small" onClick={() => setSelectOpen(true)}>添加设备</Button>
)}
</div>
<Table
size="small"
rowKey="id"
pagination={false}
dataSource={equipmentList}
columns={[
{ title: "序号", width: 60, render: (_, __, index) => index + 1 },
{ title: "装备名称", dataIndex: "deviceName" },
{ title: "规格型号", dataIndex: "deviceModel" },
{ title: "生产厂家", dataIndex: "manufacturer" },
{
title: "计量检定情况",
width: 120,
render: (_, record) => (
!disabled ? (
<Button
type="link"
size="small"
onClick={() => onUploadCalibration?.(record, resolveUploadFileId([]))}
>
上传报告
</Button>
) : (record.calibrationReportUrl ? "已上传" : "-")
),
},
{
title: "操作",
width: 100,
render: (_, record) => (
!disabled && (
<Button type="link" size="small" danger onClick={() => onRemove?.(record)}>移除</Button>
)
),
},
]}
/>
<OrgEquipmentSelectModal
open={selectOpen}
existingIds={existingIds}
onCancel={() => setSelectOpen(false)}
onConfirm={(ids, rows) => {
onAdd?.(ids, rows);
setSelectOpen(false);
}}
/>
</>
);
}