wenlele
1 year ago
21 changed files with 1616 additions and 579 deletions
@ -0,0 +1,238 @@ |
|||
'use strict' |
|||
const moment = require('moment') |
|||
const { QueryTypes } = require('sequelize'); |
|||
const Hex = require('crypto-js/enc-hex'); |
|||
const MD5 = require('crypto-js/md5'); |
|||
|
|||
let axyTokenCache = { |
|||
token: null, |
|||
orgId: null, |
|||
expireTime: null, //过期时间
|
|||
} |
|||
|
|||
async function getAnxinyunToken (ctx) { |
|||
try { |
|||
if (!axyTokenCache.token || moment() > moment(axyTokenCache.expireTime)) { |
|||
if (ctx.app.fs.opts.axyProject.split('/').length === 3) { |
|||
const dataToAxy = { |
|||
domain: ctx.app.fs.opts.axyProject.split('/')[0], |
|||
username: ctx.app.fs.opts.axyProject.split('/')[1], |
|||
password: ctx.app.fs.opts.axyProject.split('/')[2], |
|||
} |
|||
const axyResponse = await ctx.app.fs.anxinyun.post('login', { data: dataToAxy }) |
|||
if (axyResponse.authorized) { |
|||
axyTokenCache.token = axyResponse.token //放进缓存
|
|||
axyTokenCache.orgId = axyResponse.orgId //放进缓存
|
|||
axyTokenCache.expireTime = moment().add(1, 'hour').format('YYYY-MM-DD HH:mm:ss') |
|||
} |
|||
} |
|||
} |
|||
return axyTokenCache |
|||
} catch (error) { |
|||
ctx.fs.logger.error(`sechedule: laborAttendance, error: ${error}`) |
|||
} |
|||
} |
|||
//调用安心云结构物接口
|
|||
async function findAnxinyunProject (ctx, next) { |
|||
try { |
|||
let { type, url, params = {} } = ctx.request.body |
|||
let data = await getAnxinyunToken(ctx) |
|||
if (url && url.indexOf('{orgId}') != -1) { |
|||
url = url.replace(`{orgId}`, data.orgId) |
|||
} |
|||
const res = await ctx.app.fs.anxinyun[type](`${url}?token=${data.token}`, { |
|||
data: params.data || {}, |
|||
query: params.query || {}, |
|||
}) |
|||
ctx.status = 200 |
|||
ctx.body = res |
|||
} catch (error) { |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`) |
|||
ctx.status = 400 |
|||
ctx.body = { |
|||
message: '查询安心云项目失败', |
|||
} |
|||
} |
|||
} |
|||
async function addorEditRelation (ctx, next) { |
|||
let err = '' |
|||
const { axyProjectId, structrueId, id } = ctx.request.body |
|||
try { |
|||
const models = ctx.fs.dc.models |
|||
//编辑
|
|||
if (id) { |
|||
const res = await models.ProjectBind.findOne({ where: { id, axyProjectId, structureId: structrueId } }) |
|||
if (res) { |
|||
err = '所选安心云结构物和巡检结构物重复!!!' |
|||
throw '所选安心云结构物和巡检结构物重复!!!' |
|||
} |
|||
await models.ProjectBind.update({ axyProjectId, structureId: structrueId }, { where: { id } }) |
|||
|
|||
ctx.status = 204 |
|||
ctx.body = { |
|||
message: '编辑成功!!', |
|||
} |
|||
} else { |
|||
//新增
|
|||
const res = await models.ProjectBind.findOne({ where: { axyProjectId, structureId: structrueId } }) |
|||
if (res) { |
|||
err = '所选安心云结构物和巡检结构物重复!!!' |
|||
throw '所选安心云结构物和巡检结构物重复!!!' |
|||
} |
|||
await models.ProjectBind.create({ axyProjectId, structureId: structrueId }) |
|||
ctx.status = 204 |
|||
ctx.body = { |
|||
message: '新增成功!!', |
|||
} |
|||
} |
|||
} catch (error) { |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`) |
|||
ctx.status = 400 |
|||
ctx.body = { |
|||
message: err ? err : id ? '编辑失败' : '新增失败', |
|||
} |
|||
} |
|||
} |
|||
|
|||
async function getRelationList (ctx, next) { |
|||
try { |
|||
const models = ctx.fs.dc.models |
|||
const { limit, page, startTime, endTime } = ctx.query |
|||
let options = { |
|||
where: {}, |
|||
} |
|||
if (limit) { |
|||
options.limit = Number(limit) |
|||
} |
|||
if (page && limit) { |
|||
options.offset = Number(page) * Number(limit) |
|||
} |
|||
if (startTime && endTime) { |
|||
options.where.inspectTm = { $between: [startTime, endTime] } |
|||
} |
|||
const res = await models.ProjectBind.findAndCountAll(options) |
|||
ctx.body = res |
|||
ctx.status = 200 |
|||
} catch (error) { |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`) |
|||
ctx.status = 400 |
|||
ctx.body = { |
|||
message: '查询关联关系列表失败', |
|||
} |
|||
} |
|||
} |
|||
|
|||
async function deleteRelation (ctx, next) { |
|||
const { id } = ctx.params |
|||
try { |
|||
const models = ctx.fs.dc.models |
|||
const res = await models.ProjectBind.findOne({ where: { id: Number(id) } }) |
|||
if (!res) { |
|||
throw 'id不存在' |
|||
} |
|||
await models.ProjectBind.destroy({ where: { id: Number(id) } }) |
|||
ctx.status = 200 |
|||
} catch (error) { |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`) |
|||
ctx.status = 400 |
|||
ctx.body = { |
|||
message: '关联关系列表失败', |
|||
} |
|||
} |
|||
} |
|||
|
|||
async function getProjectType (ctx, next) { |
|||
try { |
|||
const models = ctx.fs.dc.models |
|||
const sequelize = ctx.fs.dc.orm; |
|||
const { } = ctx.query |
|||
|
|||
const res = await sequelize.query(`select distinct type from project`, { type: QueryTypes.SELECT }); |
|||
ctx.body = res |
|||
ctx.status = 200 |
|||
} catch (error) { |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`) |
|||
ctx.status = 400 |
|||
ctx.body = { |
|||
message: '获取项目类型失败', |
|||
} |
|||
} |
|||
} |
|||
|
|||
async function getProjectPublishList (ctx, next) { |
|||
try { |
|||
const models = ctx.fs.dc.models |
|||
const { limit, page } = ctx.query |
|||
let options = { |
|||
where: {}, |
|||
} |
|||
if (limit) { |
|||
options.limit = Number(limit) |
|||
} |
|||
if (page && limit) { |
|||
options.offset = Number(page) * Number(limit) |
|||
} |
|||
|
|||
const res = await models.ProjectUser.findAndCountAll(options) |
|||
ctx.body = res |
|||
ctx.status = 200 |
|||
} catch (error) { |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`) |
|||
ctx.status = 400 |
|||
ctx.body = { |
|||
message: '获取项目发布列表失败', |
|||
} |
|||
} |
|||
} |
|||
|
|||
async function postProjectPublish (ctx, next) { |
|||
let message = '新增项目失败' |
|||
try { |
|||
const models = ctx.fs.dc.models |
|||
const data = ctx.request.body |
|||
const { id, password } = data |
|||
|
|||
if (id) { |
|||
message = '修改项目失败' |
|||
await models.ProjectUser.update(data, { where: { id } }) |
|||
} else { |
|||
let passwords = Hex.stringify(MD5(password)); |
|||
await models.ProjectUser.create({ ...data, password: passwords, del: false }) |
|||
} |
|||
ctx.status = 204 |
|||
} catch (error) { |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`) |
|||
ctx.status = 400 |
|||
ctx.body = { |
|||
message: message |
|||
} |
|||
} |
|||
} |
|||
|
|||
async function delProjectPublish (ctx, next) { |
|||
try { |
|||
const models = ctx.fs.dc.models |
|||
const { id } = ctx.params |
|||
|
|||
await models.ProjectUser.destroy({ where: { id } }) |
|||
|
|||
ctx.status = 204 |
|||
} catch (error) { |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`) |
|||
ctx.status = 400 |
|||
ctx.body = { |
|||
message: '删除项目失败' |
|||
} |
|||
} |
|||
} |
|||
|
|||
module.exports = { |
|||
findAnxinyunProject, |
|||
addorEditRelation, |
|||
getRelationList, |
|||
deleteRelation, |
|||
getProjectType, |
|||
getProjectPublishList, |
|||
postProjectPublish, |
|||
delProjectPublish |
|||
} |
@ -0,0 +1,105 @@ |
|||
/* eslint-disable*/ |
|||
'use strict'; |
|||
|
|||
module.exports = dc => { |
|||
const DataTypes = dc.ORM; |
|||
const sequelize = dc.orm; |
|||
const ProjectUser = sequelize.define("projectUser", { |
|||
id: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: true, |
|||
field: "id", |
|||
autoIncrement: true |
|||
}, |
|||
projectName: { |
|||
type: DataTypes.STRING, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: '项目名称', |
|||
primaryKey: false, |
|||
field: "project_name", |
|||
autoIncrement: false |
|||
}, |
|||
projectDescribe: { |
|||
type: DataTypes.STRING, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: "项目描述", |
|||
primaryKey: false, |
|||
field: "project_describe", |
|||
autoIncrement: false |
|||
}, |
|||
projectType: { |
|||
type: DataTypes.STRING, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: '项目类型', |
|||
primaryKey: false, |
|||
field: "project_type", |
|||
autoIncrement: false |
|||
}, |
|||
monitorObject: { |
|||
type: DataTypes.ARRAY(DataTypes.INTEGER), |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: "监测对象", |
|||
primaryKey: false, |
|||
field: "monitor_object", |
|||
autoIncrement: false |
|||
}, |
|||
account: { |
|||
type: DataTypes.STRING, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: '发布账号', |
|||
primaryKey: false, |
|||
field: "account", |
|||
autoIncrement: false |
|||
}, |
|||
password: { |
|||
type: DataTypes.STRING, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: "发布密码", |
|||
primaryKey: false, |
|||
field: "password", |
|||
autoIncrement: false |
|||
}, |
|||
createTime: { |
|||
type: DataTypes.STRING, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: '创建时间', |
|||
primaryKey: false, |
|||
field: "create_time", |
|||
autoIncrement: false |
|||
}, |
|||
code: { |
|||
type: DataTypes.STRING, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: "p", |
|||
primaryKey: false, |
|||
field: "code", |
|||
autoIncrement: false |
|||
}, |
|||
del: { |
|||
type: DataTypes.BOOLEAN, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: "", |
|||
primaryKey: false, |
|||
field: "del", |
|||
autoIncrement: false |
|||
} |
|||
}, { |
|||
tableName: "project_user", |
|||
comment: "", |
|||
indexes: [] |
|||
}); |
|||
dc.models.ProjectUser = ProjectUser; |
|||
return ProjectUser; |
|||
}; |
@ -0,0 +1,43 @@ |
|||
/* eslint-disable*/ |
|||
'use strict'; |
|||
|
|||
module.exports = dc => { |
|||
const DataTypes = dc.ORM; |
|||
const sequelize = dc.orm; |
|||
const ProjectUserToken = sequelize.define("projectUserToken", { |
|||
token: { |
|||
type: DataTypes.UUIDV4, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: true, |
|||
field: "token", |
|||
autoIncrement: false, |
|||
unique: "project_user_token_uindex" |
|||
}, |
|||
projectUserInfo: { |
|||
type: DataTypes.JSONB, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: false, |
|||
field: "project_user_info", |
|||
autoIncrement: false |
|||
}, |
|||
expired: { |
|||
type: DataTypes.DATE, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: false, |
|||
field: "expired", |
|||
autoIncrement: false |
|||
} |
|||
}, { |
|||
tableName: "project_user_token", |
|||
comment: "", |
|||
indexes: [] |
|||
}); |
|||
dc.models.ProjectUserToken = ProjectUserToken; |
|||
return ProjectUserToken; |
|||
}; |
@ -1,19 +0,0 @@ |
|||
'use strict'; |
|||
|
|||
const projectBind = require('../../controllers/projectBind/projectBind'); |
|||
|
|||
module.exports = function (app, router, opts) { |
|||
|
|||
app.fs.api.logAttr['POST/anxinyun/project/list'] = { content: '获取安心云项目列表', visible: false } |
|||
router.post('/anxinyun/project/list', projectBind.findAnxinyunProject) |
|||
|
|||
app.fs.api.logAttr['POST/anxinyun/project/relation'] = { content: '新增或编辑项目映射关系', visible: false } |
|||
router.post('/anxinyun/project/relation', projectBind.addorEditRelation) |
|||
|
|||
app.fs.api.logAttr['GET/anxinyun/project/relation/list'] = { content: '获取项目映射关系列表', visible: false } |
|||
router.get('/anxinyun/project/relation/list', projectBind.getRelationList) |
|||
|
|||
app.fs.api.logAttr['DELETE/anxinyun/project/relation/:id'] = { content: '删除项目映射关系', visible: false } |
|||
router.delete('/anxinyun/project/relation/:id', projectBind.deleteRelation) |
|||
|
|||
} |
@ -0,0 +1,33 @@ |
|||
'use strict'; |
|||
|
|||
const projectBind = require('../../controllers/projectManagement/projectBind'); |
|||
const projectPublish = require('../../controllers/projectManagement/projectPublish'); |
|||
|
|||
module.exports = function (app, router, opts) { |
|||
|
|||
app.fs.api.logAttr['POST/anxinyun/project/list'] = { content: '获取安心云项目列表', visible: false } |
|||
router.post('/anxinyun/project/list', projectBind.findAnxinyunProject) |
|||
|
|||
app.fs.api.logAttr['POST/anxinyun/project/relation'] = { content: '新增或编辑项目映射关系', visible: false } |
|||
router.post('/anxinyun/project/relation', projectBind.addorEditRelation) |
|||
|
|||
app.fs.api.logAttr['GET/anxinyun/project/relation/list'] = { content: '获取项目映射关系列表', visible: false } |
|||
router.get('/anxinyun/project/relation/list', projectBind.getRelationList) |
|||
|
|||
app.fs.api.logAttr['DELETE/anxinyun/project/relation/:id'] = { content: '删除项目映射关系', visible: false } |
|||
router.delete('/anxinyun/project/relation/:id', projectBind.deleteRelation) |
|||
|
|||
app.fs.api.logAttr['GET/project/type'] = { content: '获取项目类型', visible: false } |
|||
router.get('/project/type', projectPublish.getProjectType) |
|||
|
|||
app.fs.api.logAttr['GET/project/publish/list'] = { content: '获取项目发布列表', visible: false } |
|||
router.get('/project/publish/list', projectPublish.getProjectPublishList) |
|||
|
|||
app.fs.api.logAttr['POST/project/publish/list'] = { content: '新增或编辑项目', visible: false } |
|||
router.post('/project/publish/list', projectPublish.postProjectPublish) |
|||
|
|||
app.fs.api.logAttr['DEL/project/publish/:id'] = { content: '删除项目', visible: false } |
|||
router.del('/project/publish/:id', projectPublish.delProjectPublish) |
|||
|
|||
|
|||
} |
@ -0,0 +1,46 @@ |
|||
create table project_user |
|||
( |
|||
id serial not null, |
|||
project_name varchar(128) not null, |
|||
project_describe varchar, |
|||
project_type varchar(128) not null, |
|||
monitor_object integer[] not null, |
|||
account varchar(128) not null, |
|||
password varchar(128) not null, |
|||
create_time timestamp not null, |
|||
code varchar(128) not null, |
|||
del boolean not null |
|||
); |
|||
|
|||
comment on table project_user is '发布项目'; |
|||
|
|||
comment on column project_user.project_name is '项目名称'; |
|||
|
|||
comment on column project_user.project_describe is '项目描述'; |
|||
|
|||
comment on column project_user.project_type is '项目类型'; |
|||
|
|||
comment on column project_user.monitor_object is '监测对象'; |
|||
|
|||
comment on column project_user.account is '发布账号'; |
|||
|
|||
comment on column project_user.password is '发布密码'; |
|||
|
|||
comment on column project_user.create_time is '创建时间'; |
|||
|
|||
comment on column project_user.code is 'p'; |
|||
|
|||
create unique index project_user_id_uindex |
|||
on project_user (id); |
|||
|
|||
alter table project_user |
|||
add constraint project_user_pk |
|||
primary key (id); |
|||
|
|||
|
|||
create table project_user_token |
|||
( |
|||
token uuid not null, |
|||
project_user_info jsonb not null, |
|||
expired timestamp not null |
|||
); |
@ -1,52 +1,53 @@ |
|||
'use strict'; |
|||
import Immutable from 'immutable'; |
|||
import { INIT_LAYOUT, RESIZE } from '../actions/global'; |
|||
import { INIT_LAYOUT, RESIZE, INIT_API_ROOT } from '../actions/global'; |
|||
import { SET_GLOBAL_SITE_LIST, CLEAR_GLOBAL_SITE_LIST } from '../actions/site' |
|||
function global(state = { |
|||
title: '', |
|||
copyright: '', |
|||
sections: [], |
|||
actions: {}, |
|||
plugins: {}, |
|||
clientHeight: 768, |
|||
clientWidth: 1024, |
|||
sites: [] |
|||
function global (state = { |
|||
title: '', |
|||
copyright: '', |
|||
sections: [], |
|||
actions: {}, |
|||
plugins: {}, |
|||
clientHeight: 768, |
|||
clientWidth: 1024, |
|||
sites: [], |
|||
webScreen: '' |
|||
}, action) { |
|||
const payload = action.payload; |
|||
switch (action.type) { |
|||
case RESIZE: |
|||
return Immutable.fromJS(state).merge({ |
|||
clientHeight: payload.clientHeight, |
|||
clientWidth: payload.clientWidth |
|||
}).toJS(); |
|||
case INIT_LAYOUT: |
|||
return { |
|||
title: payload.title, |
|||
copyright: payload.copyright, |
|||
sections: payload.sections, |
|||
actions: payload.actions, |
|||
plugins: payload.plugins, |
|||
clientHeight: state.clientHeight, |
|||
detailsComponent: null, |
|||
sites: [] |
|||
}; |
|||
// case INIT_RESOURCE_ROOT:
|
|||
// return Immutable.fromJS(state).merge(payload).toJS();
|
|||
// case INIT_PAGE_HEADER_DETAILS:
|
|||
// return Immutable.fromJS(state).merge({
|
|||
// detailsComponent: payload.component
|
|||
// }).toJS();
|
|||
case SET_GLOBAL_SITE_LIST: |
|||
return Immutable.fromJS(state).merge({ |
|||
sites: payload.data |
|||
}).toJS(); |
|||
case CLEAR_GLOBAL_SITE_LIST: |
|||
return Immutable.fromJS(state).merge({ |
|||
sites: [] |
|||
}).toJS(); |
|||
default: |
|||
return state; |
|||
} |
|||
const payload = action.payload; |
|||
switch (action.type) { |
|||
case RESIZE: |
|||
return Immutable.fromJS(state).merge({ |
|||
clientHeight: payload.clientHeight, |
|||
clientWidth: payload.clientWidth |
|||
}).toJS(); |
|||
case INIT_LAYOUT: |
|||
return { |
|||
title: payload.title, |
|||
copyright: payload.copyright, |
|||
sections: payload.sections, |
|||
actions: payload.actions, |
|||
plugins: payload.plugins, |
|||
clientHeight: state.clientHeight, |
|||
detailsComponent: null, |
|||
sites: [], |
|||
}; |
|||
case INIT_API_ROOT: |
|||
return Immutable.fromJS(state).merge(payload).toJS(); |
|||
// case INIT_PAGE_HEADER_DETAILS:
|
|||
// return Immutable.fromJS(state).merge({
|
|||
// detailsComponent: payload.component
|
|||
// }).toJS();
|
|||
case SET_GLOBAL_SITE_LIST: |
|||
return Immutable.fromJS(state).merge({ |
|||
sites: payload.data |
|||
}).toJS(); |
|||
case CLEAR_GLOBAL_SITE_LIST: |
|||
return Immutable.fromJS(state).merge({ |
|||
sites: [] |
|||
}).toJS(); |
|||
default: |
|||
return state; |
|||
} |
|||
} |
|||
|
|||
export default global; |
@ -1,6 +1,8 @@ |
|||
|
|||
'use strict'; |
|||
import projectBinding from './projectBinding' |
|||
import projectPublish from './projectPublish' |
|||
export default { |
|||
...projectBinding |
|||
...projectBinding, |
|||
...projectPublish |
|||
} |
@ -0,0 +1,71 @@ |
|||
'use strict'; |
|||
import { basicAction } from '@peace/utils' |
|||
import { ApiTable } from '$utils' |
|||
|
|||
export function getProjectType () { |
|||
return dispatch => basicAction({ |
|||
type: 'get', |
|||
dispatch: dispatch, |
|||
actionType: 'GET_PORJECT_TYPE', |
|||
url: `${ApiTable.projectType}`, |
|||
msg: { error: '获取项目类型失败' }, |
|||
reducer: { name: 'projectType' } |
|||
}); |
|||
} |
|||
|
|||
export function getProjectPublishList (query = {}) { |
|||
return dispatch => basicAction({ |
|||
type: 'get', |
|||
query, |
|||
dispatch: dispatch, |
|||
actionType: 'GET_PROJECT_PUBLISH_LIST', |
|||
url: `${ApiTable.projectPublishList}`, |
|||
msg: { error: '获取项目发布列表失败' }, |
|||
reducer: { name: 'publishList' } |
|||
}); |
|||
} |
|||
|
|||
export function postProjectPublish (data = {}) { |
|||
return dispatch => basicAction({ |
|||
type: 'post', |
|||
dispatch: dispatch, |
|||
data, |
|||
actionType: 'POST_PROJECT_PUBLISH', |
|||
url: `${ApiTable.projectPublishList}`, |
|||
msg: { option: data?.isCode ? '修改地址' : data?.id ? "编辑项目" : '新增项目' }, |
|||
reducer: { name: 'anxinyunProject' } |
|||
}); |
|||
} |
|||
|
|||
|
|||
// export function addorEditRelation(data) {
|
|||
// return dispatch => basicAction({
|
|||
// type: 'post',
|
|||
// dispatch: dispatch,
|
|||
// data,
|
|||
// actionType: 'ADD_OR_EDIT_RELATION',
|
|||
// url: `${ApiTable.addorEditRelation}`,
|
|||
// msg: { option:data?.id? '编辑绑定关系':'新增绑定关系' },
|
|||
// // reducer: { name: 'anxinyunProject'}
|
|||
// });
|
|||
// }
|
|||
|
|||
|
|||
|
|||
export function delProjectPublish (id) { |
|||
return dispatch => basicAction({ |
|||
type: 'del', |
|||
dispatch: dispatch, |
|||
actionType: 'DEL_RELATION', |
|||
url: ApiTable.delProjectPublish.replace('{id}', id), |
|||
msg: { option: '删除项目' }, |
|||
}); |
|||
} |
|||
|
|||
|
|||
export default { |
|||
getProjectType, |
|||
getProjectPublishList, |
|||
postProjectPublish, |
|||
delProjectPublish |
|||
} |
@ -0,0 +1,128 @@ |
|||
import React, { useState, useEffect } from 'react'; |
|||
import { connect } from 'react-redux'; |
|||
import { v4 } from 'uuid'; |
|||
import moment from 'moment'; |
|||
import { Form, Input, Modal, Select, Row, Col, message } from 'antd'; |
|||
const { TextArea } = Input; |
|||
|
|||
|
|||
const ProjectModel = ({ dispatch, actions, user, modelData, close, success, projectType, strucList }) => { |
|||
|
|||
const { projectManagement, projectRegime } = actions |
|||
const [showBaiduMap, setShowBaiduMap] = useState(false) |
|||
const [strucData, setStrucData] = useState([]) |
|||
|
|||
const [form] = Form.useForm(); |
|||
|
|||
useEffect(() => { |
|||
if (modelData?.id) { |
|||
setStrucData(strucList?.filter(s => s.type == modelData?.projectType) || []) |
|||
} |
|||
}, []) |
|||
|
|||
|
|||
return ( |
|||
<Modal |
|||
// className="global-modal"
|
|||
title={modelData?.id ? '修改项目' : '新增项目'} |
|||
width={600} |
|||
open={true} |
|||
onOk={() => { |
|||
form.validateFields().then(v => { |
|||
if (modelData?.id || v.password == v.confirmPassword) { |
|||
dispatch(projectManagement.postProjectPublish({ |
|||
...v, |
|||
id: modelData?.id, |
|||
createTime: moment(modelData?.createTime).format('YYYY-MM-DD HH:mm:ss'), |
|||
code: modelData?.code || v4() |
|||
})).then(res => { |
|||
if (res.success) { |
|||
success() |
|||
} |
|||
}) |
|||
} else { |
|||
message.warning('两次输入的密码不一致'); |
|||
} |
|||
|
|||
}) |
|||
}} |
|||
onCancel={() => close()} |
|||
> |
|||
<Form |
|||
style={{}} |
|||
form={form} |
|||
labelAlign='right' |
|||
labelCol={{ span: 4 }} wrapperCol={{ span: 18 }} |
|||
onFinish={r => { |
|||
}} |
|||
> |
|||
<Form.Item label='项目名称' name='projectName' initialValue={modelData?.projectName} |
|||
rules={[{ required: true, message: '请输入项目名称' },]} |
|||
> |
|||
<Input style={{ width: 210 }} placeholder='请输入项目名称' /> |
|||
</Form.Item> |
|||
<Form.Item name='projectDescribe' label="项目描述" initialValue={modelData?.projectDescribe} |
|||
rules={[{ required: true, message: '请输入项目描述' },]} |
|||
> |
|||
<TextArea placeholder='请输入项目描述' style={{ width: 360 }} /> |
|||
</Form.Item> |
|||
<Form.Item label='项目类型' name="projectType" |
|||
initialValue={modelData?.projectType} |
|||
rules={[{ required: true, message: '请选择项目类型' },]} |
|||
> |
|||
<Select allowClear options={projectType?.map(d => ({ value: d.type, label: d.type })) || []} style={{ width: 254 }} placeholder='请选择项目类型' |
|||
onSelect={d => { |
|||
form.setFieldValue('monitorObject', []) |
|||
setStrucData(strucList?.filter(s => s.type == d) || []) |
|||
}} |
|||
/> |
|||
</Form.Item> |
|||
|
|||
<Form.Item label='监测对象' name="monitorObject" |
|||
initialValue={modelData?.monitorObject || []} |
|||
rules={[{ required: true, message: '请选择监测对象' },]} |
|||
> |
|||
<Select allowClear options={strucData?.map(d => ({ value: d.id, label: d.name })) || []} style={{ width: 254 }} mode='multiple' placeholder='请选择监测对象' |
|||
/> |
|||
</Form.Item> |
|||
|
|||
<Form.Item label='发布账号' name='account' initialValue={modelData?.account} |
|||
rules={[{ required: true, message: '请输入发布账号' },]} |
|||
> |
|||
<Input style={{ width: 150 }} placeholder='请输入发布账号' /> |
|||
</Form.Item> |
|||
|
|||
{!modelData?.id && |
|||
<> |
|||
<Form.Item label='发布密码' name='password' initialValue={modelData?.password} |
|||
rules={[{ required: true, message: '请输入发布密码' },]} |
|||
> |
|||
<Input.Password autocomplete='new-password' onPaste={e => { |
|||
e.preventDefault(); |
|||
}} style={{ width: 150 }} placeholder='请输入发布密码' /> |
|||
</Form.Item> |
|||
<Form.Item label='确认密码' name='confirmPassword' initialValue={modelData?.confirmPassword} |
|||
rules={[{ required: true, message: '请输入确认密码' },]} |
|||
> |
|||
<Input.Password autocomplete='new-password' style={{ width: 150 }} placeholder='请输入确认密码' /> |
|||
</Form.Item> |
|||
</> |
|||
} |
|||
|
|||
</Form> |
|||
</Modal> |
|||
|
|||
); |
|||
}; |
|||
|
|||
|
|||
function mapStateToProps (state) { |
|||
const { auth, global, projectType } = state; |
|||
return { |
|||
user: auth.user, |
|||
actions: global.actions, |
|||
projectType: projectType?.data || [], |
|||
}; |
|||
} |
|||
|
|||
export default connect(mapStateToProps)(ProjectModel); |
@ -1,110 +1,110 @@ |
|||
{ |
|||
"name": "fs-anxincloud-4.0", |
|||
"version": "1.0.0", |
|||
"description": "anxincloud-4.0", |
|||
"main": "server.js", |
|||
"scripts": { |
|||
"test": "mocha", |
|||
"start": "cross-env NODE_ENV=development npm run start-params", |
|||
"start-params": "node server -p 5900 -u http://127.0.0.1:4900 --qnak 5XrM4wEB9YU6RQwT64sPzzE6cYFKZgssdP5Kj3uu --qnsk w6j2ixR_i-aelc6I7S3HotKIX-ukMzcKmDfH6-M5 --qnbkt anxinyun-test --qndmn http://test.resources.anxinyun.cn --aliOssAccessKey LTAI5tNDfn7UhStYQcn3JBtw --aliOssSecretKey rnoXtDWQA1djJ5Xqcdn1OSEol0lVyv --aliOssBucket test-c371 --aliOssRegion oss-cn-hangzhou", |
|||
"deploy": "export NODE_ENV=production && 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" |
|||
}, |
|||
"keywords": [ |
|||
"app" |
|||
], |
|||
"author": "", |
|||
"license": "ISC", |
|||
"devDependencies": { |
|||
"@babel/core": "^7.14.6", |
|||
"@babel/plugin-proposal-class-properties": "^7.14.5", |
|||
"@babel/plugin-proposal-object-rest-spread": "^7.14.7", |
|||
"@babel/plugin-transform-runtime": "^7.14.5", |
|||
"@babel/polyfill": "^7.12.1", |
|||
"@babel/preset-env": "^7.14.7", |
|||
"@babel/preset-react": "^7.14.5", |
|||
"babel-loader": "^8.2.2", |
|||
"babel-polyfill": "^6.26.0", |
|||
"babel-plugin-import": "^1.13.3", |
|||
"connected-react-router": "^6.8.0", |
|||
"css-loader": "^3.5.0", |
|||
"express": "^4.17.1", |
|||
"file-loader": "^6.0.0", |
|||
"html-webpack-plugin": "^4.5.0", |
|||
"immutable": "^4.0.0-rc.12", |
|||
"less": "^3.12.2", |
|||
"less-loader": "^7.0.2", |
|||
"natty-fetch": "^2.5.3", |
|||
"nprogress": "^0.2.0", |
|||
"path": "^0.12.7", |
|||
"path-to-regexp": "^2.4.0", |
|||
"perfect-scrollbar": "^1.5.0", |
|||
"react": "^17.0.0", |
|||
"react-copy-to-clipboard": "^5.0.1", |
|||
"react-dnd": "^10.0.2", |
|||
"react-dnd-html5-backend": "^10.0.2", |
|||
"react-dom": "^17.0.0", |
|||
"react-if": "^2.2.1", |
|||
"react-jsonschema-form": "^1.8.1", |
|||
"react-quill": "^1.3.5", |
|||
"react-redux": "^7.2.1", |
|||
"react-router-dom": "^5.2.0", |
|||
"react-router-redux": "^4.0.8", |
|||
"redux": "^4.0.5", |
|||
"redux-thunk": "^2.3.0", |
|||
"redux-undo": "^1.0.1", |
|||
"style-loader": "^2.0.0", |
|||
"webpack": "^5.3.2", |
|||
"webpack-bundle-analyzer": "^4.1.0", |
|||
"webpack-cli": "^4.2.0", |
|||
"webpack-dev-middleware": "^4.0.2", |
|||
"webpack-hot-middleware": "^2.25.0" |
|||
}, |
|||
"dependencies": { |
|||
"@ant-design/icons": "^4.6.2", |
|||
"@ant-design/pro-form": "^1.34.0", |
|||
"@ant-design/pro-table": "^2.48.0", |
|||
"@antv/g6": "^4.2.5", |
|||
"@fs/attachment": "^1.0.0", |
|||
"@peace/components": "0.0.35", |
|||
"@peace/utils": "0.0.37", |
|||
"ahooks": "^3.7.4", |
|||
"ali-oss": "^6.17.1", |
|||
"antd": "^4.24.5", |
|||
"antd-theme-generator": "^1.2.8", |
|||
"args": "^5.0.1", |
|||
"array-move": "^3.0.1", |
|||
"bpmn-js": "^6.5.1", |
|||
"camunda-bpmn-moddle": "^4.4.0", |
|||
"canvas": "^2.11.0", |
|||
"co-busboy": "^1.4.1", |
|||
"cross-env": "^7.0.3", |
|||
"crypto-js": "^4.1.1", |
|||
"echarts": "^5.4.1", |
|||
"file-saver": "^2.0.5", |
|||
"form-data": "^3.0.0", |
|||
"fs-attachment": "^1.0.0", |
|||
"fs-web-server-scaffold": "^1.0.6", |
|||
"i": "^0.3.6", |
|||
"jszip": "^3.10.1", |
|||
"koa-better-http-proxy": "^0.2.5", |
|||
"koa-proxy": "^1.0.0-alpha.3", |
|||
"koa-view": "^2.1.4", |
|||
"mini-dynamic-antd-theme": "^0.5.3", |
|||
"moment": "^2.22.0", |
|||
"npm": "^7.20.6", |
|||
"qrcode": "^1.5.1", |
|||
"qs": "^6.10.1", |
|||
"react-dnd": "^7", |
|||
"react-dnd-html5-backend": "^7", |
|||
"react-color": "^2.19.3", |
|||
"react-router-breadcrumbs-hoc": "^4.0.1", |
|||
"react-sortable-hoc": "^2.0.0", |
|||
"shortid": "^2.2.16", |
|||
"superagent": "^6.1.0", |
|||
"uuid": "^8.3.1", |
|||
"webpack-dev-server": "^3.11.2", |
|||
"xlsx": "^0.16.9" |
|||
} |
|||
"name": "fs-anxincloud-4.0", |
|||
"version": "1.0.0", |
|||
"description": "anxincloud-4.0", |
|||
"main": "server.js", |
|||
"scripts": { |
|||
"test": "mocha", |
|||
"start": "cross-env NODE_ENV=development npm run start-params", |
|||
"start-params": "node server -p 5900 -u http://127.0.0.1:4900 --webScreen http://localhost:5800 --qnak 5XrM4wEB9YU6RQwT64sPzzE6cYFKZgssdP5Kj3uu --qnsk w6j2ixR_i-aelc6I7S3HotKIX-ukMzcKmDfH6-M5 --qnbkt anxinyun-test --qndmn http://test.resources.anxinyun.cn --aliOssAccessKey LTAI5tNDfn7UhStYQcn3JBtw --aliOssSecretKey rnoXtDWQA1djJ5Xqcdn1OSEol0lVyv --aliOssBucket test-c371 --aliOssRegion oss-cn-hangzhou", |
|||
"deploy": "export NODE_ENV=production && 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" |
|||
}, |
|||
"keywords": [ |
|||
"app" |
|||
], |
|||
"author": "", |
|||
"license": "ISC", |
|||
"devDependencies": { |
|||
"@babel/core": "^7.14.6", |
|||
"@babel/plugin-proposal-class-properties": "^7.14.5", |
|||
"@babel/plugin-proposal-object-rest-spread": "^7.14.7", |
|||
"@babel/plugin-transform-runtime": "^7.14.5", |
|||
"@babel/polyfill": "^7.12.1", |
|||
"@babel/preset-env": "^7.14.7", |
|||
"@babel/preset-react": "^7.14.5", |
|||
"babel-loader": "^8.2.2", |
|||
"babel-polyfill": "^6.26.0", |
|||
"babel-plugin-import": "^1.13.3", |
|||
"connected-react-router": "^6.8.0", |
|||
"css-loader": "^3.5.0", |
|||
"express": "^4.17.1", |
|||
"file-loader": "^6.0.0", |
|||
"html-webpack-plugin": "^4.5.0", |
|||
"immutable": "^4.0.0-rc.12", |
|||
"less": "^3.12.2", |
|||
"less-loader": "^7.0.2", |
|||
"natty-fetch": "^2.5.3", |
|||
"nprogress": "^0.2.0", |
|||
"path": "^0.12.7", |
|||
"path-to-regexp": "^2.4.0", |
|||
"perfect-scrollbar": "^1.5.0", |
|||
"react": "^17.0.0", |
|||
"react-copy-to-clipboard": "^5.0.1", |
|||
"react-dnd": "^10.0.2", |
|||
"react-dnd-html5-backend": "^10.0.2", |
|||
"react-dom": "^17.0.0", |
|||
"react-if": "^2.2.1", |
|||
"react-jsonschema-form": "^1.8.1", |
|||
"react-quill": "^1.3.5", |
|||
"react-redux": "^7.2.1", |
|||
"react-router-dom": "^5.2.0", |
|||
"react-router-redux": "^4.0.8", |
|||
"redux": "^4.0.5", |
|||
"redux-thunk": "^2.3.0", |
|||
"redux-undo": "^1.0.1", |
|||
"style-loader": "^2.0.0", |
|||
"webpack": "^5.3.2", |
|||
"webpack-bundle-analyzer": "^4.1.0", |
|||
"webpack-cli": "^4.2.0", |
|||
"webpack-dev-middleware": "^4.0.2", |
|||
"webpack-hot-middleware": "^2.25.0" |
|||
}, |
|||
"dependencies": { |
|||
"@ant-design/icons": "^4.6.2", |
|||
"@ant-design/pro-form": "^1.34.0", |
|||
"@ant-design/pro-table": "^2.48.0", |
|||
"@antv/g6": "^4.2.5", |
|||
"@fs/attachment": "^1.0.0", |
|||
"@peace/components": "0.0.35", |
|||
"@peace/utils": "0.0.37", |
|||
"ahooks": "^3.7.4", |
|||
"ali-oss": "^6.17.1", |
|||
"antd": "^4.24.5", |
|||
"antd-theme-generator": "^1.2.8", |
|||
"args": "^5.0.1", |
|||
"array-move": "^3.0.1", |
|||
"bpmn-js": "^6.5.1", |
|||
"camunda-bpmn-moddle": "^4.4.0", |
|||
"canvas": "^2.11.0", |
|||
"co-busboy": "^1.4.1", |
|||
"cross-env": "^7.0.3", |
|||
"crypto-js": "^4.1.1", |
|||
"echarts": "^5.4.1", |
|||
"file-saver": "^2.0.5", |
|||
"form-data": "^3.0.0", |
|||
"fs-attachment": "^1.0.0", |
|||
"fs-web-server-scaffold": "^1.0.6", |
|||
"i": "^0.3.6", |
|||
"jszip": "^3.10.1", |
|||
"koa-better-http-proxy": "^0.2.5", |
|||
"koa-proxy": "^1.0.0-alpha.3", |
|||
"koa-view": "^2.1.4", |
|||
"mini-dynamic-antd-theme": "^0.5.3", |
|||
"moment": "^2.22.0", |
|||
"npm": "^7.20.6", |
|||
"qrcode": "^1.5.1", |
|||
"qs": "^6.10.1", |
|||
"react-dnd": "^7", |
|||
"react-dnd-html5-backend": "^7", |
|||
"react-color": "^2.19.3", |
|||
"react-router-breadcrumbs-hoc": "^4.0.1", |
|||
"react-sortable-hoc": "^2.0.0", |
|||
"shortid": "^2.2.16", |
|||
"superagent": "^6.1.0", |
|||
"uuid": "^8.3.1", |
|||
"webpack-dev-server": "^3.11.2", |
|||
"xlsx": "^0.16.9" |
|||
} |
|||
} |
Loading…
Reference in new issue