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

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

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

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

Loading…
Cancel
Save