Browse Source

(*)用户增加配置角色

master
peng.peng 1 year ago
parent
commit
8c1d84e5f8
  1. 24
      api/app/lib/controllers/organization/user.js
  2. 16
      web/client/src/sections/organization/components/userModal.js

24
api/app/lib/controllers/organization/user.js

@ -62,7 +62,7 @@ const MD5 = require('crypto-js/md5');
// } // }
// } // }
async function getDepMessage (ctx, next) { async function getDepMessage(ctx, next) {
let error = { name: 'FindError', message: '获取部门列表失败' }; let error = { name: 'FindError', message: '获取部门列表失败' };
let rslt = []; let rslt = [];
try { try {
@ -105,7 +105,7 @@ async function getDepMessage (ctx, next) {
} }
} }
async function createDept (ctx, next) { async function createDept(ctx, next) {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
try { try {
let rslt = ctx.request.body; let rslt = ctx.request.body;
@ -119,7 +119,7 @@ async function createDept (ctx, next) {
} }
} }
async function updateDept (ctx, next) { async function updateDept(ctx, next) {
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
const { id } = ctx.params; const { id } = ctx.params;
@ -137,7 +137,7 @@ async function updateDept (ctx, next) {
} }
} }
async function delDept (ctx, next) { async function delDept(ctx, next) {
let errMsg = "删除部门失败"; let errMsg = "删除部门失败";
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
@ -167,7 +167,7 @@ async function delDept (ctx, next) {
} }
} }
async function getUser (ctx, next) { async function getUser(ctx, next) {
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
const { depId } = ctx.params; const { depId } = ctx.params;
@ -207,7 +207,7 @@ async function getUser (ctx, next) {
} }
} }
async function creatUser (ctx, next) { async function creatUser(ctx, next) {
let errMsg = "新建用户失败" let errMsg = "新建用户失败"
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
@ -226,6 +226,7 @@ async function creatUser (ctx, next) {
} }
await models.User.create({ await models.User.create({
role: data.role,
name: data.name, name: data.name,
username: data.phone, username: data.phone,
password: Hex.stringify(MD5(data.password)), password: Hex.stringify(MD5(data.password)),
@ -249,7 +250,7 @@ async function creatUser (ctx, next) {
} }
async function updateUser (ctx, next) { async function updateUser(ctx, next) {
let errMsg = "修改用户失败" let errMsg = "修改用户失败"
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
@ -268,6 +269,7 @@ async function updateUser (ctx, next) {
} }
await models.User.update({ await models.User.update({
role: data.role,
name: data.name, name: data.name,
username: data.phone, username: data.phone,
departmentId: data.departmentId, departmentId: data.departmentId,
@ -293,7 +295,7 @@ async function updateUser (ctx, next) {
} }
} }
async function deleteUser (ctx, next) { async function deleteUser(ctx, next) {
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
const { ids } = ctx.params; const { ids } = ctx.params;
@ -315,7 +317,7 @@ async function deleteUser (ctx, next) {
} }
} }
async function resetPwd (ctx, next) { async function resetPwd(ctx, next) {
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
const { id } = ctx.params; const { id } = ctx.params;
@ -342,7 +344,7 @@ async function resetPwd (ctx, next) {
* @params {userId-用户Id} ctx * @params {userId-用户Id} ctx
* @request.body {password-用户新密码} ctx * @request.body {password-用户新密码} ctx
*/ */
async function updateUserPassword (ctx, next) { async function updateUserPassword(ctx, next) {
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
const { userId } = ctx.params; const { userId } = ctx.params;
@ -376,7 +378,7 @@ async function updateUserPassword (ctx, next) {
} }
} }
async function getStructuresUsers (ctx, next) { async function getStructuresUsers(ctx, next) {
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;

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

@ -38,8 +38,9 @@ const UserModal = (props) => {
} : } :
{ {
contract: { contract: {
enable: true enable: true,
} role: '巡检人员'
},
} }
} }
> >
@ -195,6 +196,17 @@ const UserModal = (props) => {
valuePropName="checked" valuePropName="checked"
/> />
</ProForm.Group> </ProForm.Group>
<ProFormSelect
name={['contract', 'role']}
colProps={{ md: 12, xl: 12 }}
label="角色"
placeholder="请选择角色"
options={[{ label: '巡检人员', value: '巡检人员' }, { label: '管理人员', value: '管理人员' }]}
rules={[
{ required: true, message: '请选择角色' },
]}
/>
</ModalForm> </ModalForm>
</Spin> </Spin>
) )

Loading…
Cancel
Save