Commit 5a33990a authored by cellee's avatar cellee

bug修复

Signed-off-by: cellee's avatarcellee <893264950@qq.com>
parent 19afdaad
......@@ -13,6 +13,7 @@ export default {
Result: null,
DataSave: null,
DataSaveDetail: null,
Permission: null,
},
reducers: {
......@@ -28,6 +29,9 @@ export default {
returnDataSaveDetail(state, { DataSaveDetail }) {
return { ...state, DataSaveDetail };
},
returnPermission(state, { Permission }) {
return { ...state, Permission };
},
},
effects: {
......@@ -81,7 +85,8 @@ export default {
break;
case 54: // 账号权限
{
console.log(resp.data);
let Permission = resp.data;
yield put({ type: 'returnPermission', Permission });
// let Result = resp.error_code;
// yield put({ type: 'returnResult', Result });
}
......
......@@ -27,24 +27,18 @@ import moment from 'moment';
const Account = (props: any) => {
const module = 'Account';
const { dispatch, Data, DataSave, DataSaveDetail, Result, loading, CommunityList } = props;
const { dispatch, Data, DataSave, DataSaveDetail, Result, loading, user } = props;
// 拉取数据的条件存储
const [term, setTerm] = useState({} as any);
// 小区列表
// const [comList, setCommunityList] = useState(CommunityList as any);
// // 数据
// useEffect(() => {
// if (CommunityList != null) {
// setCommunityList(CommunityList);
// }
// }, [CommunityList]);
// 权限列表
const treeData = enUsFaci || zhCnFaci;
const [expandedKeys, setExpandedKeys] = useState<string[]>([]); // 展开栏目
const [checkedKeys, setCheckedKeys] = useState<string[]>([]); // 默认已选栏目
const [checkedKeys, setCheckedKeys] = useState<string[]>([] as any); // 默认已选栏目
const [selectedKeys, setSelectedKeys] = useState<string[]>([]); // 设置选中的树节点
const [autoExpandParent, setAutoExpandParent] = useState<boolean>(true); // 树形菜单展开关闭
......@@ -55,6 +49,48 @@ const Account = (props: any) => {
const [form] = Form.useForm();
const formRef = useRef(null);
// 当前账户信息
useEffect(() => {
if (user != null) {
let treeDatas = treeData;
let _a = user.currentUser.permission; // 当前账户权限
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;
}
}
}
}
// 赋值改变
treeDatas[0].children = _p;
setCheckedKeys(treeDatas as any); // 可勾选列表
}
}, [user]);
function funs(arr: any, val: any) {
console.log(val);
console.log(arr.key);
console.log('-------');
if (arr.key == val) {
return true;
} else {
return false;
}
}
// 保存提交
const onFinishContract = async (value: any) => {
// console.log(value);
......@@ -110,7 +146,7 @@ const Account = (props: any) => {
// 点击单个触发
const onCheck = (checkedKeys: any) => {
console.log('onCheck', checkedKeys);
// console.log('onCheck', checkedKeys);
setCheckedKeys(checkedKeys);
};
......@@ -250,6 +286,7 @@ const AccountProps = (state: any) => {
const { Data, DataSave, DataSaveDetail, Result } = state.Account;
const { CommunityList } = state.Init; // 小区列表
const loading = state.loading.models.Account || false;
const { user } = state;
return {
Data,
DataSave,
......@@ -257,6 +294,7 @@ const AccountProps = (state: any) => {
Result,
loading,
CommunityList,
user, // 获取当前账户信息
};
};
......
import React, { useState, useEffect, useRef } from 'react';
import {
Form,
Input,
Button,
Pagination,
message,
Descriptions,
Checkbox,
Tree,
Radio,
} from 'antd';
import { Form, Input, Button, Spin, 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';
......@@ -27,7 +17,7 @@ import moment from 'moment';
const Account = (props: any) => {
const module = 'Account';
const { dispatch, Data, DataSave, DataSaveDetail, Result, loading, CommunityList } = props;
const { dispatch, Data, DataSave, DataSaveDetail, Result, loading, Permission, user } = props;
// 权限列表
const treeData = enUsFaci || zhCnFaci;
......@@ -69,8 +59,57 @@ const Account = (props: any) => {
// 发起获取权限请求
RA(54, { tosUserName: DataSave.tosUserName }, module, dispatch); // 发起获取权限请求
}
let a = [];
for (var i = 0; i <= 66; i++) {
a.push(i);
}
console.log(a);
}, [DataSave]);
// 当前账户权限
useEffect(() => {
if (user != null) {
let treeDatas = treeData;
let _a = user.currentUser.permission; // 当前账户权限
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;
}
}
}
}
// 赋值改变
treeDatas[0].children = _p;
setCheckedKeys(treeDatas as any); // 可勾选列表
}
}, [user]);
// 已选权限
useEffect(() => {
if (Permission != null) {
let newPer = eval('(' + Permission + ')');
let data: any = [];
for (let i in newPer) {
data[i] = newPer[i] + '';
}
setCheckedKeys(data);
}
}, [Permission]);
// 保存提交
const onFinishContract = async (value: any) => {
// console.log(value);
......@@ -159,7 +198,7 @@ const Account = (props: any) => {
// 选择小区名字并赋值
return (
<>
<Spin spinning={loading}>
<div className="contop" style={{ padding: '12px 20px' }}>
<h3 className="capi">
<EditOutlined />
......@@ -258,21 +297,22 @@ const Account = (props: any) => {
</div>
</Form>
</div>
</>
</Spin>
);
};
const AccountProps = (state: any) => {
const { Data, DataSave, DataSaveDetail, Result } = state.Account;
const { CommunityList } = state.Init; // 小区列表
const { Data, DataSave, DataSaveDetail, Result, Permission } = state.Account;
const loading = state.loading.models.Account || false;
const { user } = state;
return {
Data,
DataSave,
DataSaveDetail,
Result,
loading,
CommunityList,
Permission,
user,
};
};
......
......@@ -12,7 +12,7 @@ import {
Spin,
Image,
} from 'antd';
import { PlusOutlined, LeftOutlined } from '@ant-design/icons';
import { PlusOutlined, LeftOutlined, LoadingOutlined } from '@ant-design/icons';
import { Link, useIntl, connect, Dispatch, Loading } from 'umi';
import { RA } from '@/services/tos';
......@@ -61,6 +61,8 @@ const ContractContent = (props: any) => {
const [imgInfo, setimgInfo] = useState(null as any); //本地图片预览
const [previewVisible, setPreviewVisible] = useState(false); //本地图片预览弹窗
const [imgLoad, setimgLoad] = useState(false); //本地图片预览
useEffect(() => {
// 如果是添加传来没有值的时候 就清空 否则 赋值给表单
if (DataSaveDetail == null) {
......@@ -166,13 +168,17 @@ const ContractContent = (props: any) => {
data: { imageType: 'tosContract', extends: comtyName },
fileList: fileList,
onChange: ({ file, fileList }: { file: any; fileList: any }) => {
if (file.status === 'uploading') {
setimgLoad(true);
}
if (file.status == 'done') {
message.success(file.name, 3);
message.success(file.name);
setFileList(fileList);
// 添加到表单
form.setFieldsValue({
upload: 'ok',
});
setimgLoad(false);
}
},
};
......@@ -184,7 +190,6 @@ const ContractContent = (props: any) => {
let a2 = moment(data[1]).subtract(1, 'month').format('YYYY-MM-DD');
setTipTime([a1, a2]);
}
console.log(dateStrings);
};
// 选择小区名字并赋值
......@@ -264,6 +269,27 @@ const ContractContent = (props: any) => {
return isJpgOrPng && isLt2M;
}
// 移除文件
const onRemove = async (file: any) => {
console.log('点击');
let fileListArr = fileList;
for (let i in fileListArr) {
if (fileListArr[i].uid == file.uid) {
fileListArr.splice(i, 1);
}
}
console.log(fileListArr);
setFileList([...fileListArr]);
};
// 文件上传按钮
const uploadButton = (
<div>
{imgLoad ? <LoadingOutlined /> : <PlusOutlined />}
<div style={{ marginTop: 5 }}>Upload</div>
</div>
);
return (
<>
<Spin spinning={loading}>
......@@ -378,8 +404,9 @@ const ContractContent = (props: any) => {
disabled={uploadUp}
beforeUpload={beforeUpload}
onPreview={onPreviews}
onRemove={onRemove}
>
{fileList.length >= 3 ? null : <PlusOutlined />}
{fileList.length >= 3 ? null : uploadButton}
</Upload>
</Form.Item>
</div>
......
This diff is collapsed.
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