diff --git a/src/pages/RecruitmentDataCollection/JobMonitor/detail.tsx b/src/pages/RecruitmentDataCollection/JobMonitor/detail.tsx new file mode 100644 index 0000000..8dda108 --- /dev/null +++ b/src/pages/RecruitmentDataCollection/JobMonitor/detail.tsx @@ -0,0 +1,106 @@ +import { Modal, Table } from 'antd'; +import type { ProColumns } from '@ant-design/pro-components'; +import { ProDescriptions } from '@ant-design/pro-components'; +import React, { useEffect } from 'react'; + +export type StorageFormProps = { + onCancel: (flag?: boolean, formVals?: unknown) => void; + open: boolean; + values?: Partial; +}; + +const ViewStorageDetail: React.FC = (props) => { + const detailColumns: ProColumns[] = [ + // { + // title: '详情ID', + // dataIndex: 'detailId', + // key: 'detailId', + // width: 80, + // ellipsis: true, + // }, + { + title: '入库来源网站名称', + dataIndex: 'websiteName', + key: 'websiteName', + width: 150, + }, + { + title: '入库成功数量', + dataIndex: 'successNumber', + key: 'successNumber', + width: 120, + align: 'center', + }, + { + title: '入库失败数量', + dataIndex: 'failedNumber', + key: 'failedNumber', + width: 120, + align: 'center', + }, + { + title: '入库数据详情', + dataIndex: 'storageDetail', + key: 'storageDetail', + width: 200, + ellipsis: true, + }, + { + title: '入库具体时间', + dataIndex: 'storageTime', + key: 'storageTime', + width: 180, + }, + ]; + + const handleCancel = () => { + props.onCancel(); + }; + + return ( + + {/* 基本信息 */} +
+

基本信息

+ + column={2} + dataSource={props.values || {}} + bordered + > + {/* */} + + + + + +
+ + {/* 入库数据来源详情列表 */} +
+

入库数据来源详情

+ + columns={detailColumns} + dataSource={props.values?.details || []} + rowKey="detailId" + pagination={false} + bordered + size="middle" + scroll={{ x: 800 }} + /> +
+
+ ); +}; + +export default ViewStorageDetail; \ No newline at end of file diff --git a/src/pages/RecruitmentDataCollection/JobMonitor/edit.tsx b/src/pages/RecruitmentDataCollection/JobMonitor/edit.tsx deleted file mode 100644 index 342625a..0000000 --- a/src/pages/RecruitmentDataCollection/JobMonitor/edit.tsx +++ /dev/null @@ -1,134 +0,0 @@ -import { - ModalForm, - ProForm, - ProFormDatePicker, - ProFormDigit, - ProFormText, - ProFormTextArea, - ProDescriptions, -} from '@ant-design/pro-components'; -import { Form } from 'antd'; -import React, { useEffect } from 'react'; - -export type StorageFormProps = { - onCancel: (flag?: boolean, formVals?: unknown) => void; - onSubmit: (values: API.StorageDetection.StorageItem) => Promise; - open: boolean; - values?: Partial; - mode?: 'view' | 'edit' | 'create'; -}; - -const StorageEdit: React.FC = (props) => { - const [form] = Form.useForm(); - const { mode = props.values ? 'edit' : 'create' } = props; - - useEffect(() => { - if (props.open) { - form.resetFields(); - if (props.values) { - form.setFieldsValue(props.values); - } - } - }, [form, props.values?.detectionId, props.open]); - - const handleCancel = () => { - props.onCancel(); - form.resetFields(); - }; - - const handleFinish = async (values: Record) => { - props.onSubmit(values as API.StorageDetection.StorageItem); - }; - - if (mode === 'view') { - return ( - handleCancel(), - footer: null, - }} - submitter={false} - > - - column={2} - dataSource={props.values || {}} - > - {/* */} - - - - - - - - ); - } - - return ( - - title={mode === 'edit' ? '编辑入库监测' : '新建入库监测'} - form={form} - autoFocusFirstInput - open={props.open} - modalProps={{ - destroyOnClose: true, - onCancel: () => handleCancel(), - }} - submitTimeout={2000} - onFinish={handleFinish} - > - - - - - - - - - - - ); -}; - -export default StorageEdit; diff --git a/src/pages/RecruitmentDataCollection/JobMonitor/index.tsx b/src/pages/RecruitmentDataCollection/JobMonitor/index.tsx index 1a11205..b1ca2d5 100644 --- a/src/pages/RecruitmentDataCollection/JobMonitor/index.tsx +++ b/src/pages/RecruitmentDataCollection/JobMonitor/index.tsx @@ -3,12 +3,11 @@ import { useAccess } from '@umijs/max'; import { getStorageDetectionList, getStorageDetectionSingle, - saveStorageDetection, } from '@/services/recruitmentDataCollection/jobMonitor'; import { Button, FormInstance, message } from 'antd'; import { ActionType, ProColumns, ProTable } from '@ant-design/pro-components'; -import { FormOutlined, EyeOutlined } from '@ant-design/icons'; -import EditStorageRow from './edit'; +import { EyeOutlined } from '@ant-design/icons'; +import ViewStorageDetail from './detail'; function StorageDetectionList() { const access = useAccess(); @@ -18,7 +17,6 @@ function StorageDetectionList() { const [currentRow, setCurrentRow] = useState(); const [modalVisible, setModalVisible] = useState(false); - const [mode, setMode] = useState<'view' | 'edit'>('view'); const [loading, setLoading] = useState(false); // 查看详情 @@ -29,7 +27,6 @@ function StorageDetectionList() { if (res.code === 200) { setCurrentRow(res.data); setModalVisible(true); - setMode('view'); } else { message.error(res.msg); } @@ -40,33 +37,7 @@ function StorageDetectionList() { } }; - // 编辑 - const handleEdit = async (detectionId: any) => { - setLoading(true); - try { - const res = await getStorageDetectionSingle(detectionId); - if (res.code === 200) { - setCurrentRow(res.data); - setModalVisible(true); - setMode('edit'); - } else { - message.error(res.msg); - } - } catch (error) { - message.error('获取编辑数据失败'); - } finally { - setLoading(false); - } - }; - const columns: ProColumns[] = [ - // { - // title: '监测ID', - // dataIndex: 'detectionId', - // valueType: 'text', - // align: 'center', - // hideInSearch: true, - // }, { title: '采集入库日期', dataIndex: 'storageDate', @@ -103,13 +74,12 @@ function StorageDetectionList() { hideInSearch: true, ellipsis: true, }, - { title: '操作', hideInSearch: true, align: 'center', dataIndex: 'detectionId', - width: 200, + width: 120, render: (detectionId, record) => (
- {/* */}
), }, @@ -166,26 +125,8 @@ function StorageDetectionList() { }} /> - { - try { - const resData = await saveStorageDetection(values); - if (resData.code === 200) { - setModalVisible(false); - setCurrentRow(undefined); - message.success('保存成功'); - if (actionRef.current) { - actionRef.current.reload(); - } - } else { - message.error(resData.msg || '保存失败'); - } - } catch (error) { - message.error('保存失败'); - } - }} values={currentRow} onCancel={() => { setModalVisible(false); @@ -196,4 +137,4 @@ function StorageDetectionList() { ); } -export default StorageDetectionList; +export default StorageDetectionList; \ No newline at end of file diff --git a/src/types/RecruitmentDataCollection/jobMonitor.d.ts b/src/types/RecruitmentDataCollection/jobMonitor.d.ts index 0daf8e5..12c5264 100644 --- a/src/types/RecruitmentDataCollection/jobMonitor.d.ts +++ b/src/types/RecruitmentDataCollection/jobMonitor.d.ts @@ -1,4 +1,14 @@ declare namespace API.StorageDetection { + export interface StorageDetailItem { + detailId?: string; + websiteId?: string; + websiteName?: string; + successNumber?: string; + failedNumber?: string; + storageDetail?: string; + storageTime?: string; + } + export interface StorageItem { detectionId?: string; storageDate?: string; @@ -7,6 +17,7 @@ declare namespace API.StorageDetection { storageDetail?: string; websiteId?: string; websiteName?: string; + details?: StorageDetailItem[]; } export interface AddParams { @@ -35,4 +46,4 @@ declare namespace API.StorageDetection { total: number; rows: Array; } -} +} \ No newline at end of file