Commit 55a80bad authored by cellee's avatar cellee

修复设施图片key值错误问题

Signed-off-by: cellee's avatarcellee <893264950@qq.com>
parent 01a17551
......@@ -27,11 +27,16 @@ const Facilitys = (props: any) => {
const [previewTitle, setpreviewTitle] = useState('');
// 图片地址
const [previewImage, setpreviewImage] = useState('');
//
// 默认Id
const [idKey, setidKey] = useState(10001);
// 当前操作的Id
const [idPush, setidPush] = useState(null as any);
// 传递给后台加 key
const updetaTow = (key: any) => {
console.log(key);
setidPush(key);
let data = updata;
data.identification = key;
return data;
......@@ -58,28 +63,29 @@ const Facilitys = (props: any) => {
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`);
// 后台返回的内容
let data = info.file.response.data;
// 拿到key 值 开始存储
let key = parseInt(info.fileList[0].response.data.identification);
let key = parseInt(data.identification);
// 重命名图片的名称
info.fileList[0].name = info.file.response.data.imageName;
info.file.name = data.imageName;
let list = FacilitysList;
setidKey(idKey + 1);
list[key] = {
id: idKey,
name: FacilitysList[key].name,
fileList: info.fileList,
fileList: [info.file],
disabled: false,
};
// 存储到mode里面去
dispatch({ type: module + '/genxin', list });
console.log(list);
// 清除操作ID
setidPush(null);
} else if (info.file.status === 'error') {
message.error(`${info.file.name} file upload failed.`);
}
......@@ -117,9 +123,9 @@ const Facilitys = (props: any) => {
//删除动作
const deleteImg = (key: any, id: any) => {
// console.log(key);
let list = FacilitysList;
list[key].name = '';
// list[key].name = '';
list.splice(key, 1);
// 存储到mode里面去
dispatch({ type: module + '/genxin', list });
......@@ -150,6 +156,11 @@ const Facilitys = (props: any) => {
dispatch({ type: module + '/genxin', list });
};
//点击新增按钮
const handleChange = (a) => {
console.log(a);
};
return (
<>
<Form.Item name="picList" required={false} style={{ marginBottom: 0 }}>
......@@ -166,12 +177,13 @@ const Facilitys = (props: any) => {
: false
}
// data={updata}
data={updetaTow(index)} // 携带数据
data={() => updetaTow(index)} // 携带数据
disabled={disabled} // 禁止
onPreview={handlePreview} // 预览
onRemove={() => {
deleteImgs(index, item.id);
}} //移除
// onChange={handleChange} // 点击确认
>
{FacilitysList[index].fileList.length > 0 ? null : uploadButton}
</Upload>
......
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