Browse Source

巡检计划&点位搜索

master
liujiangyong 2 years ago
parent
commit
bdcd74f094
  1. 10
      api/app/lib/controllers/patrolManage/patrolPlan.js
  2. 3
      web/client/src/sections/patrolManage/actions/plan.js
  3. 41
      web/client/src/sections/patrolManage/containers/patrolPlan.js
  4. 15
      web/client/src/sections/projectRegime/containers/point.js

10
api/app/lib/controllers/patrolManage/patrolPlan.js

@ -4,9 +4,10 @@ const moment = require('moment');
async function getPatrolPlan (ctx, next) { async function getPatrolPlan (ctx, next) {
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
const { limit, page, userId } = ctx.query; const { limit, page, userId, name, projectName } = ctx.query;
let where = {} let where = {}
let userWhere = {}; let userWhere = {};
let projectWhere = {};
let options = { let options = {
order: [['id', 'desc']], order: [['id', 'desc']],
where, where,
@ -22,9 +23,16 @@ async function getPatrolPlan (ctx, next) {
}, { }, {
model: models.Project, model: models.Project,
attributes: ['id', 'name'], attributes: ['id', 'name'],
where: projectWhere,
}], }],
distinct: true, distinct: true,
}; };
if (name) {
options.where.name = { $like: `%${name}%` };
}
if (projectName) {
projectWhere.name = { $like: `%${projectName}%` };
}
if (limit) { if (limit) {
options.limit = Number(limit); options.limit = Number(limit);
} }

3
web/client/src/sections/patrolManage/actions/plan.js

