Browse Source

feat:新增部门隐藏+新建用户只能操作用户所在部门

dev
zhaobing 1 year ago
parent
commit
3a5ea96745
  1. 16
      api/app/lib/controllers/report/index.js
  2. 28
      web/client/src/sections/fillion/components/patrolTable.js
  3. 20
      web/client/src/sections/organization/components/userModal.js
  4. 7
      web/client/src/sections/organization/containers/user.js

16
api/app/lib/controllers/report/index.js

@ -1,7 +1,7 @@
'use strict';
const { QueryTypes } = require('sequelize');
async function reportList (ctx) {
async function reportList(ctx) {
try {
const models = ctx.fs.dc.models;
const { limit, page, startTime, endTime, keyword, userId, reportType, isTop, asc, projectType, handleState = '', performerId = '' } = ctx.query
@ -48,7 +48,9 @@ async function reportList (ctx) {
model: models.User,
attributes: ['name']
}],
order: [['time', asc ? 'ASC' : 'DESC']],
//order: [['time', asc ? 'ASC' : 'DESC']],
order: [['time', 'DESC']],
}
if (limit) {
findOption.limit = limit
@ -114,7 +116,7 @@ async function reportList (ctx) {
}
}
async function reportPosition (ctx) {
async function reportPosition(ctx) {
try {
const models = ctx.fs.dc.models;
const { startTime, endTime, userId, reportType } = ctx.query
@ -164,7 +166,7 @@ async function reportPosition (ctx) {
}
}
async function reportDetail (ctx) {
async function reportDetail(ctx) {
try {
const models = ctx.fs.dc.models;
const { reportId } = ctx.params
@ -186,7 +188,7 @@ async function reportDetail (ctx) {
}
}
async function reportHandle (ctx) {
async function reportHandle(ctx) {
try {
const { models } = ctx.fs.dc;
@ -216,7 +218,7 @@ async function reportHandle (ctx) {
}
}
async function createReport (ctx) {
async function createReport(ctx) {
try {
const { userId } = ctx.fs.api
const models = ctx.fs.dc.models;
@ -238,7 +240,7 @@ async function createReport (ctx) {
}
}
async function deleteReport (ctx) {
async function deleteReport(ctx) {
try {
const models = ctx.fs.dc.models;
const { reportId } = ctx.params;

28
web/client/src/sections/fillion/components/patrolTable.js

@ -368,23 +368,19 @@ const PatrolNameList = (props) => {
});
return children;
};
if (user?.username === 'SuperAdmin') {
departments = [...new Set(depAllUser)]
} else {
let depAllUserCopy = []
depAllUser.map((item) => {
if (item.depId === user?.departmentId) {
depAllUserCopy.push(item)
}
})
departments = [...new Set(depAllUserCopy)]
if (depAllUser && depAllUser.length) {
if (user?.username === 'SuperAdmin') {
departments = [...new Set(depAllUser)]
} else {
const targetDepartment = depAllUser.find(department => department.users.some(item => item.id === user?.id));
departments = [targetDepartment]
}
const processedData = [];
const expandedKeys = generateData(departments, null, processedData);
setDefaultData(processedData);
setDataList(processedData.map(item => ({ key: item.key, title: item.title.toString(), children: item.children })));
setExpandedKeys(expandedKeys);
}
const processedData = [];
const expandedKeys = generateData(departments, null, processedData);
setDefaultData(processedData);
setDataList(processedData.map(item => ({ key: item.key, title: item.title.toString(), children: item.children })));
setExpandedKeys(expandedKeys);
}, [depAllUser])
useEffect(() => {

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

@ -3,14 +3,30 @@ import { connect } from 'react-redux';
import { Spin } from 'antd';
import ProForm, { ProFormText, ModalForm, ProFormSwitch, ProFormTreeSelect } from '@ant-design/pro-form';
const UserModal = (props) => {
const { visible, modalType, depData, onVisibleChange, onConfirm, editData } = props
const { visible, modalType, depData, onVisibleChange, onConfirm, editData, depMessagedata } = props
const pakData = (dep) => {
// console.log(dep);
return dep.map((d) => {
return {
title: d.name,
value: d.id,
// key: d.id,
children: pakData(d.subordinate)
}
})
}
let depDatas = pakData(depMessagedata || [])
const onFinish = (values) => {
if (onConfirm) {
onConfirm(values);
}
}
const checkName = (rule, value, callback) => {
if (value && value.replace(/[^\u4E00-\u9FA5]/g).includes('undefined')) {
callback(new Error('请输入中文!'));
@ -98,7 +114,7 @@ const UserModal = (props) => {
}}
rules={[{ required: true, message: '请选择所属部门' }]}
request={async () => {
return depData
return depDatas
}}
expandedKeys={["title"]}
/>

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

@ -315,14 +315,14 @@ const UserManage = (props) => {
<Col flex="260px" style={{ height: '100%' }}>
<Card bordered={false} bodyStyle={{ padding: 8, paddingTop: 24, }}>
<Button
{user?.username === 'SuperAdmin' ? <Button
type="primary"
key="primary"
style={{ marginLeft: 10 }}
onClick={() => openDepModal('create')}
disabled={user?.username !== 'SuperAdmin'}
>
新建部门</Button>
新建部门</Button> : null}
{
depMessage.length ?
@ -412,6 +412,7 @@ const UserManage = (props) => {
{
depMessage.length && modalVisible ?
<UserModal
depMessagedata={depMessagedata}
dispatch={dispatch}
visible={modalVisible}
onVisibleChange={setModalVisible}

Loading…
Cancel
Save