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

master
wuzuowei 4 months ago
parent 4c92545972
commit c4f57cda6d

@ -8,103 +8,108 @@
*/
const bsc = {
'/baseApi': {
target: 'http://192.168.10.91:8090/api/',
pathRewrite: { '^/baseApi': '' },
changeOrigin: true,
},
'/api': {
target: 'http://192.168.10.91:8090/api/',
pathRewrite: { '^/api': '' },
changeOrigin: true,
},
'/statics': {
target: 'http://192.168.10.92/statics/',
pathRewrite: { '^/statics': '' },
changeOrigin: true,
},
'/sso/oauth': {
target: 'http://192.168.10.91:8015/api/oauth/',
pathRewrite: { '^/sso/oauth': '' },
changeOrigin: true,
},
'/baseApi': {
target: 'http://192.168.10.91:8090/api/',
pathRewrite: { '^/baseApi': '' },
changeOrigin: true,
},
'/api': {
target: 'http://192.168.10.91:8090/api/',
pathRewrite: { '^/api': '' },
changeOrigin: true,
},
'/statics': {
target: 'http://192.168.10.92/statics/',
pathRewrite: { '^/statics': '' },
changeOrigin: true,
},
'/sso/oauth': {
target: 'http://192.168.10.91:8015/api/oauth/',
pathRewrite: { '^/sso/oauth': '' },
changeOrigin: true,
},
};
const huadong = {
'/baseApi': {
target: 'http://192.168.10.91:8090/api/',
pathRewrite: { '^/baseApi': '' },
changeOrigin: true,
},
// '/api/oauth/': {
// target: 'http://192.168.10.91:8060/oauth/',
// pathRewrite: { '^/api/oauth/': '' },
// changeOrigin: true,
// },
'/api': {
target: 'http://192.168.10.91:8090/api/',
pathRewrite: { '^/api': '' },
changeOrigin: true,
},
'/statics': {
target: 'http://192.168.10.92/statics/',
pathRewrite: { '^/statics': '' },
changeOrigin: true,
},
'/download': {
target: 'http://192.168.10.92/download/',
pathRewrite: { '^/download': '' },
changeOrigin: true,
},
'/sso/oauth': {
target: 'http://192.168.10.91:8090/api/oauth/',
pathRewrite: { '^/sso/oauth': '' },
changeOrigin: true,
},
'/baseApi': {
target: 'http://192.168.10.91:8090/api/',
pathRewrite: { '^/baseApi': '' },
changeOrigin: true,
},
// '/api/oauth/': {
// target: 'http://192.168.10.91:8060/oauth/',
// pathRewrite: { '^/api/oauth/': '' },
// changeOrigin: true,
// },
'/api': {
target: 'http://192.168.10.91:8090/api/',
pathRewrite: { '^/api': '' },
changeOrigin: true,
},
'/statics': {
target: 'http://192.168.10.92/statics/',
pathRewrite: { '^/statics': '' },
changeOrigin: true,
},
'/download': {
target: 'http://192.168.10.92/download/',
pathRewrite: { '^/download': '' },
changeOrigin: true,
},
'/sso/oauth': {
target: 'http://192.168.10.91:8090/api/oauth/',
pathRewrite: { '^/sso/oauth': '' },
changeOrigin: true,
},
};
const daye460 = {
'/baseApi': {
target: 'http://172.15.199.55:8090/api/',
pathRewrite: { '^/baseApi': '' },
changeOrigin: true,
},
'/api/oauth/': {
target: 'http://172.15.89.246:8060/oauth/',
pathRewrite: { '^/api/oauth/': '' },
changeOrigin: true,
},
'/api': {
target: 'http://172.15.89.222:80/api/',
pathRewrite: { '^/api': '' },
changeOrigin: true,
},
'/statics': {
target: 'http://172.15.199.56/statics/',
pathRewrite: { '^/statics': '' },
changeOrigin: true,
},
'/download': {
target: 'http://172.15.199.56/download/',
pathRewrite: { '^/download': '' },
changeOrigin: true,
},
'/sso/oauth': {
target: 'http://172.15.199.55:8090/api/oauth/',
pathRewrite: { '^/sso/oauth': '' },
changeOrigin: true,
},
'/CZapi': {
target: 'http://172.15.89.232:8081/api/',//材智接口
pathRewrite: { '^/CZapi': '' },
changeOrigin: true,
},
'/openapi': {
target: 'http://172.15.89.232:8081/openapi/',//材智接口
pathRewrite: { '^/openapi': '' },
changeOrigin: true,
},
'/baseApi': {
target: 'http://172.15.199.55:8090/api/',
pathRewrite: { '^/baseApi': '' },
changeOrigin: true,
},
'/api/oauth/': {
target: 'http://172.15.89.246:8060/oauth/',
pathRewrite: { '^/api/oauth/': '' },
changeOrigin: true,
},
// '/api': {
// target: 'http://172.15.89.222:80/api/',
// pathRewrite: { '^/api': '' },
// changeOrigin: true,
// },
'/api': {
target: 'https://craft.dayesteel.com.cn/api/',
pathRewrite: { '^/api': '' },
changeOrigin: true,
},
'/statics': {
target: 'http://172.15.199.56/statics/',
pathRewrite: { '^/statics': '' },
changeOrigin: true,
},
'/download': {
target: 'http://172.15.199.56/download/',
pathRewrite: { '^/download': '' },
changeOrigin: true,
},
'/sso/oauth': {
target: 'http://172.15.199.55:8090/api/oauth/',
pathRewrite: { '^/sso/oauth': '' },
changeOrigin: true,
},
'/CZapi': {
target: 'http://172.15.89.232:8081/api/',//材智接口
pathRewrite: { '^/CZapi': '' },
changeOrigin: true,
},
'/openapi': {
target: 'http://172.15.89.232:8081/openapi/',//材智接口
pathRewrite: { '^/openapi': '' },
changeOrigin: true,
},
};

