diff --git a/api/app/lib/controllers/report/index.js b/api/app/lib/controllers/report/index.js index 0bede193..bbaf89c6 100644 --- a/api/app/lib/controllers/report/index.js +++ b/api/app/lib/controllers/report/index.js @@ -43,8 +43,8 @@ async function reportList(ctx) { if (isTop) { const sqlStr = 'select * from (SELECT R.*, "row_number"() OVER(PARTITION BY R.user_id ORDER BY R."time" DESC) AS NEWINDEX FROM report AS R ) AS NR WHERE NEWINDEX = 1' - const sequelize = ctx.fs.dc.ORM; - reportRes = sequelize.query(sqlStr, { type: QueryTypes.SELECT }); + const sequelize = ctx.fs.dc.orm; + reportRes = await sequelize.query(sqlStr, { type: QueryTypes.SELECT }); } else { reportRes = await models.Report.findAll(findOption) } diff --git a/web/client/src/sections/fillion/components/gis/patrolGis.js b/web/client/src/sections/fillion/components/gis/patrolGis.js index 5b6ceab1..2d15fbc5 100644 --- a/web/client/src/sections/fillion/components/gis/patrolGis.js +++ b/web/client/src/sections/fillion/components/gis/patrolGis.js @@ -35,6 +35,9 @@ function PatrolGis(props) { if ((dateRange && dateRange instanceof Array)) { query.startTime = moment(dateRange[0]).startOf('day').format('YYYY-MM-DD HH:mm:ss') query.endTime = moment(dateRange[1]).endOf('day').format('YYYY-MM-DD HH:mm:ss') + } else { + query.startTime = moment().add(-6, 'day').startOf('day').format('YYYY-MM-DD HH:mm:ss') + query.endTime = moment().endOf('day').format('YYYY-MM-DD HH:mm:ss') } dispatch(getReportList(query)); } else { @@ -47,9 +50,10 @@ function PatrolGis(props) { if (reportList && mapObj) { mapObj.clearMap(); renderMarkers(); - renderPath(); + if (userId) + renderPath(); } - }, [reportList, mapObj]) + }, [reportList, mapObj, userId]) const loadMap = () => { const map = new AMap.Map("amapId", { @@ -100,9 +104,9 @@ function PatrolGis(props) { position: new AMap.LngLat(longitude, latitude), icon: icon, offset: new AMap.Pixel(-12, -12), - extData: { - name: user.name || '', - } + // extData: { + // name: user.name || '', + // } }); // marker.setTitle(s.name); markers.push(marker); diff --git a/web/client/src/sections/fillion/components/patrolTable.js b/web/client/src/sections/fillion/components/patrolTable.js index c93e0bb8..6a5d8caa 100644 --- a/web/client/src/sections/fillion/components/patrolTable.js +++ b/web/client/src/sections/fillion/components/patrolTable.js @@ -126,7 +126,7 @@ const DetailList = (props) => { dataIndex: 'userName', align: 'center', render: (text, record) => { - return record.user.name + return record?.user?.name || '' } }, { title: '上报时间', @@ -254,6 +254,7 @@ const PatrolTable = (props) => { const [record, setRecord] = useState(); const [dateRange, setDateRange] = useState(); const [detailVisible, setDetailVisible] = useState(false) + const [activeTabKey1, setActiveTabKey1] = useState('tab1'); const { RangePicker } = DatePicker; @@ -265,15 +266,27 @@ const PatrolTable = (props) => { useEffect(() => { if (record) { - let query = { userId: record.id, reportType: 'patrol' } - if ((dateRange && dateRange instanceof Array)) { - query.startTime = moment(dateRange[0]).startOf('day').format('YYYY-MM-DD HH:mm:ss') - query.endTime = moment(dateRange[1]).endOf('day').format('YYYY-MM-DD HH:mm:ss') - } - dispatch(getReportList(query)); + queryData(); } }, [record, dateRange]) + const queryData = () => { + let query = { userId: record.id, reportType: 'patrol' } + if ((dateRange && dateRange instanceof Array)) { + query.startTime = moment(dateRange[0]).startOf('day').format('YYYY-MM-DD HH:mm:ss') + query.endTime = moment(dateRange[1]).endOf('day').format('YYYY-MM-DD HH:mm:ss') + } + dispatch(getReportList(query)); + } + + useEffect(() => { + if (activeTabKey1 && activeTabKey1 == 'tab2') { + setRecord(null); + } else if (activeTabKey1 && activeTabKey1 == 'tab1') { + setRecord(userList[0]); + } + }, [activeTabKey1]) + const handelRefresh = () => { let query = { userId: record.id, reportType: 'patrol' } dispatch(getReportList(query)); @@ -303,7 +316,6 @@ const PatrolTable = (props) => { ], tab2: }; - const [activeTabKey1, setActiveTabKey1] = useState('tab1'); const onTab1Change = (key) => { setActiveTabKey1(key); };