Browse Source

Merge branch 'master' of https://gitea.anxinyun.cn/free-sun/Inspection into master

master
dengyinhuan 2 years ago
parent
commit
a1d3f7f420
  1. 3
      api/app/lib/controllers/auth/index.js
  2. 34
      api/app/lib/controllers/pointDeploy/index.js
  3. 3
      api/app/lib/routes/pointDeploy/index.js
  4. 11
      web/client/src/sections/projectRegime/actions/graph.js
  5. 36
      web/client/src/sections/projectRegime/containers/pointDeploy/default.js
  6. 3
      web/client/src/utils/webapi.js

3
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));

34
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
};

3
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);

11
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',

36
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}
/>
: <div style={{ border: '1px dashed #999', width: w, height: h, paddingTop: clientHeight * 0.4, textAlign: 'center' }}>
: <div style={{ border: '1px dashed #999', width: w, height: h, paddingTop: h * 0.45, textAlign: 'center' }}>
暂无热点图
</div>
}
@ -351,6 +357,7 @@ class ConfigPlanarGraph extends Component {
onConfirm={() => {
this.props.dispatch(deleteGraph(pictureInfo.id)).then(_ => {
this.getData();
this.setSpotsState(allPoints, [])
})
}}>
<Button className='graph-cfg-btn'>删除图片</Button>
@ -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 || []
};
}

3
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',
};

Loading…
Cancel
Save