111 lines
3.5 KiB
JavaScript
111 lines
3.5 KiB
JavaScript
import React from 'react';
|
|
|
|
import Table from '@material-ui/core/Table';
|
|
import TableContainer from '@material-ui/core/TableContainer';
|
|
import TableBody from '@material-ui/core/TableBody';
|
|
import TableHead from '@material-ui/core/TableHead';
|
|
import TableRow from '@material-ui/core/TableRow';
|
|
import DpTableCell from '../../../../layouts/mui/DpTableCell';
|
|
import DpTableRow from '../../../../layouts/mui/DpTableRow';
|
|
import appconsts from '../../../../models/appconsts';
|
|
import { dcpjGet, wataGet } from '../../../../models/_/dcpj';
|
|
import { openRecordPop } from '../../MapCtrl/_';
|
|
import { useDispatch } from 'react-redux';
|
|
import { DrpRealPromise, PicStPromise, SkRealPromise } from '../../../../models/_/real';
|
|
import { InfoPopNames } from '../../InfoPops';
|
|
|
|
|
|
function RecordTable({ data }) {
|
|
const dispatch = useDispatch();
|
|
|
|
data = data || [];
|
|
const flyTo = (record) => {
|
|
const { type } = record;
|
|
if (type === 'adcd' || type === 'fzdx') {
|
|
console.log(record);
|
|
openRecordPop(dispatch, 'adcd', {
|
|
...record,
|
|
ADCD: record.adcd,
|
|
NAME: record.adnm,
|
|
}, true)
|
|
} else if (type === 'wata' || type?.startsWith('ws')) {
|
|
wataGet(record.id).then(o => {
|
|
openRecordPop(dispatch, 'ws', o, true)
|
|
});
|
|
} else if (
|
|
type === 'bridge' ||
|
|
type === 'culvert' ||
|
|
type === 'bsnssinfo' ||
|
|
type === 'stinfo' ||
|
|
type === 'wbrinfo' ||
|
|
type === 'srstinfo' ||
|
|
type === 'swstinfo' ||
|
|
type === 'sluice' ||
|
|
type === 'dike' ||
|
|
type === 'danad' ||
|
|
type === 'daminfo' ||
|
|
type === 'flrvvlg' ||
|
|
type === 'transfer' ||
|
|
type === 'placement' ||
|
|
type === 'danad'
|
|
) {
|
|
dcpjGet(type, record.id).then(o => {
|
|
openRecordPop(dispatch, type, o, true)
|
|
});
|
|
} else if (type === 'picst') {
|
|
PicStPromise.get().then((datas) => {
|
|
if (datas?.length > 0) {
|
|
const st = datas.find(o => o.stcd === record.id);
|
|
if (st) {
|
|
openRecordPop(dispatch, InfoPopNames.PicStPop, st, true)
|
|
}
|
|
}
|
|
});
|
|
} else if (type === 'shst' || type === 'qxst' || type === 'swst') {
|
|
DrpRealPromise.get().then((datas) => {
|
|
if (datas?.length > 0) {
|
|
const sttype = type.substr(0, 2);
|
|
const st = datas.find(o => o.stcd === record.id && o.type === sttype);
|
|
if (st) {
|
|
openRecordPop(dispatch, InfoPopNames.RealDrpPop, st, true)
|
|
}
|
|
}
|
|
})
|
|
} else if (type === 'sk') {
|
|
SkRealPromise.get().then((datas) => {
|
|
if (datas?.length > 0) {
|
|
const st = datas.find(o => o.stcd === record.id);
|
|
if (st) {
|
|
openRecordPop(dispatch, InfoPopNames.RealSkPop, st, true)
|
|
}
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
return (
|
|
<TableContainer style={{ height: '100%' }}>
|
|
<Table size="small" stickyHeader>
|
|
<TableHead>
|
|
<TableRow>
|
|
<DpTableCell align="left">名称</DpTableCell>
|
|
<DpTableCell align="right">类型</DpTableCell>
|
|
</TableRow>
|
|
</TableHead>
|
|
<TableBody>
|
|
{data.map((row) => (
|
|
<DpTableRow key={row.type + row.id}>
|
|
<DpTableCell component="th" scope="row">
|
|
<div className="table-ellipsis cursor-pointer" onClick={() => flyTo(row)}>{row.name}</div>
|
|
</DpTableCell>
|
|
<DpTableCell align="right">{appconsts.GlobalSearch_Type[row.type]}</DpTableCell>
|
|
</DpTableRow>
|
|
))}
|
|
</TableBody>
|
|
</Table>
|
|
</TableContainer>
|
|
)
|
|
}
|
|
|
|
export default RecordTable
|