diff --git a/api/app/lib/controllers/auth/index.js b/api/app/lib/controllers/auth/index.js index e501c0a9..e77ad9b0 100644 --- a/api/app/lib/controllers/auth/index.js +++ b/api/app/lib/controllers/auth/index.js @@ -20,6 +20,10 @@ async function login(ctx, next) { delete: false, }, attributes: { exclude: ['password', 'delete'] }, + include: [{ + attributes: ["resourceId", "isshow"], + model: models.UserResource + }] }); console.log('userRes', userRes) if (!userRes.isAdmin) { diff --git a/api/app/lib/controllers/organization/authority.js b/api/app/lib/controllers/organization/authority.js new file mode 100644 index 00000000..229b702a --- /dev/null +++ b/api/app/lib/controllers/organization/authority.js @@ -0,0 +1,122 @@ +async function getResource(ctx, next) { + try { + const models = ctx.fs.dc.models; + console.log('models.Resource', models.Resource) + const res = await models.Resource.findAll({ + + where: { parentResource: null }, + include: [{ + model: models.Resource, + }], + }) + + ctx.body = res; + ctx.status = 200; + + } catch (error) { + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); + ctx.status = 400; + ctx.body = { + "message": "查询所有权限数据失败" + } + } +} +async function getUserResource(ctx, next) { + try { + const models = ctx.fs.dc.models; + const { userId } = ctx.query; + + const res = await models.UserResource.findAll({ + where: { userId: userId }, + include: [{ + model: models.Resource, + }] + }) + + ctx.body = res; + ctx.status = 200; + + } catch (error) { + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); + ctx.status = 400; + ctx.body = { + "message": "查询用户权限数据失败" + } + } +} + +async function updateUserRes(ctx, next) { + const transaction = await ctx.fs.dc.orm.transaction(); + try { + const models = ctx.fs.dc.models; + const { userId, resCode, isShow } = ctx.request.body; + console.log('isShow1', ctx.request.body) + + const res = await models.UserResource.findAll({ + attributes: ["resourceId"], + raw: true, + where: { userId: userId } + }) + + const addRes = resCode.filter(r => !res.some(rr => rr.resourceId == r)).map(r => { return { userId: userId, resourceId: r, isShow: isShow } }); + const delRes = res.filter(r => !resCode.includes(r.resourceId)).map(r => r.resourceId); + addRes.length && await models.UserResource.bulkCreate(addRes, { transaction: transaction }); + delRes.length && await models.UserResource.destroy({ + where: { + resourceId: { $in: delRes }, + userId: userId + }, + transaction: transaction + }) + // await models.UserResource.update({ + // isShow: isShow + + // }, { + // where: { + // userId: userId + // } + // }) + ctx.status = 204; + await transaction.commit(); + + } catch (error) { + await transaction.rollback(); + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); + ctx.status = 400; + ctx.body = { + "message": "更新用户权限数据失败" + } + } +} + +async function editeUserRes(ctx, next) { + const transaction = await ctx.fs.dc.orm.transaction() + await transaction.commit() + try { + const models = ctx.fs.dc.models; + const { userId, isShow } = ctx.request.body + console.log('ctx.request.body1', ctx.request.body) + await models.UserResource.update({ + isshow: isShow + }, { + where: { + userId: userId + } + }) + ctx.status = 204; + + } catch (error) { + await transaction.rollback() + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); + ctx.status = 400; + ctx.body = { + "message": "更新用户权限数据失败" + } + } +} +module.exports = { + getResource, + getUserResource, + updateUserRes, + editeUserRes +}; \ No newline at end of file diff --git a/api/app/lib/controllers/organization/department.js b/api/app/lib/controllers/organization/department.js index f6e64304..7b72e096 100644 --- a/api/app/lib/controllers/organization/department.js +++ b/api/app/lib/controllers/organization/department.js @@ -1,6 +1,6 @@ 'use strict'; -async function getdep (ctx) { +async function getdep(ctx) { try { const { fs: { api: { userInfo } } } = ctx const models = ctx.fs.dc.models; @@ -49,10 +49,11 @@ async function getdep (ctx) { } } -async function editDep (ctx) { +async function editDep(ctx) { try { const models = ctx.fs.dc.models; - const { depId, name, dependence } = ctx.request.body; + const { depId, name, dependence, areaCode, area } = ctx.request.body + //console.log(ctx.request.body, '111111wed') if (dependence) { let dep = await models.Department.findOne({ where: { @@ -79,6 +80,7 @@ async function editDep (ctx) { await models.Department.update({ name: name, dependence: dependence || null, + areaCode: areaCode || null }, { where: { id: depId @@ -99,6 +101,7 @@ async function editDep (ctx) { name: name, delete: false, dependence: dependence || null, + areaCode: area || null }) } ctx.status = 204; @@ -111,7 +114,7 @@ async function editDep (ctx) { } } -async function delDep (ctx) { +async function delDep(ctx) { const transaction = await ctx.fs.dc.orm.transaction(); try { const models = ctx.fs.dc.models; diff --git a/api/app/lib/index.js b/api/app/lib/index.js index 6349db80..a0fe0492 100644 --- a/api/app/lib/index.js +++ b/api/app/lib/index.js @@ -26,7 +26,7 @@ module.exports.models = function (dc) { // dc = { orm: Sequelize对象, ORM: Seq require(`./models/${filename}`)(dc) }); - const { User, Department, Report, FileType, Road, Files, FileRoad, TaskManage } = dc.models; + const { User, Department, Report, FileType, Road, Files, FileRoad, TaskManage, UserResource, Resource } = dc.models; // 定义外键 User.belongsTo(Department, { foreignKey: 'departmentId', targetKey: 'id' }); Department.hasMany(User, { foreignKey: 'departmentId', sourceKey: 'id' }); @@ -46,4 +46,14 @@ module.exports.models = function (dc) { // dc = { orm: Sequelize对象, ORM: Seq // TaskManage.belongsTo(Road, { foreignKey: 'roadid', targetKey: 'id' }) Road.hasMany(TaskManage, { foreignKey: 'roadid', targetKey: 'id' }) + + UserResource.belongsTo(User, { foreignKey: 'userId', targetKey: 'id' }); + User.hasMany(UserResource, { foreignKey: 'userId', sourceKey: 'id' }); + + UserResource.belongsTo(Resource, { foreignKey: 'resourceId', targetKey: 'code' }); + Resource.hasMany(UserResource, { foreignKey: 'resourceId', sourceKey: 'code' }); + Resource.hasMany(Resource, { foreignKey: 'parentResource', sourceKey: 'code' }); + }; + + diff --git a/api/app/lib/models/department.js b/api/app/lib/models/department.js index e01b417a..6f8c07c9 100644 --- a/api/app/lib/models/department.js +++ b/api/app/lib/models/department.js @@ -41,7 +41,16 @@ module.exports = dc => { primaryKey: false, field: "delete", autoIncrement: false - } + }, + areaCode: { + type: DataTypes.STRING, + allowNull: true, + defaultValue: null, + comment: '所属区域代码', + primaryKey: false, + field: "area_code", + autoIncrement: false + }, }, { tableName: "department", comment: "", diff --git a/api/app/lib/models/resource.js b/api/app/lib/models/resource.js new file mode 100644 index 00000000..c6e209a0 --- /dev/null +++ b/api/app/lib/models/resource.js @@ -0,0 +1,43 @@ +/* eslint-disable*/ + +'use strict'; + +module.exports = dc => { + const DataTypes = dc.ORM; + const sequelize = dc.orm; + const Resource = sequelize.define("resource", { + code: { + type: DataTypes.STRING, + allowNull: false, + defaultValue: "NULL", + comment: null, + primaryKey: true, + field: "code", + autoIncrement: false + }, + name: { + type: DataTypes.STRING, + allowNull: false, + defaultValue: "NULL", + comment: null, + primaryKey: false, + field: "name", + autoIncrement: false + }, + parentResource: { + type: DataTypes.STRING, + allowNull: true, + defaultValue: "NULL", + comment: null, + primaryKey: false, + field: "parent_resource", + autoIncrement: false + } + }, { + tableName: "resource", + comment: "", + indexes: [] + }); + dc.models.Resource = Resource; + return Resource; +}; \ No newline at end of file diff --git a/api/app/lib/models/user_resource.js b/api/app/lib/models/user_resource.js new file mode 100644 index 00000000..7c60bff5 --- /dev/null +++ b/api/app/lib/models/user_resource.js @@ -0,0 +1,60 @@ +/* eslint-disable*/ + +'use strict'; + +module.exports = dc => { + const DataTypes = dc.ORM; + const sequelize = dc.orm; + const UserResource = sequelize.define("userResource", { + id: { + type: DataTypes.INTEGER, + allowNull: false, + defaultValue: null, + comment: null, + primaryKey: true, + field: "id", + autoIncrement: true + }, + userId: { + type: DataTypes.INTEGER, + allowNull: false, + defaultValue: null, + comment: null, + primaryKey: false, + field: "user_id", + autoIncrement: false, + references: { + key: "id", + model: "user" + } + }, + resourceId: { + type: DataTypes.STRING, + allowNull: false, + defaultValue: "NULL", + comment: null, + primaryKey: false, + field: "resource_id", + autoIncrement: false, + references: { + key: "code", + model: "resource" + } + }, + isshow: { + type: DataTypes.STRING, + allowNull: true, + defaultValue: null, + comment: null, + primaryKey: false, + field: "isshow", + autoIncrement: false + } + }, { + tableName: "user_resource", + comment: "", + indexes: [] + }); + dc.models.UserResource = UserResource; + return UserResource; +}; \ No newline at end of file diff --git a/api/app/lib/routes/organization/index.js b/api/app/lib/routes/organization/index.js index 57cc9ee3..f9c7a949 100644 --- a/api/app/lib/routes/organization/index.js +++ b/api/app/lib/routes/organization/index.js @@ -1,7 +1,8 @@ 'use strict'; const Department = require('../../controllers/organization/department') -const user = require('../../controllers/organization/user'); +const user = require('../../controllers/organization/user') +const Authority = require('../../controllers/organization/authority') module.exports = function (app, router, opts) { app.fs.api.logAttr['GET/department'] = { content: '获取部门列表', visible: false }; @@ -32,5 +33,34 @@ module.exports = function (app, router, opts) { // router.put('/department/user/:userId/resetPwd', user.resetPwd); app.fs.api.logAttr['PUT/department/user/:userId/password'] = { content: '修改用户密码', visible: false }; - router.put('/department/user/:userId/password', user.setPassword); + router.put('/department/user/:userId/password', user.setPassword) + + /** + * @api {GET} resource 查询所有权限码. + * @apiVersion 1.0.0 + * @apiGroup Org + */ + app.fs.api.logAttr['GET/resource'] = { content: '查询所有权限码', visible: true }; + router.get('resource', Authority.getResource); + /** + * @api {GET} user/resource 查询用户权限. + * @apiVersion 1.0.0 + * @apiGroup Org + */ + app.fs.api.logAttr['GET/user/resource'] = { content: '查询用户权限', visible: true }; + router.get('user/resource', Authority.getUserResource); + + /** + * @api {POST} user/resource 更新用户权限. + * @apiVersion 1.0.0 + * @apiGroup Org + */ + app.fs.api.logAttr['POST/user/resource'] = { content: '更新用户权限', visible: true }; + router.post('user/resource', Authority.updateUserRes); + + app.fs.api.logAttr['POST/user/resources'] = { content: '更新用户权限', visible: true }; + router.post('user/resources', Authority.editeUserRes); + + + }; \ No newline at end of file diff --git a/scripts/1.2.2/schema/1.alter_department.sql b/scripts/1.2.2/schema/1.alter_department.sql new file mode 100644 index 00000000..46bba273 --- /dev/null +++ b/scripts/1.2.2/schema/1.alter_department.sql @@ -0,0 +1,4 @@ +alter table department + add area_code varchar(100); + +comment on column department.area_code is '所属区域代码'; \ No newline at end of file diff --git a/scripts/1.2.2/schema/2.create_resource.sql b/scripts/1.2.2/schema/2.create_resource.sql new file mode 100644 index 00000000..9811ebf9 --- /dev/null +++ b/scripts/1.2.2/schema/2.create_resource.sql @@ -0,0 +1,8 @@ +create table resource +( + code varchar(128) default NULL::character varying not null + constraint resource_pk + primary key, + name varchar(128) default NULL::character varying not null, + parent_resource varchar(128) default NULL::character varying +) diff --git a/scripts/1.2.2/schema/3.create_user_resource.sql b/scripts/1.2.2/schema/3.create_user_resource.sql new file mode 100644 index 00000000..919b80f2 --- /dev/null +++ b/scripts/1.2.2/schema/3.create_user_resource.sql @@ -0,0 +1,13 @@ +create table user_resource +( + id integer default nextval('user_resource_id_seq'::regclass) not null + constraint user_resource_pk + primary key, + user_id integer not null + constraint fk_emp_dept2 + references "user", + resource_id varchar(128) default NULL::character varying not null + constraint user_resource_resource_code_fk + references resource, + isshow boolean +) \ No newline at end of file diff --git a/scripts/1.2.2/schema/4.insert_resource.sql b/scripts/1.2.2/schema/4.insert_resource.sql new file mode 100644 index 00000000..fc8f99ef --- /dev/null +++ b/scripts/1.2.2/schema/4.insert_resource.sql @@ -0,0 +1,15 @@ +INSERT INTO resource (code, name, parent_resource) VALUES ('ALLSELECT', '全选', null); +INSERT INTO resource (code, name, parent_resource) VALUES ('USERMANAGE', '用户管理', 'ALLSELECT'); +INSERT INTO resource (code, name, parent_resource) VALUES ('AUTHORIMANAGE', '权限管理', 'ALLSELECT'); +INSERT INTO resource (code, name, parent_resource) VALUES ('OVERLOADMANAGE', '治超管理', 'ALLSELECT'); +INSERT INTO resource (code, name, parent_resource) VALUES ('ROADMANAGE', '道路管理', 'ALLSELECT'); +INSERT INTO resource (code, name, parent_resource) VALUES ('BRIDGEMANAGE', '桥梁管理', 'ALLSELECT'); +INSERT INTO resource (code, name, parent_resource) VALUES ('MAINTENANCEMANAGE', '管养管理', 'ALLSELECT'); +INSERT INTO resource (code, name, parent_resource) VALUES ('TRANSPORTATIONMANAGE', '运政管理', 'ALLSELECT'); +INSERT INTO resource (code, name, parent_resource) VALUES ('CONSERVATIONMANAGE', '养护管理', 'ALLSELECT'); +INSERT INTO resource (code, name, parent_resource) VALUES ('PATROLMANAGE', '巡查管理', 'ALLSELECT'); +INSERT INTO resource (code, name, parent_resource) VALUES ('PUBLICTRANSPORTMANAGE', '公交管理', 'ALLSELECT'); +INSERT INTO resource (code, name, parent_resource) VALUES ('FILEMANAGE', '档案管理', 'ALLSELECT'); +INSERT INTO resource (code, name, parent_resource) VALUES ('PUBLICITYVIDEO', '宣传视频', 'ALLSELECT'); +INSERT INTO resource (code, name, parent_resource) VALUES ('FEEDBACKMANAGE', '异常反馈', 'ALLSELECT'); +INSERT INTO resource (code, name, parent_resource) VALUES ('REPORTMANAGE', '建设上报', 'ALLSELECT'); \ No newline at end of file diff --git a/web/client/src/sections/fillion/components/bridgeTable.js b/web/client/src/sections/fillion/components/bridgeTable.js index deb7f974..1da7c91a 100644 --- a/web/client/src/sections/fillion/components/bridgeTable.js +++ b/web/client/src/sections/fillion/components/bridgeTable.js @@ -25,7 +25,7 @@ const BrideTable = (props) => { const [whichofits, setWhichofits] = useState('qiaoliang') const [delet, setDelet] = useState() const [differentiate, setDifferentiate] = useState('bridge') - + const [editAble, setEditAble] = useState(user?.username !== 'SuperAdmin' && user?.userResources?.filter(i => i.resourceId === 'BRIDGEMANAGE')[0].isshow === "true" ? true : '') const ref = useRef() useEffect(() => { ref.current.reload() }, [whichofits, delet]) const deldata = (id) => { // 桥梁 @@ -1510,9 +1510,10 @@ const BrideTable = (props) => { setTypecard('compile') setRecortd(record) }} + disabled={editAble} >编辑 - { deldata(record.id) }}> - + { deldata(record.id) }} disabled={editAble}> + } @@ -1531,6 +1532,7 @@ const BrideTable = (props) => { openModal('edit', record) setTypecard('') }} + disabled={editAble} > 新增 @@ -1694,8 +1696,9 @@ const BrideTable = (props) => { setTypecard('compile') setRecortd(record) }} - >编辑 { deldatas(record.id) }}> - + disabled={editAble} + >编辑 { deldatas(record.id) }} disabled={editAble}> + } @@ -1714,6 +1717,7 @@ const BrideTable = (props) => { yilanModal('edit', record) setTypecard('') }} + disabled={editAble} > 新增 @@ -1815,7 +1819,7 @@ const BrideTable = (props) => { } if (whichofits == 'gongcheng') { const query = { type: 'bridge', - entryName:sitename + entryName: sitename } setRowSelected([]); const res = await dispatch(getProject(query)); @@ -1830,8 +1834,9 @@ const BrideTable = (props) => { defaultCollapsed: false, optionRender: (searchConfig, formProps, dom) => [ ...dom.reverse(), - { props.exports(rowSelected,differentiate) }}> + { props.exports(rowSelected, differentiate) }} disabled={editAble}> diff --git a/web/client/src/sections/fillion/components/fileTable.js b/web/client/src/sections/fillion/components/fileTable.js index a0dbc8d9..2982d33a 100644 --- a/web/client/src/sections/fillion/components/fileTable.js +++ b/web/client/src/sections/fillion/components/fileTable.js @@ -18,7 +18,7 @@ import UploadModal from './file/uploadModal'; // var pdfh5 = null; const DetailList = (props) => { - const { fileList, loading, dispatch, handelRefresh, onPageChange } = props; + const { fileList, loading, dispatch, handelRefresh, onPageChange, user } = props; const [imgSrc, setImgSrc] = useState({ imageView: false, imgSrc: '' }) const [pdfView, setPdfView] = useState({ showPDF: false, pdfName: '', pdfurl: '' }) var tyApiRoot = localStorage.getItem('tyApiRoot') @@ -137,7 +137,9 @@ const DetailList = (props) => { window.open(filePath_); }} >下载} - { showDeleteConfirm(record, filePath) }}>删除 + { showDeleteConfirm(record, filePath) }} + disabled={user?.username !== 'SuperAdmin' && user?.userResources?.filter(i => i.resourceId === 'FILEMANAGE')[0].isshow === "true" ? true : ''} + >删除 { ['.png', '.jpg'].some(item => item == record.fileExt) ? [, @@ -206,7 +208,8 @@ const RoadNameList = (props) => { const [filterRoad, setFilterRoad] = useState([]); const [addVisible, setAddVisible] = useState(false); const [selectRoad, setSelectRoad] = useState(); - const { onChange, roads, loading, queryData, dispatch } = props; + const { onChange, roads, loading, queryData, dispatch, user } = props + const [editAble, setEditAble] = useState(user?.username !== 'SuperAdmin' && user?.userResources?.filter(i => i.resourceId === 'FILEMANAGE')[0].isshow === "true" ? true : '') const columns = [ { title: '道路名称', @@ -270,7 +273,9 @@ const RoadNameList = (props) => { }} toolBarRender={() => [
- +
]} @@ -281,8 +286,8 @@ const RoadNameList = (props) => { return { onClick: () => { if (record) { - let id = record.rId - if(selectRoad == record.rId){ + let id = record.rId + if (selectRoad == record.rId) { id = null } setSelectRoad(id); @@ -401,6 +406,7 @@ const FileTable = (props) => {
handleChangeRecord(record)} @@ -417,10 +423,12 @@ const FileTable = (props) => { }} > - + - + { const [delet, setDelet] = useState() const [differentiate, setDifferentiate] = useState('road') const [grade, setGrade] = useState('县') + const [editAble, setEditAble] = useState(user?.username !== 'SuperAdmin' && user?.userResources?.filter(i => i.resourceId === 'MAINTENANCEMANAGE')[0].isshow === "true" ? true : '') const ref = useRef() useEffect(() => { ref.current.reload() }, [whichofits, delet]) //打开弹窗 @@ -95,6 +96,7 @@ const TransporTationTable = (props) => { setTypecard('compile') setRecortd(record) }} + disabled={editAble} >编辑
} @@ -250,6 +252,7 @@ const TransporTationTable = (props) => { setTypecard('compile') setRecortd(record) }} + disabled={editAble} >编辑 } diff --git a/web/client/src/sections/fillion/components/infor/videoUpload.js b/web/client/src/sections/fillion/components/infor/videoUpload.js index 67d941df..bcd81980 100644 --- a/web/client/src/sections/fillion/components/infor/videoUpload.js +++ b/web/client/src/sections/fillion/components/infor/videoUpload.js @@ -9,12 +9,12 @@ import { getPropagata } from '../../actions/infor'; const VideoUpload = (props) => { // const [counts, setCounts] = useState()//shuju - - - const { dispatch, record, counts, setCounts } = props + const { dispatch, record, counts, setCounts, user } = props const [success, setSuccess] = useState() //状态 const [form] = Form.useForm(); - + const [editAble, setEditAble] = useState(user?.username !== 'SuperAdmin' && user?.userResources?.filter(i => i.resourceId === 'PUBLICITYVIDEO')[0].isshow === "true" ? true : '') + //console.log('editAble', props) + let edit = editAble //弹窗 const [isModalVisible, setIsModalVisible] = useState(false); const showModal = () => { @@ -84,7 +84,7 @@ const VideoUpload = (props) => { return (
{ - props.type_ys ?
+ props.type_ys ?
{
: -
+
handleOkEdit(record)} onCancel={handleCancel}> { function mapStateToProps(state) { - const { depMessage } = state; + const { depMessage, auth } = state; const pakData = (dep) => { return dep.map((d) => { return { @@ -219,6 +219,7 @@ function mapStateToProps(state) { } let depData = pakData(depMessage.data || []) return { + user: auth.user, loading: depMessage.isRequesting, depData, }; diff --git a/web/client/src/sections/fillion/components/inforTable.js b/web/client/src/sections/fillion/components/inforTable.js index fa803831..83661111 100644 --- a/web/client/src/sections/fillion/components/inforTable.js +++ b/web/client/src/sections/fillion/components/inforTable.js @@ -357,10 +357,16 @@ const InForTable = (props) => { setTypecard('compile') setRecortd(record) }} + disabled={user?.username !== 'SuperAdmin' && user?.userResources?.filter(i => i.resourceId === 'OVERLOADMANAGE')[0].isshow === "true" ? true : ''} >编辑 - { deldata(record.id) }}> - + { deldata(record.id) }} + disabled={user?.username !== 'SuperAdmin' && user?.userResources?.filter(i => i.resourceId === 'OVERLOADMANAGE')[0].isshow === "true" ? true : ''} + + > +
} @@ -379,6 +385,7 @@ const InForTable = (props) => { openModal('edit', record) setTypecard('') }} + disabled={user?.username !== 'SuperAdmin' && user?.userResources?.filter(i => i.resourceId === 'OVERLOADMANAGE')[0].isshow === "true" ? true : ''} > 新增 @@ -461,8 +468,11 @@ const InForTable = (props) => { // console.log(rowSelected) rowSelected.length === 0 ? null : props.exports(rowSelected, counts) }} + disabled={user?.username !== 'SuperAdmin' && user?.userResources?.filter(i => i.resourceId === 'OVERLOADMANAGE')[0].isshow === "true" ? true : ''} > @@ -518,7 +528,7 @@ const data = { "fine": "罚款", "remarks": "备注" } -function mapStateToProps (state) { +function mapStateToProps(state) { const { auth, depMessage } = state; const pakData = (dep) => { return dep.map((d) => { diff --git a/web/client/src/sections/fillion/components/maintenanceTable.js b/web/client/src/sections/fillion/components/maintenanceTable.js index 45adec67..f58c8dc7 100644 --- a/web/client/src/sections/fillion/components/maintenanceTable.js +++ b/web/client/src/sections/fillion/components/maintenanceTable.js @@ -67,9 +67,10 @@ const DetailForm = (props) => { } const DetailList = (props) => { - const { reportList, loading, dispatch, handleOpen, handelRefresh } = props; + const { reportList, loading, dispatch, handleOpen, handelRefresh, user } = props; const [visible, setVisible] = useState(false) - const [selectRecord, setSelectRecord] = useState(); + const [selectRecord, setSelectRecord] = useState() + const [editAble, setEditAble] = useState(user?.username !== 'SuperAdmin' && user?.userResources?.filter(i => i.resourceId === 'CONSERVATIONMANAGE')[0].isshow === "true" ? true : '') const checkDetail = (record) => { dispatch(getReportDetail(record.id)) } @@ -182,11 +183,11 @@ const DetailList = (props) => { ]} visible={selectRecord == record.id && visible} trigger="click" - onClick={() => setSelectRecord(record.id)} + onClick={() => user?.username !== 'SuperAdmin' && user?.userResources?.filter(i => i.resourceId === 'CONSERVATIONMANAGE')[0].isshow === "true" ? '' : setSelectRecord(record.id)} title="是否删除该记录?" onVisibleChange={(newVisible) => setVisible(newVisible)} > - + ] } @@ -290,7 +291,7 @@ const PatrolNameList = (props) => { const MaintenanceTable = (props) => { - const { userList, reportList, dispatch, reportListLoading, reportDetail, reportDetailLoading, userLoading, exports } = props; + const { userList, user, reportList, dispatch, reportListLoading, reportDetail, reportDetailLoading, userLoading, exports } = props; const [record, setRecord] = useState(); const [dateRange, setDateRange] = useState(); const [detailVisible, setDetailVisible] = useState(false) @@ -363,6 +364,7 @@ const MaintenanceTable = (props) => {
@@ -378,7 +380,7 @@ const MaintenanceTable = (props) => { ); }; -function mapStateToProps (state) { +function mapStateToProps(state) { const { auth, depMessage, userList, reportList, reportDetail } = state; const pakData = (dep) => { return dep.map((d) => { diff --git a/web/client/src/sections/fillion/components/operationalTable.js b/web/client/src/sections/fillion/components/operationalTable.js index c00e6788..aabe131b 100644 --- a/web/client/src/sections/fillion/components/operationalTable.js +++ b/web/client/src/sections/fillion/components/operationalTable.js @@ -22,8 +22,9 @@ const OperaTionalTable = (props) => { const [recortd, setRecortd] = useState() const [rewkeys, setRewkeys] = useState('keyun') const [delet, setDelet] = useState() -const [differentiate,setDifferentiate]=useState() -const [genre,setGenre]=useState() + const [editAble, setEditAble] = useState(user?.username !== 'SuperAdmin' && user?.userResources?.filter(i => i.resourceId === 'TRANSPORTATIONMANAGE')[0].isshow === "true" ? true : '') + const [differentiate, setDifferentiate] = useState() + const [genre, setGenre] = useState() const ref = useRef() useEffect(() => { ref.current.reload() }, [rewkeys, activeKey, delet]) //打开弹窗 @@ -111,6 +112,7 @@ const [genre,setGenre]=useState() setTypecard('compile') setRecortd(record) }} + disabled={editAble} >编辑
} @@ -164,6 +166,7 @@ const [genre,setGenre]=useState() setTypecard('compile') setRecortd(record) }} + disabled={editAble} >编辑
} @@ -752,8 +755,9 @@ const [genre,setGenre]=useState() setTypecard('compile') setRecortd(record) }} - >编辑 { deldata(record.id) }}> - + disabled={editAble} + >编辑 { deldata(record.id) }} disabled={editAble}> + } @@ -772,6 +776,7 @@ const [genre,setGenre]=useState() openModal('edit', record) setTypecard('') }} + disabled={editAble} > 新增 @@ -1385,8 +1390,9 @@ const [genre,setGenre]=useState() setTypecard('compile') setRecortd(record) }} - >编辑 { deldata(record.id) }}> - + disabled={editAble} + >编辑 { deldata(record.id) }} disabled={editAble}> + } @@ -1405,6 +1411,7 @@ const [genre,setGenre]=useState() openModal('edit', record) setTypecard('') }} + disabled={editAble} > 新增 @@ -1850,13 +1857,14 @@ const [genre,setGenre]=useState() fixed: 'right', render: (dom, record) => { return
{ deldatas(record.id) }}> - + onClick={() => { + openModal('edit', record) + setTypecard('compile') + setRecortd(record) + }} + disabled={editAble} + >编辑 { deldatas(record.id) }} disabled={editAble}> +
} @@ -1875,6 +1883,7 @@ const [genre,setGenre]=useState() openModal('edit', record) setTypecard('') }} + disabled={editAble} > 新增 @@ -1927,9 +1936,9 @@ const [genre,setGenre]=useState() key: 'tab3', label: { { - setDifferentiate('vehicle') - setRewkeys('chuzu') - setGenre('出租车') + setDifferentiate('vehicle') + setRewkeys('chuzu') + setGenre('出租车') } }}>出租车{activeKey === 'tab3'}, @@ -1938,9 +1947,9 @@ const [genre,setGenre]=useState() key: 'tab4', label: { { - setDifferentiate('vehicle') - setGenre('危货') - setRewkeys('weihuo') + setDifferentiate('vehicle') + setGenre('危货') + setRewkeys('weihuo') } }}>危险货运{activeKey === 'tab4'}, @@ -2037,8 +2046,9 @@ const [genre,setGenre]=useState() defaultCollapsed: false, optionRender: (searchConfig, formProps, dom) => [ ...dom.reverse(), - ['tab3', 'tab4', 'tab5'].includes(activeKey) ? { props.exports(rowSelected, differentiate, genre) }}> + ['tab3', 'tab4', 'tab5'].includes(activeKey) ? { props.exports(rowSelected, differentiate, genre) }}> @@ -2066,7 +2076,7 @@ const [genre,setGenre]=useState() onVisibleChange={setModalVisibleyilan} modalRecord={modalRecord} typecard={typecard} - rewkeys={rewkeys=='keyun'?'passenger':'freight'} + rewkeys={rewkeys == 'keyun' ? 'passenger' : 'freight'} recortd={recortd} setDelet={setDelet} setRecortd={setRecortd} diff --git a/web/client/src/sections/fillion/components/patrolTable.js b/web/client/src/sections/fillion/components/patrolTable.js index c1333337..17cf8bd2 100644 --- a/web/client/src/sections/fillion/components/patrolTable.js +++ b/web/client/src/sections/fillion/components/patrolTable.js @@ -79,13 +79,11 @@ const DetailForm = (props) => { } const DetailList = (props) => { - const { reportList, loading, dispatch, handleOpen, handelRefresh, isAnomaly, isRoad, isPatrol, queryData } = props; + const { reportList, loading, dispatch, handleOpen, handelRefresh, isAnomaly, isRoad, isPatrol, queryData, user } = props; const [visible, setVisible] = useState(false) const [selectRecord, setSelectRecord] = useState(); const [noProcessingPopVisible, setNoProcessingPopVisible] = useState(false); const [noProcessingSelectRecord, setNoProcessingSelectRecord] = useState(); - - const checkDetail = (record) => { dispatch(getReportDetail(record.id)) } @@ -204,7 +202,7 @@ const DetailList = (props) => { , - isAnomaly && record.handleState != '已处理' ? : null, + isAnomaly && record.handleState != '已处理' ? : null, isAnomaly && record.handleState != '已处理' ? { ]} visible={noProcessingSelectRecord == record.id && noProcessingPopVisible} trigger="click" - onClick={() => setNoProcessingSelectRecord(record.id)} + onClick={() => user?.username !== 'SuperAdmin' && user?.userResources?.filter(i => i.resourceId === 'FEEDBACKMANAGE' || 'FEEDBACKMANAGE')[0].isshow === "true" ? '' : setNoProcessingSelectRecord(record.id)} title="是否不处理该记录?" onVisibleChange={(newVisible) => setNoProcessingPopVisible(newVisible)} > - + : null, { ]} visible={selectRecord == record.id && visible} trigger="click" - onClick={() => setSelectRecord(record.id)} + onClick={() => user?.username !== 'SuperAdmin' && user?.userResources?.filter(i => i.resourceId === 'FEEDBACKMANAGE' || 'FEEDBACKMANAGE')[0].isshow === "true" ? '' : setSelectRecord(record.id)} title="是否删除该记录?" onVisibleChange={(newVisible) => setVisible(newVisible)} > - + ] } @@ -349,13 +347,12 @@ const PatrolNameList = (props) => { const PatrolTable = (props) => { - const { userList, reportList, dispatch, reportListLoading, reportDetail, reportDetailLoading, userLoading, exports, pathname } = props; + const { user, userList, reportList, dispatch, reportListLoading, reportDetail, reportDetailLoading, userLoading, exports, pathname } = props; const [record, setRecord] = useState(); const [dateRange, setDateRange] = useState(); const [selectProjectType, setSelectProjectType] = useState(''); const [detailVisible, setDetailVisible] = useState(false) const [activeTabKey1, setActiveTabKey1] = useState('tab1'); - const { RangePicker } = DatePicker; const isRoad = pathname.includes('road') @@ -420,6 +417,7 @@ const PatrolTable = (props) => {
@@ -506,7 +504,7 @@ const PatrolTable = (props) => { ); }; -function mapStateToProps (state) { +function mapStateToProps(state) { const { auth, depMessage, userList, reportList, reportDetail } = state; const pakData = (dep) => { return dep.map((d) => { diff --git a/web/client/src/sections/fillion/components/promotionalTable.js b/web/client/src/sections/fillion/components/promotionalTable.js index 0ae13a79..758bc2e1 100644 --- a/web/client/src/sections/fillion/components/promotionalTable.js +++ b/web/client/src/sections/fillion/components/promotionalTable.js @@ -9,9 +9,10 @@ import { putEditPropagata } from '../actions/infor'; import { delPropagata } from '../actions/infor'; const promotionalTable = (props) => { - const { dispatch, } = props + const { dispatch, user } = props const [rowSelected, setRowSelected] = useState([]) const [counts, setCounts] = useState()//shuju + const [editAble, setEditAble] = useState(user?.username !== 'SuperAdmin' && user?.userResources?.filter(i => i.resourceId === 'PUBLICITYVIDEO')[0].isshow === "true" ? true : '') const onClickEnable = (record) => { const id = record.id @@ -61,7 +62,7 @@ const promotionalTable = (props) => { fixed: 'right', render: (dom, record) => { return
- onClickEnable(record)} defaultChecked={true ? record.enable == true : false} /> + onClickEnable(record)} defaultChecked={true ? record.enable == true : false} disabled={editAble} />
} }, @@ -74,8 +75,9 @@ const promotionalTable = (props) => { fixed: 'right', render: (dom, record) => { return
- + { } > -
diff --git a/web/client/src/sections/fillion/components/publicTable.js b/web/client/src/sections/fillion/components/publicTable.js index c16271a1..f2bf5f93 100644 --- a/web/client/src/sections/fillion/components/publicTable.js +++ b/web/client/src/sections/fillion/components/publicTable.js @@ -22,6 +22,7 @@ const PublicTable = (props) => { const [recortd, setRecortd] = useState() const [rewkeys, setRewkeys] = useState('xianlu') const [delet, setDelet] = useState() + const [editAble, setEditAble] = useState(user?.username !== 'SuperAdmin' && user?.userResources?.filter(i => i.resourceId === 'PUBLICTRANSPORTMANAGE')[0].isshow === "true" ? true : '') const ref = useRef() useEffect(() => { ref.current.reload() }, [delet, rewkeys]) @@ -411,8 +412,9 @@ const PublicTable = (props) => { setTypecard('compile') setRecortd(record) }} - >编辑 { deldata(record.id) }}> - + disabled={editAble} + >编辑 { deldata(record.id) }} disabled={editAble}> +
} @@ -431,6 +433,7 @@ const PublicTable = (props) => { openModal('edit', record) setTypecard('') }} + disabled={editAble} > 新增 @@ -1106,8 +1109,9 @@ const PublicTable = (props) => { setTypecard('compile') setRecortd(record) }} - >编辑 { deldatas(record.id) }}> - + disabled={editAble} + >编辑 { deldatas(record.id) }} disabled={editAble}> + } @@ -1126,6 +1130,7 @@ const PublicTable = (props) => { openModal('edit', record) setTypecard('') }} + disabled={editAble} > 新增 @@ -1231,8 +1236,9 @@ const PublicTable = (props) => { defaultCollapsed: false, optionRender: (searchConfig, formProps, dom) => [ ...dom.reverse(), - { props.exports(rowSelected,rewkeys ) }}> + { props.exports(rowSelected, rewkeys) }} disabled={editAble}> diff --git a/web/client/src/sections/fillion/components/transportationTable.js b/web/client/src/sections/fillion/components/transportationTable.js index 35e4cd7a..d53aa732 100644 --- a/web/client/src/sections/fillion/components/transportationTable.js +++ b/web/client/src/sections/fillion/components/transportationTable.js @@ -23,6 +23,8 @@ const TransporTationTable = (props) => { const [delet, setDelet] = useState() const [differentiate, setDifferentiate] = useState('road') const [grade, setGrade] = useState('县') + const [departmentInfo, setDepartment] = useState('') + const [editAble, setEditAble] = useState(user?.username !== 'SuperAdmin' && user?.userResources?.filter(i => i.resourceId === 'ROADMANAGE')[0].isshow === "true" ? true : '') const ref = useRef() useEffect(() => { ref.current.reload() }, [whichofits, delet]) //打开弹窗 @@ -35,6 +37,17 @@ const TransporTationTable = (props) => { setModalRecord(null); } } + useEffect(() => { + const { departmentId } = user + const departmentInfo = depMessage.find((item) => { + return item.id === departmentId + }) + setDepartment(departmentInfo) + }, [user, depMessage]) + console.log('sad', departmentInfo) + // useEffect(() => { + // console.log('11111', depMessage) + // }, [depMessage]) const yilanModal = (type, record) => { setModalVisibleyilan(true); // setModalType(type); @@ -1180,11 +1193,12 @@ const TransporTationTable = (props) => { openModal('edit', record) setTypecard('compile') }} + disabled={editAble} >编辑 - { deldata(record.id) }}> @@ -1205,6 +1219,7 @@ const TransporTationTable = (props) => { // sessionStorage.setItem('newly', JSON.stringify(data)) setTypecard('') }} + disabled={user?.username !== 'SuperAdmin' && user?.userResources?.filter(i => i.resourceId === 'ROADMANAGE')[0].isshow === "true" ? true : ''} > 新增 @@ -2338,9 +2353,11 @@ const TransporTationTable = (props) => { setRecortd(record) }} + disabled={editAble} >编辑 - { deldata(record.id) }}> - + { deldata(record.id) }} disabled={editAble} + > + @@ -3495,9 +3512,14 @@ const TransporTationTable = (props) => { setRecortd(record) }} + disabled={user?.username !== 'SuperAdmin' && user?.userResources?.filter(i => i.resourceId === 'ROADMANAGE')[0].isshow === "true" ? true : ''} >编辑 - { deldata(record.id) }}> - + { deldata(record.id) }} + disabled={editAble} + > + } @@ -3681,9 +3703,10 @@ const TransporTationTable = (props) => { setTypecard('compile') setRecortd(record) }} + disabled={editAble} >编辑 - { deldatas(record.id) }}> - + { deldatas(record.id) }} disabled={editAble}> + @@ -3787,7 +3810,7 @@ const TransporTationTable = (props) => { request={async (params) => { console.log(whichofits) if (whichofits == '县') { - console.log('differentiate','我我我我吧') + console.log('differentiate', '我我我我吧') const query = { level: '县', @@ -3797,7 +3820,10 @@ const TransporTationTable = (props) => { const res = await dispatch(getRoadway(query)); // console.log(res) - setCounts(res.payload.data) + setCounts(departmentInfo ? res.payload.data.filter((item) => { + return item.townshipCode === departmentInfo.areaCode + }) : res.payload.data) + //setCounts(res.payload.data) return { ...res, total: res.payload.data ? res.payload.data.count : 0 @@ -3809,7 +3835,9 @@ const TransporTationTable = (props) => { } setRowSelected([]); const res = await dispatch(getRoadway(query)); - setCounts(res.payload.data) + setCounts(departmentInfo ? res.payload.data.filter((item) => { + return item.townshipCode === departmentInfo.areaCode + }) : res.payload.data) return { ...res, total: res.payload.data ? res.payload.data.count : 0 @@ -3821,7 +3849,9 @@ const TransporTationTable = (props) => { } setRowSelected([]); const res = await dispatch(getRoadway(query)); - setCounts(res.payload.data) + setCounts(departmentInfo ? res.payload.data.filter((item) => { + return item.townshipCode === departmentInfo.areaCode + }) : res.payload.data) return { ...res, total: res.payload.data ? res.payload.data.count : 0 @@ -3830,7 +3860,7 @@ const TransporTationTable = (props) => { if (whichofits == 'gongcheng') { const query = { type: 'road', - entryName:sitename + entryName: sitename } setRowSelected([]); const res = await dispatch(getProject(query)); @@ -3845,8 +3875,11 @@ const TransporTationTable = (props) => { defaultCollapsed: false, optionRender: (searchConfig, formProps, dom) => [ ...dom.reverse(), - { props.exports(rowSelected,grade,differentiate) }}> + { props.exports(rowSelected, grade, differentiate) }} + disabled={user?.username !== 'SuperAdmin' && user?.userResources?.filter(i => i.resourceId === 'ROADMANAGE')[0].isshow === "true" ? true : ''} + > diff --git a/web/client/src/sections/fillion/containers/patrol.js b/web/client/src/sections/fillion/containers/patrol.js index f3a362af..16779c1a 100644 --- a/web/client/src/sections/fillion/containers/patrol.js +++ b/web/client/src/sections/fillion/containers/patrol.js @@ -25,12 +25,12 @@ const patrol = (props) => { } return ( <> - + ) } -function mapStateToProps (state) { +function mapStateToProps(state) { const { auth } = state return { user: auth.user, diff --git a/web/client/src/sections/fillion/nav-item.js b/web/client/src/sections/fillion/nav-item.js index e7871de4..57cc1deb 100644 --- a/web/client/src/sections/fillion/nav-item.js +++ b/web/client/src/sections/fillion/nav-item.js @@ -3,56 +3,87 @@ import { Link } from 'react-router-dom'; import { Menu } from 'antd'; import { ReadOutlined } from '@ant-design/icons'; const SubMenu = Menu.SubMenu; -export function getNavItem (user, dispatch) { +export function getNavItem(user, dispatch) { + const isshow = user?.userResources?. + filter(i => i.resourceId === 'OVERLOADMANAGE' || + i.resourceId === 'ROADMANAGE' || + i.resourceId === 'BRIDGEMANAGE' || + i.resourceId === 'MAINTENANCEMANAGE' || + i.resourceId === 'TRANSPORTATIONMANAGE' || + i.resourceId === 'CONSERVATIONMANAGE' || + i.resourceId === 'PUBLICTRANSPORTMANAGE' || + i.resourceId === 'FILEMANAGE' || + i.resourceId === 'PUBLICITYVIDEO' || + i.resourceId === 'FEEDBACKMANAGE' || + i.resourceId === 'REPORTMANAGE' || + i.resourceId === 'PATROLMANAGE')?.length !== 0 + return ( - } title={'数据管理'}> - - 治超管理 - - {/* + user?.username == 'SuperAdmin' || isshow ? + } title={'数据管理'}> + {user?.username == 'SuperAdmin' || user?.userResources?.filter(i => i.resourceId === 'OVERLOADMANAGE')?.length !== 0 ? + + 治超管理 + : ''} + {/* 任务管理 */} - - 道路管理 - - 桥梁管理 - - - 管养管理 - - - 运政管理 - - {/* + {user?.username == 'SuperAdmin' || user?.userResources?.filter(i => i.resourceId === 'ROADMANAGE')?.length !== 0 ? + + 道路管理 + : ''} + {user?.username == 'SuperAdmin' || user?.userResources?.filter(i => i.resourceId === 'BRIDGEMANAGE')?.length !== 0 ? + + 桥梁管理 + : ''} + {user?.username == 'SuperAdmin' || user?.userResources?.filter(i => i.resourceId === 'MAINTENANCEMANAGE')?.length !== 0 ? + + 管养管理 + : ''} + {user?.username == 'SuperAdmin' || user?.userResources?.filter(i => i.resourceId === 'TRANSPORTATIONMANAGE')?.length !== 0 ? + + 运政管理 + : ''} + {/* 执法管理 */} - - 养护管理 - - - 巡查管理 - - - 公交管理 - - - 档案管理 - - {/* + {user?.username == 'SuperAdmin' || user?.userResources?.filter(i => i.resourceId === 'CONSERVATIONMANAGE')?.length !== 0 ? + + 养护管理 + : ''} + {user?.username == 'SuperAdmin' || user?.userResources?.filter(i => i.resourceId === 'PATROLMANAGE')?.length !== 0 ? + + 巡查管理 + : ''} + {user?.username == 'SuperAdmin' || user?.userResources?.filter(i => i.resourceId === 'PUBLICTRANSPORTMANAGE')?.length !== 0 ? + + 公交管理 + : ''} + {user?.username == 'SuperAdmin' || user?.userResources?.filter(i => i.resourceId === 'FILEMANAGE')?.length !== 0 ? + + 档案管理 + : ''} + {/* 视频管理 */} - {/* + {/* 接口管理 */} - - 宣传视频 - - - 异常反馈 - - - 建设上报 - - + {user?.username == 'SuperAdmin' || user?.userResources?.filter(i => i.resourceId === 'PUBLICITYVIDEO')?.length !== 0 ? + + + 宣传视频 + : ''} + {user?.username == 'SuperAdmin' || user?.userResources?.filter(i => i.resourceId === 'FEEDBACKMANAGE')?.length !== 0 ? + + + 异常反馈 + : ''} + {user?.username == 'SuperAdmin' || user?.userResources?.filter(i => i.resourceId === 'REPORTMANAGE')?.length !== 0 ? + + + 建设上报 + : ''} + : null ); } diff --git a/web/client/src/sections/organization/actions/authority.js b/web/client/src/sections/organization/actions/authority.js index d5f07191..6aab3ffb 100644 --- a/web/client/src/sections/organization/actions/authority.js +++ b/web/client/src/sections/organization/actions/authority.js @@ -43,9 +43,21 @@ export function postUserRes(body) { msg: { success: '更新用户权限' } }); } + +export function postUserReso(body) { + return dispatch => basicAction({ + type: 'post', + dispatch: dispatch, + actionType: 'UPDATE_USER_RESOURCE', + url: `${ApiTable.postUserReso}`, + data: body, + msg: { success: '更新用户权限' } + }); +} export default { getAuthority, getResource, getUserResource, - postUserRes + postUserRes, + postUserReso } \ No newline at end of file diff --git a/web/client/src/sections/organization/components/depModal.js b/web/client/src/sections/organization/components/depModal.js index efb14b30..b54e74af 100644 --- a/web/client/src/sections/organization/components/depModal.js +++ b/web/client/src/sections/organization/components/depModal.js @@ -1,4 +1,4 @@ -import React, { useRef, useState } from 'react'; +import React, { useRef, useState, useEffect } from 'react'; import { connect } from 'react-redux'; import { Spin, Card, Modal, TreeSelect } from 'antd'; import ProForm, { ProFormText, ModalForm, ProFormSwitch, ProFormTreeSelect } from '@ant-design/pro-form'; @@ -6,13 +6,42 @@ import ProForm, { ProFormText, ModalForm, ProFormSwitch, ProFormTreeSelect } fro const DepModal = (props) => { const { visible, onVisibleChange, onConfirm, depModalType, depData, data } = props; const formRef = useRef(); + const roadCode = [ + { title: "莲塘镇", value: "360121100000" }, + { title: "向塘镇", value: "360121101000" }, + { title: "三江镇", value: "360121102000" }, + { title: "塘南镇", value: "360121103000" }, + { title: "幽兰镇", value: "360121104000" }, + { title: "蒋巷镇", value: "360121105000" }, + { title: "武阳镇", value: "360121106000" }, + { title: "冈上镇", value: "360121107000" }, + { title: "广福镇", value: "360121108000" }, + { title: "昌东镇", value: "360121191000" }, + { title: "麻丘镇", value: "360121192000" }, + { title: "泾口乡", value: "360121200000" }, + { title: "南新乡", value: "360121201000" }, + { title: "塔城乡", value: "360121202000" }, + { title: "黄马乡", value: "360121203000" }, + { title: "富山乡", value: "360121204000" }, + { title: "东新乡", value: "360121205000" }, + { title: "八一乡", value: "360121206000" }, + { title: "小蓝经济开发区", value: "360121403000" }, + { title: "银三角管理委员会", value: "360121501000" }, + { title: "五星垦殖场", value: "360121501000" }, + { title: "良种繁殖场", value: "360121572000" }, + ] + useEffect(() => { + console.log('depData', depData) + }, []) + const onFinish = (values) => { if (onConfirm) { if (depModalType === 'edit') { let value = { name: values.name, depId: data.id, - dependence:values.dependence + dependence: values.dependence, + areaCode: values.area } onConfirm(value) } else { @@ -62,6 +91,21 @@ const DepModal = (props) => { return depData }} /> + { + return roadCode + }} + /> ) diff --git a/web/client/src/sections/organization/containers/authority.js b/web/client/src/sections/organization/containers/authority.js index 0f29d81c..aece8e9a 100644 --- a/web/client/src/sections/organization/containers/authority.js +++ b/web/client/src/sections/organization/containers/authority.js @@ -1,33 +1,91 @@ import React, { useEffect, useState } from 'react'; import { connect } from 'react-redux'; -import { Spin, Row, Col, Card, Button, Tree, Empty } from 'antd'; +import { Spin, Row, Col, Card, Button, Tree, Empty, Checkbox } from 'antd'; import { getDepMessage, getDepUser } from '../actions/user'; -import { getResource, getUserResource, postUserRes } from '../actions/authority'; +import { getResource, getUserResource, postUserRes, postUserReso } from '../actions/authority'; import Resource from '../components/resource'; +import user from './user'; const Authority = (props) => { - const { dispatch, loading, depMessage, depUser, resource, userResource, clientHeight } = props + const CheckboxGroup = Checkbox.Group; + const { dispatch, loading, depMessage, depUser, resource, userResource, clientHeight, user } = props + const r1 = ['USERMANAGE', 'AUTHORIMANAGE', 'OVERLOADMANAGE', 'ROADMANAGE', 'BRIDGEMANAGE', 'MAINTENANCEMANAGE', 'TRANSPORTATIONMANAGE', + 'CONSERVATIONMANAGE', 'PATROLMANAGE', 'PUBLICTRANSPORTMANAGE', 'FILEMANAGE', 'PUBLICITYVIDEO', 'FEEDBACKMANAGE', 'REPORTMANAGE'] const [depSelectedKeys, setDepSelectedKeys] = useState([]) const [userSelectedKeys, setUserSelectedKeys] = useState([]) const [depSelected, setDepSelected] = useState() const [userSelected, setUserSelected] = useState() - const [resCode, setResCode] = useState({}) + const [resCode, setResCode] = useState(userResource.map(i => i.resourceId)) const [useName, setUseName] = useState()// 选中名字 - const [userType,setUserType]=useState() + const [userType, setUserType] = useState() + const [depMessagedata, setdepMessagedata] = useState(depMessage) + + const rescodeall = resource[0]?.resources?.map(i => ({ label: i.name, value: i.code })) + //console.log(resource[0]?.resources?.map(i => ({ label: i.name, value: i.code })), '这个是总的骂') + const [indeterminate, setIndeterminate] = useState(false); + const [checkAll, setCheckAll] = useState(true); + const [rescheckAll, setrescheckAll] = useState(false) + const [isshow, setisshow] = useState(false); + let plainOptions = depUser.map(i => ({ label: i.name, value: i.id })); + const [checkedList, setCheckedList] = useState(depUser.map(i => i.id)); + const onChange = (list) => { + // console.log(list,'选择的') + setCheckedList(list); + setIndeterminate(!!list.length && list.length < plainOptions.length); + // setResCode(userResource.map(i=>i.resourceId)) + setCheckAll(list.length === plainOptions.length); + dispatch(getUserResource(list)) + // if(list.length === plainOptions.length){ + // setUseName('全部用户') + // } + }; + // console.log(userSelectedKeys,'当前1') + const onresChange = (d) => { + setResCode(d) + setrescheckAll(d.length === r1.length) + } + const onresCheckAllChange = (d) => { + setrescheckAll(d.target.checked) + setResCode(d.target.checked ? r1 : []) + + } + const onCheckAllChange = (e) => { + setCheckedList(e.target.checked ? plainOptions.map(i => i.value) : []); + setIndeterminate(false); + // if(e.target.checked){ + // setUseName('全部用户') + // } + + setCheckAll(e.target.checked); + // setResCode(userResource.map(i=>i.resourceId)) + }; + const onshowchange = (e) => { + setisshow(e.target.checked) + } useEffect(() => { dispatch(getResource()) if (!(depMessage && depMessage.length)) { dispatch(getDepMessage()) } - + setResCode(userResource.map(i => i.resourceId)) + setisshow(userResource.some(i => i.isshow === "true")) + setrescheckAll(userResource.map(i => i.resourceId).length === 14) }, []) + useEffect(() => { + setResCode(userResource.map(i => i.resourceId)) + setisshow(userResource.some(i => i.isshow === "true")) + setrescheckAll(userResource.map(i => i.resourceId).length === 14) + }, [userResource]) useEffect(() => { if (depMessage.length) { - setDepSelectedKeys([depMessage[0].id]) - setDepSelected([depMessage[0].name]) - dispatch(getDepUser(depMessage[0].id)) + console.log('depMessage', depMessage) + setdepMessagedata(depMessage) + setDepSelectedKeys([depMessage[0]?.id]) + setDepSelected([depMessage[0]?.name]) + dispatch(getDepUser(depMessage[0]?.id)) } + }, [depMessage]) useEffect(() => { if (depUser.length) { @@ -36,36 +94,59 @@ const Authority = (props) => { dispatch(getUserResource(depUser[0].id)) setUseName(depUser[0].name) } - }, [depUser]) + setCheckedList(depUser.map(i => i.id)) + + }, [depUser]) + // console.log(depUser,'用户信息') const handleSave = () => { - dispatch(postUserRes({ userId: userSelectedKeys[0], resCode: resCode })).then(res => { + // console.log( userSelectedKeys[0],'当前选中的id') + // checkedList.map(i=>{ + // dispatch(postUserRes({ userId: i, resCode: resCode,isShow:isshow })).then(res => { + // if (res.success) { + // dispatch(getUserResource(i)) + // } + // }) + // dispatch(postUserReso({ userId: i, resCode: resCode,isShow:isshow })) + // }) + + dispatch(postUserRes({ userId: userSelectedKeys[0], resCode: resCode, isShow: isshow })).then(res => { if (res.success) { dispatch(getUserResource(userSelectedKeys[0])) } }) + dispatch(postUserReso({ userId: userSelectedKeys[0], resCode: resCode, isShow: isshow })) } + return ( { - depMessage.length ? + depMessagedata.length ? { setUserType(selectedNodes[0].type) + setCheckedList(depUser.map(i => i.id)) + // setResCode(userResource.map(i=>i.resourceId)) + + if (selected) { + setCheckedList(depUser.map(i => i.id)) setDepSelectedKeys(selectedKeys) setDepSelected(selectedNodes[0].name || "") dispatch(getDepUser(selectedKeys[0])) + + // setResCode(userResource.map(i=>i.resourceId)) + } }} - treeData={depMessage} + treeData={depMessagedata} fieldNames={{ title: 'name', key: 'id', @@ -76,7 +157,7 @@ const Authority = (props) => { - + { depUser.length ? { setUseName(name) if (selected) { + // console.log(selectedKeys,'选中的selectedKeys') + // console.log(selectedNodes[0].username || '','node') + // console.log(selectedKeys[0],'请求的值') setUserSelectedKeys(selectedKeys) setUserSelected(selectedNodes[0].username || '') dispatch(getUserResource(selectedKeys[0])) @@ -100,23 +184,50 @@ const Authority = (props) => { key: 'id' }} /> : + + //
+ // i.resourceId==='AUTHORIMANAGE')[0].isShow==="true"?true:''}> + // 全选 + // + + // i.resourceId==='AUTHORIMANAGE')[0].isShow==="true"?true:''}/> + //
: + }
+ i.resourceId === 'AUTHORIMANAGE')[0]?.isshow === "true" ? true : ''}> + 不可编辑 + {depUser.length ? - - + {/* + userType={user?.department?.type==="qifu"&&user?.userResources?.filter(i=>i.resourceId==='AUTHORIMANAGE')[0].isShow==="true"?4:userType} + /> */} +
+ i.resourceId === 'AUTHORIMANAGE')[0].isshow === "true" ? true : ''} + > + 全选 + + i.resourceId === 'AUTHORIMANAGE')[0].isshow === "true" ? true : ''} + /> +
@@ -133,14 +244,15 @@ const Authority = (props) => { } function mapStateToProps(state) { - const { userResource, resource, depMessage, depUser, global } = state; + const { userResource, resource, depMessage, depUser, global, auth } = state; return { clientHeight: global.clientHeight, loading: depMessage.isRequesting || depUser.isRequesting || resource.isRequesting, userResource: userResource.data || [], resource: resource.data || [], depMessage: depMessage.data || [], - depUser: depUser.data || [] + depUser: depUser.data || [], + user: auth.user }; } diff --git a/web/client/src/sections/organization/containers/user.js b/web/client/src/sections/organization/containers/user.js index 59b11374..beece4d5 100644 --- a/web/client/src/sections/organization/containers/user.js +++ b/web/client/src/sections/organization/containers/user.js @@ -3,7 +3,8 @@ import { connect } from 'react-redux'; import { DeleteOutlined, EllipsisOutlined, FormOutlined } from '@ant-design/icons'; import { Spin, Space, Button, Popconfirm, Row, Col, Tree, Table, Card, Switch, Tooltip, Breadcrumb } from 'antd'; import ProTable from '@ant-design/pro-table'; -import { getDepMessage, getDepUser, createUser, updateUser, delUser, resetPwd, createDep, delDep, updateDep } from '../actions/user'; +import { getDepMessage, getDepUser, createUser, updateUser, delUser, resetPwd, createDep, delDep, updateDep } from '../actions/user' +import { postUserRes } from '../actions/authority' import UserModal from '../components/userModal'; import ResetPwd from '../components/resetPwd'; import DepModal from '../components/depModal'; @@ -24,6 +25,19 @@ const UserManage = (props) => { const [selectedTree, setSelectedTree] = useState(); const [depCrumbs, setDepCrumbs] = useState([]); const [depUserCopy, setDepUserCopy] = useState([])//用于存放除了自己的管理的数组,即自己不能调整自己是否为管理员 + const [uid, setuid] = useState() + const [editAble, setEditAble] = useState(user?.username !== 'SuperAdmin' && user?.userResources?.filter(i => i.resourceId === 'USERMANAGE')[0].isshow === "true" ? true : '')//控制操作(新增删除等操作,对应权限的'不可编辑')是否可操作 + + useEffect(() => { + let code = ['USERMANAGE', 'AUTHORIMANAGE'] + //console.log('你來u盧克嗎', depUser, uid) + // console.log(depUser.filter(i=>i.phone===uid)[0]?.id,'当前的用户user') + if (depUser?.filter(i => i.phone === uid)[0]?.id) { + //console.log('你來u盧克嗎', depUser, uid) + + dispatch(postUserRes({ userId: depUser.filter(i => i.phone === uid)[0]?.id, resCode: code, isShow: false })) + } + }, [uid]) useEffect(() => { dispatch(getDepMessage()) @@ -96,14 +110,15 @@ const UserManage = (props) => { // >重置密码 // ] return [ - , + , { delUsers([record.id]) }} + disabled={editAble} > - + , ] }, @@ -119,6 +135,7 @@ const UserManage = (props) => { //弹窗确认 const onConfirm = (values) => { + console.log('values.contract', values.contract) if (modalType == 'edit') { dispatch(updateUser(modalRecord.id, values.contract)).then(res => { if (res.success) { @@ -130,7 +147,9 @@ const UserManage = (props) => { dispatch(createUser(values.contract)).then(res => { if (res.success) { setModalVisible(false); - dispatch(getDepMessage()); + dispatch(getDepMessage()) + setuid(values.contract.phone) + } }); } @@ -268,7 +287,9 @@ const UserManage = (props) => { key="primary" style={{ marginLeft: 10 }} onClick={() => openDepModal('create')} - >新建部门 + disabled={editAble} + > + 新建部门 { depMessage.length ? @@ -344,10 +365,11 @@ const UserManage = (props) => { key="primary" style={{ marginRight: 10 }} onClick={() => openModal('create')} + disabled={editAble} >新建用户 {/* */} - { delUsers(rowSelected, 'batch') }}> - + { delUsers(rowSelected, 'batch') }} disabled={editAble}> +
]} @@ -393,7 +415,7 @@ function mapStateToProps(state) { loading: depMessage.isRequesting, depMessage: depMessage.data || [], depUser: depUser.data || [], - user: auth?.user?.name + user: auth.user }; } diff --git a/web/client/src/sections/organization/nav-item.js b/web/client/src/sections/organization/nav-item.js index 25c094d5..604ea5a6 100644 --- a/web/client/src/sections/organization/nav-item.js +++ b/web/client/src/sections/organization/nav-item.js @@ -17,16 +17,23 @@ export function getNavItem(user, dispatch) { // dispatch(push('/fillion/infor')); // return null // } + const isshow = user?.userResources?.filter(i => i.resourceId === 'USERMANAGE' || i.resourceId === 'AUTHORIMANAGE')?.length !== 0 return ( - } title={'授权管理'}> - - { - 用户管理 - - } - - - - - ); + user?.username == 'SuperAdmin' || isshow ? + } title={'授权管理'}> + + {user?.username == 'SuperAdmin' || user?.userResources?.filter(i => i.resourceId === 'USERMANAGE')?.length !== 0 ? < Menu.Item key="userManage"> + 用户管理 + : '' + } + + {user?.username == 'SuperAdmin' || user?.userResources?.filter(i => i.resourceId === 'AUTHORIMANAGE')?.length !== 0 ? + 权限管理 + : ''} + + + + + : null + ) } \ No newline at end of file diff --git a/web/client/src/sections/organization/routes.js b/web/client/src/sections/organization/routes.js index 2b4d1571..e3b843f6 100644 --- a/web/client/src/sections/organization/routes.js +++ b/web/client/src/sections/organization/routes.js @@ -1,6 +1,6 @@ 'use strict'; -import { UserManage, Authority,AdminiSter } from './containers'; - +import { UserManage, AdminiSter } from './containers'; +import Authority from './containers/authority'; export default [{ type: 'inner', route: { @@ -15,6 +15,15 @@ export default [{ menuSelectKeys: ['userManage'], component: UserManage, breadcrumb: '用户管理', - }] + }, + { + path: '/authority', + key: 'userAuthority', + menuSelectKeys: ['userAuthority'], + component: Authority, + breadcrumb: '权限管理', + } + + ] } }]; \ No newline at end of file diff --git a/web/client/src/sections/quanju/containers/heand/index.js b/web/client/src/sections/quanju/containers/heand/index.js index ac9cb6f2..2589ffb6 100644 --- a/web/client/src/sections/quanju/containers/heand/index.js +++ b/web/client/src/sections/quanju/containers/heand/index.js @@ -6,14 +6,14 @@ import { Tabs } from 'antd'; const { TabPane } = Tabs; const Header = (props) => { - const { dispatch, tabChange, tabKey } = props + const { dispatch, tabChange, tabKey, user } = props // const [tab, setTad] = useState("base") const onClick = (tab) => { // setTad({ tab }) tabChange(tab) } const dianji = () => { - dispatch(push('/fillion/infor')) + dispatch(push('/noContent')) } return (
diff --git a/web/client/src/sections/quanju/containers/noContent/index.js b/web/client/src/sections/quanju/containers/noContent/index.js new file mode 100644 index 00000000..e69de29b diff --git a/web/client/src/utils/webapi.js b/web/client/src/utils/webapi.js index f8f9f37e..1746a7f4 100644 --- a/web/client/src/utils/webapi.js +++ b/web/client/src/utils/webapi.js @@ -148,7 +148,7 @@ export const ApiTable = { compileReportRectifyDetail: 'report/rectify/detail', getReportList: 'report/list', getReportDetail: 'report/{reportId}/detail', - handleReport:'report/{reportId}/handle', + handleReport: 'report/{reportId}/handle', getUsers: 'user', @@ -220,6 +220,8 @@ export const ApiTable = { getResource: 'resource', getUserResource: 'user/resource', postUserRes: 'user/resource', + postUserReso: 'user/resources', + //报表配置 allAreas: 'allAreas',