Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
front-backend
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
framework
front-backend
Commits
aeebe25c
Commit
aeebe25c
authored
Dec 21, 2019
by
Elune
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码生成同步功能完成
parent
1e1705be
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
86 additions
and
58 deletions
+86
-58
src/api/generator/generator.js
+8
-0
src/views/generator/config.vue
+23
-14
src/views/generator/index.vue
+50
-31
src/views/generator/preview.vue
+4
-12
src/views/tools/picture/index.vue
+1
-1
No files found.
src/api/generator/generator.js
View file @
aeebe25c
...
@@ -23,3 +23,11 @@ export function save(data) {
...
@@ -23,3 +23,11 @@ export function save(data) {
})
})
}
}
export
function
sync
(
tables
)
{
return
request
({
url
:
'api/generator/sync'
,
method
:
'post'
,
data
:
tables
})
}
src/views/generator/config.vue
View file @
aeebe25c
<
template
>
<
template
>
<div
class=
"app-container"
>
<div
class=
"app-container"
>
<el-row
:gutter=
"15"
>
<el-row
:gutter=
"15"
>
<!--角色管理-->
<el-col
style=
"margin-bottom: 10px"
>
<el-col
style=
"margin-bottom: 10px"
>
<el-card
class=
"box-card"
shadow=
"never"
>
<el-card
class=
"box-card"
shadow=
"never"
>
<div
slot=
"header"
class=
"clearfix"
>
<div
slot=
"header"
class=
"clearfix"
>
...
@@ -10,10 +9,18 @@
...
@@ -10,10 +9,18 @@
:loading=
"columnLoading"
:loading=
"columnLoading"
icon=
"el-icon-check"
icon=
"el-icon-check"
size=
"mini"
size=
"mini"
style=
"float: right; padding: 6px 9px"
style=
"float: right; padding: 6px 9px
;
"
type=
"primary"
type=
"primary"
@
click=
"saveColumnConfig"
@
click=
"saveColumnConfig"
>
保存
</el-button>
>
保存
</el-button>
<el-button
:loading=
"syncLoading"
icon=
"el-icon-refresh"
size=
"mini"
style=
"float: right; padding: 6px 9px;margin-right: 10px"
type=
"success"
@
click=
"sync"
>
同步
</el-button>
</div>
</div>
<el-form
size=
"small"
label-width=
"90px"
>
<el-form
size=
"small"
label-width=
"90px"
>
<el-table
v-loading=
"loading"
:data=
"data"
:max-height=
"tableHeight"
size=
"small"
style=
"width: 100%;margin-bottom: 15px"
>
<el-table
v-loading=
"loading"
:data=
"data"
:max-height=
"tableHeight"
size=
"small"
style=
"width: 100%;margin-bottom: 15px"
>
...
@@ -179,7 +186,7 @@
...
@@ -179,7 +186,7 @@
<
script
>
<
script
>
import
crud
from
'@/mixins/crud'
import
crud
from
'@/mixins/crud'
import
{
update
,
get
}
from
'@/api/generator/genConfig'
import
{
update
,
get
}
from
'@/api/generator/genConfig'
import
{
save
}
from
'@/api/generator/generator'
import
{
save
,
sync
}
from
'@/api/generator/generator'
import
{
getDicts
}
from
'@/api/system/dict'
import
{
getDicts
}
from
'@/api/system/dict'
export
default
{
export
default
{
name
:
'GeneratorConfig'
,
name
:
'GeneratorConfig'
,
...
@@ -187,7 +194,7 @@ export default {
...
@@ -187,7 +194,7 @@ export default {
mixins
:
[
crud
],
mixins
:
[
crud
],
data
()
{
data
()
{
return
{
return
{
activeName
:
'first'
,
tableName
:
''
,
tableHeight
:
550
,
columnLoading
:
false
,
configLoading
:
false
,
dicts
:
[],
activeName
:
'first'
,
tableName
:
''
,
tableHeight
:
550
,
columnLoading
:
false
,
configLoading
:
false
,
dicts
:
[],
syncLoading
:
false
,
form
:
{
id
:
null
,
tableName
:
''
,
author
:
''
,
pack
:
''
,
path
:
''
,
moduleName
:
''
,
cover
:
'false'
,
apiPath
:
''
,
prefix
:
''
,
apiAlias
:
null
},
form
:
{
id
:
null
,
tableName
:
''
,
author
:
''
,
pack
:
''
,
path
:
''
,
moduleName
:
''
,
cover
:
'false'
,
apiPath
:
''
,
prefix
:
''
,
apiAlias
:
null
},
rules
:
{
rules
:
{
author
:
[
author
:
[
...
@@ -235,11 +242,7 @@ export default {
...
@@ -235,11 +242,7 @@ export default {
saveColumnConfig
()
{
saveColumnConfig
()
{
this
.
columnLoading
=
true
this
.
columnLoading
=
true
save
(
this
.
data
).
then
(
res
=>
{
save
(
this
.
data
).
then
(
res
=>
{
this
.
$notify
({
this
.
notify
(
'保存成功'
,
'success'
)
title
:
'保存成功'
,
type
:
'success'
,
duration
:
2500
})
this
.
columnLoading
=
false
this
.
columnLoading
=
false
}).
catch
(
err
=>
{
}).
catch
(
err
=>
{
this
.
columnLoading
=
false
this
.
columnLoading
=
false
...
@@ -251,11 +254,7 @@ export default {
...
@@ -251,11 +254,7 @@ export default {
if
(
valid
)
{
if
(
valid
)
{
this
.
configLoading
=
true
this
.
configLoading
=
true
update
(
this
.
form
).
then
(
res
=>
{
update
(
this
.
form
).
then
(
res
=>
{
this
.
$notify
({
this
.
notify
(
'保存成功'
,
'success'
)
title
:
'保存成功'
,
type
:
'success'
,
duration
:
2500
})
this
.
form
=
res
this
.
form
=
res
this
.
form
.
cover
=
this
.
form
.
cover
.
toString
()
this
.
form
.
cover
=
this
.
form
.
cover
.
toString
()
this
.
configLoading
=
false
this
.
configLoading
=
false
...
@@ -265,6 +264,16 @@ export default {
...
@@ -265,6 +264,16 @@ export default {
})
})
}
}
})
})
},
sync
()
{
this
.
syncLoading
=
true
sync
([
this
.
tableName
]).
then
(()
=>
{
this
.
init
()
this
.
notify
(
'同步成功'
,
'success'
)
this
.
syncLoading
=
false
}).
then
(()
=>
{
this
.
syncLoading
=
false
})
}
}
}
}
}
}
...
...
src/views/generator/index.vue
View file @
aeebe25c
...
@@ -2,21 +2,31 @@
...
@@ -2,21 +2,31 @@
<div
class=
"app-container"
>
<div
class=
"app-container"
>
<!--工具栏-->
<!--工具栏-->
<div
class=
"head-container"
>
<div
class=
"head-container"
>
<el-input
v-model=
"query.name"
clearable
size=
"small"
placeholder=
"请输入表名"
style=
"width: 200px;"
class=
"filter-item"
@
keyup
.
enter
.
native=
"toQuery"
/>
<div
v-if=
"crud.props.searchToggle"
>
<el-button
class=
"filter-item"
size=
"mini"
type=
"success"
icon=
"el-icon-search"
@
click=
"toQuery"
>
搜索
</el-button>
<el-input
v-model=
"query.name"
clearable
size=
"small"
placeholder=
"请输入表名"
style=
"width: 200px;"
class=
"filter-item"
@
keyup
.
enter
.
native=
"crud.toQuery"
/>
<rrOperation
:crud=
"crud"
/>
</div>
<crudOperation>
<el-button
slot=
"left"
class=
"filter-item"
size=
"mini"
type=
"success"
icon=
"el-icon-refresh"
:loading=
"syncLoading"
:disabled=
"crud.selections.length === 0"
@
click=
"sync"
>
同步
</el-button>
</crudOperation>
</div>
</div>
<!--表格渲染-->
<!--表格渲染-->
<el-table
v-loading=
"loading"
:data=
"data"
style=
"width: 100%;"
>
<el-table
ref=
"table"
v-loading=
"crud.loading"
:data=
"crud.data"
style=
"width: 100%;"
@
selection-change=
"crud.selectionChangeHandler"
>
<el-table-column
label=
"序号"
width=
"85"
align=
"center"
>
<el-table-column
type=
"selection"
width=
"55"
/>
<template
slot-scope=
"scope"
>
<el-table-column
v-if=
"columns.visible('tableName')"
:show-overflow-tooltip=
"true"
prop=
"tableName"
label=
"表名"
/>
<div>
{{
scope
.
$index
+
1
}}
</div>
<el-table-column
v-if=
"columns.visible('engine')"
:show-overflow-tooltip=
"true"
prop=
"engine"
label=
"数据库引擎"
/>
</
template
>
<el-table-column
v-if=
"columns.visible('coding')"
:show-overflow-tooltip=
"true"
prop=
"coding"
label=
"字符编码集"
/>
</el-table-column>
<el-table-column
v-if=
"columns.visible('remark')"
:show-overflow-tooltip=
"true"
prop=
"remark"
label=
"备注"
/>
<el-table-column
:show-overflow-tooltip=
"true"
prop=
"tableName"
label=
"表名"
/>
<el-table-column
v-if=
"columns.visible('createTime')"
prop=
"createTime"
label=
"创建日期"
>
<el-table-column
:show-overflow-tooltip=
"true"
prop=
"engine"
label=
"数据库引擎"
/>
<el-table-column
:show-overflow-tooltip=
"true"
prop=
"coding"
label=
"字符编码集"
/>
<el-table-column
:show-overflow-tooltip=
"true"
prop=
"remark"
label=
"备注"
/>
<el-table-column
prop=
"createTime"
label=
"创建日期"
>
<template
slot-scope=
"scope"
>
<template
slot-scope=
"scope"
>
<span>
{{
parseTime
(
scope
.
row
.
createTime
)
}}
</span>
<span>
{{
parseTime
(
scope
.
row
.
createTime
)
}}
</span>
</
template
>
</
template
>
...
@@ -39,37 +49,32 @@
...
@@ -39,37 +49,32 @@
</el-table-column>
</el-table-column>
</el-table>
</el-table>
<!--分页组件-->
<!--分页组件-->
<el-pagination
<pagination
/>
:total=
"total"
:current-page=
"page + 1"
style=
"margin-top: 8px;"
layout=
"total, prev, pager, next, sizes"
@
size-change=
"sizeChange"
@
current-change=
"pageChange"
/>
</div>
</div>
</template>
</template>
<
script
>
<
script
>
import
crud
from
'@/mixins/crud'
import
{
generator
,
sync
}
from
'@/api/generator/generator'
import
{
generator
}
from
'@/api/generator/generator'
import
CRUD
,
{
presenter
,
header
}
from
'@crud/crud'
import
rrOperation
from
'@crud/RR.operation'
import
crudOperation
from
'@crud/CRUD.operation'
import
pagination
from
'@crud/Pagination'
// crud交由presenter持有
const
defaultCrud
=
CRUD
({
url
:
'api/generator/tables'
})
export
default
{
export
default
{
name
:
'GeneratorIndex'
,
name
:
'GeneratorIndex'
,
mixins
:
[
crud
],
components
:
{
pagination
,
crudOperation
,
rrOperation
},
mixins
:
[
presenter
(
defaultCrud
),
header
()],
data
()
{
data
()
{
return
{
return
{
syncLoading
:
false
}
}
},
},
created
()
{
created
()
{
this
.
$nextTick
(()
=>
{
this
.
crud
.
optShow
=
{
add
:
false
,
edit
:
false
,
del
:
false
,
download
:
false
}
this
.
init
()
})
},
},
methods
:
{
methods
:
{
beforeInit
()
{
this
.
url
=
'api/generator/tables'
return
true
},
toGen
(
tableName
)
{
toGen
(
tableName
)
{
// 生成代码
// 生成代码
generator
(
tableName
,
0
).
then
(
data
=>
{
generator
(
tableName
,
0
).
then
(
data
=>
{
...
@@ -85,6 +90,20 @@ export default {
...
@@ -85,6 +90,20 @@ export default {
generator
(
tableName
,
2
).
then
(
data
=>
{
generator
(
tableName
,
2
).
then
(
data
=>
{
this
.
downloadFile
(
data
,
tableName
,
'zip'
)
this
.
downloadFile
(
data
,
tableName
,
'zip'
)
})
})
},
sync
()
{
const
tables
=
[]
this
.
crud
.
selections
.
forEach
(
val
=>
{
tables
.
push
(
val
.
tableName
)
})
this
.
syncLoading
=
true
sync
(
tables
).
then
(()
=>
{
this
.
crud
.
refresh
()
this
.
crud
.
notify
(
'同步成功'
,
CRUD
.
NOTIFICATION_TYPE
.
SUCCESS
)
this
.
syncLoading
=
false
}).
then
(()
=>
{
this
.
syncLoading
=
false
})
}
}
}
}
}
}
...
...
src/views/generator/preview.vue
View file @
aeebe25c
<
template
>
<
template
>
<el-tabs
v-
if=
"!error"
v-
model=
"activeName"
type=
"card"
>
<el-tabs
v-model=
"activeName"
type=
"card"
>
<el-tab-pane
v-for=
"item in data"
:key=
"item.name"
:lazy=
"true"
:label=
"item.name"
:name=
"item.name"
>
<el-tab-pane
v-for=
"item in data"
:key=
"item.name"
:lazy=
"true"
:label=
"item.name"
:name=
"item.name"
>
<Java
:value=
"item.content"
:height=
"height"
/>
<Java
:value=
"item.content"
:height=
"height"
/>
</el-tab-pane>
</el-tab-pane>
</el-tabs>
</el-tabs>
<div
v-else
class=
"app-container"
>
<el-alert
:title=
"error"
type=
"error"
/>
</div>
</
template
>
</
template
>
<
script
>
<
script
>
...
@@ -20,18 +14,16 @@ export default {
...
@@ -20,18 +14,16 @@ export default {
components
:
{
Java
},
components
:
{
Java
},
data
()
{
data
()
{
return
{
return
{
data
:
null
,
error
:
null
,
height
:
''
,
activeName
:
'Entity'
data
:
null
,
height
:
''
,
activeName
:
'Entity'
}
}
},
},
created
()
{
created
()
{
this
.
height
=
document
.
documentElement
.
clientHeight
-
180
+
'px'
this
.
height
=
document
.
documentElement
.
clientHeight
-
180
+
'px'
const
tableName
=
this
.
$route
.
params
.
tableName
const
tableName
=
this
.
$route
.
params
.
tableName
this
.
$nextTick
(()
=>
{
generator
(
tableName
,
1
).
then
(
data
=>
{
generator
(
tableName
,
1
).
then
(
data
=>
{
this
.
data
=
data
this
.
data
=
data
}).
catch
(
err
=>
{
}).
catch
(()
=>
{
this
.
error
=
err
.
response
.
data
.
message
this
.
$router
.
go
(
-
1
)
})
})
})
}
}
}
}
...
...
src/views/tools/picture/index.vue
View file @
aeebe25c
...
@@ -35,7 +35,7 @@
...
@@ -35,7 +35,7 @@
class=
"filter-item"
class=
"filter-item"
size=
"mini"
size=
"mini"
type=
"success"
type=
"success"
icon=
"el-icon-
upload
"
icon=
"el-icon-
refresh
"
:loading=
"syncLoading"
:loading=
"syncLoading"
@
click=
"sync"
@
click=
"sync"
>
同步
</el-button>
>
同步
</el-button>
...
...
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