tsg-web/src/views/gcaqjc/sjtjcx/sljc/index.js

76 lines
3.1 KiB
JavaScript

import React, { Fragment, useRef, useMemo,useEffect,useState } from 'react';
import BasicCrudModal from '../../../../components/crud/BasicCrudModal';
import { Table, Card,Modal,Form,Input,Button,Row,Col,message } from 'antd';
import { useSelector } from 'react-redux';
import ToolBar from './toolbar';
import apiurl from '../../../../service/apiurl';
import usePageTable from '../../../../components/crud/usePageTable2';
import { createCrudService } from '../../../../components/crud/_';
import { httppost2 } from '../../../../utils/request';
import "./index.less"
const Page = () => {
const role = useSelector(state => state.auth.role);
const refModal = useRef();
const [searchVal, setSearchVal] = useState(false)
const columns = [
{ title: '序号', key: 'inx', dataIndex: 'inx', width: 60, align:"center" },
{ title: '水库代码', key: 'rscd', dataIndex: 'rscd', width: 200, ellipsis: true, align:"center" },
{ title: '水工建筑物编号', key: 'hycncd', dataIndex: 'hycncd', width: 200, align:"center"},
{ title: '测点编号', key: 'mpcd', dataIndex: 'mpcd', width: 200, align:"center"},
{ title: '测量时间', key: 'mstm', dataIndex: 'mstm', width: 200, align:"center"},
{ title: '温度(°C)', key: 'tm', dataIndex: 'tm', width: 250, ellipsis: true,align:"center", },
{ title: '渗流量(l/s)', key: 'spqn', dataIndex: 'spqn', width: 250, ellipsis: true,align:"center", },
{
title: '标准水温渗流量(l/s)', key: 'stspqn', dataIndex: 'stspqn', width: 200, align:"center",
},
{ title: '创建时间', key: 'createTime', dataIndex: 'createTime', width: 200, ellipsis: true,align:"center" },
{ title: '更新时间', key: 'updateTm', dataIndex: 'updateTm', width: 200, ellipsis: true,align:"center" },
];
const width = useMemo(() => columns.reduce((total, cur) => total + (cur.width), 0), [columns]);
const command = (type) => (params) => {
if (type === 'save') {
refModal.current.showSave();
} else if (type === 'edit') {
refModal.current.showEdit({ ...params });
} else if (type === 'view') {
refModal.current.showView(params);
} else if (type === 'del') {
refModal.current.onDeleteGet(apiurl.gcaqjc.gcaqyj.yhyj.delete + `/${params.goodsId}`);
}
}
const { tableProps, search, refresh } = usePageTable(createCrudService(apiurl.gcaqjc.sjtjcx.slcx.page).find_noCode);
useEffect(()=>{
const params = {
search: {
...searchVal,
}
};
search(params)
}, [searchVal])
return (
<>
<div className='content-root clearFloat xybm' style={{paddingRight:"0",paddingBottom:"0"}}>
<div className='lf CrudAdcdTreeTableBox' style={{ width: "100%" }}>
<Card className='nonebox'>
<ToolBar
setSearchVal={setSearchVal}
onSave={command('save')}
role={role}
/>
</Card>
<div className="ant-card-body" style={{padding:"20px 0 0 0"}}>
<Table columns={columns} rowKey="inx" {...tableProps} scroll={{ x: width , y: "calc( 100vh - 400px )"}}/>
</div>
</div>
</div>
</>
);
}
export default Page;