Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
emport-web
Overview
Overview
Details
Activity
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
刘泽志
emport-web
Commits
12f2ed43
Commit
12f2ed43
authored
Feb 10, 2023
by
刘泽志
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
文档上传
parent
bb8f553e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
228 additions
and
20 deletions
+228
-20
Emport.js
src/api/emport/Emport.js
+64
-0
AutoLoading.vue
src/views/emport/emport/AutoLoading.vue
+65
-0
index.vue
src/views/emport/emport/index.vue
+99
-20
No files found.
src/api/emport/Emport.js
View file @
12f2ed43
...
@@ -332,6 +332,44 @@ export function uploadExcel(data) {
...
@@ -332,6 +332,44 @@ export function uploadExcel(data) {
}
}
/**
/**
* 下载模板
* @param excelId
* @returns {*}
*/
export
function
downloadTemplate
(
excelId
)
{
return
request
({
url
:
`
${
prefix
}
/template/download`
,
method
:
'get'
,
params
:{
excelId
},
headers
:
{
"Content-Type"
:
"application/x-www-form-urlencoded"
},
responseType
:
"blob"
,
})
}
/**
* 下载模板
* @param excelId
* @returns {*}
*/
export
function
getTemplateFileName
(
excelId
)
{
return
request
({
url
:
`
${
prefix
}
/template/download/filename`
,
method
:
'get'
,
params
:{
excelId
}
})
}
export
async
function
blobValidate
(
data
)
{
try
{
const
text
=
await
data
.
text
();
JSON
.
parse
(
text
);
return
false
;
}
catch
(
error
)
{
return
true
;
}
}
/**
* 根据基础模板重置字段
* 根据基础模板重置字段
* @param excelId
* @param excelId
* @returns {*}
* @returns {*}
...
@@ -344,3 +382,29 @@ export function resetField(excelId){
...
@@ -344,3 +382,29 @@ export function resetField(excelId){
})
})
}
}
/**
* 创建物理表
* @param tableName
* @param templateId
* @returns {*}
*/
export
function
createTable
(
tableName
,
templateId
){
return
request
({
url
:
`
${
prefix
}
/table/create`
,
method
:
'get'
,
params
:{
tableName
,
templateId
}
})
}
/**
* 数据分析并导出
* @param templateId
* @returns {*}
*/
export
function
analyzeExport
(
templateId
){
return
request
({
url
:
`
${
prefix
}
/analyze/export`
,
method
:
'get'
,
params
:{
templateId
}
})
}
src/views/emport/emport/AutoLoading.vue
0 → 100644
View file @
12f2ed43
<
template
>
<el-dialog
:close-on-click-modal=
"false"
:show-close=
"false"
:visible=
"loading"
:width=
"width"
append-to-body
center
class=
"dialog-loading"
custom-class=
"dialog-loading-custom"
>
<div
v-loading=
"loading"
:element-loading-text=
"content"
:style=
"
{height: height}"
element-loading-spinner="el-icon-loading"
>
</div>
</el-dialog>
</
template
>
<
script
>
export
default
{
name
:
'AutoLoading'
,
props
:
{
loading
:
{
type
:
Boolean
,
default
:
false
},
content
:
{
type
:
String
,
default
:
''
},
width
:
{
type
:
String
,
default
:
'300px'
},
height
:
{
type
:
String
,
default
:
'200px'
}
}
}
</
script
>
<
style
lang=
"scss"
scoped
>
.dialog-loading
{
::v-deep
{
.el-dialog__header
{
display
:
none
;
}
.el-loading-mask
{
border-radius
:
16px
;
background-color
:
transparent
;
}
.dialog-loading-custom
{
border-radius
:
16px
;
background-color
:
rgba
(
255
,
255
,
255
,
0.5
);
}
.el-dialog__body
{
padding
:
0
;
}
}
}
</
style
>
src/views/emport/emport/index.vue
View file @
12f2ed43
...
@@ -45,7 +45,9 @@
...
@@ -45,7 +45,9 @@
<el-divider
class=
"divider1"
></el-divider>
<el-divider
class=
"divider1"
></el-divider>
<el-form
inline
size=
"small"
>
<el-form
inline
size=
"small"
>
<el-form-item>
<el-form-item>
<el-button
style=
"margin-left:6px;"
size=
"small"
icon=
"el-icon-pie-chart"
plain
>
分析并导出
</el-button>
<el-button
icon=
"el-icon-pie-chart"
plain
size=
"small"
style=
"margin-left:6px;"
@
click=
"analyzeExport"
>
分析并导出
</el-button>
<el-button
size=
"small"
icon=
"el-icon-set-up"
plain
>
设置机构字典
</el-button>
<el-button
size=
"small"
icon=
"el-icon-set-up"
plain
>
设置机构字典
</el-button>
<el-button
size=
"small"
icon=
"el-icon-refresh"
plain
>
清空数据
</el-button>
<el-button
size=
"small"
icon=
"el-icon-refresh"
plain
>
清空数据
</el-button>
<el-button
icon=
"el-icon-folder-add"
plain
size=
"small"
@
click=
"openTemplateDialog"
>
添加模板
</el-button>
<el-button
icon=
"el-icon-folder-add"
plain
size=
"small"
@
click=
"openTemplateDialog"
>
添加模板
</el-button>
...
@@ -78,7 +80,10 @@
...
@@ -78,7 +80,10 @@
<el-dropdown-item
icon=
"el-icon-upload2"
@
click
.
native=
"openUploadTemplate(scope.row)"
>
<el-dropdown-item
icon=
"el-icon-upload2"
@
click
.
native=
"openUploadTemplate(scope.row)"
>
模板上传
模板上传
</el-dropdown-item>
</el-dropdown-item>
<el-dropdown-item
icon=
"el-icon-download"
>
模板下载
</el-dropdown-item>
<el-dropdown-item
:disabled=
"!scope.row.excelId"
icon=
"el-icon-download"
@
click
.
native=
"downloadTemplate(scope.row)"
>
模板下载
</el-dropdown-item>
<el-dropdown-item
icon=
"el-icon-view"
@
click
.
native=
"openFieldDrawer(scope.row)"
>
查看字段
<el-dropdown-item
icon=
"el-icon-view"
@
click
.
native=
"openFieldDrawer(scope.row)"
>
查看字段
</el-dropdown-item>
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown-menu>
...
@@ -197,10 +202,12 @@
...
@@ -197,10 +202,12 @@
<el-input-number
v-model=
"fieldDialog.data.sort"
:min=
"0"
:precision=
"0"
/>
<el-input-number
v-model=
"fieldDialog.data.sort"
:min=
"0"
:precision=
"0"
/>
</el-form-item>
</el-form-item>
<el-form-item
label=
"数据库字段"
prop=
"field"
>
<el-form-item
label=
"数据库字段"
prop=
"field"
>
<el-select
v-model=
"fieldDialog.data.field"
:popper-append-to-body=
"false"
>
<el-select
v-
if=
"false"
v-
model=
"fieldDialog.data.field"
:popper-append-to-body=
"false"
>
<el-option
v-for=
"item in fieldDict"
:key=
"item.id"
:label=
"item.label"
:value=
"item.value"
<el-option
v-for=
"item in fieldDict"
:key=
"item.id"
:label=
"item.label"
:value=
"item.value"
></el-option>
></el-option>
</el-select>
</el-select>
<el-autocomplete
v-model=
"fieldDialog.data.field"
:fetch-suggestions=
"fetchSuggestions"
>
</el-autocomplete>
</el-form-item>
</el-form-item>
</el-form>
</el-form>
<div
slot=
"footer"
class=
"dialog-footer"
>
<div
slot=
"footer"
class=
"dialog-footer"
>
...
@@ -227,14 +234,17 @@
...
@@ -227,14 +234,17 @@
<el-input
v-model=
"fieldDrawer.queryForm.coordinate"
/>
<el-input
v-model=
"fieldDrawer.queryForm.coordinate"
/>
</el-form-item>
</el-form-item>
<el-form-item
label=
""
>
<el-form-item
label=
""
>
<el-button
:loading=
"fieldDrawer.queryFieldLoading"
icon=
"el-icon-search"
type=
"primary"
<el-button
:loading=
"fieldDrawer.queryFieldLoading"
icon=
"el-icon-search"
style=
"margin-left: 8px"
type=
"primary"
@
click=
"queryFieldList"
@
click=
"queryFieldList"
>
查询
>
查询
</el-button>
</el-button>
<el-button
type=
"success"
@
click=
"openFieldDialog"
>
新增
</el-button>
<el-button
type=
"success"
@
click=
"openFieldDialog"
>
新增
</el-button>
<el-button
type=
"warning"
@
click=
"openQuicklyBind"
>
快速绑定
</el-button>
<el-button
type=
"warning"
@
click=
"openQuicklyBind"
>
快速绑定
</el-button>
<el-button
type=
"warning"
@
click=
"resetField"
:loading=
"fieldDrawer.resetFieldLoading"
<el-button
type=
"warning"
@
click=
"resetField"
:loading=
"fieldDrawer.resetFieldLoading"
:disabled=
"!fieldDrawer.template.excelId"
>
模板初始化
:disabled=
"!fieldDrawer.template.excelId"
>
模板初始化
</el-button>
<el-button
type=
"info"
@
click=
"createTable"
>
物理表生成
</el-button>
</el-button>
</el-form-item>
</el-form-item>
</el-form>
</el-form>
...
@@ -316,6 +326,10 @@
...
@@ -316,6 +326,10 @@
@
upload=
"initTemplateUpload"
@
upload=
"initTemplateUpload"
:loading=
"initTemplateDialog.loading"
:loading=
"initTemplateDialog.loading"
/>
/>
<!-- 分析loading -->
<AutoLoading
:content=
"analyzeData.content"
:loading=
"analyzeData.loading"
/>
</div>
</div>
</template>
</template>
...
@@ -323,11 +337,11 @@
...
@@ -323,11 +337,11 @@
import
*
as
Emport
from
'@/api/emport/Emport'
import
*
as
Emport
from
'@/api/emport/Emport'
import
StringUtil
from
'@/utils/document/StringUtil'
import
StringUtil
from
'@/utils/document/StringUtil'
import
AutoUpload
from
'@/views/emport/emport/AutoUpload.vue'
import
AutoUpload
from
'@/views/emport/emport/AutoUpload.vue'
import
{
resetField
}
from
"@/api/emport/Emport"
;
import
AutoLoading
from
'@/views/emport/emport/AutoLoading.vue'
export
default
{
export
default
{
name
:
'Emport'
,
name
:
'Emport'
,
components
:
{
AutoUpload
},
components
:
{
AutoLoading
,
AutoUpload
},
data
()
{
data
()
{
return
{
return
{
// 页面查询字段
// 页面查询字段
...
@@ -398,7 +412,11 @@ export default {
...
@@ -398,7 +412,11 @@ export default {
importLoading
:
false
,
// 导入数据loading
importLoading
:
false
,
// 导入数据loading
queryTemplateLoading
:
false
,
// 模板查询loading
queryTemplateLoading
:
false
,
// 模板查询loading
queryTableLoading
:
false
,
// 查询数据表loading
queryTableLoading
:
false
,
// 查询数据表loading
templateList
:
[]
// 模板列表
templateList
:
[],
// 模板列表
analyzeData
:{
loading
:
false
,
content
:
""
}
}
}
},
},
created
()
{
created
()
{
...
@@ -516,7 +534,7 @@ export default {
...
@@ -516,7 +534,7 @@ export default {
// 打开年份字典编辑框
// 打开年份字典编辑框
editYearDialog
(
data
)
{
editYearDialog
(
data
)
{
this
.
yearDialog
.
title
=
'编辑年份'
this
.
yearDialog
.
title
=
'编辑年份'
this
.
yearDialog
.
data
=
{
...
data
}
this
.
yearDialog
.
data
=
{
...
data
}
this
.
yearDialog
.
show
=
true
this
.
yearDialog
.
show
=
true
},
},
// 提交年份dialog
// 提交年份dialog
...
@@ -540,7 +558,7 @@ export default {
...
@@ -540,7 +558,7 @@ export default {
})
})
},
},
// 删除年份字典
// 删除年份字典
deleteYear
({
id
,
label
})
{
deleteYear
({
id
,
label
})
{
this
.
$confirm
(
`是否删除数据项
${
label
}
?`
,
'删除'
,
this
.
$confirm
(
`是否删除数据项
${
label
}
?`
,
'删除'
,
{
{
type
:
'warning'
,
type
:
'warning'
,
...
@@ -562,13 +580,13 @@ export default {
...
@@ -562,13 +580,13 @@ export default {
// 打开机构类型字典新增框
// 打开机构类型字典新增框
openOrgDialog
()
{
openOrgDialog
()
{
this
.
orgDialog
.
title
=
'新增机构类型'
this
.
orgDialog
.
title
=
'新增机构类型'
this
.
orgDialog
.
data
=
{
type
:
'org'
,
value
:
''
}
this
.
orgDialog
.
data
=
{
type
:
'org'
,
value
:
''
}
this
.
orgDialog
.
show
=
true
this
.
orgDialog
.
show
=
true
},
},
// 打开机构类型字典编辑框
// 打开机构类型字典编辑框
editOrgDialog
(
data
)
{
editOrgDialog
(
data
)
{
this
.
orgDialog
.
title
=
'编辑机构类型'
this
.
orgDialog
.
title
=
'编辑机构类型'
this
.
orgDialog
.
data
=
{
...
data
}
this
.
orgDialog
.
data
=
{
...
data
}
this
.
orgDialog
.
show
=
true
this
.
orgDialog
.
show
=
true
},
},
// 提交机构类型dialog
// 提交机构类型dialog
...
@@ -598,7 +616,7 @@ export default {
...
@@ -598,7 +616,7 @@ export default {
})
})
},
},
// 删除机构类型字典
// 删除机构类型字典
deleteOrg
({
id
,
label
})
{
deleteOrg
({
id
,
label
})
{
this
.
$confirm
(
`是否删除数据项
${
label
}
?`
,
'删除'
,
this
.
$confirm
(
`是否删除数据项
${
label
}
?`
,
'删除'
,
{
{
type
:
'warning'
,
type
:
'warning'
,
...
@@ -634,10 +652,15 @@ export default {
...
@@ -634,10 +652,15 @@ export default {
this
.
queryForm
.
file
=
fileList
[
0
]
this
.
queryForm
.
file
=
fileList
[
0
]
},
},
// 文件上传方法
// 文件上传方法
fileUpload
({
file
,
onError
,
onProgress
,
onSuccess
})
{
fileUpload
({
file
,
onError
,
onProgress
,
onSuccess
})
{
this
.
importLoading
=
true
this
.
importLoading
=
true
let
formData
=
new
FormData
()
let
formData
=
new
FormData
()
formData
.
append
(
'file'
,
file
)
formData
.
append
(
'file'
,
file
)
let
template
=
this
.
templateList
.
find
(
item
=>
item
.
orgName
===
this
.
queryForm
.
orgName
)
formData
.
append
(
"type"
,
"1"
)
formData
.
append
(
"templateId"
,
template
.
id
)
formData
.
append
(
"year"
,
template
.
year
)
formData
.
append
(
"orgName"
,
template
.
orgName
)
//formData.append("templateId", this.checkTemplate.id);
//formData.append("templateId", this.checkTemplate.id);
Emport
.
uploadExcel
(
formData
)
Emport
.
uploadExcel
(
formData
)
.
then
((
res
)
=>
{
.
then
((
res
)
=>
{
...
@@ -710,7 +733,7 @@ export default {
...
@@ -710,7 +733,7 @@ export default {
// 打开模板编辑框
// 打开模板编辑框
editTemplateDialog
(
row
)
{
editTemplateDialog
(
row
)
{
this
.
templateDialog
.
title
=
'编辑模板'
this
.
templateDialog
.
title
=
'编辑模板'
this
.
templateDialog
.
data
=
{
...
row
}
this
.
templateDialog
.
data
=
{
...
row
}
this
.
templateDialog
.
show
=
true
this
.
templateDialog
.
show
=
true
},
},
// 删除模板
// 删除模板
...
@@ -755,7 +778,7 @@ export default {
...
@@ -755,7 +778,7 @@ export default {
},
},
// 打开字段抽屉
// 打开字段抽屉
openFieldDrawer
(
row
)
{
openFieldDrawer
(
row
)
{
this
.
fieldDrawer
.
template
=
{
...
row
}
this
.
fieldDrawer
.
template
=
{
...
row
}
this
.
fieldDrawer
.
queryForm
=
{
this
.
fieldDrawer
.
queryForm
=
{
templateId
:
row
.
id
,
templateId
:
row
.
id
,
code
:
''
,
code
:
''
,
...
@@ -791,7 +814,7 @@ export default {
...
@@ -791,7 +814,7 @@ export default {
// 打开修改字段的dialog
// 打开修改字段的dialog
editFieldDialog
(
row
)
{
editFieldDialog
(
row
)
{
this
.
fieldDialog
.
title
=
'修改字段'
this
.
fieldDialog
.
title
=
'修改字段'
this
.
fieldDialog
.
data
=
{
...
row
}
this
.
fieldDialog
.
data
=
{
...
row
}
this
.
fieldDialog
.
show
=
true
this
.
fieldDialog
.
show
=
true
},
},
// 删除字段
// 删除字段
...
@@ -872,7 +895,7 @@ export default {
...
@@ -872,7 +895,7 @@ export default {
this
.
initTemplateDialog
.
show
=
true
this
.
initTemplateDialog
.
show
=
true
},
},
// 初始化模板上上传方法
// 初始化模板上上传方法
initTemplateUpload
({
file
,
onSuccess
})
{
initTemplateUpload
({
file
,
onSuccess
})
{
let
formData
=
new
FormData
()
let
formData
=
new
FormData
()
formData
.
append
(
'file'
,
file
)
formData
.
append
(
'file'
,
file
)
formData
.
append
(
'type'
,
'2'
)
formData
.
append
(
'type'
,
'2'
)
...
@@ -899,12 +922,68 @@ export default {
...
@@ -899,12 +922,68 @@ export default {
this
.
fieldDrawer
.
resetFieldLoading
=
true
this
.
fieldDrawer
.
resetFieldLoading
=
true
Emport
.
resetField
(
this
.
fieldDrawer
.
template
.
excelId
).
then
(
res
=>
{
Emport
.
resetField
(
this
.
fieldDrawer
.
template
.
excelId
).
then
(
res
=>
{
if
(
res
.
code
===
200
)
{
if
(
res
.
code
===
200
)
{
this
.
$message
.
success
(
"字段初始化成功"
)
this
.
$message
.
success
(
'字段初始化成功'
)
this
.
queryFieldList
()
this
.
queryFieldList
()
}
}
}).
finally
(
_
=>
this
.
fieldDrawer
.
resetFieldLoading
=
false
)
}).
finally
(
_
=>
this
.
fieldDrawer
.
resetFieldLoading
=
false
)
})
})
}
},
// 模板下载
downloadTemplate
(
row
)
{
Emport
.
downloadTemplate
(
row
.
excelId
)
.
then
(
async
res
=>
{
const
isFile
=
await
Emport
.
blobValidate
(
res
)
if
(
isFile
)
{
const
{
data
}
=
await
Emport
.
getTemplateFileName
(
row
.
excelId
)
//const blob = new Blob([res])
saveAs
(
res
,
data
.
fileName
)
}
})
},
// 物理表生成
createTable
()
{
let
template
=
this
.
fieldDrawer
.
template
this
.
$prompt
(
'请输入要生成的表名(表名会自动转成大写形式)'
,
'物理表生成'
,
{
confirmButtonText
:
'确定'
,
cancelButtonText
:
'取消'
,
beforeClose
:
(
action
,
instance
,
done
)
=>
{
if
(
action
===
'confirm'
)
{
instance
.
confirmButtonLoading
=
true
Emport
.
createTable
(
instance
.
inputValue
,
template
.
id
).
then
(
res
=>
{
if
(
res
.
code
===
200
)
{
this
.
$message
.
success
({
message
:
'物理表创建成功'
,
duration
:
1000
*
5
})
done
()
}
}).
finally
(
_
=>
instance
.
confirmButtonLoading
=
false
)
}
else
{
done
()
}
}
}
)
},
// 字段输入建议
fetchSuggestions
(
qs
,
callback
)
{
if
(
!
this
.
fieldDict
)
{
callback
([])
return
}
if
(
qs
)
{
let
result
=
this
.
fieldDict
.
filter
(
item
=>
item
.
label
.
toUpperCase
().
includes
(
qs
.
toUpperCase
()))
callback
(
result
)
}
else
{
callback
(
this
.
fieldDict
)
}
},
// 数据分析并导出
analyzeExport
(){
this
.
analyzeData
.
content
=
"正在分析导入数据"
this
.
analyzeData
.
loading
=
true
},
}
}
}
}
</
script
>
</
script
>
...
...
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