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

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

@ -3,9 +3,10 @@
import { basicAction } from '@peace/utils'
import { ApiTable } from '$utils'
export function getPatrolPlan() {
export function getPatrolPlan(query) {
return dispatch => basicAction({
type: 'get',
query,
dispatch: dispatch,
actionType: 'GET_PATROL_PLAN',
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 moment from 'moment';
function PatrolPlan (props) {
function PatrolPlan(props) {
const { dispatch, user } = props;
const tableRef = useRef();
const [dataSource, setDataSource] = useState([{}]);
@ -39,8 +39,8 @@ function PatrolPlan (props) {
const columns = [{
title: '结构物名称',
dataIndex: 'struName',
key: 'struName',
dataIndex: 'projectName',
key: 'projectName',
ellipsis: true,
render: (_, record) => {
return <div>{record?.project?.name}</div>
@ -55,36 +55,41 @@ function PatrolPlan (props) {
dataIndex: 'startTime',
key: 'startTime',
ellipsis: true,
search: false,
render: (_, record) => moment(record.startTime).format('YYYY-MM-DD')
}, {
title: '结束时间',
dataIndex: 'endTime',
key: 'endTime',
ellipsis: true,
search: false,
render: (_, record) => moment(record.endTime).format('YYYY-MM-DD')
}, {
title: '巡检频次',
dataIndex: 'frequency',
key: 'frequency',
ellipsis: true,
search: false,
}, {
title: '巡检点位',
dataIndex: 'patrolPoints',
key: 'patrolPoints',
ellipsis: true,
search: false,
render: (_, record) => <div>{record?.points?.length ? record?.points?.map(p => p.name).join() : '-'}</div>
}, {
title: '巡检人',
dataIndex: 'patrolPerson',
key: 'patrolPerson',
ellipsis: true,
search: false,
render: (_, record) => <div>{record?.users?.map(u => u.name).join()}</div>
}, {
title: '巡检次数统计',
dataIndex: 'patrolCount',
key: 'patrolCount',
ellipsis: true,
search: false,
}, {
title: '操作',
dataIndex: 'action',
@ -127,23 +132,27 @@ function PatrolPlan (props) {
dataSource={dataSource || []}
rowKey='id'
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 = {}) => {
const res = await dispatch(getPatrolPlan(params));
setDataSource(res?.payload.data?.rows);
return { ...res };
}}
onReset={() => { }}
toolBarRender={() => [
<Button
type="primary"
key="primary"
onClick={() => {
setType('create')
setVisible(true)
}}
>新增巡检计划</Button>
]}
/>
{
visible ?
@ -162,7 +171,7 @@ function PatrolPlan (props) {
)
}
function mapStateToProps (state) {
function mapStateToProps(state) {
const { auth } = state
return {
user: auth.user

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

@ -1,6 +1,6 @@
import React, { useEffect, useState } from 'react';
import { connect } from 'react-redux';
import { Button, Table, Popconfirm } from 'antd';
import { Button, Table, Popconfirm, Input } from 'antd';
import '../style.less';
import PointModel from '../components/pointModel'
@ -17,6 +17,8 @@ const Information = (props) => {
const [select, setSelect] = useState([])
const [selec, setSelec] = useState()
const [qrCodeingIds, setQrCodeingIds] = useState(null)
const [searchTableList, setSearchTableList] = useState([])
const [name, setName] = useState('')
const qrCodeId = props?.match?.params?.id
@ -35,6 +37,7 @@ const Information = (props) => {
})
})
settableList(data?.map(v => ({ ...v, key: v.id })))
setSearchTableList(data?.map(v => ({ ...v, key: v.id })))
setLimits(res.payload.data?.count)
}
})
@ -128,14 +131,18 @@ const Information = (props) => {
})
}
}} 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>
<Table
columns={columns}
dataSource={tableList}
dataSource={searchTableList}
pagination={{
current: query.page + 1,
total: limits,
// current: query.page + 1,
// total: limits,
showSizeChanger: true,
showQuickJumper: true,
pageSizeOptions: [10, 20, 50],

Loading…
Cancel
Save