Browse Source

导出功能添加-巡更/养护

dev
LUCAS 2 years ago
parent
commit
c6ceb74142
  1. 4
      api/.vscode/launch.json
  2. 10
      api/app/lib/controllers/data/index.js
  3. 16
      api/app/lib/models/report.js
  4. 9
      web/client/src/sections/fillion/components/maintenanceTable.js
  5. 11
      web/client/src/sections/fillion/components/patrolTable.js
  6. 12
      web/client/src/sections/fillion/containers/maintenance.js
  7. 12
      web/client/src/sections/fillion/containers/patrol.js
  8. 2
      web/package.json

4
api/.vscode/launch.json

@ -13,8 +13,8 @@
"NODE_ENV": "development"
},
"args": [
"-p 14000",
"-f http://localhost:14000",
"-p 4000",
"-f http://localhost:4000",
"-g postgres://postgres:123@10.8.30.32:5432/highways4good",
"--qnak XuDgkao6cL0HidoMAPnA5OB10Mc_Ew08mpIfRJK5",
"--qnsk yewcieZLzKZuDfig0wLZ9if9jKp2P_1jd3CMJPSa",

10
api/app/lib/controllers/data/index.js

@ -55,6 +55,16 @@ async function dataExport (ctx) {
k: 'busCar',
tableName: 'BusCar',
},
{
n: '巡更记录',
k: 'patrol',
tableName: 'Report',
},
{
n: '养护记录',
k: 'maintenance',
tableName: 'Report',
},
]
const modalOption = modalList.find(item => item.k == exp);

16
api/app/lib/models/report.js

