diff --git a/api/app/lib/controllers/patrolManage/patrolRecord.js b/api/app/lib/controllers/patrolManage/patrolRecord.js index 4c4b15b..204177a 100644 --- a/api/app/lib/controllers/patrolManage/patrolRecord.js +++ b/api/app/lib/controllers/patrolManage/patrolRecord.js @@ -10,7 +10,11 @@ async function findPatrolRecord(ctx, next) { let generalInclude = [{ model: models.PatrolPlan, attributes: ['name'] - }] + }, + { + model: models.PatrolRecordIssueHandle + } + ] if (patrolPlanId == 'all') { /* 如果有startTime && endTime,查询所有符合条件的数据 */ if (startTime !== 'null' && endTime !== 'null') { diff --git a/api/app/lib/index.js b/api/app/lib/index.js index faf68b5..6f6cb92 100644 --- a/api/app/lib/index.js +++ b/api/app/lib/index.js @@ -56,12 +56,15 @@ module.exports.models = function (dc) { // dc = { orm: Sequelize对象, ORM: Seq const { Department, User, UserResource, Resource, Project, Point, PatrolPlan, PatrolRecord, CheckItems, CheckItemsGroup, - PatrolTemplate, PatrolTemplateCheckItems + PatrolTemplate, PatrolTemplateCheckItems, PatrolRecordIssueHandle } = dc.models; PatrolRecord.belongsTo(PatrolPlan, { foreignKey: 'patrolPlanId', targetKey: 'id' }); PatrolPlan.hasMany(PatrolRecord, { foreignKey: 'patrolPlanId', sourceKey: 'id' }); + PatrolRecordIssueHandle.belongsTo(PatrolRecord, { foreignKey: 'patrolRecordId', targetKey: 'id' }); + PatrolRecord.hasMany(PatrolRecordIssueHandle, { foreignKey: 'patrolRecordId', sourceKey: 'id' }); + UserResource.belongsTo(User, { foreignKey: 'userId', targetKey: 'id' }); User.hasMany(UserResource, { foreignKey: 'userId', sourceKey: 'id' }); diff --git a/api/app/lib/models/patrol_record_issue_handle.js b/api/app/lib/models/patrol_record_issue_handle.js new file mode 100644 index 0000000..a46ddba --- /dev/null +++ b/api/app/lib/models/patrol_record_issue_handle.js @@ -0,0 +1,143 @@ +/* eslint-disable*/ + +'use strict'; + +module.exports = dc => { + const DataTypes = dc.ORM; + const sequelize = dc.orm; + const PatrolRecordIssueHandle = sequelize.define("patrolRecordIssueHandle", { + id: { + type: DataTypes.INTEGER, + allowNull: false, + defaultValue: null, + comment: null, + primaryKey: true, + field: "id", + autoIncrement: true, + unique: "patrol_record_issue_handle_id_uindex" + }, + patrolRecordId: { + type: DataTypes.INTEGER, + allowNull: true, + defaultValue: null, + comment: "巡检记录id", + primaryKey: false, + field: "patrol_record_id", + autoIncrement: false + }, + repairPerson: { + type: DataTypes.JSONB, + allowNull: true, + defaultValue: null, + comment: "维修人", + primaryKey: false, + field: "repair_person", + autoIncrement: false + }, + repairUnit: { + type: DataTypes.STRING, + allowNull: true, + defaultValue: null, + comment: "维修单位", + primaryKey: false, + field: "repair_unit", + autoIncrement: false + }, + startTime: { + type: DataTypes.DATE, + allowNull: true, + defaultValue: null, + comment: null, + primaryKey: false, + field: "start_time", + autoIncrement: false + }, + endTime: { + type: DataTypes.DATE, + allowNull: true, + defaultValue: null, + comment: null, + primaryKey: false, + field: "end_time", + autoIncrement: false + }, + repairAsk: { + type: DataTypes.INTEGER, + allowNull: true, + defaultValue: null, + comment: "维修要求", + primaryKey: false, + field: "repair_ask", + autoIncrement: false + }, + checkPerson: { + type: DataTypes.JSONB, + allowNull: true, + defaultValue: null, + comment: "质检验收人", + primaryKey: false, + field: "check_person", + autoIncrement: false + }, + state: { + type: DataTypes.INTEGER, + allowNull: true, + defaultValue: null, + comment: "流程状态 \n1 制定计划 待审核\n2 \n3\n4\n5\n6\n7", + primaryKey: false, + field: "state", + autoIncrement: false + }, + approvePerson: { + type: DataTypes.JSONB, + allowNull: true, + defaultValue: null, + comment: "审批人", + primaryKey: false, + field: "approve_person", + autoIncrement: false + }, + approveDate: { + type: DataTypes.DATE, + allowNull: true, + defaultValue: null, + comment: "审批日期", + primaryKey: false, + field: "approve_date", + autoIncrement: false + }, + approveOpinion: { + type: DataTypes.STRING, + allowNull: true, + defaultValue: null, + comment: "审批意见", + primaryKey: false, + field: "approve_opinion", + autoIncrement: false + }, + repairDesc: { + type: DataTypes.STRING, + allowNull: true, + defaultValue: null, + comment: "维修情况描述", + primaryKey: false, + field: "repair_desc", + autoIncrement: false + }, + repairImage: { + type: DataTypes.JSONB, + allowNull: true, + defaultValue: null, + comment: null, + primaryKey: false, + field: "repair_image", + autoIncrement: false + } + }, { + tableName: "patrol_record_issue_handle", + comment: "", + indexes: [] + }); + dc.models.PatrolRecordIssueHandle = PatrolRecordIssueHandle; + return PatrolRecordIssueHandle; +}; \ No newline at end of file diff --git a/web/client/src/sections/issueHandle/containers/patrolRecord.js b/web/client/src/sections/issueHandle/containers/patrolRecord.js index 938dae2..9e84532 100644 --- a/web/client/src/sections/issueHandle/containers/patrolRecord.js +++ b/web/client/src/sections/issueHandle/containers/patrolRecord.js @@ -28,7 +28,7 @@ const PatrolRecord = (props) => { }, []) const record = (params) => { - dispatch(patrolManage.records(`patrolRecord/all/${times[0]}/${times[1]}/null/null`)).then(res => { + dispatch(patrolManage.records(`patrolRecord/all/${times[0]}/${times[1]}/true/null`)).then(res => { if (res.success) { settableList(params.name != null ? res.payload.data?.filter(v => (v.points.user.name.indexOf(params.name) != -1 || v.points.project.name.indexOf(params.name) != -1)) @@ -53,94 +53,155 @@ const PatrolRecord = (props) => { return text } - const columns = [{ - title: '结构物名称', - dataIndex: 'name', - key: 'name', - width: '10%', - showInDetail: true, - render: (text, record, index) => { - return !record.points?.project ? '' :
{record.points.project.name}
- } - }, { - title: '巡检计划', - dataIndex: 'name', - key: 'name', - width: '10%', - showInDetail: true, - render: (text, record, index) => { - return !record.patrolPlan ? '' :
{record.patrolPlan.name}
- } - }, { - title: '巡检点位', - dataIndex: 'type', - key: 'type', - showInDetail: true, - width: '10%', - render: (text, record, index) => { - return !record.points?.user ? '' :
{record.points.itemData.name}
- } - }, { - title: '巡检人', - dataIndex: 'type', - key: 'type', - showInDetail: true, - width: '10%', - render: (text, record, index) => { - return !record.points?.user ? '' :
{record.points.user.name}
- } - }, { - title: '巡检单位', - dataIndex: 'type', - showInDetail: true, - key: 'type', - width: '10%', - render: (text, record, index) => { - return !record.points?.user ? '' :
{record.points.user.department.name}
- } - }, { - title: '巡检频次', - dataIndex: 'describe', - key: 'describe', - showInDetail: true, - width: '10%', - render: (text, record, index) => { - return !record.points ? '' :
{record.points.frequency}
- } - }, { - title: '上次巡检日期', - dataIndex: 'describe', - showInDetail: true, - key: 'describe', - render: (text, record, index) => record.lastInspectionTime ? moment(record.lastInspectionTime).format('YYYY-MM-DD HH:mm:ss') : '--' - }, { - title: '本次巡检日期', - dataIndex: 'describe', - key: 'describe', - showInDetail: true, - render: (text, record, index) => moment(record.inspectionTime).format('YYYY-MM-DD HH:mm:ss') || '--' - }, { - title: '巡检结果', - dataIndex: 'describe', - key: 'describe', - render: (text, record, index) => !record.alarm ? '正常' : '异常' - }, { - title: '操作', - dataIndex: 'operation', - key: 'operation', - render: (text, record, index) => { - return ( - {renderOptionText(1)}} - user={{}} - onFinish={onFinish} /> - ) + const columns = [ + { + title: '结构物名称', + dataIndex: 'name', + key: 'name', + width: '10%', + showInDetail: true, + render: (text, record, index) => { + return !record.points?.project ? '' :
{record.points.project.name}
+ } + }, + { + title: '上报人', + dataIndex: 'type', + key: 'type', + showInDetail: true, + width: '10%', + render: (text, record, index) => { + return !record.points?.user ? '' :
{record.points.user.name}
+ } + }, + { + title: '上报时间', + dataIndex: 'time', + key: 'time', + showInDetail: true, + render: (text, record, index) => moment(record.inspectionTime).format('YYYY-MM-DD HH:mm:ss') || '--' + }, { + title: '点位名称', + dataIndex: 'station', + key: 'station', + showInDetail: true, + render: (text, record, index) => record?.points?.itemData?.name + }, + { + title: '问题来源', + dataIndex: 'source', + key: 'source', + showInDetail: true, + render: (text, record, index) => '巡检上报' //暂定巡检上报 后续会增加平台录入 + }, + { + title: '严重等级', + dataIndex: 'level', + key: 'level', + showInDetail: true, + render: (text, record, index) => { + const LEVELS_ = ['严重', '中度', '轻微']; + const recordLevels = [] + Object.keys(record?.points?.inspectContent).map(key => { + recordLevels.push(record?.points?.inspectContent[key]?.level) + }) + const level = LEVELS_.find(s => recordLevels.find(x => x == s)) + return level; + } + }, + { + title: '当前状态', + dataIndex: 'state', + key: 'name', + width: '10%', + showInDetail: true, + render: (text, record, index) => { + return !record?.patrolRecordIssueHandles || record?.patrolRecordIssueHandles?.length == 0 ? '待制定计划' : + record?.patrolRecordIssueHandles[0]?.state + } + }, + + + // { + // title: '巡检计划', + // dataIndex: 'name', + // key: 'name', + // width: '10%', + // showInDetail: true, + // render: (text, record, index) => { + // return !record.patrolPlan ? '' :
{record.patrolPlan.name}
+ // } + // }, { + // title: '巡检点位', + // dataIndex: 'type', + // key: 'type', + // showInDetail: true, + // width: '10%', + // render: (text, record, index) => { + // return !record.points?.user ? '' :
{record.points.itemData.name}
+ // } + // }, { + // title: '巡检人', + // dataIndex: 'type', + // key: 'type', + // showInDetail: true, + // width: '10%', + // render: (text, record, index) => { + // return !record.points?.user ? '' :
{record.points.user.name}
+ // } + // }, { + // title: '巡检单位', + // dataIndex: 'type', + // showInDetail: true, + // key: 'type', + // width: '10%', + // render: (text, record, index) => { + // return !record.points?.user ? '' :
{record.points.user.department.name}
+ // } + // }, { + // title: '巡检频次', + // dataIndex: 'describe', + // key: 'describe', + // showInDetail: true, + // width: '10%', + // render: (text, record, index) => { + // return !record.points ? '' :
{record.points.frequency}
+ // } + // }, { + // title: '上次巡检日期', + // dataIndex: 'describe', + // showInDetail: true, + // key: 'describe', + // render: (text, record, index) => record.lastInspectionTime ? moment(record.lastInspectionTime).format('YYYY-MM-DD HH:mm:ss') : '--' + // }, { + // title: '本次巡检日期', + // dataIndex: 'describe', + // key: 'describe', + // showInDetail: true, + // render: (text, record, index) => moment(record.inspectionTime).format('YYYY-MM-DD HH:mm:ss') || '--' + // }, { + // title: '巡检结果', + // dataIndex: 'describe', + // key: 'describe', + // render: (text, record, index) => !record.alarm ? '正常' : '异常' + // }, + { + title: '操作', + dataIndex: 'operation', + key: 'operation', + render: (text, record, index) => { + return ( + {renderOptionText(1)}} + user={{}} + onFinish={onFinish} /> + ) + } } - } ] return ( @@ -158,7 +219,7 @@ const PatrolRecord = (props) => { name="name" style={{ marginRight: 16, minWidth: 250 }} > - + { pagination={{ showSizeChanger: true, pageSizeOptions: [10, 20, 50], - + }} /> - + ) }