From c6ceb741424d7d24e156b3058ada85fddccdc348 Mon Sep 17 00:00:00 2001 From: LUCAS Date: Sat, 30 Jul 2022 15:33:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E5=8A=9F=E8=83=BD=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0-=E5=B7=A1=E6=9B=B4/=E5=85=BB=E6=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/.vscode/launch.json | 4 ++-- api/app/lib/controllers/data/index.js | 10 ++++++++++ api/app/lib/models/report.js | 16 ++++++++-------- .../fillion/components/maintenanceTable.js | 9 ++++++++- .../sections/fillion/components/patrolTable.js | 11 +++++++++-- .../sections/fillion/containers/maintenance.js | 16 ++++------------ .../src/sections/fillion/containers/patrol.js | 16 ++++------------ web/package.json | 2 +- 8 files changed, 46 insertions(+), 38 deletions(-) diff --git a/api/.vscode/launch.json b/api/.vscode/launch.json index eaa8220c..35dd29e4 100644 --- a/api/.vscode/launch.json +++ b/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", diff --git a/api/app/lib/controllers/data/index.js b/api/app/lib/controllers/data/index.js index d7b75558..ab91d22d 100644 --- a/api/app/lib/controllers/data/index.js +++ b/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); diff --git a/api/app/lib/models/report.js b/api/app/lib/models/report.js index 2eaa09b6..3d1d39c6 100644 --- a/api/app/lib/models/report.js +++ b/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 diff --git a/web/client/src/sections/fillion/components/maintenanceTable.js b/web/client/src/sections/fillion/components/maintenanceTable.js index fd71bb1a..5131c273 100644 --- a/web/client/src/sections/fillion/components/maintenanceTable.js +++ b/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 (
@@ -310,7 +317,7 @@ const MaintenanceTable = (props) => {
{ setDateRange(dateString) }} /> - +
diff --git a/web/client/src/sections/fillion/components/patrolTable.js b/web/client/src/sections/fillion/components/patrolTable.js index 2b1e796d..08d408bf 100644 --- a/web/client/src/sections/fillion/components/patrolTable.js +++ b/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 (
@@ -366,7 +373,7 @@ const PatrolTable = (props) => { activeTabKey1 == 'tab1' ?
{ setDateRange(dateString) }} /> - +
: '' } {contentList[activeTabKey1]} diff --git a/web/client/src/sections/fillion/containers/maintenance.js b/web/client/src/sections/fillion/containers/maintenance.js index 6c36021e..d08a032d 100644 --- a/web/client/src/sections/fillion/containers/maintenance.js +++ b/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() - window.open( - '/_api/' + - `attachments?src=files/${resTextIs}&filename=${encodeURIComponent(resTextIs)}&token=${user.token}`) - }) + let reportIds = ids.toString(); + window.open( + '/_api/' + + `data/export?exp=patrol&ids=${reportIds}&token=${user.token}`) } return ( <> diff --git a/web/client/src/sections/fillion/containers/patrol.js b/web/client/src/sections/fillion/containers/patrol.js index 3372ad0a..df84bd81 100644 --- a/web/client/src/sections/fillion/containers/patrol.js +++ b/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() - window.open( - '/_api/' + - `attachments?src=files/${resTextIs}&filename=${encodeURIComponent(resTextIs)}&token=${user.token}`) - }) + let reportIds = ids.toString(); + window.open( + '/_api/' + + `data/export?exp=patrol&ids=${reportIds}&token=${user.token}`) } return ( <> diff --git a/web/package.json b/web/package.json index 7cd3d607..b8aaf86a 100644 --- a/web/package.json +++ b/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",