Browse Source

巡检计划web框架

master
liujiangyong 2 years ago
parent
commit
6a176ffffc
  1. 3
      web/client/src/app.js
  2. 7
      web/client/src/sections/patrolManage/actions/index.js
  3. 46
      web/client/src/sections/patrolManage/actions/plan.js
  4. 72
      web/client/src/sections/patrolManage/components/userModal.js
  5. 5
      web/client/src/sections/patrolManage/containers/index.js
  6. 131
      web/client/src/sections/patrolManage/containers/patrolPlan.js
  7. 15
      web/client/src/sections/patrolManage/index.js
  8. 19
      web/client/src/sections/patrolManage/nav-item.js
  9. 5
      web/client/src/sections/patrolManage/reducers/index.js
  10. 17
      web/client/src/sections/patrolManage/routes.js
  11. 4
      web/client/src/utils/webapi.js

3
web/client/src/app.js

@ -6,6 +6,7 @@ import Auth from './sections/auth';
import Safetymanage from './sections/safetymanage'; import Safetymanage from './sections/safetymanage';
import ProjectRegime from './sections/projectRegime'; import ProjectRegime from './sections/projectRegime';
import Organization from './sections/organization'; import Organization from './sections/organization';
import PatrolManage from './sections/patrolManage';
const App = props => { const App = props => {
const { projectName } = props const { projectName } = props
@ -17,7 +18,7 @@ const App = props => {
return ( return (
<Layout <Layout
title={projectName} title={projectName}
sections={[Auth, ProjectRegime, Safetymanage, Organization]} sections={[Auth, ProjectRegime, Safetymanage, Organization, PatrolManage]}
/> />
) )

7
web/client/src/sections/patrolManage/actions/index.js

@ -0,0 +1,7 @@
'use strict';
import * as plan from './plan'
export default {
...plan,
}

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

@ -0,0 +1,46 @@
'use strict';
import { basicAction } from '@peace/utils'
import { ApiTable } from '$utils'
export function getPatrolPlan() {
return dispatch => basicAction({
type: 'get',
dispatch: dispatch,
actionType: 'GET_PATROL_PLAN',
url: ApiTable.patrolPlan,
msg: { error: '获取巡检计划失败' },
});
}
export function createPatrolPlan(data) {
return dispatch => basicAction({
type: 'post',
data,
dispatch: dispatch,
actionType: 'CREATE_PATROL_PLAN',
url: ApiTable.patrolPlan,
msg: { error: '新增巡检计划失败' },
});
}
export function delPatrolPlan(id) {
return dispatch => basicAction({
type: 'del',
dispatch: dispatch,
actionType: 'DEL_PATROL_PLAN',
url: ApiTable.delPatrolPlan.replace('{id}', id),
msg: { error: '删除巡检计划失败' },
});
}
export function updatePatrolPlan(data) {
return dispatch => basicAction({
type: 'put',
data,
dispatch: dispatch,
actionType: 'UPDATE_PATROL_PLAN',
url: ApiTable.patrolPlan,
msg: { error: '修改巡检计划失败' },
});
}

72
web/client/src/sections/patrolManage/components/userModal.js

@ -0,0 +1,72 @@
import { Button, Form, Input, Modal } from 'antd';
import React, { useState } from 'react';
const UserModal = ({ visible, onCreate, onCancel }) => {
const [form] = Form.useForm();
const reg_tel = /^1([358][0-9]|4[579]|66|7[0135678]|9[89])[0-9]{8}$/;
return (
<Modal
visible={visible}
title="新建用户"
okText="新建"
cancelText="取消"
onCancel={() => {
form.resetFields();
onCancel();
}}
onOk={() => {
form
.validateFields()
.then((values) => {
form.resetFields();
onCreate(values);
})
.catch((info) => {
console.log('Validate Failed:', info);
});
}}
>
<Form
form={form}
layout="vertical"
name="form_in_modal"
initialValues={{
modifier: 'public',
}}
>
<Form.Item
name="name"
label="姓名"
rules={[
{ required: true, message: '请输入姓名' },
{ max: 24, message: '姓名不能大于24个字符' },
]}
>
<Input />
</Form.Item>
<Form.Item
name="phone"
label="用户名(手机号)"
rules={[
{ required: true, message: '请输入正确的手机号' },
{ pattern: reg_tel, message: '请输入正确的手机号' },
]}
>
<Input />
</Form.Item>
<Form.Item
name="password"
label="密码"
rules={[
{ required: true, message: '请填写密码' },
{ min: 6, message: '请填写至少6位密码' },
]}
>
<Input type="password" />
</Form.Item>
</Form>
</Modal>
);
};
export default UserModal;

5
web/client/src/sections/patrolManage/containers/index.js

@ -0,0 +1,5 @@
'use strict';
import PatrolPlan from './patrolPlan';
export { PatrolPlan };

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

@ -0,0 +1,131 @@
import React, { useState, useRef } from 'react';
import { connect } from 'react-redux';
import { Button, Popconfirm } from 'antd';
import ProTable from '@ant-design/pro-table';
import UserModal from '../components/userModal';
import { createPatrolPlan, delPatrolPlan, updatePatrolPlan, getPatrolPlan } from '../actions/plan';
function PatrolPlan(props) {
const { dispatch, user } = props;
const tableRef = useRef();
const [dataSource, setDataSource] = useState([{}]);
const [visible, setVisible] = useState(false);
const onCreate = (values) => {
console.log(values, 'values')
// dispatch(createEarthquakeUser(values)).then(res => {
// if (res.success) {
// tableRef.current.reload();
// }
// })
// setVisible(false);
};
const columns = [{
title: '结构物名称',
dataIndex: 'struName',
key: 'struName',
ellipsis: true
}, {
title: '巡检任务名称',
dataIndex: 'name',
key: 'name',
ellipsis: true
}, {
title: '开始时间',
dataIndex: 'startTime',
key: 'startTime',
ellipsis: true,
}, {
title: '结束时间',
dataIndex: 'endTime',
key: 'endTime',
ellipsis: true,
}, {
title: '巡检频次',
dataIndex: 'frequency',
key: 'frequency',
ellipsis: true,
}, {
title: '巡检点位',
dataIndex: 'patrolPoints',
key: 'patrolPoints',
ellipsis: true,
}, {
title: '巡检人',
dataIndex: 'patrolPerson',
key: 'patrolPerson',
ellipsis: true,
render: (_, record) => <div></div>
}, {
title: '巡检次数统计',
dataIndex: 'patrolCount',
key: 'patrolCount',
ellipsis: true,
}, {
title: '操作',
dataIndex: 'action',
key: 'action',
search: false,
render: (_, record) => {
return <>
<Button type="link">修改</Button>
<Button type="link">查看</Button>
<Popconfirm
title="确认删除?"
onConfirm={() => {
dispatch(delPatrolPlan(record.id)).then(res => {
if (res.success) {
tableRef.current.reload();
}
})
}}>
<Button type="link" danger>删除</Button>
</Popconfirm>
</>
},
}];
return (
<>
<ProTable
columns={columns}
actionRef={tableRef}
options={false}
dataSource={dataSource || []}
rowKey='id'
pagination={{ pageSize: 10 }}
search={false}
request={async (params = {}) => {
const res = await dispatch(getPatrolPlan(params));
console.log(res, 'res')
setDataSource(res?.payload.data?.rows);
return { ...res };
}}
onReset={() => { }}
toolBarRender={() => [
<Button
type="primary"
key="primary"
onClick={() => { setVisible(true) }}
>新增巡检计划</Button>
]}
/>
<UserModal
visible={visible}
onCreate={onCreate}
onCancel={() => {
setVisible(false);
}}
/>
</>
)
}
function mapStateToProps(state) {
const { auth } = state
return {
user: auth.user
}
}
export default connect(mapStateToProps)(PatrolPlan);

15
web/client/src/sections/patrolManage/index.js

@ -0,0 +1,15 @@
'use strict';
import reducers from './reducers';
import routes from './routes';
import actions from './actions';
import { getNavItem } from './nav-item';
export default {
key: 'patrolManage',
name: '',
reducers: reducers,
routes: routes,
actions: actions,
getNavItem: getNavItem
};

19
web/client/src/sections/patrolManage/nav-item.js

@ -0,0 +1,19 @@
import React from 'react';
import { Link } from 'react-router-dom';
import { Menu } from 'antd';
import { SettingOutlined } from '@ant-design/icons';
const SubMenu = Menu.SubMenu;
export function getNavItem(user, dispatch) {
// if (!Func.isAuthorized("ORG_MANAGE")) {
// return null
// }
return (
<SubMenu key="patrolManage" icon={<SettingOutlined />} title={'巡检管理'}>
<Menu.Item key="patrolPlan">
<Link to="/patrolManage/patrolPlan">巡检计划制定</Link>
</Menu.Item>
</SubMenu>
);
}

5
web/client/src/sections/patrolManage/reducers/index.js

@ -0,0 +1,5 @@
'use strict';
export default {
};

17
web/client/src/sections/patrolManage/routes.js

@ -0,0 +1,17 @@
'use strict';
import { PatrolPlan } from './containers';
export default [{
type: 'inner',
route: {
path: '/patrolManage',
key: 'patrolManage',
breadcrumb: '巡检管理',
childRoutes: [{
path: '/patrolPlan',
key: 'patrolPlan',
component: PatrolPlan,
breadcrumb: '巡检计划制定',
}]
}
}];

4
web/client/src/utils/webapi.js

@ -19,6 +19,10 @@ export const ApiTable = {
delUser: 'organization/department/user/{ids}', delUser: 'organization/department/user/{ids}',
resetPwd: '/organization/department/user/resetPwd/{id}', resetPwd: '/organization/department/user/resetPwd/{id}',
// 巡检计划
patrolPlan: 'patrolPlan', // 增改查
delPatrolPlan: 'patrolPlan/{id}',
// 用户权限 // 用户权限
getResource: 'resource', getResource: 'resource',
getUserResource: 'user/resource', getUserResource: 'user/resource',

Loading…
Cancel
Save