Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
TOSTUMI
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Maple
TOSTUMI
Commits
55a80bad
Commit
55a80bad
authored
Jan 25, 2021
by
cellee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复设施图片key值错误问题
Signed-off-by:
cellee
<
893264950@qq.com
>
parent
01a17551
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
10 deletions
+22
-10
Facilitys.tsx
src/components/Facilitys/Facilitys.tsx
+22
-10
No files found.
src/components/Facilitys/Facilitys.tsx
View file @
55a80bad
...
...
@@ -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
.
file
List
[
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
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment