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