Browse Source

(*) 巡检模板搜索

master
liujiangyong 2 years ago
parent
commit
a40a95f53c
  1. 5
      api/app/lib/controllers/patrolManage/patrolTemplate.js
  2. 3
      web/client/src/sections/patrolManage/actions/template.js
  3. 32
      web/client/src/sections/patrolManage/containers/patrolTemplate.js

5
api/app/lib/controllers/patrolManage/patrolTemplate.js

@ -4,7 +4,7 @@ async function getPatrolTemplate (ctx, next) {
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
const { userId } = ctx.fs.api const { userId } = ctx.fs.api
const { limit, page, id } = ctx.query; const { limit, page, id, name } = ctx.query;
let options = { let options = {
where: {}, where: {},
order: [['id', 'desc']], order: [['id', 'desc']],
@ -22,6 +22,9 @@ async function getPatrolTemplate (ctx, next) {
if (id) { if (id) {
options.where.id = id; options.where.id = id;
} }
if (name) {
options.where.name = { $like: `%${name}%` };
}
if (limit) { if (limit) {
options.limit = Number(limit); options.limit = Number(limit);
} }

3
web/client/src/sections/patrolManage/actions/template.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 getPatrolTemplate () { export function getPatrolTemplate (query) {
return dispatch => basicAction({ return dispatch => basicAction({
type: 'get', type: 'get',
query,
dispatch: dispatch, dispatch: dispatch,
actionType: 'GET_PATROL_TEMPLATE', actionType: 'GET_PATROL_TEMPLATE',
url: ApiTable.patrolTemplate, url: ApiTable.patrolTemplate,

32
web/client/src/sections/patrolManage/containers/patrolTemplate.js

@ -6,7 +6,7 @@ import PlanTemplateModal from '../components/planTemplateModal';
import { createPatrolTemplate, delPatrolTemplate, updatePatrolTemplate, getPatrolTemplate } from '../actions/template'; import { createPatrolTemplate, delPatrolTemplate, updatePatrolTemplate, getPatrolTemplate } from '../actions/template';
import { getCheckItemsGroup } from '../actions/checkItems'; import { getCheckItemsGroup } from '../actions/checkItems';
function PatrolTemplate (props) { function PatrolTemplate(props) {
const { dispatch, user } = props; const { dispatch, user } = props;
const tableRef = useRef(); const tableRef = useRef();
const [dataSource, setDataSource] = useState([{}]); const [dataSource, setDataSource] = useState([{}]);
@ -27,12 +27,14 @@ function PatrolTemplate (props) {
title: '模板描述', title: '模板描述',
dataIndex: 'describe', dataIndex: 'describe',
key: 'describe', key: 'describe',
ellipsis: true ellipsis: true,
search: false,
}, { }, {
title: '操作人', title: '操作人',
dataIndex: 'user.name', dataIndex: 'user.name',
key: 'user.name', key: 'user.name',
ellipsis: true, ellipsis: true,
search: false,
render: (t, r, i) => { render: (t, r, i) => {
return r.user ? r.user.name : '-' return r.user ? r.user.name : '-'
} }
@ -41,6 +43,7 @@ function PatrolTemplate (props) {
dataIndex: 'checkItems', dataIndex: 'checkItems',
key: 'checkItems', key: 'checkItems',
ellipsis: true, ellipsis: true,
search: false,
render: (_, r) => { render: (_, r) => {
return r?.checkItems ? r?.checkItems.map(c => <Tag>{c.name}</Tag>) : '-' return r?.checkItems ? r?.checkItems.map(c => <Tag>{c.name}</Tag>) : '-'
} }
@ -81,14 +84,10 @@ function PatrolTemplate (props) {
dataSource={dataSource || []} dataSource={dataSource || []}
rowKey='id' rowKey='id'
pagination={{ pageSize: 10 }} pagination={{ pageSize: 10 }}
search={false} search={{
request={async (params = {}) => { defaultCollapsed: false,
const res = await dispatch(getPatrolTemplate(params)); optionRender: (searchConfig, formProps, dom) => [
setDataSource(res?.payload.data?.rows); ...dom.reverse(),
return { ...res };
}}
onReset={() => { }}
toolBarRender={() => [
<Button <Button
type="primary" type="primary"
key="primary" key="primary"
@ -96,8 +95,15 @@ function PatrolTemplate (props) {
setType('create') setType('create')
setVisible(true) setVisible(true)
}} }}
>新增巡检模板</Button> >新增巡检模板</Button>,
]} ],
}}
request={async (params = {}) => {
const res = await dispatch(getPatrolTemplate(params));
setDataSource(res?.payload.data?.rows);
return { ...res };
}}
onReset={() => { }}
/> />
{ {
visible ? visible ?
@ -116,7 +122,7 @@ function PatrolTemplate (props) {
) )
} }
function mapStateToProps (state) { function mapStateToProps(state) {
const { auth } = state const { auth } = state
return { return {
user: auth.user user: auth.user

Loading…
Cancel
Save