开启密码编辑可以增加特殊字符

master
wuzuowei 4 months ago
parent 4c92545972
commit c4f57cda6d

@ -75,8 +75,13 @@ const daye460 = {
pathRewrite: { '^/api/oauth/': '' },
changeOrigin: true,
},
// '/api': {
// target: 'http://172.15.89.222:80/api/',
// pathRewrite: { '^/api': '' },
// changeOrigin: true,
// },
'/api': {
target: 'http://172.15.89.222:80/api/',
target: 'https://craft.dayesteel.com.cn/api/',
pathRewrite: { '^/api': '' },
changeOrigin: true,
},

@ -2,7 +2,7 @@ import React, { useState, useEffect, useRef } from 'react'
import RowBox from '@/components/Box/RowBox'
import { Button, Card, Divider, Form, Input, InputNumber, message, Modal, Popconfirm, Select, Tooltip, Tree, TreeSelect, Upload } from 'antd'
import EditableTable from '@/components/NR_TableEditRow'
import { DeleteOutlined, UploadOutlined, KeyOutlined, EditOutlined, EyeTwoTone, EyeInvisibleOutlined, EyeOutlined ,PictureOutlined,ClearOutlined } from '@ant-design/icons'
import { DeleteOutlined, UploadOutlined, KeyOutlined, EditOutlined, EyeTwoTone, EyeInvisibleOutlined, EyeOutlined, PictureOutlined, ClearOutlined } from '@ant-design/icons'
import CryptoJs, { MD5, SHA256 } from 'crypto-js';
import { User, Module, Role, Organ } from '@/interfaces/interface'
import ImportAndExport from '@/components/NR_ImportAndExport'
@ -15,7 +15,7 @@ import Events from '../events'
import ModuleService from '@/services/modules'
import { addOrganization, addUser, addUserToRole, deleteOrganization, deleteUser, getOrganizations, getRoles, getRolesByAccount, query, removeUserFromRole, updateOrganization, updateUser, updateUserList } from '../../user/role/service'
import FormSelectorInput from '@/components/iBKLinker/form/selector-input'
import { getTreeData,getTreeSelectData } from '@/utils/commoTool'
import { getTreeData, getTreeSelectData } from '@/utils/commoTool'
import { history } from 'umi'
import { isArray } from 'lodash'
@ -29,18 +29,18 @@ interface IManagementAccountEditor {
/**
*
*/
const ManagementAccountEditor : React.FC<IManagementAccountEditor> = (props) => {
const ManagementAccountEditor: React.FC<IManagementAccountEditor> = (props) => {
const thisViewName = "ManagementAccountEditor"
const $emitter: EventView = new EventView(thisViewName)
const encoder = useRef<"md5"|"sha256">(history.location.query?.encoder ? history.location.query?.encoder : "sha256")
const encoder = useRef<"md5" | "sha256">(history.location.query?.encoder ? history.location.query?.encoder : "sha256")
const [isLoading, setIsLoading] = useState<boolean>(false)
const [thisForm] = Form.useForm()
const activeData = useRef<User|undefined>(undefined)
const activeData = useRef<User | undefined>(undefined)
const [roleList, setRoleList] = useState<Role[]>([])
const [organList, setOrganList] = useState<Organ[]>([])
const originRoles = useRef<any[]>([])
const selectOrgan = useRef<Organ|undefined>()
const multiTeamname = useRef<string|undefined>()
const selectOrgan = useRef<Organ | undefined>()
const multiTeamname = useRef<string | undefined>()
useEffect(() => {
@ -59,13 +59,13 @@ const ManagementAccountEditor : React.FC<IManagementAccountEditor> = (props) =>
}, [])
useEffect(() => {
if(!props.data){
if (!props.data) {
thisForm.resetFields()
thisForm.setFieldsValue({
OrganName: selectOrgan.current ? selectOrgan.current.Name : undefined,
})
}
else{
else {
thisForm.setFieldsValue({
...props.data,
})
@ -73,11 +73,11 @@ const ManagementAccountEditor : React.FC<IManagementAccountEditor> = (props) =>
getUserRole(props.data.LoginID)
}
activeData.current = {...props.data}
activeData.current = { ...props.data }
}, [props.data])
useEffect(() => {
if(props.visible){
if (props.visible) {
getRoleList()
}
}, [props.visible])
@ -101,12 +101,12 @@ const ManagementAccountEditor : React.FC<IManagementAccountEditor> = (props) =>
roles = !roles ? [] : roles
originRoles.current = [...roles]
if(roles.length > 0){
if (roles.length > 0) {
thisForm.setFieldsValue({
role: roles.map((rr) => rr.RoleName),
})
}
else{
else {
thisForm.setFieldsValue({
role: undefined,
})
@ -133,7 +133,7 @@ const ManagementAccountEditor : React.FC<IManagementAccountEditor> = (props) =>
setIsLoading(false)
organs = !organs ? [] : organs
setOrganList(organs.length != 0 ? getTreeSelectData(organs, '00000000-0000-0000-0000-000000000000','Guid', 'ParentID', 'Name','Name'): [])
setOrganList(organs.length != 0 ? getTreeSelectData(organs, '00000000-0000-0000-0000-000000000000', 'Guid', 'ParentID', 'Name', 'Name') : [])
}
@ -184,8 +184,10 @@ const ManagementAccountEditor : React.FC<IManagementAccountEditor> = (props) =>
}
},
"rules": [{
pattern: '^[A-Za-z0-9]+$',
message: '密码只能由英文字母和数字组成'
// pattern: '^[A-Za-z0-9]+$',
pattern: '^[A-Za-z0-9@!-]+$',
// message: '密码只能由英文字母和数字组成'
message: '密码只能包含数字字母和@!-'
}],
"inputComponent": <Input.Password iconRender={visible => (visible ? <EyeTwoTone /> : <EyeInvisibleOutlined />)}
/>
@ -293,7 +295,7 @@ const ManagementAccountEditor : React.FC<IManagementAccountEditor> = (props) =>
]
const submitData = async () => {
if(!activeData.current){
if (!activeData.current) {
message.error("请选择一个账号")
return
}
@ -301,17 +303,17 @@ const ManagementAccountEditor : React.FC<IManagementAccountEditor> = (props) =>
await thisForm.validateFields()
let subvals = thisForm.getFieldsValue()
let values = {...activeData.current}
let values = { ...activeData.current }
//let oldData = values.role ? (values.role.value ? values.role.value : values.role) : undefined
for(let s in subvals){
for (let s in subvals) {
values[s] = subvals[s]
}
if(subvals.Uid){
if(subvals.Password2 && subvals.Password2.length > 0){
if (subvals.Uid) {
if (subvals.Password2 && subvals.Password2.length > 0) {
switch(encoder.current){
switch (encoder.current) {
case "md5":
values.Password = CryptoJs.enc.Base64.stringify(MD5(subvals.Password2))
break
@ -324,13 +326,13 @@ const ManagementAccountEditor : React.FC<IManagementAccountEditor> = (props) =>
}
await updateUser(values)
}
else{
else {
values.LineState = 0
values.LoginCount = 0
values.Attributes = 0
//先用MD5加密 再用base64编码
// values.Password = CryptoJs.enc.Base64.stringify(MD5(values.Password))
switch(encoder.current){
switch (encoder.current) {
case "md5":
values.Password = CryptoJs.enc.Base64.stringify(MD5(values.Password2))
break
@ -350,8 +352,8 @@ const ManagementAccountEditor : React.FC<IManagementAccountEditor> = (props) =>
//console.log("update list", values, subvals, roleList)
if (subvals.role != undefined && roleList) {
if(originRoles.current && originRoles.current.length > 0){
for(let ri = 0; ri < originRoles.current.length; ri++){
if (originRoles.current && originRoles.current.length > 0) {
for (let ri = 0; ri < originRoles.current.length; ri++) {
await removeUserFromRole({
LoginId: values.LoginID,
RoleName: originRoles.current[ri].RoleName,
@ -359,8 +361,8 @@ const ManagementAccountEditor : React.FC<IManagementAccountEditor> = (props) =>
}
}
if(isArray(subvals.role)){
for(let ri = 0; ri < subvals.role.length; ri++){
if (isArray(subvals.role)) {
for (let ri = 0; ri < subvals.role.length; ri++) {
let subrole = subvals.role[ri]
let roleData = subrole.value ? subrole.value : subrole//{...values.role}
@ -378,7 +380,7 @@ const ManagementAccountEditor : React.FC<IManagementAccountEditor> = (props) =>
})
}
}
else{
else {
let roleData = subvals.role.value ? subvals.role.value : subvals.role//{...values.role}
await addUserToRole({
@ -404,12 +406,12 @@ const ManagementAccountEditor : React.FC<IManagementAccountEditor> = (props) =>
return (
<Modal title={"编辑模块"} visible={props.visible} onCancel={() => props.onComplete(false)} confirmLoading={isLoading} onOk={() => {
let subvals = thisForm.getFieldsValue()
let values = {...activeData.current}
let values = { ...activeData.current }
console.log("submit data", subvals, values)
submitData()
}}>
<Form form={thisForm} labelCol={{span: 6}} wrapperCol={{span: 18}}>
<Form form={thisForm} labelCol={{ span: 6 }} wrapperCol={{ span: 18 }}>
{
userColumns.slice(1, 9).map((col: any) => (
<Form.Item name={col.dataIndex} label={col.title} rules={col.rules != undefined ? col.rules : []}>
@ -438,11 +440,11 @@ const ManagementAccountEditor : React.FC<IManagementAccountEditor> = (props) =>
count={1}
placeholder='请选择工作组'
options={[
{label: "默认", value: null},
{label: "1/A班", value: "A"},
{label: "2/B班", value: "B"},
{label: "3/C班", value: "C"},
{label: "4/D班", value: "D"},
{ label: "默认", value: null },
{ label: "1/A班", value: "A" },
{ label: "2/B班", value: "B" },
{ label: "3/C班", value: "C" },
{ label: "4/D班", value: "D" },
]}
onChanged={(value) => {
let val: any = value && value.length > 0 ? value[0] : null

@ -107,8 +107,9 @@ const UserManager = (props: any) => {
}
},
"rules": [{ required: true }, {
pattern: '^[A-Za-z0-9]+$',
message: '密码只能由英文字母和数字组成'
pattern: '^[A-Za-z0-9@!-]+$',
// pattern: /^(?=.*[0-9])(?=.*[!@#$%^&*])(?=.*[a-z])(?=.*[A-Z]).{8,}$/,
message: '密码只能包含数字字母和@!-'
}],
"inputComponent": <Input.Password iconRender={visible => (visible ? <EyeTwoTone /> : <EyeInvisibleOutlined />)}
/>
@ -242,7 +243,7 @@ const UserManager = (props: any) => {
// selectedRowKeys: currentClickProductKey,
onSave: async (user: User) => {
//console.log(user)
if(user.Password2 && user.Password2.length > 0){
if (user.Password2 && user.Password2.length > 0) {
user.Password = CryptoJs.enc.Base64.stringify(SHA256(user.Password2))
}
// user.Password = CryptoJs.enc.Base64.stringify(MD5(user.Password))
@ -466,7 +467,7 @@ const UserManager = (props: any) => {
labelCol={{ span: 4 }} wrapperCol={{ span: 20 }}
onFinish={async (values: any) => {
if (!editFlag) {
values.Guid=uuidGenerator()
values.Guid = uuidGenerator()
await addOrganization(values).then((response: any) => {
init()
})

Loading…
Cancel
Save