Commit 1890b26c authored by cellee's avatar cellee

修复bug

Signed-off-by: cellee's avatarcellee <893264950@qq.com>
parent 9ec4b3bf
...@@ -3,6 +3,8 @@ import React, { useState, useEffect } from 'react'; ...@@ -3,6 +3,8 @@ import React, { useState, useEffect } from 'react';
import { Upload, Modal, message } from 'antd'; import { Upload, Modal, message } from 'antd';
import { PlusOutlined, LoadingOutlined } from '@ant-design/icons'; import { PlusOutlined, LoadingOutlined } from '@ant-design/icons';
import { randomString } from '@/utils/string';
function getBase64(file: File) { function getBase64(file: File) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const reader = new FileReader(); const reader = new FileReader();
...@@ -14,7 +16,7 @@ function getBase64(file: File) { ...@@ -14,7 +16,7 @@ function getBase64(file: File) {
import { getUrlPicName } from '../../utils/string'; import { getUrlPicName } from '../../utils/string';
const PictureOptionsRow = (props: any) => { const PictureOptionsRow = (props: any) => {
const { value, onChange, limitNums } = props; const { value, onChange, limitNums, defaultValue } = props;
const [fileList, setFileList] = useState([] as any); const [fileList, setFileList] = useState([] as any);
const [previewVisible, setPreviewVisible] = useState(false); const [previewVisible, setPreviewVisible] = useState(false);
const [previewImage, setPreviewImage] = useState(''); const [previewImage, setPreviewImage] = useState('');
...@@ -36,10 +38,11 @@ const PictureOptionsRow = (props: any) => { ...@@ -36,10 +38,11 @@ const PictureOptionsRow = (props: any) => {
var resultToInside = new Array(); var resultToInside = new Array();
if (tmp.length > 0 && typeof tmp[0] != 'string') { if (tmp.length > 0 && typeof tmp[0] != 'string') {
//输入输出 //输入输出
tmp.map((item: any, index: any) => { tmp.map((item: any) => {
if (item.name == null) { if (item.name == null) {
item.name = getUrlPicName(item.url); item.name = getUrlPicName(item.url);
item.uid = index; item.uid = randomString(8);
item.status = 'done';
} }
result.push(item); result.push(item);
resultToInside.push(item.name); resultToInside.push(item.name);
...@@ -52,23 +55,24 @@ const PictureOptionsRow = (props: any) => { ...@@ -52,23 +55,24 @@ const PictureOptionsRow = (props: any) => {
useEffect(() => { useEffect(() => {
// if (props.disabled) { // if (props.disabled) {
if (props.defaultValue != null) { if (defaultValue != null) {
var tmp = props.defaultValue; var tmp = defaultValue;
var result = new Array(); var result = new Array();
var resultToInside = new Array(); var resultToInside = new Array();
tmp.map((item: any) => {
tmp.map((item: any, index: any) => {
if (item.name == null) { if (item.name == null) {
item.name = getUrlPicName(item.url); item.name = getUrlPicName(item.url);
item.uid = index; item.uid = randomString(8);
item.status = 'done';
} }
result.push(item); result.push(item);
resultToInside.push(item.name); resultToInside.push(item.name);
}); });
setFileList(result); setFileList(result);
onChange(resultToInside);
} }
// } // }
}, [props.defaultValue]); }, [defaultValue]);
// 加载logo // 加载logo
const uploadButton = ( const uploadButton = (
...@@ -104,12 +108,26 @@ const PictureOptionsRow = (props: any) => { ...@@ -104,12 +108,26 @@ const PictureOptionsRow = (props: any) => {
onChange(result); onChange(result);
} }
}; };
// 移除
const onRemove = (file: any) => {
let list = fileList;
for (let i in list) {
if (list[i].uid == file.uid) {
list.splice(i, 1);
}
}
setFileList([...list]);
onChange([...list]);
};
// 提交前限制
function beforeUpload(file: any) { function beforeUpload(file: any) {
// 文件类型判断 // 文件类型判断
const isJpgOrPng = const isJpgOrPng =
file.type === 'image/jpeg' || file.type === 'image/png' || file.type === 'image/jpg'; file.type === 'image/jpeg' || file.type === 'image/png' || file.type === 'image/jpg';
if (!isJpgOrPng) { if (!isJpgOrPng) {
message.error('You can only upload JPG/PNG file!'); message.error('You can only upload JPG/PNG/Jpeg file!');
} }
const isLt2M = file.size / 1024 / 1024 < 2; const isLt2M = file.size / 1024 / 1024 < 2;
if (!isLt2M) { if (!isLt2M) {
...@@ -126,9 +144,10 @@ const PictureOptionsRow = (props: any) => { ...@@ -126,9 +144,10 @@ const PictureOptionsRow = (props: any) => {
listType="picture-card" listType="picture-card"
data={props.data} data={props.data}
fileList={fileList} fileList={fileList}
onPreview={handlePreview} onPreview={handlePreview} // 预览
onRemove={onRemove} // 删除
beforeUpload={beforeUpload} beforeUpload={beforeUpload}
onChange={handleChange} onChange={handleChange} // 点击上传
disabled={props.over} disabled={props.over}
> >
{fileList.length >= limitNum ? null : props.disabled ? null : uploadButton} {fileList.length >= limitNum ? null : props.disabled ? null : uploadButton}
......
...@@ -80,17 +80,6 @@ const Account = (props: any) => { ...@@ -80,17 +80,6 @@ const Account = (props: any) => {
} }
}, [user]); }, [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) => { const onFinishContract = async (value: any) => {
// console.log(value); // console.log(value);
...@@ -143,9 +132,6 @@ const Account = (props: any) => { ...@@ -143,9 +132,6 @@ const Account = (props: any) => {
history.go(-1); history.go(-1);
}; };
// 全选
const onCheckAllChange = (e: any) => {};
// 展开/收起树形菜单触发 // 展开/收起树形菜单触发
const onExpand = (expandedKeys: any) => { const onExpand = (expandedKeys: any) => {
setExpandedKeys(expandedKeys); setExpandedKeys(expandedKeys);
......
...@@ -24,7 +24,7 @@ const Account = (props: any) => { ...@@ -24,7 +24,7 @@ const Account = (props: any) => {
// 权限列表 // 权限列表
const treeData = enUsFaci || zhCnFaci; const treeData = enUsFaci || zhCnFaci;
const [expandedKeys, setExpandedKeys] = useState<string[]>(['0']); // 展开栏目 const [expandedKeys, setExpandedKeys] = useState<string[]>([]); // 展开栏目
const [checkedKeys, setCheckedKeys] = useState<string[]>([]); // 默认已选栏目 const [checkedKeys, setCheckedKeys] = useState<string[]>([]); // 默认已选栏目
const [selectedKeys, setSelectedKeys] = useState<string[]>([]); // 设置选中的树节点 const [selectedKeys, setSelectedKeys] = useState<string[]>([]); // 设置选中的树节点
const [autoExpandParent, setAutoExpandParent] = useState<boolean>(true); // 树形菜单展开关闭 const [autoExpandParent, setAutoExpandParent] = useState<boolean>(true); // 树形菜单展开关闭
...@@ -32,9 +32,6 @@ const Account = (props: any) => { ...@@ -32,9 +32,6 @@ const Account = (props: any) => {
// 单选 二级还是三级管理员 // 单选 二级还是三级管理员
const [values, setvalues] = useState(2); // 树形菜单展开关闭 const [values, setvalues] = useState(2); // 树形菜单展开关闭
// 已选小区
const [ServiceCell, setServiceCell] = useState(null as any);
const [over, setOver] = useState(false); // 关闭账号确认弹窗 const [over, setOver] = useState(false); // 关闭账号确认弹窗
const [accountName, setaccountName] = useState(null as any); // 弹窗账号信息 const [accountName, setaccountName] = useState(null as any); // 弹窗账号信息
...@@ -42,15 +39,10 @@ const Account = (props: any) => { ...@@ -42,15 +39,10 @@ const Account = (props: any) => {
const [form] = Form.useForm(); const [form] = Form.useForm();
const formRef = useRef(null); const formRef = useRef(null);
// 拉取数据的条件存储
// const [term, setTerm] = useState({} as any);
// 小区列表
// const [comList, setCommunityList] = useState(CommunityList as any);
// // 数据 // // 数据
useEffect(() => { useEffect(() => {
if (DataSave != null) { if (DataSave != null) {
console.log(DataSave); console.log(DataSave.tosUserLevel);
// 赋值 // 赋值
form.setFieldsValue({ form.setFieldsValue({
tosUserName: DataSave.tosUserName, tosUserName: DataSave.tosUserName,
...@@ -59,17 +51,10 @@ const Account = (props: any) => { ...@@ -59,17 +51,10 @@ const Account = (props: any) => {
}); });
setvalues(DataSave.tosUserLevel); // 等级 setvalues(DataSave.tosUserLevel); // 等级
setServiceCell(DataSave.tosUserServiceCell.split(',')); // 已选小区
// 发起获取权限请求 // 发起获取权限请求
RA(54, { tosUserName: DataSave.tosUserName }, module, dispatch); // 发起获取权限请求 RA(54, { tosUserName: DataSave.tosUserName }, module, dispatch); // 发起获取权限请求
} }
let a = [];
for (var i = 0; i <= 66; i++) {
a.push(i);
}
console.log(a);
}, [DataSave]); }, [DataSave]);
// 当前账户权限 // 当前账户权限
...@@ -159,9 +144,6 @@ const Account = (props: any) => { ...@@ -159,9 +144,6 @@ const Account = (props: any) => {
history.go(-1); history.go(-1);
}; };
// 全选
const onCheckAllChange = (e: any) => {};
// 展开/收起树形菜单触发 // 展开/收起树形菜单触发
const onExpand = (expandedKeys: any) => { const onExpand = (expandedKeys: any) => {
setExpandedKeys(expandedKeys); setExpandedKeys(expandedKeys);
...@@ -170,13 +152,11 @@ const Account = (props: any) => { ...@@ -170,13 +152,11 @@ const Account = (props: any) => {
// 点击单个触发 // 点击单个触发
const onCheck = (checkedKeys: any) => { const onCheck = (checkedKeys: any) => {
console.log('onCheck', checkedKeys);
setCheckedKeys(checkedKeys); setCheckedKeys(checkedKeys);
}; };
// 点击树节点触发 - 大栏目 // 点击树节点触发 - 大栏目
const onSelect = (selectedKeys: any, info: any) => { const onSelect = (selectedKeys: any, info: any) => {
console.log('onSelect', info);
setSelectedKeys(selectedKeys); setSelectedKeys(selectedKeys);
}; };
...@@ -309,7 +289,7 @@ const Account = (props: any) => { ...@@ -309,7 +289,7 @@ 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={values} onChange={onRadio} disabled> <Radio.Group defaultValue={DataSave.tosUserLevel} onChange={onRadio} disabled>
<Radio style={radioStyle} value={2}> <Radio style={radioStyle} value={2}>
Two Level Administrator Two Level Administrator
</Radio> </Radio>
......
...@@ -34,15 +34,9 @@ const Account = (props: any) => { ...@@ -34,15 +34,9 @@ const Account = (props: any) => {
const [form] = Form.useForm(); const [form] = Form.useForm();
const formRef = useRef(null); const formRef = useRef(null);
// 拉取数据的条件存储
// const [term, setTerm] = useState({} as any);
// 小区列表
// const [comList, setCommunityList] = useState(CommunityList as any);
// // 数据 // // 数据
useEffect(() => { useEffect(() => {
if (DataSave != null) { if (DataSave != null) {
console.log(DataSave);
// 赋值 // 赋值
form.setFieldsValue({ form.setFieldsValue({
tosUserName: DataSave.tosUserName, tosUserName: DataSave.tosUserName,
...@@ -56,11 +50,11 @@ const Account = (props: any) => { ...@@ -56,11 +50,11 @@ const Account = (props: any) => {
RA(54, { tosUserName: DataSave.tosUserName }, module, dispatch); // 发起获取权限请求 RA(54, { tosUserName: DataSave.tosUserName }, module, dispatch); // 发起获取权限请求
} }
let a = []; // let a = [];
for (var i = 0; i <= 66; i++) { // for (var i = 0; i <= 66; i++) {
a.push(i); // a.push(i);
} // }
console.log(a); // console.log(a);
}, [DataSave]); }, [DataSave]);
// 当前账户权限 // 当前账户权限
......
...@@ -6,18 +6,15 @@ import { connect, history } from 'umi'; ...@@ -6,18 +6,15 @@ import { connect, history } from 'umi';
import { RA, SA } from '@/utils/method'; import { RA, SA } from '@/utils/method';
import TitleBack from '@/components/TitleBack/TitleBack'; import TitleBack from '@/components/TitleBack/TitleBack';
// import FileUpload from '@/components/FileUpload/FileUpload';
import { validateMessages } from '@/utils/params'; import { validateMessages } from '@/utils/params';
import PictureOptionsRow from '@/components/PictureOptions/PictureOptionsRow'; import PictureOptionsRow from '@/components/PictureOptions/PictureOptionsRow';
import TextArea from 'antd/lib/input/TextArea'; import TextArea from 'antd/lib/input/TextArea';
import SelectCommunity from '@/components/SelectCommunity'; import SelectCommunity from '@/components/SelectCommunity';
// import Line from '@/components/Line/Line';
// import TimeComfirm from '@/components/TimeComfirm/TimeComfirm';
import imgs from '@/assets/logo_icon_bg.png';
import './ann.less'; import './ann.less';
import { Notice } from '@/utils/tip'; import { Notice } from '@/utils/tip';
import { getCookie } from '@/utils/method'; import { getCookie } from '@/utils/method';
import moment from 'moment'; import moment from 'moment';
import { randomString } from '@/utils/string';
const module = 'CommunityAnnouncement'; const module = 'CommunityAnnouncement';
...@@ -61,10 +58,10 @@ const Add = (props: any) => { ...@@ -61,10 +58,10 @@ const Add = (props: any) => {
// 监听图片状态 ImgSrc // 监听图片状态 ImgSrc
useEffect(() => { useEffect(() => {
if (ImgSrc != null) { if (ImgSrc != null) {
let a = ImgSrc.map((item: any, index: number) => { let a = ImgSrc.map((item: any) => {
let key = Object.keys(item)[0]; let key = Object.keys(item)[0];
return { return {
uid: index, uid: randomString(8),
name: key, name: key,
status: 'done', status: 'done',
url: item[key], url: item[key],
......
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