Commit 7955ee38 authored by cellee's avatar cellee

Signed-off-by: cellee <893264950@qq.com>

parent c9b23759
import React, { useState,useEffect} from 'react';
import React, { useState, useEffect } from 'react';
import SelectOptions from '../SelectOptions';
import { connect } from 'umi'
import { connect } from 'umi';
const index = (props:any) => {
const {dispatch, CommunityList,value,onChange , checklist} = props;
const index = (props: any) => {
const { dispatch, CommunityList, value, onChange, checklist } = props;
// console.log(props)
const tosCommunityget = (values:any) => {dispatch({type: 'Init/tosCommunityget',playload:values})};
const tosCommunityget = (values: any) => {
dispatch({ type: 'Init/tosCommunityget', playload: values });
};
useEffect(() => {
if (CommunityList == null) {
tosCommunityget(null)
tosCommunityget(null);
}
}, []);
// 给已选值默认 如果有默认就传递默认 否则传递列表数据
useEffect(() => {
if (checklist != null) {
onChange({ index:1,value: checklist})
}else{
onChange({ index:1,value: CommunityList})
onChange({ index: 1, value: checklist });
} else {
onChange({ index: 1, value: CommunityList });
}
}, [checklist]);
// 点击选择的时候传递给子组件 已选列表
const printContent = (values:any) => {
onChange({ index:CommunityList.length==values.length?1:0,value: values})
}
const printContent = (values: any) => {
onChange({ index: CommunityList.length == values.length ? 1 : 0, value: values });
};
return (
<>
{
CommunityList != null ?
<SelectOptions list={CommunityList.sort()} checklist={checklist} show={true} onSubmit={printContent} />:
null
}
{CommunityList != null ? (
<SelectOptions
list={CommunityList.sort()}
checklist={checklist}
show={true}
onSubmit={printContent}
/>
) : null}
</>
);
};
function mapStateToProps(state:any) {
function mapStateToProps(state: any) {
const { CommunityList } = state.Init;
return {
CommunityList,
......
......@@ -75,7 +75,6 @@ class SelectOptions extends React.PureComponent {
lastValue: null,
};
} else {
// console.log(checklist);
this.state = {
menuList: ArrayToPingYin.get(list),
checkedListOptions: list,
......@@ -89,6 +88,17 @@ class SelectOptions extends React.PureComponent {
};
}
}
componentWillReceiveProps(nextProps) {
// 如果存在更新 就拿取最新的选中小区值
// 判断是不是props 的最新值 否则每次点击都要更新
if (nextProps.checklist !== this.props.checklist) {
this.setState({
checkedList: nextProps.checklist,
});
}
}
componentDidUpdate(prevProps) {
if (this.props.show != null) {
if (this.props.show == this.state.flag) {
......@@ -100,8 +110,8 @@ class SelectOptions extends React.PureComponent {
}
console.log(this.state.componetVisible);
}
if (this.props.list.length > this.state.checkedList.length) {
}
// if (this.props.list.length > this.state.checkedList.length) {
// }
// console.log(prevProps.list);
// if (this.props.list.length > prevProps.list.length) {
// console.log(this.props.list);
......
......@@ -16,9 +16,16 @@ export default {
Permission: null,
SubResult: null, // 结果
Info: null, // 二级管辖小区和权限
},
reducers: {
// 二级账户管辖小区和权限
returnInfo(state, { Info }) {
return { ...state, Info };
},
returnPage(state, { Data }) {
return { ...state, Data };
},
......@@ -110,6 +117,12 @@ export default {
localStorage.setItem('towAccount', JSON.stringify(resp.data));
}
break;
case 57: // 二级账号
{
let Info = resp.data;
yield put({ type: 'returnInfo', Info });
}
break;
}
}
},
......@@ -134,5 +147,11 @@ export default {
var SubResult = null;
yield put({ type: 'returnDelccount', SubResult });
},
// 清除二级账户选择
*InfoClear({}, { put }) {
var Info = null;
yield put({ type: 'returnInfo', Info });
},
},
};
......@@ -161,6 +161,8 @@ const Account = (props: any) => {
// 编辑- 新增
const edit = (item: any) => {
// console.log(item);
// 无论编辑还是新增都清掉二级账户选择
dispatch({ type: 'Account/InfoClear' });
if (item == 1) {
history.push('/AccountManagement/account/Add');
} else {
......
......@@ -14,10 +14,10 @@ import { RA } from '@/utils/method';
const Account = (props: any) => {
const module = 'Account';
const { dispatch, SubResult, CommunityList, loading, user } = props;
const { dispatch, SubResult, CommunityList, loading, user, Info } = props;
// 权限列表
const treeData = enUsFaci || zhCnFaci;
const treeData = localStorage.getItem('umi_locale') == 'zh-CN' ? zhCnFaci : enUsFaci;
const [expandedKeys, setExpandedKeys] = useState<string[]>([]); // 展开栏目
const [checkedKeys, setCheckedKeys] = useState([] as any); // 默认已选栏目
......@@ -28,6 +28,9 @@ const Account = (props: any) => {
const [values, setvalues] = useState(2); // 树形菜单展开关闭
const [disab, setdisab] = useState(false); // 是否禁止选择二级
const [towAccountId, settowAccountId] = useState(null); // 二级账户id
const [treeDataList, settreeDataList] = useState(treeData); // 权限列表
//默认选中的小区
const [community, setCommunity] = useState(CommunityList); // 默认全选
// 表单标识
const [form] = Form.useForm();
......@@ -40,8 +43,9 @@ const Account = (props: any) => {
// 当前账户权限
useEffect(() => {
if (user != null) {
let treeDatas = treeData;
if (user != null || values == 2) {
let _tmp = JSON.stringify(treeData); //将对象转换为json字符串形式
let treeDatas = JSON.parse(_tmp); //将转换而来的字符串转换为原生js对
let _a = user.currentUser.permission; // 当前账户权限
let _p = treeDatas[0].children; // 所有权限列表
......@@ -68,13 +72,10 @@ const Account = (props: any) => {
if (user.currentUser.userModel.tosUserLevel > 1) {
setvalues(3);
setdisab(true);
settowAccountId(user.currentUser.id);
// 如果是三级账户,禁用最后两个账户管理
if (user.currentUser.userModel.tosUserLevel == 3) {
// 禁用最后两个
settowAccountId(user.currentUser.userModel.id);
// 且禁用最后两个账户管理
_p[_p.length - 1].children[2].disableCheckbox = true;
_p[_p.length - 1].children[3].disableCheckbox = true;
}
} else {
// 如果是一级账户获取挂靠的二级账户名称
RA(56, {}, module, dispatch); // 权限上传
......@@ -82,9 +83,9 @@ const Account = (props: any) => {
// 赋值改变
treeDatas[0].children = _p;
setCheckedKeys(treeDatas as any); // 可勾选列表
settreeDataList(treeDatas as any); // 可勾选列表
}
}, [user]);
}, [user, values]);
useEffect(() => {
// 提交信息结果
......@@ -99,10 +100,57 @@ const Account = (props: any) => {
}
}, [SubResult]);
// 二级管辖小区和权限
useEffect(() => {
if (Info != null) {
setCommunity(Info.community);
power(Info.permissions);
}
}, [Info]);
//权限赋值
const power = (val: any) => {
let _tmp = JSON.stringify(treeData); //将对象转换为json字符串形式
let treeDatas = JSON.parse(_tmp); //将转换而来的字符串转换为原生js对
let _a = val; // 当前账户权限
let _p = treeDatas[0].children; // 所有权限列表
let arr: any = []; // 一级栏目权限
let erArr: any = []; // 一级栏目权限
// 循环一级 判断当前账户有没有权限修改增加
for (let i of _a) {
for (let j in _p) {
if (_p[j].key == i) {
arr.push(_p[j].key);
_p[j].disabled = false;
}
// 二级权限
for (let k in _p[j].children) {
if (_p[j].children[k].key == i) {
erArr.push(_p[j].children[k].key);
_p[j].children[k].disableCheckbox = false;
}
}
}
}
// 且禁用最后两个账户管理
_p[_p.length - 1].children[2].disableCheckbox = true;
_p[_p.length - 1].children[3].disableCheckbox = true;
// 赋值改变
treeDatas[0].children = _p;
settreeDataList(treeDatas as any); // 可勾选列表
};
// 保存提交
const onFinishContract = async (value: any) => {
const userInfo = localStorage.getItem('userInfo') || '';
const id = JSON.parse(userInfo).userModel.id;
console.log(treeDataList);
console.log();
if (
value.tosAccountName.length <= 2 &&
value.tosUserPhone.length != 8 &&
......@@ -111,7 +159,7 @@ const Account = (props: any) => {
// 姓名联系方式
message.error('Please enter the correct name and contact information!');
return false;
} else if (checkedKeys[0].key) {
} else if (checkedKeys.length == 0) {
// 如果存在key 就是没有选择
// 权限
message.error('Please Select Permission!');
......@@ -209,7 +257,7 @@ const Account = (props: any) => {
setvalues(e.target.value);
// 如果是3级,取消后面两个选择
let treeDatas = treeData;
let treeDatas = treeDataList; //将转换而来的字符串转换为原生js对
let _p = treeDatas[0].children; // 所有权限列表
// 禁用最后两个
if (e.target.value == 3) {
......@@ -221,10 +269,11 @@ const Account = (props: any) => {
_p[_p.length - 1].children[3].disableCheckbox = false;
settowAccountId(null);
setCommunity(CommunityList);
}
// 赋值改变
treeDatas[0].children = _p;
setCheckedKeys(treeDatas as any); // 可勾选列表
settreeDataList(treeDatas as any); // 可勾选列表
};
//手机号
......@@ -247,6 +296,8 @@ const Account = (props: any) => {
// 选择哪个二级账号
const handleChange = (value: any) => {
console.log(`selected ${value}`);
RA(57, { tosUserLevelId: value }, module, dispatch); // 根据用户id获取用户管辖小区名和权限
settowAccountId(value);
};
......@@ -300,7 +351,7 @@ const Account = (props: any) => {
</Descriptions>
<Form.Item name="community" label="Community">
<SelectCommunity checklist={CommunityList == null ? null : CommunityList} />
<SelectCommunity checklist={community ? community : null} />
</Form.Item>
<div className="diy" style={{ marginBottom: '14px' }}>
......@@ -346,7 +397,7 @@ const Account = (props: any) => {
checkedKeys={checkedKeys}
onSelect={onSelect}
selectedKeys={selectedKeys}
treeData={treeData}
treeData={treeDataList}
/>
</div>
</div>
......@@ -366,7 +417,7 @@ const Account = (props: any) => {
};
const AccountProps = (state: any) => {
const { Data, DataSave, DataSaveDetail, Result, SubResult } = state.Account;
const { Data, DataSave, DataSaveDetail, Result, SubResult, Info } = state.Account;
const { CommunityList } = state.Init; // 小区列表
const loading = state.loading.models.Account || false;
const { user } = state;
......@@ -379,6 +430,7 @@ const AccountProps = (state: any) => {
CommunityList,
user, // 获取当前账户信息
SubResult,
Info,
};
};
......
import React, { useState, useEffect, useRef } from 'react';
import { Form, Input, Button, Spin, message, Descriptions, Modal, Tree, Radio } from 'antd';
import { Form, Input, Button, Spin, message, Descriptions, Modal, Tree, Tag } from 'antd';
import { connect, history } from 'umi';
import { EditOutlined, LeftOutlined, PoweroffOutlined } from '@ant-design/icons';
import {
EditOutlined,
LeftOutlined,
PoweroffOutlined,
RightOutlined,
CheckCircleOutlined,
} from '@ant-design/icons';
import { getCookie } from '@/utils/method';
import './Account.less';
......@@ -92,10 +98,37 @@ const Account = (props: any) => {
useEffect(() => {
if (Permission != null) {
let newPer = eval('(' + Permission + ')');
let data: any = [];
let data: any = []; // 编辑的账户的权限
for (let i in newPer) {
data[i] = newPer[i] + '';
}
let _p = treeData[0].children; // 所有权限列表
// console.log(_p); // 所有权限列表
for (let i in _p) {
let arr = _p[i].children; // 每个权限
let newArr = []; // 每个权限下的子权限列表
for (let j in arr) {
newArr.push(arr[j].key);
}
// console.log(newArr);
if (!newArr.every((val) => data.includes(val))) {
// 判断数组是否包含另一个数组
// console.log('不包含' + _p[i].key);
// 不全部包含就删除数组的元素
var index = data.indexOf(_p[i].key);
if (index > -1) {
data.splice(index, 1);
}
} else {
// console.log('包含' + _p[i].key);
}
}
// 再赋值给列表
// data.push('0');
setCheckedKeys(data);
}
}, [Permission]);
......@@ -292,15 +325,26 @@ const Account = (props: any) => {
<span className="title">Privilege Level:</span>
</div>
<div className="label">
<Radio.Group defaultValue={DataSave.tosUserLevel} onChange={onRadio} disabled>
<Radio style={radioStyle} value={2}>
Two Level Administrator
</Radio>
<Radio style={radioStyle} value={3}>
Three Level Administrator
{/* <Input placeholder="三级管理员" style={{ width: 160, marginLeft: 10 }} /> */}
</Radio>
</Radio.Group>
<Tag
icon={<CheckCircleOutlined />}
color="success"
style={{ verticalAlign: 'sub', fontSize: 14, padding: '4px 7px' }}
>
{DataSave.tosUserLevel == 2
? 'Two Level Administrator '
: 'Three Level Administrator'}
</Tag>
{DataSave.tosUserLevel == 3 ? (
<Tag
icon={<RightOutlined />}
color="processing"
style={{ verticalAlign: 'sub', fontSize: 14, padding: '4px 7px' }}
>
Superiors:{DataSave.userLeaderAccountName} - {DataSave.userLeaderName}
</Tag>
) : (
''
)}
</div>
</div>
......
......@@ -167,9 +167,7 @@ const BookingDetail = (props: any) => {
<hr />
{/* 已交押金且未产生退费 */}
{DataSave != null &&
DataSave.managerFeeStatus == 1 &&
DataSave.communityManagerFee > 0 ? (
{DataSave != null && DataSave.managerFeeStatus == 1 && DataSave.backMarginFee > 0 ? (
<>
<Form
ref={formRef}
......
......@@ -130,4 +130,5 @@ export const requestList = [
['/tos/user/permission/get', '54 根据用户名称获取用户权限', {}],
['/tos/tosCommunity/get/user', '55 根据用户id获取用户管辖小区名', {}],
['/tos/user/twoLevel/get', '56 获取二级账号', {}],
['/tos/user/twoLevel/get/CommunityAuth', '57 根据用户id获取用户管辖小区名和权限', {}],
];
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