Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qahome-diamond
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
QA
qahome-diamond
Commits
d2142368
Commit
d2142368
authored
Mar 13, 2019
by
智勇
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dbsync' into 'master'
Dbsync See merge request !4
parents
ac17fb0f
64f83ad0
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
516 additions
and
300 deletions
+516
-300
dbconfig.js
src/api/dbconfig.js
+32
-0
database.svg
src/icons/svg/database.svg
+1
-0
index.js
src/router/index.js
+309
-291
index.vue
src/views/dbconfig/manager/index.vue
+17
-9
index.vue
src/views/dbconfig/sync/index.vue
+157
-0
No files found.
src/api/dbconfig.js
View file @
d2142368
...
@@ -23,3 +23,35 @@ export function deleteConfig(query) {
...
@@ -23,3 +23,35 @@ export function deleteConfig(query) {
params
:
query
params
:
query
})
})
}
}
export
function
getNamespace
(
query
)
{
return
request
({
url
:
'
/dbsync/get_name_space
'
,
method
:
'
get
'
,
params
:
query
})
}
export
function
getDBName
(
query
)
{
return
request
({
url
:
'
/dbsync/get_dbs
'
,
method
:
'
get
'
,
params
:
query
})
}
export
function
dbSync
(
data
)
{
return
request
({
url
:
'
/dbsync/db_sync
'
,
method
:
'
post
'
,
data
})
}
export
function
dbSyncQuery
(
data
)
{
return
request
({
url
:
'
/dbsync/db_sync_query
'
,
method
:
'
post
'
,
data
})
}
src/icons/svg/database.svg
0 → 100644
View file @
d2142368
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg
t=
"1552358833449"
class=
"icon"
style=
""
viewBox=
"0 0 1024 1024"
version=
"1.1"
xmlns=
"http://www.w3.org/2000/svg"
p-id=
"5768"
xmlns:xlink=
"http://www.w3.org/1999/xlink"
width=
"200"
height=
"200"
><defs><style
type=
"text/css"
></style></defs><path
d=
"M512 438.857143q135.428571 0 253.142857-24.571429t185.714286-72.571428v97.142857q0 39.428571-58.857143 73.142857t-160 53.428571-220 19.714286-220-19.714286T132 512 73.142857 438.857143V341.714286q68 48 185.714286 72.571428t253.142857 24.571429z m0 438.857143q135.428571 0 253.142857-24.571429t185.714286-72.571428v97.142857q0 39.428571-58.857143 73.142857t-160 53.428571-220 19.714286-220-19.714286-160-53.428571-58.857143-73.142857v-97.142857q68 48 185.714286 72.571428t253.142857 24.571429z m0-219.428572q135.428571 0 253.142857-24.571428t185.714286-72.571429v97.142857q0 39.428571-58.857143 73.142857t-160 53.428572-220 19.714286-220-19.714286-160-53.428572-58.857143-73.142857V561.142857q68 48 185.714286 72.571429t253.142857 24.571428zM512 0q118.857143 0 220 19.714286t160 53.428571 58.857143 73.142857v73.142857q0 39.428571-58.857143 73.142858t-160 53.428571T512 365.714286t-220-19.714286T132 292.571429 73.142857 219.428571V146.285714q0-39.428571 58.857143-73.142857t160-53.428571T512 0z"
p-id=
"5769"
></path></svg>
\ No newline at end of file
src/router/index.js
View file @
d2142368
This diff is collapsed.
Click to expand it.
src/views/dbconfig/manager/index.vue
View file @
d2142368
...
@@ -161,15 +161,23 @@ export default {
...
@@ -161,15 +161,23 @@ export default {
createData
()
{
createData
()
{
this
.
$refs
[
'
dataForm
'
].
validate
((
valid
)
=>
{
this
.
$refs
[
'
dataForm
'
].
validate
((
valid
)
=>
{
if
(
valid
)
{
if
(
valid
)
{
saveConfig
(
this
.
temp
).
then
(()
=>
{
saveConfig
(
this
.
temp
).
then
((
res
)
=>
{
this
.
dialogFormVisible
=
false
if
(
res
.
data
.
code
!==
'
0000
'
)
{
this
.
$notify
({
this
.
$notify
({
title
:
'
成功
'
,
message
:
`
${
res
.
data
.
msg
}
`
,
message
:
'
保存成功
'
,
type
:
'
error
'
,
type
:
'
success
'
,
duration
:
2000
duration
:
2000
})
})
}
else
{
this
.
getConfig
()
this
.
dialogFormVisible
=
false
this
.
$notify
({
title
:
'
成功
'
,
message
:
'
保存成功
'
,
type
:
'
success
'
,
duration
:
2000
})
this
.
getConfig
()
}
})
})
}
}
})
})
...
...
src/views/dbconfig/sync/index.vue
0 → 100644
View file @
d2142368
<
template
>
<div
>
<div
class=
"app-container"
style=
"width:1000px; margin:0 auto;"
>
<el-form
ref=
"dataForm"
:inline=
"true"
:rules=
"rules"
:model=
"temp"
label-width=
"150px"
style=
"margin-bottom:15px"
>
<el-form-item
label=
"Namespace"
prop=
"namespace"
>
<el-select
:disabled=
"disableBool"
v-model=
"temp.namespace"
style=
"width:310px"
placeholder=
"要同步数据库的环境"
>
<el-option
v-for=
"item in namespaces"
:value=
"item"
:label=
"item"
:key=
"item"
/>
</el-select>
</el-form-item>
<el-form-item
label=
"数据库名称"
prop=
"dbname"
>
<el-select
:disabled=
"disableBool"
v-model=
"temp.dbname"
placeholder=
"要同步表结构及配置数据的数据库名称"
style=
"width:310px"
>
<el-option
v-for=
"item in dbnames"
:value=
"item"
:label=
"item"
:key=
"item"
/>
</el-select>
</el-form-item>
</el-form>
<el-form
:inline=
"true"
:model=
"temp"
label-width=
"150px"
>
<el-form-item
label=
"保留业务数据"
>
<el-switch
:disabled=
"disableBool"
v-model=
"temp.not_delete_business_data"
style=
"margin-right:280px"
/>
<span
是否保留当前已经存在的测试数据
/>
</el-form-item>
<el-form-item
label=
"使用备份数据"
>
<el-switch
:disabled=
"disableBool"
v-model=
"temp.use_cache"
/>
</el-form-item>
</el-form>
<div
style=
"margin-left:420px"
>
<el-button
:disabled=
"disableBool"
type=
"primary"
@
click=
"sync()"
>
{{
$t
(
'
table.confirm
'
)
}}
</el-button>
<el-button
:disabled=
"disableBool"
@
click=
"resetTemp()"
>
{{
$t
(
'
table.cancel
'
)
}}
</el-button>
</div
>
</div
>
<div
style=
"padding:10px 20px 0px"
>
<!--
<div
v-if=
"desc"
style=
"padding:10px 20px 0px"
>
-->
<textarea
v-if=
"desc"
v-model=
"desc"
style=
"min-height:600px;background-color:black;width:-webkit-fill-available;color:white"
/>
</div>
</div>
</
template
>
<
script
>
import
{
getNamespace
,
getDBName
,
dbSync
,
dbSyncQuery
}
from
'
@/api/dbconfig
'
import
Pagination
from
'
@/components/Pagination
'
// Secondary package based on el-pagination
import
JsonEditor
from
'
@/components/JsonEditor
'
export
default
{
name
:
'
DBSync
'
,
components
:
{
Pagination
,
JsonEditor
},
filters
:
{
},
data
()
{
return
{
dialogFormVisible
:
false
,
dialogDeleteVisible
:
false
,
dialogStatus
:
''
,
rules
:
{
dbname
:
[{
required
:
true
,
message
:
'
请输入
'
,
trigger
:
'
change
'
}],
namespace
:
[{
required
:
true
,
message
:
'
请输入
'
,
trigger
:
'
change
'
}]
},
configs
:
[],
namespace
:
undefined
,
namespaces
:
[],
dbname
:
undefined
,
dbnames
:
[],
temp
:
{
not_delete_business_data
:
true
,
use_cache
:
true
},
desc
:
''
,
location
:
''
,
time
:
undefined
,
disableBool
:
false
}
},
computed
:
{
},
watch
:
{
},
created
()
{
this
.
getNamespace
()
this
.
getDBName
()
},
methods
:
{
getNamespace
()
{
getNamespace
().
then
(
res
=>
{
this
.
namespaces
=
res
.
data
.
data
.
map
(
item
=>
item
.
name
)
})
},
getDBName
()
{
getDBName
().
then
(
res
=>
{
this
.
dbnames
=
res
.
data
.
data
.
map
(
item
=>
item
.
dbname
)
this
.
dbnames
.
unshift
(
'
all(no_mall)
'
)
})
},
resetTemp
()
{
this
.
temp
=
{
namespace
:
''
,
dbname
:
''
,
not_delete_business_data
:
false
,
use_cache
:
false
}
},
syncQuery
(
location
)
{
dbSyncQuery
({
location
}).
then
(
res
=>
{
res
=
res
.
data
.
data
if
(
this
.
timer
>
300
)
{
this
.
$notify
({
title
:
'
超时
'
,
message
:
'
同步超时!
'
,
type
:
'
error
'
,
duration
:
2000
})
return
true
}
if
(
res
.
status
===
'
complete
'
)
{
this
.
desc
=
new
Date
().
toLocaleTimeString
()
+
'
完成同步:
'
+
res
.
msg
.
result
+
'
; ID:
'
+
res
.
msg
.
number
+
'
\n\n\n
'
+
res
.
log
.
body
this
.
disableBool
=
false
this
.
$notify
({
title
:
'
成功
'
,
message
:
'
完成同步!
'
,
type
:
'
success
'
,
duration
:
2000
})
return
true
}
this
.
timer
=
this
.
timer
+
3
this
.
desc
=
new
Date
().
toLocaleTimeString
()
+
` 测试环境
${
this
.
temp
.
namespace
}
正在同步
${
this
.
temp
.
dbname
}
数据库,已等待
${
this
.
timer
}
s...\n\n\n`
+
res
.
log
.
body
setTimeout
(()
=>
{
this
.
syncQuery
(
location
)
},
3000
)
})
},
sync
()
{
console
.
log
(
1
,
this
)
this
.
$refs
[
'
dataForm
'
].
validate
((
valid
)
=>
{
if
(
valid
)
{
dbSync
(
this
.
temp
).
then
((
res
)
=>
{
this
.
dialogFormVisible
=
false
this
.
location
=
res
.
data
.
data
.
location
this
.
$notify
({
message
:
'
正在同步
'
,
type
:
'
success
'
,
duration
:
2000
})
this
.
desc
=
''
this
.
timer
=
0
this
.
disableBool
=
true
this
.
syncQuery
(
this
.
location
)
})
}
})
}
}
}
</
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