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) { async function reportList (ctx) {
try { try {
const models = ctx.fs.dc.models; 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 = { let findOption = {
where: { where: {
@ -14,7 +14,7 @@ async function reportList (ctx) {
model: models.User, model: models.User,
attributes: ['name'] attributes: ['name']
}], }],
order: [['time', 'DESC']], order: [['time', asc ? 'ASC': 'DESC']],
} }
if (limit) { if (limit) {
findOption.limit = 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 { visible, data, handleClose, loading } = props;
const [qndmn] = useState(localStorage.getItem('qndmn')); const [qndmn] = useState(localStorage.getItem('qndmn'));
const keyList = [ const keyList = [
{ key: '编号', name: 'id' }, // { key: '编号', name: 'id' },
{ key: '工程类型', name: 'projectType' }, { key: '工程类型', name: 'projectType' },
{ key: '所在路段', name: 'road' }, { key: '所在路段', name: 'road' },
{ key: '具体位置', name: 'address' }, { key: '具体位置', name: 'address' },
@ -91,7 +91,8 @@ const DetailList = (props) => {
} }
} }
let daySet = {}; let basicDate = null;
let counter = 0;
const columns = [ const columns = [
{ {
@ -101,14 +102,16 @@ const DetailList = (props) => {
align: 'center', align: 'center',
render: (text, record) => { render: (text, record) => {
let day = moment(record.time).format("YYYYMMDD") let day = moment(record.time).format("YYYYMMDD")
if (daySet[day]) { if(!basicDate){
daySet[day].add(Symbol()) basicDate = day;
} else { counter +=1;
daySet[day] = new Set() } else if(basicDate == day){
daySet[day].add(Symbol()) counter += 1;
} else if(basicDate != day){
basicDate = day;
counter = 1;
} }
return day * 10000 + daySet[day].size return moment(record.time).format("YYYYMMDD") * 10000 + counter;
return moment(record.time).format("YYYYMMDD") * 10000 + record.id;
} }
}, { }, {
title: '工程类型', title: '工程类型',
@ -300,7 +303,7 @@ const MaintenanceTable = (props) => {
useEffect(() => { useEffect(() => {
if (record) { 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] != '')) { if ((dateRange && dateRange instanceof Array && dateRange[0] != '')) {
query.startTime = moment(dateRange[0]).startOf('day').format('YYYY-MM-DD HH:mm:ss') 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') query.endTime = moment(dateRange[1]).endOf('day').format('YYYY-MM-DD HH:mm:ss')
@ -317,7 +320,7 @@ const MaintenanceTable = (props) => {
} }
const handelRefresh = () => { const handelRefresh = () => {
let query = { userId: record.id, reportType: 'patrol' } let query = { userId: record.id, reportType: 'patrol', asc: true }
dispatch(getReportList(query)); 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 { visible, data, handleClose, loading } = props;
const [qndmn] = useState(localStorage.getItem('qndmn')); const [qndmn] = useState(localStorage.getItem('qndmn'));
const keyList = [ const keyList = [
{ key: '编号', name: 'id' }, // { key: '编号', name: 'id' },
{ key: '工程类型', name: 'projectType' }, { key: '工程类型', name: 'projectType' },
{ key: '所在路段', name: 'road' }, { key: '所在路段', name: 'road' },
{ key: '具体位置', name: 'address' }, { key: '具体位置', name: 'address' },
@ -91,7 +91,9 @@ const DetailList = (props) => {
}) })
} }
} }
let daySet = {}; let basicDate = null;
let counter = 0;
const columns = [ const columns = [
{ {
title: '编号', title: '编号',
@ -100,14 +102,16 @@ const DetailList = (props) => {
align: 'center', align: 'center',
render: (text, record) => { render: (text, record) => {
let day = moment(record.time).format("YYYYMMDD") let day = moment(record.time).format("YYYYMMDD")
if (daySet[day]) { if(!basicDate){
daySet[day].add(Symbol()) basicDate = day;
} else { counter +=1;
daySet[day] = new Set() } else if(basicDate == day){
daySet[day].add(Symbol()) counter += 1;
} else if(basicDate != day){
basicDate = day;
counter = 1;
} }
return day * 10000 + daySet[day].size return moment(record.time).format("YYYYMMDD") * 10000 + counter;
return moment(record.time).format("YYYYMMDD") * 10000 + record.id;
} }
}, },
{ {
@ -316,7 +320,7 @@ const PatrolTable = (props) => {
}, [record, dateRange]) }, [record, dateRange])
const queryData = () => { 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] != '')) { if ((dateRange && dateRange instanceof Array && dateRange[0] != '')) {
query.startTime = moment(dateRange[0]).startOf('day').format('YYYY-MM-DD HH:mm:ss') 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') query.endTime = moment(dateRange[1]).endOf('day').format('YYYY-MM-DD HH:mm:ss')
@ -333,7 +337,7 @@ const PatrolTable = (props) => {
}, [activeTabKey1]) }, [activeTabKey1])
const handelRefresh = () => { const handelRefresh = () => {
let query = { userId: record.id, reportType: 'patrol' } let query = { userId: record.id, reportType: 'patrol', asc: true }
dispatch(getReportList(query)); dispatch(getReportList(query));
} }

Loading…
Cancel
Save