liujiangyong
2 years ago
11 changed files with 323 additions and 1 deletions
@ -0,0 +1,7 @@ |
|||
'use strict'; |
|||
|
|||
import * as plan from './plan' |
|||
|
|||
export default { |
|||
...plan, |
|||
} |
@ -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: '修改巡检计划失败' }, |
|||
}); |
|||
} |
@ -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; |
@ -0,0 +1,5 @@ |
|||
'use strict'; |
|||
|
|||
import PatrolPlan from './patrolPlan'; |
|||
|
|||
export { PatrolPlan }; |
@ -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); |
@ -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 |
|||
}; |
@ -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> |
|||
); |
|||
} |
@ -0,0 +1,5 @@ |
|||
'use strict'; |
|||
|
|||
export default { |
|||
|
|||
}; |
@ -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: '巡检计划制定', |
|||
}] |
|||
} |
|||
}]; |
Loading…
Reference in new issue