Browse Source

巡更、养护编号按照日期累加

dev
LUCAS 2 years ago
parent
commit
e9a997d11e
  1. 4
      api/app/lib/controllers/report/index.js
  2. 25
      web/client/src/sections/fillion/components/maintenanceTable.js
  3. 26
      web/client/src/sections/fillion/components/patrolTable.js

4
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

25
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));
}

26
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));
}

Loading…
Cancel
Save