Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
H
H5Public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
CI / CD
CI / CD
流水线
作业
日程
统计图
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
前端开发小组
H5Public
Commits
52bde14c
提交
52bde14c
authored
12月 20, 2024
作者:
钟是志
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
http://scjoyedu.eicp.net:57400/zentao/task-view-4340.html
http://scjoyedu.eicp.net:57400/zentao/task-view-4385.html
上级
ee72e570
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
59 行增加
和
27 行删除
+59
-27
DiyUploadOneStopFile.js
baseComponents/FormArray/DiyUploadOneStopFile.js
+35
-21
index.js
baseComponents/FormArray/index.js
+5
-6
requestJSON.js
utils/requestJSON.js
+19
-0
没有找到文件。
baseComponents/FormArray/DiyUploadOneStopFile.js
浏览文件 @
52bde14c
...
...
@@ -2,13 +2,21 @@ import React, { useRef, useState, useEffect } from 'react';
import
{
List
,
Switch
,
Button
,
Toast
,
Icon
}
from
'antd-mobile'
;
import
styles
from
'./styles.less'
;
import
{
uploadOnestopFile
}
from
'@/H5Public/baseComponents/UploadFile/api'
;
import
systemConfig
from
'@/config/config'
;
const
Brief
=
List
.
Item
.
Brief
;
export
default
function
DiyUploadOneStopFile
(
props
)
{
const
{
config
,
formValue
=
[],
giveRequiredName
,
changeValue
}
=
props
;
const
{
readOnly
}
=
config
;
const
[
files
,
setFiles
]
=
useState
([]);
const
inputRef
=
useRef
(
null
);
useEffect
(()
=>
{
if
(
formValue
[
config
.
key
]
&&
Array
.
isArray
(
formValue
[
config
.
key
])){
setFiles
(
formValue
[
config
.
key
]);
}
},
[
readOnly
,
formValue
]);
const
uploadImage
=
()
=>
{
Toast
.
loading
(
'文件上传中'
,
1
);
const
domF
=
inputRef
.
current
.
files
;
...
...
@@ -36,13 +44,13 @@ export default function DiyUploadOneStopFile(props) {
};
useEffect
(()
=>
{
changeValue
(
files
,
config
.
key
);
changeValue
(
files
,
config
.
key
);
},
[
files
]);
const
deleteItem
=
(
data
)
=>
{
setFiles
((
files
)
=>
{
return
files
.
filter
((
item
)
=>
{
return
item
.
path
!==
data
.
path
;
return
item
.
path
!==
data
.
path
;
});
});
};
...
...
@@ -53,29 +61,35 @@ export default function DiyUploadOneStopFile(props) {
className
=
{
styles
.
diyStyle
}
>
{
giveRequiredName
(
config
)}
<
Brief
>
支持格式:
xls
、
xlsx
、
wps
、
rar
、
zip
、
doc
、
docx
、
pdf
、
png
、
jpg
、
jpeg
<
div
className
=
{
styles
.
uploadButton
}
>
<
input
type
=
"file"
// accept={'*'}
id
=
{
config
.
key
}
ref
=
{
inputRef
}
style
=
{{
opacity
:
0
,
width
:
'100vw'
,
height
:
'50px'
,
position
:
'absolute'
,
zIndex
:
2
,
}}
onChange
=
{
uploadImage
}
/
>
<
Button
type
=
{
'primary'
}
>
上传文件
<
/Button
>
<
/div
>
{
!
readOnly
&&
<>
支持格式:
xls
、
xlsx
、
wps
、
rar
、
zip
、
doc
、
docx
、
pdf
、
png
、
jpg
、
jpeg
<
div
className
=
{
styles
.
uploadButton
}
>
<
input
type
=
"file"
// accept={'*'}
id
=
{
config
.
key
}
ref
=
{
inputRef
}
style
=
{{
opacity
:
0
,
width
:
'100vw'
,
height
:
'50px'
,
position
:
'absolute'
,
zIndex
:
2
,
}}
onChange
=
{
uploadImage
}
/
>
<
Button
type
=
{
'primary'
}
>
上传文件
<
/Button
>
<
/div
>
<
/
>
}
<
div
className
=
{
styles
.
fileList
}
>
{
files
.
map
((
g
)
=>
{
return
<
div
key
=
{
g
.
path
}
className
=
{
styles
.
fileItem
}
>
<
a
>
{
g
.
name
}
<
/a><Icon type={'cross-circle'} onClick={deleteItem.bind
(
this, g
)
} /
>
{
/* TODO 加个弹窗的预览功能 */
}
<
a
href
=
{
systemConfig
.
sqlFormsServer
+
g
.
path
}
target
=
{
'_blank'
}
>
{
g
.
name
}
<
/a> {!readOnly && <Icon type={'cross-circle'} onClick={deleteItem.bind
(
this, g
)
} /
>
}
<
/div>
;
})
}
...
...
baseComponents/FormArray/index.js
浏览文件 @
52bde14c
...
...
@@ -12,7 +12,6 @@ import {
}
from
'antd-mobile'
;
import
moment
from
'moment'
;
import
PropTypes
from
'prop-types'
;
import
FieldList
from
'@/H5Public/baseComponents/FieldList'
;
import
TextareaItemMultiRows
from
'../TextareaItemMultiRows'
;
import
{
useState
}
from
'react'
;
...
...
@@ -69,9 +68,9 @@ const DiyTextarea = props => {
const
DiyPicker
=
props
=>
{
let
{
config
,
formValue
,
changeValue
}
=
props
;
if
(
config
.
readOnly
)
{
config
.
placeholder
=
' '
;
config
.
extra
=
' '
;
}
else
{
config
.
placeholder
=
config
.
placeholder
||
'点击输入
'
;
config
.
extra
=
config
.
placeholder
||
'请选择
'
;
}
let
opt
=
config
.
options
.
map
(
x
=>
{
return
{
...
...
@@ -79,18 +78,18 @@ const DiyPicker = props => {
value
:
x
.
key
,
};
});
return
(
<
Picker
data
=
{
opt
}
cols
=
{
1
}
// extra={' '}
key
=
{
config
.
key
}
value
=
{
[
formValue
[
config
.
key
]]
}
value
=
{
formValue
[
config
.
key
]
?
[
formValue
[
config
.
key
]]
:
undefined
}
disabled
=
{
config
.
readOnly
}
onChange
=
{
val
=>
{
changeValue
(
val
[
0
],
config
.
key
);
}}
extra
=
{
config
.
extra
}
{...
config
.
otherProps
}
>
<
List
.
Item
arrow
=
{
config
.
readOnly
?
''
:
'horizontal'
}
>
{
giveRequiredName
(
config
)}
<
/List.Item
>
...
...
@@ -352,5 +351,5 @@ FormArray.defaultProps = {
},
readOnly
:
false
,
};
export
{
giveRequiredName
}
export
default
FormArray
;
utils/requestJSON.js
0 → 100644
浏览文件 @
52bde14c
import
{
getHeaders
}
from
'@/H5Public/utils/2022new/getHeaders'
;
export
default
function
requestJSON
(
url
,
data
)
{
return
fetch
(
url
,
{
method
:
'post'
,
body
:
JSON
.
stringify
({...
data
}),
headers
:
{
'Content-Type'
:
'application/json'
,
Accept
:
'application/json'
,
...
getHeaders
().
headers
,
}
})
.
then
(
function
(
res
)
{
return
res
.
json
();
}).
then
(
function
(
data
)
{
return
data
;
})
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论