From 631505a4265a64e681c2d28322835c61a910d290 Mon Sep 17 00:00:00 2001 From: wuqun Date: Wed, 8 Mar 2023 10:15:36 +0800 Subject: [PATCH] =?UTF-8?q?(*)=E7=BB=93=E6=9E=84=E7=89=A9=E5=B8=83?= =?UTF-8?q?=E8=AE=BE=E5=9B=BE=E7=82=B9=E4=BD=8D=E5=B8=83=E8=AE=BE=20?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/controllers/auth/index.js | 3 +- api/app/lib/controllers/pointDeploy/index.js | 34 +++++++++++++----- api/app/lib/routes/pointDeploy/index.js | 3 ++ .../sections/projectRegime/actions/graph.js | 11 ++++++ .../containers/pointDeploy/default.js | 36 +++++++++++-------- web/client/src/utils/webapi.js | 3 +- 6 files changed, 64 insertions(+), 26 deletions(-) diff --git a/api/app/lib/controllers/auth/index.js b/api/app/lib/controllers/auth/index.js index 85a6ab1..93578bc 100644 --- a/api/app/lib/controllers/auth/index.js +++ b/api/app/lib/controllers/auth/index.js @@ -6,9 +6,8 @@ const moment = require('moment'); const uuid = require('uuid'); async function login(ctx, next) { + const transaction = await ctx.fs.dc.orm.transaction(); try { - const transaction = await ctx.fs.dc.orm.transaction(); - const models = ctx.fs.dc.models; const params = ctx.request.body; let password = Hex.stringify(MD5(params.password)); diff --git a/api/app/lib/controllers/pointDeploy/index.js b/api/app/lib/controllers/pointDeploy/index.js index 49b6fec..8a7360e 100644 --- a/api/app/lib/controllers/pointDeploy/index.js +++ b/api/app/lib/controllers/pointDeploy/index.js @@ -120,24 +120,39 @@ async function delProjectGraph(ctx) { } } +async function getProjectPoints(ctx) { + let rslt = null + try { + const projectId = ctx.params.projectId; + const models = ctx.fs.dc.models; + rslt = await models.Point.findAll({ + attributes: ['id', 'name'], + where: { projectId: projectId } + }) + ctx.status = 200; + ctx.body = rslt; + } catch (err) { + ctx.fs.logger.error(`path: ${ctx.path}, error: ${err}`); + ctx.status = 400; + ctx.body = { + name: 'FindError', + message: '获取结构物点位列表失败' + } + } +} + async function getDeployPoints(ctx) { + let rslt = null; try { const pictureId = ctx.params.pictureId; const models = ctx.fs.dc.models; const heatmap = await models.ProjectGraph.findOne({ where: { id: pictureId } }) if (heatmap) { - let allPoints = await models.Point.findAll({ - attributes: ['id', 'name'], - where: { projectId: heatmap.dataValues.projectId } - }) - let setedPoints = await models.ProjectPointsDeploy.findAll({ + rslt = await models.ProjectPointsDeploy.findAll({ where: { graphId: pictureId } }) ctx.status = 200; - ctx.body = { - allPoints, - setedPoints - }; + ctx.body = rslt; } else { throw new Error('pictureId not found'); } @@ -204,6 +219,7 @@ module.exports = { createGraph, updateGraph, delProjectGraph, + getProjectPoints, getDeployPoints, setDeployPoints }; \ No newline at end of file diff --git a/api/app/lib/routes/pointDeploy/index.js b/api/app/lib/routes/pointDeploy/index.js index 87d06a6..4313f5d 100644 --- a/api/app/lib/routes/pointDeploy/index.js +++ b/api/app/lib/routes/pointDeploy/index.js @@ -15,6 +15,9 @@ module.exports = function (app, router, opts) { app.fs.api.logAttr['DEL/project/graph/:id'] = { content: '删除结构物布设图', visible: false }; router.del('/project/graph/:id', pointDeploy.delProjectGraph); + app.fs.api.logAttr['GET/project/:projectId/all/points'] = { content: '获取结构物点位列表', visible: false }; + router.get('/project/:projectId/all/points', pointDeploy.getProjectPoints); + app.fs.api.logAttr['GET/picture/:pictureId/deploy/points'] = { content: '获取点位布设信息', visible: false }; router.get('/picture/:pictureId/deploy/points', pointDeploy.getDeployPoints); diff --git a/web/client/src/sections/projectRegime/actions/graph.js b/web/client/src/sections/projectRegime/actions/graph.js index 6a8e2f5..1380bb0 100644 --- a/web/client/src/sections/projectRegime/actions/graph.js +++ b/web/client/src/sections/projectRegime/actions/graph.js @@ -49,6 +49,17 @@ export function deleteGraph(id) { }); } +export function getProjectPoints(projectId) { + return (dispatch) => basicAction({ + type: 'get', + dispatch, + actionType: 'GET_PROJECT_ALL_POINTS', + url: ApiTable.getProjectPoints.replace('{projectId}', projectId), + msg: { option: '获取结构物所有点位' }, + reducer: { name: 'projectAllPoints' } + }); +} + export function getDeployPoints(pictureId) { return (dispatch) => basicAction({ type: 'get', diff --git a/web/client/src/sections/projectRegime/containers/pointDeploy/default.js b/web/client/src/sections/projectRegime/containers/pointDeploy/default.js index fa3f90f..71bb257 100644 --- a/web/client/src/sections/projectRegime/containers/pointDeploy/default.js +++ b/web/client/src/sections/projectRegime/containers/pointDeploy/default.js @@ -12,7 +12,7 @@ const Search = Input.Search; const TreeNode = Tree.TreeNode; import StationSpot from '../../components/pointDeploy/station-spot'; import './deploy-style.less'; -import { getProjectGraph, deleteGraph, getDeployPoints, setDeployPoints } from '../../actions/graph'; +import { getProjectGraph, deleteGraph, getProjectPoints, getDeployPoints, setDeployPoints } from '../../actions/graph'; import UploadImgModal from './upload-img-modal'; import PerfectScrollbar from 'perfect-scrollbar'; @@ -39,6 +39,7 @@ class ConfigPlanarGraph extends Component { } componentDidMount() { + this.props.dispatch(getProjectPoints(this.projectId));//获取所有点位列表 this.getData(); } @@ -48,27 +49,26 @@ class ConfigPlanarGraph extends Component { let graph = _.payload.data; if (graph) {//有图片 this.props.dispatch(getDeployPoints(graph.id));//获取平面图点位分布 - } else { - this.setSpotsState([]); } } }); } componentWillReceiveProps(nextProps) { - const { projectDeployPoints } = nextProps; + const { allPoints, projectDeployPoints } = nextProps; if (projectDeployPoints && projectDeployPoints != this.props.projectDeployPoints) { - this.setSpotsState(projectDeployPoints); + this.setSpotsState(allPoints, projectDeployPoints); } } - setSpotsState = (projectDeployPoints) => { + setSpotsState = (allPoints, projectDeployPoints) => { + const { searchValue } = this.state; let deployedSpotsMap = new Map(); - projectDeployPoints.setedPoints?.forEach(s => { + projectDeployPoints?.forEach(s => { deployedSpotsMap.set(s.pointId, s); }); let tempData = []; - projectDeployPoints.allPoints?.map(m => { + allPoints?.map(m => { let x = null, y = null, screenH = null, screenW = null; let deployed = false; let station = deployedSpotsMap.get(m.id); @@ -92,9 +92,15 @@ class ConfigPlanarGraph extends Component { deployed: deployed, }) }); + + let searchSpots = tempData; + if (searchValue.trim().length > 0) { + searchSpots = tempData.filter(s => s.location.indexOf(searchValue) >= 0); + } + this.setState({ spots: tempData, - filteredSpots: tempData, + filteredSpots: searchSpots, }); } @@ -296,7 +302,7 @@ class ConfigPlanarGraph extends Component { }; render() { - const { pictureInfo, clientHeight, clientWidth } = this.props; + const { pictureInfo, clientHeight, clientWidth, allPoints } = this.props; const { deployState, spots, filteredSpots, dataHasChanged } = this.state; const treeDataSource = this.formatTreeSource(filteredSpots); let h = clientHeight / 1.3; @@ -336,7 +342,7 @@ class ConfigPlanarGraph extends Component { onRemoveSpot={this.onRemoveSpot} onDeploySpot={this.onDeploySpot} /> - :
+ :
暂无热点图
} @@ -351,6 +357,7 @@ class ConfigPlanarGraph extends Component { onConfirm={() => { this.props.dispatch(deleteGraph(pictureInfo.id)).then(_ => { this.getData(); + this.setSpotsState(allPoints, []) }) }}> @@ -372,12 +379,13 @@ class ConfigPlanarGraph extends Component { } } function mapStateToProps(state) { - const { global, projectGraph, projectDeployPoints } = state; + const { global, projectGraph, projectDeployPoints, projectAllPoints } = state; return { pictureInfo: projectGraph.data, - projectDeployPoints: projectDeployPoints.data, + projectDeployPoints: projectDeployPoints?.data || [], clientHeight: global.clientHeight, - clientWidth: global.clientWidth + clientWidth: global.clientWidth, + allPoints: projectAllPoints?.data || [] }; } diff --git a/web/client/src/utils/webapi.js b/web/client/src/utils/webapi.js index bcf1c7e..b33e6ab 100644 --- a/web/client/src/utils/webapi.js +++ b/web/client/src/utils/webapi.js @@ -64,7 +64,7 @@ export const ApiTable = { delCheckTask: '/delcheckTask/:id', addPatrolRecordIssueHandle: 'patrolRecord/issue/handle', modifyPatrolRecordIssueHandle: 'patrolRecord/issue/handle/{id}', - yujingguanli:'/yujingguanli', + yujingguanli: '/yujingguanli', //协调申请 getCoordinateList: 'risk/coordinate', @@ -135,6 +135,7 @@ export const ApiTable = { createGraph: 'planarGraph/add', updateGraph: 'planarGraph/{id}/modify', deleteGraph: 'project/graph/{id}', + getProjectPoints: 'project/{projectId}/all/points', getDeployPoints: 'picture/{pictureId}/deploy/points', setDeployPoints: 'set/picture/{pictureId}/deploy/points', };