Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
WebPublic
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
前端开发小组
WebPublic
Commits
62236816
提交
62236816
authored
2月 08, 2023
作者:
钟是志
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
23013 学生事务/学生医保管理/学生平安险/保险办理,2001010248 高职界面已购买 导入 报错【接口超时】
上级
60e38016
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
599 行增加
和
467 行删除
+599
-467
ImportUtil.js
one_stop_public/App/ImportUtil.js
+465
-413
ImportUtil.less
one_stop_public/App/ImportUtil.less
+67
-54
ProgressDiy.js
one_stop_public/App/ProgressDiy.js
+54
-0
DataObj.js
one_stop_public/models/DataObj.js
+13
-0
没有找到文件。
one_stop_public/App/ImportUtil.js
浏览文件 @
62236816
...
...
@@ -9,455 +9,507 @@ import { connect } from 'dva';
import
{
getMessage
,
getModal
}
from
'@/webPublic/one_stop_public/utils/utils'
;
import
{
giveFilePostDataInfoForTrue
}
from
'@/webPublic/one_stop_public/Base16'
;
import
{
getTransformApi
}
from
'@/webPublic/one_stop_public/2022beidianke/localstorageTransform'
;
import
ProgressDiy
from
'./ProgressDiy'
;
const
Modal
=
getModal
();
const
message
=
getMessage
();
const
Step
=
Steps
.
Step
;
const
TabPane
=
Tabs
.
TabPane
;
let
tempCallback
=
()
=>
{
};
let
tempCallback
=
()
=>
{
};
@
connect
(({
DataObj
,
loading
})
=>
({
DataObj
,
loading
:
loading
.
models
.
DataObj
,
@
connect
(({
DataObj
,
loading
,
})
=>
({
DataObj
,
loading
:
loading
.
models
.
DataObj
,
}))
export
default
class
ImportUtil
extends
React
.
PureComponent
{
constructor
(
props
)
{
super
(
props
);
tempCallback
=
this
.
props
.
callback
;
constructor
(
props
)
{
super
(
props
);
tempCallback
=
this
.
props
.
callback
;
this
.
state
=
{
ch
:
false
,
currentKey
:
'1'
,
visible
:
false
,
current
:
0
,
isShow
:
true
,
fileCacheKey
:
''
,
sucData
:
[],
errData
:
[],
column
:
[],
confirmLoading
:
false
,
// exportTemplateUrl,
this
.
state
=
{
ch
:
false
,
currentKey
:
'1'
,
visible
:
false
,
current
:
0
,
isShow
:
true
,
fileCacheKey
:
''
,
sucData
:
[],
errData
:
[],
column
:
[],
confirmLoading
:
false
,
openProgress
:
false
,
// exportTemplateUrl,
isNextDisabled
:
false
,
};
}
isNextDisabled
:
false
,
};
}
showModal
=
()
=>
{
this
.
setState
({
sucData
:
[],
errData
:
[],
column
:
[],
current
:
0
,
isShow
:
true
,
isNextDisabled
:
false
,
fileCacheKey
:
''
,
visible
:
true
,
});
};
handleOk
=
(
e
)
=>
{
this
.
setState
({
visible
:
false
,
});
};
handleCancel
=
(
e
)
=>
{
this
.
setState
({
visible
:
false
,
});
};
showModal
=
()
=>
{
this
.
setState
({
sucData
:
[],
errData
:
[],
column
:
[],
current
:
0
,
isShow
:
true
,
isNextDisabled
:
false
,
fileCacheKey
:
''
,
visible
:
true
,
});
};
handleOk
=
(
e
)
=>
{
this
.
setState
({
visible
:
false
,
});
};
handleCancel
=
(
e
)
=>
{
this
.
setState
({
visible
:
false
,
});
};
next
()
{
const
current
=
this
.
state
.
current
+
1
;
if
(
current
===
2
)
{
this
.
setState
({
current
:
current
,
isShow
:
false
,
});
if
(
this
.
state
.
errData
.
lenth
>
0
)
{
message
.
error
(
'请检查数据'
);
return
;
}
else
{
this
.
import
();
}
}
if
(
current
===
3
)
{
console
.
log
(
'current === 3'
);
this
.
setState
(
{
current
:
current
,
isShow
:
true
,
},
()
=>
{
if
(
tempCallback
&&
typeof
tempCallback
===
'function'
)
{
tempCallback
();
tempCallback
=
null
;
}
},
);
}
}
next
()
{
const
current
=
this
.
state
.
current
+
1
;
if
(
current
===
2
)
{
this
.
setState
({
current
:
current
,
isShow
:
false
,
});
if
(
this
.
state
.
errData
.
lenth
>
0
)
{
message
.
error
(
'请检查数据'
);
return
;
}
else
{
this
.
import
();
}
}
if
(
current
===
3
)
{
// 导入完成后
console
.
log
(
'current === 3'
);
this
.
setState
(
{
current
:
current
,
isShow
:
true
,
},
()
=>
{
if
(
tempCallback
&&
typeof
tempCallback
===
'function'
)
{
tempCallback
();
tempCallback
=
null
;
}
},
);
}
}
prev
()
{
const
current
=
this
.
state
.
current
-
1
;
this
.
setState
({
current
});
}
prev
()
{
const
current
=
this
.
state
.
current
-
1
;
this
.
setState
({
current
});
}
import
()
{
const
{
dispatch
,
importParams
,
importConfig
}
=
this
.
props
;
dispatch
({
type
:
'DataObj/importExecute'
,
payload
:
{
...(
importParams
||
{}),
cacheKey
:
this
.
state
.
fileCacheKey
,
objId
:
this
.
props
.
objId
,
},
callback
:
(
res
)
=>
{
this
.
next
();
message
.
success
(
'导入成功'
);
changeOpenProgress
=
(
v
)
=>
{
if
(
v
===
false
)
{
this
.
next
();
message
.
success
(
'导入成功'
);
this
.
setState
({
current
:
3
,
isShow
:
true
,
visible
:
false
,
});
}
};
this
.
setState
({
current
:
3
,
isShow
:
true
,
visible
:
false
,
});
import
()
{
const
{
dispatch
,
importParams
,
}
=
this
.
props
;
dispatch
({
type
:
'DataObj/importExecute'
,
payload
:
{
...(
importParams
||
{}),
cacheKey
:
this
.
state
.
fileCacheKey
,
objId
:
this
.
props
.
objId
,
},
callback
:
(
res
)
=>
{
if
(
res
&&
res
.
sync
===
false
&&
res
.
total
)
{
// 23013 学生事务/学生医保管理/学生平安险/保险办理,2001010248 高职界面已购买 导入 报错【接口超时】
this
.
setState
({
openProgress
:
res
,
});
return
;
}
},
});
}
this
.
next
();
message
.
success
(
'导入成功'
);
this
.
setState
({
current
:
3
,
isShow
:
true
,
visible
:
false
,
});
getCachKey
=
(
filePath
)
=>
{
const
{
dispatch
,
importParams
,
importConfig
}
=
this
.
props
;
dispatch
({
type
:
'DataObj/importAnalyse'
,
payload
:
{
...(
importParams
||
{}),
isLocal
:
false
,
filePath
,
},
});
}
importConfig
:
importConfig
?
JSON
.
stringify
(
importConfig
)
:
null
,
objId
:
this
.
props
.
objId
,
},
callback
:
(
res
)
=>
{
this
.
setState
({
// TODO 23013 学生事务/学生医保管理/学生平安险/保险办理,2001010248 高职界面已购买 导入 报错【接口超时】
fileCacheKey
:
res
.
cacheKey
,
});
this
.
queryFile
(
res
.
cacheKey
);
},
});
};
queryFile
=
(
cacheKey
)
=>
{
const
{
dispatch
,
importParams
}
=
this
.
props
;
dispatch
({
type
:
'DataObj/importDataQuery'
,
payload
:
{
...(
importParams
||
{}),
cacheKey
,
objId
:
this
.
props
.
objId
,
},
callback
:
(
res
)
=>
{
this
.
setState
({
current
:
1
,
isShow
:
false
,
getCachKey
=
(
filePath
)
=>
{
const
{
dispatch
,
importParams
,
importConfig
,
}
=
this
.
props
;
dispatch
({
type
:
'DataObj/importAnalyse'
,
payload
:
{
...(
importParams
||
{}),
isLocal
:
false
,
filePath
,
sucData
:
res
.
pass
,
errData
:
res
.
noPass
,
column
:
res
.
column
,
});
if
(
res
.
noPass
&&
res
.
noPass
.
length
===
0
)
{
if
(
res
.
pass
.
length
===
0
)
{
message
.
error
(
'当前没有验证成功的数据,无法导入。'
);
this
.
setState
({
currentKey
:
'1'
,
ch
:
!
this
.
state
.
ch
,
isNextDisabled
:
true
,
});
}
else
{
message
.
success
(
'所有数据验证通过,请确认后点击下一步。'
);
this
.
setState
({
currentKey
:
'2'
,
ch
:
!
this
.
state
.
ch
,
isNextDisabled
:
false
,
});
}
}
else
{
message
.
error
(
'当前存在未验证通过的数据,请按错误提示检测更正导入文件'
);
this
.
setState
({
currentKey
:
'1'
,
ch
:
!
this
.
state
.
ch
,
isNextDisabled
:
true
,
});
}
},
});
};
importConfig
:
importConfig
?
JSON
.
stringify
(
importConfig
)
:
null
,
objId
:
this
.
props
.
objId
,
},
callback
:
(
res
)
=>
{
this
.
setState
({
fileCacheKey
:
res
.
cacheKey
,
});
this
.
queryFile
(
res
.
cacheKey
);
},
});
};
queryFile
=
(
cacheKey
)
=>
{
const
{
dispatch
,
importParams
,
}
=
this
.
props
;
dispatch
({
type
:
'DataObj/importDataQuery'
,
payload
:
{
...(
importParams
||
{}),
cacheKey
,
objId
:
this
.
props
.
objId
,
},
callback
:
(
res
)
=>
{
this
.
setState
({
current
:
1
,
isShow
:
false
,
changePane
=
(
activeKey
)
=>
{
this
.
setState
({
currentKey
:
activeKey
});
};
sucData
:
res
.
pass
,
errData
:
res
.
noPass
,
column
:
res
.
column
,
});
if
(
res
.
noPass
&&
res
.
noPass
.
length
===
0
)
{
if
(
res
.
pass
.
length
===
0
)
{
message
.
error
(
'当前没有验证成功的数据,无法导入。'
);
this
.
setState
({
currentKey
:
'1'
,
ch
:
!
this
.
state
.
ch
,
isNextDisabled
:
true
,
});
}
else
{
message
.
success
(
'所有数据验证通过,请确认后点击下一步。'
);
this
.
setState
({
currentKey
:
'2'
,
ch
:
!
this
.
state
.
ch
,
isNextDisabled
:
false
,
});
}
}
else
{
message
.
error
(
'当前存在未验证通过的数据,请按错误提示检测更正导入文件'
);
this
.
setState
({
currentKey
:
'1'
,
ch
:
!
this
.
state
.
ch
,
isNextDisabled
:
true
,
});
}
},
});
};
changePane
=
(
activeKey
)
=>
{
this
.
setState
({
currentKey
:
activeKey
});
};
downloadFile
=
async
()
=>
{
this
.
setState
({
confirmLoading
:
true
});
const
{
objId
,
fileName
,
importParams
,
importConfig
}
=
this
.
props
;
const
params
=
{
...
importParams
,
importConfig
:
importConfig
?
JSON
.
stringify
(
importConfig
)
:
null
,
objId
,
fileName
,
};
let
url
=
`
${
config
.
httpServer
}
/DataObjApi/importTemplateDownload`
;
let
newParams
=
giveFilePostDataInfoForTrue
(
params
,
url
);
if
(
newParams
&&
newParams
.
datas
)
{
newParams
.
datas
.
token
=
getToken
();
}
const
{
transformApi
,
headersApi
}
=
await
getTransformApi
(
newParams
.
url
);
fetch
(
transformApi
,
{
method
:
'POST'
,
body
:
FormdataWrapper
(
newParams
.
datas
),
})
.
then
((
res
)
=>
{
console
.
log
(
res
.
status
);
if
(
res
.
status
!=
200
&&
res
.
status
!==
202
)
{
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
{
message
.
error
(
`文件导出错误`
);
}
})
.
catch
((
err
)
=>
{
console
.
error
(
err
);
message
.
error
(
`网络请求超时`
);
})
.
finally
(()
=>
{
this
.
setState
({
confirmLoading
:
false
});
});
};
downloadFile
=
async
()
=>
{
this
.
setState
({
confirmLoading
:
true
});
render
()
{
const
props
=
{
name
:
'file'
,
action
:
config
.
uploadUrl
,
headers
:
{
Authorization
:
`bearer
${
getToken
()}
`
,
},
data
:
{
token
:
getToken
(),
},
accept
:
'.xlsx'
,
showUploadList
:
false
,
onChange
:
(
info
)
=>
{
if
(
info
.
file
.
status
!==
'uploading'
)
{
}
if
(
info
.
file
.
status
===
'done'
)
{
message
.
success
(
`
${
info
.
file
.
name
}
上传成功`
);
let
x
=
info
.
file
.
response
;
const
{
objId
,
fileName
,
importParams
,
importConfig
,
}
=
this
.
props
;
const
params
=
{
...
importParams
,
importConfig
:
importConfig
?
JSON
.
stringify
(
importConfig
)
:
null
,
objId
,
fileName
,
};
let
url
=
`
${
config
.
httpServer
}
/DataObjApi/importTemplateDownload`
;
let
newParams
=
giveFilePostDataInfoForTrue
(
params
,
url
);
if
(
newParams
&&
newParams
.
datas
)
{
newParams
.
datas
.
token
=
getToken
();
}
const
{
transformApi
,
headersApi
,
}
=
await
getTransformApi
(
newParams
.
url
);
fetch
(
transformApi
,
{
method
:
'POST'
,
body
:
FormdataWrapper
(
newParams
.
datas
),
})
.
then
((
res
)
=>
{
console
.
log
(
res
.
status
);
if
(
res
.
status
!=
200
&&
res
.
status
!==
202
)
{
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
{
message
.
error
(
`文件导出错误`
);
}
})
.
catch
((
err
)
=>
{
console
.
error
(
err
);
message
.
error
(
`网络请求超时`
);
})
.
finally
(()
=>
{
this
.
setState
({
confirmLoading
:
false
});
});
};
this
.
getCachKey
(
x
);
}
else
if
(
info
.
file
.
status
===
'error'
)
{
message
.
error
(
`
${
info
.
file
.
name
}
上传失败`
);
}
},
};
const
steps
=
[
{
title
:
'上传Excel'
,
},
{
title
:
'验证数据'
,
},
{
title
:
'数据导入'
,
},
{
title
:
'导入完成'
,
},
];
render
()
{
const
props
=
{
name
:
'file'
,
action
:
config
.
uploadUrl
,
headers
:
{
Authorization
:
`bearer
${
getToken
()}
`
,
},
data
:
{
token
:
getToken
(),
},
accept
:
'.xlsx'
,
showUploadList
:
false
,
onChange
:
(
info
)
=>
{
if
(
info
.
file
.
status
!==
'uploading'
)
{
}
if
(
info
.
file
.
status
===
'done'
)
{
message
.
success
(
`
${
info
.
file
.
name
}
上传成功`
);
let
x
=
info
.
file
.
response
;
const
{
current
}
=
this
.
state
;
const
{
name
}
=
this
.
props
;
const
column1
=
this
.
state
.
column
?
[
{
title
:
'序号'
,
dataIndex
:
'index'
,
fixed
:
'left'
,
width
:
50
,
render
:
(
v
,
r
,
i
)
=>
i
+
1
,
},
{
title
:
'数据行数'
,
dataIndex
:
'row_index'
,
width
:
50
,
},
...
this
.
state
.
column
,
]
:
[];
let
column2
=
this
.
state
.
column
?
[{
title
:
'数据行数'
,
dataIndex
:
'row_index'
,
width
:
50
,
},
...
this
.
state
.
column
]
:
[];
if
(
column1
.
length
>
1
)
{
column1
[
1
].
render
=
(
val
)
=>
<
span
style
=
{{
color
:
'red'
}}
>
{
val
}
<
/span>
;
}
this
.
getCachKey
(
x
);
}
else
if
(
info
.
file
.
status
===
'error'
)
{
message
.
error
(
`
${
info
.
file
.
name
}
上传失败`
);
}
},
};
const
steps
=
[
{
title
:
'上传Excel'
,
},
{
title
:
'验证数据'
,
},
{
title
:
'数据导入'
,
},
{
title
:
'导入完成'
,
},
];
if
(
column2
)
{
let
xuhao
=
column2
.
find
((
g
)
=>
g
.
dataIndex
===
'序号'
);
if
(
!
xuhao
)
{
column2
.
unshift
({
title
:
'序号'
,
fixed
:
'left'
,
width
:
50
,
render
:
(
v
,
r
,
i
)
=>
i
+
1
,
dataIndex
:
'序号'
,
});
}
}
const
{
current
,
openProgress
,
fileCacheKey
,
}
=
this
.
state
;
const
{
name
}
=
this
.
props
;
const
column1
=
this
.
state
.
column
?
[
{
title
:
'序号'
,
dataIndex
:
'index'
,
fixed
:
'left'
,
width
:
50
,
render
:
(
v
,
r
,
i
)
=>
i
+
1
,
},
{
title
:
'数据行数'
,
dataIndex
:
'row_index'
,
width
:
50
,
},
...
this
.
state
.
column
,
]
:
[];
let
column2
=
this
.
state
.
column
?
[{
title
:
'数据行数'
,
dataIndex
:
'row_index'
,
width
:
50
,
},
...
this
.
state
.
column
]
:
[];
if
(
column1
.
length
>
1
)
{
column1
[
1
].
render
=
(
val
)
=>
<
span
style
=
{{
color
:
'red'
}}
>
{
val
}
<
/span>
;
}
const
btn
=
{
name
:
name
||
'批量导入'
,
type
:
'default'
,
className
:
'defaultBlue'
,
...(
this
.
props
.
btn
?
this
.
props
.
btn
:
{}),
};
if
(
column2
)
{
let
xuhao
=
column2
.
find
((
g
)
=>
g
.
dataIndex
===
'序号'
);
if
(
!
xuhao
)
{
column2
.
unshift
({
title
:
'序号'
,
fixed
:
'left'
,
width
:
50
,
render
:
(
v
,
r
,
i
)
=>
i
+
1
,
dataIndex
:
'序号'
,
});
}
}
return
(
<
span
>
const
btn
=
{
name
:
name
||
'批量导入'
,
type
:
'default'
,
className
:
'defaultBlue'
,
...(
this
.
props
.
btn
?
this
.
props
.
btn
:
{}),
};
return
(
<
span
>
<
ButtonDiy
{...
btn
}
handleClick
=
{
this
.
showModal
}
/
>
<
Modal
visible
=
{
this
.
state
.
visible
}
onOk
=
{
this
.
handleOk
}
maskClosable
=
{
false
}
destroyOnClose
onCancel
=
{
this
.
handleCancel
}
title
=
{
null
}
footer
=
{
null
}
width
=
{
'80%'
}
>
<
div
className
=
{
styles
.
nomal
}
>
<
p
className
=
{
styles
.
import
}
>
EXCEL
导入向导
<
/p
>
<
div
style
=
{{
margin
:
'auto 23px'
}}
>
<
Steps
current
=
{
current
}
>
{
steps
.
map
((
item
)
=>
(
<
Step
key
=
{
item
.
title
}
title
=
{
item
.
title
}
/
>
))}
<
/Steps
>
<
div
className
=
"steps-content"
>
{
steps
[
this
.
state
.
current
].
content
}
<
/div
>
<
div
className
=
{
styles
.
button
}
>
{
this
.
state
.
current
<
steps
.
length
-
1
&&
this
.
state
.
current
!==
0
&&
(
<
ButtonDiy
name
=
{
this
.
state
.
current
==
3
?
'确认导入'
:
'下一步'
}
type
=
"primary"
disabled
=
{
this
.
state
.
current
!=
3
&&
this
.
state
.
isNextDisabled
}
// className='primaryBlue'
handleClick
=
{()
=>
this
.
next
()}
/
>
)}
visible
=
{
this
.
state
.
visible
}
onOk
=
{
this
.
handleOk
}
maskClosable
=
{
false
}
destroyOnClose
onCancel
=
{
this
.
handleCancel
}
title
=
{
null
}
footer
=
{
null
}
width
=
{
'80%'
}
>
{
!!
openProgress
?
<
ProgressDiy
fileCacheKey
=
{
fileCacheKey
}
{...
openProgress
}
changeOpenProgress
=
{
this
.
changeOpenProgress
}
/>
:
<
div
className
=
{
styles
.
nomal
}
>
<
p
className
=
{
styles
.
import
}
>
EXCEL
导入向导
<
/p
>
<
div
style
=
{{
margin
:
'auto 23px'
}}
>
<
Steps
current
=
{
current
}
>
{
steps
.
map
((
item
)
=>
(
<
Step
key
=
{
item
.
title
}
title
=
{
item
.
title
}
/
>
))}
<
/Steps
>
<
div
className
=
'steps-content'
>
{
steps
[
this
.
state
.
current
].
content
}
<
/div
>
<
div
className
=
{
styles
.
button
}
>
{
this
.
state
.
current
<
steps
.
length
-
1
&&
this
.
state
.
current
!==
0
&&
(
<
ButtonDiy
name
=
{
this
.
state
.
current
==
3
?
'确认导入'
:
'下一步'
}
type
=
'primary'
disabled
=
{
this
.
state
.
current
!=
3
&&
this
.
state
.
isNextDisabled
}
// className='primaryBlue'
handleClick
=
{()
=>
this
.
next
()}
/
>
)}
{
this
.
state
.
current
>
0
&&
(
<
ButtonDiy
style
=
{{
marginLeft
:
8
}}
name
=
"上一步"
className
=
"defaultBlue"
handleClick
=
{()
=>
this
.
prev
()}
/
>
)}
<
/div
>
<
/div
>
{
this
.
state
.
current
>
0
&&
(
<
ButtonDiy
style
=
{{
marginLeft
:
8
}}
name
=
'上一步'
className
=
'defaultBlue'
handleClick
=
{()
=>
this
.
prev
()}
/
>
)}
<
/div
>
<
/div
>
<
div
className
=
{
styles
.
tip
}
>
<
p
className
=
{
styles
.
tipContent
}
>
<
span
>
欢迎使用
EXCEL
导入向导,首先请您上传需要导入的
EXCEL
文件。
<
/span
>
<
span
>
<
div
className
=
{
styles
.
tip
}
>
<
p
className
=
{
styles
.
tipContent
}
>
<
span
>
欢迎使用
EXCEL
导入向导,首先请您上传需要导入的
EXCEL
文件。
<
/span
>
<
span
>
点击“选择文件”选择您要导入的
EXCEL
文件,点击“开始上传”将其上传到服务器上,点击“清空队列”清空当前上传文件队列。
<
/span
>
<
/p
>
<
/div
>
{
this
.
state
.
isShow
?
(
<
div
className
=
{
styles
.
buttonDown
}
>
<
Upload
{...
props
}
>
<
Button
>
<
Icon
type
=
"upload"
/>
点击上传
<
/Button
>
<
/Upload
>
<
ButtonDiy
name
=
{
'下载模板'
}
type
=
"primary"
// className='primaryBlue'
handleClick
=
{()
=>
this
.
downloadFile
()}
loading
=
{
this
.
state
.
confirmLoading
}
/
>
<
/div
>
)
:
(
<
Upload
{...
props
}
>
<
Button
>
<
Icon
type
=
"upload"
/>
重新上传
<
/Button
>
<
/Upload
>
)}
<
/p
>
<
/div
>
{
this
.
state
.
isShow
?
(
<
div
className
=
{
styles
.
buttonDown
}
>
<
Upload
{...
props
}
>
<
Button
>
<
Icon
type
=
'upload'
/>
点击上传
<
/Button
>
<
/Upload
>
<
ButtonDiy
name
=
{
'下载模板'
}
type
=
'primary'
// className='primaryBlue'
handleClick
=
{()
=>
this
.
downloadFile
()}
loading
=
{
this
.
state
.
confirmLoading
}
/
>
<
/div
>
)
:
(
<
Upload
{...
props
}
>
<
Button
>
<
Icon
type
=
'upload'
/>
重新上传
<
/Button
>
<
/Upload
>
)}
{
this
.
state
.
isShow
?
(
<
div
className
=
{
styles
.
attentionItem
}
>
<
p
>
导入事项
<
/p
>
<
p
>
1
.
导入操作一次只能上传
1
个
EXCEL
文件。
<
/p
>
<
p
>
2
.
导入文件最大文件大小上传
1
GB
。
<
/p
>
<
p
>
3
.
只能上传
EXCEL
文件
(
XLS
,
XLSX
)
默认支持
EXCEL
2003
和
EXCEL
2007
。
<
/p
>
<
p
>
4
.
请将
EXCEL
文件的所有单元格格式设置为“文本”格式
<
/p
>
<
/div
>
)
:
(
<
div
className
=
{
styles
.
error
}
style
=
{{
marginTop
:
20
}}
>
<
Tabs
activeKey
=
{
this
.
state
.
currentKey
}
key
=
{
this
.
state
.
ch
}
onChange
=
{
this
.
changePane
}
type
=
"card"
>
{
this
.
state
.
errData
&&
this
.
state
.
errData
.
length
==
0
?
(
''
)
:
(
<
TabPane
tab
=
{
<
span
style
=
{{
color
:
'red'
}}
>
验证错误列表
<
/span>} key="1"
>
<
Table
columns
=
{
column1
}
size
=
"small"
style
=
{{
overflow
:
'auto'
}}
dataSource
=
{
this
.
state
.
errData
}
bordered
=
{
true
}
scroll
=
{{
x
:
'max-content'
}}
/
>
<
/TabPane
>
)}
<
TabPane
tab
=
{
<
span
style
=
{{
color
:
'green'
}}
>
验证成功列表
<
/span>} key="2"
>
<
Table
columns
=
{
column2
}
size
=
"small"
style
=
{{
overflow
:
'auto'
}}
dataSource
=
{
this
.
state
.
sucData
}
bordered
=
{
true
}
scroll
=
{{
x
:
'max-content'
}}
/
>
<
/TabPane
>
<
/Tabs
>
<
/div
>
)}
<
/div
>
{
this
.
state
.
isShow
?
(
<
div
className
=
{
styles
.
attentionItem
}
>
<
p
>
导入事项
<
/p
>
<
p
>
1
.
导入操作一次只能上传
1
个
EXCEL
文件。
<
/p
>
<
p
>
2
.
导入文件最大文件大小上传
1
GB
。
<
/p
>
<
p
>
3
.
只能上传
EXCEL
文件
(
XLS
,
XLSX
)
默认支持
EXCEL
2003
和
EXCEL
2007
。
<
/p
>
<
p
>
4
.
请将
EXCEL
文件的所有单元格格式设置为“文本”格式
<
/p
>
<
/div
>
)
:
(
<
div
className
=
{
styles
.
error
}
style
=
{{
marginTop
:
20
}}
>
<
Tabs
activeKey
=
{
this
.
state
.
currentKey
}
key
=
{
this
.
state
.
ch
}
onChange
=
{
this
.
changePane
}
type
=
'card'
>
{
this
.
state
.
errData
&&
this
.
state
.
errData
.
length
==
0
?
(
''
)
:
(
<
TabPane
tab
=
{
<
span
style
=
{{
color
:
'red'
}}
>
验证错误列表
<
/span>} key='1'
>
<
Table
columns
=
{
column1
}
size
=
'small'
style
=
{{
overflow
:
'auto'
}}
dataSource
=
{
this
.
state
.
errData
}
bordered
=
{
true
}
scroll
=
{{
x
:
'max-content'
}}
/
>
<
/TabPane
>
)}
<
TabPane
tab
=
{
<
span
style
=
{{
color
:
'green'
}}
>
验证成功列表
<
/span>} key='2'
>
<
Table
columns
=
{
column2
}
size
=
'small'
style
=
{{
overflow
:
'auto'
}}
dataSource
=
{
this
.
state
.
sucData
}
bordered
=
{
true
}
scroll
=
{{
x
:
'max-content'
}}
/
>
<
/TabPane
>
<
/Tabs
>
<
/div
>
)}
<
/div
>
}
<
/Modal
>
<
/span
>
);
}
);
}
}
one_stop_public/App/ImportUtil.less
浏览文件 @
62236816
...
...
@@ -3,7 +3,7 @@
padding: 10px;
}
.title{
display: flex;
display: flex;
margin-bottom: 20px;
}
.info{
...
...
@@ -19,36 +19,36 @@
margin: auto 10px;
}
.button{
display: -webkit-box; /* 老版本语法: Safari, iOS, Android browser, older WebKit browsers. */
display: -moz-box; /* 老版本语法: Firefox (buggy) */
display: -ms-flexbox; /* 混合版本语法: IE 10 */
display: -webkit-flex; /* 新版本语法: Chrome 21+ */
display: -moz-flex;
display: flex;
-moz-box-pack: center; /*Firefox*/
-webkit-box-pack: center; /*Safari,Opera,Chrome*/
box-pack: center;
-moz-justify-content: center;
-webkit-justify-content: center;
justify-content: center;
display: -webkit-box; /* 老版本语法: Safari, iOS, Android browser, older WebKit browsers. */
display: -moz-box; /* 老版本语法: Firefox (buggy) */
display: -ms-flexbox; /* 混合版本语法: IE 10 */
display: -webkit-flex; /* 新版本语法: Chrome 21+ */
display: -moz-flex;
display: flex;
-moz-box-pack: center; /*Firefox*/
-webkit-box-pack: center; /*Safari,Opera,Chrome*/
box-pack: center;
-moz-justify-content: center;
-webkit-justify-content: center;
justify-content: center;
}
.operation{
display: -webkit-box; /* 老版本语法: Safari, iOS, Android browser, older WebKit browsers. */
display: -moz-box; /* 老版本语法: Firefox (buggy) */
display: -ms-flexbox; /* 混合版本语法: IE 10 */
display: -webkit-flex; /* 新版本语法: Chrome 21+ */
display: -moz-flex;
display: flex;
-moz-box-pack: center; /*Firefox*/
-webkit-box-pack: center; /*Safari,Opera,Chrome*/
box-pack: center;
-moz-justify-content: center;
-webkit-justify-content: center;
justify-content: center;
display: -webkit-box; /* 老版本语法: Safari, iOS, Android browser, older WebKit browsers. */
display: -moz-box; /* 老版本语法: Firefox (buggy) */
display: -ms-flexbox; /* 混合版本语法: IE 10 */
display: -webkit-flex; /* 新版本语法: Chrome 21+ */
display: -moz-flex;
display: flex;
-moz-box-pack: center; /*Firefox*/
-webkit-box-pack: center; /*Safari,Opera,Chrome*/
box-pack: center;
-moz-justify-content: center;
-webkit-justify-content: center;
justify-content: center;
}
.button Button{
margin: auto 10px;
}
.titleInfo p span{
font-weight: bold;
...
...
@@ -106,25 +106,25 @@
margin-left: 34px;
}
.contentTable{
display: -webkit-box; /* 老版本语法: Safari, iOS, Android browser, older WebKit browsers. */
display: -moz-box; /* 老版本语法: Firefox (buggy) */
display: -ms-flexbox; /* 混合版本语法: IE 10 */
display: -webkit-flex; /* 新版本语法: Chrome 21+ */
display: -moz-flex;
display: flex;
-moz-box-pack: justify; /*Firefox*/
-webkit-box-pack:justify; /*Safari,Opera,Chrome*/
box-pack: justify;
-moz-justify-content: space-between;
-webkit-justify-content: space-between;
justify-content: space-between;
display: -webkit-box; /* 老版本语法: Safari, iOS, Android browser, older WebKit browsers. */
display: -moz-box; /* 老版本语法: Firefox (buggy) */
display: -ms-flexbox; /* 混合版本语法: IE 10 */
display: -webkit-flex; /* 新版本语法: Chrome 21+ */
display: -moz-flex;
display: flex;
-moz-box-pack: justify; /*Firefox*/
-webkit-box-pack:justify; /*Safari,Opera,Chrome*/
box-pack: justify;
-moz-justify-content: space-between;
-webkit-justify-content: space-between;
justify-content: space-between;
margin-top: 20px;
}
.left{
width: 50%;
}
.right{
width: 50%;
width: 50%;
border-left: 1px solid #317ecc;
}
.error p{
...
...
@@ -136,7 +136,7 @@
}
.download{
background: #f5f5f5;
padding: 5px;
padding: 5px;
margin-top: -16px;
}
.download img{
...
...
@@ -154,18 +154,18 @@
border-right: 1px solid #ccc;
}
.buttonDown{
display: -webkit-box; /* 老版本语法: Safari, iOS, Android browser, older WebKit browsers. */
display: -moz-box; /* 老版本语法: Firefox (buggy) */
display: -ms-flexbox; /* 混合版本语法: IE 10 */
display: -webkit-flex; /* 新版本语法: Chrome 21+ */
display: -moz-flex;
display: flex;
-moz-box-pack: start; /*Firefox*/
-webkit-box-pack: start; /*Safari,Opera,Chrome*/
box-pack: start;
-moz-justify-content: flex-start;
-webkit-justify-content: flex-start;
justify-content: flex-start;
display: -webkit-box; /* 老版本语法: Safari, iOS, Android browser, older WebKit browsers. */
display: -moz-box; /* 老版本语法: Firefox (buggy) */
display: -ms-flexbox; /* 混合版本语法: IE 10 */
display: -webkit-flex; /* 新版本语法: Chrome 21+ */
display: -moz-flex;
display: flex;
-moz-box-pack: start; /*Firefox*/
-webkit-box-pack: start; /*Safari,Opera,Chrome*/
box-pack: start;
-moz-justify-content: flex-start;
-webkit-justify-content: flex-start;
justify-content: flex-start;
margin-bottom: 20px;
}
.buttonDown>button{
...
...
@@ -175,4 +175,18 @@
color: #fff;
padding: 5px 12px;
border-radius: 5px;
}
\ No newline at end of file
}
.juzhongSpin{
min-height: 300px;
width: 100%;
display: grid;
align-items: center;
justify-items: center;
}
.textCenter{
margin-top: 20px;
text-align: center;
}
one_stop_public/App/ProgressDiy.js
0 → 100644
浏览文件 @
62236816
import
React
,
{
useEffect
,
useState
,
useRef
}
from
'react'
;
import
{
Progress
,
message
}
from
'antd'
;
import
styles
from
'./ImportUtil.less'
;
import
{
connect
}
from
'dva'
;
function
ProgressDiy
(
props
)
{
const
{
fileCacheKey
,
dispatch
,
changeOpenProgress
=
()
=>
{}
}
=
props
;
const
interv
=
useRef
();
const
[
speedData
,
setData
]
=
useState
({
...
props
});
useEffect
(()
=>
{
interv
.
current
=
setInterval
(()
=>
{
dispatch
({
type
:
'DataObj/importProcess'
,
payload
:
{
cacheKey
:
fileCacheKey
,
},
callback
:
res
=>
{
setData
(
res
);
if
(
res
.
finished
)
{
clearInterval
(
interv
.
current
);
message
.
success
(
'导入完成'
);
// changeOpenProgress(false); // 导入成功
}
},
});
},
1000
);
},
[]);
return
(
<
div
className
=
{
styles
.
juzhongSpin
}
>
<
div
style
=
{{
textAlign
:
'center'
}}
>
<
Progress
type
=
"circle"
strokeColor
=
{{
'0%'
:
'#108ee9'
,
'100%'
:
'#87d068'
,
}}
percent
=
{
speedData
.
finished
?
100
:
(
speedData
.
success
+
speedData
.
fail
)
/
speedData
.
total
}
status
=
{
speedData
.
finished
?
'success '
:
'active'
}
format
=
{
percent
=>
`
${
speedData
.
success
+
speedData
.
fail
}
/
${
speedData
.
total
}
`
}
/
>
<
div
className
=
{
styles
.
textCenter
}
>
正在处理导入数据
:
共计
{
speedData
.
total
}
条
已处理
{
speedData
.
success
+
speedData
.
fail
}
条
.
<
/div
>
<
/div
>
<
/div
>
);
}
export
default
connect
(({
DataObj
,
loading
})
=>
({
DataObj
,
}))(
ProgressDiy
);
one_stop_public/models/DataObj.js
浏览文件 @
62236816
...
...
@@ -42,6 +42,19 @@ export default {
});
if
(
callback
)
callback
(
response
);
},
*
importProcess
({
payload
,
callback
},
{
call
,
put
})
{
const
response
=
yield
call
(
apiRequest
,
api
+
'/importProcess'
,
payload
);
if
(
!
response
)
{
yield
put
({
type
:
'nom'
});
return
;
}
yield
put
({
type
:
'nom'
,
payload
:
response
,
});
if
(
callback
)
callback
(
response
);
},
*
importExecute
({
payload
,
callback
},
{
call
,
put
})
{
const
response
=
yield
call
(
apiRequest
,
api
+
'/importExecute'
,
{
...
payload
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论