Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
WebPublic
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
前端开发小组
WebPublic
Commits
1727a6a9
提交
1727a6a9
authored
4月 13, 2021
作者:
钟是志
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
11794 后勤编外人员库,000013 批量导入报错 数据库 监听器 报错在前端不显示导入什么报错了
上级
15f2e239
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
246 行增加
和
219 行删除
+246
-219
ImportUtil.js
one_stop_public/App/ImportUtil.js
+145
-147
DataObj.js
one_stop_public/models/DataObj.js
+47
-43
request.js
one_stop_public/utils/request.js
+54
-29
没有找到文件。
one_stop_public/App/ImportUtil.js
浏览文件 @
1727a6a9
import
React
,
{
Fragment
}
from
'react'
;
import
React
,
{
Fragment
}
from
'react'
;
import
{
import
{
Button
,
Modal
,
Steps
,
Upload
,
Icon
,
message
,
Spin
,
Tabs
,
Table
}
from
'antd'
;
Button
,
Modal
,
Steps
,
Upload
,
Icon
,
message
,
Spin
,
Tabs
,
Table
,
}
from
'antd'
;
import
styles
from
'./ImportUtil.less'
;
import
styles
from
'./ImportUtil.less'
;
import
ButtonDiy
from
'./ButtonDiy/ButtonDiy'
;
import
ButtonDiy
from
'./ButtonDiy/ButtonDiy'
;
...
@@ -19,7 +9,7 @@ import { connect } from 'dva';
...
@@ -19,7 +9,7 @@ import { connect } from 'dva';
const
Step
=
Steps
.
Step
;
const
Step
=
Steps
.
Step
;
const
TabPane
=
Tabs
.
TabPane
;
const
TabPane
=
Tabs
.
TabPane
;
const
exportExcel
=
(
CLIENT_TYPE
==
'mobile'
)
?
null
:
require
(
'xlsx-oc'
).
exportExcel
;
const
exportExcel
=
CLIENT_TYPE
==
'mobile'
?
null
:
require
(
'xlsx-oc'
).
exportExcel
;
@
connect
(({
DataObj
,
loading
})
=>
({
@
connect
(({
DataObj
,
loading
})
=>
({
DataObj
,
DataObj
,
...
@@ -29,7 +19,9 @@ export default class ImportUtil extends React.PureComponent {
...
@@ -29,7 +19,9 @@ export default class ImportUtil extends React.PureComponent {
constructor
(
props
)
{
constructor
(
props
)
{
super
(
props
);
super
(
props
);
const
exportTemplateUrl
=
encodeURI
(
`
${
config
.
httpServer
}
/DataObjApi/importTemplateDownload?objId=
${
this
.
props
.
objId
}
&name=
${
props
.
fileName
}
`
);
const
exportTemplateUrl
=
encodeURI
(
`
${
config
.
httpServer
}
/DataObjApi/importTemplateDownload?objId=
${
this
.
props
.
objId
}
&name=
${
props
.
fileName
}
`
,
);
this
.
state
=
{
this
.
state
=
{
ch
:
false
,
ch
:
false
,
...
@@ -49,17 +41,16 @@ export default class ImportUtil extends React.PureComponent {
...
@@ -49,17 +41,16 @@ export default class ImportUtil extends React.PureComponent {
}
}
showModal
=
()
=>
{
showModal
=
()
=>
{
this
.
setState
({
this
.
setState
({
visible
:
true
,
visible
:
true
,
});
});
};
};
handleOk
=
(
e
)
=>
{
handleOk
=
e
=>
{
this
.
setState
({
this
.
setState
({
visible
:
false
,
visible
:
false
,
});
});
};
};
handleCancel
=
(
e
)
=>
{
handleCancel
=
e
=>
{
this
.
setState
({
this
.
setState
({
visible
:
false
,
visible
:
false
,
});
});
...
@@ -88,7 +79,6 @@ export default class ImportUtil extends React.PureComponent {
...
@@ -88,7 +79,6 @@ export default class ImportUtil extends React.PureComponent {
this
.
props
.
callback
();
this
.
props
.
callback
();
}
}
}
}
}
}
prev
()
{
prev
()
{
...
@@ -106,8 +96,7 @@ export default class ImportUtil extends React.PureComponent {
...
@@ -106,8 +96,7 @@ export default class ImportUtil extends React.PureComponent {
objId
:
this
.
props
.
objId
,
objId
:
this
.
props
.
objId
,
},
},
callback
:
(
res
)
=>
{
callback
:
res
=>
{
this
.
next
();
this
.
next
();
message
.
success
(
'导入成功'
);
message
.
success
(
'导入成功'
);
...
@@ -115,18 +104,15 @@ export default class ImportUtil extends React.PureComponent {
...
@@ -115,18 +104,15 @@ export default class ImportUtil extends React.PureComponent {
current
:
3
,
current
:
3
,
isShow
:
true
,
isShow
:
true
,
visible
:
false
,
visible
:
false
,
});
});
if
(
this
.
props
.
callback
)
{
if
(
this
.
props
.
callback
)
{
this
.
props
.
callback
();
this
.
props
.
callback
();
}
}
},
},
});
});
}
}
getCachKey
=
(
filePath
)
=>
{
getCachKey
=
filePath
=>
{
const
{
dispatch
,
importParams
}
=
this
.
props
;
const
{
dispatch
,
importParams
}
=
this
.
props
;
dispatch
({
dispatch
({
type
:
'DataObj/importAnalyse'
,
type
:
'DataObj/importAnalyse'
,
...
@@ -136,19 +122,15 @@ export default class ImportUtil extends React.PureComponent {
...
@@ -136,19 +122,15 @@ export default class ImportUtil extends React.PureComponent {
filePath
,
filePath
,
objId
:
this
.
props
.
objId
,
objId
:
this
.
props
.
objId
,
},
},
callback
:
(
res
)
=>
{
callback
:
res
=>
{
this
.
setState
({
this
.
setState
({
filekey
:
res
.
cacheKey
,
filekey
:
res
.
cacheKey
,
});
});
this
.
queryFile
(
res
.
cacheKey
);
this
.
queryFile
(
res
.
cacheKey
);
},
},
});
});
};
};
queryFile
=
(
cacheKey
)
=>
{
queryFile
=
cacheKey
=>
{
const
{
dispatch
,
importParams
}
=
this
.
props
;
const
{
dispatch
,
importParams
}
=
this
.
props
;
dispatch
({
dispatch
({
type
:
'DataObj/importDataQuery'
,
type
:
'DataObj/importDataQuery'
,
...
@@ -157,7 +139,7 @@ export default class ImportUtil extends React.PureComponent {
...
@@ -157,7 +139,7 @@ export default class ImportUtil extends React.PureComponent {
cacheKey
,
cacheKey
,
objId
:
this
.
props
.
objId
,
objId
:
this
.
props
.
objId
,
},
},
callback
:
(
res
)
=>
{
callback
:
res
=>
{
this
.
setState
({
this
.
setState
({
current
:
1
,
current
:
1
,
isShow
:
false
,
isShow
:
false
,
...
@@ -167,8 +149,6 @@ export default class ImportUtil extends React.PureComponent {
...
@@ -167,8 +149,6 @@ export default class ImportUtil extends React.PureComponent {
column
:
res
.
column
,
column
:
res
.
column
,
});
});
if
(
res
.
noPass
&&
res
.
noPass
.
length
==
0
)
{
if
(
res
.
noPass
&&
res
.
noPass
.
length
==
0
)
{
if
(
res
.
pass
.
length
==
0
)
{
if
(
res
.
pass
.
length
==
0
)
{
message
.
error
(
'当前没有验证成功的数据,无法导入。'
);
message
.
error
(
'当前没有验证成功的数据,无法导入。'
);
this
.
setState
({
this
.
setState
({
...
@@ -192,15 +172,13 @@ export default class ImportUtil extends React.PureComponent {
...
@@ -192,15 +172,13 @@ export default class ImportUtil extends React.PureComponent {
isNextDisabled
:
true
,
isNextDisabled
:
true
,
});
});
}
}
},
},
});
});
};
};
changePane
=
(
activeKey
)
=>
{
changePane
=
activeKey
=>
{
this
.
setState
({
currentKey
:
activeKey
});
this
.
setState
({
currentKey
:
activeKey
});
};
};
exportError
=
(
column
,
dataSource
)
=>
{
exportError
=
(
column
,
dataSource
)
=>
{
if
(
exportExcel
==
null
)
{
if
(
exportExcel
==
null
)
{
message
.
info
(
'当前终端暂不支持此功能'
);
message
.
info
(
'当前终端暂不支持此功能'
);
return
;
return
;
...
@@ -213,12 +191,9 @@ export default class ImportUtil extends React.PureComponent {
...
@@ -213,12 +191,9 @@ export default class ImportUtil extends React.PureComponent {
dataSource
[
j
].
index
=
j
+
1
;
dataSource
[
j
].
index
=
j
+
1
;
}
}
exportExcel
(
_headers
,
dataSource
);
exportExcel
(
_headers
,
dataSource
);
};
};
render
()
{
render
()
{
const
props
=
{
const
props
=
{
name
:
'file'
,
name
:
'file'
,
action
:
config
.
uploadUrl
,
action
:
config
.
uploadUrl
,
...
@@ -228,54 +203,61 @@ export default class ImportUtil extends React.PureComponent {
...
@@ -228,54 +203,61 @@ export default class ImportUtil extends React.PureComponent {
},
},
accept
:
'.xlsx'
,
accept
:
'.xlsx'
,
showUploadList
:
false
,
showUploadList
:
false
,
onChange
:
(
info
)
=>
{
onChange
:
info
=>
{
if
(
info
.
file
.
status
!==
'uploading'
)
{
if
(
info
.
file
.
status
!==
'uploading'
)
{
}
}
if
(
info
.
file
.
status
===
'done'
)
{
if
(
info
.
file
.
status
===
'done'
)
{
message
.
success
(
`
${
info
.
file
.
name
}
上传成功`
);
message
.
success
(
`
${
info
.
file
.
name
}
上传成功`
);
let
x
=
info
.
file
.
response
;
let
x
=
info
.
file
.
response
;
this
.
getCachKey
(
x
);
this
.
getCachKey
(
x
);
}
else
if
(
info
.
file
.
status
===
'error'
)
{
}
else
if
(
info
.
file
.
status
===
'error'
)
{
message
.
error
(
`
${
info
.
file
.
name
}
file upload failed.
`
);
message
.
error
(
`
${
info
.
file
.
name
}
上传失败
`
);
}
}
},
},
};
};
const
steps
=
[{
const
steps
=
[
title
:
'上传Excel'
,
{
},
{
title
:
'上传Excel'
,
title
:
'验证数据'
,
},
},
{
{
title
:
'数据导入'
,
title
:
'验证数据'
,
},
},
{
title
:
'数据导入'
,
},
{
{
title
:
'导入完成'
,
title
:
'导入完成'
,
}];
},
];
const
{
current
}
=
this
.
state
;
const
{
current
}
=
this
.
state
;
const
{
name
,
loading
}
=
this
.
props
;
const
{
name
,
loading
}
=
this
.
props
;
const
column1
=
this
.
state
.
column
?
[{
const
column1
=
this
.
state
.
column
title
:
'序号'
,
?
[
dataIndex
:
'index'
,
{
fixed
:
'left'
,
title
:
'序号'
,
width
:
50
,
dataIndex
:
'index'
,
render
:
(
v
,
r
,
i
)
=>
i
+
1
,
fixed
:
'left'
,
},
...
this
.
state
.
column
]
:
[];
width
:
50
,
render
:
(
v
,
r
,
i
)
=>
i
+
1
,
},
...
this
.
state
.
column
,
]
:
[];
var
column2
=
this
.
state
.
column
?
[...
this
.
state
.
column
]
:
[];
var
column2
=
this
.
state
.
column
?
[...
this
.
state
.
column
]
:
[];
if
(
column1
.
length
>
1
)
column1
[
1
].
render
=
(
val
)
=>
<
span
style
=
{{
color
:
'red'
}}
>
{
val
}
<
/span>
;
if
(
column1
.
length
>
1
)
column1
[
1
].
render
=
val
=>
<
span
style
=
{{
color
:
'red'
}}
>
{
val
}
<
/span>
;
column2
.
splice
(
0
,
1
);
column2
.
splice
(
0
,
1
);
column2
=
[{
title
:
'序号'
,
fixed
:
'left'
,
width
:
50
,
render
:
(
v
,
r
,
i
)
=>
i
+
1
},
...
column2
];
column2
=
[{
title
:
'序号'
,
fixed
:
'left'
,
width
:
50
,
render
:
(
v
,
r
,
i
)
=>
i
+
1
},
...
column2
];
return
(
return
(
<
span
>
<
span
>
<
ButtonDiy
name
=
{
name
||
'批量导入'
}
<
ButtonDiy
type
=
'default'
name
=
{
name
||
'批量导入'
}
// 应用里面的批量导入
className
=
'defaultBlue'
type
=
"default"
handleClick
=
{
this
.
showModal
}
/
>
className
=
"defaultBlue"
handleClick
=
{
this
.
showModal
}
/
>
<
Modal
<
Modal
visible
=
{
this
.
state
.
visible
}
visible
=
{
this
.
state
.
visible
}
onOk
=
{
this
.
handleOk
}
onOk
=
{
this
.
handleOk
}
...
@@ -286,108 +268,124 @@ export default class ImportUtil extends React.PureComponent {
...
@@ -286,108 +268,124 @@ export default class ImportUtil extends React.PureComponent {
footer
=
{
null
}
footer
=
{
null
}
width
=
{
'80%'
}
width
=
{
'80%'
}
>
>
<
div
className
=
{
styles
.
nomal
}
>
<
div
className
=
{
styles
.
nomal
}
>
<
p
className
=
{
styles
.
import
}
>
<
p
className
=
{
styles
.
import
}
>
EXCEL
导入向导
<
/p
>
EXCEL
导入向导
<
/p
>
<
div
style
=
{{
margin
:
'auto 23px'
}}
>
<
div
style
=
{{
margin
:
'auto 23px'
}}
>
<
Steps
current
=
{
current
}
>
<
Steps
current
=
{
current
}
>
{
steps
.
map
(
item
=>
{
steps
.
map
(
item
=>
(
<
Step
key
=
{
item
.
title
}
<
Step
key
=
{
item
.
title
}
title
=
{
item
.
title
}
/
>
title
=
{
item
.
title
}
/>
)
}
)
)}
<
/Steps
>
<
/Steps
>
<
div
className
=
"steps-content"
>
<
div
className
=
"steps-content"
>
{
steps
[
this
.
state
.
current
].
content
}
<
/div
>
{
steps
[
this
.
state
.
current
].
content
}
<
/div
>
<
div
className
=
{
styles
.
button
}
>
<
div
className
=
{
styles
.
button
}
>
{
{
this
.
state
.
current
<
steps
.
length
-
1
&&
this
.
state
.
current
!==
0
&&
(
(
this
.
state
.
current
<
steps
.
length
-
1
&&
this
.
state
.
current
!==
0
)
<
ButtonDiy
&&
name
=
{
this
.
state
.
current
==
3
?
'确认导入'
:
'下一步'
}
<
ButtonDiy
name
=
{
this
.
state
.
current
==
3
?
'确认导入'
:
'下一步'
}
type
=
"primary"
type
=
"primary"
disabled
=
{
this
.
state
.
current
!=
3
&&
this
.
state
.
isNextDisabled
}
disabled
=
{
this
.
state
.
current
!=
3
&&
this
.
state
.
isNextDisabled
}
// className='primaryBlue'
// className='primaryBlue'
handleClick
=
{()
=>
this
.
next
()}
handleClick
=
{()
=>
this
.
next
()}
/
>
/
>
)}
}
{
this
.
state
.
current
>
0
&&
(
{
<
ButtonDiy
this
.
state
.
current
>
0
style
=
{{
marginLeft
:
8
}}
&&
name
=
"上一步"
<
ButtonDiy
style
=
{{
marginLeft
:
8
}}
name
=
"上一步"
className
=
'defaultBlue'
className
=
"defaultBlue"
handleClick
=
{()
=>
this
.
prev
()}
/
>
handleClick
=
{()
=>
this
.
prev
()}
/
>
}
)
}
<
/div
>
<
/div
>
<
/div
>
<
/div
>
<
div
className
=
{
styles
.
tip
}
>
<
div
className
=
{
styles
.
tip
}
>
<
p
className
=
{
styles
.
tipContent
}
>
<
p
className
=
{
styles
.
tipContent
}
>
<
span
>
欢迎使用
EXCEL
导入向导,首先请您上传需要导入的
EXCEL
文件。
<
/span
>
<
span
>
欢迎使用
EXCEL
导入向导,首先请您上传需要导入的
EXCEL
文件。
<
/span
>
<
span
>
点击“选择文件”选择您要导入的
EXCEL
文件,点击“开始上传”将其上传到服务器上,点击“清空队列”清空当前上传文件队列。
<
/span
>
<
span
>
点击“选择文件”选择您要导入的
EXCEL
文件,点击“开始上传”将其上传到服务器上,点击“清空队列”清空当前上传文件队列。
<
/span
>
<
/p
>
<
/p
>
<
/div
>
<
/div
>
{
{
this
.
state
.
isShow
?
(
this
.
state
.
isShow
?
<
div
className
=
{
styles
.
buttonDown
}
>
<
div
className
=
{
styles
.
buttonDown
}
>
<
Upload
{...
props
}
>
<
Button
>
<
Icon
type
=
"upload"
/>
点击上传
<
/Button
>
<
/Upload
>
<
Button
href
=
{
this
.
state
.
exportTemplateUrl
}
target
=
"_blank"
type
=
"danger"
>
下载模板
<
/Button
>
<
/div>
:
<
Upload
{...
props
}
>
<
Upload
{...
props
}
>
<
Button
>
<
Button
>
<
Icon
type
=
"upload"
/>
<
Icon
type
=
"upload"
/>
重新
上传
点击
上传
<
/Button
>
<
/Button
>
<
/Upload
>
<
/Upload
>
}
<
Button
href
=
{
this
.
state
.
exportTemplateUrl
}
target
=
"_blank"
type
=
"danger"
>
下载模板
{
<
/Button
>
this
.
state
.
isShow
?
<
div
className
=
{
styles
.
attentionItem
}
>
<
/div
>
<
p
>
导入事项
<
/p
>
)
:
(
<
p
>
1
.
导入操作一次只能上传
1
个
EXCEL
文件。
<
/p
>
<
Upload
{...
props
}
>
<
p
>
2
.
导入文件最大文件大小上传
1
GB
。
<
/p
>
<
Button
>
<
p
>
3
.
只能上传
EXCEL
文件
(
XLS
,
XLSX
)
默认支持
EXCEL
2003
和
EXCEL
2007
。
<
/p
>
<
Icon
type
=
"upload"
/>
<
p
>
4
.
请将
EXCEL
文件的所有单元格格式设置为“文本”格式
<
/p
>
重新上传
<
/div>
:
<
/Button
>
<
div
className
=
{
styles
.
error
}
style
=
{{
marginTop
:
20
}}
>
<
/Upload
>
)}
<
Tabs
activeKey
=
{
this
.
state
.
currentKey
}
key
=
{
this
.
state
.
ch
}
onChange
=
{
this
.
changePane
}
type
=
"card"
>
{
this
.
state
.
errData
&&
this
.
state
.
errData
.
length
==
0
?
''
:
{
this
.
state
.
isShow
?
(
<
TabPane
tab
=
{
<
span
style
=
{{
color
:
'red'
}}
>
验证错误列表
<
/span>} key="1"
>
<
div
className
=
{
styles
.
attentionItem
}
>
<
Button
style
=
{{
marginTop
:
5
,
marginBottom
:
5
}}
type
=
"danger"
<
p
>
导入事项
<
/p
>
onClick
=
{
this
.
exportError
.
bind
(
this
,
column1
,
this
.
state
.
errData
)}
>
导出错误信息
<
/Button
>
<
p
>
1
.
导入操作一次只能上传
1
个
EXCEL
文件。
<
/p
>
<
p
>
2
.
导入文件最大文件大小上传
1
GB
。
<
/p
>
<
Table
columns
=
{
column1
}
size
=
"small"
<
p
>
3
.
只能上传
EXCEL
文件
(
XLS
,
XLSX
)
默认支持
EXCEL
2003
和
EXCEL
2007
。
<
/p
>
style
=
{{
overflow
:
'auto'
}}
<
p
>
4
.
请将
EXCEL
文件的所有单元格格式设置为“文本”格式
<
/p
>
dataSource
=
{
this
.
state
.
errData
}
<
/div
>
bordered
=
{
true
}
/></
TabPane
>
}
)
:
(
<
TabPane
tab
=
{
<
span
style
=
{{
color
:
'green'
}}
>
验证成功列表
<
/span>} key="2"
>
<
div
className
=
{
styles
.
error
}
style
=
{{
marginTop
:
20
}}
>
<
Tabs
<
Button
style
=
{{
marginTop
:
5
,
marginBottom
:
5
}}
type
=
"primary"
activeKey
=
{
this
.
state
.
currentKey
}
onClick
=
{
this
.
exportError
.
bind
(
this
,
column2
,
this
.
state
.
sucData
)}
>
导出正确信息
<
/Button
>
key
=
{
this
.
state
.
ch
}
onChange
=
{
this
.
changePane
}
<
Table
columns
=
{
column2
}
size
=
"small"
type
=
"card"
style
=
{{
overflow
:
'auto'
}}
>
dataSource
=
{
this
.
state
.
sucData
}
{
this
.
state
.
errData
&&
this
.
state
.
errData
.
length
==
0
?
(
bordered
=
{
true
}
/></
TabPane
>
''
)
:
(
<
/Tabs
>
<
TabPane
tab
=
{
<
span
style
=
{{
color
:
'red'
}}
>
验证错误列表
<
/span>} key="1"
>
<
Button
style
=
{{
marginTop
:
5
,
marginBottom
:
5
}}
type
=
"danger"
onClick
=
{
this
.
exportError
.
bind
(
this
,
column1
,
this
.
state
.
errData
)}
>
导出错误信息
<
/Button
>
<
Table
columns
=
{
column1
}
size
=
"small"
style
=
{{
overflow
:
'auto'
}}
dataSource
=
{
this
.
state
.
errData
}
bordered
=
{
true
}
/
>
<
/TabPane
>
)}
<
TabPane
tab
=
{
<
span
style
=
{{
color
:
'green'
}}
>
验证成功列表
<
/span>} key="2"
>
<
Button
style
=
{{
marginTop
:
5
,
marginBottom
:
5
}}
type
=
"primary"
onClick
=
{
this
.
exportError
.
bind
(
this
,
column2
,
this
.
state
.
sucData
)}
>
导出正确信息
<
/Button
>
<
/div
>
<
Table
}
columns
=
{
column2
}
size
=
"small"
style
=
{{
overflow
:
'auto'
}}
dataSource
=
{
this
.
state
.
sucData
}
bordered
=
{
true
}
/
>
<
/TabPane
>
<
/Tabs
>
<
/div
>
)}
<
/div
>
<
/div
>
<
/Modal
>
<
/Modal
>
<
/span
>
<
/span
>
);
);
...
...
one_stop_public/models/DataObj.js
浏览文件 @
1727a6a9
import
{
apiRequest
}
from
'../utils/request'
;
import
{
apiRequest
}
from
'../utils/request'
;
const
api
=
'/DataObjApi'
;
const
api
=
'/DataObjApi'
;
import
{
Base16Encode
}
from
"../Base16/index"
import
{
Base16Encode
}
from
"../Base16/index"
...
@@ -18,10 +19,10 @@ export default {
...
@@ -18,10 +19,10 @@ export default {
},
},
effects
:
{
effects
:
{
*
importAnalyse
({
payload
,
callback
},
{
call
,
put
})
{
*
importAnalyse
({
payload
,
callback
},
{
call
,
put
})
{
const
response
=
yield
call
(
apiRequest
,
api
+
'/importAnalyse'
,
payload
);
const
response
=
yield
call
(
apiRequest
,
api
+
'/importAnalyse'
,
payload
);
if
(
!
response
)
{
if
(
!
response
)
{
yield
put
({
type
:
'nom'
});
yield
put
({
type
:
'nom'
});
return
;
return
;
}
}
...
@@ -31,10 +32,10 @@ export default {
...
@@ -31,10 +32,10 @@ export default {
});
});
if
(
callback
)
callback
(
response
);
if
(
callback
)
callback
(
response
);
},
},
*
importDataQuery
({
payload
,
callback
},
{
call
,
put
})
{
*
importDataQuery
({
payload
,
callback
},
{
call
,
put
})
{
const
response
=
yield
call
(
apiRequest
,
api
+
'/importDataQuery'
,
payload
);
const
response
=
yield
call
(
apiRequest
,
api
+
'/importDataQuery'
,
payload
);
if
(
!
response
)
{
if
(
!
response
)
{
yield
put
({
type
:
'nom'
});
yield
put
({
type
:
'nom'
});
return
;
return
;
}
}
...
@@ -44,10 +45,13 @@ export default {
...
@@ -44,10 +45,13 @@ export default {
});
});
if
(
callback
)
callback
(
response
);
if
(
callback
)
callback
(
response
);
},
},
*
importExecute
({
payload
,
callback
},
{
call
,
put
})
{
*
importExecute
({
payload
,
callback
},
{
call
,
put
})
{
const
response
=
yield
call
(
apiRequest
,
api
+
'/importExecute'
,
payload
);
const
response
=
yield
call
(
apiRequest
,
api
+
'/importExecute'
,
{
...
payload
,
customErrMsg
:
'导入的文件中可能存在字段不一致、字段类型不匹配、唯一性字段冲突,请检查或联系系统管理员'
,
// 自定义errMsg
});
if
(
!
response
)
{
if
(
!
response
)
{
yield
put
({
type
:
'nom'
});
yield
put
({
type
:
'nom'
});
return
;
return
;
}
}
...
@@ -57,18 +61,18 @@ export default {
...
@@ -57,18 +61,18 @@ export default {
});
});
if
(
callback
)
callback
(
response
);
if
(
callback
)
callback
(
response
);
},
},
*
getAll
({
payload
,
callback
},
{
call
,
put
})
{
*
getAll
({
payload
,
callback
},
{
call
,
put
})
{
const
response
=
yield
call
(
apiRequest
,
api
+
'/getAll'
,
payload
);
const
response
=
yield
call
(
apiRequest
,
api
+
'/getAll'
,
payload
);
if
(
!
response
)
{
if
(
!
response
)
{
yield
put
({
type
:
'nom'
});
yield
put
({
type
:
'nom'
});
return
;
return
;
}
}
if
(
callback
)
callback
(
response
);
if
(
callback
)
callback
(
response
);
},
},
*
getStatistics
({
payload
,
callback
},
{
call
,
put
})
{
*
getStatistics
({
payload
,
callback
},
{
call
,
put
})
{
const
response
=
yield
call
(
apiRequest
,
api
+
'/getStatistics'
,
payload
);
const
response
=
yield
call
(
apiRequest
,
api
+
'/getStatistics'
,
payload
);
if
(
!
response
)
{
if
(
!
response
)
{
yield
put
({
type
:
'nom'
});
yield
put
({
type
:
'nom'
});
return
;
return
;
}
}
...
@@ -78,10 +82,10 @@ export default {
...
@@ -78,10 +82,10 @@ export default {
});
});
if
(
callback
)
callback
(
response
);
if
(
callback
)
callback
(
response
);
},
},
*
getExportInfo
({
payload
,
callback
},
{
call
,
put
})
{
*
getExportInfo
({
payload
,
callback
},
{
call
,
put
})
{
const
response
=
yield
call
(
apiRequest
,
api
+
'/getExportInfo'
,
payload
);
const
response
=
yield
call
(
apiRequest
,
api
+
'/getExportInfo'
,
payload
);
if
(
!
response
)
{
if
(
!
response
)
{
yield
put
({
type
:
'nom'
});
yield
put
({
type
:
'nom'
});
return
;
return
;
}
}
...
@@ -91,10 +95,10 @@ export default {
...
@@ -91,10 +95,10 @@ export default {
});
});
if
(
callback
)
callback
(
response
);
if
(
callback
)
callback
(
response
);
},
},
*
changeCatalogue
({
payload
,
callback
},
{
call
,
put
})
{
*
changeCatalogue
({
payload
,
callback
},
{
call
,
put
})
{
const
response
=
yield
call
(
apiRequest
,
api
+
'/changeCatalogue'
,
payload
);
const
response
=
yield
call
(
apiRequest
,
api
+
'/changeCatalogue'
,
payload
);
if
(
!
response
)
{
if
(
!
response
)
{
yield
put
({
type
:
'nom'
});
yield
put
({
type
:
'nom'
});
return
;
return
;
}
}
...
@@ -104,10 +108,10 @@ export default {
...
@@ -104,10 +108,10 @@ export default {
});
});
if
(
callback
)
callback
(
response
);
if
(
callback
)
callback
(
response
);
},
},
*
findByCode
({
payload
,
callback
},
{
call
,
put
})
{
*
findByCode
({
payload
,
callback
},
{
call
,
put
})
{
const
response
=
yield
call
(
apiRequest
,
api
+
'/findByCode'
,
payload
);
const
response
=
yield
call
(
apiRequest
,
api
+
'/findByCode'
,
payload
);
if
(
!
response
)
{
if
(
!
response
)
{
yield
put
({
type
:
'nom'
});
yield
put
({
type
:
'nom'
});
return
;
return
;
}
}
...
@@ -117,10 +121,10 @@ export default {
...
@@ -117,10 +121,10 @@ export default {
});
});
if
(
callback
)
callback
(
response
);
if
(
callback
)
callback
(
response
);
},
},
*
findByName
({
payload
,
callback
},
{
call
,
put
})
{
*
findByName
({
payload
,
callback
},
{
call
,
put
})
{
const
response
=
yield
call
(
apiRequest
,
api
+
'/findByName'
,
payload
);
const
response
=
yield
call
(
apiRequest
,
api
+
'/findByName'
,
payload
);
if
(
!
response
)
{
if
(
!
response
)
{
yield
put
({
type
:
'nom'
});
yield
put
({
type
:
'nom'
});
return
;
return
;
}
}
yield
put
({
yield
put
({
...
@@ -129,10 +133,10 @@ export default {
...
@@ -129,10 +133,10 @@ export default {
});
});
if
(
callback
)
callback
(
response
);
if
(
callback
)
callback
(
response
);
},
},
*
find
({
payload
,
callback
},
{
call
,
put
})
{
*
find
({
payload
,
callback
},
{
call
,
put
})
{
const
response
=
yield
call
(
apiRequest
,
api
+
'/find'
,
payload
);
const
response
=
yield
call
(
apiRequest
,
api
+
'/find'
,
payload
);
if
(
!
response
)
{
if
(
!
response
)
{
yield
put
({
type
:
'nom'
});
yield
put
({
type
:
'nom'
});
return
;
return
;
}
}
...
@@ -142,14 +146,14 @@ export default {
...
@@ -142,14 +146,14 @@ export default {
});
});
if
(
callback
)
callback
(
response
);
if
(
callback
)
callback
(
response
);
},
},
*
add
({
payload
,
callback
},
{
call
,
put
})
{
*
add
({
payload
,
callback
},
{
call
,
put
})
{
if
(
payload
.
sqlScript
)
{
if
(
payload
.
sqlScript
)
{
payload
.
sqlScript
=
Base16Encode
(
payload
.
sqlScript
)
payload
.
sqlScript
=
Base16Encode
(
payload
.
sqlScript
)
}
}
const
response
=
yield
call
(
apiRequest
,
api
+
'/add'
,
payload
);
const
response
=
yield
call
(
apiRequest
,
api
+
'/add'
,
payload
);
if
(
!
response
)
{
if
(
!
response
)
{
yield
put
({
type
:
'nom'
});
yield
put
({
type
:
'nom'
});
return
;
return
;
}
}
...
@@ -159,33 +163,33 @@ export default {
...
@@ -159,33 +163,33 @@ export default {
});
});
if
(
callback
)
callback
(
response
);
if
(
callback
)
callback
(
response
);
},
},
*
fetch
({
payload
,
callback
},
{
call
,
put
})
{
*
fetch
({
payload
,
callback
},
{
call
,
put
})
{
const
response
=
yield
call
(
apiRequest
,
api
+
'/getPage'
,
payload
);
const
response
=
yield
call
(
apiRequest
,
api
+
'/getPage'
,
payload
);
if
(
!
response
)
{
if
(
!
response
)
{
yield
put
({
type
:
'nom'
});
yield
put
({
type
:
'nom'
});
return
;
return
;
}
}
yield
put
({
yield
put
({
type
:
'page'
,
type
:
'page'
,
payload
:
{
...
response
,
isMain
:
payload
.
isMain
},
payload
:
{
...
response
,
isMain
:
payload
.
isMain
},
});
});
},
},
*
getTableList
({
payload
,
callback
},
{
call
,
put
})
{
*
getTableList
({
payload
,
callback
},
{
call
,
put
})
{
const
response
=
yield
call
(
apiRequest
,
api
+
'/getTableList'
,
payload
);
const
response
=
yield
call
(
apiRequest
,
api
+
'/getTableList'
,
payload
);
if
(
!
response
)
{
if
(
!
response
)
{
yield
put
({
type
:
'nom'
});
yield
put
({
type
:
'nom'
});
return
;
return
;
}
}
yield
put
({
yield
put
({
type
:
'nom'
,
type
:
'nom'
,
payload
:
response
,
payload
:
response
,
});
});
if
(
callback
)
callback
(
response
);
if
(
callback
)
callback
(
response
);
},
},
*
createTableByName
({
payload
,
callback
},
{
call
,
put
})
{
*
createTableByName
({
payload
,
callback
},
{
call
,
put
})
{
const
response
=
yield
call
(
apiRequest
,
api
+
'/createTableByName'
,
payload
);
const
response
=
yield
call
(
apiRequest
,
api
+
'/createTableByName'
,
payload
);
if
(
!
response
)
{
if
(
!
response
)
{
yield
put
({
type
:
'nom'
});
yield
put
({
type
:
'nom'
});
return
;
return
;
}
}
yield
put
({
yield
put
({
...
@@ -194,10 +198,10 @@ export default {
...
@@ -194,10 +198,10 @@ export default {
});
});
if
(
callback
)
callback
(
response
);
if
(
callback
)
callback
(
response
);
},
},
*
remove
({
payload
,
callback
},
{
call
,
put
})
{
*
remove
({
payload
,
callback
},
{
call
,
put
})
{
const
response
=
yield
call
(
apiRequest
,
api
+
'/remove'
,
payload
);
const
response
=
yield
call
(
apiRequest
,
api
+
'/remove'
,
payload
);
if
(
!
response
)
{
if
(
!
response
)
{
yield
put
({
type
:
'nom'
});
yield
put
({
type
:
'nom'
});
return
;
return
;
}
}
yield
put
({
yield
put
({
...
@@ -208,10 +212,10 @@ export default {
...
@@ -208,10 +212,10 @@ export default {
callback
();
callback
();
}
}
},
},
*
open
({
payload
,
callback
},
{
call
,
put
})
{
*
open
({
payload
,
callback
},
{
call
,
put
})
{
const
response
=
yield
call
(
apiRequest
,
api
+
'/open'
,
payload
);
const
response
=
yield
call
(
apiRequest
,
api
+
'/open'
,
payload
);
if
(
!
response
)
{
if
(
!
response
)
{
yield
put
({
type
:
'nom'
});
yield
put
({
type
:
'nom'
});
return
;
return
;
}
}
yield
put
({
yield
put
({
...
@@ -222,10 +226,10 @@ export default {
...
@@ -222,10 +226,10 @@ export default {
callback
();
callback
();
}
}
},
},
*
createTabel
({
payload
,
callback
},
{
call
,
put
})
{
*
createTabel
({
payload
,
callback
},
{
call
,
put
})
{
const
response
=
yield
call
(
apiRequest
,
api
+
'/createTable'
,
payload
);
const
response
=
yield
call
(
apiRequest
,
api
+
'/createTable'
,
payload
);
if
(
!
response
)
{
if
(
!
response
)
{
yield
put
({
type
:
'nom'
});
yield
put
({
type
:
'nom'
});
return
;
return
;
}
}
yield
put
({
yield
put
({
...
@@ -245,7 +249,7 @@ export default {
...
@@ -245,7 +249,7 @@ export default {
list
:
action
.
payload
,
list
:
action
.
payload
,
};
};
},
},
page
(
state
,
{
payload
})
{
page
(
state
,
{
payload
})
{
if
(
payload
.
isMain
)
{
if
(
payload
.
isMain
)
{
return
{
return
{
...
state
,
...
state
,
...
@@ -273,7 +277,7 @@ export default {
...
@@ -273,7 +277,7 @@ export default {
}
}
},
},
nom
(
state
,
action
)
{
nom
(
state
,
action
)
{
return
{
...
state
};
return
{
...
state
};
},
},
},
},
};
};
one_stop_public/utils/request.js
浏览文件 @
1727a6a9
...
@@ -5,10 +5,16 @@
...
@@ -5,10 +5,16 @@
import
{
extend
}
from
'umi-request'
;
import
{
extend
}
from
'umi-request'
;
import
{
notification
}
from
'antd'
;
import
{
notification
}
from
'antd'
;
import
{
getToken
}
from
'./token'
;
import
{
getToken
}
from
'./token'
;
import
{
queryApiActionPath
,
queryOauthActionPath
,
queryPermActionPath
,
queryDynamicActionPath
}
from
'./queryConfig'
;
import
{
queryApiActionPath
,
queryOauthActionPath
,
queryPermActionPath
,
queryDynamicActionPath
,
}
from
'./queryConfig'
;
import
{
openToast
}
from
'../location/Notification'
;
import
{
openToast
}
from
'../location/Notification'
;
import
{
showToast
}
from
'../location/Toast'
;
import
{
showToast
}
from
'../location/Toast'
;
import
{
offline
}
from
'../location/Toast'
;
import
{
offline
}
from
'../location/Toast'
;
const
codeMessage
=
{
const
codeMessage
=
{
200
:
'服务器成功返回请求的数据。'
,
200
:
'服务器成功返回请求的数据。'
,
201
:
'新建或修改数据成功。'
,
201
:
'新建或修改数据成功。'
,
...
@@ -33,7 +39,17 @@ const codeMessage = {
...
@@ -33,7 +39,17 @@ const codeMessage = {
*
*
* return URL参数字符串
* return URL参数字符串
*/
*/
const
objectToQuery
=
function
(
param
,
key
,
encode
)
{
const
qqCw
=
({
title
=
'请求错误'
,
msg
=
''
,
customErrMsg
=
''
})
=>
{
// 请求错误 增加自定义错误提示信息
notification
.
error
({
message
:
title
,
description
:
customErrMsg
||
msg
,
});
return
undefined
;
};
const
objectToQuery
=
function
(
param
,
key
,
encode
)
{
if
(
param
==
null
)
return
''
;
if
(
param
==
null
)
return
''
;
var
paramStr
=
''
;
var
paramStr
=
''
;
var
t
=
typeof
param
;
var
t
=
typeof
param
;
...
@@ -56,9 +72,8 @@ const errorHandler = error => {
...
@@ -56,9 +72,8 @@ const errorHandler = error => {
if
(
response
&&
response
.
status
)
{
if
(
response
&&
response
.
status
)
{
const
errorText
=
codeMessage
[
response
.
status
]
||
response
.
statusText
;
const
errorText
=
codeMessage
[
response
.
status
]
||
response
.
statusText
;
notification
.
error
({
qqCw
({
message
:
`请求错误`
,
msg
:
errorText
,
description
:
errorText
,
});
});
if
(
response
.
status
===
401
)
{
if
(
response
.
status
===
401
)
{
// @HACK
// @HACK
...
@@ -84,6 +99,9 @@ const errorHandler = error => {
...
@@ -84,6 +99,9 @@ const errorHandler = error => {
/**
/**
* 配置request请求时的默认参数
* 配置request请求时的默认参数
*/
*/
const
umiRequest
=
extend
({
const
umiRequest
=
extend
({
errorHandler
,
// 默认错误处理
errorHandler
,
// 默认错误处理
credentials
:
'omit'
,
// 默认请求是否带上cookie
credentials
:
'omit'
,
// 默认请求是否带上cookie
...
@@ -134,8 +152,8 @@ export const request = (url, data, options = {}) => {
...
@@ -134,8 +152,8 @@ export const request = (url, data, options = {}) => {
window
.
location
.
href
=
x
.
mobileAdress
window
.
location
.
href
=
x
.
mobileAdress
?
mobileAdress
+
'?timeVersion='
+
time
?
mobileAdress
+
'?timeVersion='
+
time
:
ul
.
indexOf
(
'?'
)
>
-
1
:
ul
.
indexOf
(
'?'
)
>
-
1
?
ul
+
'&timeVersion='
+
time
?
ul
+
'&timeVersion='
+
time
:
ul
+
'?timeVersion='
+
time
;
:
ul
+
'?timeVersion='
+
time
;
}
else
{
}
else
{
sessionStorage
.
removeItem
(
'cacheMobile'
);
sessionStorage
.
removeItem
(
'cacheMobile'
);
openToast
(
'error'
,
'版本更新'
,
'检查到最新版本,即将自动更新,更新完成后请重新操作'
);
openToast
(
'error'
,
'版本更新'
,
'检查到最新版本,即将自动更新,更新完成后请重新操作'
);
...
@@ -143,8 +161,8 @@ export const request = (url, data, options = {}) => {
...
@@ -143,8 +161,8 @@ export const request = (url, data, options = {}) => {
window
.
location
.
href
=
x
.
webAdress
window
.
location
.
href
=
x
.
webAdress
?
x
.
webAdress
+
'?timeVersion='
+
time
?
x
.
webAdress
+
'?timeVersion='
+
time
:
ul
.
indexOf
(
'?'
)
>
-
1
:
ul
.
indexOf
(
'?'
)
>
-
1
?
ul
+
'&timeVersion='
+
time
?
ul
+
'&timeVersion='
+
time
:
ul
+
'?timeVersion='
+
time
;
:
ul
+
'?timeVersion='
+
time
;
}
}
setTimeout
(()
=>
location
.
reload
(),
3000
);
setTimeout
(()
=>
location
.
reload
(),
3000
);
}
}
...
@@ -161,16 +179,16 @@ export const request = (url, data, options = {}) => {
...
@@ -161,16 +179,16 @@ export const request = (url, data, options = {}) => {
if
(
!
response
)
return
;
if
(
!
response
)
return
;
if
(
response
.
errCode
||
response
.
errMsg
)
{
if
(
response
.
errCode
||
response
.
errMsg
)
{
notification
.
error
({
qqCw
({
m
essage
:
`请求错误`
,
m
sg
:
response
.
errMsg
,
description
:
response
.
e
rrMsg
,
customErrMsg
:
pp
.
customE
rrMsg
,
});
});
return
;
return
;
}
}
if
(
response
.
errcode
)
{
if
(
response
.
errcode
)
{
notification
.
error
({
qqCw
({
m
essage
:
`请求错误`
,
m
sg
:
response
.
errmsg
,
description
:
response
.
errm
sg
,
customErrMsg
:
pp
.
customErrM
sg
,
});
});
return
;
return
;
}
}
...
@@ -178,7 +196,11 @@ export const request = (url, data, options = {}) => {
...
@@ -178,7 +196,11 @@ export const request = (url, data, options = {}) => {
return
response
;
return
response
;
});
});
}
else
{
}
else
{
const
pp
=
{
...
data
,
token
:
getToken
(),
version_
:
version
};
const
pp
=
{
...
data
,
token
:
getToken
(),
version_
:
version
,
};
for
(
let
i
in
pp
)
{
for
(
let
i
in
pp
)
{
if
(
pp
[
i
]
==
null
)
{
if
(
pp
[
i
]
==
null
)
{
...
@@ -209,8 +231,8 @@ export const request = (url, data, options = {}) => {
...
@@ -209,8 +231,8 @@ export const request = (url, data, options = {}) => {
window
.
location
.
href
=
x
.
mobileAdress
window
.
location
.
href
=
x
.
mobileAdress
?
mobileAdress
+
'?timeVersion='
+
time
?
mobileAdress
+
'?timeVersion='
+
time
:
ul
.
indexOf
(
'?'
)
>
-
1
:
ul
.
indexOf
(
'?'
)
>
-
1
?
ul
+
'&timeVersion='
+
time
?
ul
+
'&timeVersion='
+
time
:
ul
+
'?timeVersion='
+
time
;
:
ul
+
'?timeVersion='
+
time
;
}
else
{
}
else
{
sessionStorage
.
removeItem
(
'cacheMobile'
);
sessionStorage
.
removeItem
(
'cacheMobile'
);
openToast
(
'error'
,
'版本更新'
,
'检查到最新版本,即将自动更新,更新完成后请重新操作'
);
openToast
(
'error'
,
'版本更新'
,
'检查到最新版本,即将自动更新,更新完成后请重新操作'
);
...
@@ -218,8 +240,8 @@ export const request = (url, data, options = {}) => {
...
@@ -218,8 +240,8 @@ export const request = (url, data, options = {}) => {
window
.
location
.
href
=
x
.
webAdress
window
.
location
.
href
=
x
.
webAdress
?
x
.
webAdress
+
'?timeVersion='
+
time
?
x
.
webAdress
+
'?timeVersion='
+
time
:
ul
.
indexOf
(
'?'
)
>
-
1
:
ul
.
indexOf
(
'?'
)
>
-
1
?
ul
+
'&timeVersion='
+
time
?
ul
+
'&timeVersion='
+
time
:
ul
+
'?timeVersion='
+
time
;
:
ul
+
'?timeVersion='
+
time
;
}
}
setTimeout
(()
=>
location
.
reload
(),
3000
);
setTimeout
(()
=>
location
.
reload
(),
3000
);
}
}
...
@@ -235,17 +257,17 @@ export const request = (url, data, options = {}) => {
...
@@ -235,17 +257,17 @@ export const request = (url, data, options = {}) => {
if
(
!
response
)
return
;
if
(
!
response
)
return
;
if
(
response
.
errCode
||
response
.
errMsg
)
{
if
(
response
.
errCode
||
response
.
errMsg
)
{
notification
.
error
({
qqCw
({
m
essage
:
`请求错误`
,
m
sg
:
response
.
errMsg
,
description
:
response
.
e
rrMsg
,
customErrMsg
:
pp
.
customE
rrMsg
,
})
;
})
return
;
return
;
}
}
if
(
response
.
errcode
)
{
if
(
response
.
errcode
)
{
notification
.
error
({
qqCw
({
m
essage
:
`请求错误`
,
m
sg
:
response
.
errmsg
,
description
:
response
.
errm
sg
,
customErrMsg
:
pp
.
customErrM
sg
,
})
;
})
return
;
return
;
}
}
canReportError
=
true
;
canReportError
=
true
;
...
@@ -272,7 +294,10 @@ const createServerRequest = (config = {}) => {
...
@@ -272,7 +294,10 @@ const createServerRequest = (config = {}) => {
return
setRequestConfig
(
config
);
return
setRequestConfig
(
config
);
};
};
export
const
dynamicRequest
=
createServerRequest
({
method
:
'POST'
,
prefix
:
queryDynamicActionPath
()
});
export
const
dynamicRequest
=
createServerRequest
({
method
:
'POST'
,
prefix
:
queryDynamicActionPath
(),
});
export
const
uaaRequest
=
createServerRequest
({
method
:
'POST'
,
prefix
:
queryOauthActionPath
()
});
export
const
uaaRequest
=
createServerRequest
({
method
:
'POST'
,
prefix
:
queryOauthActionPath
()
});
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论