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

master
wuzuowei 4 months ago
parent 4c92545972
commit c4f57cda6d

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

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

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

Loading…
Cancel
Save