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. 16
      web/client/src/sections/fillion/containers/maintenance.js
  7. 16
      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" "NODE_ENV": "development"
}, },
"args": [ "args": [
"-p 14000", "-p 4000",
"-f http://localhost:14000", "-f http://localhost:4000",
"-g postgres://postgres:123@10.8.30.32:5432/highways4good", "-g postgres://postgres:123@10.8.30.32:5432/highways4good",
"--qnak XuDgkao6cL0HidoMAPnA5OB10Mc_Ew08mpIfRJK5", "--qnak XuDgkao6cL0HidoMAPnA5OB10Mc_Ew08mpIfRJK5",
"--qnsk yewcieZLzKZuDfig0wLZ9if9jKp2P_1jd3CMJPSa", "--qnsk yewcieZLzKZuDfig0wLZ9if9jKp2P_1jd3CMJPSa",

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

@ -55,6 +55,16 @@ async function dataExport (ctx) {
k: 'busCar', k: 'busCar',
tableName: 'BusCar', tableName: 'BusCar',
}, },
{
n: '巡更记录',
k: 'patrol',
tableName: 'Report',
},
{
n: '养护记录',
k: 'maintenance',
tableName: 'Report',
},
] ]
const modalOption = modalList.find(item => item.k == exp); 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, type: DataTypes.STRING,
allowNull: true, allowNull: true,
defaultValue: null, defaultValue: null,
comment: null, comment: '所属道路',
primaryKey: false, primaryKey: false,
field: "road", field: "road",
autoIncrement: false autoIncrement: false
@ -51,7 +51,7 @@ module.exports = dc => {
type: DataTypes.STRING, type: DataTypes.STRING,
allowNull: true, allowNull: true,
defaultValue: null, defaultValue: null,
comment: null, comment: '开始路段',
primaryKey: false, primaryKey: false,
field: "road_section_start", field: "road_section_start",
autoIncrement: false autoIncrement: false
@ -61,7 +61,7 @@ module.exports = dc => {
type: DataTypes.STRING, type: DataTypes.STRING,
allowNull: true, allowNull: true,
defaultValue: null, defaultValue: null,
comment: null, comment: '结束路段',
primaryKey: false, primaryKey: false,
field: "road_section_end", field: "road_section_end",
autoIncrement: false autoIncrement: false
@ -71,7 +71,7 @@ module.exports = dc => {
type: DataTypes.DOUBLE, type: DataTypes.DOUBLE,
allowNull: true, allowNull: true,
defaultValue: null, defaultValue: null,
comment: null, comment: '经度',
primaryKey: false, primaryKey: false,
field: "longitude", field: "longitude",
autoIncrement: false autoIncrement: false
@ -81,7 +81,7 @@ module.exports = dc => {
type: DataTypes.DOUBLE, type: DataTypes.DOUBLE,
allowNull: true, allowNull: true,
defaultValue: null, defaultValue: null,
comment: null, comment: '纬度',
primaryKey: false, primaryKey: false,
field: "latitude", field: "latitude",
autoIncrement: false autoIncrement: false
@ -91,7 +91,7 @@ module.exports = dc => {
type: DataTypes.STRING, type: DataTypes.STRING,
allowNull: true, allowNull: true,
defaultValue: null, defaultValue: null,
comment: null, comment: '具体内容',
primaryKey: false, primaryKey: false,
field: "content", field: "content",
autoIncrement: false autoIncrement: false
@ -151,7 +151,7 @@ module.exports = dc => {
type: DataTypes.DATE, type: DataTypes.DATE,
allowNull: false, allowNull: false,
defaultValue: null, defaultValue: null,
comment: null, comment: '创建日期',
primaryKey: false, primaryKey: false,
field: "time", field: "time",
autoIncrement: false autoIncrement: false
@ -161,7 +161,7 @@ module.exports = dc => {
type: DataTypes.STRING, type: DataTypes.STRING,
allowNull: true, allowNull: true,
defaultValue: null, defaultValue: null,
comment: null, comment: '具体位置',
primaryKey: false, primaryKey: false,
field: "address", field: "address",
autoIncrement: false autoIncrement: false

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

@ -301,6 +301,13 @@ const MaintenanceTable = (props) => {
dispatch(getReportList(query)); dispatch(getReportList(query));
} }
const handleExport = () => {
if (reportList && reportList instanceof Array && reportList.length) {
let ids = reportList.map(item => item.id);
exports(ids);
}
}
return ( return (
<div className='card-protable'> <div className='card-protable'>
<Card > <Card >
@ -310,7 +317,7 @@ const MaintenanceTable = (props) => {
<div style={{ marginBottom: 20 }}> <div style={{ marginBottom: 20 }}>
<RangePicker onChange={(date, dateString) => { setDateRange(dateString) }} /> <RangePicker onChange={(date, dateString) => { setDateRange(dateString) }} />
<Button style={{ marginLeft: 20 }}>查询</Button> <Button style={{ marginLeft: 20 }}>查询</Button>
<Button style={{ marginLeft: 20 }}>导出</Button> <Button style={{ marginLeft: 20 }} onClick={handleExport}>导出</Button>
</div> </div>
<Card style={{ flex: 1 }}> <Card style={{ flex: 1 }}>
<DetailList reportList={reportList} record={record} loading={reportListLoading} dispatch={dispatch} handleOpen={handleOpen} /> <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 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 [record, setRecord] = useState();
const [dateRange, setDateRange] = useState(); const [dateRange, setDateRange] = useState();
const [detailVisible, setDetailVisible] = useState(false) const [detailVisible, setDetailVisible] = useState(false)
@ -345,6 +345,13 @@ const PatrolTable = (props) => {
setRecord(target); setRecord(target);
} }
const handleExport = () => {
if (reportList && reportList instanceof Array && reportList.length) {
let ids = reportList.map(item => item.id);
exports(ids);
}
}
return ( return (
<div className='card-protable'> <div className='card-protable'>
<Card > <Card >
@ -366,7 +373,7 @@ const PatrolTable = (props) => {
activeTabKey1 == 'tab1' ? <div style={{ marginBottom: 20 }}> activeTabKey1 == 'tab1' ? <div style={{ marginBottom: 20 }}>
<RangePicker onChange={(date, dateString) => { setDateRange(dateString) }} /> <RangePicker onChange={(date, dateString) => { setDateRange(dateString) }} />
<Button style={{ marginLeft: 20 }}>查询</Button> <Button style={{ marginLeft: 20 }}>查询</Button>
<Button style={{ marginLeft: 20 }}>导出</Button> <Button style={{ marginLeft: 20 }} onClick={handleExport} >导出</Button>
</div> : '' </div> : ''
} }
{contentList[activeTabKey1]} {contentList[activeTabKey1]}

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

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

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

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

2
web/package.json

@ -6,7 +6,7 @@
"scripts": { "scripts": {
"test": "mocha", "test": "mocha",
"start": "cross-env NODE_ENV=development npm run start-params", "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", "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-dev": "export NODE_ENV=development&&webpack --config webpack.config.js",
"build": "export NODE_ENV=production&&webpack --config webpack.config.prod.js", "build": "export NODE_ENV=production&&webpack --config webpack.config.prod.js",

Loading…
Cancel
Save