🚑️ hotfix: 修复账号新增、编辑字段报错
This commit is contained in:
parent
425f667dff
commit
701e7b465f
|
@ -1,12 +1,12 @@
|
|||
import React from "react";
|
||||
import "./adduserinfo.less";
|
||||
import Ipt from "@/components/input/main";
|
||||
import Form from "@/components/form/main";
|
||||
import FormItem from "@/components/form-item/main";
|
||||
import "@/assets/comm.css";
|
||||
import { Select, Button, ImageUpload, Sweetalert, Notify } from "zent";
|
||||
import Bus from "@/assets/eventBus.js";
|
||||
import cloneDeep from "lodash/cloneDeep";
|
||||
import React from 'react';
|
||||
import './adduserinfo.less';
|
||||
import Ipt from '@/components/input/main';
|
||||
import Form from '@/components/form/main';
|
||||
import FormItem from '@/components/form-item/main';
|
||||
import '@/assets/comm.css';
|
||||
import { Select, Button, ImageUpload, Sweetalert, Notify } from 'zent';
|
||||
import Bus from '@/assets/eventBus.js';
|
||||
import cloneDeep from 'lodash/cloneDeep';
|
||||
import {
|
||||
handelResponse,
|
||||
uploadImg,
|
||||
|
@ -16,7 +16,7 @@ import {
|
|||
getRole,
|
||||
postAddAcc,
|
||||
getDepartmentJob
|
||||
} from "@/assets/api.js";
|
||||
} from '@/assets/api.js';
|
||||
|
||||
export default class addUserinfo extends React.Component {
|
||||
constructor(props) {
|
||||
|
@ -25,24 +25,24 @@ export default class addUserinfo extends React.Component {
|
|||
this.state = {
|
||||
model: {
|
||||
//数据模型不可少
|
||||
user_name: "",
|
||||
mobile: "",
|
||||
password: "",
|
||||
real_name: "",
|
||||
company: "",
|
||||
deparment: "",
|
||||
post: "",
|
||||
station: ""
|
||||
user_name: '',
|
||||
mobile: '',
|
||||
password: '',
|
||||
real_name: '',
|
||||
company: '',
|
||||
deparment: '',
|
||||
post: '',
|
||||
station: ''
|
||||
},
|
||||
companyList: [], //公司
|
||||
departmentList: [], //部门
|
||||
departmentJob: [], //岗位
|
||||
roleList: [], //角色
|
||||
headImg: "",
|
||||
pwdtype: "text",
|
||||
defaultFileList: [{ src: "" }],
|
||||
headImg: '',
|
||||
pwdtype: 'text',
|
||||
defaultFileList: [{ src: '' }],
|
||||
disabled: false,
|
||||
id: ""
|
||||
id: ''
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ export default class addUserinfo extends React.Component {
|
|||
componentWillMount() {
|
||||
let _self = this;
|
||||
this.getCompanyFn(); //获取公司
|
||||
let companys = JSON.parse(sessionStorage.getItem("company"));
|
||||
let companys = JSON.parse(sessionStorage.getItem('company'));
|
||||
if (!companys) {
|
||||
this.getCompanyFn(); //获取公司
|
||||
}
|
||||
|
@ -58,20 +58,20 @@ export default class addUserinfo extends React.Component {
|
|||
this.getRoleFn(); //获取角色
|
||||
let formInfo = this.props;
|
||||
if (formInfo && formInfo.enumer == 1) {
|
||||
this.setState({ pwdtype: "password" });
|
||||
this.setState({ pwdtype: 'password' });
|
||||
let acceptData = cloneDeep(formInfo.rowData);
|
||||
let data = {
|
||||
user_name: acceptData.user_name,
|
||||
mobile: acceptData.mobile,
|
||||
password: "yxtx2021",
|
||||
password: 'yxtx2021',
|
||||
real_name: acceptData.real_name,
|
||||
company: companys.find((o) => o.key == acceptData.company_id),
|
||||
deparment: {
|
||||
key: acceptData.department.id,
|
||||
text: acceptData.department.department_name
|
||||
key: acceptData.department?.id,
|
||||
text: acceptData.department?.department_name
|
||||
},
|
||||
post: { key: acceptData.job.id, text: acceptData.job.job_name },
|
||||
station: { key: acceptData.role.id, text: acceptData.role.role_name }
|
||||
post: { key: acceptData.job?.id, text: acceptData.job?.job_name },
|
||||
station: { key: acceptData.role?.id, text: acceptData.role?.role_name }
|
||||
};
|
||||
let img = {};
|
||||
|
||||
|
@ -130,9 +130,9 @@ export default class addUserinfo extends React.Component {
|
|||
if (valiform) {
|
||||
//取消二次弹出框
|
||||
Sweetalert.confirm({
|
||||
type: "warning",
|
||||
type: 'warning',
|
||||
closeBtn: true,
|
||||
title: "确认操作",
|
||||
title: '确认操作',
|
||||
content:
|
||||
_this.props.enumer == 0 ? (
|
||||
<p>
|
||||
|
@ -166,10 +166,10 @@ export default class addUserinfo extends React.Component {
|
|||
Notify.success(msg);
|
||||
setTimeout(() => {
|
||||
// window.history.back()
|
||||
window.location.replace("#/home/system/account-list");
|
||||
window.location.replace('#/home/system/account-list');
|
||||
sessionStorage.setItem(
|
||||
"pathname2",
|
||||
"/home/system/account-list"
|
||||
'pathname2',
|
||||
'/home/system/account-list'
|
||||
);
|
||||
}, 1000);
|
||||
},
|
||||
|
@ -193,11 +193,11 @@ export default class addUserinfo extends React.Component {
|
|||
Notify.success(msg);
|
||||
setTimeout(() => {
|
||||
sessionStorage.setItem(
|
||||
"pathname2",
|
||||
"/home/system/account-list"
|
||||
'pathname2',
|
||||
'/home/system/account-list'
|
||||
);
|
||||
// window.history.back()
|
||||
window.location.replace("#/home/system/account-list");
|
||||
window.location.replace('#/home/system/account-list');
|
||||
}, 1000);
|
||||
},
|
||||
(err) => {
|
||||
|
@ -209,19 +209,19 @@ export default class addUserinfo extends React.Component {
|
|||
}
|
||||
},
|
||||
onCancel: this.onCancel,
|
||||
className: "questModal",
|
||||
className: 'questModal',
|
||||
parentComponent: this
|
||||
});
|
||||
} else {
|
||||
Notify.clear();
|
||||
Notify.error("请完善表单数据");
|
||||
Notify.error('请完善表单数据');
|
||||
}
|
||||
}
|
||||
onUploadError = (type, data) => {
|
||||
if (type === "overMaxAmount") {
|
||||
if (type === 'overMaxAmount') {
|
||||
Notify.clear();
|
||||
Notify.error(`最多可上传 ${data.maxAmount} 张图片`);
|
||||
} else if (type === "overMaxSize") {
|
||||
} else if (type === 'overMaxSize') {
|
||||
Notify.clear();
|
||||
Notify.error(`图片大小不能超过 ${data.formattedMaxSize}b`);
|
||||
}
|
||||
|
@ -232,8 +232,8 @@ export default class addUserinfo extends React.Component {
|
|||
let _self = this;
|
||||
if (files && files.length > 0) {
|
||||
let formdata = new FormData();
|
||||
formdata.append("file", files[0].file);
|
||||
formdata.append("path", "account_avatar");
|
||||
formdata.append('file', files[0].file);
|
||||
formdata.append('path', 'account_avatar');
|
||||
uploadImg(formdata)
|
||||
.then((res) => {
|
||||
handelResponse(
|
||||
|
@ -250,15 +250,15 @@ export default class addUserinfo extends React.Component {
|
|||
})
|
||||
.catch((err) => {});
|
||||
} else {
|
||||
_self.setState({ headImg: "" });
|
||||
_self.setState({ headImg: '' });
|
||||
}
|
||||
}
|
||||
onCompanyChange(e) {
|
||||
if (!e) {
|
||||
let _self = this;
|
||||
let model2 = this.state.model;
|
||||
model2.deparment = "";
|
||||
model2.post = "";
|
||||
model2.deparment = '';
|
||||
model2.post = '';
|
||||
this.setState({
|
||||
model: model2
|
||||
});
|
||||
|
@ -272,8 +272,8 @@ export default class addUserinfo extends React.Component {
|
|||
//调部门的数据
|
||||
if (e) {
|
||||
let model3 = this.state.model;
|
||||
model3.deparment = "";
|
||||
model3.post = "";
|
||||
model3.deparment = '';
|
||||
model3.post = '';
|
||||
_self.setState({ departmentList: [] });
|
||||
_self.setState({ departmentJob: [] });
|
||||
_self.setState({ model: model3 });
|
||||
|
@ -285,7 +285,7 @@ export default class addUserinfo extends React.Component {
|
|||
(response, msg) => {
|
||||
let departmentList = response.map((item) => {
|
||||
return { key: item.id, text: item.department_name };
|
||||
_self.setState({ deparment: "" });
|
||||
_self.setState({ deparment: '' });
|
||||
});
|
||||
_self.setState({ departmentList });
|
||||
},
|
||||
|
@ -304,7 +304,7 @@ export default class addUserinfo extends React.Component {
|
|||
if (!e) {
|
||||
let _self = this;
|
||||
let model2 = this.state.model;
|
||||
model2.post = "";
|
||||
model2.post = '';
|
||||
this.setState({
|
||||
model: model2
|
||||
});
|
||||
|
@ -328,7 +328,7 @@ export default class addUserinfo extends React.Component {
|
|||
});
|
||||
_self.setState({ departmentJob });
|
||||
let model3 = this.state.model;
|
||||
model3.post = "";
|
||||
model3.post = '';
|
||||
_self.setState({ model: model3 });
|
||||
},
|
||||
(err) => {
|
||||
|
@ -366,7 +366,7 @@ export default class addUserinfo extends React.Component {
|
|||
let companyList = response.map((item) => {
|
||||
return { key: item.id, text: item.company_name };
|
||||
});
|
||||
sessionStorage.setItem("company", JSON.stringify(companyList));
|
||||
sessionStorage.setItem('company', JSON.stringify(companyList));
|
||||
_self.setState({ companyList });
|
||||
},
|
||||
(err) => {
|
||||
|
@ -404,23 +404,23 @@ export default class addUserinfo extends React.Component {
|
|||
.catch((err) => {});
|
||||
}
|
||||
changeKind() {
|
||||
this.setState({ pwdtype: "password" });
|
||||
this.setState({ pwdtype: 'password' });
|
||||
}
|
||||
cancel() {
|
||||
//取消二次弹出框
|
||||
Sweetalert.confirm({
|
||||
type: "warning",
|
||||
type: 'warning',
|
||||
closeBtn: true,
|
||||
title: "确认操作",
|
||||
title: '确认操作',
|
||||
content: <p>是否取消本次操作?</p>,
|
||||
onConfirm: () => {
|
||||
// window.history.back()
|
||||
window.location.replace("#/home/system/account-list");
|
||||
window.location.replace('#/home/system/account-list');
|
||||
|
||||
sessionStorage.setItem("pathname2", "/home/system/account-list");
|
||||
sessionStorage.setItem('pathname2', '/home/system/account-list');
|
||||
},
|
||||
onCancel: this.onCancel,
|
||||
className: "questModal",
|
||||
className: 'questModal',
|
||||
parentComponent: this
|
||||
});
|
||||
}
|
||||
|
@ -434,35 +434,35 @@ export default class addUserinfo extends React.Component {
|
|||
render() {
|
||||
//校验规则
|
||||
const rules = {
|
||||
account: [{ type: "required", message: "请输入手机号" }],
|
||||
account: [{ type: 'required', message: '请输入手机号' }],
|
||||
phone: [
|
||||
{ type: "required", message: "请输入手机号" },
|
||||
{ type: 'required', message: '请输入手机号' },
|
||||
{
|
||||
type: "regExp",
|
||||
message: "手机号格式不正确",
|
||||
reg: "^[1][3,4,5,6,7,8,9][0-9]{9}$"
|
||||
type: 'regExp',
|
||||
message: '手机号格式不正确',
|
||||
reg: '^[1][3,4,5,6,7,8,9][0-9]{9}$'
|
||||
}
|
||||
],
|
||||
pwd: [
|
||||
{ type: "required", message: "请输入密码" },
|
||||
{ type: 'required', message: '请输入密码' },
|
||||
{
|
||||
type: "regExp",
|
||||
message: "6-16位字符,数字+字母组成(字母区分大小写)",
|
||||
reg: "^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$"
|
||||
type: 'regExp',
|
||||
message: '6-16位字符,数字+字母组成(字母区分大小写)',
|
||||
reg: '^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$'
|
||||
}
|
||||
],
|
||||
name: [
|
||||
{ type: "required", message: "请输入真实姓名" },
|
||||
{ type: 'required', message: '请输入真实姓名' },
|
||||
{
|
||||
type: "regExp",
|
||||
message: "2-16字汉字/字母组成",
|
||||
reg: "^([\u4e00-\u9fa5]|[a-zA-Z]){2,16}$"
|
||||
type: 'regExp',
|
||||
message: '2-16字汉字/字母组成',
|
||||
reg: '^([\u4e00-\u9fa5]|[a-zA-Z]){2,16}$'
|
||||
}
|
||||
],
|
||||
company: [{ type: "required", message: "请选择公司" }],
|
||||
deparment: [{ type: "required", message: "请选择部门" }],
|
||||
post: [{ type: "required", message: "请选择岗位" }],
|
||||
station: [{ type: "required", message: "请选择角色" }]
|
||||
company: [{ type: 'required', message: '请选择公司' }],
|
||||
deparment: [{ type: 'required', message: '请选择部门' }],
|
||||
post: [{ type: 'required', message: '请选择岗位' }],
|
||||
station: [{ type: 'required', message: '请选择角色' }]
|
||||
};
|
||||
return (
|
||||
<div id='addaccinfo'>
|
||||
|
@ -480,16 +480,16 @@ export default class addUserinfo extends React.Component {
|
|||
}}
|
||||
onClearItem={(e) => {
|
||||
let model2 = this.state.model;
|
||||
model2.user_name = "";
|
||||
model2.user_name = '';
|
||||
this.setState({ model: model2 });
|
||||
}}
|
||||
value={this.state.model.user_name}
|
||||
placeholder={"请输入手机号"}
|
||||
labelWidth={"0px"}
|
||||
placeholder={'请输入手机号'}
|
||||
labelWidth={'0px'}
|
||||
maxLength={12}
|
||||
height={"36px"}
|
||||
width={"520px"}
|
||||
alignment={"left"}
|
||||
height={'36px'}
|
||||
width={'520px'}
|
||||
alignment={'left'}
|
||||
/>
|
||||
</FormItem>
|
||||
|
||||
|
@ -503,16 +503,16 @@ export default class addUserinfo extends React.Component {
|
|||
}}
|
||||
onClearItem={(e) => {
|
||||
let model2 = this.state.model;
|
||||
model2.mobile = "";
|
||||
model2.mobile = '';
|
||||
this.setState({ model: model2 });
|
||||
}}
|
||||
value={this.state.model.mobile}
|
||||
placeholder={"请输入手机号"}
|
||||
labelWidth={"0px"}
|
||||
placeholder={'请输入手机号'}
|
||||
labelWidth={'0px'}
|
||||
maxLength={11}
|
||||
height={"36px"}
|
||||
width={"520px"}
|
||||
alignment={"left"}
|
||||
height={'36px'}
|
||||
width={'520px'}
|
||||
alignment={'left'}
|
||||
/>
|
||||
</FormItem>
|
||||
<FormItem labelname='密码' prop='pwd' id='pwd'>
|
||||
|
@ -530,16 +530,16 @@ export default class addUserinfo extends React.Component {
|
|||
onfocusFn={(e) => this.changeKind()}
|
||||
onClearItem={(e) => {
|
||||
let model2 = this.state.model;
|
||||
model2.password = "";
|
||||
model2.password = '';
|
||||
this.setState({ model: model2 });
|
||||
}}
|
||||
value={this.state.model.password}
|
||||
placeholder={"请输入密码"}
|
||||
labelWidth={"0px"}
|
||||
placeholder={'请输入密码'}
|
||||
labelWidth={'0px'}
|
||||
maxLength={16}
|
||||
height={"36px"}
|
||||
width={"520px"}
|
||||
alignment={"left"}
|
||||
height={'36px'}
|
||||
width={'520px'}
|
||||
alignment={'left'}
|
||||
/>
|
||||
</FormItem>
|
||||
|
||||
|
@ -552,16 +552,16 @@ export default class addUserinfo extends React.Component {
|
|||
}}
|
||||
onClearItem={(e) => {
|
||||
let model2 = this.state.model;
|
||||
model2.real_name = "";
|
||||
model2.real_name = '';
|
||||
this.setState({ model: model2 });
|
||||
}}
|
||||
value={this.state.model.real_name}
|
||||
placeholder={"请输入真实姓名"}
|
||||
labelWidth={"0px"}
|
||||
placeholder={'请输入真实姓名'}
|
||||
labelWidth={'0px'}
|
||||
maxLength={16}
|
||||
height={"36px"}
|
||||
width={"520px"}
|
||||
alignment={"left"}
|
||||
height={'36px'}
|
||||
width={'520px'}
|
||||
alignment={'left'}
|
||||
/>
|
||||
</FormItem>
|
||||
<FormItem
|
||||
|
@ -575,7 +575,7 @@ export default class addUserinfo extends React.Component {
|
|||
value={this.state.model.company}
|
||||
onChange={(e) => {
|
||||
this.onCompanyChange(e);
|
||||
Bus.emit("change", "company", e);
|
||||
Bus.emit('change', 'company', e);
|
||||
}}
|
||||
/>
|
||||
</FormItem>
|
||||
|
@ -591,7 +591,7 @@ export default class addUserinfo extends React.Component {
|
|||
value={this.state.model.deparment}
|
||||
onChange={(e) => {
|
||||
this.onDepartmentChange(e);
|
||||
Bus.emit("change", "deparment", e);
|
||||
Bus.emit('change', 'deparment', e);
|
||||
}}
|
||||
/>
|
||||
</FormItem>
|
||||
|
@ -607,7 +607,7 @@ export default class addUserinfo extends React.Component {
|
|||
value={this.state.model.post}
|
||||
onChange={(e) => {
|
||||
this.onPostChange(e);
|
||||
Bus.emit("change", "post", e);
|
||||
Bus.emit('change', 'post', e);
|
||||
}}
|
||||
/>
|
||||
</FormItem>
|
||||
|
@ -619,7 +619,7 @@ export default class addUserinfo extends React.Component {
|
|||
value={this.state.model.station}
|
||||
onChange={(e) => {
|
||||
this.onStationChange(e);
|
||||
Bus.emit("change", "station", e);
|
||||
Bus.emit('change', 'station', e);
|
||||
}}
|
||||
popupWidth='360px'
|
||||
width='520px'
|
||||
|
@ -641,7 +641,7 @@ export default class addUserinfo extends React.Component {
|
|||
<div className='mypic'>
|
||||
<b>头像</b>
|
||||
<div className='changepic dflexac'>
|
||||
{this.state.defaultFileList[0].src == "" ? (
|
||||
{this.state.defaultFileList[0].src == '' ? (
|
||||
<ImageUpload
|
||||
className='zent-image-upload-demo'
|
||||
maxSize={500 * 1024}
|
||||
|
|
Loading…
Reference in New Issue