@ -3,9 +3,10 @@
import { basicAction } from '@peace/utils' import { basicAction } from '@peace/utils'
import { ApiTable } from '$utils' import { ApiTable } from '$utils'
export function getPatrolPlan() { export function getPatrolPlan(query) {
return dispatch => basicAction({ return dispatch => basicAction({
type: 'get', type: 'get',
query,
dispatch: dispatch, dispatch: dispatch,
actionType: 'GET_PATROL_PLAN', actionType: 'GET_PATROL_PLAN',
url: ApiTable.patrolPlan, url: ApiTable.patrolPlan,

41
web/client/src/sections/patrolManage/containers/patrolPlan.js

@ -7,7 +7,7 @@ import { createPatrolPlan, delPatrolPlan, updatePatrolPlan, getPatrolPlan } from
import { getPatrolTemplate } from '../actions/template'; import { getPatrolTemplate } from '../actions/template';
import moment from 'moment'; import moment from 'moment';
function PatrolPlan (props) { function PatrolPlan(props) {
const { dispatch, user } = props; const { dispatch, user } = props;
const tableRef = useRef(); const tableRef = useRef();
const [dataSource, setDataSource] = useState([{}]); const [dataSource, setDataSource] = useState([{}]);
@ -39,8 +39,8 @@ function PatrolPlan (props) {
const columns = [{ const columns = [{
title: '结构物名称', title: '结构物名称',
dataIndex: 'struName', dataIndex: 'projectName',
key: 'struName', key: 'projectName',
ellipsis: true, ellipsis: true,
render: (_, record) => { render: (_, record) => {
return <div>{record?.project?.name}</div> return <div>{record?.project?.name}</div>
@ -55,36 +55,41 @@ function PatrolPlan (props) {
dataIndex: 'startTime', dataIndex: 'startTime',
key: 'startTime', key: 'startTime',
ellipsis: true, ellipsis: true,
search: false,
render: (_, record) => moment(record.startTime).format('YYYY-MM-DD') render: (_, record) => moment(record.startTime).format('YYYY-MM-DD')
}, { }, {
title: '结束时间', title: '结束时间',
dataIndex: 'endTime', dataIndex: 'endTime',
key: 'endTime', key: 'endTime',
ellipsis: true, ellipsis: true,
search: false,
render: (_, record) => moment(record.endTime).format('YYYY-MM-DD') render: (_, record) => moment(record.endTime).format('YYYY-MM-DD')
}, { }, {
title: '巡检频次', title: '巡检频次',
dataIndex: 'frequency', dataIndex: 'frequency',
key: 'frequency', key: 'frequency',
ellipsis: true, ellipsis: true,
search: false,
}, { }, {
title: '巡检点位', title: '巡检点位',
dataIndex: 'patrolPoints', dataIndex: 'patrolPoints',
key: 'patrolPoints', key: 'patrolPoints',
ellipsis: true, ellipsis: true,
search: false,
render: (_, record) => <div>{record?.points?.length ? record?.points?.map(p => p.name).join() : '-'}</div> render: (_, record) => <div>{record?.points?.length ? record?.points?.map(p => p.name).join() : '-'}</div>
}, { }, {
title: '巡检人', title: '巡检人',
dataIndex: 'patrolPerson', dataIndex: 'patrolPerson',
key: 'patrolPerson', key: 'patrolPerson',
ellipsis: true, ellipsis: true,
search: false,
render: (_, record) => <div>{record?.users?.map(u => u.name).join()}</div> render: (_, record) => <div>{record?.users?.map(u => u.name).join()}</div>
}, { }, {
title: '巡检次数统计', title: '巡检次数统计',
dataIndex: 'patrolCount', dataIndex: 'patrolCount',
key: 'patrolCount', key: 'patrolCount',
ellipsis: true, ellipsis: true,
search: false,
}, { }, {
title: '操作', title: '操作',
dataIndex: 'action', dataIndex: 'action',
@ -127,23 +132,27 @@ function PatrolPlan (props) {
dataSource={dataSource || []} dataSource={dataSource || []}
rowKey='id' rowKey='id'
pagination={{ pageSize: 10 }} pagination={{ pageSize: 10 }}
search={false} search={{
defaultCollapsed: false,
labelWidth: 'auto',
optionRender: (searchConfig, formProps, dom) => [
...dom.reverse(),
<Button
type="primary"
key="primary"
onClick={() => {
setType('create')
setVisible(true)
}}
>新增巡检计划</Button>,
],
}}
request={async (params = {}) => { request={async (params = {}) => {
const res = await dispatch(getPatrolPlan(params)); const res = await dispatch(getPatrolPlan(params));
setDataSource(res?.payload.data?.rows); setDataSource(res?.payload.data?.rows);
return { ...res }; return { ...res };
}} }}
onReset={() => { }} onReset={() => { }}
toolBarRender={() => [
<Button
type="primary"
key="primary"
onClick={() => {
setType('create')
setVisible(true)
}}
>新增巡检计划</Button>
]}
/> />
{ {
visible ? visible ?
@ -162,7 +171,7 @@ function PatrolPlan (props) {
) )
} }
function mapStateToProps (state) { function mapStateToProps(state) {
const { auth } = state const { auth } = state
return { return {
user: auth.user user: auth.user

15
web/client/src/sections/projectRegime/containers/point.js

@ -1,6 +1,6 @@
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { Button, Table, Popconfirm } from 'antd'; import { Button, Table, Popconfirm, Input } from 'antd';
import '../style.less'; import '../style.less';
import PointModel from '../components/pointModel' import PointModel from '../components/pointModel'
@ -17,6 +17,8 @@ const Information = (props) => {
const [select, setSelect] = useState([]) const [select, setSelect] = useState([])
const [selec, setSelec] = useState() const [selec, setSelec] = useState()
const [qrCodeingIds, setQrCodeingIds] = useState(null) const [qrCodeingIds, setQrCodeingIds] = useState(null)
const [searchTableList, setSearchTableList] = useState([])
const [name, setName] = useState('')
const qrCodeId = props?.match?.params?.id const qrCodeId = props?.match?.params?.id
@ -35,6 +37,7 @@ const Information = (props) => {
}) })
}) })
settableList(data?.map(v => ({ ...v, key: v.id }))) settableList(data?.map(v => ({ ...v, key: v.id })))
setSearchTableList(data?.map(v => ({ ...v, key: v.id })))
setLimits(res.payload.data?.count) setLimits(res.payload.data?.count)
} }
}) })
@ -128,14 +131,18 @@ const Information = (props) => {
}) })
} }
}} disabled={qrCodeingIds?.length}>一键生成二维码</Button> }} disabled={qrCodeingIds?.length}>一键生成二维码</Button>
<Input style={{ width: 300, margin: '0px 20px' }} placeholder="请输入点位名称" onChange={(e) => { setName(e.target.value) }} />
<Button type="primary" onClick={() => {
setSearchTableList(tableList?.filter(l => l.name?.includes(name)))
}}>搜索</Button>
</div> </div>
<Table <Table
columns={columns} columns={columns}
dataSource={tableList} dataSource={searchTableList}
pagination={{ pagination={{
current: query.page + 1, // current: query.page + 1,
total: limits, // total: limits,
showSizeChanger: true, showSizeChanger: true,
showQuickJumper: true, showQuickJumper: true,
pageSizeOptions: [10, 20, 50], pageSizeOptions: [10, 20, 50],

Loading…
Cancel
Save