From 6a176ffffc4d0e58b738d1f6597b19859271ba17 Mon Sep 17 00:00:00 2001 From: liujiangyong Date: Mon, 16 Jan 2023 22:48:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A1=E6=A3=80=E8=AE=A1=E5=88=92web?= =?UTF-8?q?=E6=A1=86=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/client/src/app.js | 3 +- .../sections/patrolManage/actions/index.js | 7 + .../src/sections/patrolManage/actions/plan.js | 46 ++++++ .../patrolManage/components/userModal.js | 72 ++++++++++ .../sections/patrolManage/containers/index.js | 5 + .../patrolManage/containers/patrolPlan.js | 131 ++++++++++++++++++ web/client/src/sections/patrolManage/index.js | 15 ++ .../src/sections/patrolManage/nav-item.js | 19 +++ .../sections/patrolManage/reducers/index.js | 5 + .../src/sections/patrolManage/routes.js | 17 +++ web/client/src/utils/webapi.js | 4 + 11 files changed, 323 insertions(+), 1 deletion(-) create mode 100644 web/client/src/sections/patrolManage/actions/index.js create mode 100644 web/client/src/sections/patrolManage/actions/plan.js create mode 100644 web/client/src/sections/patrolManage/components/userModal.js create mode 100644 web/client/src/sections/patrolManage/containers/index.js create mode 100644 web/client/src/sections/patrolManage/containers/patrolPlan.js create mode 100644 web/client/src/sections/patrolManage/index.js create mode 100644 web/client/src/sections/patrolManage/nav-item.js create mode 100644 web/client/src/sections/patrolManage/reducers/index.js create mode 100644 web/client/src/sections/patrolManage/routes.js diff --git a/web/client/src/app.js b/web/client/src/app.js index b1073a0..98d351d 100644 --- a/web/client/src/app.js +++ b/web/client/src/app.js @@ -6,6 +6,7 @@ import Auth from './sections/auth'; import Safetymanage from './sections/safetymanage'; import ProjectRegime from './sections/projectRegime'; import Organization from './sections/organization'; +import PatrolManage from './sections/patrolManage'; const App = props => { const { projectName } = props @@ -17,7 +18,7 @@ const App = props => { return ( ) diff --git a/web/client/src/sections/patrolManage/actions/index.js b/web/client/src/sections/patrolManage/actions/index.js new file mode 100644 index 0000000..aaaafe9 --- /dev/null +++ b/web/client/src/sections/patrolManage/actions/index.js @@ -0,0 +1,7 @@ +'use strict'; + +import * as plan from './plan' + +export default { + ...plan, +} \ No newline at end of file diff --git a/web/client/src/sections/patrolManage/actions/plan.js b/web/client/src/sections/patrolManage/actions/plan.js new file mode 100644 index 0000000..cf3d5f8 --- /dev/null +++ b/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: '修改巡检计划失败' }, + }); +} \ No newline at end of file diff --git a/web/client/src/sections/patrolManage/components/userModal.js b/web/client/src/sections/patrolManage/components/userModal.js new file mode 100644 index 0000000..f527e73 --- /dev/null +++ b/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 ( + { + form.resetFields(); + onCancel(); + }} + onOk={() => { + form + .validateFields() + .then((values) => { + form.resetFields(); + onCreate(values); + }) + .catch((info) => { + console.log('Validate Failed:', info); + }); + }} + > +
+ + + + + + + + + +
+
+ ); +}; + +export default UserModal; \ No newline at end of file diff --git a/web/client/src/sections/patrolManage/containers/index.js b/web/client/src/sections/patrolManage/containers/index.js new file mode 100644 index 0000000..4121322 --- /dev/null +++ b/web/client/src/sections/patrolManage/containers/index.js @@ -0,0 +1,5 @@ +'use strict'; + +import PatrolPlan from './patrolPlan'; + +export { PatrolPlan }; \ No newline at end of file diff --git a/web/client/src/sections/patrolManage/containers/patrolPlan.js b/web/client/src/sections/patrolManage/containers/patrolPlan.js new file mode 100644 index 0000000..2c20320 --- /dev/null +++ b/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) =>
+ }, { + title: '巡检次数统计', + dataIndex: 'patrolCount', + key: 'patrolCount', + ellipsis: true, + }, { + title: '操作', + dataIndex: 'action', + key: 'action', + search: false, + render: (_, record) => { + return <> + + + { + dispatch(delPatrolPlan(record.id)).then(res => { + if (res.success) { + tableRef.current.reload(); + } + }) + }}> + + + + }, + }]; + + return ( + <> + { + const res = await dispatch(getPatrolPlan(params)); + console.log(res, 'res') + setDataSource(res?.payload.data?.rows); + return { ...res }; + }} + onReset={() => { }} + toolBarRender={() => [ + + ]} + /> + { + setVisible(false); + }} + /> + + ) +} + +function mapStateToProps(state) { + const { auth } = state + return { + user: auth.user + } +} +export default connect(mapStateToProps)(PatrolPlan); diff --git a/web/client/src/sections/patrolManage/index.js b/web/client/src/sections/patrolManage/index.js new file mode 100644 index 0000000..fe6ee58 --- /dev/null +++ b/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 +}; \ No newline at end of file diff --git a/web/client/src/sections/patrolManage/nav-item.js b/web/client/src/sections/patrolManage/nav-item.js new file mode 100644 index 0000000..51174e4 --- /dev/null +++ b/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 ( + } title={'巡检管理'}> + + 巡检计划制定 + + + ); +} \ No newline at end of file diff --git a/web/client/src/sections/patrolManage/reducers/index.js b/web/client/src/sections/patrolManage/reducers/index.js new file mode 100644 index 0000000..0203d01 --- /dev/null +++ b/web/client/src/sections/patrolManage/reducers/index.js @@ -0,0 +1,5 @@ +'use strict'; + +export default { + +}; \ No newline at end of file diff --git a/web/client/src/sections/patrolManage/routes.js b/web/client/src/sections/patrolManage/routes.js new file mode 100644 index 0000000..e8e874c --- /dev/null +++ b/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: '巡检计划制定', + }] + } +}]; \ No newline at end of file diff --git a/web/client/src/utils/webapi.js b/web/client/src/utils/webapi.js index 8d5e9ff..e09a8a2 100644 --- a/web/client/src/utils/webapi.js +++ b/web/client/src/utils/webapi.js @@ -19,6 +19,10 @@ export const ApiTable = { delUser: 'organization/department/user/{ids}', resetPwd: '/organization/department/user/resetPwd/{id}', + // 巡检计划 + patrolPlan: 'patrolPlan', // 增改查 + delPatrolPlan: 'patrolPlan/{id}', + // 用户权限 getResource: 'resource', getUserResource: 'user/resource',