Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
submodule
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
web_component
submodule
Commits
7493438e
Commit
7493438e
authored
Sep 10, 2020
by
zhangwenshuai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update upload
parent
49acd331
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
79 deletions
+32
-79
styles.less
...ents/apolloTable/component/base/detail/upload/styles.less
+1
-0
index.less
components/apolloTable/component/base/edit/upload/index.less
+2
-0
index.tsx
components/apolloTable/component/base/edit/upload/index.tsx
+29
-79
No files found.
components/apolloTable/component/base/detail/upload/styles.less
View file @
7493438e
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
display: flex;
display: flex;
vertical-align: middle;
vertical-align: middle;
align-items: center;
align-items: center;
user-select: none;
}
}
.moreBtn {
.moreBtn {
...
...
components/apolloTable/component/base/edit/upload/index.less
View file @
7493438e
...
@@ -7,6 +7,8 @@
...
@@ -7,6 +7,8 @@
align-items: center;
align-items: center;
border: 1px solid @primaryColor;
border: 1px solid @primaryColor;
min-height: 32px;
min-height: 32px;
padding: 0 @paddingLg;
user-select: none;
&.disabled {
&.disabled {
background: @disabledColor;
background: @disabledColor;
border-color: #d9d9d9;
border-color: #d9d9d9;
...
...
components/apolloTable/component/base/edit/upload/index.tsx
View file @
7493438e
import
React
,
{
useEffect
,
use
Ref
,
use
State
}
from
'react'
;
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
{
Modal
,
Tooltip
,
Button
,
Icon
}
from
'antd'
;
import
{
Modal
}
from
'antd'
;
import
classNames
from
'classnames'
;
import
classNames
from
'classnames'
;
import
{
ApolloUploadProps
}
from
'../editInterface'
;
import
{
ApolloUploadProps
}
from
'../editInterface'
;
import
{
antiAssign
}
from
'../../../../utils/utils'
;
import
{
antiAssign
}
from
'../../../../utils/utils'
;
import
s
from
'./index.less'
;
import
{
onBlurFn
}
from
'../onBlurFn'
;
import
Upload
from
'../../extra/upload'
;
import
Upload
from
'../../extra/upload'
;
import
s
from
'./index.less'
;
export
const
ApolloUpload
=
(
props
:
ApolloUploadProps
)
=>
{
export
const
ApolloUpload
=
(
props
:
ApolloUploadProps
)
=>
{
const
{
const
{
isMultiple
,
onEmitChange
,
onChange
,
disabled
,
origin
,
value
}
=
props
;
isMultiple
,
onEmitChange
,
onChange
,
disabled
,
origin
,
tableId
,
}
=
props
;
const
selfProps
=
antiAssign
(
props
,
[
const
selfProps
=
antiAssign
(
props
,
[
'onChange'
,
'onChange'
,
'value'
,
'value'
,
...
@@ -25,7 +22,6 @@ export const ApolloUpload = (props: ApolloUploadProps) => {
...
@@ -25,7 +22,6 @@ export const ApolloUpload = (props: ApolloUploadProps) => {
'origin'
,
'origin'
,
'disableOptions'
,
'disableOptions'
,
'rowId'
,
'rowId'
,
'onBlurFn'
,
'getInstanceDetail'
,
'getInstanceDetail'
,
]);
]);
selfProps
.
disabled
=
!!
props
.
disabled
;
selfProps
.
disabled
=
!!
props
.
disabled
;
...
@@ -35,75 +31,35 @@ export const ApolloUpload = (props: ApolloUploadProps) => {
...
@@ -35,75 +31,35 @@ export const ApolloUpload = (props: ApolloUploadProps) => {
selfProps
.
multiple
=
false
;
selfProps
.
multiple
=
false
;
selfProps
.
maxLength
=
1
;
selfProps
.
maxLength
=
1
;
}
}
const
[
value
,
setValue
]
=
useState
<
any
>
([]);
const
[
curValue
,
setCurValue
]
=
useState
<
any
>
(
value
);
useEffect
(()
=>
{
setValue
(
props
.
value
);
},
[
props
.
value
]);
const
changeValue
=
(
value
:
any
)
=>
{
const
changeValue
=
(
value
:
any
)
=>
{
setValue
(
value
);
setCurValue
(
value
);
if
(
origin
===
'editForm'
)
{
if
(
typeof
onChange
===
'function'
)
{
if
(
typeof
onChange
===
'function'
)
{
onChange
(
value
);
onChange
(
value
);
}
// onBlurFn({ ...props, value });
}
};
const
[
visible
,
setVisible
]
=
useState
(
false
);
const
refHelper
=
useRef
(
visible
);
const
toggleUploadDialog
=
(
flag
:
boolean
)
=>
{
refHelper
.
current
=
flag
;
setVisible
(
flag
);
};
// 点击Modal中上传时回调用浏览器弹框,触发onBlur,而此时并不希望触发onBlur,因此在组件内自定义监听
// useEffect(() => {
// document.addEventListener('click', onBlur, false);
// if (origin !== 'editForm') {
// toggleUploadDialog(true);
// }
// return () => {
// document.removeEventListener('click', onBlur, false);
// };
// }, []);
const
clearEdit
=
()
=>
{
// 清除所有dom的编辑状态
const
doms
=
document
.
querySelectorAll
(
`.cellUnit.table_
${
tableId
}
`
);
if
(
doms
)
{
doms
.
forEach
((
item
)
=>
{
item
.
setAttribute
(
'data-editing-cell'
,
'0'
);
});
}
};
const
onBlur
=
()
=>
{
// 当弹框显示时,不触发emit事件
if
(
refHelper
.
current
)
{
return
;
}
}
if
(
typeof
onEmitChange
===
'function
'
)
{
if
(
origin
===
'editForm
'
)
{
on
EmitChange
(
props
.
value
);
on
Blur
(
value
);
}
}
clearEdit
();
};
};
const
on
Ok
=
(
)
=>
{
const
on
Blur
=
(
value
:
any
)
=>
{
if
(
typeof
onEmitChange
===
'function'
)
{
if
(
typeof
onEmitChange
===
'function'
)
{
onEmitChange
(
value
);
onEmitChange
(
value
);
}
}
if
(
typeof
onChange
===
'function'
)
{
onChange
(
value
);
}
clearEdit
();
toggleUploadDialog
(
false
);
};
};
const
onCancel
=
()
=>
{
const
[
visible
,
setVisible
]
=
useState
(
false
);
if
(
typeof
onEmitChange
===
'function'
)
{
// 点击Modal中上传时回调用浏览器弹框,触发onBlur,而此时并不希望触发onBlur,因此在组件内自定义监听
onEmitChange
(
props
.
value
);
useEffect
(()
=>
{
if
(
origin
!==
'editForm'
)
{
setVisible
(
true
);
}
}
clearEdit
();
},
[]);
toggleUploadDialog
(
false
);
const
onOk
=
()
=>
{
onBlur
(
curValue
);
setVisible
(
false
);
};
};
const
onC
lickContainer
=
(
e
:
any
)
=>
{
const
onC
ancel
=
(
)
=>
{
e
.
stopPropagation
();
// 阻止事件冒泡
onBlur
(
value
);
e
.
nativeEvent
.
stopImmediatePropagation
(
);
setVisible
(
false
);
};
};
let
containerClass
=
s
.
container
;
let
containerClass
=
s
.
container
;
if
(
disabled
)
{
if
(
disabled
)
{
...
@@ -113,29 +69,23 @@ export const ApolloUpload = (props: ApolloUploadProps) => {
...
@@ -113,29 +69,23 @@ export const ApolloUpload = (props: ApolloUploadProps) => {
containerClass
=
classNames
(
containerClass
,
s
.
editForm
);
containerClass
=
classNames
(
containerClass
,
s
.
editForm
);
return
(
return
(
<
div
className=
{
containerClass
}
>
<
div
className=
{
containerClass
}
>
<
Upload
{
...
selfProps
}
value=
{
v
alue
}
listType=
"picture-card"
onChange=
{
changeValue
}
/>
<
Upload
{
...
selfProps
}
value=
{
curV
alue
}
listType=
"picture-card"
onChange=
{
changeValue
}
/>
</
div
>
</
div
>
);
);
}
}
return
(
return
(
<
div
className=
{
containerClass
}
onClick=
{
onClickContainer
}
>
<
div
className=
{
containerClass
}
>
{
value
{
curValue
&&
&&
v
alue
.
map
((
item
:
any
,
i
:
number
)
=>
{
curV
alue
.
map
((
item
:
any
,
i
:
number
)
=>
{
return
(
return
(
<
div
key=
{
i
}
className=
{
s
.
picContainer
}
>
<
div
key=
{
i
}
className=
{
s
.
picContainer
}
>
<
Tooltip
placement=
"bottom"
title=
{
item
.
name
}
>
<
img
alt=
""
className=
{
s
.
pic
}
src=
{
item
.
thumbUrl
}
/>
<
img
alt=
""
className=
{
origin
===
'editForm'
?
classNames
(
s
.
pic
,
s
.
editForm
)
:
s
.
pic
}
src=
{
item
.
thumbUrl
}
/>
</
Tooltip
>
</
div
>
</
div
>
);
);
})
}
})
}
<
Modal
visible=
{
visible
}
title=
"文件上传"
onOk=
{
onOk
}
onCancel=
{
onCancel
}
>
<
Modal
visible=
{
visible
}
title=
"文件上传"
onOk=
{
onOk
}
onCancel=
{
onCancel
}
>
<
div
className=
{
s
.
uploadContainer
}
>
<
div
className=
{
s
.
uploadContainer
}
>
<
Upload
{
...
selfProps
}
value=
{
props
.
v
alue
}
onChange=
{
changeValue
}
/>
<
Upload
{
...
selfProps
}
value=
{
curV
alue
}
onChange=
{
changeValue
}
/>
</
div
>
</
div
>
</
Modal
>
</
Modal
>
</
div
>
</
div
>
...
...
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