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
9b970461
Commit
9b970461
authored
Sep 15, 2023
by
liuzz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
导入错误列表提示
字段同步功能
parent
47c885b2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
135 additions
and
2 deletions
+135
-2
DataField.js
src/api/emport/DataField.js
+24
-0
index.vue
src/views/emport/emport/index.vue
+30
-2
index.vue
src/views/emport/field/index.vue
+81
-0
No files found.
src/api/emport/DataField.js
View file @
9b970461
...
@@ -182,4 +182,28 @@ export function sameFieldCheck(templateId) {
...
@@ -182,4 +182,28 @@ export function sameFieldCheck(templateId) {
})
})
}
}
/**
* 字段与数据库差异化查询
* @returns {*}
*/
export
function
fieldDbDiff
(
data
)
{
return
request
({
url
:
`
${
prefix
}
/fieldDbDiff`
,
method
:
'post'
,
data
})
}
/**
* sql执行
* @returns {*}
*/
export
function
executeSql
(
data
)
{
return
request
({
url
:
`
${
prefix
}
/executeSql`
,
method
:
'post'
,
data
})
}
src/views/emport/emport/index.vue
View file @
9b970461
...
@@ -541,6 +541,19 @@
...
@@ -541,6 +541,19 @@
<el-table-column
align=
"center"
label=
"字段备注"
prop=
"fieldComment"
show-overflow-tooltip
/>
<el-table-column
align=
"center"
label=
"字段备注"
prop=
"fieldComment"
show-overflow-tooltip
/>
</el-table>
</el-table>
</el-dialog>
</el-dialog>
<!-- 错误列表 -->
<el-dialog
:visible
.
sync=
"errorDialog.show"
append-to-body
close-on-click-modal
title=
"异常列表"
width=
"60%"
>
<el-table
:data=
"errorDialog.data"
style=
"width: 100%"
>
<el-table-column
prop=
"error"
label=
"错误信息"
>
</el-table-column>
</el-table>
</el-dialog>
</div>
</div>
</template>
</template>
...
@@ -578,7 +591,11 @@ export default {
...
@@ -578,7 +591,11 @@ export default {
dataSourceList
:
[],
// 数据源列表
dataSourceList
:
[],
// 数据源列表
tableList
:
[],
// 表列表
tableList
:
[],
// 表列表
fieldDict
:
[],
// 字段字典
fieldDict
:
[],
// 字段字典
metaFieldDict
:
[],
// 元字段字典
metaFieldDict
:
[],
//
errorDialog
:
{
// 错误列表dialog
show
:
false
,
data
:
[]
},
yearDialog
:
{
// 年份dialog
yearDialog
:
{
// 年份dialog
title
:
''
,
title
:
''
,
show
:
false
,
show
:
false
,
...
@@ -949,7 +966,18 @@ export default {
...
@@ -949,7 +966,18 @@ export default {
ExcelData
.
uploadExcel
(
formData
)
ExcelData
.
uploadExcel
(
formData
)
.
then
((
res
)
=>
{
.
then
((
res
)
=>
{
if
(
res
.
code
===
200
)
{
if
(
res
.
code
===
200
)
{
onSuccess
()
if
(
res
.
data
&&
res
.
data
.
length
>
0
){
onError
()
// 弹出数据导入异常
this
.
errorDialog
=
{
show
:
true
,
data
:
res
.
data
.
map
(
item
=>
{
return
{
error
:
item
}
})
}
}
else
{
onSuccess
()
}
}
else
{
}
else
{
onError
()
onError
()
}
}
...
...
src/views/emport/field/index.vue
View file @
9b970461
...
@@ -37,6 +37,9 @@
...
@@ -37,6 +37,9 @@
<el-table-column
:show-overflow-tooltip=
"true"
align=
"center"
label=
"备注"
prop=
"remarks"
/>
<el-table-column
:show-overflow-tooltip=
"true"
align=
"center"
label=
"备注"
prop=
"remarks"
/>
<el-table-column
align=
"center"
label=
"操作"
show-overflow-tooltip
width=
"150"
>
<el-table-column
align=
"center"
label=
"操作"
show-overflow-tooltip
width=
"150"
>
<template
slot-scope=
"scope"
>
<template
slot-scope=
"scope"
>
<el-button
circle
icon=
"el-icon-refresh"
plain
size=
"small"
type=
"primary"
@
click
.
stop=
"syncFieldType(scope.row)"
></el-button>
<el-button
circle
icon=
"el-icon-edit"
plain
size=
"small"
type=
"primary"
<el-button
circle
icon=
"el-icon-edit"
plain
size=
"small"
type=
"primary"
@
click
.
stop=
"editMetaFieldDialog(scope.row)"
@
click
.
stop=
"editMetaFieldDialog(scope.row)"
></el-button>
></el-button>
...
@@ -74,6 +77,49 @@
...
@@ -74,6 +77,49 @@
<el-button
@
click=
"metaFieldDialog.show = false"
>
取 消
</el-button>
<el-button
@
click=
"metaFieldDialog.show = false"
>
取 消
</el-button>
</div>
</div>
</el-dialog>
</el-dialog>
<el-dialog
:close-on-click-modal=
"false"
title=
"字段同步"
:visible
.
sync=
"diffDialog.show"
append-to-body
width=
"80%"
@
open=
"diffDialogOpen"
>
<el-table
v-loading=
"diffDialog.loading"
:data=
"diffDialog.data"
border
stripe
>
<el-table-column
type=
"expand"
>
<
template
slot-scope=
"scope"
>
<div
style=
"width: 100%;margin-left: 32px"
>
<div
style=
"margin: 8px"
>
<span
style=
"margin-right: 8px"
>
修改字段SQL(同步执行的SQL):
</span>
<span>
{{
scope
.
row
.
mergeSql
}}
</span>
</div>
<div
style=
"margin: 8px"
>
<span>
针对特殊的例如NUMBER类型的无法直接修改精度的字段,可以参考如下办法:
</span>
<div
style=
"margin-left: 32px"
>
<div>
-- 修改原字段名
</div>
<div>
ALTER TABLE
{{
scope
.
row
.
tableName
}}
RENAME COLUMN
{{
scope
.
row
.
columnName
}}
TO
{{
scope
.
row
.
columnName
+
'_BACKUP'
}}
;
</div>
<div>
-- 添加一个和原字段同名的字段
</div>
<div>
ALTER TABLE
{{
scope
.
row
.
tableName
}}
ADD
{{
scope
.
row
.
columnName
}}
{{
scope
.
row
.
metaType
}}
;
</div>
<div>
-- 将原来的数据更新到新的字段中,这时需要注意数据类型转换,此语句仅供参考
</div>
<div>
UPDATE
{{
scope
.
row
.
tableName
}}
SET
{{
scope
.
row
.
columnName
}}
= CAST(
{{
scope
.
row
.
columnName
+
'_BACKUP'
}}
AS
{{
scope
.
row
.
metaType
}}
);
</div>
<div>
-- 删除原来的备份字段,注意确认一下数据是否正常
</div>
<div>
ALTER TABLE
{{
scope
.
row
.
tableName
}}
DROP COLUMN
{{
scope
.
row
.
columnName
+
'_BACKUP'
}}
;
</div>
</div>
</div>
</div>
</
template
>
</el-table-column>
<el-table-column
:show-overflow-tooltip=
"true"
align=
"center"
label=
"数据源名称"
prop=
"datasourceId"
width=
"110"
/>
<el-table-column
:show-overflow-tooltip=
"true"
align=
"center"
label=
"表名"
prop=
"tableName"
min-width=
"210"
/>
<el-table-column
:show-overflow-tooltip=
"true"
align=
"center"
label=
"字段名"
prop=
"columnName"
min-width=
"210"
/>
<el-table-column
:show-overflow-tooltip=
"true"
align=
"center"
label=
"元数据类型"
prop=
"metaType"
width=
"130"
/>
<el-table-column
:show-overflow-tooltip=
"true"
align=
"center"
label=
"字段来类型"
prop=
"columnType"
width=
"130"
/>
<el-table-column
:show-overflow-tooltip=
"true"
align=
"center"
label=
"字段长度"
prop=
"columnLength"
width=
"75"
/>
<el-table-column
:show-overflow-tooltip=
"true"
align=
"center"
label=
"字段精度"
prop=
"columnPrecision"
width=
"75"
/>
<el-table-column
:show-overflow-tooltip=
"true"
align=
"center"
label=
"精度系数"
prop=
"columnScale"
width=
"75"
/>
<el-table-column
align=
"center"
label=
"操作"
show-overflow-tooltip
width=
"75"
>
<
template
slot-scope=
"scope"
>
<el-button
plain
size=
"small"
type=
"primary"
@
click
.
stop=
"executeSql(scope.row)"
>
同步
</el-button>
</
template
>
</el-table-column>
</el-table>
</el-dialog>
</div>
</div>
</template>
</template>
...
@@ -98,6 +144,12 @@ export default {
...
@@ -98,6 +144,12 @@ export default {
title
:
''
,
title
:
''
,
show
:
false
,
show
:
false
,
data
:
{}
data
:
{}
},
diffDialog
:
{
show
:
false
,
data
:
[],
row
:{},
loading
:
false
,
}
}
}
}
},
},
...
@@ -149,6 +201,34 @@ export default {
...
@@ -149,6 +201,34 @@ export default {
this
.
metaFieldDialog
.
data
=
{
...
data
}
this
.
metaFieldDialog
.
data
=
{
...
data
}
this
.
metaFieldDialog
.
show
=
true
this
.
metaFieldDialog
.
show
=
true
},
},
// 同步字段类型弹框
syncFieldType
(
row
){
this
.
diffDialog
=
{
data
:
[],
loading
:
false
,
row
:{...
row
},
show
:
true
}
},
diffDialogOpen
(){
this
.
diffDialog
.
loading
=
true
DataField
.
fieldDbDiff
(
this
.
diffDialog
.
row
).
then
(
res
=>
{
if
(
res
.
code
===
200
){
this
.
diffDialog
.
data
=
res
.
data
}
}).
finally
(
_
=>
{
this
.
diffDialog
.
loading
=
false
})
},
executeSql
(
row
){
DataField
.
executeSql
({...
row
}).
then
(
res
=>
{
if
(
res
.
code
===
200
){
this
.
$message
.
success
(
"执行成功"
)
}
}).
finally
(
_
=>
{
this
.
diffDialogOpen
()
})
},
// 删除字段
// 删除字段
deleteMetaRule
(
data
)
{
deleteMetaRule
(
data
)
{
this
.
$confirm
(
`是否删除字段
${
data
.
fieldName
}
?`
,
'删除'
,
this
.
$confirm
(
`是否删除字段
${
data
.
fieldName
}
?`
,
'删除'
,
...
@@ -211,4 +291,5 @@ export default {
...
@@ -211,4 +291,5 @@ export default {
width
:
250px
;
width
:
250px
;
}
}
}
}
</
style
>
</
style
>
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