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