Browse Source

(*) 检查项删除功能

master
liujiangyong 2 years ago
parent
commit
4c35e45f4c
  1. 6
      api/app/lib/controllers/patrolManage/checkItems.js
  2. 5
      web/client/src/sections/patrolManage/actions/checkItems.js
  3. 3
      web/client/src/sections/patrolManage/components/checkItemsModal.js
  4. 32
      web/client/src/sections/patrolManage/containers/checkItems.js

6
api/app/lib/controllers/patrolManage/checkItems.js

@ -38,8 +38,9 @@ async function createGroup(ctx, next) {
async function getCheckItems(ctx, next) {
try {
const models = ctx.fs.dc.models;
const { limit, page } = ctx.query;
const { limit, page, name } = ctx.query;
let options = {
where: {},
order: [['id', 'asc']],
include: [{
required: true,
@ -47,6 +48,9 @@ async function getCheckItems(ctx, next) {
attributes: ['id', 'name'],
}]
}
if (name) {
options.where.name = { $like: `%${name}%` };
}
if (limit) {
options.limit = Number(limit);
}

5
web/client/src/sections/patrolManage/actions/checkItems.js

@ -24,10 +24,11 @@ export function createCheckItemsGroup(data) {
});
}
export function getCheckItems() {
export function getCheckItems(query) {
return dispatch => basicAction({
type: 'get',
dispatch: dispatch,
query: query,
actionType: 'GET_CHECK_ITEMS',
url: ApiTable.checkItems,
msg: { error: '获取检查项失败' }
@ -61,7 +62,7 @@ export function delCheckItems(ids) {
type: 'del',
dispatch: dispatch,
actionType: 'DEL_CHECK_ITEMS',
url: ApiTable.delUser.replace('{ids}', ids),
url: ApiTable.delCheckItems.replace('{ids}', ids),
msg: { option: '删除检查项' },
});
}

3
web/client/src/sections/patrolManage/components/checkItemsModal.js

@ -2,7 +2,6 @@ import { Button, Form, Input, Modal, Select } from 'antd';
import React, { useState, useEffect } from 'react';
import { connect } from 'react-redux';
import { getCheckItemsGroup } from '../actions/checkItems';
import moment from 'moment';
const CheckItemsModal = ({ visible, onOk, onCancel, curRecord, dispatch }) => {
const [group, setGroup] = useState([]);
@ -50,7 +49,7 @@ const CheckItemsModal = ({ visible, onOk, onCancel, curRecord, dispatch }) => {
name="form_in_modal"
initialValues={{
...curRecord,
userDept: curRecord?.user?.department?.name,
group: curRecord?.check_items_group?.id
}}
>
<Form.Item

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

@ -3,11 +3,10 @@ import { connect } from 'react-redux';
import { Button, Popconfirm } from 'antd';
import ProTable from '@ant-design/pro-table';
import CheckItemsModal from '../components/checkItemsModal';
import { createPatrolPlan, delPatrolPlan, updatePatrolPlan } from '../actions/plan';
import { getCheckItems, createCheckItems, updateCheckItems, createCheckItemsGroup } from '../actions/checkItems';
import { getCheckItems, createCheckItems, updateCheckItems, delCheckItems, createCheckItemsGroup } from '../actions/checkItems';
function CheckItems(props) {
const { dispatch, user } = props;
const { dispatch } = props;
const tableRef = useRef();
const [dataSource, setDataSource] = useState([{}]);
const [visible, setVisible] = useState(false);
@ -45,6 +44,14 @@ function CheckItems(props) {
setVisible(false);
};
function delItems(ids) {
dispatch(delCheckItems(ids)).then(res => {
if (res.success) {
tableRef.current.reload();
}
})
}
const columns = [{
title: '检查项',
dataIndex: 'name',
@ -75,13 +82,7 @@ function CheckItems(props) {
}}>修改</Button>
<Popconfirm
title="确认删除?"
onConfirm={() => {
dispatch(delPatrolPlan(record.id)).then(res => {
if (res.success) {
tableRef.current.reload();
}
})
}}>
onConfirm={() => { delItems(record.id) }}>
<Button type="link" danger>删除</Button>
</Popconfirm>
</>
@ -98,7 +99,11 @@ function CheckItems(props) {
rowKey='id'
pagination={{ pageSize: 10 }}
request={async (params = {}) => {
const res = await dispatch(getCheckItems(params));
const res = await dispatch(getCheckItems({
limit: params.pageSize,
page: params.current - 1,
name: params?.name
}));
setDataSource(res?.payload.data?.rows);
return { ...res };
}}
@ -118,9 +123,10 @@ function CheckItems(props) {
<Button
key="del"
type='primary'
disabled={!select?.length}
onClick={() => {
// const values = searchConfig?.form?.getFieldsValue();
// console.log(values);
const ids = select?.map(s => s.id).join();
delItems(ids);
}}
>批量删除</Button>,
],

Loading…
Cancel
Save