Commit c9b23759 authored by cellee's avatar cellee

账号权限

Signed-off-by: cellee's avatarcellee <893264950@qq.com>
parent d1381930
import React, { useState, useEffect, useRef } from 'react';
import './index.less';
import { Button, Form, message, Modal, Input, Upload } from 'antd';
import { PlusOutlined } from '@ant-design/icons';
// import FacilitysTow from './FacilitysTow';
import { Link, useIntl, connect, Dispatch, history } from 'umi';
function getBase64(file: any) {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = () => resolve(reader.result);
reader.onerror = (error) => reject(error);
});
}
const module = 'FacilityBookings';
const Facilitys = (props: any) => {
//传递值
const { updata, disabled, FacilitysList, dispatch, dumps } = props;
//上传列表
// const [FacilitysList, setFileList] = useState(FacilitysList);
//显示隐藏
const [previewVisible, setpreviewVisible] = useState(false);
// 名称
const [previewTitle, setpreviewTitle] = useState('');
// 图片地址
const [previewImage, setpreviewImage] = useState('');
// 传递给后台加 key
const updetaTow = (key: any) => {
let data = updata;
data.identification = key;
return data;
};
//绑定值
const updetaList = (key: any) => {
return FacilitysList[key].fileList;
};
// 预览
const handlePreview = async (file: any) => {
if (!file.url && !file.preview) {
file.preview = await getBase64(file.originFileObj);
}
setpreviewImage(file.url || file.preview);
setpreviewTitle(file.name);
setpreviewVisible(true);
};
// 点击遮罩回调
const handleCancel = () => {
setpreviewVisible(false);
};
// 上传属性
const uploadProps: any = {
listType: 'picture-card',
accept: '.jpeg,.png,.jpg',
action: '/tos/image/upload',
onChange(info: any) {
// console.log(info);
if (info.file.status === 'done') {
message.success(`${info.file.name} file uploaded successfully`);
// 拿到key 值 开始存储
let key = info.fileList[0].response.data.identification;
let list = FacilitysList;
list[key].id = key;
list[key].fileList = info.fileList;
// 存储到mode里面去
dispatch({ type: module + '/genxin', list });
// 当前页面也要刷新
// let list = fileList;
// setFileList(list); // 注意 不能直接赋值 因为使用完全绑定需要全部更新
// setFileList(list);
// let list: any = [...fileList, ...info.fileList];
// setFileList(list);
console.log(list);
// 将图片信息提交给state
// let data = { val: info.file.name, key: keys };
// dispatch({ type: module + '/retImgsList', data });
// 结束
} else if (info.file.status === 'error') {
message.error(`${info.file.name} file upload failed.`);
}
},
};
// 新增动作
const add = () => {
let list = FacilitysList;
let adds = {
id: '-1',
fileList: [],
name: '',
};
// 验证已添加的是否上传完整
let complete = list.every((item: any) => {
// return item.fileList.length > 0 && item.name !== '';
return item.fileList.length > 0;
});
if (list.length == 0 || complete) {
list.push(adds);
// 存储到mode里面去
dispatch({ type: module + '/genxin', list });
} else {
// 提示每一项都要填写完
message.error('Please fill out each item !');
}
};
//删除动作
const deleteImg = (key: any) => {
console.log(key);
let list = FacilitysList;
// list[key].name = '';
// 这里还要清除表单的值,否则再次新增输入框的值会重复出现
dumps(key);
list.splice(key, 1);
console.log(list);
// // 存储到mode里面去
dispatch({ type: module + '/genxin', list });
};
// 新增按钮
const uploadButton = (
<div>
<PlusOutlined />
<div className="ant-upload-text">Upload</div>
</div>
);
// 输入框内容
const monitor = (e: any) => {
let list = FacilitysList;
let { id, value } = e.target;
if (id == 'basic_shebei_0') {
id = 0;
}
list[id].name = value;
dispatch({ type: module + '/genxin', list });
};
return (
<>
<Form.Item name="picList" required={false} style={{ marginBottom: 0 }}>
{FacilitysList.map((item: any, index: any, keys: any) => {
console.log(item);
return (
<div className={'test'} key={item.id}>
<div className={'diybox'} key={item.id}>
<Upload
{...uploadProps}
fileList={
FacilitysList[index].fileList.length > 0 ? FacilitysList[index].fileList : false
}
// data={updata}
data={updetaTow(index)} // 携带数据
disabled={disabled} // 禁止
onPreview={handlePreview} // 预览
onRemove={() => {
deleteImg(index);
}} //移除
>
{FacilitysList[index].fileList.length > 0 ? null : uploadButton}
</Upload>
<div className={'Facility'} key={item.id}>
<Form.Item
label={`Facility Name ${index + 1}`}
name={'shebei_' + index}
rules={[{ required: true, message: 'Please input Facility Name!' }]}
>
<Input
placeholder="Facility Name"
disabled={disabled}
id={index}
onChange={(e: any) => monitor(e)}
value={FacilitysList[index].name}
/>
</Form.Item>
<div className={'over'}>
<Button type="link" disabled={disabled} onClick={() => deleteImg(index)}>
Delete
</Button>
</div>
</div>
</div>
</div>
);
})}
</Form.Item>
<Form.Item>
<Button
type="dashed"
onClick={() => add()}
style={{ width: '100px', height: '100px' }}
icon={<PlusOutlined />}
disabled={disabled}
></Button>
</Form.Item>
{/* 预览表格 */}
<Modal visible={previewVisible} title={previewTitle} footer={null} onCancel={handleCancel}>
<img alt="example" style={{ width: '100%' }} src={previewImage} />
</Modal>
</>
);
};
function mapStateToProps(state: any) {
const { FacilitysList } = state.FacilityBookings;
return {
FacilitysList,
};
}
export default connect(mapStateToProps)(Facilitys);
......@@ -50,13 +50,6 @@ const Facilitys = (props: any) => {
setpreviewVisible(true);
};
// 点击移除图片
const handRemove = (key: any) => {
// let list = fileList;
// 将图片信息提交给state
deleteImg(key);
};
// 点击遮罩回调
const handleCancel = () => {
setpreviewVisible(false);
......@@ -123,12 +116,13 @@ const Facilitys = (props: any) => {
};
//删除动作
const deleteImg = (key: any) => {
const deleteImg = (key: any, id: any) => {
let list = FacilitysList;
list[key].name = '';
// 这里还要清除表单的值,否则再次新增输入框的值会重复出现
dumps(key);
dumps(id);
list.splice(key, 1);
// 存储到mode里面去
......@@ -159,8 +153,8 @@ const Facilitys = (props: any) => {
<Form.Item name="picList" required={false} style={{ marginBottom: 0 }}>
{FacilitysList.map((item: any, index: any, key: any) => {
return (
<div className={'test'} key={'pic_' + index}>
<div className={'diybox'} key={'pic_' + index}>
<div className={'test'} key={item.id}>
<div className={'diybox'} key={item.id}>
<Upload
{...uploadProps}
fileList={
......@@ -171,16 +165,16 @@ const Facilitys = (props: any) => {
disabled={disabled} // 禁止
onPreview={handlePreview} // 预览
onRemove={() => {
handRemove(index);
deleteImg(index, item.id);
}} //移除
>
{FacilitysList[index].fileList.length > 0 ? null : uploadButton}
</Upload>
<div className={'Facility'} key={'pic_' + index}>
<div className={'Facility'} key={item.id}>
<Form.Item
label={`Facility Name ${index + 1}`}
name={'shebei_' + index}
name={'shebei_' + item.id}
rules={[{ required: true, message: 'Please input Facility Name!' }]}
>
<Input
......@@ -192,7 +186,11 @@ const Facilitys = (props: any) => {
/>
</Form.Item>
<div className={'over'}>
<Button type="link" disabled={disabled} onClick={() => deleteImg(index)}>
<Button
type="link"
disabled={disabled}
onClick={() => deleteImg(index, item.id)}
>
Delete
</Button>
</div>
......
......@@ -115,7 +115,7 @@ const PictureOptionsRow = (props: any) => {
}
return isJpgOrPng && isLt2M;
}
console.log(props);
// console.log(props);
return (
<div>
<Upload
......
......@@ -105,6 +105,11 @@ export default {
// yield put({ type: 'returnResult', Result });
}
break;
case 56: // 二级账号
{
localStorage.setItem('towAccount', JSON.stringify(resp.data));
}
break;
}
}
},
......
......@@ -110,8 +110,8 @@ const Account = (props: any) => {
},
{
title: 'Creation Time',
dataIndex: 'createTime',
key: 'createTime',
dataIndex: 'updateTime',
key: 'updateTime',
render: (text: any) => {
return moment(text).format('YYYY-MM-DD');
},
......
import React, { useState, useEffect, useRef } from 'react';
import { Form, Input, Button, message, Descriptions, Spin, Tree, Radio } from 'antd';
import { Form, Input, Button, message, Descriptions, Spin, Tree, Radio, Select } from 'antd';
import { connect, history } from 'umi';
import { EditOutlined, LeftOutlined } from '@ant-design/icons';
import { getCookie } from '@/utils/method';
import './Account.less';
import { zhCnFaci, enUsFaci } from '@/utils/power';
......@@ -27,11 +26,18 @@ const Account = (props: any) => {
// 单选 二级还是三级管理员
const [values, setvalues] = useState(2); // 树形菜单展开关闭
const [disab, setdisab] = useState(false); // 是否禁止选择二级
const [towAccountId, settowAccountId] = useState(null); // 二级账户id
// 表单标识
const [form] = Form.useForm();
const formRef = useRef(null);
const { Option } = Select;
//二级账户列表
const towAccount = JSON.parse(localStorage.getItem('towAccount') || '[]');
// 当前账户权限
useEffect(() => {
if (user != null) {
......@@ -57,6 +63,23 @@ const Account = (props: any) => {
}
}
}
// 当当前账户是二级以上禁用创建二级菜单
if (user.currentUser.userModel.tosUserLevel > 1) {
setvalues(3);
setdisab(true);
settowAccountId(user.currentUser.id);
// 如果是三级账户,禁用最后两个账户管理
if (user.currentUser.userModel.tosUserLevel == 3) {
// 禁用最后两个
_p[_p.length - 1].children[2].disableCheckbox = true;
_p[_p.length - 1].children[3].disableCheckbox = true;
}
} else {
// 如果是一级账户获取挂靠的二级账户名称
RA(56, {}, module, dispatch); // 权限上传
}
// 赋值改变
treeDatas[0].children = _p;
setCheckedKeys(treeDatas as any); // 可勾选列表
......@@ -101,12 +124,19 @@ const Account = (props: any) => {
// 账号长度
message.error('The Account Password is Greater Than 6 Digits!');
return false;
} else if (values == 3 && towAccountId == null) {
// 如果创建的是三级账号就要判断是否选择了绑定的二级账户
message.error('Please select affiliated account !');
return false;
} else {
value.tosUserServiceCellList = value.community.value; // 管辖小区
value.tosUserEmail = value.tosUserName; // 邮箱就是账号
value.tosUserLevel = values; //级别
value.creatorName = JSON.parse(userInfo).userModel.tosUserName; //新建者账号
value.creatorId = id; //新建者ID
if (values == 3) {
value.userLeader = towAccountId;
}
delete value.community;
// 判断有没有 0 有就删除
......@@ -177,6 +207,24 @@ const Account = (props: any) => {
//级别切换
const onRadio = (e: any) => {
setvalues(e.target.value);
// 如果是3级,取消后面两个选择
let treeDatas = treeData;
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 {
//否则打开
_p[_p.length - 1].children[2].disableCheckbox = false;
_p[_p.length - 1].children[3].disableCheckbox = false;
settowAccountId(null);
}
// 赋值改变
treeDatas[0].children = _p;
setCheckedKeys(treeDatas as any); // 可勾选列表
};
//手机号
......@@ -186,7 +234,21 @@ const Account = (props: any) => {
const keyup_tool = (value: any) => {
return getNumber(value.replace(/[^\d^\.]+/g, ''));
};
// 选择小区名字并赋值
// 二级账户
const listItems = towAccount.map((item: any) => {
return (
<Option key={item.id} value={item.id}>
{item.tosAccountName}-{item.tosUserEmail}
</Option>
);
});
// 选择哪个二级账号
const handleChange = (value: any) => {
console.log(`selected ${value}`);
settowAccountId(value);
};
return (
<Spin spinning={loading}>
......@@ -246,15 +308,27 @@ const Account = (props: any) => {
<span className="title">Privilege Level:</span>
</div>
<div className="label">
<Radio.Group defaultValue={values} onChange={onRadio}>
<Radio style={radioStyle} value={2}>
<Radio.Group value={values} onChange={onRadio}>
<Radio style={radioStyle} disabled={disab} value={2}>
Two Level Administrator
</Radio>
<Radio style={radioStyle} value={3}>
Three Level Administrator
{/* <Input placeholder="三级管理员" style={{ width: 160, marginLeft: 10 }} /> */}
</Radio>
</Radio.Group>
{/* 选择挂靠的二级菜单 */}
{values === 3 && user.currentUser.userModel.tosUserLevel <= 1 ? (
<Select
style={{ width: 260 }}
onChange={handleChange}
placeholder="Please select affiliated account"
>
{towAccount ? listItems : ''}
</Select>
) : (
''
)}
</div>
</div>
......
This diff is collapsed.
......@@ -135,11 +135,16 @@ const CardDetail = (props: any) => {
{listData.apply_status === 0 ? (
<Form ref={formRef} name="basic" onFinish={onFinish}>
<Row gutter={8} style={{ marginTop: 16 }}>
<Col span={3}>Examine:</Col>
<Col span={3}>Approval For Application:</Col>
<Col span={5}>
<Form.Item
name="applyStatus"
rules={[{ required: true, message: 'Please select the reply result!' }]}
rules={[
{
required: true,
message: 'Please choose Approve or Reject for the application!',
},
]}
>
<Radio.Group>
<Radio.Button value={'1'}>Approve</Radio.Button>
......
......@@ -136,7 +136,12 @@ const RenovationDetail = (props: any) => {
<Col>
<Form.Item
name="decorationStatus"
rules={[{ required: true, message: 'You have to choose an outcome!' }]}
rules={[
{
required: true,
message: 'Please choose Approve or Reject the application! ',
},
]}
>
<Radio.Group>
<Radio.Button value={'1'}>Approve</Radio.Button>{' '}
......
......@@ -45,6 +45,8 @@ const Facility = (props: any) => {
const [ctyName, setCtyName] = useState(null);
const [soltTime, setSoltTime] = useState(['', '']); // 已选时间
const [Cycle, setCycle] = useState(null as any); // Appointment Cycle下拉
// 表单标识
const [form] = Form.useForm();
......@@ -102,9 +104,14 @@ const Facility = (props: any) => {
setFileList(sourceData.categoriesDetailsImageName); //设置图片组名称
// delete sourceData.categoriesDetailsImageName;
setCycle(sourceData.periodType + '');
// delete sourceData.periodType;
// 设置表单默认值
formRef.current.setFieldsValue(sourceData);
console.log(Cycle);
} else {
// 新增页面进来 先清一遍 图片列表
let list: any = [];
......@@ -175,6 +182,8 @@ const Facility = (props: any) => {
result.categoriesOpenTime = `${soltTime[0]}-${soltTime[1]}`; // 预约时间段 二开需要
result.communityManagerFee = result.communityManagerFee ? result.communityManagerFee : '0.00'; // 价格押金没有为0
result.communityMargin = result.communityMargin ? result.communityMargin : '0.00'; // 价格押金没有为0
result.periodType = Cycle;
delete result.startTime;
delete result.endTime;
delete result.picList;
......@@ -216,6 +225,11 @@ const Facility = (props: any) => {
formRef.current.setFieldsValue(tmp);
};
//选择周期
function handleChange(value: any) {
setCycle(value);
}
// 选择小区名字并赋值
const opname = (value: any) => {
console.log('选择的小区是:' + value);
......@@ -455,12 +469,14 @@ const Facility = (props: any) => {
{/* 设置次数 */}
<Input.Group>
<Form.Item label="Appointment Cycle" name="periodType" rules={NewFaci[8]}>
<Form.Item label="Appointment Cycle" rules={NewFaci[8]}>
<Select
placeholder="Period"
allowClear
style={{ width: 120 }}
disabled={facilityDetail}
value={Cycle ? Cycle : ''}
onChange={handleChange}
>
<Option value="1">Week</Option>
<Option value="2">Month</Option>
......
......@@ -392,7 +392,7 @@ const FacilityBookings = (props: any) => {
};
function mapStateToProps(state: any) {
console.log(state);
// console.log(state);
const { Data, Data2, DataSave, curString, Result } = state.FacilityBookings;
const { token } = state.login;
const loading =
......
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