zhaobing 2 years ago
parent
commit
e488a523f1
  1. 58
      web/client/src/sections/auth/containers/login.js
  2. 35
      web/client/src/sections/fillion/actions/task.js
  3. 152
      web/client/src/sections/fillion/components/task/addTaskModal.js
  4. 3
      web/client/src/sections/fillion/containers/index.js
  5. 186
      web/client/src/sections/fillion/containers/task.js
  6. 3
      web/client/src/sections/fillion/nav-item.js
  7. 9
      web/client/src/sections/fillion/routes.js
  8. 8
      web/client/src/sections/organization/components/userModal.js
  9. 36
      web/client/src/sections/organization/containers/user.js
  10. 9
      web/client/src/utils/webapi.js

58
web/client/src/sections/auth/containers/login.js

@ -50,7 +50,7 @@ const Login = props => {
return return
} }
setInputChanged(false) setInputChanged(false)
dispatch(login("12345678912564589", "123456789")) dispatch(login(username, password))
} }
@ -60,34 +60,36 @@ const Login = props => {
<div className='right'> <div className='right'>
<div className='loginBox'> <div className='loginBox'>
<h1>南昌县智慧交通监管系统</h1> <h1>南昌县智慧交通监管系统</h1>
<Form onKeyDown={enterHandler}> <Form onKeyDown={enterHandler}>
<FormItem> <FormItem>
<div className='loginFormTit'>用户名</div> <div className='loginFormTit'>用户名</div>
<Input <Input
className='loginInp' className='loginInp'
type="text" type="text"
value={username} value={username}
maxlength={11} maxlength={11}
onChange={e => { onChange={e => {
setUserName(e.target.value) console.log('e.target.value', e.target.value)
setInputChanged(true) setUserName(e.target.value)
}} setInputChanged(true)
/> }}
</FormItem> />
<div className='loginFormTit'>密码</div> </FormItem>
<FormItem> <div className='loginFormTit'>密码</div>
<Input <FormItem>
className='loginInp' <Input
type="password" className='loginInp'
value={password} type="password"
value={password}
onChange={e => { onChange={e => {
setPassword(e.target.value) console.log('setPassword', e.target.value)
setInputChanged(true) setPassword(e.target.value)
}} setInputChanged(true)
/> }}
</FormItem> />
</Form> </FormItem>
</Form>
<Button type="primary" className='loginBtn' loading={isRequesting} onClick={handleLogin}>登录</Button> <Button type="primary" className='loginBtn' loading={isRequesting} onClick={handleLogin}>登录</Button>
</div> </div>
</div> </div>

35
web/client/src/sections/fillion/actions/task.js

@ -0,0 +1,35 @@
import { basicAction } from '@peace/utils'
import { ApiTable } from '$utils'
export function getTask(query) {
return dispatch => basicAction({
type: 'get',
dispatch: dispatch,
query: query,
actionType: 'GET_TASK',
url: ApiTable.getTask,
msg: { error: '获取任务信息' },
reducer: { name: 'task' }
});
}
export function delTask(query) {
return dispatch => basicAction({
type: 'del',
dispatch: dispatch,
actionType: 'DEL_TASK',
url: ApiTable.delTask.replace("{taskId}", query?.id),
msg: { option: '删除任务信息' },
});
}
export function editTask(query) {
return dispatch => basicAction({
type: 'put',
dispatch: dispatch,
data: query,
actionType: 'GET_TASK',
url: ApiTable.editTask,
msg: { error: '编辑或新增任务信息' },
});
}

152
web/client/src/sections/fillion/components/task/addTaskModal.js

@ -0,0 +1,152 @@
import React, { useState, useEffect, useRef } from 'react';
import { Modal, Form, Input, Select, Button } from 'antd';
import { connect } from 'react-redux';
import { getRoadway } from '../../actions/infor'
import { getUserList } from '../../actions/patrol';
import { editTask } from '../../actions/task';
const AddModal = (props) => {
const { dispatch, recordRow, visible, onClose, user, lookVal } = props
const { TextArea } = Input
const [form] = Form.useForm()
const [inputVal, setIputVal] = useState(undefined)
const [selectVal, setSelectVal] = useState('')
const [roadRes, setRoadRes] = useState([])//路线列表
const [userList, setUserList] = useState([])//用户列表
useEffect(async () => {
const res = await dispatch(getUserList())
setUserList(res?.payload.data)
}, [true])
const onChange = () => {
form.resetFields(['code'])//清空具体某个表单的值
}
useEffect(() => {
form.setFieldsValue(recordRow ? { 'name': recordRow?.road.routeName, 'code': recordRow?.road.routeCode, 'danger': recordRow?.dangerDescription, 'user': recordRow?.user.name } : {})
}, [recordRow])
useEffect(async () => {
const res = await dispatch(getRoadway({}))
setRoadRes(res?.payload.data)
}, [])
//新增和修改
const handleSaveUpdate = () => {
form.validateFields().then((values) => {
console.log('VALUES', values)
const val = {
routeCode: values.code,
dangerDescription: values.danger,
name: values.user,
id: recordRow?.id
}
dispatch(editTask(val)).then(res => {
if (res.success) {
onClose()
form.resetFields()
}
})
})
}
return (
<Modal visible={visible}
title={lookVal ? '查看' : recordRow ? '编辑任务' : '新增数据'}
onCancel={() => {
onClose()
form.resetFields()//清空所有个表单的值
setSelectVal('')//置空路线代码的选择
}}
onOk={
handleSaveUpdate
}
okButtonProps={{
disabled: lookVal ? true : false,
}}
cancelButtonProps={{
disabled: lookVal ? true : false,
}}
>
<Form form={form}>
<Form.Item
label="路线名称"
name="name"
//initialValues={recordRow?.road.routeName}
rules={[{ required: true, message: '路线名称' }]} >
<Select
disabled={lookVal ? true : false}
allowClear='true'
showSearch
placeholder="请输入关键词"
onChange={(value) => {
console.log('value', value)
onChange()
setSelectVal(value)
}}
filterOption={(input, option) =>
(option?.label ?? '').toLowerCase().includes(input.toLowerCase())
}
options={roadRes?.map((item) => ({
label: item.routeName,
value: item.routeCode
})
)}
/>
</Form.Item>
<Form.Item
label="路线代码"
name="code"
rules={[{ required: true, message: '路线代码' }]}>
<Select
disabled={lookVal ? true : false}
placeholder="请输入关键词"
value={selectVal}
>
<Select.Option key={selectVal}>{selectVal}</Select.Option>
</Select>
</Form.Item>
<Form.Item
label="隐患说明"
name="danger"
rules={[{ required: true, message: '隐患说明' }]}>
<TextArea disabled={lookVal ? true : false} />
</Form.Item>
<Form.Item
label="责任人"
name="user"
rules={[{ required: true, message: '责任人' }]}>
<Select
disabled={lookVal ? true : false}
allowClear='true'
showSearch
placeholder="请输入负责人"
options={userList?.map((item) => ({
label: item.name,
value: item.name
})
)}
/>
</Form.Item>
{lookVal ? <Form.Item
label="下发时间"
name="issuanceTime"
>
<Input disabled={lookVal ? true : false} />
</Form.Item> : ''}
{lookVal ? <Form.Item
label="图片说明"
name="picture"
>
<Input disabled={lookVal ? true : false} />
</Form.Item> : ''}
</Form>
</Modal >
)
}
function mapStateToProps(state) {
const { auth } = state
return {
user: auth.user,
}
}
export default connect(mapStateToProps)(AddModal)

3
web/client/src/sections/fillion/containers/index.js

@ -13,4 +13,5 @@ import Maintenance from './maintenance';
import Patrol from './patrol'; import Patrol from './patrol';
import File from './file'; import File from './file';
import Jiekouguanli from './jiekouguanli'; import Jiekouguanli from './jiekouguanli';
export { Infor,transportation,BridgeTable,HigHways,OperaTional,Enforce,Public,Videois,PromoTional,Maintenance,Patrol,File,Jiekouguanli}; import Task from './task'
export { Infor, transportation, BridgeTable, HigHways, OperaTional, Enforce, Public, Videois, PromoTional, Maintenance, Patrol, File, Jiekouguanli, Task };

186
web/client/src/sections/fillion/containers/task.js

@ -0,0 +1,186 @@
'use strict';
import React, { useState, useEffect } from 'react';
import { connect } from 'react-redux';
import { Button, Table, Spin, Select, Divider, Popconfirm } from 'antd';
import moment from 'moment';
import { debounce } from 'lodash'
import AddModal from '../components/task/addTaskModal';
import { getRoadway } from '../actions/infor'
import { getTask } from '../actions/task'
import { delTask } from '../actions/task'
const Task = (props) => {
const { dispatch, isRequesting } = props
const [addModalVis, setAddModalVis] = useState(false)
const [roadRes, setRoadRes] = useState([])//路线列表
const [selectVal, setSelectVal] = useState('all')//选择框得值
const [inputVal, setIputVal] = useState(undefined)
const [taskRes, setTaskRes] = useState([])
const [recordRow, setRecordRow] = useState(null)
const [lookVal, setLookval] = useState('')
useEffect(async () => {
const res = await dispatch(getRoadway({}))
setRoadRes(res.payload.data)
}, [])
const getData = async (querySelect = { id: inputVal, isdanger: selectVal === 'all' ? undefined : selectVal === 'y' ? true : false }) => {
console.log('getData', inputVal, selectVal)
const task = await dispatch(getTask(querySelect))
setTaskRes(task.payload?.data)
}
useEffect(async () => {
getData()
}, [])
//搜索道路名称
const searchRoadName = async (value) => {
const task = await dispatch(getTask({ id: value, isdanger: selectVal === 'all' ? undefined : selectVal === 'y' ? true : false }))
setTaskRes(task.payload?.data)
setIputVal(value)
}
//选择安全是否消除
const changeSelect = async (value) => {
console.log('value', value)
const task1 = await dispatch(getTask({ id: inputVal, isdanger: value === 'all' ? undefined : value === 'y' ? true : false }))
setTaskRes(task1.payload?.data)
setSelectVal(value)
}
//刪除task
const delTaskHandler = async (record) => {
const res = await dispatch(delTask({ id: record.id }))
if (res.success) {
const task = await getData()
setTaskRes(task.payload?.data)
}
}
//查看
const look = (record) => {
setAddModalVis(true)
setLookval(record)
setRecordRow(record);
}
//配置表格列
const columns = [{
title: '路线名称',
render: (_, record) => {
return <div>{record.road.routeName}</div>
}
},
{
title: '路线代码',
render: (_, record) => {
return <div>{record.road.routeCode}</div>
}
},
{
title: '隐患说明',
dataIndex: 'dangerDescription',
},
{
title: '下发时间',
render: (_, record) => {
return <div>{record.issuanceTime ? moment(record?.issuanceTime).format('YYYY-MM-DD HH:mm:ss') : ''}</div>
}
},
{
title: '责任人',
render: (_, record) => {
return <div>{record.user.name}</div>
}
},
{
title: '是否消除隐患',
render: (_, record) => {
return <div>{record.isdanger === null ? '' : record.isdanger === 'true' ? '是' : '否'}</div>
}
},
{
title: '上报时间',
render: (_, record) => {
return <div>{record.reportTime ? moment(record.reportTime).format('YYYY-MM-DD HH:mm:ss') : ''}</div>
}
},
{
title: '操作',
render: (dom, record) => {
return <div>
{record.reportTime ? <Button type='link' onClick={() => {
setRecordRow(record);
setAddModalVis(true)
}}>编辑</Button> : ''}
<Popconfirm title='确定要删除吗?' onConfirm={() => { delTaskHandler(record) }}><Button type='link'>刪除</Button></Popconfirm>
<Button type='link' onClick={() => { look(record) }}>查看</Button>
</div>
}
},
]
//配置分页
const paginationOpt = {
defaultCurrent: 1,
defaultPageSize: 5,
total: taskRes?.count,
showSizeChanger: true,
showQuickJumper: true,
pageSizeOptions: ["5", "10", "15"],
showTotal: function () {
return `共有${taskRes?.count}`
}
}
return (<div className='taskMenu'>
<div style={{ display: 'flex', flexWrap: ' nowrap', justifyContent: 'space-between' }}>
<div style={{ marginLeft: 20 }}>
路线名称: <Select
allowClear='true'
loading={isRequesting}
showSearch
placeholder="请输入关键词"
//optionFilterProp="children"
onChange={(value) => { searchRoadName(value) }}
//onSearch={(value) => { console.log('11111', value) }}
filterOption={(input, option) =>
(option?.label ?? '').toLowerCase().includes(input.toLowerCase())
}
options={roadRes?.map((item) => ({
label: item.routeName,
value: item.id
})
)}
/>
</div>
<div>
是否存在安全隐患: <Select placeholder='请输入关键词'
options={[{ value: 'all', label: '全部' }, { value: 'y', label: '是' }, { value: 'n', label: '否' }]}
onChange={(value) => { changeSelect(value) }}>
</Select>
</div>
<div >
<Button type='primary' onClick={() => { setRecordRow(null); setAddModalVis(true) }}>新增</Button>
</div>
</div>
<Divider style={{ marginTop: 10 }} />
<Table columns={columns} dataSource={taskRes?.rows} size="small" pagination={paginationOpt}>
</Table>
<AddModal visible={addModalVis} onClose={() => { setAddModalVis(false); getData(); setRecordRow(null); setLookval(null) }} recordRow={recordRow}
lookVal={lookVal}
></AddModal>
</div >)
}
function mapStateToProps(state) {
const { auth } = state;
return {
user: auth.user,
error: auth.error,
isRequesting: auth.isRequesting,
}
}
export default connect(mapStateToProps)(Task);

3
web/client/src/sections/fillion/nav-item.js

@ -9,6 +9,9 @@ export function getNavItem(user, dispatch) {
<Menu.Item key="fillioninfor"> <Menu.Item key="fillioninfor">
<Link to="/fillion/infor">治超管理</Link> <Link to="/fillion/infor">治超管理</Link>
</Menu.Item> </Menu.Item>
<Menu.Item key="filliontask">
<Link to="/fillion/task">任务管理</Link>
</Menu.Item>
<Menu.Item key="filliontransportation"> <Menu.Item key="filliontransportation">
<Link to="/fillion/transportation">道路管理</Link> <Link to="/fillion/transportation">道路管理</Link>
</Menu.Item><Menu.Item key="fillionbridge"> </Menu.Item><Menu.Item key="fillionbridge">

9
web/client/src/sections/fillion/routes.js

@ -11,7 +11,8 @@ import { PromoTional } from './containers';
import { Maintenance } from './containers' import { Maintenance } from './containers'
import { Patrol } from './containers' import { Patrol } from './containers'
import { File } from './containers'; import { File } from './containers';
import {Jiekouguanli} from './containers' import { Jiekouguanli } from './containers'
import { Task } from './containers'
export default [{ export default [{
type: 'inner', type: 'inner',
route: { route: {
@ -26,6 +27,12 @@ export default [{
menuSelectKeys: ['fillioninfor'], menuSelectKeys: ['fillioninfor'],
component: Infor, component: Infor,
breadcrumb: '治超管理', breadcrumb: '治超管理',
}, {
path: '/task',
key: 'filliontask',
menuSelectKeys: ['filliontask'],
component: Task,
breadcrumb: '任务管理',
}, { }, {
path: '/transportation', path: '/transportation',
key: 'filliontransportation', key: 'filliontransportation',

8
web/client/src/sections/organization/components/userModal.js

@ -153,6 +153,14 @@ const UserModal = (props) => {
// defaultChecked // defaultChecked
valuePropName="checked" valuePropName="checked"
/> />
<ProFormSwitch
name={['contract', 'isAdmin']}
width="md"
label="是否管理员"
placeholder="请选择"
// defaultChecked
valuePropName="checked"
/>
</ProForm.Group> </ProForm.Group>
</ModalForm> </ModalForm>
</Spin> </Spin>

36
web/client/src/sections/organization/containers/user.js

@ -11,7 +11,7 @@ import DepModal from '../components/depModal';
const TreeNode = Tree.TreeNode; const TreeNode = Tree.TreeNode;
const UserManage = (props) => { const UserManage = (props) => {
const { dispatch, loading, depMessage, depUser, clientHeight } = props const { dispatch, loading, depMessage, depUser, clientHeight, user } = props
const [modalVisible, setModalVisible] = useState(false); const [modalVisible, setModalVisible] = useState(false);
const [modalType, setModalType] = useState(); const [modalType, setModalType] = useState();
const [modalRecord, setModalRecord] = useState(); const [modalRecord, setModalRecord] = useState();
@ -23,12 +23,17 @@ const UserManage = (props) => {
const [depModalRecord, setDepModalRecord] = useState(); const [depModalRecord, setDepModalRecord] = useState();
const [selectedTree, setSelectedTree] = useState(); const [selectedTree, setSelectedTree] = useState();
const [depCrumbs, setDepCrumbs] = useState([]); const [depCrumbs, setDepCrumbs] = useState([]);
const [depUserCopy, setDepUserCopy] = useState([])//用于存放除了自己的管理的数组,即自己不能调整自己是否为管理员
useEffect(() => { useEffect(() => {
dispatch(getDepMessage()) dispatch(getDepMessage())
}, [])
}, [])
useEffect(() => {
const copy = depUser.filter((item) => {
return item.name !== user//把自己筛选出去
})
setDepUserCopy(copy)
}, [depUser])
useEffect(() => { useEffect(() => {
if (depMessage.length) { if (depMessage.length) {
setDepSelectedKeys([depMessage[0].id]) setDepSelectedKeys([depMessage[0].id])
@ -60,7 +65,15 @@ const UserManage = (props) => {
render: (_, r) => { render: (_, r) => {
return <Switch checkedChildren="启用" unCheckedChildren="禁用" disabled defaultChecked={r.enable} /> return <Switch checkedChildren="启用" unCheckedChildren="禁用" disabled defaultChecked={r.enable} />
} }
}, { },
{
title: '是否管理员',
dataIndex: 'isadmin',
render: (_, r) => {
return <div>{r.isAdmin ? '是' : '否'}</div>
}
},
{
title: '操作', title: '操作',
dataIndex: 'action', dataIndex: 'action',
render: (dom, record) => { render: (dom, record) => {
@ -168,10 +181,10 @@ const UserManage = (props) => {
} }
//部门新增及编辑 //部门新增及编辑
const onDepConfirm = (data) => { const onDepConfirm = (data) => {
console.log('depModalType:',depModalType); console.log('depModalType:', depModalType);
console.log('data:',data); console.log('data:', data);
if (depModalType == 'edit') { if (depModalType == 'edit') {
dispatch(updateDep(data)).then(res => { dispatch(updateDep(data)).then(res => {
if (res.success) { if (res.success) {
setDepModalVisible(false); setDepModalVisible(false);
@ -307,7 +320,7 @@ const UserManage = (props) => {
</Breadcrumb> </Breadcrumb>
<ProTable <ProTable
columns={columns} columns={columns}
dataSource={depUser} dataSource={depUserCopy}
style={{ width: "100% ", height: clientHeight - 95, overflow: "auto" }} style={{ width: "100% ", height: clientHeight - 95, overflow: "auto" }}
rowSelection={{ rowSelection={{
selectedRowKeys: rowSelected, selectedRowKeys: rowSelected,
@ -373,13 +386,14 @@ const UserManage = (props) => {
} }
function mapStateToProps(state) { function mapStateToProps(state) {
const { depMessage, depUser, global } = state; const { depMessage, depUser, global, auth } = state;
// console.log(state); // console.log(state);
return { return {
clientHeight: global.clientHeight, clientHeight: global.clientHeight,
loading: depMessage.isRequesting, loading: depMessage.isRequesting,
depMessage: depMessage.data || [], depMessage: depMessage.data || [],
depUser: depUser.data || [] depUser: depUser.data || [],
user: auth?.user?.name
}; };
} }

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

@ -275,10 +275,13 @@ export const ApiTable = {
getCircuit: 'bus/line', putCircuit: 'bus/line', delCircuit: 'bus/line/{lineId}', getCircuit: 'bus/line', putCircuit: 'bus/line', delCircuit: 'bus/line/{lineId}',
getVehicle: 'bus/car', putVehicle: 'bus/car', delVehicle: 'bus/car/{carId}', getVehicle: 'bus/car', putVehicle: 'bus/car', delVehicle: 'bus/car/{carId}',
//单位概况 //单位概况
getCustodyunit:'/road/maintenance', getCustodyunit: '/road/maintenance',
postCustodyunit:'/road/maintenance', postCustodyunit: '/road/maintenance',
//养护费用 //养护费用
getMaintenance:'/road/maintenance/cost/nanchang/query' getMaintenance: '/road/maintenance/cost/nanchang/query',
//任务信息
getTask: 'task', delTask: 'task/{taskId}', editTask: 'editTask'
}; };

Loading…
Cancel
Save