Commit 8a8364cb authored by cellee's avatar cellee

重做权限管理页面

Signed-off-by: cellee's avatarcellee <893264950@qq.com>
parent 5a981862
...@@ -21,6 +21,7 @@ const TitleSearch = (props: any) => { ...@@ -21,6 +21,7 @@ const TitleSearch = (props: any) => {
defaultValue, defaultValue,
time, time,
username, username,
searchNone, // 隐藏搜索框
} = props; } = props;
const key = props.listkey; const key = props.listkey;
...@@ -184,15 +185,19 @@ const TitleSearch = (props: any) => { ...@@ -184,15 +185,19 @@ const TitleSearch = (props: any) => {
/> />
) : null} ) : null}
<Form.Item style={{ marginBottom: 5 }}> {searchNone == null ? (
<Button <Form.Item style={{ marginBottom: 5 }}>
type="primary" <Button
htmlType="submit" type="primary"
style={{ backgroundColor: '#e7f4ff', color: 'rgba(24,144,255,1)' }} htmlType="submit"
> style={{ backgroundColor: '#e7f4ff', color: 'rgba(24,144,255,1)' }}
<SearchOutlined /> Search >
</Button> <SearchOutlined /> Search
</Form.Item> </Button>
</Form.Item>
) : (
''
)}
</> </>
) : null} ) : null}
</Form> </Form>
......
...@@ -58,6 +58,12 @@ export default { ...@@ -58,6 +58,12 @@ export default {
yield put({ type: 'returnPage', Data }); yield put({ type: 'returnPage', Data });
} }
break; break;
case 51:
{
let Data = resp.data;
yield put({ type: 'returnPage', Data });
}
break;
} }
} }
}, },
......
...@@ -3,10 +3,47 @@ ...@@ -3,10 +3,47 @@
padding: 20px; padding: 20px;
border-right: 4px; border-right: 4px;
margin-bottom: 15px; margin-bottom: 15px;
h3 {
margin-bottom: 0;
position: relative;
.back {
position: absolute;
right: 0;
top: 0;
top: -2px;
background: #fff;
}
}
.capi {
text-transform: capitalize;
line-height: 34px;
}
.pages { .pages {
text-align: right; text-align: right;
padding: 10px; padding: 10px;
} }
.ant-descriptions-row > th,
.ant-descriptions-row > td {
margin-bottom: 0;
padding-bottom: 0;
}
.ant-form-item-label,
.label {
min-width: 100px;
}
.label {
span.title {
line-height: 32px;
display: block;
text-align: right;
}
}
.input {
width: 180px;
}
.diy {
display: flex;
}
} }
.contop2 { .contop2 {
padding: 0 10px 20px; padding: 0 10px 20px;
......
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import { Form, Input, Button, Pagination } from 'antd'; import { Form, Input, Button, Pagination, message } from 'antd';
import { connect, history } from 'umi'; import { connect, history } from 'umi';
import { SearchOutlined, ClearOutlined, PlusOutlined } from '@ant-design/icons'; import { SearchOutlined, ClearOutlined, PlusOutlined } from '@ant-design/icons';
import ProTable from '@ant-design/pro-table'; import ProTable from '@ant-design/pro-table';
...@@ -15,24 +15,22 @@ const Account = (props: any) => { ...@@ -15,24 +15,22 @@ const Account = (props: any) => {
dispatch({ type: 'Account/RA', playload: { index: index, body: values } }); dispatch({ type: 'Account/RA', playload: { index: index, body: values } });
}; };
// 数据
useEffect(() => {
let obj = {
leaderID: getCookie('id'),
};
RA(45, obj);
}, [1]); //页面进来执行一次
// 数据 // 数据
useEffect(() => { useEffect(() => {
if (Data == null) { if (Data == null) {
let obj = { let obj = {
leaderID: getCookie('id'), leaderID: getCookie('id'),
pageNum: 1,
}; };
RA(45, obj); // RA(45, obj);
setTerm(obj);
RA(51, obj);
} }
}, [Data]); //页面进来执行一次 }, [Data]); //页面进来执行一次
// 拉取数据的条件存储
const [term, setTerm] = useState({} as any);
// 表单标识 // 表单标识
const [form] = Form.useForm(); const [form] = Form.useForm();
...@@ -109,12 +107,36 @@ const Account = (props: any) => { ...@@ -109,12 +107,36 @@ const Account = (props: any) => {
}, },
]; ];
// 编辑- 新增
const edit = (item: any) => { const edit = (item: any) => {
history.push('./account/edit'); history.push('./account/edit');
}; };
// 停用账号
const lockS = (item: any) => {}; const lockS = (item: any) => {};
// 表头单搜索
const onFinishContract = (value: any) => {
if (value.creatorName || value.accountName) {
let t = { ...term, ...value };
delete t.pageNum; // 搜索的时候 删除页码
setTerm(t);
RA(51, t);
} else {
message.error('Enter At Least One Entry!');
}
};
// 页码切换
const sopens = (page: any) => {
let p = {
pageNum: page,
};
let t = { ...term, ...p };
setTerm(t);
RA(51, t);
};
return ( return (
<> <>
<div className="contop"> <div className="contop">
...@@ -123,12 +145,12 @@ const Account = (props: any) => { ...@@ -123,12 +145,12 @@ const Account = (props: any) => {
layout="inline" layout="inline"
form={form} form={form}
name="contract" name="contract"
// onFinish={onFinishContract} onFinish={onFinishContract}
> >
<Form.Item name="username"> <Form.Item name="accountName">
<Input allowClear placeholder="Account Name" /> <Input allowClear placeholder="Account Name" />
</Form.Item> </Form.Item>
<Form.Item name="creator"> <Form.Item name="creatorName">
<Input allowClear placeholder="Account Creator" /> <Input allowClear placeholder="Account Creator" />
</Form.Item> </Form.Item>
<Form.Item> <Form.Item>
...@@ -153,7 +175,7 @@ const Account = (props: any) => { ...@@ -153,7 +175,7 @@ const Account = (props: any) => {
<ProTable <ProTable
// request={requestHeadl} // request={requestHeadl}
rowKey={'id'} rowKey={'id'}
dataSource={Data ? Data.rows : null} dataSource={Data ? Data.list : null}
columns={columns} columns={columns}
pagination={false} // 隐藏默认分页 pagination={false} // 隐藏默认分页
search={false} search={false}
...@@ -185,9 +207,10 @@ const Account = (props: any) => { ...@@ -185,9 +207,10 @@ const Account = (props: any) => {
<div className="pages"> <div className="pages">
<Pagination <Pagination
// onShowSizeChange={pageSizeHandler} // onShowSizeChange={pageSizeHandler}
// current={Data.total} current={Data ? Data.page.currentPage : 0}
total={Data ? Data.total : 0} onChange={sopens}
pageSize={Data ? Data.total : 0} total={Data ? Data.page.totalRow : 0}
pageSize={Data ? Data.page.curPageSize : 0}
/> />
</div> </div>
</div> </div>
......
import React from 'react';
import {connect, routerRedux} from 'dva';
import {Button, Input, Upload, Icon, Checkbox, Row, Tooltip, List, Modal,Select} from "antd";
import styles from './style.less';
import {ConnectState} from "@/models/connect";
import XLSX from './xlsx.core.min';
import {router} from "umi";
import permission from "@/models/permission";
import TitleSearch from "@/components/TitleSearch/TitleSearch";
let go = 0;
let deviceData = [];
let checkUser = 1;
class AccountEdit extends React.Component {
//构造
constructor(props) {
super(props);
this.state = {
account: '',
pw: '',
pw2: '',
id: '',
email: '',
phone: '',
status: '',
radio: 2,
createUser: '',
userId: '',
defaultLevel:'',
permission: [],
targetKeys: [],
deviceData: [],
visible: false,
visible2: false,
newEdit: false,
level: '',
levelList: [{label: '四级管理员', value: 1},
{label: '三级管理员', value: 2},
{label: '二级管理员', value: 3},
{label: '一级管理员', value: 4},
{label: '超级管理员', value: 5}
],
leaderList: [{userAccount: '未选择管理员等级'}],
adList: ["一级管理员", "二级管理员","三级管理员"],
leader: '',
deviceList: [],
addDevice: '',
flag: 1,
used: null,
newAdd: null,
strList: [],
}
}
/*----------------- 方法集 ------------------*/
//显示信息
info() {
let _this = this;
const { used, newAdd, strList} = this.state;
const strSelect = strList.map((item, index) => (
<p>{item}</p>
));
Modal.info({
title: '批量导入结果',
content: (
<div>
<p>绑定<span style={{color:"lightgreen",fontSize:24}}>{newAdd}</span>台设备,
以下<span style={{color:"red",fontSize:24}}>{used}</span>台设备已被占用</p>
{strSelect}
</div>
),
onOk() {
_this.back();
},
});
}
//检测是否存在相同用户
checkUser = () => {
checkUser = 1;
if(this.state.account==null||this.state.account.trim()==''||this.state.account==undefined){
alert("未输入账号名称!");
checkUser = 0;
return;
}
this.props.dispatch({
type: 'accountModel/checkAccountByName',
payload: {
username: this.state.account,
},
callback: (res) => {
if (res) {
if (res.error_code == "0000") {
checkUser = 0;
alert(res.error_msg);
} else if(res.error_code == "0008"){
alert(res.error_msg);
window.location.href = '/';
router.replace('/');
} else {
checkUser = 1;
}
}
}
});
};
//跳转到账户页面
back = () => {
this.props.dispatch(routerRedux.push({
pathname: '/AccountManagement/account',
}))
};
//获取所有上级
getAllLeader = (level) => {
const params = {
userLevel: level,
};
this.props.dispatch({
type: 'accountModel/getAllLeader',
payload: params,
callback: (res) => {
if (res) {
this.setState({
leaderList: res,
})
}
}
});
};
//两次密码校对
checkPw = () => {
if (this.state.pw == null || this.state.pw == undefined || this.state.pw.trim() == '') {
alert("未输入密码!");
go = 0;
} else if (this.state.pw2 == null || this.state.pw2 == undefined || this.state.pw2.trim() == '') {
alert("未输入确认密码!");
go = 0;
} else if (this.state.pw != this.state.pw2) {
go = 0;
alert("两次输入的密码不同!");
} else {
go = 1;
this.onSubmit();
}
};
//批量导入设备
importUserDeviceListExcel = (id) => {
if (this.state.deviceList != undefined && this.state.deviceList != null && this.state.deviceList != '') {
this.props.dispatch({
type: 'deviceModel/importUserDeviceListExcel',
payload: {
jsonArr: this.state.deviceList,
userID: id,
},
callback: (res) => {
if (res) {
this.setState({
used: res.data.used,
newAdd: res.data.integer,
strList: res.data.strList,
},() => {
this.info();
});
}
}
});
}else{
this.back();
}
};
//获取用户拥有的设备
getUserDevice = (userID) => {
const params = {
userID: userID,
};
this.props.dispatch({
type: 'deviceModel/getTargetKeys',
payload: params,
callback: (res) => {
if (res) {
this.setState({
targetKeys: res
});
}
}
});
};
//获取操作员拥有的设备
getDevice = () => {
const params = {
userID: this.props.currentUser.userid,
};
this.props.dispatch({
type: 'deviceModel/getUserDevice',
payload: params,
callback: (res) => {
deviceData = [];
if (res) {
for (let i = 0; i < res.total; i++) {
if (res.rows[i].deviceSerialNumber != '' && res.rows[i].deviceSerialNumber != null) {
deviceData.push({
key: res.rows[i].deviceID,
title: res.rows[i].deviceSerialNumber,
});
}
}
}
}
});
};
//保存权限信息
savePermission = (id) => {
const nowUser = this.props.currentUser;
this.props.dispatch({
type: 'permissionModel/saveAccountPermission',
payload: {
userName: this.state.account,
userPassword: this.state.pw,
permissionArray: this.state.permission,
},
callback: (res) => {
if(res){
console.log(res);
if(id == nowUser.userid){
this.props.currentUser.permission = this.state.permission;
}
alert(res.error_msg);
}
}
});
};
//获取权限信息
getPermission = (userID) => {
const params1 = this.props.location.query;
const params = {
userID: params1.tosUserName,
};
this.props.dispatch({
type: 'permissionModel/getAccountPermission',
payload: params,
callback: (res) => {
if (res) {
this.setState({
permission: res,
})
}
}
});
};
//绑定单个设备
addToDeviceList() {
const oldDeviceList = this.state.deviceList;
if (!oldDeviceList.includes(this.state.addDevice) && this.state.addDevice != '' && this.state.addDevice != null && this.state.addDevice != undefined) {
oldDeviceList.push(this.state.addDevice);
}
this.setState({
deviceList: oldDeviceList
})
}
//SN变更
addDeviceChange(e) {
this.setState({
addDevice: e.target.value,
});
}
//用户名变更
accountChange = (e) => {
this.setState({account: e.target.value});
};
adChange = (e) => {
this.setState({level: e == undefined?undefined:e+1});
};
//密码变更
pwChange = (e) => {
this.setState({pw: e.target.value});
};
//确认密码变更
pwChange2 = (e) => {
this.setState({pw2: e.target.value});
};
//联系电话变更
phoneChange = (e) => {
this.setState({phone: e.target.value});
};
//联系邮箱变更
emailChange = (e) => {
this.setState({email: e.target.value});
};
//提交前验证
onGo = () => {
if(this.state.account==null||this.state.account.trim()==''||this.state.account==undefined){
alert("未输入账号名称!");
checkUser = 0;
return;
}
this.props.dispatch({
type: 'accountModel/checkAccountByName',
payload: {
username: this.state.account,
},
callback: (res) => {
if (res) {
console.log(res);
if (res.error_code == "0000") {
checkUser = 0;
alert(res.error_msg);
} else if(res.error_code == "0008"){
alert(res.error_msg);
window.location.href = '/';
router.replace('/');
} else {
this.checkPw();
}
}
}
});
};
//提交
onSubmit = () => {
if(this.state.account==null||this.state.account.trim()==''||this.state.account==undefined){
alert("未输入账号名称!");
checkUser = 0;
return;
}
this.props.dispatch({
type: 'accountModel/checkAccountByName',//请求一次,通过用户名查表
payload: {
username: this.state.account,
},
callback: (res) => {
if (res) {
console.log(res);
if (res.error_code == "0000") {
// if(this.state.newEdit==true){
// checkUser = 0;
// alert(res.error_msg);
// }else {
let oneself = 0;
if(this.state.id!=null&&(this.state.id == this.props.currentUser.userid)){
oneself = 1;
}
const params = {
/* userAccount: this.state.account,
userID: this.state.id ? this.state.id : null,
userPhone: this.state.phone,
userPassword: this.state.newEdit == true ? this.state.pw : null,
userEmail: this.state.email,
createUser: this.state.createUser != undefined ? this.state.createUser : this.state.userId,
userLevel: this.state.level,*/
userLeader: this.state.leader,
oneself: oneself,
tosUserName:this.state.account,
id:this.state.id ? this.state.id : null,
tosUserPhone:this.state.phone,
userStatus: this.state.status ? this.state.status : 1,
tosUserPwd:this.state.newEdit == true ? this.state.pw : null,
tosUserEmail:this.state.email,
tosuserLevel:this.state.level,
tosUserToCompany:this.state.createUser != undefined ? this.state.createUser : this.state.userId,
tosUserServiceCell:this.state.leader,
};
this.props.dispatch({
type: 'accountModel/saveAccount',// 第二次请求,查不到用户的时候,保存新的用户
payload: params,
callback: (res) => {
console.log(res);
if (res.error_code == "0000") {
// alert(res.error_msg);
console.log("data",res.data);
// this.importUserDeviceListExcel(res.data.userID);
this.savePermission(res.data.userID);// 第三次请求,插入权限表格
} else if (res.error_code == "0001") {
alert(res.error_msg);
} else if (res.error_code == "0002") {
alert(res.error_msg);
} else if(res.error_code == "0008"){
alert(res.error_msg);
window.location.href = '/';
router.replace('/');
} else {
alert("提交失败!");
}
}
});
// }
} else if(res.error_code == "0008"){
alert(res.error_msg);
window.location.href = '/';
router.replace('/');
} else {
checkUser = 1;
let oneself = 0;
if(this.state.id!=null&&(this.state.id == this.props.currentUser.userid)){
oneself = 1;
}
const params = {
tosUserName:this.state.account,
id:this.state.id ? this.state.id : null,
tosUserPhone:this.state.phone,
userStatus: this.state.status ? this.state.status : 1,
tosUserPwd:this.state.newEdit == true ? this.state.pw : null,
tosUserEmail:this.state.email,
tosuserLevel:this.state.level,
tosUserToCompany:this.state.createUser != undefined ? this.state.createUser : this.state.userId,
tosUserServiceCell:this.state.leader,
userLevel: this.state.level,
userLeader: this.state.leader,
oneself: oneself,
/* userAccount: this.state.account,
userID: this.state.id ? this.state.id : null,
userPhone: this.state.phone,
userStatus: this.state.status ? this.state.status : 1,
userPassword: this.state.newEdit == true ? this.state.pw : null,
userEmail: this.state.email,
createUser: this.state.createUser != undefined ? this.state.createUser : this.state.userId,
userLevel: this.state.level,
userLeader: this.state.leader,
oneself: oneself,*/
};
this.props.dispatch({
type: 'accountModel/saveAccount',
payload: params,
callback: (res) => {
console.log(res);
if (res.error_code == "0000") {
alert(res.error_msg);
console.log("data",res.data);
this.importUserDeviceListExcel(res.data.userID);
this.savePermission(res.data.userID); //第三次请求,RPC保存权限表格
} else if (res.error_code == "0001") {
alert(res.error_msg);
} else if (res.error_code == "0002") {
alert(res.error_msg);
} else if(res.error_code == "0008"){
alert(res.error_msg);
window.location.href = '/';
router.replace('/');
} else {
alert("提交失败!");
}
}
});
}
}
}
});
};
//初始化
componentDidMount() {
this.getDevice();
const nowUser = this.props.currentUser.userid;
if (this.props.location.query != null) {
const params = this.props.location.query;
if (params.userID == null || params.userID == '' || params.userID == undefined) {
this.setState({
newEdit: true
})
}
this.setState({
level:params.tosuserLevel,
account: params.tosUserName,
pw: params.userPassword,
id: params.id,
email: params.tosUserEmail,
phone: params.tosUserPhone,
status: params.deleted,
/* level: params.userLevel,
account: params.userAccount,
pw: params.userPassword,
id: params.userID,
email: params.userEmail,
phone: params.userPhone,
status: params.userStatus,*/
userId: nowUser,
createUser: params.createUser,
leader: params.userLeader ? params.userLeader.toString() : params.userLeader,
},() => {
if(this.props.currentUser.userid==this.state.id){
this.setState({
flag: 0,
})
}
this.setState({
flag: 1,
})
});
if (params.id != '' && params.id != null) {
this.getPermission(params.account);
this.getUserDevice(params.account);
}
if (params.userLevel != '' && params.userLevel != null) {
this.getAllLeader(params.userLevel);
}
}
}
//多选框
onChange(checkedValues) {
this.setState({
permission: checkedValues,
});
}
/*--------------------------------------*/
columns = [
{
title: '设备串号',
dataIndex: 'deviceName',
key: 'deviceName',
},
];
//渲染
render() {
const {
adList,defaultLevel,level, phone, email, permission, account, newEdit, deviceList, pw, pw2, flag
} = this.state;
const adSelect = adList.map((item, index) => (
<Select.Option value={index}>{item}</Select.Option>
));
const uploadprops = {
accept: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
name: 'file',
headers: {
authorization: 'authorization-text',
},
showUploadList: false,
beforeUpload: (file, fileList) => {
const rABS = true;
const f = fileList[0];
const reader = new FileReader();
reader.onload = e => {
let dataResult = e.target.result;
if (!rABS) dataResult = new Uint8Array(dataResult);
const workbook = XLSX.read(dataResult, {
type: rABS ? 'binary' : 'array',
});
const firstWorksheet = workbook.Sheets[workbook.SheetNames[0]];
const jsonArr = XLSX.utils.sheet_to_json(firstWorksheet, {header: 1});
const oldDeviceList = this.state.deviceList;
for (let i = 0; i < jsonArr.length; i++) {
//去重
if (!oldDeviceList.includes(jsonArr[i][0]) && jsonArr[i][0] != '' && jsonArr[i][0] != null && jsonArr[i][0] != undefined) {
oldDeviceList.push(jsonArr[i][0]);
}
}
this.setState({
deviceList: oldDeviceList
})
};
if (rABS) reader.readAsBinaryString(f);
else reader.readAsArrayBuffer(f);
return false;
},
};
const CallBackTitleSearch = (comment: any)=>{
console.log(comment)
}
return (
<div className={styles.body}>
<div style={{marginTop: 48}}>
<div className={styles.detailsBox}>
<div>
<span className={styles.detailsContent}>账号</span>
{newEdit != true ?
<Input className={styles.input}
value={account}
onChange={(e) => this.accountChange(e)}
disabled
placeholder="请输入账号名"/>:''}
{newEdit == true ?
<Input className={styles.input}
value={account}
onChange={(e) => this.accountChange(e)}
placeholder="请输入账号名"/>:''}
</div>
<div>
{newEdit == true ?
<span className={styles.detailsContent}>密码</span> : ''}
{newEdit == true ?
<div style={{display: "inline-block"}}>
<Input.Password className={styles.input}
onChange={(e) => this.pwChange(e)}
value={pw}
placeholder="请输入密码"/>
<Input.Password className={styles.input}
onChange={(e) => this.pwChange2(e)}
value={pw2}
placeholder="请再次输入密码"/>
</div>
: ''}
</div>
<div>
<span className={styles.detailsContent}>联系方式</span>
<Input className={styles.input} value={phone} onChange={(e) => this.phoneChange(e)}
placeholder="请输入联系电话"/>
<Input className={styles.input} value={email} onChange={(e) => this.emailChange(e)}
placeholder="请输入联系邮箱"/>
</div>
{newEdit != true ?
<div>
<span className={styles.detailsContent}>用户等级:</span>
<Select className={styles.input} disabled placeholder="用户等级" value={defaultLevel} onChange={(e) => this.adChange(e)}
allowClear={true}>{adSelect}</Select>
</div>:''}
{newEdit == true ?
<div>
<span className={styles.detailsContent}>用户等级:</span>
<Select className={styles.input} placeholder="用户等级" value={level} onChange={(e) => this.adChange(e)}
allowClear={true}>{adSelect}</Select>
</div>:''}
<TitleSearch
listkey={["providerName"]}
list={["Service Provider"]}
community={"serviceCommunityList"}
onSubmit={CallBackTitleSearch} />
<div>
<div style={{marginTop:20}}>
{/*<span className={styles.detailsContent}*/}
{/* style={{position: "relative", marginTop:20,bottom: 250}}>权限配置</span>*/}
{flag == 0?
<div style={{display: "inline-block"}}>
<Checkbox.Group style={{width: '100%'}}
onChange={(e) => this.onChange(e)}
value={permission}>
<Row>
{/*<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}>我的设备</span>*/}
<Checkbox value="1" disabled>数据中心</Checkbox>
<Checkbox value="2" disabled>查看life用户</Checkbox>
<Checkbox value="3" disabled>编辑life用户</Checkbox>
<Checkbox value="4" disabled>添加业主档案</Checkbox>
</Row>
<Row>
{/*<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}>广告推送</span>*/}
<Checkbox value="5" disabled>注销业主档案</Checkbox>
<Checkbox value="6" disabled>查看服务商</Checkbox>
<Checkbox value="7" disabled>编辑服务商</Checkbox>
<Checkbox value="8" disabled>添加服务商</Checkbox>
</Row>
<Row>
{/*<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}>警报提醒</span>*/}
<div style={{margin: "5px 0px 5px 0px"}}>
<Checkbox value="9" disabled>注销服务商</Checkbox>
<Checkbox value="10" disabled>查看物业费记录</Checkbox>
<Checkbox value="11" disabled>添加物业费记录</Checkbox>
<Checkbox value="12" disabled>查看物业服务</Checkbox>
</div>
<div style={{margin: "5px 0px 5px 0px"}}>
<Checkbox value="13" disabled>编辑物业服务</Checkbox>
<Checkbox value="14" disabled>注销物业服务</Checkbox>
<Checkbox value="15" disabled>查看订单</Checkbox>
<Checkbox value="16" disabled>编辑订单</Checkbox>
</div>
</Row>
<Row>
{/*<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}>创建后台账号</span>*/}
<Checkbox value="17" disabled>查看合同</Checkbox>
<Checkbox value="18" disabled>编辑合同</Checkbox>
<Checkbox value="19" disabled>添加合同</Checkbox>
<Checkbox value="20" disabled>查看小区</Checkbox>
</Row>
<Row>
{/*<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}>系统更新</span>*/}
<Checkbox value="21" disabled>编辑小区</Checkbox>
<Checkbox value="22" disabled>添加小区</Checkbox>
<Checkbox value="23" disabled>查看公告</Checkbox>
<Checkbox value="24" disabled>编辑公告</Checkbox>
</Row>
<Row>
{/*<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}>系统更新</span>*/}
<Checkbox value="25" disabled>添加公告</Checkbox>
<Checkbox value="26" disabled>查看访客记录</Checkbox>
<Checkbox value="27" disabled>查看预定服务</Checkbox>
<Checkbox value="28" disabled>编辑预定服务</Checkbox>
</Row>
<Row>
{/*<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}>系统更新</span>*/}
<Checkbox value="29" disabled>添加预定服务</Checkbox>
<Checkbox value="30" disabled>查看后台账号</Checkbox>
<Checkbox value="31" disabled>配置后台账号</Checkbox>
</Row>
</Checkbox.Group>
</div>:''}
{flag == 1?
<div style={{display: "inline-block"}}>
<Checkbox.Group style={{width: '100%'}}
onChange={(e) => this.onChange(e)}
value={permission}>
<Row>
<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}></span>
<Checkbox value="1" >数据中心</Checkbox>
<Checkbox value="2" >查看life用户</Checkbox>
<Checkbox value="3" >编辑life用户</Checkbox>
<Checkbox value="4" >添加业主档案</Checkbox>
</Row>
<Row>
<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}></span>
<Checkbox value="5" >注销业主档案</Checkbox>
<Checkbox value="6" >查看服务商</Checkbox>
<Checkbox value="7" >编辑服务商</Checkbox>
<Checkbox value="8" >添加服务商</Checkbox>
</Row>
<Row>
<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}></span>
<div style={{margin: "5px 0px 5px 0px"}}>
<Checkbox value="9" >注销服务商</Checkbox>
<Checkbox value="10" >查看物业费记录</Checkbox>
<Checkbox value="11" >添加物业费记录</Checkbox>
<Checkbox value="12" >查看物业服务</Checkbox>
</div>
<div style={{margin: "5px 0px 5px 0px"}}>
<Checkbox value="13" >编辑物业服务</Checkbox>
<Checkbox value="14" >注销物业服务</Checkbox>
<Checkbox value="15" >查看订单</Checkbox>
<Checkbox value="16" >编辑订单</Checkbox>
</div>
</Row>
<Row>
<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}></span>
<Checkbox value="17" >查看合同</Checkbox>
<Checkbox value="18" >编辑合同</Checkbox>
<Checkbox value="19" >添加合同</Checkbox>
<Checkbox value="20" >查看小区</Checkbox>
</Row>
<Row>
<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}></span>
<Checkbox value="21" >编辑小区</Checkbox>
<Checkbox value="22" >添加小区</Checkbox>
<Checkbox value="23" >查看公告</Checkbox>
<Checkbox value="24" >编辑公告</Checkbox>
</Row>
<Row>
<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}></span>
<Checkbox value="25" >添加公告</Checkbox>
<Checkbox value="26" >查看访客记录</Checkbox>
<Checkbox value="27" >查看预定服务</Checkbox>
<Checkbox value="28" >编辑预定服务</Checkbox>
</Row>
<Row>
<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}></span>
<Checkbox value="29" >添加预定服务</Checkbox>
<Checkbox value="30" >查看后台账号</Checkbox>
<Checkbox value="31" >配置后台账号</Checkbox>
</Row>
</Checkbox.Group>
</div>:''}
</div>
</div>
{/* <div>
<span className={styles.detailsContent}>绑定设备</span>
<div style={{position: "relative", left: 110, bottom: 50}}>
<Input
className={styles.input}
onChange={(e) => this.addDeviceChange(e)}
placeholder="请输入设备串号"/>
<Button className={styles.button1}
onClick={() => this.addToDeviceList()}>添加</Button>
<Upload {...uploadprops}>
<Tooltip title="">
<Button className={styles.button1}
style={{margin: 5, width: 120}}>
<Icon type="upload"/>批量导入
</Button>
</Tooltip>
</Upload>
<br/>
<List
style={{width: 240}}
size="small"
header={<div>设备串号</div>}
bordered
dataSource={deviceList}
renderItem={item => <List.Item>{item}</List.Item>}
/>
</div>
</div>*/}
<div>
{newEdit == false ?
<Button className={styles.button1}
onClick={() => this.onSubmit()}>提交</Button> : ''}
{newEdit == true ?
<Button className={styles.button1}
// onClick={() => this.onGo()}>提交</Button> : ''}
onClick={() => this.onSubmit()}>提交</Button> : ''}
<Button className={styles.button1} onClick={() => this.back()}>返回</Button>
</div>
</div>
</div>
</div>
);
}
}
export default connect(({user}: ConnectState) => ({
currentUser: user.currentUser,
}))(AccountEdit);
import React from 'react'; import React, { useState, useEffect, useRef } from 'react';
import {connect, routerRedux} from 'dva'; import {
import {Button, Input, Upload, Icon, Checkbox, Row, Tooltip, List, Modal,Select} from "antd"; Form,
import styles from './style.less'; Input,
import {ConnectState} from "@/models/connect"; Button,
import XLSX from './xlsx.core.min'; Pagination,
import {router} from "umi"; message,
import permission from "@/models/permission"; Descriptions,
import TitleSearch from "@/components/TitleSearch/TitleSearch"; Checkbox,
Tree,
Radio,
} from 'antd';
import { connect, history } from 'umi';
import { SearchOutlined, ClearOutlined, EditOutlined, LeftOutlined } from '@ant-design/icons';
import { getCookie } from '@/utils/method';
import './Account.less';
import { zhCnFaci } from '@/utils/power';
import { AccountTip } from '@/utils/tip';
import SelectCommunity from '@/components/SelectCommunity';
import moment from 'moment';
const Account = (props: any) => {
const { dispatch, Data, DataSave, DataSaveDetail, Result, loading, CommunityList } = props;
const RA = (index: any, values: any) => {
dispatch({ type: 'Account/RA', playload: { index: index, body: values } });
};
// 拉取数据的条件存储
const [term, setTerm] = useState({} as any);
// 小区列表
const [comList, setCommunityList] = useState(CommunityList as any);
// 数据
useEffect(() => {
if (CommunityList != null) {
setCommunityList(CommunityList);
}
}, [CommunityList]);
let go = 0; // 权限列表
let deviceData = []; const treeData = zhCnFaci;
let checkUser = 1;
class AccountEdit extends React.Component { const [expandedKeys, setExpandedKeys] = useState<string[]>(['0']); // 展开栏目
const [checkedKeys, setCheckedKeys] = useState<string[]>(['3']); // 默认已选栏目
const [selectedKeys, setSelectedKeys] = useState<string[]>([]); // 设置选中的树节点
const [autoExpandParent, setAutoExpandParent] = useState<boolean>(true); // 树形菜单展开关闭
//构造 // 单选 二级还是三级管理员
constructor(props) { const [values, setvalues] = useState(1); // 树形菜单展开关闭
super(props);
this.state = {
account: '',
pw: '',
pw2: '',
id: '',
email: '',
phone: '',
status: '',
radio: 2,
createUser: '',
userId: '',
defaultLevel:'',
permission: [], // 表单标识
targetKeys: [], const [form] = Form.useForm();
deviceData: [], const formRef = useRef(null);
visible: false,
visible2: false,
newEdit: false,
level: '',
levelList: [{label: '四级管理员', value: 1},
{label: '三级管理员', value: 2},
{label: '二级管理员', value: 3},
{label: '一级管理员', value: 4},
{label: '超级管理员', value: 5}
],
leaderList: [{userAccount: '未选择管理员等级'}],
adList: ["一级管理员", "二级管理员","三级管理员"],
leader: '', // 表头单搜索
deviceList: [], const onFinishContract = (value: any) => {
addDevice: '', console.log(value);
flag: 1, console.log(value.community);
};
//goToReturn
const goToReturn = () => {};
used: null, // 全选
newAdd: null, const onCheckAllChange = (e: any) => {};
strList: [],
}
}
/*----------------- 方法集 ------------------*/ // 展开/收起树形菜单触发
//显示信息 const onExpand = (expandedKeys: any) => {
info() { setExpandedKeys(expandedKeys);
let _this = this; setAutoExpandParent(false);
const { used, newAdd, strList} = this.state;
const strSelect = strList.map((item, index) => (
<p>{item}</p>
));
Modal.info({
title: '批量导入结果',
content: (
<div>
<p>绑定<span style={{color:"lightgreen",fontSize:24}}>{newAdd}</span>台设备,
以下<span style={{color:"red",fontSize:24}}>{used}</span>台设备已被占用</p>
{strSelect}
</div>
),
onOk() {
_this.back();
},
});
}
//检测是否存在相同用户
checkUser = () => {
checkUser = 1;
if(this.state.account==null||this.state.account.trim()==''||this.state.account==undefined){
alert("未输入账号名称!");
checkUser = 0;
return;
}
this.props.dispatch({
type: 'accountModel/checkAccountByName',
payload: {
username: this.state.account,
},
callback: (res) => {
if (res) {
if (res.error_code == "0000") {
checkUser = 0;
alert(res.error_msg);
} else if(res.error_code == "0008"){
alert(res.error_msg);
window.location.href = '/';
router.replace('/');
} else {
checkUser = 1;
}
}
}
});
};
//跳转到账户页面
back = () => {
this.props.dispatch(routerRedux.push({
pathname: '/AccountManagement/account',
}))
};
//获取所有上级
getAllLeader = (level) => {
const params = {
userLevel: level,
};
this.props.dispatch({
type: 'accountModel/getAllLeader',
payload: params,
callback: (res) => {
if (res) {
this.setState({
leaderList: res,
})
}
}
});
};
//两次密码校对
checkPw = () => {
if (this.state.pw == null || this.state.pw == undefined || this.state.pw.trim() == '') {
alert("未输入密码!");
go = 0;
} else if (this.state.pw2 == null || this.state.pw2 == undefined || this.state.pw2.trim() == '') {
alert("未输入确认密码!");
go = 0;
} else if (this.state.pw != this.state.pw2) {
go = 0;
alert("两次输入的密码不同!");
} else {
go = 1;
this.onSubmit();
}
};
//批量导入设备
importUserDeviceListExcel = (id) => {
if (this.state.deviceList != undefined && this.state.deviceList != null && this.state.deviceList != '') {
this.props.dispatch({
type: 'deviceModel/importUserDeviceListExcel',
payload: {
jsonArr: this.state.deviceList,
userID: id,
},
callback: (res) => {
if (res) {
this.setState({
used: res.data.used,
newAdd: res.data.integer,
strList: res.data.strList,
},() => {
this.info();
});
}
}
});
}else{
this.back();
}
};
//获取用户拥有的设备
getUserDevice = (userID) => {
const params = {
userID: userID,
};
this.props.dispatch({
type: 'deviceModel/getTargetKeys',
payload: params,
callback: (res) => {
if (res) {
this.setState({
targetKeys: res
});
}
}
});
};
//获取操作员拥有的设备
getDevice = () => {
const params = {
userID: this.props.currentUser.userid,
};
this.props.dispatch({
type: 'deviceModel/getUserDevice',
payload: params,
callback: (res) => {
deviceData = [];
if (res) {
for (let i = 0; i < res.total; i++) {
if (res.rows[i].deviceSerialNumber != '' && res.rows[i].deviceSerialNumber != null) {
deviceData.push({
key: res.rows[i].deviceID,
title: res.rows[i].deviceSerialNumber,
});
}
}
}
}
});
}; };
//保存权限信息
savePermission = (id) => {
const nowUser = this.props.currentUser;
this.props.dispatch({
type: 'permissionModel/saveAccountPermission',
payload: {
userName: this.state.account,
userPassword: this.state.pw,
permissionArray: this.state.permission,
},
callback: (res) => {
if(res){
console.log(res);
if(id == nowUser.userid){
this.props.currentUser.permission = this.state.permission;
}
alert(res.error_msg);
}
}
});
};
//获取权限信息
getPermission = (userID) => {
const params1 = this.props.location.query;
const params = { // 点击单个触发
userID: params1.tosUserName, const onCheck = (checkedKeys: any) => {
}; console.log('onCheck', checkedKeys);
this.props.dispatch({ setCheckedKeys(checkedKeys);
type: 'permissionModel/getAccountPermission',
payload: params,
callback: (res) => {
if (res) {
this.setState({
permission: res,
})
}
}
});
};
//绑定单个设备
addToDeviceList() {
const oldDeviceList = this.state.deviceList;
if (!oldDeviceList.includes(this.state.addDevice) && this.state.addDevice != '' && this.state.addDevice != null && this.state.addDevice != undefined) {
oldDeviceList.push(this.state.addDevice);
}
this.setState({
deviceList: oldDeviceList
})
}
//SN变更
addDeviceChange(e) {
this.setState({
addDevice: e.target.value,
});
}
//用户名变更
accountChange = (e) => {
this.setState({account: e.target.value});
}; };
adChange = (e) => { // 点击树节点触发 - 大栏目
this.setState({level: e == undefined?undefined:e+1}); const onSelect = (selectedKeys: any, info: any) => {
console.log('onSelect', info);
setSelectedKeys(selectedKeys);
}; };
//密码变更 // 管理员级别样式
pwChange = (e) => { const radioStyle = {
this.setState({pw: e.target.value}); display: 'block',
}; height: '30px',
//确认密码变更 lineHeight: '30px',
pwChange2 = (e) => { marginBottom: '15px',
this.setState({pw2: e.target.value});
}; };
//联系电话变更
phoneChange = (e) => {
this.setState({phone: e.target.value});
};
//联系邮箱变更
emailChange = (e) => {
this.setState({email: e.target.value});
};
//提交前验证
onGo = () => {
if(this.state.account==null||this.state.account.trim()==''||this.state.account==undefined){
alert("未输入账号名称!");
checkUser = 0;
return;
}
this.props.dispatch({
type: 'accountModel/checkAccountByName',
payload: {
username: this.state.account,
},
callback: (res) => {
if (res) {
console.log(res);
if (res.error_code == "0000") {
checkUser = 0;
alert(res.error_msg);
} else if(res.error_code == "0008"){
alert(res.error_msg);
window.location.href = '/';
router.replace('/');
} else {
this.checkPw();
}
}
}
});
};
//提交
onSubmit = () => {
if(this.state.account==null||this.state.account.trim()==''||this.state.account==undefined){
alert("未输入账号名称!");
checkUser = 0;
return;
}
this.props.dispatch({
type: 'accountModel/checkAccountByName',//请求一次,通过用户名查表
payload: {
username: this.state.account,
},
callback: (res) => {
if (res) {
console.log(res);
if (res.error_code == "0000") {
// if(this.state.newEdit==true){
// checkUser = 0;
// alert(res.error_msg);
// }else {
let oneself = 0;
if(this.state.id!=null&&(this.state.id == this.props.currentUser.userid)){
oneself = 1;
}
const params = {
/* userAccount: this.state.account,
userID: this.state.id ? this.state.id : null,
userPhone: this.state.phone,
userPassword: this.state.newEdit == true ? this.state.pw : null,
userEmail: this.state.email,
createUser: this.state.createUser != undefined ? this.state.createUser : this.state.userId,
userLevel: this.state.level,*/
userLeader: this.state.leader,
oneself: oneself,
tosUserName:this.state.account, //级别切换
id:this.state.id ? this.state.id : null, const onRadio = (e: any) => {
tosUserPhone:this.state.phone, setvalues(e.target.value);
userStatus: this.state.status ? this.state.status : 1,
tosUserPwd:this.state.newEdit == true ? this.state.pw : null,
tosUserEmail:this.state.email,
tosuserLevel:this.state.level,
tosUserToCompany:this.state.createUser != undefined ? this.state.createUser : this.state.userId,
tosUserServiceCell:this.state.leader,
};
this.props.dispatch({
type: 'accountModel/saveAccount',// 第二次请求,查不到用户的时候,保存新的用户
payload: params,
callback: (res) => {
console.log(res);
if (res.error_code == "0000") {
// alert(res.error_msg);
console.log("data",res.data);
// this.importUserDeviceListExcel(res.data.userID);
this.savePermission(res.data.userID);// 第三次请求,插入权限表格
} else if (res.error_code == "0001") {
alert(res.error_msg);
} else if (res.error_code == "0002") {
alert(res.error_msg);
} else if(res.error_code == "0008"){
alert(res.error_msg);
window.location.href = '/';
router.replace('/');
} else {
alert("提交失败!");
}
}
});
// }
} else if(res.error_code == "0008"){
alert(res.error_msg);
window.location.href = '/';
router.replace('/');
} else {
checkUser = 1;
let oneself = 0;
if(this.state.id!=null&&(this.state.id == this.props.currentUser.userid)){
oneself = 1;
}
const params = {
tosUserName:this.state.account,
id:this.state.id ? this.state.id : null,
tosUserPhone:this.state.phone,
userStatus: this.state.status ? this.state.status : 1,
tosUserPwd:this.state.newEdit == true ? this.state.pw : null,
tosUserEmail:this.state.email,
tosuserLevel:this.state.level,
tosUserToCompany:this.state.createUser != undefined ? this.state.createUser : this.state.userId,
tosUserServiceCell:this.state.leader,
userLevel: this.state.level,
userLeader: this.state.leader,
oneself: oneself,
/* userAccount: this.state.account,
userID: this.state.id ? this.state.id : null,
userPhone: this.state.phone,
userStatus: this.state.status ? this.state.status : 1,
userPassword: this.state.newEdit == true ? this.state.pw : null,
userEmail: this.state.email,
createUser: this.state.createUser != undefined ? this.state.createUser : this.state.userId,
userLevel: this.state.level,
userLeader: this.state.leader,
oneself: oneself,*/
};
this.props.dispatch({
type: 'accountModel/saveAccount',
payload: params,
callback: (res) => {
console.log(res);
if (res.error_code == "0000") {
alert(res.error_msg);
console.log("data",res.data);
this.importUserDeviceListExcel(res.data.userID);
this.savePermission(res.data.userID); //第三次请求,RPC保存权限表格
} else if (res.error_code == "0001") {
alert(res.error_msg);
} else if (res.error_code == "0002") {
alert(res.error_msg);
} else if(res.error_code == "0008"){
alert(res.error_msg);
window.location.href = '/';
router.replace('/');
} else {
alert("提交失败!");
}
}
});
}
}
}
});
}; };
//初始化
componentDidMount() {
this.getDevice();
const nowUser = this.props.currentUser.userid;
if (this.props.location.query != null) {
const params = this.props.location.query;
if (params.userID == null || params.userID == '' || params.userID == undefined) {
this.setState({
newEdit: true
})
}
this.setState({
level:params.tosuserLevel,
account: params.tosUserName,
pw: params.userPassword,
id: params.id,
email: params.tosUserEmail,
phone: params.tosUserPhone,
status: params.deleted,
/* level: params.userLevel,
account: params.userAccount,
pw: params.userPassword,
id: params.userID,
email: params.userEmail,
phone: params.userPhone,
status: params.userStatus,*/
userId: nowUser,
createUser: params.createUser,
leader: params.userLeader ? params.userLeader.toString() : params.userLeader,
},() => {
if(this.props.currentUser.userid==this.state.id){
this.setState({
flag: 0,
})
}
this.setState({
flag: 1,
})
});
if (params.id != '' && params.id != null) {
this.getPermission(params.account);
this.getUserDevice(params.account);
}
if (params.userLevel != '' && params.userLevel != null) {
this.getAllLeader(params.userLevel);
}
}
}
//多选框
onChange(checkedValues) {
this.setState({
permission: checkedValues,
});
}
/*--------------------------------------*/ // 选择小区名字并赋值
columns = [
{
title: '设备串号',
dataIndex: 'deviceName',
key: 'deviceName',
},
];
//渲染 return (
render() { <>
const { <div className="contop" style={{ padding: '12px 20px' }}>
adList,defaultLevel,level, phone, email, permission, account, newEdit, deviceList, pw, pw2, flag <h3 className="capi">
} = this.state; <EditOutlined />
const adSelect = adList.map((item, index) => ( &nbsp; {DataSave ? 'Edit' : 'Add'} Account
<Select.Option value={index}>{item}</Select.Option> <div className="back">
)); <Button onClick={goToReturn}>
const uploadprops = { <LeftOutlined />
accept: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', Back
name: 'file', </Button>
headers: { </div>
authorization: 'authorization-text', </h3>
}, </div>
showUploadList: false, <div className="contop">
beforeUpload: (file, fileList) => { <Form
const rABS = true; ref={formRef}
const f = fileList[0]; form={form}
const reader = new FileReader(); autoComplete="off"
reader.onload = e => { // layout="inline"
let dataResult = e.target.result; layout="horizontal"
if (!rABS) dataResult = new Uint8Array(dataResult); name="contract"
const workbook = XLSX.read(dataResult, { onFinish={onFinishContract}
type: rABS ? 'binary' : 'array', >
}); <Descriptions column={{ xs: 1, sm: 2, md: 3 }}>
const firstWorksheet = workbook.Sheets[workbook.SheetNames[0]]; <Descriptions.Item>
const jsonArr = XLSX.utils.sheet_to_json(firstWorksheet, {header: 1}); <Form.Item name="basic" label="管理员姓名" rules={AccountTip[0]}>
const oldDeviceList = this.state.deviceList; <Input placeholder="6 Postcode" className="input" />
for (let i = 0; i < jsonArr.length; i++) { </Form.Item>
//去重 </Descriptions.Item>
if (!oldDeviceList.includes(jsonArr[i][0]) && jsonArr[i][0] != '' && jsonArr[i][0] != null && jsonArr[i][0] != undefined) { <Descriptions.Item>
oldDeviceList.push(jsonArr[i][0]); <Form.Item name="basic" label="联系方式">
} <Input placeholder="6 Postcode" className="input" />
} </Form.Item>
this.setState({ </Descriptions.Item>
deviceList: oldDeviceList <Descriptions.Item>
}) <Form.Item name="basic" label="所属公司">
}; <Input placeholder="6 Postcode" className="input" />
if (rABS) reader.readAsBinaryString(f); </Form.Item>
else reader.readAsArrayBuffer(f); </Descriptions.Item>
return false; </Descriptions>
},
}; <Descriptions column={{ xs: 1, sm: 2, md: 3 }}>
const CallBackTitleSearch = (comment: any)=>{ <Descriptions.Item>
console.log(comment) <Form.Item name="basic" label="账号ID">
} <Input placeholder="6 Postcode" className="input" />
return ( </Form.Item>
<div className={styles.body}> </Descriptions.Item>
<div style={{marginTop: 48}}> <Descriptions.Item>
<div className={styles.detailsBox}> <Form.Item name="basic" label="登录密码">
<div> <Input placeholder="6 Postcode" className="input" />
<span className={styles.detailsContent}>账号</span> </Form.Item>
{newEdit != true ? </Descriptions.Item>
<Input className={styles.input} </Descriptions>
value={account}
onChange={(e) => this.accountChange(e)} <Form.Item name="community" label="服务小区">
disabled <SelectCommunity />
placeholder="请输入账号名"/>:''} </Form.Item>
{newEdit == true ?
<Input className={styles.input} <div className="diy" style={{ marginBottom: '14px' }}>
value={account} <div className="label">
onChange={(e) => this.accountChange(e)} <span className="title">权限配置:</span>
placeholder="请输入账号名"/>:''}
</div>
<div>
{newEdit == true ?
<span className={styles.detailsContent}>密码</span> : ''}
{newEdit == true ?
<div style={{display: "inline-block"}}>
<Input.Password className={styles.input}
onChange={(e) => this.pwChange(e)}
value={pw}
placeholder="请输入密码"/>
<Input.Password className={styles.input}
onChange={(e) => this.pwChange2(e)}
value={pw2}
placeholder="请再次输入密码"/>
</div>
: ''}
</div> </div>
<div> <div className="label">
<span className={styles.detailsContent}>联系方式</span> <Radio.Group defaultValue={values} onChange={onRadio}>
<Input className={styles.input} value={phone} onChange={(e) => this.phoneChange(e)} <Radio style={radioStyle} value={1}>
placeholder="请输入联系电话"/> 二级管理员
<Input className={styles.input} value={email} onChange={(e) => this.emailChange(e)} </Radio>
placeholder="请输入联系邮箱"/> <Radio style={radioStyle} value={2}>
三级管理员
<Input placeholder="三级管理员" style={{ width: 160, marginLeft: 10 }} />
</Radio>
</Radio.Group>
</div> </div>
</div>
<div className="diy" style={{ marginBottom: '24px' }}>
{newEdit != true ? <div className="label">
<div> <span className="title">权限选择:</span>
<span className={styles.detailsContent}>用户等级:</span>
<Select className={styles.input} disabled placeholder="用户等级" value={defaultLevel} onChange={(e) => this.adChange(e)}
allowClear={true}>{adSelect}</Select>
</div>:''}
{newEdit == true ?
<div>
<span className={styles.detailsContent}>用户等级:</span>
<Select className={styles.input} placeholder="用户等级" value={level} onChange={(e) => this.adChange(e)}
allowClear={true}>{adSelect}</Select>
</div>:''}
<TitleSearch
listkey={["providerName"]}
list={["Service Provider"]}
community={"serviceCommunityList"}
onSubmit={CallBackTitleSearch} />
<div>
<div style={{marginTop:20}}>
{/*<span className={styles.detailsContent}*/}
{/* style={{position: "relative", marginTop:20,bottom: 250}}>权限配置</span>*/}
{flag == 0?
<div style={{display: "inline-block"}}>
<Checkbox.Group style={{width: '100%'}}
onChange={(e) => this.onChange(e)}
value={permission}>
<Row>
{/*<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}>我的设备</span>*/}
<Checkbox value="1" disabled>数据中心</Checkbox>
<Checkbox value="2" disabled>查看life用户</Checkbox>
<Checkbox value="3" disabled>编辑life用户</Checkbox>
<Checkbox value="4" disabled>添加业主档案</Checkbox>
</Row>
<Row>
{/*<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}>广告推送</span>*/}
<Checkbox value="5" disabled>注销业主档案</Checkbox>
<Checkbox value="6" disabled>查看服务商</Checkbox>
<Checkbox value="7" disabled>编辑服务商</Checkbox>
<Checkbox value="8" disabled>添加服务商</Checkbox>
</Row>
<Row>
{/*<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}>警报提醒</span>*/}
<div style={{margin: "5px 0px 5px 0px"}}>
<Checkbox value="9" disabled>注销服务商</Checkbox>
<Checkbox value="10" disabled>查看物业费记录</Checkbox>
<Checkbox value="11" disabled>添加物业费记录</Checkbox>
<Checkbox value="12" disabled>查看物业服务</Checkbox>
</div>
<div style={{margin: "5px 0px 5px 0px"}}>
<Checkbox value="13" disabled>编辑物业服务</Checkbox>
<Checkbox value="14" disabled>注销物业服务</Checkbox>
<Checkbox value="15" disabled>查看订单</Checkbox>
<Checkbox value="16" disabled>编辑订单</Checkbox>
</div>
</Row>
<Row>
{/*<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}>创建后台账号</span>*/}
<Checkbox value="17" disabled>查看合同</Checkbox>
<Checkbox value="18" disabled>编辑合同</Checkbox>
<Checkbox value="19" disabled>添加合同</Checkbox>
<Checkbox value="20" disabled>查看小区</Checkbox>
</Row>
<Row>
{/*<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}>系统更新</span>*/}
<Checkbox value="21" disabled>编辑小区</Checkbox>
<Checkbox value="22" disabled>添加小区</Checkbox>
<Checkbox value="23" disabled>查看公告</Checkbox>
<Checkbox value="24" disabled>编辑公告</Checkbox>
</Row>
<Row>
{/*<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}>系统更新</span>*/}
<Checkbox value="25" disabled>添加公告</Checkbox>
<Checkbox value="26" disabled>查看访客记录</Checkbox>
<Checkbox value="27" disabled>查看预定服务</Checkbox>
<Checkbox value="28" disabled>编辑预定服务</Checkbox>
</Row>
<Row>
{/*<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}>系统更新</span>*/}
<Checkbox value="29" disabled>添加预定服务</Checkbox>
<Checkbox value="30" disabled>查看后台账号</Checkbox>
<Checkbox value="31" disabled>配置后台账号</Checkbox>
</Row>
</Checkbox.Group>
</div>:''}
{flag == 1?
<div style={{display: "inline-block"}}>
<Checkbox.Group style={{width: '100%'}}
onChange={(e) => this.onChange(e)}
value={permission}>
<Row>
<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}></span>
<Checkbox value="1" >数据中心</Checkbox>
<Checkbox value="2" >查看life用户</Checkbox>
<Checkbox value="3" >编辑life用户</Checkbox>
<Checkbox value="4" >添加业主档案</Checkbox>
</Row>
<Row>
<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}></span>
<Checkbox value="5" >注销业主档案</Checkbox>
<Checkbox value="6" >查看服务商</Checkbox>
<Checkbox value="7" >编辑服务商</Checkbox>
<Checkbox value="8" >添加服务商</Checkbox>
</Row>
<Row>
<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}></span>
<div style={{margin: "5px 0px 5px 0px"}}>
<Checkbox value="9" >注销服务商</Checkbox>
<Checkbox value="10" >查看物业费记录</Checkbox>
<Checkbox value="11" >添加物业费记录</Checkbox>
<Checkbox value="12" >查看物业服务</Checkbox>
</div>
<div style={{margin: "5px 0px 5px 0px"}}>
<Checkbox value="13" >编辑物业服务</Checkbox>
<Checkbox value="14" >注销物业服务</Checkbox>
<Checkbox value="15" >查看订单</Checkbox>
<Checkbox value="16" >编辑订单</Checkbox>
</div>
</Row>
<Row>
<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}></span>
<Checkbox value="17" >查看合同</Checkbox>
<Checkbox value="18" >编辑合同</Checkbox>
<Checkbox value="19" >添加合同</Checkbox>
<Checkbox value="20" >查看小区</Checkbox>
</Row>
<Row>
<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}></span>
<Checkbox value="21" >编辑小区</Checkbox>
<Checkbox value="22" >添加小区</Checkbox>
<Checkbox value="23" >查看公告</Checkbox>
<Checkbox value="24" >编辑公告</Checkbox>
</Row>
<Row>
<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}></span>
<Checkbox value="25" >添加公告</Checkbox>
<Checkbox value="26" >查看访客记录</Checkbox>
<Checkbox value="27" >查看预定服务</Checkbox>
<Checkbox value="28" >编辑预定服务</Checkbox>
</Row>
<Row>
<span className={styles.font} style={{margin: "5px 0px 5px 0px"}}></span>
<Checkbox value="29" >添加预定服务</Checkbox>
<Checkbox value="30" >查看后台账号</Checkbox>
<Checkbox value="31" >配置后台账号</Checkbox>
</Row>
</Checkbox.Group>
</div>:''}
</div>
</div> </div>
{/* <div> <div className="label">
<span className={styles.detailsContent}>绑定设备</span> <Tree
<div style={{position: "relative", left: 110, bottom: 50}}> checkable
<Input onExpand={onExpand}
className={styles.input} expandedKeys={expandedKeys}
onChange={(e) => this.addDeviceChange(e)} autoExpandParent={autoExpandParent}
placeholder="请输入设备串号"/> onCheck={onCheck}
<Button className={styles.button1} checkedKeys={checkedKeys}
onClick={() => this.addToDeviceList()}>添加</Button> onSelect={onSelect}
<Upload {...uploadprops}> selectedKeys={selectedKeys}
<Tooltip title=""> treeData={treeData}
<Button className={styles.button1} />
style={{margin: 5, width: 120}}>
<Icon type="upload"/>批量导入
</Button>
</Tooltip>
</Upload>
<br/>
<List
style={{width: 240}}
size="small"
header={<div>设备串号</div>}
bordered
dataSource={deviceList}
renderItem={item => <List.Item>{item}</List.Item>}
/>
</div>
</div>*/}
<div>
{newEdit == false ?
<Button className={styles.button1}
onClick={() => this.onSubmit()}>提交</Button> : ''}
{newEdit == true ?
<Button className={styles.button1}
// onClick={() => this.onGo()}>提交</Button> : ''}
onClick={() => this.onSubmit()}>提交</Button> : ''}
<Button className={styles.button1} onClick={() => this.back()}>返回</Button>
</div> </div>
</div> </div>
</div>
</div>
);
}
}
export default connect(({user}: ConnectState) => ({ <div className="diy">
currentUser: user.currentUser, <div className="label"></div>
}))(AccountEdit); <div className="label">
<Button type="primary" htmlType="submit">
Submit
</Button>
</div>
</div>
</Form>
</div>
</>
);
};
const AccountProps = (state: any) => {
console.log(state);
const { Data, DataSave, DataSaveDetail, Result } = state.Account;
const { CommunityList } = state.Init; // 小区列表
const loading = state.loading.models.Account || false;
return {
Data,
DataSave,
DataSaveDetail,
Result,
loading,
CommunityList,
};
};
export default connect(AccountProps)(Account);
...@@ -29,8 +29,6 @@ const Add = (props: any) => { ...@@ -29,8 +29,6 @@ const Add = (props: any) => {
// 图片地址 // 图片地址
const [ImageSrc, setImageSrc] = useState([] as any); const [ImageSrc, setImageSrc] = useState([] as any);
console.log(ImgSrc);
// 监听传递过来的值 // 监听传递过来的值
useEffect(() => { useEffect(() => {
if (DataSave != null) { if (DataSave != null) {
...@@ -134,7 +132,6 @@ const Add = (props: any) => { ...@@ -134,7 +132,6 @@ const Add = (props: any) => {
ref={formRef} ref={formRef}
form={form} form={form}
// {...layout} // {...layout}
name="nest-messages"
onFinish={onFinish} onFinish={onFinish}
validateMessages={validateMessages} validateMessages={validateMessages}
> >
......
import React, { useState, useEffect, useRef } from 'react'; import React, { useState, useEffect, useRef } from 'react';
import styles from './ContractContent.less'; import styles from './ContractContent.less';
import { Input, Form, message, Upload, Button, DatePicker, Space } from 'antd'; import { Input, Form, message, Upload, Button, DatePicker, Space, Modal } from 'antd';
import { PlusOutlined, LeftOutlined } from '@ant-design/icons'; import { PlusOutlined, LeftOutlined } from '@ant-design/icons';
import { Link, useIntl, connect, Dispatch, Loading } from 'umi'; import { Link, useIntl, connect, Dispatch, Loading } from 'umi';
...@@ -18,8 +18,6 @@ import locale from 'antd/es/date-picker/locale/en_US'; ...@@ -18,8 +18,6 @@ import locale from 'antd/es/date-picker/locale/en_US';
import SearchOptionsCommnity from '@/components/SearchOptions/SearchOptionsCommnity'; import SearchOptionsCommnity from '@/components/SearchOptions/SearchOptionsCommnity';
import { tipList } from '@/utils/tip'; import { tipList } from '@/utils/tip';
import FileViewer from 'react-file-viewer';
const ContractContent = (props: any) => { const ContractContent = (props: any) => {
const { ContractModel, dispatch } = props; const { ContractModel, dispatch } = props;
const { RangePicker } = DatePicker; // 日期组件 const { RangePicker } = DatePicker; // 日期组件
...@@ -32,14 +30,12 @@ const ContractContent = (props: any) => { ...@@ -32,14 +30,12 @@ const ContractContent = (props: any) => {
function disabledDate(current: any) { function disabledDate(current: any) {
return current && current <= moment().subtract(1, 'days').endOf('day'); return current && current <= moment().subtract(1, 'days').endOf('day');
} }
const startTime = moment().format('YYYY-MM-DD'); // 开始默认事件
const overTime = moment().add(1, 'month').format('YYYY-MM-DD'); // 结束默认事件
const [fileList, setFileList] = useState([] as any); // 图片列表 const [fileList, setFileList] = useState([] as any); // 图片列表
const [uploadUp, setUploadUp] = useState(true); // 禁止上传 直到选择了小区后 const [uploadUp, setUploadUp] = useState(true); // 禁止上传 直到选择了小区后
const [comtyName, setComtyName] = useState(null); // 小区名字 const [comtyName, setComtyName] = useState(null); // 小区名字
const [tipTime, setTipTime] = useState(['previous month', 'two months'] as any); //提示时间
console.log(tipList); const [tipModal, settipModal] = useState(false); //附件弹窗
useEffect(() => { useEffect(() => {
// 如果是添加传来没有值的时候 就清空 否则 赋值给表单 // 如果是添加传来没有值的时候 就清空 否则 赋值给表单
...@@ -58,15 +54,23 @@ const ContractContent = (props: any) => { ...@@ -58,15 +54,23 @@ const ContractContent = (props: any) => {
uid: i, uid: i,
name: arr[i], name: arr[i],
status: 'done', status: 'done',
url: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png', url: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.pdf',
}; };
obj.push(a); obj.push(a);
} }
setFileList([...obj]); setFileList([...obj]);
// setFileList([{ uid: 1,name:DataSaveDetail.contractFileName }]) // 提示时间
let a1 = moment(ContractModel.record.contractValidEndDate)
.subtract(2, 'month')
.format('YYYY-MM-DD');
let a2 = moment(ContractModel.record.contractValidEndDate)
.subtract(1, 'month')
.format('YYYY-MM-DD');
setTipTime([a1, a2]);
// 表单内容
form.setFieldsValue({ form.setFieldsValue({
...ContractModel.record, ...ContractModel.record,
time: [ time: [
...@@ -77,6 +81,7 @@ const ContractContent = (props: any) => { ...@@ -77,6 +81,7 @@ const ContractContent = (props: any) => {
} }
}, [1]); }, [1]);
// 返回
const goToReturn = () => { const goToReturn = () => {
// console.log(fileList) // console.log(fileList)
history.back(); history.back();
...@@ -118,22 +123,16 @@ const ContractContent = (props: any) => { ...@@ -118,22 +123,16 @@ const ContractContent = (props: any) => {
}, },
}; };
// 时间提示 // // 设置提示倒计时
// let tipTime = moment(defForm.time[1]).subtract(25, 'days').format('YYYY-MM-DD');
// let dec = moment(tipTime).diff(startTime,'days') > 1 ? tipTime : 'Due soon';
// const [stateTime,setmodalTime] = useState(dec); // 监听时间变化 -- 结束时间
// // 设置提示倒计时 25 天
const changeTime = (data: any, dateStrings: any) => { const changeTime = (data: any, dateStrings: any) => {
// if(overTime != dateStrings[1]){ if (data != null) {
// moment(dateStrings[1]).diff(startTime,'days') > 25 ? let a1 = moment(data[1]).subtract(2, 'month').format('YYYY-MM-DD');
// setmodalTime(moment(dateStrings[1]).subtract(25, 'days').format('YYYY-MM-DD')) : let a2 = moment(data[1]).subtract(1, 'month').format('YYYY-MM-DD');
// setmodalTime('Due soon'); setTipTime([a1, a2]);
// } }
// form.setFieldsValue({ console.log(dateStrings);
// 'time' : [moment(dateStrings[0]),moment(dateStrings[1])]
// })
}; };
// 选择小区名字并赋值 // 选择小区名字并赋值
const opname = (value: any) => { const opname = (value: any) => {
// 打开上传 如果选择了 小区就打开 否则 禁止上传 // 打开上传 如果选择了 小区就打开 否则 禁止上传
...@@ -148,6 +147,16 @@ const ContractContent = (props: any) => { ...@@ -148,6 +147,16 @@ const ContractContent = (props: any) => {
}); });
}; };
//点击预览
const onPreviews = () => {
console.log('预览');
settipModal(true);
};
// 关闭预览
const handleCancel = () => {
settipModal(false);
};
return ( return (
<div className={styles.base}> <div className={styles.base}>
{/* 头部组件 */} {/* 头部组件 */}
...@@ -241,7 +250,7 @@ const ContractContent = (props: any) => { ...@@ -241,7 +250,7 @@ const ContractContent = (props: any) => {
defaultValue={ContractModel.time} defaultValue={ContractModel.time}
disabledDate={disabledDate} disabledDate={disabledDate}
placeholder={['Effective Date', 'Expiration Date']} placeholder={['Effective Date', 'Expiration Date']}
// onChange={changeTime} onChange={changeTime}
/> />
</Form.Item> </Form.Item>
</div> </div>
...@@ -253,7 +262,12 @@ const ContractContent = (props: any) => { ...@@ -253,7 +262,12 @@ const ContractContent = (props: any) => {
label="Contract Annex" label="Contract Annex"
rules={[{ required: true, message: `${tipList[6]}` }]} rules={[{ required: true, message: `${tipList[6]}` }]}
> >
<Upload {...uploadProps} listType={'picture-card'} disabled={uploadUp}> <Upload
{...uploadProps}
listType={'picture-card'}
disabled={uploadUp}
onPreview={onPreviews}
>
{fileList.length >= 3 ? null : <PlusOutlined />} {fileList.length >= 3 ? null : <PlusOutlined />}
</Upload> </Upload>
</Form.Item> </Form.Item>
...@@ -266,16 +280,29 @@ const ContractContent = (props: any) => { ...@@ -266,16 +280,29 @@ const ContractContent = (props: any) => {
rules={[{ required: true, message: `${tipList[5]}` }]} rules={[{ required: true, message: `${tipList[5]}` }]}
label="Contract Remarks" label="Contract Remarks"
name="contractRemindContent" name="contractRemindContent"
style={{ marginBottom: 0 }}
> >
<TextArea <TextArea
autoSize={false} style={{ padding: 8, width: 600 }}
style={{ padding: 8, width: 600, height: 194 }} placeholder="Remarks"
placeholder="remarks" showCount={true}
autoSize={{ minRows: 6, maxRows: 6 }}
></TextArea> ></TextArea>
</Form.Item> </Form.Item>
</div> </div>
<div className={styles.box8item2x2} style={{ marginLeft: 150 }}> <div
The system will send out reminders of contract expiration on 25 . className={styles.box8item2x2}
style={{ marginLeft: 150, textTransform: 'capitalize' }}
>
<p style={{ marginBottom: 0 }}>
The system will send e-mail notification in the{' '}
<span style={{ color: 'red' }}>{tipTime[0]}</span> and{' '}
<span style={{ color: 'red' }}>{tipTime[1]}</span> that the contract is about to
expire !
</p>
<p style={{ marginBottom: 0 }}>
<span style={{ color: 'red' }}>*</span> If the time has passed, it will not be sent
</p>
{/* <span style={{color:'#f00'}}>&nbsp;{stateTime}</span> */} {/* <span style={{color:'#f00'}}>&nbsp;{stateTime}</span> */}
</div> </div>
</div> </div>
...@@ -288,6 +315,20 @@ const ContractContent = (props: any) => { ...@@ -288,6 +315,20 @@ const ContractContent = (props: any) => {
</div> </div>
</div> </div>
</Form> </Form>
{/* 附件预览 */}
<Modal
title="File Preview"
visible={tipModal}
// centered={true}
width={800}
onOk={handleCancel}
onCancel={handleCancel}
>
<p>预览接口调整中。。。</p>
<p>预览接口调整中。。。</p>
<p>预览接口调整中。。。</p>
</Modal>
</div> </div>
); );
}; };
......
...@@ -137,6 +137,7 @@ export const requestList = [ ...@@ -137,6 +137,7 @@ export const requestList = [
['/tos/tosCommunity/get/list', '48 修改获取小区列表', {}], ['/tos/tosCommunity/get/list', '48 修改获取小区列表', {}],
['/tos/community/delete', '49 关闭小区', {}], ['/tos/community/delete', '49 关闭小区', {}],
['/tos/community/facilities/subscribeTime/query', '50 设施预订时间段查询', {}], ['/tos/community/facilities/subscribeTime/query', '50 设施预订时间段查询', {}],
['/tos/user/infromation/get', '51 获取后台所有账号', {}],
]; ];
const params = [ const params = [
......
export const zhCnFaci = [
{
title: 'Check all',
key: '0',
children: [
{
title: 'life用户管理',
key: '1',
children: [
{ title: '查看LIFE用户', key: '2' },
{ title: '编辑LIFE用户', key: '3' },
{ title: '添加业主档案', key: '4' },
{ title: '注销业主档案', key: '5' },
{ title: '添加家属/租户', key: '6' },
{ title: '注销家属/租户', key: '7' },
],
},
{
title: '物业费管理',
key: '8',
children: [
{ title: '查看物业费', key: '9' },
{ title: '编辑物业费', key: '10' },
{ title: '0-0-1-2', key: '11' },
],
},
],
},
];
\ No newline at end of file
...@@ -50,3 +50,14 @@ export const BookingsTip = [ ...@@ -50,3 +50,14 @@ export const BookingsTip = [
[{ required: true, message: 'Required' }], [{ required: true, message: 'Required' }],
[{ required: true, message: 'Please Select The Date' }], [{ required: true, message: 'Please Select The Date' }],
]; ];
// 账号新增编辑
export const AccountTip = [
[{ required: true, message: 'Required' }],
[{ required: true, message: 'Required' }],
[{ required: true, message: 'Required' }],
[{ required: true, message: 'Required' }],
[{ required: true, message: 'Required' }],
[{ required: true, message: 'Required' }],
[{ required: true, message: 'Required' }],
];
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment