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 ( 名称 类型 {data.map((row) => (
flyTo(row)}>{row.name}
{appconsts.GlobalSearch_Type[row.type]}
))}
) } export default RecordTable