Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
quantum-blocks
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
ui
quantum-blocks
Commits
7ea115fd
Commit
7ea115fd
authored
Oct 26, 2022
by
徐光星
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 积木增加历史记录表结构及查询等接口
parent
98b13b21
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
99 additions
and
1 deletion
+99
-1
editor.ts
app/controller/editor.ts
+49
-1
router.ts
app/router.ts
+2
-0
editor.api.ts
app/web/api/editor.api.ts
+3
-0
records.vue
app/web/page/editor/component/QgTable/components/records.vue
+45
-0
No files found.
app/controller/editor.ts
View file @
7ea115fd
import
{
Console
}
from
'
console
'
;
import
{
Controller
,
Context
}
from
'
egg
'
;
import
_
,
{
omitBy
}
from
'
lodash
'
;
import
{
v1
as
uuidv1
}
from
'
uuid
'
;
...
...
@@ -142,4 +141,53 @@ export default class EditorController extends Controller {
public
async
getServerTime
(
ctx
:
Context
)
{
ctx
.
body
=
ctx
.
helper
.
ok
(
new
Date
().
getTime
());
}
// 恢复历史记录
public
async
recoverPageData
(
ctx
:
Context
)
{
const
params
=
ctx
.
request
.
body
;
const
id
=
params
.
id
;
const
author
=
params
.
author
;
console
.
log
(
params
)
if
(
!
id
)
{
ctx
.
body
=
{};
return
;
}
const
pageData
=
await
ctx
.
model
.
PageHistory
.
findOne
({
where
:
{
id
:
+
id
,
tenantId
:
ctx
.
headers
[
'
qg-tenant-id
'
]}})
const
data
=
Object
.
assign
({},
pageData
.
dataValues
);
// 记录当前操作人
data
.
author
=
author
;
delete
data
.
updatedAt
;
delete
data
.
createdAt
;
// 更新主表行数据
const
uuid
=
pageData
.
uuid
;
const
updateData
=
Object
.
assign
({},
data
);
delete
updateData
.
uuid
;
delete
updateData
.
pageId
;
delete
updateData
.
id
;
await
ctx
.
model
.
PageInfo
.
update
(
updateData
,
{
where
:
{
uuid
:
uuid
,
tenantId
:
ctx
.
headers
[
'
qg-tenant-id
'
]
}});
await
ctx
.
service
.
redis
.
del
(
`pageInfo:
${
uuid
}
`
);
await
ctx
.
service
.
redis
.
del
(
`page:
${
uuid
}
`
);
// 创建新历史记录
const
historyData
=
Object
.
assign
({},
data
);
delete
historyData
.
id
;
await
ctx
.
model
.
PageHistory
.
create
(
historyData
);
ctx
.
body
=
ctx
.
helper
.
ok
({});
}
// 获取历史记录页面预览信息
public
async
getHistoryPreviewData
(
ctx
:
Context
)
{
const
pageInfo
=
await
ctx
.
model
.
PageHistory
.
findOne
({
where
:
{
id
:
ctx
.
params
.
id
}});
// console.log('sql', pageInfo);
if
(
ctx
.
query
.
lite
&&
pageInfo
)
{
// 如果存在sheme移除掉
const
page
=
JSON
.
parse
(
pageInfo
.
page
||
[]);
for
(
let
i
=
0
;
i
<
page
.
elements
.
length
;
i
++
)
{
delete
page
.
elements
[
i
].
schame
}
if
(
page
.
scheme
)
{
delete
page
.
scheme
;
}
pageInfo
.
page
=
JSON
.
stringify
(
page
);
}
ctx
.
body
=
ctx
.
helper
.
ok
(
pageInfo
);
}
}
\ No newline at end of file
app/router.ts
View file @
7ea115fd
...
...
@@ -16,6 +16,8 @@ export default (application: Application) => {
router
.
get
(
'
/editor/get/template
'
,
controller
.
editor
.
getTemplateList
);
router
.
get
(
'
/editor/getServerTime
'
,
controller
.
editor
.
getServerTime
);
router
.
get
(
'
/editor/get/:uuid
'
,
controller
.
editor
.
get
);
router
.
get
(
'
/editor/getHistoryPage/:id
'
,
controller
.
editor
.
getHistoryPreviewData
);
router
.
post
(
'
/editor/recoverPageData
'
,
controller
.
editor
.
recoverPageData
);
router
.
delete
(
'
/editor/:pageId
'
,
controller
.
editor
.
delete
);
router
.
get
(
'
/editor/login
'
,
controller
.
editor
.
login
);
router
.
get
(
'
/editor
'
,
controller
.
editor
.
home
);
...
...
app/web/api/editor.api.ts
View file @
7ea115fd
...
...
@@ -24,6 +24,9 @@ export default {
getTemplateList
()
{
return
http
.
get
(
'
editor/get/template
'
);
},
recoverPageData
(
params
)
{
return
http
.
post
(
`editor/recoverPageData`
,
params
);
},
getUpToken
()
{
return
axios
.
get
(
`
${
config
.
opapiHost
}
/upload/getToken`
);
},
...
...
app/web/page/editor/component/QgTable/components/records.vue
View file @
7ea115fd
...
...
@@ -9,6 +9,7 @@
</Modal>
</
template
>
<
script
>
import
editorApi
from
'
@api/editor.api
'
;
export
default
{
props
:
{
value
:
{
...
...
@@ -48,6 +49,50 @@
key
:
'
author
'
,
title
:
'
操作人
'
,
align
:
'
center
'
},
{
title
:
'
操作
'
,
align
:
'
center
'
,
render
:
(
h
,
params
)
=>
{
const
props
=
{
type
:
'
primary
'
,
};
const
style
=
{
display
:
'
inline-block
'
,
margin
:
'
5px
'
,
};
return
h
(
'
Poptip
'
,
{
props
:
{
confirm
:
true
,
transfer
:
true
,
title
:
'
确认恢复到此版本?
'
,
},
style
:
{
...
style
,
},
on
:
{
'
on-ok
'
:
async
()
=>
{
await
editorApi
.
recoverPageData
({
id
:
params
.
row
.
id
,
author
:
JSON
.
parse
(
localStorage
.
getItem
(
'
user
'
)).
account
||
''
});
window
.
location
.
reload
();
},
},
},
[
h
(
'
Button
'
,
{
...
props
},
'
恢复
'
),
]
)
}
}
]
}
...
...
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