Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
WebPublic
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
前端开发小组
WebPublic
Commits
7f380903
提交
7f380903
authored
5月 25, 2022
作者:
钟是志
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
26598 自定义数据导出---导出字段调整,,,注意数据权限
上级
6bfce114
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
259 行增加
和
112 行删除
+259
-112
ExportCurrentInfo.js
one_stop_public/App/ExportCurrentInfo.js
+0
-112
SelectModal.js
one_stop_public/App/ExportCurrentInfo/SelectModal.js
+103
-0
index.js
one_stop_public/App/ExportCurrentInfo/index.js
+145
-0
style.less
one_stop_public/App/ExportCurrentInfo/style.less
+10
-0
SplitIndex.js
one_stop_public/libs/formList/SplitIndex.js
+1
-0
没有找到文件。
one_stop_public/App/ExportCurrentInfo.js
deleted
100644 → 0
浏览文件 @
6bfce114
import
fetch
from
'dva/fetch'
;
import
React
from
'react'
;
import
{
Form
,
notification
,
}
from
'antd'
;
import
{
connect
}
from
'dva'
;
import
{
getToken
}
from
'../utils/token'
;
import
config
from
'@/webPublic/one_stop_public/config'
;
import
FormdataWrapper
from
'../utils/object-to-formdata-custom'
;
import
ButtonDiy
from
'./ButtonDiy/ButtonDiy'
;
import
{
queryIsSafe
}
from
'@/webPublic/one_stop_public/utils/queryConfig'
;
import
{
giveFilePostData
,
giveFilePostDataInfoForTrue
}
from
'@/webPublic/one_stop_public/Base16'
;
/**
*
* 2019/02/21 修改导出方式为fetch
* 增加 props.fileName 设置导出文件名称
* mustQuerys 设置搜索条件 demo :
* mustQuerys={[{
hql: 'bean.adminStatus',
x: '=',
v: "pass",
c: 'com.zysoft.app.zydxl.entity.base.BaseImportantWatch$Status',
notes: 'com.zysoft.app.zydxl.entity.base.BaseImportantWatch$Status',
}]}
*/
@
connect
(({
DataObj
,
loading
})
=>
({
DataObj
,
loading
:
loading
.
models
.
DataObj
,
}))
@
Form
.
create
()
export
default
class
ExportCurrentInfo
extends
React
.
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
confirmLoading
:
false
,
};
}
exportData
=
()
=>
{
let
downloadUrl
=
config
.
httpServer
+
'/DataObjApi/exportCurrent?'
;
const
token
=
getToken
()
!=
null
&&
getToken
()
!=
'null'
?
getToken
()
:
'0000'
;
downloadUrl
=
`
${
downloadUrl
}
token=
${
token
}
`
;
let
param
=
{
dataObjId
:
this
.
props
.
objId
,
query
:
this
.
props
.
query
,
custom
:
this
.
props
.
custom
,
sql
:
this
.
props
.
sql
,
index
:
this
.
props
.
index
,
};
this
.
downloadFile
(
downloadUrl
,
param
);
};
downloadFile
(
url
,
params
)
{
this
.
setState
({
confirmLoading
:
true
});
let
newApi
=
giveFilePostDataInfoForTrue
(
params
,
url
);
fetch
(
newApi
.
url
,
{
method
:
'POST'
,
body
:
FormdataWrapper
(
newApi
.
datas
,
),
})
.
then
((
res
)
=>
{
if
(
res
.
status
!=
'200'
)
{
return
res
.
json
();
}
else
{
return
res
.
blob
();
}
})
.
then
((
data
)
=>
{
if
(
data
instanceof
Blob
)
{
let
a
=
document
.
createElement
(
'a'
);
let
url
=
window
.
URL
.
createObjectURL
(
data
);
let
filename
=
(
this
.
props
.
fileName
?
this
.
props
.
fileName
:
'导出文件.'
)
+
(
this
.
props
.
ext
||
'xlsx'
);
a
.
href
=
url
;
a
.
download
=
filename
;
a
.
click
();
window
.
URL
.
revokeObjectURL
(
url
);
a
=
null
;
}
else
{
notification
.
error
({
message
:
`文件导出错误`
,
description
:
data
.
errMsg
,
});
}
})
.
catch
((
err
)
=>
{
notification
.
error
({
message
:
`网络请求超时`
,
});
})
.
finally
(()
=>
{
this
.
setState
({
confirmLoading
:
false
});
});
}
render
()
{
const
btn
=
{
name
:
'导出'
,
type
:
'default'
,
className
:
'defaultBlue'
,
...(
this
.
props
.
btn
?
this
.
props
.
btn
:
{}),
};
return
(
<
span
>
<
ButtonDiy
{...
btn
}
loading
=
{
this
.
state
.
confirmLoading
}
handleClick
=
{
this
.
exportData
}
/
>
<
div
id
=
"downloadDiv"
style
=
{{
display
:
'none'
}}
/
>
<
/span
>
);
}
}
one_stop_public/App/ExportCurrentInfo/SelectModal.js
0 → 100644
浏览文件 @
7f380903
/**
* 钟是志
* 2022年5月25日
* openSelectFieldsModal 弹窗
*/
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
{
isJSON
}
from
'@/webPublic/one_stop_public/copy'
;
import
{
Checkbox
,
Col
,
Modal
,
Row
,
message
}
from
'antd'
;
import
ButtonDiy
from
'@/webPublic/one_stop_public/App/ButtonDiy/ButtonDiy'
;
import
styles
from
'./style.less'
;
export
default
function
SelectModal
({
custom
,
index
,
show
,
changeShow
,
downloadFile
,
})
{
const
[
fields
,
setFields
]
=
useState
([]);
const
[
buttonName
,
setButtonName
]
=
useState
(
'全部选中'
);
const
[
strInput
,
setStrInput
]
=
useState
([]);
const
[
inputDisable
,
setInputDisable
]
=
useState
(
false
);
// 点击全部选中整族失效
useEffect
(()
=>
{
if
(
isJSON
(
custom
))
{
let
exportConfig
=
JSON
.
parse
(
custom
)?.
exportConfig
;
if
(
exportConfig
&&
exportConfig
.
length
>
index
&&
index
>=
0
)
{
setFields
(
exportConfig
[
index
].
fields
);
}
}
},
[
custom
]);
const
arrayChange
=
(
checkedValues
)
=>
{
setStrInput
(
checkedValues
);
};
const
selectAllAndCancelAll
=
()
=>
{
const
all
=
fields
.
map
(
item
=>
item
.
k
);
if
(
strInput
.
length
===
all
.
length
)
{
setStrInput
([]);
setButtonName
(
'全部选中'
);
}
else
{
setStrInput
(
all
);
setButtonName
(
'全部取消'
);
}
};
const
handleOk
=
()
=>
{
if
(
!
strInput
||
!
strInput
.
length
)
{
message
.
warning
(
'请选择导出的列'
);
return
false
;
}
const
newFileds
=
fields
.
filter
((
item
)
=>
{
return
strInput
.
includes
(
item
.
k
);
});
if
(
!
newFileds
||
!
newFileds
.
length
)
{
changeShow
();
return
false
;
}
const
newCustom
=
JSON
.
parse
(
custom
);
newCustom
.
exportConfig
[
index
].
fields
=
newFileds
;
const
newParams
=
{
...
show
.
param
,
custom
:
JSON
.
stringify
(
newCustom
),
};
downloadFile
(
show
.
downloadUrl
,
newParams
);
};
return
!!
show
&&
<
Modal
title
=
{
'请选择导出列'
}
visible
=
{
true
}
onOk
=
{
handleOk
}
onCancel
=
{
changeShow
}
width
=
{
900
}
>
<
Row
>
<
Col
span
=
{
4
}
>
导出列数据
<
Col
>
<
ButtonDiy
name
=
{
buttonName
}
handleClick
=
{
selectAllAndCancelAll
}
/
>
<
/Col
>
<
/Col
>
<
Col
span
=
{
20
}
>
<
div
className
=
{
styles
.
formbody
}
>
<
Checkbox
.
Group
options
=
{
fields
.
map
((
g
)
=>
{
return
{
label
:
g
.
n
,
value
:
g
.
k
,
};
})}
onChange
=
{
arrayChange
}
value
=
{
strInput
}
disabled
=
{
inputDisable
}
/
>
<
/div
>
<
/Col
>
<
/Row
>
<
/Modal>
;
}
one_stop_public/App/ExportCurrentInfo/index.js
0 → 100644
浏览文件 @
7f380903
import
fetch
from
'dva/fetch'
;
import
React
from
'react'
;
import
{
Form
,
notification
,
}
from
'antd'
;
import
{
connect
}
from
'dva'
;
import
{
getToken
}
from
'../../utils/token'
;
import
config
from
'@/webPublic/one_stop_public/config'
;
import
FormdataWrapper
from
'../../utils/object-to-formdata-custom'
;
import
ButtonDiy
from
'../ButtonDiy/ButtonDiy'
;
import
{
giveFilePostData
,
giveFilePostDataInfoForTrue
}
from
'@/webPublic/one_stop_public/Base16'
;
import
SelectModal
from
'@/webPublic/one_stop_public/App/ExportCurrentInfo/SelectModal'
;
/**
*
* 2019/02/21 修改导出方式为fetch
* 增加 props.fileName 设置导出文件名称
* mustQuerys 设置搜索条件 demo :
* mustQuerys={[{
hql: 'bean.adminStatus',
x: '=',
v: "pass",
c: 'com.zysoft.app.zydxl.entity.base.BaseImportantWatch$Status',
notes: 'com.zysoft.app.zydxl.entity.base.BaseImportantWatch$Status',
}]}
*/
@
connect
(({
DataObj
,
loading
})
=>
({
DataObj
,
loading
:
loading
.
models
.
DataObj
,
}))
@
Form
.
create
()
export
default
class
ExportCurrentInfo
extends
React
.
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
confirmLoading
:
false
,
showSelectModal
:
false
,
};
}
changeShowSelectModal
=
()
=>
{
this
.
setState
({
showSelectModal
:
!
this
.
state
.
showSelectModal
,
})
}
exportData
=
()
=>
{
let
downloadUrl
=
config
.
httpServer
+
'/DataObjApi/exportCurrent?'
;
const
token
=
getToken
()
!=
null
&&
getToken
()
!=
'null'
?
getToken
()
:
'0000'
;
downloadUrl
=
`
${
downloadUrl
}
token=
${
token
}
`
;
let
param
=
{
dataObjId
:
this
.
props
.
objId
,
query
:
this
.
props
.
query
,
custom
:
this
.
props
.
custom
,
sql
:
this
.
props
.
sql
,
index
:
this
.
props
.
index
,
};
if
(
this
.
props
.
openSelectFieldsModal
){
// 26598 自定义数据导出---导出字段调整,,,注意数据权限
this
.
setState
({
showSelectModal
:
{
param
,
downloadUrl
,
}
});
return
false
;
}
this
.
downloadFile
(
downloadUrl
,
param
);
};
downloadFile
(
url
,
params
)
{
this
.
setState
({
confirmLoading
:
true
});
let
newApi
=
giveFilePostDataInfoForTrue
(
params
,
url
);
fetch
(
newApi
.
url
,
{
method
:
'POST'
,
body
:
FormdataWrapper
(
newApi
.
datas
,
),
})
.
then
((
res
)
=>
{
if
(
res
.
status
!=
'200'
)
{
return
res
.
json
();
}
else
{
return
res
.
blob
();
}
})
.
then
((
data
)
=>
{
if
(
data
instanceof
Blob
)
{
let
a
=
document
.
createElement
(
'a'
);
let
url
=
window
.
URL
.
createObjectURL
(
data
);
let
filename
=
(
this
.
props
.
fileName
?
this
.
props
.
fileName
:
'导出文件.'
)
+
(
this
.
props
.
ext
||
'xlsx'
);
a
.
href
=
url
;
a
.
download
=
filename
;
a
.
click
();
window
.
URL
.
revokeObjectURL
(
url
);
a
=
null
;
}
else
{
notification
.
error
({
message
:
`文件导出错误`
,
description
:
data
.
errMsg
,
});
}
})
.
catch
((
err
)
=>
{
notification
.
error
({
message
:
`网络请求超时`
,
});
})
.
finally
(()
=>
{
this
.
setState
({
confirmLoading
:
false
});
});
}
render
()
{
const
btn
=
{
name
:
'导出'
,
type
:
'default'
,
className
:
'defaultBlue'
,
...(
this
.
props
.
btn
?
this
.
props
.
btn
:
{}),
};
const
{
custom
,
index
,
openSelectFieldsModal
}
=
this
.
props
;
const
{
showSelectModal
}
=
this
.
state
;
return
(
<
span
>
<
ButtonDiy
{...
btn
}
loading
=
{
this
.
state
.
confirmLoading
}
handleClick
=
{
this
.
exportData
}
/
>
{
openSelectFieldsModal
&&
<
SelectModal
custom
=
{
custom
}
index
=
{
index
}
changeShow
=
{
this
.
changeShowSelectModal
}
show
=
{
showSelectModal
}
downloadFile
=
{
this
.
downloadFile
.
bind
(
this
)}
/
>
}
<
div
id
=
"downloadDiv"
style
=
{{
display
:
'none'
}}
/
>
<
/span
>
);
}
}
one_stop_public/App/ExportCurrentInfo/style.less
0 → 100644
浏览文件 @
7f380903
.formbody{
display: flex;
flex-wrap: wrap;
height: 450px;
overflow: auto;
label{
width: 30%;
box-sizing: border-box;
}
}
one_stop_public/libs/formList/SplitIndex.js
浏览文件 @
7f380903
...
...
@@ -65,6 +65,7 @@ export function FormListButtons(props) {
index
=
{
r
.
index
}
btn
=
{
r
.
btn
}
ext
=
{
r
.
ext
?
r
.
ext
:
'xlsx'
}
openSelectFieldsModal
=
{
r
.
openSelectFieldsModal
||
false
}
sql
=
{
Base16Encode
(
sql
)}
/>
;
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论