wenlele
1 year ago
15 changed files with 1386 additions and 827 deletions
@ -0,0 +1,252 @@ |
|||
'use strict'; |
|||
const moment = require('moment'); |
|||
|
|||
async function postReportFile (ctx) { |
|||
try { |
|||
const { models } = ctx.fs.dc; |
|||
const data = ctx.request.body |
|||
|
|||
await models.ReportFile.create(data) |
|||
|
|||
ctx.status = 204; |
|||
} catch (error) { |
|||
|
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|||
ctx.status = 400; |
|||
ctx.body = { |
|||
message: typeof error == 'string' ? error : undefined |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
async function getReportFile (ctx) { |
|||
try { |
|||
const { models } = ctx.fs.dc; |
|||
const { limit, page, projectId } = ctx.query; |
|||
const { userInfo } = ctx.fs.api; |
|||
|
|||
let options = { |
|||
where: {}, |
|||
order: [['startTime', 'desc']] |
|||
} |
|||
if (limit || page) { |
|||
options.limit = Number(limit) |
|||
options.page = Number(page) * Number(limit) |
|||
} |
|||
if (projectId) { |
|||
options.where.projectId = projectId |
|||
} |
|||
|
|||
let res = await models.ReportFile.findAndCountAll(options); |
|||
|
|||
|
|||
|
|||
ctx.status = 200; |
|||
ctx.body = res |
|||
} catch (error) { |
|||
|
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|||
ctx.status = 400; |
|||
ctx.body = { |
|||
message: typeof error == 'string' ? error : undefined |
|||
} |
|||
} |
|||
} |
|||
|
|||
async function delReportFile (ctx) { |
|||
try { |
|||
const { models } = ctx.fs.dc; |
|||
const { id } = ctx.params |
|||
|
|||
await models.ReportFile.destroy({ |
|||
where: { |
|||
id: id |
|||
} |
|||
}) |
|||
|
|||
ctx.status = 204; |
|||
} catch (error) { |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|||
ctx.status = 400; |
|||
ctx.body = { |
|||
message: typeof error == 'string' ? error : undefined |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
async function getFactorList (ctx) { |
|||
try { |
|||
const { models } = ctx.fs.dc; |
|||
const { clickHouse, utils: { anxinStrucIdRange } } = ctx.app.fs |
|||
const { userInfo } = ctx.fs.api; |
|||
const { pepProjectId } = ctx.query |
|||
|
|||
|
|||
let anxinStruc = await anxinStrucIdRange({ |
|||
ctx, pepProjectId |
|||
}) |
|||
|
|||
if (anxinStruc.length) { |
|||
const anxinStrucIds = anxinStruc.map(a => a.strucId) |
|||
let factorProto = [1002, 1001, 4009, 2001, 3001, 4004, 5002, 4001, 4002, 4008, 4007, 1004] |
|||
|
|||
|
|||
const factor = anxinStrucIds.length ? await clickHouse.anxinyun.query(` |
|||
SELECT |
|||
id,name,proto, |
|||
t_structure_factor.structure AS structure |
|||
FROM t_factor |
|||
INNER JOIN t_structure_factor |
|||
ON t_structure_factor.factor = t_factor.id |
|||
AND t_structure_factor.structure IN (${anxinStrucIds.join(',')}, -1) |
|||
WHERE |
|||
t_factor.proto IN (${factorProto.join(',')}, -1) |
|||
`).toPromise() : []
|
|||
|
|||
const factorId = factor.map(a => a.id) |
|||
|
|||
const sensor = factorId.length ? await clickHouse.anxinyun.query(` |
|||
SELECT |
|||
id,name,factor |
|||
FROM t_sensor |
|||
WHERE |
|||
t_sensor.factor IN (${factorId.join(',')}, -1) |
|||
`).toPromise() : []
|
|||
|
|||
|
|||
|
|||
// WSDJC(温湿度监测) 1002
|
|||
// FSFXJC(风速风向监测) 1001
|
|||
// SSFJC(伸缩缝监测) 4009
|
|||
// SLJC(索力监测) 2001
|
|||
// YBJC(应力应变监测) 3001
|
|||
// NDJC(挠度监测) 4004
|
|||
// ZDJC(振动监测) 5002
|
|||
// CLZHJC(车辆载荷监测)
|
|||
// ZZWYJC(支座位移监测) 4001
|
|||
// QTPWJC(桥塔偏位监测) 4002
|
|||
// LFJC(裂缝监测) 4008
|
|||
// QDQXJC(桥墩倾斜监测) 4007
|
|||
// JGWDJC(结构温度监测) 1004
|
|||
|
|||
anxinStruc.forEach(s => { |
|||
s.factor = factor.filter(d => { |
|||
if (d.structure == s.strucId) { |
|||
d.sensor = sensor.filter(f => f.factor == d.id) |
|||
return true |
|||
} else { |
|||
return false |
|||
} |
|||
|
|||
}) |
|||
}) |
|||
|
|||
ctx.status = 200; |
|||
ctx.body = anxinStruc |
|||
} else { |
|||
ctx.status = 200; |
|||
ctx.body = [] |
|||
} |
|||
} catch (error) { |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|||
ctx.status = 400; |
|||
ctx.body = { |
|||
message: typeof error == 'string' ? error : undefined |
|||
} |
|||
} |
|||
} |
|||
|
|||
async function postAutomaticReport (ctx) { |
|||
try { |
|||
const { models } = ctx.fs.dc; |
|||
const data = ctx.request.body |
|||
|
|||
if (data.id) { |
|||
await models.ReportAutomatic.update(data, { |
|||
where: { |
|||
id: data.id |
|||
}}) |
|||
} else { |
|||
await models.ReportAutomatic.create(data) |
|||
} |
|||
ctx.status = 204; |
|||
} catch (error) { |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|||
ctx.status = 400; |
|||
ctx.body = { |
|||
message: typeof error == 'string' ? error : undefined |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
async function getAutomaticReport (ctx) { |
|||
try { |
|||
const { models } = ctx.fs.dc; |
|||
const { limit, page, projectId, keyword } = ctx.query; |
|||
const { userInfo } = ctx.fs.api; |
|||
|
|||
let options = { |
|||
where: {}, |
|||
order: [['time', 'desc']] |
|||
} |
|||
if (limit || page) { |
|||
options.limit = Number(limit) |
|||
options.page = Number(page) * Number(limit) |
|||
} |
|||
if (projectId) { |
|||
options.where.projectId = { $in: String(projectId).split(',') } |
|||
} |
|||
|
|||
if (keyword) { |
|||
options.where.reportName = { $iLike: `%${keyword}%` } |
|||
} |
|||
|
|||
let res = await models.ReportAutomatic.findAndCountAll(options); |
|||
|
|||
ctx.status = 200; |
|||
ctx.body = res |
|||
} catch (error) { |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|||
ctx.status = 400; |
|||
ctx.body = { |
|||
message: typeof error == 'string' ? error : undefined |
|||
} |
|||
} |
|||
} |
|||
|
|||
async function delAutomaticReport (ctx) { |
|||
try { |
|||
const { models } = ctx.fs.dc; |
|||
const { id } = ctx.params |
|||
|
|||
await models.ReportAutomatic.destroy({ |
|||
where: { |
|||
id: id |
|||
} |
|||
}) |
|||
|
|||
ctx.status = 204; |
|||
} catch (error) { |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|||
ctx.status = 400; |
|||
ctx.body = { |
|||
message: typeof error == 'string' ? error : undefined |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
module.exports = { |
|||
|
|||
getReportFile, |
|||
postReportFile, |
|||
delReportFile, |
|||
getFactorList, |
|||
postAutomaticReport, |
|||
getAutomaticReport, |
|||
delAutomaticReport |
|||
}; |
@ -0,0 +1,70 @@ |
|||
/* eslint-disable*/ |
|||
|
|||
'use strict'; |
|||
|
|||
module.exports = dc => { |
|||
const DataTypes = dc.ORM; |
|||
const sequelize = dc.orm; |
|||
const ReportFile = sequelize.define("reportFile", { |
|||
id: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: "id", |
|||
primaryKey: true, |
|||
field: "id", |
|||
autoIncrement: true |
|||
}, |
|||
projectId: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: "项目id", |
|||
primaryKey: false, |
|||
field: "project_id", |
|||
autoIncrement: false |
|||
}, |
|||
fileName: { |
|||
type: DataTypes.STRING, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: "文件名称", |
|||
primaryKey: false, |
|||
field: "file_name", |
|||
autoIncrement: false |
|||
}, |
|||
url: { |
|||
type: DataTypes.STRING, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: "文件路径", |
|||
primaryKey: false, |
|||
field: "url", |
|||
autoIncrement: false |
|||
}, |
|||
reportType: { |
|||
type: DataTypes.STRING, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: "报表类型", |
|||
primaryKey: false, |
|||
field: "report_type", |
|||
autoIncrement: false |
|||
}, |
|||
startTime: { |
|||
type: DataTypes.DATE, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: "开始时间", |
|||
primaryKey: false, |
|||
field: "start_time", |
|||
autoIncrement: false |
|||
}, |
|||
}, { |
|||
tableName: "report_file", |
|||
comment: "", |
|||
indexes: [] |
|||
}); |
|||
dc.models.ReportFile = ReportFile; |
|||
return ReportFile; |
|||
}; |
@ -0,0 +1,151 @@ |
|||
/* eslint-disable*/ |
|||
|
|||
'use strict'; |
|||
|
|||
module.exports = dc => { |
|||
const DataTypes = dc.ORM; |
|||
const sequelize = dc.orm; |
|||
const ReportAutomatic = sequelize.define("reportAutomatic", { |
|||
id: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: "id", |
|||
primaryKey: true, |
|||
field: "id", |
|||
autoIncrement: true |
|||
}, |
|||
reportName: { |
|||
type: DataTypes.STRING, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: "", |
|||
primaryKey: false, |
|||
field: "report_name", |
|||
autoIncrement: false |
|||
}, |
|||
projectId: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: "项目id", |
|||
primaryKey: false, |
|||
field: "project_id", |
|||
autoIncrement: false |
|||
}, |
|||
projectName: { |
|||
type: DataTypes.STRING, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: "", |
|||
primaryKey: false, |
|||
field: "project_name", |
|||
autoIncrement: false |
|||
}, |
|||
reportType: { |
|||
type: DataTypes.STRING, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: "报表类型", |
|||
primaryKey: false, |
|||
field: "report_type", |
|||
autoIncrement: false |
|||
}, |
|||
reportPicPath: { |
|||
type: DataTypes.STRING, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: "", |
|||
primaryKey: false, |
|||
field: "reportpic_path", |
|||
autoIncrement: false |
|||
}, |
|||
framer: { |
|||
type: DataTypes.STRING, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: "", |
|||
primaryKey: false, |
|||
field: "framer", |
|||
autoIncrement: false |
|||
}, |
|||
auditor: { |
|||
type: DataTypes.STRING, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: "", |
|||
primaryKey: false, |
|||
field: "auditor", |
|||
autoIncrement: false |
|||
}, |
|||
ratifier: { |
|||
type: DataTypes.STRING, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: "", |
|||
primaryKey: false, |
|||
field: "ratifier", |
|||
autoIncrement: false |
|||
}, |
|||
structId: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: "", |
|||
primaryKey: false, |
|||
field: "struct_id", |
|||
autoIncrement: false |
|||
}, |
|||
projectOverview: { |
|||
type: DataTypes.STRING, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: "", |
|||
primaryKey: false, |
|||
field: "project_overview", |
|||
autoIncrement: false |
|||
}, |
|||
reportStartTime: { |
|||
type: DataTypes.DATE, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: "开始时间", |
|||
primaryKey: false, |
|||
field: "report_start_time", |
|||
autoIncrement: false |
|||
}, |
|||
reportEndTime: { |
|||
type: DataTypes.DATE, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: "开始时间", |
|||
primaryKey: false, |
|||
field: "report_end_time", |
|||
autoIncrement: false |
|||
}, |
|||
time: { |
|||
type: DataTypes.DATE, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: "", |
|||
primaryKey: false, |
|||
field: "time", |
|||
autoIncrement: false |
|||
}, |
|||
factors: { |
|||
type: DataTypes.JSON, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: "", |
|||
primaryKey: false, |
|||
field: "factors", |
|||
autoIncrement: false |
|||
}, |
|||
}, { |
|||
tableName: "report_automatic", |
|||
comment: "", |
|||
indexes: [] |
|||
}); |
|||
dc.models.ReportAutomatic = ReportAutomatic; |
|||
return ReportAutomatic; |
|||
}; |
@ -0,0 +1,32 @@ |
|||
'use strict'; |
|||
|
|||
const report = require('../../controllers/service/report'); |
|||
|
|||
module.exports = function (app, router, opts) { |
|||
app.fs.api.logAttr['GET/report/file'] = { content: '获取服务记录列表', visible: true }; |
|||
router.get('/report/file', report.getReportFile); |
|||
|
|||
app.fs.api.logAttr['POST/report/file'] = { content: '上传文件', visible: true }; |
|||
router.post('/report/file', report.postReportFile); |
|||
|
|||
app.fs.api.logAttr['DEL/report/file/:id'] = { content: '删除报表文件', visible: true }; |
|||
router.del('/report/file/:id', report.delReportFile); |
|||
|
|||
app.fs.api.logAttr['GET/factor/list'] = { content: '获取监测因素信息', visible: true }; |
|||
router.get('/factor/list', report.getFactorList); |
|||
|
|||
app.fs.api.logAttr['POST/automatic/report'] = { content: '新增/编辑报表生成规则', visible: true }; |
|||
router.post('/automatic/report', report.postAutomaticReport); |
|||
|
|||
app.fs.api.logAttr['GET/automatic/report'] = { content: '获取报表生成规则', visible: true }; |
|||
router.get('/automatic/report', report.getAutomaticReport); |
|||
|
|||
app.fs.api.logAttr['DEL/automatic/report/:id'] = { content: '删除报表规则', visible: true }; |
|||
router.del('/automatic/report/:id', report.delAutomaticReport); |
|||
|
|||
|
|||
|
|||
// app.fs.api.logAttr['GET/respond-record'] = { content: '获取响应记录数据', visible: true };
|
|||
// router.get('/respond-record', record.respondRecord);
|
|||
|
|||
}; |
@ -0,0 +1,30 @@ |
|||
create table report_file |
|||
( |
|||
-- Only integer types can be auto increment |
|||
id serial not null, |
|||
file_name varchar(255) not null, |
|||
project_id int not null, |
|||
url varchar(1024) not null, |
|||
start_time timestamp not null, |
|||
report_type varchar(255) not null |
|||
); |
|||
|
|||
comment on table report_file is '报表文件'; |
|||
|
|||
comment on column report_file.file_name is '报表文件名'; |
|||
|
|||
comment on column report_file.project_id is '运维项目id'; |
|||
|
|||
comment on column report_file.url is '文件路径'; |
|||
|
|||
comment on column report_file.start_time is '产生时间'; |
|||
|
|||
comment on column report_file.report_type is '报表类型'; |
|||
|
|||
create unique index report_file_id_uindex |
|||
on report_file (id); |
|||
|
|||
alter table report_file |
|||
add constraint report_file_pk |
|||
primary key (id); |
|||
|
@ -0,0 +1,26 @@ |
|||
create table report_automatic |
|||
( |
|||
id serial not null, |
|||
report_name varchar(255) not null, |
|||
project_id int not null, |
|||
project_Name varchar(255) not null, |
|||
report_type varchar(255) not null, |
|||
reportpic_path varchar(255) not null, |
|||
framer varchar(255) not null, |
|||
auditor varchar(255) not null, |
|||
ratifier varchar(255) not null, |
|||
struct_id int not null, |
|||
report_start_time timestamp not null, |
|||
report_end_time timestamp not null, |
|||
factors json not null, |
|||
time timestamp not null, |
|||
project_overview varchar not null |
|||
); |
|||
|
|||
create unique index report_automatic_id_uindex |
|||
on report_automatic (id); |
|||
|
|||
alter table report_automatic |
|||
add constraint report_automatic_pk |
|||
primary key (id); |
|||
|
@ -0,0 +1,105 @@ |
|||
'use strict'; |
|||
|
|||
import { ApiTable, basicAction } from '$utils' |
|||
|
|||
export function getReportFile (query = {}) { //获取报表文件
|
|||
return dispatch => basicAction({ |
|||
type: 'get', |
|||
dispatch: dispatch, |
|||
query: query, |
|||
actionType: 'GET_REPORT_FILE', |
|||
url: `${ApiTable.reportFile}`, |
|||
msg: { option: '获取报表文件信息' }, |
|||
reducer: { |
|||
name: "reportFile", |
|||
params: { noClear: true } |
|||
} |
|||
}); |
|||
} |
|||
|
|||
export function postReportFile (data = {}) { //上传文件
|
|||
return dispatch => basicAction({ |
|||
type: 'post', |
|||
data, |
|||
dispatch: dispatch, |
|||
actionType: 'POST_REPORT_FILE', |
|||
url: `${ApiTable.reportFile}`, |
|||
msg: { option: '上传文件' }, |
|||
}); |
|||
} |
|||
|
|||
|
|||
export function delReportFile (id) {//删除报表文件
|
|||
return dispatch => basicAction({ |
|||
type: 'del', |
|||
dispatch: dispatch, |
|||
actionType: 'DEL_REPORT_FILE', |
|||
url: `${ApiTable.delReportFile.replace('{id}', id)}`, |
|||
msg: { option: '删除报表文件' }, |
|||
|
|||
|
|||
}); |
|||
} |
|||
|
|||
|
|||
export function getFactorList (query = {}) { //获取报表文件
|
|||
return dispatch => basicAction({ |
|||
type: 'get', |
|||
dispatch: dispatch, |
|||
query: query, |
|||
actionType: 'GET_FACTOR_LIST', |
|||
url: `${ApiTable.factorList}`, |
|||
msg: { error: '获取监测因素信息失败' }, |
|||
reducer: { |
|||
name: "", |
|||
params: { noClear: true } |
|||
} |
|||
}); |
|||
} |
|||
|
|||
export function postAutomaticReport (data = {}) { //上传文件
|
|||
return dispatch => basicAction({ |
|||
type: 'post', |
|||
data, |
|||
dispatch: dispatch, |
|||
actionType: 'POST_AUTOMATIC_REPORT', |
|||
url: `${ApiTable.automaticReport}`, |
|||
msg: { option: data?.id ? '编辑报表生成规则' : "新增报表生成规则" }, |
|||
}); |
|||
} |
|||
|
|||
|
|||
export function getAutomaticReport (query = {}) { //获取报表文件
|
|||
return dispatch => basicAction({ |
|||
type: 'get', |
|||
dispatch: dispatch, |
|||
query: query, |
|||
actionType: 'GET_AUTOMATIC_REPORT', |
|||
url: `${ApiTable.automaticReport}`, |
|||
msg: { error: '获取报表生成规则' }, |
|||
reducer: { |
|||
name: "automaticReport", |
|||
params: { noClear: true } |
|||
} |
|||
}); |
|||
} |
|||
|
|||
|
|||
export function delAutomaticReport (id) {//删除报表文件
|
|||
return dispatch => basicAction({ |
|||
type: 'del', |
|||
dispatch: dispatch, |
|||
actionType: 'DEL_AUTOMATIC_REPORT', |
|||
url: `${ApiTable.delAutomaticReport.replace('{id}', id)}`, |
|||
msg: { option: '删除报表规则' }, |
|||
|
|||
|
|||
}); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
@ -0,0 +1,318 @@ |
|||
import React, { useState, useRef, useEffect } from "react"; |
|||
import { connect } from "react-redux"; |
|||
import { Modal, Form, Notification, Tooltip, Upload, Button, Checkbox, CheckboxGroup, Collapse } from "@douyinfe/semi-ui"; |
|||
import { IconUpload } from '@douyinfe/semi-icons'; |
|||
import moment from "moment"; |
|||
|
|||
|
|||
const AutomaticModal = ({ actions, dispatch, apiRoot, qiniuUrl, visible, eidtData, close, success, projectList }) => { |
|||
|
|||
const { service, problem } = actions; |
|||
const form = useRef();//表单 |
|||
const [strucData, setStrucData] = useState([]) //结构物数据 |
|||
|
|||
const [projectId, setProjectId] = useState(); //项目id |
|||
const [structId, setStructId] = useState(); //结构物id |
|||
const [factorId, setFactorId] = useState([]); //监测因素id |
|||
const [factorList, setFactorList] = useState([]); //监测因素 |
|||
const [factorChech, setFactorChech] = useState([]); //选中的监测因素 |
|||
|
|||
|
|||
useEffect(async () => { |
|||
if (eidtData?.id) { |
|||
setProjectId(eidtData?.projectId) |
|||
setStructId(eidtData?.structId) |
|||
setFactorId(eidtData?.factors?.map(s => s.codeName) || []) |
|||
|
|||
let data = await getData(eidtData?.projectId) |
|||
let Factor = data?.find(s => s.strucId == eidtData?.structId)?.factor || [] |
|||
setFactorList(Factor) |
|||
setFactorChech(Factor?.filter(s => eidtData?.factors?.map(s => s.codeName)?.includes(s.proto))) |
|||
} |
|||
}, []) |
|||
|
|||
const getData = async (projectId) => { |
|||
let data = [] |
|||
await dispatch(service.getFactorList({ pepProjectId: projectId })).then((res) => { |
|||
if (res.success) { |
|||
setStrucData(res.payload.data) |
|||
data = res.payload.data |
|||
} |
|||
}) |
|||
return data |
|||
} |
|||
|
|||
return ( |
|||
<> |
|||
<Modal |
|||
title={eidtData.id ? "编辑生成规制" : '新增生成规制'} |
|||
okText="确定" |
|||
cancelText="取消" |
|||
visible={visible} |
|||
onOk={() => { |
|||
form.current.validate().then((v) => { |
|||
console.log(v); |
|||
let data = { |
|||
id: eidtData?.id, |
|||
reportName: v.reportName, |
|||
projectId: v.projectId, |
|||
projectName: v.projectName, |
|||
reportType: v.reportType, |
|||
reportPicPath: v.reportPicPath[0]?.response?.url, |
|||
framer: v.framer, |
|||
auditor: v.auditor, |
|||
ratifier: v.ratifier, |
|||
structId: v.structId, |
|||
projectOverview: v.projectOverview, |
|||
reportStartTime: moment(v.reportTime[0]).format('YYYY-MM-DD HH:mm:ss'), |
|||
reportEndTime: moment(v.reportTime[1]).format('YYYY-MM-DD HH:mm:ss'), |
|||
time: moment().format('YYYY-MM-DD HH:mm:ss'), |
|||
factors: [] |
|||
} |
|||
|
|||
v.factorId?.forEach(d => { |
|||
let index = d.length |
|||
let factorData = {} |
|||
for (let key in v) { |
|||
factorData.codeName = d |
|||
factorData.tempName = factorData.tempName || [] |
|||
if (key?.indexOf(d) != -1) { |
|||
if (key?.slice(index) == 'pointDescrip') factorData.pointDescrip = v[key] |
|||
if (key?.slice(index) == 'pointPicPath') factorData.pointPicPath = v[key] && v[key][0]?.response?.url |
|||
if (key?.slice(index) == 'factorDescrip') factorData.factorDescrip = v[key] |
|||
if (key?.slice(index) == 'sensorNames') factorData.sensorNames = factorChech?.find(p => p.proto == d)?.sensor?.filter(f => v[key]?.includes(f.id))?.map(c => ({ id: c.id, name: c.name })) || [] |
|||
if (key?.slice(index) == 'startEndTime') { |
|||
factorData.startTime = v[key] && moment(v[key][0]).format('YYYY-MM-DD HH:mm:ss') |
|||
factorData.endTime = v[key] && moment(v[key][1]).format('YYYY-MM-DD HH:mm:ss') |
|||
} |
|||
if (key?.slice(index) == 'tempName1') { |
|||
factorData.tempName?.push({ |
|||
index: 1, |
|||
id: v[key], |
|||
name: factorChech?.find(p => p.proto == d)?.sensor?.find(f => v[key] == f.id)?.name |
|||
}) |
|||
} |
|||
if (key?.slice(index) == 'tempName2') { |
|||
factorData.tempName?.push({ |
|||
index: 2, |
|||
id: v[key], |
|||
name: factorChech?.find(p => p.proto == 1004)?.sensor?.find(f => v[key] == f.id)?.name |
|||
}) |
|||
} |
|||
if (key?.slice(index) == 'factorDescrip') factorData.factorDescrip = v[key] |
|||
if (key?.slice(index) == 'glStaName') factorData.glStaName = v[key] |
|||
if (key?.slice(index) == 'tempStaName') factorData.tempStaName = v[key] |
|||
if (key?.slice(index) == 'initialTime') factorData.initialTime = v[key] && moment(v[key]).format('YYYY-MM-DD HH:mm:ss') |
|||
if (key?.slice(index) == 'releTime') { |
|||
factorData.releStartTime = v[key] && moment(v[key][0]).format('YYYY-MM-DD HH:mm:ss') |
|||
factorData.releEndTime = v[key] && moment(v[key][1]).format('YYYY-MM-DD HH:mm:ss') |
|||
} |
|||
} |
|||
} |
|||
data.factors?.push(factorData) |
|||
}) |
|||
console.log(111, data); |
|||
|
|||
dispatch(service.postAutomaticReport(data)).then((res) => { |
|||
console.log(res); |
|||
if (res.success) { |
|||
close() |
|||
success() |
|||
} |
|||
}) |
|||
|
|||
}) |
|||
}} |
|||
width={700} |
|||
onCancel={() => close()} |
|||
> |
|||
<Form |
|||
labelPosition="left" |
|||
labelAlign="right" |
|||
labelWidth="150px" |
|||
onValueChange={(values, field) => { }} |
|||
getFormApi={(formApi) => (form.current = formApi)} |
|||
> |
|||
<Form.Input field="reportName" label='报表名称' style={{ width: 300 }} placeholder="请输入报表名称" showClear |
|||
initValue={eidtData?.reportName || ""} |
|||
rules={[{ required: true, message: "请输入报表名称" }]} |
|||
/> |
|||
<Form.Select label="所属项目" field="projectId" placeholder="请选择项目" style={{ width: 300 }} filter |
|||
initValue={eidtData?.projectId || ""} |
|||
rules={[{ required: true, message: "请选择项目" }]} |
|||
onChange={v => { |
|||
setProjectId(v) |
|||
getData(v) |
|||
form.current.setValue('structId', null) |
|||
setStructId("") |
|||
setFactorList([]) |
|||
form.current.setValue('factorId', []) |
|||
setFactorChech([]) |
|||
}} > |
|||
{projectList?.map((item) => { |
|||
return <Form.Select.Option value={item.id} label={item.name || item.pepProjectName}></Form.Select.Option> |
|||
|
|||
})} |
|||
</Form.Select> |
|||
<Form.Input field="projectName" label='项目名称' style={{ width: 300 }} placeholder="请输入项目名称" showClear |
|||
initValue={eidtData?.projectName || ""} |
|||
rules={[{ required: true, message: "请输入项目名称" }]} |
|||
/> |
|||
<Form.Select label="报表类型" field="reportType" placeholder="请选择报表类型" style={{ width: 300 }} |
|||
rules={[{ required: true, message: "请选择报表类型" }]} |
|||
initValue={eidtData?.reportType || ""} |
|||
optionList={[{ value: "月报表", label: "月报表" }, { value: "季报表", label: "季报表" }, { value: "年报表", label: "年报表" }]} |
|||
/> |
|||
<Form.Upload label="首页图片" field="reportPicPath" style={{ display: 'inline-block', }} |
|||
initValue={eidtData?.reportPicPath && [{ url: `/_file-server/${eidtData?.reportPicPath?.slice(qiniuUrl.length + 1)}`, name: eidtData.reportPicPath?.split('/')?.pop(), status: 'success', preview: ['png', 'jpg', 'jpeg'].includes(eidtData.reportPicPath?.split('.')?.pop()?.replace('.', '')) }] || null} |
|||
rules={[{ required: true, message: "请上传首页图片" }]} |
|||
action={`${apiRoot}/attachments/p`} |
|||
accept={'.txt, .doc, .docx, .xls, .xlsx, .pdf, .png, .jpg, .rar, .zip'} |
|||
limit={1} maxSize={5120} |
|||
> |
|||
<Button icon={<IconUpload />} theme="light"> |
|||
文件上传 |
|||
</Button> |
|||
</Form.Upload> |
|||
<Form.Input field="framer" label='制定者' style={{ width: 300 }} placeholder="请输入制定者" showClear |
|||
initValue={eidtData?.framer || ""} |
|||
rules={[{ required: true, message: "请输入制定者" }]} |
|||
/> |
|||
<Form.Input field="auditor" label='审核者' style={{ width: 300 }} placeholder="请输入审核者" showClear |
|||
initValue={eidtData?.auditor || ""} |
|||
rules={[{ required: true, message: "请输入审核者" }]} |
|||
/> |
|||
<Form.Input field="ratifier" label='批准者' style={{ width: 300 }} placeholder="请输入批准者" showClear |
|||
initValue={eidtData?.ratifier || ""} |
|||
rules={[{ required: true, message: "请输入批准者" }]} |
|||
/> |
|||
|
|||
<Form.Select label="结构物" field="structId" placeholder="请选择结构物" style={{ width: 300 }} filter |
|||
rules={[{ required: true, message: "请选择结构物" }]} disabled={projectId ? false : true} |
|||
initValue={eidtData?.structId || ""} |
|||
onChange={v => { |
|||
setFactorList(strucData?.find(s => s.strucId == v)?.factor || []) |
|||
setStructId(v) |
|||
form.current.setValue('factorId', []) |
|||
setFactorChech([]) |
|||
}} > |
|||
{strucData?.map((item) => { |
|||
return <Form.Select.Option value={item.strucId} label={item.strucName}></Form.Select.Option> |
|||
|
|||
})} |
|||
</Form.Select> |
|||
|
|||
<Form.TextArea field="projectOverview" label='报表描述' style={{ width: 420 }} autosize={{ minRows: 2, maxRows: 10 }} placeholder="请输入报表描述" showClear |
|||
initValue={eidtData?.projectOverview || ""} |
|||
rules={[{ required: true, message: "请输入报表描述" }]} |
|||
/> |
|||
<Form.DatePicker field='reportTime' label='开始结束时间' type='dateTimeRange' showClear |
|||
initValue={eidtData?.reportStartTime && [moment(eidtData?.reportStartTime).format('YYYY-MM-DD HH:mm:ss'), moment(eidtData?.reportEndTime).format('YYYY-MM-DD HH:mm:ss')] || null} |
|||
rules={[{ required: true, message: "请选择开始结束时间" }]} |
|||
/> |
|||
<Form.Select label="包含的监测因素" field="factorId" placeholder="请选择监测因素" style={{ width: 300 }} filter multiple={true} |
|||
initValue={eidtData?.factors?.map(s => s.codeName) || []} |
|||
rules={[{ required: true, message: "请选择监测因素" }]} disabled={structId ? false : true} |
|||
onChange={v => { |
|||
setFactorChech(factorList?.filter(s => v.includes(s.proto))) |
|||
}} > |
|||
{factorList?.map((item) => { |
|||
return <Form.Select.Option value={item.proto} label={item.name}></Form.Select.Option> |
|||
})} |
|||
|
|||
</Form.Select> |
|||
|
|||
{factorChech?.length > 0 ? <Collapse style={{ margin: '20px 0 20px 30px', width: '90%', background: '#b7c9e624' }}> |
|||
{ |
|||
factorChech?.map(s => { |
|||
return <Collapse.Panel header={s.name} itemKey={s.proto}> |
|||
<div style={{ background: "#FFF" }}> |
|||
<Form.TextArea field={s.proto + "pointDescrip"} label='布点描述' style={{ width: 400 }} autosize={{ minRows: 2, maxRows: 10 }} placeholder="请输入布点描述" showClear |
|||
initValue={eidtData?.factors?.find(c => c.codeName == s.proto)?.pointDescrip || ""} |
|||
/> |
|||
<Form.Upload label="布点图片" field={s.proto + "pointPicPath"} style={{ display: 'inline-block', }} |
|||
initValue={eidtData?.factors?.find(c => c.codeName == s.proto)?.pointPicPath && [{ url: `/_file-server/${eidtData?.factors?.find(c => c.codeName == s.proto)?.pointPicPath?.slice(qiniuUrl.length + 1)}`, name: eidtData?.factors?.find(c => c.codeName == s.proto)?.pointPicPath?.split('/')?.pop(), status: 'success', preview: ['png', 'jpg', 'jpeg'].includes(eidtData?.factors?.find(c => c.codeName == s.proto)?.pointPicPath?.split('.')?.pop()?.replace('.', '')) }] || null} |
|||
action={`${apiRoot}/attachments/p`} |
|||
accept={'.png, .jpg, .jpeg'} |
|||
limit={1} maxSize={5120} |
|||
> |
|||
<Button icon={<IconUpload />} theme="light"> |
|||
文件上传 |
|||
</Button> |
|||
</Form.Upload> |
|||
|
|||
{s.proto == 2001 && |
|||
<Form.TextArea field={s.proto + "factorDescrip"} label='索力监测描述' style={{ width: 400 }} autosize={{ minRows: 2, maxRows: 10 }} placeholder="请输入布点描述" showClear |
|||
initValue={eidtData?.factors?.find(c => c.codeName == s.proto)?.factorDescrip || ""} |
|||
/> |
|||
} |
|||
|
|||
<Form.Select label="测点选择" field={s.proto + "sensorNames"} multiple={true} placeholder="请选择测点选择" style={{ width: 300 }} filter |
|||
initValue={eidtData?.factors?.find(c => c.codeName == s.proto)?.sensorNames?.map(a => a.id) || []} |
|||
> |
|||
{s.sensor?.map((item) => { |
|||
return <Form.Select.Option value={item.id} label={item.name}></Form.Select.Option> |
|||
})} |
|||
</Form.Select> |
|||
<Form.DatePicker field={s.proto + 'startEndTime'} label='开始结束时间' type='dateTimeRange' showClear style={{ width: 360 }} |
|||
initValue={eidtData?.factors?.find(c => c.codeName == s.proto)?.startTime && [moment(eidtData?.factors?.find(c => c.codeName == s.proto)?.startTime).format('YYYY-MM-DD HH:mm:ss'), moment(eidtData?.factors?.find(c => c.codeName == s.proto)?.endTime).format('YYYY-MM-DD HH:mm:ss')] || null} |
|||
/> |
|||
{ |
|||
['2001', '4004', '4007', '4008'].includes(s.proto) && |
|||
<Form.DatePicker field={s.proto + 'initialTime'} label='数据初始时间' type='dateTime' showClear |
|||
initValue={eidtData?.factors?.find(c => c.codeName == s.proto)?.initialTime && moment(eidtData?.factors?.find(c => c.codeName == s.proto)?.initialTime).format('YYYY-MM-DD HH:mm:ss')} |
|||
/> |
|||
} |
|||
|
|||
<Form.Select label="关联温度的测点" field={s.proto + "tempName1"} placeholder="请选择关联的温度测点" style={{ width: 300 }} filter |
|||
initValue={eidtData?.factors?.find(c => c.codeName == s.proto)?.tempName?.find(c => c.index == 1)?.id || ""} |
|||
> |
|||
{s.sensor?.map((item) => { |
|||
return <Form.Select.Option value={item.id} label={item.name}></Form.Select.Option> |
|||
|
|||
})} |
|||
</Form.Select> |
|||
<Form.Select label="温度测点" field={s.proto + "tempName2"} placeholder="请选择温度测点" style={{ width: 300 }} filter |
|||
initValue={eidtData?.factors?.find(c => c.codeName == s.proto)?.tempName?.find(c => c.index == 2)?.id || ""} |
|||
> |
|||
{factorList?.find(d => s.proto == 1004)?.sensor?.map((item) => { |
|||
return <Form.Select.Option value={item.name} label={item.name}></Form.Select.Option> |
|||
|
|||
})} |
|||
</Form.Select> |
|||
<Form.Input field={s.proto + "glStaName"} label='关联温度的测点名称' style={{ width: 300 }} placeholder="请输入关联温度的测点名称" showClear |
|||
initValue={eidtData?.factors?.find(c => c.codeName == s.proto)?.glStaName || ""} |
|||
/> |
|||
<Form.Input field={s.proto + "tempStaName"} label='关联温度名称' style={{ width: 300 }} placeholder="请输入关联温度名称" showClear |
|||
initValue={eidtData?.factors?.find(c => c.codeName == s.proto)?.tempStaName || ""} |
|||
/> |
|||
<Form.DatePicker field={s.proto + 'releTime'} label='关联开始结束时间' type='dateTimeRange' showClear style={{ width: 360 }} |
|||
initValue={eidtData?.factors?.find(c => c.codeName == s.proto)?.releStartTime && [moment(eidtData?.factors?.find(c => c.codeName == s.proto)?.releStartTime).format('YYYY-MM-DD HH:mm:ss'), moment(eidtData?.factors?.find(c => c.codeName == s.proto)?.releEndTime).format('YYYY-MM-DD HH:mm:ss')] || null} |
|||
/> |
|||
|
|||
</div> |
|||
</Collapse.Panel> |
|||
}) |
|||
} |
|||
|
|||
|
|||
</Collapse> : ""} |
|||
|
|||
</Form> |
|||
</Modal > |
|||
</> |
|||
); |
|||
} |
|||
function mapStateToProps (state) { |
|||
const { auth, global, members } = state; |
|||
|
|||
return { |
|||
// loading: members.isRequesting, |
|||
user: auth.user, |
|||
actions: global.actions, |
|||
apiRoot: global.apiRoot, |
|||
qiniuUrl: global.qiniu?.domain |
|||
}; |
|||
} |
|||
|
|||
export default connect(mapStateToProps)(AutomaticModal); |
@ -0,0 +1,140 @@ |
|||
import React, { useState, useRef, useEffect } from "react"; |
|||
import { connect } from "react-redux"; |
|||
import { Modal, Form, Notification, Tooltip, Upload, Button } from "@douyinfe/semi-ui"; |
|||
import { IconUpload } from '@douyinfe/semi-icons'; |
|||
import moment from "moment"; |
|||
|
|||
|
|||
const FileModal = ({ actions, dispatch, apiRoot, qiniuUrl, visible, close,success, projectList }) => { |
|||
|
|||
const { service, problem } = actions; |
|||
const form = useRef();//表单 |
|||
const [abnormal, setAbnormal] = useState(false); //异常率推送机制disable |
|||
const [usersList, setUsersList] = useState([]); //获取全部未删除用户 |
|||
const [structure, setStructure] = useState(true); //结构物disable |
|||
const [projectPoms, setProjectPoms] = useState([]); //获取已绑定项目 |
|||
const [projectStructure, setProjectStructure] = useState([]); //获取绑定项目下结构物 |
|||
const [timeTypeDis, setTimeTypeDis] = useState(true); //通知时效disable |
|||
const [projectStatus, setProjectStatus] = useState([]); //获取项目状态列表 |
|||
const timeTypePOMS = useRef([]);//表单 |
|||
|
|||
const [interval1, setInterval1] = useState(undefined); // |
|||
const [interval2, setInterval2] = useState(undefined); // |
|||
const [interval3, setInterval3] = useState(undefined); // |
|||
const [deviceProportion, setDeviceProportion] = useState(undefined); // |
|||
const [subType, setSubType] = useState([]); //监听模块中的子类 |
|||
const [factorShow, setFactorShow] = useState([]); //结构物对应监测项 |
|||
const [firstPass, setFirstPass] = useState(true) |
|||
const [uploadData, setUploadData] = useState({}) |
|||
|
|||
return ( |
|||
<> |
|||
<Modal |
|||
title={'文件上传'} |
|||
okText="确定" |
|||
cancelText="取消" |
|||
visible={visible} |
|||
onOk={() => { |
|||
form.current.validate().then((v) => { |
|||
if (uploadData?.url) { |
|||
dispatch(service.postReportFile({ |
|||
projectId: v.projectId, |
|||
fileName: v.fileName, |
|||
reportType: v.reportType, |
|||
startTime: moment().format('YYYY-MM-DD HH:mm:ss'), |
|||
url: qiniuUrl + '/' + uploadData?.url |
|||
})).then((res) => { |
|||
if (res.success) { |
|||
close() |
|||
success() |
|||
} |
|||
}) |
|||
} else { |
|||
Notification.error({ |
|||
content: '请上传文件', |
|||
duration: 2, |
|||
}) |
|||
} |
|||
}) |
|||
}} |
|||
width={500} |
|||
onCancel={() => close()} |
|||
> |
|||
<Form |
|||
labelPosition="left" |
|||
labelAlign="right" |
|||
labelWidth="128px" |
|||
onValueChange={(values, field) => { |
|||
|
|||
}} |
|||
getFormApi={(formApi) => (form.current = formApi)} |
|||
> |
|||
<Form.Select |
|||
label="请选择项目:" |
|||
field="projectId" |
|||
placeholder="请选择项目" |
|||
style={{ width: 300 }} |
|||
rules={[{ required: true, message: "请选择项目" }]} |
|||
filter |
|||
optionList={projectList?.map(v => ({ value: v.id, label: v.name || v.pepProjectName }))} |
|||
/> |
|||
<Form.Input |
|||
field="fileName" |
|||
label='文件名称' |
|||
style={{ width: 300 }} |
|||
placeholder="请输入文件名称" |
|||
showClear |
|||
rules={[{ required: true, message: "请输入文件名称" }]} |
|||
/> |
|||
<Form.Select |
|||
label="报表类型" |
|||
field="reportType" |
|||
placeholder="请选择报表类型" |
|||
style={{ width: 300 }} |
|||
rules={[{ required: true, message: "请选择报表类型" }]} |
|||
filter |
|||
optionList={[{ value: "月报表", label: "月报表" }, { value: "季报表", label: "季报表" }, { value: "年报表", label: "年报表" }]} |
|||
/> |
|||
<div style={{ display: 'flex', marginLeft: 69, marginTop: 10 }}> |
|||
<div style={{ marginTop: 6 }}>文件:<span style={{ color: 'red' }}>*</span></div> |
|||
<Upload |
|||
style={{ display: 'inline-block', marginLeft: 22 }} |
|||
action={`${apiRoot}/attachments/p`} |
|||
accept={'.txt, .doc, .docx, .xls, .xlsx, .pdf, .png, .jpg, .rar, .zip'} |
|||
limit={1} |
|||
maxSize={51200} |
|||
onRemove={() => { |
|||
setUploadData({}) |
|||
}} |
|||
onSuccess={(responseBody, file) => { |
|||
setUploadData({ |
|||
name: file.name, |
|||
size: file.size, |
|||
url: responseBody?.uploaded, |
|||
uploadTime: moment().format("YYYY-MM-DD HH:mm:ss") |
|||
}) |
|||
}} |
|||
> |
|||
<Button icon={<IconUpload />} theme="light"> |
|||
文件上传 |
|||
</Button> |
|||
</Upload> |
|||
</div> |
|||
</Form> |
|||
</Modal > |
|||
</> |
|||
); |
|||
} |
|||
function mapStateToProps (state) { |
|||
const { auth, global, members } = state; |
|||
|
|||
return { |
|||
// loading: members.isRequesting, |
|||
user: auth.user, |
|||
actions: global.actions, |
|||
apiRoot: global.apiRoot, |
|||
qiniuUrl: global.qiniu?.domain |
|||
}; |
|||
} |
|||
|
|||
export default connect(mapStateToProps)(FileModal); |
Loading…
Reference in new issue