Commit 37e38614 authored by cellee's avatar cellee

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

parent 39b38790
import React, { useState, useEffect } from 'react';
import SelectOptions from '../SelectOptions/Tow';
import { connect } from 'umi';
const index = (props: any) => {
const { dispatch, CommunityList, value, onChange, checklist } = props;
// console.log(props)
const tosCommunityget = (values: any) => {
dispatch({ type: 'Init/tosCommunityget', playload: values });
};
useEffect(() => {
if (CommunityList == null) {
tosCommunityget(null);
}
}, []);
// 给已选值默认 如果有默认就传递默认 否则传递列表数据
useEffect(() => {
if (checklist != null) {
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 });
};
return (
<>
{CommunityList != null ? (
<SelectOptions
list={CommunityList.sort()}
checklist={checklist}
show={true}
onSubmit={printContent}
/>
) : null}
</>
);
};
function mapStateToProps(state: any) {
const { CommunityList } = state.Init;
return {
CommunityList,
};
}
export default connect(mapStateToProps)(index);
import React, { useState, useEffect, useRef } from 'react';
import { Table, Tag, Space, Button, Radio, Row, Col, Input, Checkbox } from 'antd';
import { connect } from 'dva';
import { gray } from 'chalk';
import { StarOutlined, StarFilled, StarTwoTone, DownOutlined, UpOutlined } from '@ant-design/icons';
import { indexOf } from 'lodash';
import { useIntl, getLocale } from 'umi';
var ArrayToPingYin = require('./ArrayToPingYin');
const CheckboxGroup = Checkbox.Group;
const menuListNormal = [
'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
'L',
'M',
'N',
'O',
'P',
'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X',
'Y',
'Z',
];
function getDotText(arr) {
if (arr) {
var str = '';
for (var i = 0; i < arr.length; i++) {
str += arr[i] + ',';
}
if (str.length > 0) {
str = str.substr(0, str.length - 1);
}
return str;
}
}
class SelectOptions extends React.PureComponent {
state = {};
constructor(props) {
super(props);
const { list, dispatch, checklist } = this.props;
if (list == null) {
//console.error("组件错误:没有数据导入")
}
if (checklist == null) {
this.state = {
menuList: ArrayToPingYin.get(list),
checkedListOptions: list,
checkedList: this.props.single != null ? [] : list,
indeterminate: false,
checkAll: true,
checkNone: false,
resultList: this.props.single != null ? [] : list,
flag: false,
lastValue: null,
};
} else {
this.state = {
menuList: ArrayToPingYin.get(list),
checkedListOptions: list,
checkedList: checklist,
indeterminate: list.sort().toString() == checklist.sort().toString() ? false : true, // 多选框 总框的 状态
checkAll: list.sort().toString() == checklist.sort().toString() ? true : false, // 判断传递来的小区是不是全选
checkNone: false,
resultList: checklist,
flag: false,
lastValue: null,
};
}
}
componentWillReceiveProps(nextProps) {
// 如果存在更新 就拿取最新的选中小区值
// 判断是不是props 的最新值 否则每次点击都要更新
if (nextProps.checklist !== this.props.checklist) {
this.setState({
menuList: ArrayToPingYin.get(nextProps.checklist),
checkedListOptions: nextProps.checklist,
checkedList: nextProps.checklist,
indeterminate: false, // 多选框 总框的 状态
checkAll: true, // 判断传递来的小区是不是全选
checkNone: false,
resultList: nextProps.checklist,
flag: false,
lastValue: null,
});
}
}
componentDidUpdate(prevProps) {
if (this.props.show != null) {
if (this.props.show == this.state.flag) {
console.log(this.props.show);
if (this.props.show == false) {
this.setState({ componetVisible: this.state.selectoptionsOpen, flag: true });
} else {
this.setState({ componetVisible: this.state.selectoptionsPutItAway, flag: false });
}
console.log(this.state.componetVisible);
}
// 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);
// console.log(prevProps.list);
// // 发生改变重新赋值
// this.setState({
// menuList: ArrayToPingYin.get(this.props.list),
// checkedListOptions: this.props.list,
// checkedList: this.props.list,
// indeterminate: false,
// checkAll: true,
// checkNone: false,
// resultList: this.props.list,
// flag: false,
// lastValue: null,
// });
// }
}
}
componentDidMount() {
var name = getLocale();
//console.log(name)
if (name == 'zh-CN') {
this.setState({
selectoptionsOpen: '展开',
selectoptionsPutItAway: '收起',
selectoptionsSelected: '已选',
selectoptionsSelectAll: '全选',
selectoptionsSelectNone: '全不选',
selectoptionsAll: '所有',
selectoptionsSearchCell: '搜索小区',
selectoptionsAllCell: '全部小区',
componetVisible: '收起',
});
} else {
this.setState({
selectoptionsOpen: 'Collapse ',
selectoptionsPutItAway: 'Close ',
selectoptionsSelected: 'Selected',
selectoptionsSelectAll: 'Select All',
selectoptionsSelectNone: 'Unselect All',
selectoptionsAll: 'All',
selectoptionsSearchCell: 'Search',
selectoptionsAllCell: ' All',
componetVisible: 'Close',
});
}
// console.log("初始化2")
}
// 展开收起
hideAndexpand = () => {
if (this.state.componetVisible == this.state.selectoptionsOpen) {
this.setState({ componetVisible: this.state.selectoptionsPutItAway });
} else {
this.setState({ componetVisible: this.state.selectoptionsOpen });
}
};
// 多选框改变的回调
onChangeValue = (checkedList) => {
// console.log(checkedList);
if (this.props.single != null) {
var tmp;
if (checkedList.length > 1) {
for (var i = 0; i < checkedList.length; i++) {
if (checkedList[i] != this.state.lastValue[0]) {
tmp = checkedList[i];
}
}
this.setState({
lastValue: [tmp],
checkedList: [tmp],
resultList: [tmp],
});
} else {
tmp = checkedList;
this.setState({
lastValue: checkedList,
checkedList: checkedList,
resultList: checkedList,
});
}
this.props.onSubmit(tmp[0]);
} else {
let difference;
var a = this.state.resultList;
var b = this.state.checkedListOptions;
let first = a.concat(b).filter((v) => a.includes(v) && !b.includes(v));
a = first;
b = checkedList;
difference = a.concat(b.filter((v) => !a.includes(v)));
this.setState({
checkedList,
indeterminate: !!difference.length && difference.length < this.props.list.length,
checkAll: difference.length === this.props.list.length,
checkNone: difference.length === 0,
resultList: difference,
});
this.props.onSubmit(difference);
}
};
// 全选
onCheckAllChange = (e) => {
// console.log(prevProps.list);
this.setState({
checkedList: this.props.list,
indeterminate: false,
checkAll: true,
checkNone: false,
resultList: this.props.list,
});
this.props.onSubmit(this.props.list);
};
// 全不选
onCheckAllChangeOver = (e) => {
this.setState({
checkedList: [],
indeterminate: false,
checkAll: false,
checkNone: true,
resultList: [],
});
this.props.onSubmit([]);
};
// 索引 -- 全部点击
itemSelectAll = (e) => {
// console.log(this.props.list);
this.setState({
checkedListOptions: this.props.list,
checkedList: this.state.resultList,
});
};
// 索引 -- 单个点击
itemSelect = (item, e) => {
var arraylist = this.props.list;
var array = ArrayToPingYin.get(this.props.list);
var tempAarry = new Array();
if (array) {
for (var i = 0; i < array.length; i++) {
if (array[i] == item) {
tempAarry.push(arraylist[i]);
}
}
}
this.setState({
checkedListOptions: tempAarry,
checkedList: this.state.resultList,
});
};
// 小区内部搜索框
getSearchValue = (item, e) => {
var list = this.props.list;
var tempAarry = new Array();
for (var i = 0; i < list.length; i++) {
if (list[i].toLowerCase().indexOf(item.toLowerCase()) != -1) {
tempAarry.push(list[i]);
}
}
this.setState({
checkedListOptions: tempAarry,
});
//小区内部搜索框键盘回车事件阻止冒泡
// e.domEvent.stopPropagation();
};
// 小区内部搜索框回车事件
onPressEnter = (e) => {
this.getSearchValue(this.state.inputText);
e.preventDefault();
};
//小区内部搜索框输入赋值
SearchChange = (e) => {
this.setState({
inputText: e.target.value,
});
};
render() {
return (
<div style={{ marginBottom: 14 }}>
{/* 是否展开 */}
{this.state.componetVisible == this.state.selectoptionsOpen ? (
<>
<div style={{ width: '100%', height: 48, position: 'relative' }}>
<div style={{ position: 'absolute', left: 5, top: 5 }}>
{this.state.resultList.length == 0
? this.state.selectoptionsSelectNone
: this.state.selectoptionsSelected}
{this.state.resultList.length == this.props.list.length
? this.state.selectoptionsAllCell
: null}
</div>
<div
style={{ position: 'absolute', right: 16, top: 5, cursor: 'pointer' }}
onClick={() => this.hideAndexpand()}
>
{this.state.componetVisible}
<DownOutlined />
</div>
</div>
<div style={{ paddingLeft: 15, paddingRight: 15, paddingBottom: 20 }}>
{this.state.resultList.length == this.props.list.length
? null
: getDotText(this.state.resultList)}
</div>
</>
) : (
<div style={{ width: '100%', backgroundColor: '#eeeeee' }}>
<div style={{ width: '100%', height: 40, position: 'relative' }}>
<div style={{ position: 'absolute', left: 12, top: 10 }}>
{this.state.resultList.length == 0
? this.state.selectoptionsSelectNone
: this.state.selectoptionsSelected}
{this.state.resultList.length == this.props.list.length
? this.state.selectoptionsAllCell
: null}
</div>
<div
style={{ position: 'absolute', right: 14, top: 10, cursor: 'pointer' }}
onClick={() => this.hideAndexpand()}
>
{this.state.componetVisible} <UpOutlined />
</div>
</div>
<div style={{ paddingLeft: 15, paddingRight: 15, paddingBottom: 20 }}>
{this.state.resultList.length == this.props.list.length
? null
: getDotText(this.state.resultList)}
</div>
<div style={{ width: '100%', backgroundColor: '#eeeeee', userSelect: 'none' }}>
<div style={{ width: '100%', height: 30, position: 'relative' }}>
{/* a-z 索引 */}
<div style={{ fontSize: 14, position: 'absolute' }}>
<a style={{ marginLeft: 16 }} onClick={this.itemSelectAll.bind(this)}>
{this.state.selectoptionsAll}
</a>
{menuListNormal.map((item, index) => {
if (this.state.menuList.indexOf(item) > -1) {
return (
<a
key={index}
style={{ marginLeft: 10, userSelect: 'none' }}
onClick={this.itemSelect.bind(this, item)}
>
{item}
</a>
);
} else {
return (
<a key={index} style={{ marginLeft: 10, userSelect: 'none' }} disabled>
{item}
</a>
);
}
})}
</div>
{/* 全选全不选 */}
{this.props.single != null ? null : (
<>
<Checkbox
style={{ position: 'absolute', right: 120 }}
indeterminate={this.state.indeterminate}
onChange={this.onCheckAllChange}
checked={this.state.checkAll}
>
{this.state.selectoptionsSelectAll}
</Checkbox>
<Checkbox
style={{ position: 'absolute', right: 10 }}
onChange={this.onCheckAllChangeOver}
checked={this.state.checkNone}
>
{this.state.selectoptionsSelectNone}
</Checkbox>
</>
)}
</div>
{/* 小区列表 */}
<div style={{ width: '100%', paddingLeft: 12, paddingRight: 12 }}>
<div
style={{
width: '100%',
backgroundColor: '#ffffff',
border: '1px solid #cfcfcf',
padding: 5,
}}
>
<Input.Search
placeholder={this.state.selectoptionsSearchCell}
onSearch={this.getSearchValue.bind(this)}
style={{ width: 200, margin: '10px' }}
onPressEnter={this.onPressEnter}
onChange={this.SearchChange}
/>
<CheckboxGroup
options={this.state.checkedListOptions} // 所有数组
value={this.state.checkedList} // 选中的数组
onChange={this.onChangeValue}
style={{ marginLeft: 10, display: 'block' }}
/>
<div>
<h1> </h1>
</div>
</div>
</div>
<br />
</div>
</div>
)}
</div>
);
}
}
export default SelectOptions;
......@@ -7,7 +7,7 @@ import './Account.less';
import { zhCnFaci, enUsFaci } from '@/utils/power';
import { AccountTip } from '@/utils/tip';
import SelectCommunity from '@/components/SelectCommunity';
import SelectCommunity from '@/components/SelectCommunity/Tow';
import { getNumber } from '@/utils/string'; // 正则
import { RA } from '@/utils/method';
......@@ -105,6 +105,7 @@ const Account = (props: any) => {
if (Info != null) {
setCommunity(Info.community);
power(Info.permissions);
setCheckedKeys([]);
}
}, [Info]);
......@@ -148,9 +149,6 @@ const Account = (props: 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 &&
......@@ -182,9 +180,7 @@ const Account = (props: any) => {
value.tosUserLevel = values; //级别
value.creatorName = JSON.parse(userInfo).userModel.tosUserName; //新建者账号
value.creatorId = id; //新建者ID
if (values == 3) {
value.userLeader = towAccountId;
}
delete value.community;
// 判断有没有 0 有就删除
......@@ -194,7 +190,7 @@ const Account = (props: any) => {
// 追加到上级id
let Obj = treeData[0].children;
console.log(Obj);
for (let i in Obj) {
for (let j in checkedKeys) {
if (JSON.stringify(Obj[i].children).indexOf(JSON.stringify(checkedKeys[j])) != -1) {
......@@ -208,6 +204,9 @@ const Account = (props: any) => {
return parseInt(n1) - parseInt(n2);
});
if (values == 3) {
value.userLeader = towAccountId;
}
// 另传权限
let obj = {
userName: value.tosUserName,
......@@ -255,25 +254,12 @@ const Account = (props: any) => {
//级别切换
const onRadio = (e: any) => {
setvalues(e.target.value);
// 如果是3级,取消后面两个选择
let treeDatas = treeDataList; //将转换而来的字符串转换为原生js对
let _p = treeDatas[0].children; // 所有权限列表
// 禁用最后两个
if (e.target.value == 3) {
_p[_p.length - 1].children[2].disableCheckbox = true;
_p[_p.length - 1].children[3].disableCheckbox = true;
} else {
// setCheckedKeys([]);
if (e.target.value == 2) {
//否则打开
_p[_p.length - 1].children[2].disableCheckbox = false;
_p[_p.length - 1].children[3].disableCheckbox = false;
settowAccountId(null);
setCommunity(CommunityList);
}
// 赋值改变
treeDatas[0].children = _p;
settreeDataList(treeDatas as any); // 可勾选列表
};
//手机号
......
......@@ -39,7 +39,6 @@ const Account = (props: any) => {
const [values, setvalues] = useState(2); // 树形菜单展开关闭
const [over, setOver] = useState(false); // 关闭账号确认弹窗
const [accountName, setaccountName] = useState(null as any); // 弹窗账号信息
// 表单标识
const [form] = Form.useForm();
......@@ -48,7 +47,6 @@ const Account = (props: any) => {
// // 数据
useEffect(() => {
if (DataSave != null) {
console.log(DataSave.tosUserLevel);
// 赋值
form.setFieldsValue({
tosUserName: DataSave.tosUserName,
......@@ -195,14 +193,6 @@ const Account = (props: any) => {
setSelectedKeys(selectedKeys);
};
// 管理员级别样式
const radioStyle = {
display: 'block',
height: '30px',
lineHeight: '30px',
marginBottom: '15px',
};
// 监听改变状态提交结果
useEffect(() => {
if (Result != null) {
......@@ -216,11 +206,6 @@ const Account = (props: any) => {
}
}, [Result]);
//级别切换
const onRadio = (e: any) => {
setvalues(e.target.value);
};
//手机号
const keyup_communityManagerFee = (e: any) => {
e.target.value = keyup_tool(e.target.value);
......@@ -232,9 +217,14 @@ const Account = (props: any) => {
// 停用账号弹窗
const lockS = () => {
// 先判断是不是自己
const userInfo = JSON.parse(localStorage.getItem('userInfo') || '[]');
if (userInfo.userModel.id == DataSave.id) {
message.info('Unable to close own account!');
return;
} else {
setOver(true);
setaccountName(DataSave);
console.log(DataSave);
}
};
// 关闭弹窗
......@@ -246,9 +236,9 @@ const Account = (props: any) => {
const handleOk = (e: any) => {
//
let obj = {
// userStatus: accountName.userStatus == 0 ? 1 : 0,
// userStatus: DataSave.userStatus == 0 ? 1 : 0,
userStatus: 1,
userID: accountName.tosUserId,
userID: DataSave.tosUserId,
};
RA(52, obj, module, dispatch);
// setOver(false);
......@@ -261,10 +251,14 @@ const Account = (props: any) => {
<EditOutlined />
&nbsp; Detail Account
<div className="back">
{DataSave && DataSave.tosUserLevel <= 2 ? (
<Button type="primary" danger style={{ marginRight: 15 }} onClick={lockS}>
<PoweroffOutlined />
Close Account
</Button>
) : (
''
)}
<Button onClick={goToReturn}>
<LeftOutlined />
Back
......@@ -330,11 +324,11 @@ const Account = (props: any) => {
color="success"
style={{ verticalAlign: 'sub', fontSize: 14, padding: '4px 7px' }}
>
{DataSave.tosUserLevel == 2
{DataSave && DataSave.tosUserLevel == 2
? 'Two Level Administrator '
: 'Three Level Administrator'}
</Tag>
{DataSave.tosUserLevel == 3 ? (
{DataSave && DataSave.tosUserLevel == 3 ? (
<Tag
icon={<RightOutlined />}
color="processing"
......@@ -388,11 +382,11 @@ const Account = (props: any) => {
onCancel={handleCancel}
confirmLoading={loading}
>
{accountName != null ? (
{DataSave != null ? (
<p>
Are You Sure To{' '}
<span style={{ color: 'red' }}>{accountName.userStatus != 1 ? 'Close' : 'Open'}</span>{' '}
The Account '<span style={{ color: 'red' }}> {accountName.tosUserName} </span>' ?
<span style={{ color: 'red' }}>{DataSave.userStatus != 1 ? 'Close' : 'Open'}</span>{' '}
The Account '<span style={{ color: 'red' }}> {DataSave.tosUserName} </span>' ?
</p>
) : (
''
......
......@@ -91,6 +91,8 @@ const Account = (props: any) => {
// 发起获取权限请求
RA(54, { tosUserName: DataSave.tosUserName }, module, dispatch); // 发起获取权限请求
} else {
history.push('/AccountManagement/account');
}
}, [DataSave, user]);
......@@ -357,11 +359,11 @@ const Account = (props: any) => {
color="success"
style={{ verticalAlign: 'sub', fontSize: 14, padding: '4px 7px' }}
>
{DataSave.tosUserLevel == 2
{DataSave && DataSave.tosUserLevel == 2
? 'Two Level Administrator '
: 'Three Level Administrator'}
</Tag>
{DataSave.tosUserLevel == 3 ? (
{DataSave && DataSave.tosUserLevel == 3 ? (
<Tag
icon={<RightOutlined />}
color="processing"
......
......@@ -167,7 +167,10 @@ const BookingDetail = (props: any) => {
<hr />
{/* 已交押金且未产生退费 */}
{DataSave != null && DataSave.managerFeeStatus == 1 && DataSave.backMarginFee > 0 ? (
{DataSave &&
DataSaveDetail &&
DataSave.managerFeeStatus == 1 &&
DataSaveDetail.backMarginFee == 0 ? (
<>
<Form
ref={formRef}
......
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