@ -1,8 +1,8 @@
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 { 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,444 +15,446 @@ 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'
interface IManagementAccountEditor {
visible: boolean,
data?: any,
modules?: any[],
onComplete: (result: any) => void,
visible: boolean,
data?: any,
modules?: any[],
onComplete: (result: any) => void,
}
/**
*
*/
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 [isLoading, setIsLoading] = useState<boolean>(false)
const [thisForm] = Form.useForm()
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>()
useEffect(() => {
$emitter.subscribe(Events.accounts.org.selected, (organ?: Organ) => {
selectOrgan.current = organ
thisForm.setFieldsValue({
OrganName: selectOrgan.current ? selectOrgan.current.Name : undefined,
OrganID: selectOrgan.current ? selectOrgan.current.Guid : undefined,
})
})
return () => {
$emitter.dispose()
}
}, [])
useEffect(() => {
if(!props.data){
thisForm.resetFields()
thisForm.setFieldsValue({
OrganName: selectOrgan.current ? selectOrgan.current.Name : undefined,
})
}
else{
thisForm.setFieldsValue({
...props.data,
})
getUserRole(props.data.LoginID)
}
activeData.current = {...props.data}
}, [props.data])
useEffect(() => {
if(props.visible){
getRoleList()
}
}, [props.visible])
useEffect(() => {
prepareData()
return () => {
$emitter.dispose()
}
}, [])
const getUserRole = async (loginId: string) => {
setIsLoading(true)
let roles: any[] = await getRolesByAccount(loginId)
setIsLoading(false)
roles = !roles ? [] : roles
originRoles.current = [...roles]
if(roles.length > 0){
thisForm.setFieldsValue({
role: roles.map((rr) => rr.RoleName),
})
}
else{
thisForm.setFieldsValue({
role: undefined,
})
}
}
const getRoleList = async () => {
setIsLoading(true)
const roles: Role[] = await getRoles()
setIsLoading(false)
if (roles.length != 0) {
roles.map((item: any) => {
item.label = item.Name
item.value = item.Name
})
}
setRoleList(roles)
}
const prepareData = async () => {
setIsLoading(true)
let organs = await getOrganizations()
setIsLoading(false)
organs = !organs ? [] : organs
setOrganList(organs.length != 0 ? getTreeSelectData(organs, '00000000-0000-0000-0000-000000000000','Guid', 'ParentID', 'Name','Name'): [])
}
const userColumns = [
{
"title": '序号',
"key": 'userId',
"dataIndex": 'userId',
"editable": false,
"ellipsis": true,
"render": (userId: string, record: User, index: number) => {
return (index + 1).toString()
}
}, {
"title": '用户名',
"key": 'Name',
"dataIndex": 'Name',
"ellipsis": true,
"editable": true,
"rules": [{ required: true }, {
pattern: '^[\u4e00-\u9fa5]{0,}$',
message: '用户名必须为汉字'
}],
...getColumnSearchProps('Name')
}, {
"title": '账号',
"key": 'LoginID',
"dataIndex": 'LoginID',
"ellipsis": true,
"editable": true,
"rules": [{ required: true }, {
pattern: /^[a-zA-Z\d]+$/,
message: '账号为小写字母或数字'
}]
}, {
"title": '密码',
"key": 'Password2',
"dataIndex": 'Password2',
"ellipsis": true,
"editable": true,
"render": (Password: string) => {
if (Password == null || Password.length == 0) {
return '暂无'
} else {
return null
}
},
"rules": [{
pattern: '^[A-Za-z0-9]+$',
message: '密码只能由英文字母和数字组成'
}],
"inputComponent": <Input.Password iconRender={visible => (visible ? <EyeTwoTone /> : <EyeInvisibleOutlined />)}
/>
}, {
"title": '邮箱',
"key": 'Email',
"dataIndex": 'Email',
"ellipsis": true,
"editable": true,
"rules": [
{
pattern: /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/,
message: '邮箱格式不正确',
}, {
max: 50,
message: '邮箱不得超过50字符',
},
]
},
{
"title": '用户群组',
"key": 'OrganName',
"dataIndex": 'OrganName',
"editable": false,
"ellipsis": true,
// "inputComponent": <Select options={values}/>,
"inputComponent": <TreeSelect
treeData={organList}
/>,
"rules": [{ required: true }],
"onFilter": (value: any, record: any) => record.OrganName != undefined && record.OrganName == value,
},
{
"title": '地址',
"key": 'Address',
"dataIndex": 'Address',
"ellipsis": true,
"editable": true,
}, {
"title": '备注',
"key": 'Description',
"dataIndex": 'Description',
"editable": true,
"ellipsis": true,
"render": (Description: string) => {
if (Description == null || Description.length == 0) {
return '无'
} else {
return Description
}
}
}, {
"title": '是否主管',
"key": 'Leader',
"dataIndex": 'Leader',
"ellipsis": true,
"inputComponent": <Select options={[
{
'label': "否",
'value': 0
}, {
'label': "是",
'value': 1
}
]} />,
"filters": [
{
text: '是',
value: 1,
},
{
text: '否',
value: 0,
},
],
"filterMultiple": false,
"onFilter": (value: any, record: any) => record.Leader != undefined && record.Leader === value,
}, {
"title": '登录次数',
"key": 'LoginCount',
"dataIndex": 'LoginCount',
"ellipsis": true,
}, {
"title": '在线状态',
"key": 'LineState',
"dataIndex": 'LineState',
"ellipsis": true,
"render": (LineState: any) => {
return parseInt(LineState) == 1 ? '在线' : '离线'
},
"filters": [
{
text: '在线',
value: 1,
},
{
text: '离线',
value: 0,
},
],
"filterMultiple": false,
"onFilter": (value: any, record: any) => record.LineState != undefined && record.LineState === value,
}
]
const submitData = async () => {
if(!activeData.current){
message.error("请选择一个账号")
return
}
await thisForm.validateFields()
let subvals = thisForm.getFieldsValue()
let values = {...activeData.current}
//let oldData = values.role ? (values.role.value ? values.role.value : values.role) : undefined
for(let s in subvals){
values[s] = subvals[s]
}
if(subvals.Uid){
if(subvals.Password2 && subvals.Password2.length > 0){
switch(encoder.current){
case "md5":
values.Password = CryptoJs.enc.Base64.stringify(MD5(subvals.Password2))
break
case "sha256":
default:
values.Password = CryptoJs.enc.Base64.stringify(SHA256(subvals.Password2))
break
}
}
await updateUser(values)
}
else{
values.LineState = 0
values.LoginCount = 0
values.Attributes = 0
//先用MD5加密 再用base64编码
// values.Password = CryptoJs.enc.Base64.stringify(MD5(values.Password))
switch(encoder.current){
case "md5":
values.Password = CryptoJs.enc.Base64.stringify(MD5(values.Password2))
break
case "sha256":
default:
values.Password = CryptoJs.enc.Base64.stringify(SHA256(values.Password2))
break
}
await addUser(values)
}
// values.Password2 = CryptoJs.enc.Base64.stringify(SHA256(values.Password2))
//console.log("add user", values)
// await addUser(values)
//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++){
await removeUserFromRole({
LoginId: values.LoginID,
RoleName: originRoles.current[ri].RoleName,
})
}
}
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}
await addUserToRole({
"role": {
"Name": roleData,
"Description": roleData,
},
"accountRoleList": [
{
"LoginId": values.LoginID,
"RoleName": roleData
}
]
})
}
}
else{
let roleData = subvals.role.value ? subvals.role.value : subvals.role//{...values.role}
await addUserToRole({
"role": {
"Name": roleData,
"Description": roleData,
},
"accountRoleList": [
{
"LoginId": values.LoginID,
"RoleName": roleData
}
]
})
}
}
props.onComplete && props.onComplete(true)
}
return (
<Modal title={"编辑模块"} visible={props.visible} onCancel={() => props.onComplete(false)} confirmLoading={isLoading} onOk={() => {
let subvals = thisForm.getFieldsValue()
let values = {...activeData.current}
console.log("submit data", subvals, values)
submitData()
}}>
<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 : []}>
{col.inputComponent != undefined ? col.inputComponent : <Input />}
</Form.Item>
))
}
<Form.Item name="role" label="角色" >
<Select
mode={"multiple"}
labelInValue
options={roleList}
/>
</Form.Item>
<Form.Item name="OrganID" label="OrganID" style={{ display: 'none' }}>
<Select />
</Form.Item>
<Form.Item name="Uid" label="Uid" style={{ display: 'none' }}>
<Input />
</Form.Item>
<Form.Item name="Password" label="Password" style={{ display: 'none' }}>
<Input type={"password"} />
</Form.Item>
<Form.Item name="WorkTeam" label="工作小组">
<FormSelectorInput size='small'
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"},
]}
onChanged={(value) => {
let val: any = value && value.length > 0 ? value[0] : null
multiTeamname.current = val
}}
/>
</Form.Item>
</Form>
</Modal>
)
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 [isLoading, setIsLoading] = useState<boolean>(false)
const [thisForm] = Form.useForm()
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>()
useEffect(() => {
$emitter.subscribe(Events.accounts.org.selected, (organ?: Organ) => {
selectOrgan.current = organ
thisForm.setFieldsValue({
OrganName: selectOrgan.current ? selectOrgan.current.Name : undefined,
OrganID: selectOrgan.current ? selectOrgan.current.Guid : undefined,
})
})
return () => {
$emitter.dispose()
}
}, [])
useEffect(() => {
if (!props.data) {
thisForm.resetFields()
thisForm.setFieldsValue({
OrganName: selectOrgan.current ? selectOrgan.current.Name : undefined,
})
}
else {
thisForm.setFieldsValue({
...props.data,
})
getUserRole(props.data.LoginID)
}
activeData.current = { ...props.data }
}, [props.data])
useEffect(() => {
if (props.visible) {
getRoleList()
}
}, [props.visible])
useEffect(() => {
prepareData()
return () => {
$emitter.dispose()
}
}, [])
const getUserRole = async (loginId: string) => {
setIsLoading(true)
let roles: any[] = await getRolesByAccount(loginId)
setIsLoading(false)
roles = !roles ? [] : roles
originRoles.current = [...roles]
if (roles.length > 0) {
thisForm.setFieldsValue({
role: roles.map((rr) => rr.RoleName),
})
}
else {
thisForm.setFieldsValue({
role: undefined,
})
}
}
const getRoleList = async () => {
setIsLoading(true)
const roles: Role[] = await getRoles()
setIsLoading(false)
if (roles.length != 0) {
roles.map((item: any) => {
item.label = item.Name
item.value = item.Name
})
}
setRoleList(roles)
}
const prepareData = async () => {
setIsLoading(true)
let organs = await getOrganizations()
setIsLoading(false)
organs = !organs ? [] : organs
setOrganList(organs.length != 0 ? getTreeSelectData(organs, '00000000-0000-0000-0000-000000000000', 'Guid', 'ParentID', 'Name', 'Name') : [])
}
const userColumns = [
{
"title": '序号',
"key": 'userId',
"dataIndex": 'userId',
"editable": false,
"ellipsis": true,
"render": (userId: string, record: User, index: number) => {
return (index + 1).toString()
}
}, {
"title": '用户名',
"key": 'Name',
"dataIndex": 'Name',
"ellipsis": true,
"editable": true,
"rules": [{ required: true }, {
pattern: '^[\u4e00-\u9fa5]{0,}$',
message: '用户名必须为汉字'
}],
...getColumnSearchProps('Name')
}, {
"title": '账号',
"key": 'LoginID',
"dataIndex": 'LoginID',
"ellipsis": true,
"editable": true,
"rules": [{ required: true }, {
pattern: /^[a-zA-Z\d]+$/,
message: '账号为小写字母或数字'
}]
}, {
"title": '密码',
"key": 'Password2',
"dataIndex": 'Password2',
"ellipsis": true,
"editable": true,
"render": (Password: string) => {
if (Password == null || Password.length == 0) {
return '暂无'
} else {
return null
}
},
"rules": [{
// pattern: '^[A-Za-z0-9]+$',
pattern: '^[A-Za-z0-9@!-]+$',
// message: '密码只能由英文字母和数字组成'
message: '密码只能包含数字字母和@!-'
}],
"inputComponent": <Input.Password iconRender={visible => (visible ? <EyeTwoTone /> : <EyeInvisibleOutlined />)}
/>
}, {
"title": '邮箱',
"key": 'Email',
"dataIndex": 'Email',
"ellipsis": true,
"editable": true,
"rules": [
{
pattern: /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/,
message: '邮箱格式不正确',
}, {
max: 50,
message: '邮箱不得超过50字符',
},
]
},
{
"title": '用户群组',
"key": 'OrganName',
"dataIndex": 'OrganName',
"editable": false,
"ellipsis": true,
// "inputComponent": <Select options={values}/>,
"inputComponent": <TreeSelect
treeData={organList}
/>,
"rules": [{ required: true }],
"onFilter": (value: any, record: any) => record.OrganName != undefined && record.OrganName == value,
},
{
"title": '地址',
"key": 'Address',
"dataIndex": 'Address',
"ellipsis": true,
"editable": true,
}, {
"title": '备注',
"key": 'Description',
"dataIndex": 'Description',
"editable": true,
"ellipsis": true,
"render": (Description: string) => {
if (Description == null || Description.length == 0) {
return '无'
} else {
return Description
}
}
}, {
"title": '是否主管',
"key": 'Leader',
"dataIndex": 'Leader',
"ellipsis": true,
"inputComponent": <Select options={[
{
'label': "否",
'value': 0
}, {
'label': "是",
'value': 1
}
]} />,
"filters": [
{
text: '是',
value: 1,
},
{
text: '否',
value: 0,
},
],
"filterMultiple": false,
"onFilter": (value: any, record: any) => record.Leader != undefined && record.Leader === value,
}, {
"title": '登录次数',
"key": 'LoginCount',
"dataIndex": 'LoginCount',
"ellipsis": true,
}, {
"title": '在线状态',
"key": 'LineState',
"dataIndex": 'LineState',
"ellipsis": true,
"render": (LineState: any) => {
return parseInt(LineState) == 1 ? '在线' : '离线'
},
"filters": [
{
text: '在线',
value: 1,
},
{
text: '离线',
value: 0,
},
],
"filterMultiple": false,
"onFilter": (value: any, record: any) => record.LineState != undefined && record.LineState === value,
}
]
const submitData = async () => {
if (!activeData.current) {
message.error("请选择一个账号")
return
}
await thisForm.validateFields()
let subvals = thisForm.getFieldsValue()
let values = { ...activeData.current }
//let oldData = values.role ? (values.role.value ? values.role.value : values.role) : undefined
for (let s in subvals) {
values[s] = subvals[s]
}
if (subvals.Uid) {
if (subvals.Password2 && subvals.Password2.length > 0) {
switch (encoder.current) {
case "md5":
values.Password = CryptoJs.enc.Base64.stringify(MD5(subvals.Password2))
break
case "sha256":
default:
values.Password = CryptoJs.enc.Base64.stringify(SHA256(subvals.Password2))
break
}
}
await updateUser(values)
}
else {
values.LineState = 0
values.LoginCount = 0
values.Attributes = 0
//先用MD5加密 再用base64编码
// values.Password = CryptoJs.enc.Base64.stringify(MD5(values.Password))
switch (encoder.current) {
case "md5":
values.Password = CryptoJs.enc.Base64.stringify(MD5(values.Password2))
break
case "sha256":
default:
values.Password = CryptoJs.enc.Base64.stringify(SHA256(values.Password2))
break
}
await addUser(values)
}
// values.Password2 = CryptoJs.enc.Base64.stringify(SHA256(values.Password2))
//console.log("add user", values)
// await addUser(values)
//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++) {
await removeUserFromRole({
LoginId: values.LoginID,
RoleName: originRoles.current[ri].RoleName,
})
}
}
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}
await addUserToRole({
"role": {
"Name": roleData,
"Description": roleData,
},
"accountRoleList": [
{
"LoginId": values.LoginID,
"RoleName": roleData
}
]
})
}
}
else {
let roleData = subvals.role.value ? subvals.role.value : subvals.role//{...values.role}
await addUserToRole({
"role": {
"Name": roleData,
"Description": roleData,
},
"accountRoleList": [
{
"LoginId": values.LoginID,
"RoleName": roleData
}
]
})
}
}
props.onComplete && props.onComplete(true)
}
return (
<Modal title={"编辑模块"} visible={props.visible} onCancel={() => props.onComplete(false)} confirmLoading={isLoading} onOk={() => {
let subvals = thisForm.getFieldsValue()
let values = { ...activeData.current }
console.log("submit data", subvals, values)
submitData()
}}>
<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 : []}>
{col.inputComponent != undefined ? col.inputComponent : <Input />}
</Form.Item>
))
}
<Form.Item name="role" label="角色" >
<Select
mode={"multiple"}
labelInValue
options={roleList}
/>
</Form.Item>
<Form.Item name="OrganID" label="OrganID" style={{ display: 'none' }}>
<Select />
</Form.Item>
<Form.Item name="Uid" label="Uid" style={{ display: 'none' }}>
<Input />
</Form.Item>
<Form.Item name="Password" label="Password" style={{ display: 'none' }}>
<Input type={"password"} />
</Form.Item>
<Form.Item name="WorkTeam" label="工作小组">
<FormSelectorInput size='small'
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" },
]}
onChanged={(value) => {
let val: any = value && value.length > 0 ? value[0] : null
multiTeamname.current = val
}}
/>
</Form.Item>
</Form>
</Modal>
)
}
export default ManagementAccountEditor

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save