@ -41,7 +41,7 @@ module.exports = dc => {
type: DataTypes.STRING,
allowNull: true,
defaultValue: null,
comment: null,
comment: '所属道路',
primaryKey: false,
field: "road",
autoIncrement: false
@ -51,7 +51,7 @@ module.exports = dc => {
type: DataTypes.STRING,
allowNull: true,
defaultValue: null,
comment: null,
comment: '开始路段',
primaryKey: false,
field: "road_section_start",
autoIncrement: false
@ -61,7 +61,7 @@ module.exports = dc => {
type: DataTypes.STRING,
allowNull: true,
defaultValue: null,
comment: null,
comment: '结束路段',
primaryKey: false,
field: "road_section_end",
autoIncrement: false
@ -71,7 +71,7 @@ module.exports = dc => {
type: DataTypes.DOUBLE,
allowNull: true,
defaultValue: null,
comment: null,
comment: '经度',
primaryKey: false,
field: "longitude",
autoIncrement: false
@ -81,7 +81,7 @@ module.exports = dc => {
type: DataTypes.DOUBLE,
allowNull: true,
defaultValue: null,
comment: null,
comment: '纬度',
primaryKey: false,
field: "latitude",
autoIncrement: false
@ -91,7 +91,7 @@ module.exports = dc => {
type: DataTypes.STRING,
allowNull: true,
defaultValue: null,
comment: null,
comment: '具体内容',
primaryKey: false,
field: "content",
autoIncrement: false
@ -151,7 +151,7 @@ module.exports = dc => {
type: DataTypes.DATE,
allowNull: false,
defaultValue: null,
comment: null,
comment: '创建日期',
primaryKey: false,
field: "time",
autoIncrement: false
@ -161,7 +161,7 @@ module.exports = dc => {
type: DataTypes.STRING,
allowNull: true,
defaultValue: null,
comment: null,
comment: '具体位置',
primaryKey: false,
field: "address",
autoIncrement: false

9
web/client/src/sections/fillion/components/maintenanceTable.js

@ -301,6 +301,13 @@ const MaintenanceTable = (props) => {
dispatch(getReportList(query));
}
const handleExport = () => {
if (reportList && reportList instanceof Array && reportList.length) {
let ids = reportList.map(item => item.id);
exports(ids);
}
}
return (
<div className='card-protable'>
<Card >
@ -310,7 +317,7 @@ const MaintenanceTable = (props) => {
<div style={{ marginBottom: 20 }}>
<RangePicker onChange={(date, dateString) => { setDateRange(dateString) }} />
<Button style={{ marginLeft: 20 }}>查询</Button>
<Button style={{ marginLeft: 20 }}>导出</Button>
<Button style={{ marginLeft: 20 }} onClick={handleExport}>导出</Button>
</div>
<Card style={{ flex: 1 }}>
<DetailList reportList={reportList} record={record} loading={reportListLoading} dispatch={dispatch} handleOpen={handleOpen} />

11
web/client/src/sections/fillion/components/patrolTable.js

@ -267,7 +267,7 @@ const PatrolNameList = (props) => {
const PatrolTable = (props) => {
const { userList, reportList, dispatch, reportListLoading, reportDetail, reportDetailLoading, userLoading } = props;
const { userList, reportList, dispatch, reportListLoading, reportDetail, reportDetailLoading, userLoading, exports } = props;
const [record, setRecord] = useState();
const [dateRange, setDateRange] = useState();
const [detailVisible, setDetailVisible] = useState(false)
@ -345,6 +345,13 @@ const PatrolTable = (props) => {
setRecord(target);
}
const handleExport = () => {
if (reportList && reportList instanceof Array && reportList.length) {
let ids = reportList.map(item => item.id);
exports(ids);
}
}
return (
<div className='card-protable'>
<Card >
@ -366,7 +373,7 @@ const PatrolTable = (props) => {
activeTabKey1 == 'tab1' ? <div style={{ marginBottom: 20 }}>
<RangePicker onChange={(date, dateString) => { setDateRange(dateString) }} />
<Button style={{ marginLeft: 20 }}>查询</Button>
<Button style={{ marginLeft: 20 }}>导出</Button>
<Button style={{ marginLeft: 20 }} onClick={handleExport} >导出</Button>
</div> : ''
}
{contentList[activeTabKey1]}

12
web/client/src/sections/fillion/containers/maintenance.js

@ -22,18 +22,10 @@ const Maintenance = (props) => {
//批量导出
const exports = (ids, counts) => {
// console.log(user);
let reportIds = [];
if (ids.length)
reportIds = ids
else
reportIds = (counts || {}).ids || [];
superagent.post('/_report/http')
.send({ id: reportIds.map(i => Number(i)) }).end((err, res) => {
const resTextIs = res.text.split('/').pop()
let reportIds = ids.toString();
window.open(
'/_api/' +
`attachments?src=files/${resTextIs}&filename=${encodeURIComponent(resTextIs)}&token=${user.token}`)
})
`data/export?exp=patrol&ids=${reportIds}&token=${user.token}`)
}
return (
<> <MaintenanceTable data={data} exports={exports} />

12
web/client/src/sections/fillion/containers/patrol.js

@ -20,18 +20,10 @@ const patrol = (props) => {
//批量导出
const exports = (ids, counts) => {
// console.log(user);
let reportIds = [];
if (ids.length)
reportIds = ids
else
reportIds = (counts || {}).ids || [];
superagent.post('/_report/http')
.send({ id: reportIds.map(i => Number(i)) }).end((err, res) => {
const resTextIs = res.text.split('/').pop()
let reportIds = ids.toString();
window.open(
'/_api/' +
`attachments?src=files/${resTextIs}&filename=${encodeURIComponent(resTextIs)}&token=${user.token}`)
})
`data/export?exp=patrol&ids=${reportIds}&token=${user.token}`)
}
return (
<> <PatrolTable data={data} exports={exports} />

2
web/package.json

@ -6,7 +6,7 @@
"scripts": {
"test": "mocha",
"start": "cross-env NODE_ENV=development npm run start-params",
"start-params": "node server -p 5000 -u http://localhost:14000 --qndmn http://rfkimpwbb.hn-bkt.clouddn.com",
"start-params": "node server -p 5000 -u http://localhost:4000 --qndmn http://rfkimpwbb.hn-bkt.clouddn.com",
"deploy": "export NODE_ENV=production&&npm run color && npm run build && node server",
"build-dev": "export NODE_ENV=development&&webpack --config webpack.config.js",
"build": "export NODE_ENV=production&&webpack --config webpack.config.prod.js",

Loading…
Cancel
Save