From e9a997d11e56e2ba0b4ce4a1e0313b981dd0b7d7 Mon Sep 17 00:00:00 2001 From: LUCAS Date: Sat, 30 Jul 2022 20:50:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A1=E6=9B=B4=E3=80=81=E5=85=BB=E6=8A=A4?= =?UTF-8?q?=E7=BC=96=E5=8F=B7=E6=8C=89=E7=85=A7=E6=97=A5=E6=9C=9F=E7=B4=AF?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/controllers/report/index.js | 4 +-- .../fillion/components/maintenanceTable.js | 25 ++++++++++-------- .../fillion/components/patrolTable.js | 26 +++++++++++-------- 3 files changed, 31 insertions(+), 24 deletions(-) diff --git a/api/app/lib/controllers/report/index.js b/api/app/lib/controllers/report/index.js index c7aa1d18..c098336e 100644 --- a/api/app/lib/controllers/report/index.js +++ b/api/app/lib/controllers/report/index.js @@ -4,7 +4,7 @@ const { QueryTypes } = require('sequelize'); async function reportList (ctx) { try { const models = ctx.fs.dc.models; - const { limit, page, startTime, endTime, keyword, userId, reportType, isTop } = ctx.query + const { limit, page, startTime, endTime, keyword, userId, reportType, isTop, asc } = ctx.query let findOption = { where: { @@ -14,7 +14,7 @@ async function reportList (ctx) { model: models.User, attributes: ['name'] }], - order: [['time', 'DESC']], + order: [['time', asc ? 'ASC': 'DESC']], } if (limit) { findOption.limit = limit diff --git a/web/client/src/sections/fillion/components/maintenanceTable.js b/web/client/src/sections/fillion/components/maintenanceTable.js index 937169ac..07207b78 100644 --- a/web/client/src/sections/fillion/components/maintenanceTable.js +++ b/web/client/src/sections/fillion/components/maintenanceTable.js @@ -14,7 +14,7 @@ const DetailForm = (props) => { const { visible, data, handleClose, loading } = props; const [qndmn] = useState(localStorage.getItem('qndmn')); const keyList = [ - { key: '编号', name: 'id' }, + // { key: '编号', name: 'id' }, { key: '工程类型', name: 'projectType' }, { key: '所在路段', name: 'road' }, { key: '具体位置', name: 'address' }, @@ -91,7 +91,8 @@ const DetailList = (props) => { } } - let daySet = {}; + let basicDate = null; + let counter = 0; const columns = [ { @@ -101,14 +102,16 @@ const DetailList = (props) => { align: 'center', render: (text, record) => { let day = moment(record.time).format("YYYYMMDD") - if (daySet[day]) { - daySet[day].add(Symbol()) - } else { - daySet[day] = new Set() - daySet[day].add(Symbol()) + if(!basicDate){ + basicDate = day; + counter +=1; + } else if(basicDate == day){ + counter += 1; + } else if(basicDate != day){ + basicDate = day; + counter = 1; } - return day * 10000 + daySet[day].size - return moment(record.time).format("YYYYMMDD") * 10000 + record.id; + return moment(record.time).format("YYYYMMDD") * 10000 + counter; } }, { title: '工程类型', @@ -300,7 +303,7 @@ const MaintenanceTable = (props) => { useEffect(() => { if (record) { - let query = { userId: record.id, reportType: 'conserve' } + let query = { userId: record.id, reportType: 'conserve' , asc: true} if ((dateRange && dateRange instanceof Array && dateRange[0] != '')) { 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') @@ -317,7 +320,7 @@ const MaintenanceTable = (props) => { } const handelRefresh = () => { - let query = { userId: record.id, reportType: 'patrol' } + let query = { userId: record.id, reportType: 'patrol', asc: true } dispatch(getReportList(query)); } diff --git a/web/client/src/sections/fillion/components/patrolTable.js b/web/client/src/sections/fillion/components/patrolTable.js index e8a79935..0a136197 100644 --- a/web/client/src/sections/fillion/components/patrolTable.js +++ b/web/client/src/sections/fillion/components/patrolTable.js @@ -15,7 +15,7 @@ const DetailForm = (props) => { const { visible, data, handleClose, loading } = props; const [qndmn] = useState(localStorage.getItem('qndmn')); const keyList = [ - { key: '编号', name: 'id' }, + // { key: '编号', name: 'id' }, { key: '工程类型', name: 'projectType' }, { key: '所在路段', name: 'road' }, { key: '具体位置', name: 'address' }, @@ -91,7 +91,9 @@ const DetailList = (props) => { }) } } - let daySet = {}; + let basicDate = null; + let counter = 0; + const columns = [ { title: '编号', @@ -100,14 +102,16 @@ const DetailList = (props) => { align: 'center', render: (text, record) => { let day = moment(record.time).format("YYYYMMDD") - if (daySet[day]) { - daySet[day].add(Symbol()) - } else { - daySet[day] = new Set() - daySet[day].add(Symbol()) + if(!basicDate){ + basicDate = day; + counter +=1; + } else if(basicDate == day){ + counter += 1; + } else if(basicDate != day){ + basicDate = day; + counter = 1; } - return day * 10000 + daySet[day].size - return moment(record.time).format("YYYYMMDD") * 10000 + record.id; + return moment(record.time).format("YYYYMMDD") * 10000 + counter; } }, { @@ -316,7 +320,7 @@ const PatrolTable = (props) => { }, [record, dateRange]) const queryData = () => { - let query = { userId: record.id, reportType: 'patrol' } + let query = { userId: record.id, reportType: 'patrol', asc: true } if ((dateRange && dateRange instanceof Array && dateRange[0] != '')) { 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') @@ -333,7 +337,7 @@ const PatrolTable = (props) => { }, [activeTabKey1]) const handelRefresh = () => { - let query = { userId: record.id, reportType: 'patrol' } + let query = { userId: record.id, reportType: 'patrol', asc: true } dispatch(getReportList(query)); }