zhaobing
2 years ago
24 changed files with 1378 additions and 31 deletions
@ -0,0 +1,203 @@ |
|||
'use strict'; |
|||
const moment = require('moment'); |
|||
|
|||
//设备维护记录
|
|||
async function getEquipment(ctx) { |
|||
try { |
|||
const { models } = ctx.fs.dc |
|||
const sequelize = ctx.fs.dc.ORM |
|||
const { clickHouse } = ctx.app.fs |
|||
const { startTime, endTime, pageSize, pageIndex, projectId } = ctx.query |
|||
//console.log('ressss', ctx.query)
|
|||
let whereOption = {} |
|||
if (projectId) { |
|||
whereOption.projectId = projectId |
|||
} else { |
|||
whereOption = undefined |
|||
} |
|||
|
|||
//console.log('6666', ctx.query)
|
|||
let resCount = await models.EquipmentMaintenanceRecord.count({ |
|||
include: [{ |
|||
model: models.EquipmentMaintenanceRecordProject, |
|||
where: whereOption |
|||
}], |
|||
where: { |
|||
$and: [ |
|||
sequelize.where(sequelize.fn('date', sequelize.col('report_time')), '>=', moment(startTime).format('YYYY-MM-DD HH:mm:ss')), |
|||
sequelize.where(sequelize.fn('date', sequelize.col('report_time')), '<=', moment(endTime).format('YYYY-MM-DD HH:mm:ss')), |
|||
], |
|||
|
|||
|
|||
} |
|||
}) |
|||
const res = await models.EquipmentMaintenanceRecord.findAll({ |
|||
order: [['id', 'DESC']], |
|||
attributes: ['id', 'equipmentType', 'equipmentCategory', 'maintenanceReason', 'solution', 'reportTime', 'completedTime', 'status'], |
|||
offset: (pageIndex - 1) * pageSize, |
|||
limit: pageSize, |
|||
include: [{ |
|||
attributes: ['id', 'equipmentMaintenanceRecordId', 'projectId'], |
|||
model: models.EquipmentMaintenanceRecordProject, |
|||
where: whereOption |
|||
|
|||
}, |
|||
{ |
|||
attributes: ['id', 'equipmentMaintenanceRecordId', 'pepUserId'], |
|||
model: models.EquipmentMaintenanceRecordExecuteUser |
|||
} |
|||
], |
|||
where: { |
|||
$and: [ |
|||
sequelize.where(sequelize.fn('date', sequelize.col('report_time')), '>=', moment(startTime).format('YYYY-MM-DD HH:mm:ss')), |
|||
sequelize.where(sequelize.fn('date', sequelize.col('report_time')), '<=', moment(endTime).format('YYYY-MM-DD HH:mm:ss')), |
|||
], |
|||
|
|||
} |
|||
}) |
|||
//用户id
|
|||
const arrayUserId = [] |
|||
|
|||
res.forEach((item) => { item.equipmentMaintenanceRecordExecuteUsers.forEach((item1) => { arrayUserId.push(item1.pepUserId) }) }) |
|||
const arrayUserIdCopy = [...new Set(arrayUserId)] |
|||
// (${[...pepProjectIds].join(',')}, -1)
|
|||
let userRes = [] |
|||
if (arrayUserIdCopy.length > 0) { |
|||
userRes = await clickHouse.pepEmis.query(` |
|||
SELECT * FROM user |
|||
WHERE id IN (${[...arrayUserIdCopy].join(',')},-1) |
|||
`).toPromise()
|
|||
} |
|||
const lastRes = res.map((item) => { |
|||
return { |
|||
reportTime: item.reportTime, |
|||
completedTime: item.completedTime, |
|||
equipmentCategory: item.equipmentCategory, |
|||
equipmentType: item.equipmentType, |
|||
id: item.id, |
|||
maintenanceReason: item.maintenanceReason, |
|||
solution: item.solution, |
|||
status: item.status, |
|||
equipmentMaintenanceRecordExecuteUsers: |
|||
item.equipmentMaintenanceRecordExecuteUsers.map((item1) => { |
|||
const userArr = userRes.find((ac) => { return ac.id == item1.pepUserId }) |
|||
return { |
|||
id: item1.id, |
|||
pepUserId: item1.pepUserId, |
|||
name: userArr ? userArr.name : '' |
|||
} |
|||
}), |
|||
equipmentMaintenanceRecordProjects: item.equipmentMaintenanceRecordProjects |
|||
} |
|||
}) |
|||
//console.log('res111', lastRes, resCount)
|
|||
// console.log('res11', arrayUserIdCopy)
|
|||
ctx.body = { result: lastRes, resCount } |
|||
ctx.status = 200 |
|||
} catch (error) { |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`) |
|||
ctx.status = 400 |
|||
ctx.body = { |
|||
message: `查询设备维护记录失败` |
|||
} |
|||
} |
|||
} |
|||
//编辑和新增
|
|||
async function editEquipment(ctx) { |
|||
const transaction = await ctx.fs.dc.orm.transaction(); |
|||
const query = ctx.request.body |
|||
try { |
|||
const { models } = ctx.fs.dc |
|||
const sequelize = ctx.fs.dc.ORM |
|||
console.log('query1111', query) |
|||
const { id, completedTime, deviceType, model, reason, reportTime, solution, status, solver, projectId } = query |
|||
if (id) { |
|||
await models.EquipmentMaintenanceRecord.update({ |
|||
equipmentType: model, |
|||
equipmentCategory: deviceType, |
|||
maintenanceReason: reason, |
|||
solution: solution, |
|||
reportTime, |
|||
completedTime, |
|||
status |
|||
}, { where: { id } }) |
|||
await models.EquipmentMaintenanceRecordExecuteUser.destroy({ where: { equipmentMaintenanceRecordId: id } }) |
|||
await models.EquipmentMaintenanceRecordProject.destroy({ where: { equipmentMaintenanceRecordId: id } }) |
|||
if (solver) { |
|||
const insertUserVal = solver.map((item) => { |
|||
return { |
|||
equipmentMaintenanceRecordId: id, pepUserId: item |
|||
} |
|||
}) |
|||
await models.EquipmentMaintenanceRecordExecuteUser.bulkCreate(insertUserVal) |
|||
} |
|||
|
|||
await models.EquipmentMaintenanceRecordProject.create({ |
|||
equipmentMaintenanceRecordId: id, projectId |
|||
}) |
|||
|
|||
|
|||
} else { |
|||
const equipment = await models.EquipmentMaintenanceRecord.create({ |
|||
equipmentType: model, |
|||
equipmentCategory: deviceType, |
|||
maintenanceReason: reason, |
|||
solution: solution, |
|||
reportTime, |
|||
completedTime, |
|||
status |
|||
}) |
|||
await models.EquipmentMaintenanceRecordProject.create({ |
|||
equipmentMaintenanceRecordId: equipment.id, projectId |
|||
}) |
|||
if (solver) { |
|||
const insertUserVal = solver.map((item) => { |
|||
return { |
|||
equipmentMaintenanceRecordId: equipment.id, pepUserId: item |
|||
} |
|||
}) |
|||
await models.EquipmentMaintenanceRecordExecuteUser.bulkCreate(insertUserVal) |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
await transaction.commit(); |
|||
ctx.status = 204 |
|||
} catch (error) { |
|||
await transaction.rollback(); |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`) |
|||
ctx.status = 400 |
|||
ctx.body = { |
|||
message: `${query.msg}失败` |
|||
} |
|||
} |
|||
} |
|||
//删除
|
|||
async function delEquipment(ctx) { |
|||
const transaction = await ctx.fs.dc.orm.transaction(); |
|||
try { |
|||
const params = ctx.params |
|||
const { models } = ctx.fs.dc |
|||
await models.EquipmentMaintenanceRecordExecuteUser.destroy({ where: { equipmentMaintenanceRecordId: params.id } }) |
|||
await models.EquipmentMaintenanceRecordProject.destroy({ where: { equipmentMaintenanceRecordId: params.id } }) |
|||
await models.EquipmentMaintenanceRecord.destroy({ where: { id: params.id } }) |
|||
ctx.status = 204 |
|||
await transaction.commit(); |
|||
} catch (error) { |
|||
await transaction.rollback(); |
|||
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`) |
|||
ctx.status = 400 |
|||
ctx.body = { |
|||
message: `删除维护记录失败` |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
module.exports = { |
|||
getEquipment, editEquipment, delEquipment |
|||
}; |
@ -0,0 +1,88 @@ |
|||
/* eslint-disable*/ |
|||
|
|||
'use strict'; |
|||
|
|||
module.exports = dc => { |
|||
const DataTypes = dc.ORM; |
|||
const sequelize = dc.orm; |
|||
const EquipmentMaintenanceRecord = sequelize.define("equipmentMaintenanceRecord", { |
|||
id: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: true, |
|||
field: "id", |
|||
autoIncrement: true |
|||
}, |
|||
equipmentType: { |
|||
type: DataTypes.STRING, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: false, |
|||
field: "equipment_type", |
|||
autoIncrement: false |
|||
}, |
|||
equipmentCategory: { |
|||
type: DataTypes.STRING, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: false, |
|||
field: "equipment_category", |
|||
autoIncrement: false |
|||
}, |
|||
maintenanceReason: { |
|||
type: DataTypes.STRING, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: false, |
|||
field: "maintenance_reason", |
|||
autoIncrement: false |
|||
}, |
|||
solution: { |
|||
type: DataTypes.STRING, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: false, |
|||
field: "solution", |
|||
autoIncrement: false |
|||
}, |
|||
reportTime: { |
|||
type: DataTypes.DATE, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: false, |
|||
field: "report_time", |
|||
autoIncrement: false |
|||
}, |
|||
completedTime: { |
|||
type: DataTypes.DATE, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: false, |
|||
field: "completed_time", |
|||
autoIncrement: false |
|||
}, |
|||
status: { |
|||
type: DataTypes.STRING, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: false, |
|||
field: "status", |
|||
autoIncrement: false |
|||
} |
|||
}, { |
|||
tableName: "equipment_maintenance_record", |
|||
comment: "", |
|||
indexes: [] |
|||
}); |
|||
dc.models.EquipmentMaintenanceRecord = EquipmentMaintenanceRecord; |
|||
return EquipmentMaintenanceRecord; |
|||
}; |
@ -0,0 +1,47 @@ |
|||
/* eslint-disable*/ |
|||
|
|||
'use strict'; |
|||
|
|||
module.exports = dc => { |
|||
const DataTypes = dc.ORM; |
|||
const sequelize = dc.orm; |
|||
const EquipmentMaintenanceRecordExecuteUser = sequelize.define("equipmentMaintenanceRecordExecuteUser", { |
|||
id: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: true, |
|||
field: "id", |
|||
autoIncrement: true |
|||
}, |
|||
equipmentMaintenanceRecordId: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: false, |
|||
field: "equipment_maintenance_record_id", |
|||
autoIncrement: false, |
|||
references: { |
|||
key: "id", |
|||
model: "equipmentMaintenanceRecord" |
|||
} |
|||
}, |
|||
pepUserId: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: false, |
|||
field: "pep_user_id", |
|||
autoIncrement: false |
|||
} |
|||
}, { |
|||
tableName: "equipment_maintenance_record_execute_user", |
|||
comment: "", |
|||
indexes: [] |
|||
}); |
|||
dc.models.EquipmentMaintenanceRecordExecuteUser = EquipmentMaintenanceRecordExecuteUser; |
|||
return EquipmentMaintenanceRecordExecuteUser; |
|||
}; |
@ -0,0 +1,47 @@ |
|||
/* eslint-disable*/ |
|||
|
|||
'use strict'; |
|||
|
|||
module.exports = dc => { |
|||
const DataTypes = dc.ORM; |
|||
const sequelize = dc.orm; |
|||
const EquipmentMaintenanceRecordProject = sequelize.define("equipmentMaintenanceRecordProject", { |
|||
id: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: true, |
|||
field: "id", |
|||
autoIncrement: true |
|||
}, |
|||
equipmentMaintenanceRecordId: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: false, |
|||
field: "equipment_maintenance_record_id", |
|||
autoIncrement: false, |
|||
references: { |
|||
key: "id", |
|||
model: "equipmentMaintenanceRecord" |
|||
} |
|||
}, |
|||
projectId: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: false, |
|||
field: "project_id", |
|||
autoIncrement: false |
|||
} |
|||
}, { |
|||
tableName: "equipment_maintenance_record_project", |
|||
comment: "", |
|||
indexes: [] |
|||
}); |
|||
dc.models.EquipmentMaintenanceRecordProject = EquipmentMaintenanceRecordProject; |
|||
return EquipmentMaintenanceRecordProject; |
|||
}; |
@ -0,0 +1,79 @@ |
|||
/* eslint-disable*/ |
|||
|
|||
'use strict'; |
|||
|
|||
module.exports = dc => { |
|||
const DataTypes = dc.ORM; |
|||
const sequelize = dc.orm; |
|||
const ServerMaintenanceRecord = sequelize.define("serverMaintenanceRecord", { |
|||
id: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: true, |
|||
field: "id", |
|||
autoIncrement: true |
|||
}, |
|||
sketch: { |
|||
type: DataTypes.STRING, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: "简述", |
|||
primaryKey: false, |
|||
field: "sketch", |
|||
autoIncrement: false |
|||
}, |
|||
reason: { |
|||
type: DataTypes.STRING, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: "维修原因", |
|||
primaryKey: false, |
|||
field: "reason", |
|||
autoIncrement: false |
|||
}, |
|||
remark: { |
|||
type: DataTypes.STRING, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: "备注", |
|||
primaryKey: false, |
|||
field: "remark", |
|||
autoIncrement: false |
|||
}, |
|||
maintenanceStartTime: { |
|||
type: DataTypes.DATE, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: "维护开始时间", |
|||
primaryKey: false, |
|||
field: "maintenance_start_time", |
|||
autoIncrement: false |
|||
}, |
|||
maintenanceFinishTime: { |
|||
type: DataTypes.DATE, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: "维护结束时间", |
|||
primaryKey: false, |
|||
field: "maintenance_finish_time", |
|||
autoIncrement: false |
|||
}, |
|||
state: { |
|||
type: DataTypes.STRING, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: "完成状态 wait 待维修 / underway 维修中 / completed 维修完成 ", |
|||
primaryKey: false, |
|||
field: "state", |
|||
autoIncrement: false |
|||
} |
|||
}, { |
|||
tableName: "server_maintenance_record", |
|||
comment: "", |
|||
indexes: [] |
|||
}); |
|||
dc.models.ServerMaintenanceRecord = ServerMaintenanceRecord; |
|||
return ServerMaintenanceRecord; |
|||
}; |
@ -0,0 +1,47 @@ |
|||
/* eslint-disable*/ |
|||
|
|||
'use strict'; |
|||
|
|||
module.exports = dc => { |
|||
const DataTypes = dc.ORM; |
|||
const sequelize = dc.orm; |
|||
const ServerMaintenanceRecordRepairman = sequelize.define("serverMaintenanceRecordRepairman", { |
|||
id: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: false, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: true, |
|||
field: "id", |
|||
autoIncrement: true |
|||
}, |
|||
serverMaintenanceRecordId: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: false, |
|||
field: "server_maintenance_record_id", |
|||
autoIncrement: false, |
|||
references: { |
|||
key: "id", |
|||
model: "serverMaintenanceRecord" |
|||
} |
|||
}, |
|||
pepUserId: { |
|||
type: DataTypes.INTEGER, |
|||
allowNull: true, |
|||
defaultValue: null, |
|||
comment: null, |
|||
primaryKey: false, |
|||
field: "pep_user_id", |
|||
autoIncrement: false |
|||
} |
|||
}, { |
|||
tableName: "server_maintenance_record_repairman", |
|||
comment: "", |
|||
indexes: [] |
|||
}); |
|||
dc.models.ServerMaintenanceRecordRepairman = ServerMaintenanceRecordRepairman; |
|||
return ServerMaintenanceRecordRepairman; |
|||
}; |
@ -0,0 +1,15 @@ |
|||
'use strict'; |
|||
|
|||
const equipment = require('../../controllers/equipment'); |
|||
|
|||
module.exports = function (app, router, opts) { |
|||
app.fs.api.logAttr['GET/equipment'] = { content: '获取设备维护记录', visible: true }; |
|||
router.get('/equipment', equipment.getEquipment); |
|||
|
|||
app.fs.api.logAttr['POST/equipment'] = { content: '编辑或者新增设备维护记录', visible: true }; |
|||
router.post('/equipment', equipment.editEquipment); |
|||
|
|||
app.fs.api.logAttr['DEL/equipment/:id'] = { content: '删除设备维护记录', visible: true }; |
|||
router.delete('/equipment/:id', equipment.delEquipment); |
|||
|
|||
} |
@ -0,0 +1,17 @@ |
|||
'use strict'; |
|||
|
|||
const serverInfoMaintenanceRecord = require('../../controllers/serverInfoMaintenanceRecord'); |
|||
|
|||
module.exports = function (app, router, opts) { |
|||
app.fs.api.logAttr['GET/serverInfoMaintenanceRecord'] = { content: '获取服务器维护记录列表', visible: true }; |
|||
router.get('/serverInfoMaintenanceRecord', serverInfoMaintenanceRecord.getServerInfoMaintenanceRecord) |
|||
|
|||
app.fs.api.logAttr['POST/serverInfoMaintenanceRecord'] = { content: '编辑服务器维护记录列表', visible: true }; |
|||
router.post('/serverInfoMaintenanceRecord', serverInfoMaintenanceRecord.editServerInfoMaintenanceRecord) |
|||
|
|||
app.fs.api.logAttr['DEL/serverInfoMaintenanceRecord/:id'] = { content: '删除服务器维护记录列表', visible: true }; |
|||
router.del('/serverInfoMaintenanceRecord/:id', serverInfoMaintenanceRecord.delServerInfoMaintenanceRecord) |
|||
} |
|||
|
|||
|
|||
|
@ -0,0 +1,16 @@ |
|||
create table server_maintenance_record( |
|||
id serial primary key, |
|||
sketch varchar(512), |
|||
reason varchar(512), |
|||
remark varchar(1024), |
|||
maintenance_start_time timestamp with time zone, |
|||
maintenance_finish_time timestamp with time zone, |
|||
state varchar(32) |
|||
); |
|||
comment on column public.server_maintenance_record.sketch is '简述'; |
|||
comment on column public.server_maintenance_record.reason is '维修原因'; |
|||
comment on column public.server_maintenance_record.remark is '备注'; |
|||
comment on column public.server_maintenance_record.maintenance_start_time is '维护开始时间'; |
|||
comment on column public.server_maintenance_record.maintenance_finish_time is '维护结束时间'; |
|||
comment on column public.server_maintenance_record.state is '维护结束时间'; |
|||
comment on column public.server_maintenance_record.state is '完成状态 wait 待维修 / underway 维修中 / completed 维修完成 '; |
@ -0,0 +1,5 @@ |
|||
create table server_maintenance_record_repairman( |
|||
id serial primary key, |
|||
server_maintenance_record_id integer references server_maintenance_record(id), |
|||
pep_user_id integer |
|||
) |
@ -1,2 +1,5 @@ |
|||
'use strict'; |
|||
|
|||
import * as serverInfoMaintenanceRecord from '../actions/serverInfo' |
|||
export default { |
|||
...serverInfoMaintenanceRecord |
|||
} |
@ -0,0 +1,45 @@ |
|||
import { ApiTable, basicAction } from '$utils' |
|||
|
|||
export function getServerInfoMaintenanceRecord(query) { //获取服务器维护记录
|
|||
return dispatch => basicAction({ |
|||
type: 'get', |
|||
dispatch: dispatch, |
|||
query: query, |
|||
actionType: 'GET_SERVER_INFO_MAINTENANCE_RECORD', |
|||
url: `${ApiTable.getServerInfoMaintenanceRecord}`, |
|||
msg: { option: '获取服务器维护记录' }, |
|||
reducer: { |
|||
name: "getServerInfoMaintenanceRecord", |
|||
params: { noClear: true } |
|||
} |
|||
}); |
|||
} |
|||
|
|||
|
|||
export function editServerInfoMaintenanceRecord(data) {//添加/编辑服务器信息维护记录
|
|||
let msg = '' |
|||
if (data) { |
|||
msg = data.msg |
|||
} |
|||
return (dispatch) => |
|||
basicAction({ |
|||
type: "post", |
|||
dispatch: dispatch, |
|||
data, |
|||
actionType: "POST_SERVER_INFO_MAINTENANCE_RECORD", |
|||
url: `${ApiTable.editServerInfoMaintenanceRecord}`, |
|||
msg: { option: msg },//添加/编辑服务器信息维护记录
|
|||
}); |
|||
} |
|||
|
|||
export function delServerInfoMaintenanceRecord(id) {//删除服务器信息维护记录
|
|||
return (dispatch) => |
|||
basicAction({ |
|||
type: "del", |
|||
dispatch: dispatch, |
|||
actionType: "DEL_SERVER_INFO_MAINTENANCE_RECORD", |
|||
url: `${ApiTable.delServerInfoMaintenanceRecord.replace('{id}', id)}`, |
|||
msg: { option: '删除服务器信息维护记录' }, |
|||
}); |
|||
} |
|||
|
@ -0,0 +1,105 @@ |
|||
'use strict'; |
|||
|
|||
import React, { useEffect, useState, useRef } from 'react'; |
|||
import { Modal, Form, DatePicker, useFormApi, actions, Button } from '@douyinfe/semi-ui'; |
|||
import { connect } from 'react-redux'; |
|||
import moment from 'moment'; |
|||
|
|||
const ServerInfoModal = (props) => { |
|||
const { visible, onClose, dispatch, recordRow, pepList, actions, projectList } = props; |
|||
const [startTime, setStartTime] = useState(''); |
|||
const [endTime, setEndTime] = useState(''); |
|||
const { service,facility } = actions; |
|||
|
|||
// console.log('endTimex',endTime) |
|||
const api = useRef(); |
|||
|
|||
useEffect(() => { |
|||
//console.log('recordRow', recordRow) |
|||
}, [recordRow]); |
|||
const cancelHandler = () => { |
|||
onClose() |
|||
} |
|||
const okHandler = () => { |
|||
api.current.validate().then((res) => { |
|||
//console.log('res1', res) |
|||
const query = { |
|||
id: recordRow?.id, |
|||
sketch:res.sketch, |
|||
reason:res.reason, |
|||
repairman:res.repairman, |
|||
remark:res.remark, |
|||
maintenanceStartTime:res.maintenanceStartTime, |
|||
maintenanceFinishTime:res.maintenanceFinishTime, |
|||
state:res.state, |
|||
msg: recordRow ? '编辑服务器信息维护记录' : '添加服务器信息维护记录' |
|||
} |
|||
dispatch(facility.editServerInfoMaintenanceRecord(query)).then((res)=>{ |
|||
if(res.success) onClose() ; api.current.reset() |
|||
}) |
|||
|
|||
}) |
|||
} |
|||
return ( |
|||
<Modal |
|||
|
|||
title={recordRow ? '编辑服务器信息维护记录' : '服务器维护记录添加'} |
|||
visible={visible} |
|||
onCancel={cancelHandler} |
|||
onOk={okHandler} |
|||
// footer={recordRow?<Button onClick={cancelHandler}>取消</Button>:<div> |
|||
// <Button onClick={cancelHandler}>取消</Button> |
|||
// <Button theme='solid' type='primary' onClick={okHandler}>确定</Button> |
|||
// </div>} |
|||
> |
|||
<Form |
|||
labelCol={{ span: 6 }} |
|||
initValues={{ |
|||
sketch:recordRow?.sketch, |
|||
reason:recordRow?.reason, |
|||
repairman:recordRow?.serverMaintenanceRecordRepairmans.map((item)=>{return item.pepUserId}), |
|||
remark:recordRow?.remark, |
|||
maintenanceStartTime:recordRow?.maintenanceStartTime, |
|||
maintenanceFinishTime:recordRow?.maintenanceFinishTime, |
|||
state:recordRow?.state, |
|||
}} |
|||
getFormApi={(formApi) => (api.current = formApi)} |
|||
labelPosition='left' |
|||
> |
|||
<Form.Input field='sketch' label='维护简述:' maxLength={50} rules={[{ required: true, message: '请输入设备类型' }]}></Form.Input> |
|||
<Form.TextArea field='reason' label='维修原因:' rules={[{ required: true, message: '请输入维修原因' }]} ></Form.TextArea> |
|||
<Form.Select field='repairman' label='维修人:' style={{ width: '100%' }} multiple filter> |
|||
{pepList?.map((item) => { |
|||
return ( |
|||
<Form.Select.OptGroup label={item.name}> |
|||
{item.users.map((item1) => { |
|||
return <Form.Select.Option value={item1.id} label={item1.name}></Form.Select.Option>; |
|||
})} |
|||
</Form.Select.OptGroup> |
|||
); |
|||
})} |
|||
</Form.Select> |
|||
<Form.TextArea field='remark' label='备注' ></Form.TextArea> |
|||
<Form.DatePicker type='dateTime' label='维护开始时间:' field='maintenanceStartTime'></Form.DatePicker> |
|||
<Form.DatePicker type='dateTime' label='维护完成时间:' field='maintenanceFinishTime'></Form.DatePicker> |
|||
<Form.Select label='状态' style={{ width: 200 }} field='state'> |
|||
<Form.Select.Option value='wait' label='待维修'>待维修</Form.Select.Option> |
|||
<Form.Select.Option value='underway' label='维修中'>维修中</Form.Select.Option> |
|||
<Form.Select.Option value='completed' label='维修完成'>维修完成</Form.Select.Option> |
|||
</Form.Select> |
|||
</Form> |
|||
</Modal> |
|||
); |
|||
}; |
|||
function mapStateToProps(state) { |
|||
const { auth, global, members, webSocket } = state; |
|||
return { |
|||
// loading: members.isRequesting, |
|||
// user: auth.user, |
|||
actions: global.actions |
|||
// members: members.data, |
|||
// socket: webSocket.socket |
|||
}; |
|||
} |
|||
|
|||
export default connect(mapStateToProps)(ServerInfoModal); |
@ -1,34 +1,224 @@ |
|||
import React, { useEffect } from 'react'; |
|||
import React, { useEffect,useState } from 'react'; |
|||
import { connect } from 'react-redux'; |
|||
import moment from 'moment' |
|||
import { Button, DatePicker, Select, Table, Popconfirm, Tooltip, Pagination } from '@douyinfe/semi-ui'; |
|||
import ServerInfoModal from '../components/serverInfoModal' |
|||
|
|||
|
|||
|
|||
const Rest = (props) => { |
|||
const MaintenanceRecords = (props) => { |
|||
const { dispatch, actions, user, loading, socket } = props |
|||
|
|||
const [addVis, setAddVis] = useState(false) |
|||
const [recordRow, setRecordRow] = useState(null) |
|||
const [pageSize,setPageSize]=useState(10) |
|||
const [pageIndex,setPageIndex]=useState(1) |
|||
const [total,setTotal]=useState() |
|||
const [pepList, setPepList] = useState([])//角色分配 |
|||
const {install,facility}=actions |
|||
const [startTime,setStartTime]=useState(null)//配置查询起止时间 |
|||
const [endTime,setEndTime]=useState(null) |
|||
const [recordList,setRecordList]=useState([]) |
|||
useEffect(() => { |
|||
|
|||
}, []) |
|||
//获取服务器信息 |
|||
const getServerInfo=(query={startTime,endTime,pageIndex,pageSize})=>{ |
|||
dispatch(facility.getServerInfoMaintenanceRecord(query)).then((res)=>{ |
|||
if(res.success) setRecordList(res.payload.data.responseRes);setTotal(res?.payload.data.count) |
|||
}) |
|||
} |
|||
//删除逻辑 |
|||
const delHandler=(record)=>{ |
|||
dispatch(facility.delServerInfoMaintenanceRecord(record.id)).then((res)=>{ |
|||
if(res.success) { |
|||
getServerInfo({startTime,endTime,pageIndex:1,pageSize}) |
|||
setPageIndex(1) |
|||
|
|||
} |
|||
}) |
|||
} |
|||
//查询按钮的逻辑 |
|||
const searchHandler=()=>{ |
|||
setPageIndex(1);setPageSize(10) |
|||
const query={startTime,endTime,pageIndex:1,pageSize:10} |
|||
getServerInfo(query) |
|||
} |
|||
//清楚日期选择框的逻辑 |
|||
const clearHandler=()=>{ |
|||
setStartTime(null) |
|||
setEndTime(null) |
|||
const query={startTime:null,endTime:null,pageIndex,pageSize} |
|||
getServerInfo(query) |
|||
} |
|||
useEffect(() => { |
|||
getServerInfo()//获取服务器信息维护记录 |
|||
dispatch(install.getOrganizationDeps()).then((res) => {//获取项企(PEP)全部部门及其下用户 |
|||
if(res.success) setPepList(res.payload.data) |
|||
}) |
|||
}, []) |
|||
const columns = [ |
|||
{ |
|||
title: '序号', |
|||
render: (t, r, i) => { |
|||
return i + 1; |
|||
} |
|||
}, |
|||
|
|||
{ |
|||
title: '维护描述', |
|||
dataIndex: 'sketch' |
|||
}, |
|||
{ |
|||
title: '维护原因', |
|||
dataIndex: 'reason' |
|||
}, |
|||
{ |
|||
title: '维修人', |
|||
render:(record) => { |
|||
return ( |
|||
<span> |
|||
{record?.serverMaintenanceRecordRepairmans |
|||
.map((item) => { |
|||
return item.name; |
|||
}) |
|||
.toString()} |
|||
</span> |
|||
); |
|||
} |
|||
}, |
|||
{ |
|||
title: '备注', |
|||
dataIndex: 'remark' |
|||
}, |
|||
|
|||
{ |
|||
title: '维护开始时间', |
|||
render: (record) => { |
|||
return (record?.maintenanceStartTime?(<span>{moment(record.maintenanceStartTime).format('YYYY-MM-DD HH:mm:ss')}</span>):'') |
|||
} |
|||
}, |
|||
{ |
|||
title: '维护完成时间', |
|||
render: (record) => { |
|||
return (record?.maintenanceFinishTime?(<span>{moment(record.maintenanceFinishTime).format('YYYY-MM-DD HH:mm:ss')}</span>):'') |
|||
} |
|||
}, |
|||
{ |
|||
title: '状态', |
|||
render:(record)=>{ |
|||
switch(record.state){ |
|||
case 'completed': |
|||
return '维修完成' |
|||
case 'underway': |
|||
return '维修中' |
|||
case 'wait': |
|||
return '待维修' |
|||
default: |
|||
break |
|||
} |
|||
|
|||
} |
|||
}, |
|||
{ |
|||
title: '操作', |
|||
render: (record) => { |
|||
//console.log('1111111',record) |
|||
return ( |
|||
<div> |
|||
<Button |
|||
style={{marginRight:10}} |
|||
onClick={() => { |
|||
setAddVis(true); |
|||
setRecordRow(record); |
|||
}} |
|||
> |
|||
编辑 |
|||
</Button> |
|||
<Popconfirm |
|||
title='确定是否删除?' |
|||
onConfirm={() => { |
|||
delHandler(record) |
|||
}} |
|||
> |
|||
<Button type='danger' > 删除</Button> |
|||
</Popconfirm> |
|||
</div> |
|||
); |
|||
} |
|||
} |
|||
]; |
|||
|
|||
|
|||
return ( |
|||
<> |
|||
<div> |
|||
<img src="/assets/images/install/watting.png" alt="" style={{ width: 'calc(100% + 16px)', position: "relative", top: -12, left: -8, }} /> |
|||
</div> |
|||
</> |
|||
) |
|||
} |
|||
<div style={{ background: '#FFFFFF', margin: '8px 12px', padding: '20px 20px 0px 20px' }}> |
|||
<div style={{ display: 'flex', marginBottom: 20, alignItems: 'baseline' }}> |
|||
<div style={{ marginRight: 100 }}> |
|||
{' '} |
|||
<Button |
|||
theme='solid' |
|||
type='secondary' |
|||
onClick={() => { |
|||
setAddVis(true); |
|||
}} |
|||
> |
|||
新增 |
|||
</Button> |
|||
</div> |
|||
<div style={{ marginRight: 20, display: 'flex', alignItems: 'baseline' }}> |
|||
<span style={{ marginRight: 10 }}>上报时间</span> |
|||
<DatePicker type='dateTimeRange' onChange={(dateTime)=>{ |
|||
setStartTime(dateTime[0]+'') |
|||
setEndTime(dateTime[1]+'') |
|||
}} onClear={clearHandler}></DatePicker> |
|||
</div> |
|||
<div> |
|||
<Button onClick={searchHandler}>查询</Button> |
|||
</div> |
|||
</div> |
|||
<div> |
|||
<Table columns={columns} dataSource={recordList} pagination={false}></Table> |
|||
</div> |
|||
<div style={{ display: 'flex',justifyContent:'flex-end' ,margin:'10px 0 0 0'}}> |
|||
<span style={{ lineHeight: "30px", fontSize: 13, color: 'rgba(0,90,189,0.8)' }}> |
|||
共{total}条信息 |
|||
</span> |
|||
<Pagination total={total} |
|||
showSizeChanger |
|||
pageSize={pageSize} |
|||
currentPage={pageIndex} |
|||
pageSizeOpts={[10, 20, 30]} |
|||
onChange={(pageIndex,pageSize)=>{ |
|||
//console.log('pageIndex1',pageIndex,pageSize) |
|||
setPageIndex(pageIndex) |
|||
setPageSize(pageSize) |
|||
const query={ |
|||
pageIndex:pageIndex,pageSize:pageSize,startTime, endTime |
|||
} |
|||
getServerInfo(query) |
|||
}}></Pagination> |
|||
</div> |
|||
<ServerInfoModal |
|||
visible={addVis} |
|||
onClose={() => { |
|||
setAddVis(false); |
|||
setRecordRow(null); |
|||
getServerInfo() |
|||
}} |
|||
recordRow={recordRow} |
|||
pepList={pepList} |
|||
|
|||
></ServerInfoModal> |
|||
</div> |
|||
); |
|||
}; |
|||
|
|||
function mapStateToProps (state) { |
|||
const { auth, global, members, webSocket } = state; |
|||
return { |
|||
// loading: members.isRequesting, |
|||
// user: auth.user, |
|||
// actions: global.actions, |
|||
// members: members.data, |
|||
// socket: webSocket.socket |
|||
}; |
|||
function mapStateToProps(state) { |
|||
const { auth, global, members, webSocket, } = state; |
|||
return { |
|||
// loading: members.isRequesting, |
|||
// user: auth.user, |
|||
actions: global.actions, |
|||
// members: members.data, |
|||
// socket: webSocket.socket |
|||
}; |
|||
} |
|||
|
|||
export default connect(mapStateToProps)(Rest); |
|||
export default connect(mapStateToProps)(MaintenanceRecords) |
|||
|
@ -0,0 +1,46 @@ |
|||
'use strict'; |
|||
|
|||
import { ApiTable, basicAction } from '$utils' |
|||
|
|||
export function getEquipment(query) { //获取设备维护记录
|
|||
return dispatch => basicAction({ |
|||
type: 'get', |
|||
dispatch: dispatch, |
|||
query, |
|||
actionType: 'GET_EQUIPMENT', |
|||
url: `${ApiTable.getEquipment}`, |
|||
msg: { option: '获取设备维护记录' }, |
|||
reducer: { |
|||
name: "getEquipment", |
|||
params: { noClear: true } |
|||
} |
|||
}); |
|||
} |
|||
|
|||
export function editEquipment(query) { //获取设备维护记录
|
|||
let msg = '' |
|||
if (query) { |
|||
msg = query.msg |
|||
} |
|||
return dispatch => basicAction({ |
|||
type: 'post', |
|||
dispatch: dispatch, |
|||
data: query, |
|||
actionType: 'EDIT_EQUIPMENT', |
|||
url: `${ApiTable.editEquipment}`, |
|||
msg: { option: msg }, |
|||
|
|||
}); |
|||
} |
|||
|
|||
|
|||
export function delEquipment(query) { //删除设备维护记录
|
|||
return dispatch => basicAction({ |
|||
type: 'del', |
|||
dispatch: dispatch, |
|||
actionType: 'DEL_EQUIPMENT', |
|||
url: `${ApiTable.delEquipment.replace('{id}', query)}`, |
|||
msg: { option: '删除维护记录' }, |
|||
|
|||
}); |
|||
} |
@ -0,0 +1,127 @@ |
|||
'use strict'; |
|||
|
|||
import React, { useEffect, useState, useRef } from 'react'; |
|||
import { Modal, Form, DatePicker, useFormApi, actions, Button } from '@douyinfe/semi-ui'; |
|||
import { connect } from 'react-redux'; |
|||
import moment from 'moment'; |
|||
|
|||
const MaintenanceRecordModal = (props) => { |
|||
const { visible, onClose, dispatch, recordRow, pepList, actions, projectList } = props; |
|||
const [startTime, setStartTime] = useState(''); |
|||
const [endTime, setEndTime] = useState(''); |
|||
const { service } = actions; |
|||
|
|||
// console.log('endTimex',endTime) |
|||
const api = useRef(); |
|||
|
|||
useEffect(() => { |
|||
console.log('recordRow', recordRow); |
|||
}, [recordRow]); |
|||
const cancelHandler = () => { |
|||
onClose(); |
|||
}; |
|||
const okHandler = () => { |
|||
api.current.validate().then((res) => { |
|||
console.log('res1', res) |
|||
const query = { |
|||
id: recordRow?.id, |
|||
projectId:res.projectName, |
|||
deviceType:res.deviceType, |
|||
model:res.model, |
|||
reason:res.reason, |
|||
solution:res.solution, |
|||
solver:res.solver, |
|||
reportTime:res.reportTime, |
|||
completedTime:res.completedTime, |
|||
status:res.status, |
|||
msg: recordRow ? '编辑维护记录' : '添加维护记录' |
|||
} |
|||
dispatch(service.editEquipment(query)).then((res)=>{ |
|||
if(res.success) onClose() ; api.current.reset() |
|||
}) |
|||
|
|||
}) |
|||
} |
|||
return ( |
|||
<Modal |
|||
|
|||
title={recordRow ? '编辑维修记录' : '设备维修记录添加'} |
|||
visible={visible} |
|||
onCancel={cancelHandler} |
|||
onOk={okHandler} |
|||
// footer={recordRow?<Button onClick={cancelHandler}>取消</Button>:<div> |
|||
// <Button onClick={cancelHandler}>取消</Button> |
|||
// <Button theme='solid' type='primary' onClick={okHandler}>确定</Button> |
|||
// </div>} |
|||
> |
|||
<Form |
|||
labelCol={{ span: 6 }} |
|||
initValues={{ |
|||
projectName: recordRow?.equipmentMaintenanceRecordProjects.map((item) => { |
|||
return item.projectId; |
|||
})[0], |
|||
deviceType:recordRow?.equipmentCategory, |
|||
model:recordRow?.equipmentType, |
|||
reason:recordRow?.maintenanceReason, |
|||
solution:recordRow?.solution, |
|||
solver:recordRow?.equipmentMaintenanceRecordExecuteUsers.map((item)=>{return item.pepUserId}), |
|||
reportTime:recordRow?.reportTime, |
|||
completedTime:recordRow?.completedTime, |
|||
status:recordRow?.status |
|||
}} |
|||
getFormApi={(formApi) => (api.current = formApi)} |
|||
labelPosition='left' |
|||
> |
|||
<Form.Select |
|||
field='projectName' |
|||
label='项目名称' |
|||
rules={[{ required: true, message: '请输入项目名称' }]} |
|||
style={{ width: '80%' }} |
|||
> |
|||
{projectList?.map((item) => { |
|||
return <Form.Select.Option value={item.id} label={item.pepProjectName || item.name}></Form.Select.Option>; |
|||
})} |
|||
</Form.Select> |
|||
<Form.Input field='deviceType' label='设备类型:' maxLength={30} rules={[{ required: true, message: '请输入设备类型' }]}></Form.Input> |
|||
<Form.Input field='model' label='设备型号:' maxLength={30}></Form.Input> |
|||
<Form.TextArea field='reason' label='维修原因:' rules={[{ required: true, message: '请输入维修原因' }]}></Form.TextArea> |
|||
<Form.TextArea field='solution' label='解决方案:'></Form.TextArea> |
|||
<Form.Select field='solver' label='维修人:' style={{ width: '100%' }} multiple filter> |
|||
{pepList?.map((item) => { |
|||
return ( |
|||
<Form.Select.OptGroup label={item.name}> |
|||
{item.users.map((item1) => { |
|||
return <Form.Select.Option value={item1.id} label={item1.name}></Form.Select.Option>; |
|||
})} |
|||
</Form.Select.OptGroup> |
|||
); |
|||
})} |
|||
</Form.Select> |
|||
<Form.DatePicker |
|||
type='dateTime' |
|||
label='上报时间:' |
|||
field='reportTime' |
|||
rules={[{ required: true, message: '请选择上报时间' }]} |
|||
></Form.DatePicker> |
|||
<Form.DatePicker type='dateTime' label='维修完成时间:' field='completedTime'></Form.DatePicker> |
|||
<Form.Select label='状态' style={{ width: 200 }} field='status'> |
|||
<Form.Select.Option value='待维修'>待维修</Form.Select.Option> |
|||
<Form.Select.Option value='维修中'>维修中</Form.Select.Option> |
|||
<Form.Select.Option value='维修完成'>维修完成</Form.Select.Option> |
|||
</Form.Select> |
|||
</Form> |
|||
</Modal> |
|||
); |
|||
}; |
|||
function mapStateToProps(state) { |
|||
const { auth, global, members, webSocket } = state; |
|||
return { |
|||
// loading: members.isRequesting, |
|||
// user: auth.user, |
|||
actions: global.actions |
|||
// members: members.data, |
|||
// socket: webSocket.socket |
|||
}; |
|||
} |
|||
|
|||
export default connect(mapStateToProps)(MaintenanceRecordModal); |
@ -0,0 +1,238 @@ |
|||
import { Button, DatePicker, Select, Table, Popconfirm, Tooltip, Pagination } from '@douyinfe/semi-ui'; |
|||
import React, { useEffect, useState } from 'react'; |
|||
import { connect } from 'react-redux'; |
|||
import MaintenanceRecordModal from '../components/maintenanceRecordModal'; |
|||
import moment from 'moment'; |
|||
|
|||
const MaintenanceRecords = (props) => { |
|||
const { dispatch, actions, user, loading, socket, projectList } = props; |
|||
const [addVis, setAddVis] = useState(false); |
|||
const [recordRow, setRecordRow] = useState(null); |
|||
const [equipmentList, setEquipmentList] = useState([]); |
|||
const [pepList, setPepList] = useState([]); |
|||
const [pageSize, setPageSize] = useState(10); |
|||
const [pageIndex, setPageIndex] = useState(1); |
|||
const [startTime, setStartTime] = useState('1970-1-1'); |
|||
const [endTime, setEndTime] = useState('2099-1-1'); |
|||
const { install, service } = actions; |
|||
const [total,setTotal]=useState() |
|||
const [projectId,setProjectId]=useState(null) |
|||
const getEquipment = (query = { startTime, endTime, pageIndex, pageSize }) => { |
|||
dispatch(service.getEquipment(query)).then((res) => { |
|||
// console.log() |
|||
if (res.success) setEquipmentList(res?.payload.data.result); setTotal(res?.payload.data.resCount) |
|||
|
|||
|
|||
}); |
|||
}; |
|||
// console.log('equipmentList', equipmentList); |
|||
const findHandler=()=>{ |
|||
const query={ |
|||
pageIndex,pageSize,msg:'获取维护记录',startTime, endTime,projectId |
|||
} |
|||
console.log('canshu',projectId,startTime, endTime) |
|||
getEquipment(query) |
|||
} |
|||
const timeHandler=(e)=>{ |
|||
setEndTime(e[1]+'') |
|||
setStartTime(e[0]+'') |
|||
} |
|||
useEffect(() => { |
|||
dispatch(install.getOrganizationDeps()).then((res) => { |
|||
//获取项企(PEP)全部部门及其下用户 |
|||
setPepList(res.payload.data); |
|||
}); |
|||
getEquipment(); |
|||
}, []) |
|||
const delHandler=(record)=>{ |
|||
dispatch(service.delEquipment(record.id)).then((res)=>{ |
|||
if(res.success) getEquipment({ |
|||
pageIndex:1,pageSize,msg:'获取维护记录',startTime, endTime,projectId |
|||
});setPageIndex(1) |
|||
}) |
|||
} |
|||
const columns = [ |
|||
{ |
|||
title: '序号', |
|||
render: (t, r, i) => { |
|||
return i + 1; |
|||
} |
|||
}, |
|||
{ |
|||
title: '项目名称', |
|||
render: (record) => { |
|||
const currentId = record.equipmentMaintenanceRecordProjects.map((item1) => { |
|||
return item1.projectId; |
|||
})[0]; |
|||
const currnetObj = projectList?.find((item) => item.id === currentId)||{}; |
|||
const projectName = currnetObj.name ? currnetObj.name : currnetObj.pepProjectName; |
|||
return projectName?.length > 15 ? ( |
|||
<Tooltip content={<div>{projectName}</div>}> |
|||
<div style={{}}>{projectName?.length > 15 ? `${projectName?.substr(0, 15)}...` : projectName}</div> |
|||
</Tooltip> |
|||
) : ( |
|||
projectName |
|||
); |
|||
} |
|||
}, |
|||
{ |
|||
title: '设备类型', |
|||
dataIndex: 'equipmentCategory' |
|||
}, |
|||
{ |
|||
title: '设备型号', |
|||
dataIndex: 'equipmentType' |
|||
}, |
|||
{ |
|||
title: '维修原因', |
|||
dataIndex: 'maintenanceReason' |
|||
}, |
|||
{ |
|||
title: '解决方案', |
|||
dataIndex: 'solution' |
|||
}, |
|||
{ |
|||
title: '维修人', |
|||
render: (record) => { |
|||
return ( |
|||
<span> |
|||
{record?.equipmentMaintenanceRecordExecuteUsers |
|||
.map((item) => { |
|||
return item.name; |
|||
}) |
|||
.toString()} |
|||
</span> |
|||
); |
|||
} |
|||
}, |
|||
{ |
|||
title: '上报时间', |
|||
render: (record) => { |
|||
return <span>{moment(record.reportTime).format('YYYY-MM-DD HH:mm:ss')}</span>; |
|||
} |
|||
}, |
|||
{ |
|||
title: '维修完成时间', |
|||
render: (record) => { |
|||
//('record',record.completedTime) |
|||
return (record.completedTime?(<span>{moment(record.reportTime).format('YYYY-MM-DD HH:mm:ss')}</span>):'') |
|||
} |
|||
}, |
|||
{ |
|||
title: '状态', |
|||
dataIndex: 'status' |
|||
}, |
|||
{ |
|||
title: '操作', |
|||
render: (record) => { |
|||
return ( |
|||
<div> |
|||
<Button |
|||
style={{marginRight:10}} |
|||
onClick={() => { |
|||
setAddVis(true); |
|||
setRecordRow(record); |
|||
}} |
|||
> |
|||
编辑 |
|||
</Button> |
|||
<Popconfirm |
|||
title='确定是否删除?' |
|||
onConfirm={() => { |
|||
delHandler(record); |
|||
}} |
|||
> |
|||
<Button type='danger' > 删除</Button> |
|||
</Popconfirm> |
|||
</div> |
|||
); |
|||
} |
|||
} |
|||
]; |
|||
|
|||
return ( |
|||
<div style={{ background: '#FFFFFF', margin: '8px 12px', padding: '20px 20px 0px 20px' }}> |
|||
<div style={{ display: 'flex', marginBottom: 20, alignItems: 'baseline' }}> |
|||
<div style={{ marginRight: 100 }}> |
|||
{' '} |
|||
<Button |
|||
theme='solid' |
|||
type='secondary' |
|||
onClick={() => { |
|||
setAddVis(true); |
|||
}} |
|||
> |
|||
新增 |
|||
</Button> |
|||
</div> |
|||
<div style={{ marginRight: 200 }}> |
|||
{' '} |
|||
<span>项目名称</span> |
|||
<Select |
|||
showClear |
|||
onChange={(e)=>{setProjectId(e)}} |
|||
onClear={()=>{setProjectId(null)}} |
|||
style={{ width: 150 }} |
|||
optionList={projectList?.map((item) => { |
|||
return { value: item.id, label: item.pepProjectName||item.name } |
|||
})} |
|||
></Select> |
|||
</div> |
|||
<div style={{ marginRight: 20, display: 'flex', alignItems: 'baseline' }}> |
|||
<span style={{ marginRight: 10 }}>上报时间</span> |
|||
<DatePicker type='dateTimeRange' onChange={(e)=>{timeHandler(e)}} onClear={()=>{setStartTime('1970-1-1');setEndTime('2099-12-31')}}></DatePicker> |
|||
</div> |
|||
<div> |
|||
<Button onClick={findHandler}>查询</Button> |
|||
</div> |
|||
</div> |
|||
<div> |
|||
<Table columns={columns} dataSource={equipmentList} pagination={false}></Table> |
|||
</div> |
|||
<div style={{ display: 'flex',justifyContent:'flex-end' ,margin:'10px 0 0 0'}}> |
|||
<span style={{ lineHeight: "30px", fontSize: 13, color: 'rgba(0,90,189,0.8)' }}> |
|||
共{total}条信息 |
|||
</span> |
|||
<Pagination total={total} |
|||
showSizeChanger |
|||
pageSize={pageSize} |
|||
currentPage={pageIndex} |
|||
pageSizeOpts={[10, 20, 30]} |
|||
onChange={(pageIndex,pageSize)=>{ |
|||
//console.log('pageIndex1',pageIndex,pageSize) |
|||
setPageIndex(pageIndex) |
|||
setPageSize(pageSize) |
|||
const query={ |
|||
pageIndex,pageSize,msg:'获取维护记录',startTime, endTime,projectId |
|||
} |
|||
getEquipment(query) |
|||
}}></Pagination> |
|||
</div> |
|||
<MaintenanceRecordModal |
|||
visible={addVis} |
|||
onClose={() => { |
|||
setAddVis(false); |
|||
setRecordRow(null); |
|||
getEquipment(); |
|||
}} |
|||
recordRow={recordRow} |
|||
pepList={pepList} |
|||
projectList={projectList} |
|||
></MaintenanceRecordModal> |
|||
</div> |
|||
); |
|||
}; |
|||
|
|||
function mapStateToProps(state) { |
|||
const { auth, global, members, webSocket, ProjectPoms } = state; |
|||
return { |
|||
// loading: members.isRequesting, |
|||
// user: auth.user, |
|||
actions: global.actions, |
|||
// members: members.data, |
|||
// socket: webSocket.socket |
|||
projectList: ProjectPoms.data?.rows |
|||
}; |
|||
} |
|||
|
|||
export default connect(mapStateToProps)(MaintenanceRecords); |
Loading…
Reference in new issue