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) => {
defaultValue,
time,
username,
searchNone, // 隐藏搜索框
} = props;
const key = props.listkey;
......@@ -184,15 +185,19 @@ const TitleSearch = (props: any) => {
/>
) : null}
<Form.Item style={{ marginBottom: 5 }}>
<Button
type="primary"
htmlType="submit"
style={{ backgroundColor: '#e7f4ff', color: 'rgba(24,144,255,1)' }}
>
<SearchOutlined /> Search
</Button>
</Form.Item>
{searchNone == null ? (
<Form.Item style={{ marginBottom: 5 }}>
<Button
type="primary"
htmlType="submit"
style={{ backgroundColor: '#e7f4ff', color: 'rgba(24,144,255,1)' }}
>
<SearchOutlined /> Search
</Button>
</Form.Item>
) : (
''
)}
</>
) : null}
</Form>
......
......@@ -58,6 +58,12 @@ export default {
yield put({ type: 'returnPage', Data });
}
break;
case 51:
{
let Data = resp.data;
yield put({ type: 'returnPage', Data });
}
break;
}
}
},
......
......@@ -3,10 +3,47 @@
padding: 20px;
border-right: 4px;
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 {
text-align: right;
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 {
padding: 0 10px 20px;
......
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 { SearchOutlined, ClearOutlined, PlusOutlined } from '@ant-design/icons';
import ProTable from '@ant-design/pro-table';
......@@ -15,24 +15,22 @@ const Account = (props: any) => {
dispatch({ type: 'Account/RA', playload: { index: index, body: values } });
};
// 数据
useEffect(() => {
let obj = {
leaderID: getCookie('id'),
};
RA(45, obj);
}, [1]); //页面进来执行一次
// 数据
useEffect(() => {
if (Data == null) {
let obj = {
leaderID: getCookie('id'),
pageNum: 1,
};
RA(45, obj);
// RA(45, obj);
setTerm(obj);
RA(51, obj);
}
}, [Data]); //页面进来执行一次
// 拉取数据的条件存储
const [term, setTerm] = useState({} as any);
// 表单标识
const [form] = Form.useForm();
......@@ -109,12 +107,36 @@ const Account = (props: any) => {
},
];
// 编辑- 新增
const edit = (item: any) => {
history.push('./account/edit');
};
// 停用账号
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 (
<>
<div className="contop">
......@@ -123,12 +145,12 @@ const Account = (props: any) => {
layout="inline"
form={form}
name="contract"
// onFinish={onFinishContract}
onFinish={onFinishContract}
>
<Form.Item name="username">
<Form.Item name="accountName">
<Input allowClear placeholder="Account Name" />
</Form.Item>
<Form.Item name="creator">
<Form.Item name="creatorName">
<Input allowClear placeholder="Account Creator" />
</Form.Item>
<Form.Item>
......@@ -153,7 +175,7 @@ const Account = (props: any) => {
<ProTable
// request={requestHeadl}
rowKey={'id'}
dataSource={Data ? Data.rows : null}
dataSource={Data ? Data.list : null}
columns={columns}
pagination={false} // 隐藏默认分页
search={false}
......@@ -185,9 +207,10 @@ const Account = (props: any) => {
<div className="pages">
<Pagination
// onShowSizeChange={pageSizeHandler}
// current={Data.total}
total={Data ? Data.total : 0}
pageSize={Data ? Data.total : 0}
current={Data ? Data.page.currentPage : 0}
onChange={sopens}
total={Data ? Data.page.totalRow : 0}
pageSize={Data ? Data.page.curPageSize : 0}
/>
</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 {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";
import React, { useState, useEffect, useRef } from 'react';
import {
Form,
Input,
Button,
Pagination,
message,
Descriptions,
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 = [];
let checkUser = 1;
// 权限列表
const treeData = zhCnFaci;
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) {
super(props);
this.state = {
account: '',
pw: '',
pw2: '',
id: '',
email: '',
phone: '',
status: '',
radio: 2,
createUser: '',
userId: '',
defaultLevel:'',
// 单选 二级还是三级管理员
const [values, setvalues] = useState(1); // 树形菜单展开关闭
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: ["一级管理员", "二级管理员","三级管理员"],
// 表单标识
const [form] = Form.useForm();
const formRef = useRef(null);
leader: '',
deviceList: [],
addDevice: '',
flag: 1,
// 表头单搜索
const onFinishContract = (value: any) => {
console.log(value);
console.log(value.community);
};
//goToReturn
const goToReturn = () => {};
used: null,
newAdd: null,
strList: [],
}
}
// 全选
const onCheckAllChange = (e: any) => {};
/*----------------- 方法集 ------------------*/
//显示信息
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,
});
}
}
}
}
});
// 展开/收起树形菜单触发
const onExpand = (expandedKeys: any) => {
setExpandedKeys(expandedKeys);
setAutoExpandParent(false);
};
//保存权限信息
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});
// 点击单个触发
const onCheck = (checkedKeys: any) => {
console.log('onCheck', checkedKeys);
setCheckedKeys(checkedKeys);
};
adChange = (e) => {
this.setState({level: e == undefined?undefined:e+1});
// 点击树节点触发 - 大栏目
const onSelect = (selectedKeys: any, info: any) => {
console.log('onSelect', info);
setSelectedKeys(selectedKeys);
};
//密码变更
pwChange = (e) => {
this.setState({pw: e.target.value});
};
//确认密码变更
pwChange2 = (e) => {
this.setState({pw2: e.target.value});
// 管理员级别样式
const radioStyle = {
display: 'block',
height: '30px',
lineHeight: '30px',
marginBottom: '15px',
};
//联系电话变更
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("提交失败!");
}
}
});
}
}
}
});
//级别切换
const onRadio = (e: any) => {
setvalues(e.target.value);
};
//初始化
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>
: ''}
return (
<>
<div className="contop" style={{ padding: '12px 20px' }}>
<h3 className="capi">
<EditOutlined />
&nbsp; {DataSave ? 'Edit' : 'Add'} Account
<div className="back">
<Button onClick={goToReturn}>
<LeftOutlined />
Back
</Button>
</div>
</h3>
</div>
<div className="contop">
<Form
ref={formRef}
form={form}
autoComplete="off"
// layout="inline"
layout="horizontal"
name="contract"
onFinish={onFinishContract}
>
<Descriptions column={{ xs: 1, sm: 2, md: 3 }}>
<Descriptions.Item>
<Form.Item name="basic" label="管理员姓名" rules={AccountTip[0]}>
<Input placeholder="6 Postcode" className="input" />
</Form.Item>
</Descriptions.Item>
<Descriptions.Item>
<Form.Item name="basic" label="联系方式">
<Input placeholder="6 Postcode" className="input" />
</Form.Item>
</Descriptions.Item>
<Descriptions.Item>
<Form.Item name="basic" label="所属公司">
<Input placeholder="6 Postcode" className="input" />
</Form.Item>
</Descriptions.Item>
</Descriptions>
<Descriptions column={{ xs: 1, sm: 2, md: 3 }}>
<Descriptions.Item>
<Form.Item name="basic" label="账号ID">
<Input placeholder="6 Postcode" className="input" />
</Form.Item>
</Descriptions.Item>
<Descriptions.Item>
<Form.Item name="basic" label="登录密码">
<Input placeholder="6 Postcode" className="input" />
</Form.Item>
</Descriptions.Item>
</Descriptions>
<Form.Item name="community" label="服务小区">
<SelectCommunity />
</Form.Item>
<div className="diy" style={{ marginBottom: '14px' }}>
<div className="label">
<span className="title">权限配置:</span>
</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 className="label">
<Radio.Group defaultValue={values} onChange={onRadio}>
<Radio style={radioStyle} value={1}>
二级管理员
</Radio>
<Radio style={radioStyle} value={2}>
三级管理员
<Input placeholder="三级管理员" style={{ width: 160, marginLeft: 10 }} />
</Radio>
</Radio.Group>
</div>
</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 className="diy" style={{ marginBottom: '24px' }}>
<div className="label">
<span className="title">权限选择:</span>
</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 className="label">
<Tree
checkable
onExpand={onExpand}
expandedKeys={expandedKeys}
autoExpandParent={autoExpandParent}
onCheck={onCheck}
checkedKeys={checkedKeys}
onSelect={onSelect}
selectedKeys={selectedKeys}
treeData={treeData}
/>
</div>
</div>
</div>
</div>
);
}
}
export default connect(({user}: ConnectState) => ({
currentUser: user.currentUser,
}))(AccountEdit);
<div className="diy">
<div className="label"></div>
<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) => {
// 图片地址
const [ImageSrc, setImageSrc] = useState([] as any);
console.log(ImgSrc);
// 监听传递过来的值
useEffect(() => {
if (DataSave != null) {
......@@ -134,7 +132,6 @@ const Add = (props: any) => {
ref={formRef}
form={form}
// {...layout}
name="nest-messages"
onFinish={onFinish}
validateMessages={validateMessages}
>
......
import React, { useState, useEffect, useRef } from 'react';
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 { Link, useIntl, connect, Dispatch, Loading } from 'umi';
......@@ -18,8 +18,6 @@ import locale from 'antd/es/date-picker/locale/en_US';
import SearchOptionsCommnity from '@/components/SearchOptions/SearchOptionsCommnity';
import { tipList } from '@/utils/tip';
import FileViewer from 'react-file-viewer';
const ContractContent = (props: any) => {
const { ContractModel, dispatch } = props;
const { RangePicker } = DatePicker; // 日期组件
......@@ -32,14 +30,12 @@ const ContractContent = (props: any) => {
function disabledDate(current: any) {
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 [uploadUp, setUploadUp] = useState(true); // 禁止上传 直到选择了小区后
const [comtyName, setComtyName] = useState(null); // 小区名字
console.log(tipList);
const [tipTime, setTipTime] = useState(['previous month', 'two months'] as any); //提示时间
const [tipModal, settipModal] = useState(false); //附件弹窗
useEffect(() => {
// 如果是添加传来没有值的时候 就清空 否则 赋值给表单
......@@ -58,15 +54,23 @@ const ContractContent = (props: any) => {
uid: i,
name: arr[i],
status: 'done',
url: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
url: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.pdf',
};
obj.push(a);
}
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({
...ContractModel.record,
time: [
......@@ -77,6 +81,7 @@ const ContractContent = (props: any) => {
}
}, [1]);
// 返回
const goToReturn = () => {
// console.log(fileList)
history.back();
......@@ -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) => {
// if(overTime != dateStrings[1]){
// moment(dateStrings[1]).diff(startTime,'days') > 25 ?
// setmodalTime(moment(dateStrings[1]).subtract(25, 'days').format('YYYY-MM-DD')) :
// setmodalTime('Due soon');
// }
// form.setFieldsValue({
// 'time' : [moment(dateStrings[0]),moment(dateStrings[1])]
// })
if (data != null) {
let a1 = moment(data[1]).subtract(2, 'month').format('YYYY-MM-DD');
let a2 = moment(data[1]).subtract(1, 'month').format('YYYY-MM-DD');
setTipTime([a1, a2]);
}
console.log(dateStrings);
};
// 选择小区名字并赋值
const opname = (value: any) => {
// 打开上传 如果选择了 小区就打开 否则 禁止上传
......@@ -148,6 +147,16 @@ const ContractContent = (props: any) => {
});
};
//点击预览
const onPreviews = () => {
console.log('预览');
settipModal(true);
};
// 关闭预览
const handleCancel = () => {
settipModal(false);
};
return (
<div className={styles.base}>
{/* 头部组件 */}
......@@ -241,7 +250,7 @@ const ContractContent = (props: any) => {
defaultValue={ContractModel.time}
disabledDate={disabledDate}
placeholder={['Effective Date', 'Expiration Date']}
// onChange={changeTime}
onChange={changeTime}
/>
</Form.Item>
</div>
......@@ -253,7 +262,12 @@ const ContractContent = (props: any) => {
label="Contract Annex"
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 />}
</Upload>
</Form.Item>
......@@ -266,16 +280,29 @@ const ContractContent = (props: any) => {
rules={[{ required: true, message: `${tipList[5]}` }]}
label="Contract Remarks"
name="contractRemindContent"
style={{ marginBottom: 0 }}
>
<TextArea
autoSize={false}
style={{ padding: 8, width: 600, height: 194 }}
placeholder="remarks"
style={{ padding: 8, width: 600 }}
placeholder="Remarks"
showCount={true}
autoSize={{ minRows: 6, maxRows: 6 }}
></TextArea>
</Form.Item>
</div>
<div className={styles.box8item2x2} style={{ marginLeft: 150 }}>
The system will send out reminders of contract expiration on 25 .
<div
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> */}
</div>
</div>
......@@ -288,6 +315,20 @@ const ContractContent = (props: any) => {
</div>
</div>
</Form>
{/* 附件预览 */}
<Modal
title="File Preview"
visible={tipModal}
// centered={true}
width={800}
onOk={handleCancel}
onCancel={handleCancel}
>
<p>预览接口调整中。。。</p>
<p>预览接口调整中。。。</p>
<p>预览接口调整中。。。</p>
</Modal>
</div>
);
};
......
......@@ -137,6 +137,7 @@ export const requestList = [
['/tos/tosCommunity/get/list', '48 修改获取小区列表', {}],
['/tos/community/delete', '49 关闭小区', {}],
['/tos/community/facilities/subscribeTime/query', '50 设施预订时间段查询', {}],
['/tos/user/infromation/get', '51 获取后台所有账号', {}],
];
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 = [
[{ required: true, message: 'Required' }],
[{ 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