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
98b13b21
Commit
98b13b21
authored
Oct 25, 2022
by
徐光星
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 增加历史记录model、查询
parent
ba6342c1
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
141 additions
and
13 deletions
+141
-13
editor.ts
app/controller/editor.ts
+11
-5
pageHistory.ts
app/model/pageHistory.ts
+32
-5
pageInfo.ts
app/model/pageInfo.ts
+1
-0
records.vue
app/web/page/editor/component/QgTable/components/records.vue
+70
-0
index.vue
app/web/page/editor/component/QgTable/index.vue
+11
-3
index.vue
app/web/page/editor/view/pageList/index.vue
+16
-0
No files found.
app/controller/editor.ts
View file @
98b13b21
import
{
Console
}
from
'
console
'
;
import
{
Controller
,
Context
}
from
'
egg
'
;
import
_
,
{
omitBy
}
from
'
lodash
'
;
import
{
v1
as
uuidv1
}
from
'
uuid
'
;
...
...
@@ -17,8 +18,8 @@ export default class EditorController extends Controller {
const
pageInfo
=
ctx
.
request
.
body
;
try
{
const
result
=
await
ctx
.
model
.
PageInfo
.
create
({
...
pageInfo
,
uuid
:
uuidv1
().
replace
(
/-/g
,
''
),
tenantId
:
ctx
.
headers
[
'
qg-tenant-id
'
]});
const
uuid
=
result
.
dataValues
.
uuid
;
await
ctx
.
model
.
PageHistory
.
create
({
...
pageInfo
,
uuid
,
tenantId
:
ctx
.
headers
[
'
qg-tenant-id
'
]});
const
{
uuid
,
id
}
=
result
.
dataValues
;
await
ctx
.
model
.
PageHistory
.
create
({
...
pageInfo
,
uuid
,
pageId
:
id
,
tenantId
:
ctx
.
headers
[
'
qg-tenant-id
'
]});
ctx
.
body
=
ctx
.
helper
.
ok
(
result
);
await
ctx
.
service
.
redis
.
del
(
`pageInfo:
${
uuid
}
`
);
await
ctx
.
service
.
redis
.
del
(
`page:
${
uuid
}
`
);
...
...
@@ -41,7 +42,9 @@ export default class EditorController extends Controller {
const
uuid
=
pageInfo
.
uuid
;
try
{
const
result
=
await
ctx
.
model
.
PageInfo
.
update
(
pageInfo
,
{
where
:
{
uuid
:
pageInfo
.
uuid
,
tenantId
:
ctx
.
headers
[
'
qg-tenant-id
'
]
}});
await
ctx
.
model
.
PageHistory
.
create
({
...
pageInfo
,
tenantId
:
ctx
.
headers
[
'
qg-tenant-id
'
]});
const
pageData
=
await
ctx
.
model
.
PageInfo
.
findOne
({
where
:
{
uuid
}});
const
pageId
=
pageData
.
id
;
await
ctx
.
model
.
PageHistory
.
create
({
...
pageInfo
,
uuid
,
pageId
,
tenantId
:
ctx
.
headers
[
'
qg-tenant-id
'
]});
await
ctx
.
service
.
redis
.
del
(
`pageInfo:
${
uuid
}
`
);
await
ctx
.
service
.
redis
.
del
(
`page:
${
uuid
}
`
);
ctx
.
body
=
ctx
.
helper
.
ok
(
result
);
...
...
@@ -96,7 +99,10 @@ export default class EditorController extends Controller {
where
=
{
...
where
,
isTemplate
:
1
};
}
const
{
count
:
total
,
rows
:
data
}
=
await
ctx
.
model
.
PageInfo
.
findAndCountAll
({
where
,
limit
:
+
pageSize
||
10
,
offset
:
(
+
pageNo
-
1
)
*
+
pageSize
||
0
,
order
:
[[
'
updated_at
'
,
'
DESC
'
]],
include
:
[
PageHistory
]});
offset
:
(
+
pageNo
-
1
)
*
+
pageSize
||
0
,
order
:
[[
'
updated_at
'
,
'
DESC
'
]],
include
:
[
PageHistory
.
scope
(
'
relative
'
)]});
data
.
map
(
item
=>
{
item
.
pageHistory
&&
item
.
pageHistory
.
reverse
();
})
ctx
.
body
=
ctx
.
helper
.
ok
({
total
,
data
});
}
...
...
@@ -130,7 +136,7 @@ export default class EditorController extends Controller {
public
async
delete
(
ctx
:
Context
)
{
const
pageInfo
=
await
ctx
.
model
.
PageInfo
.
update
({
enable
:
0
},
{
where
:
{
id
:
+
ctx
.
params
.
pageId
,
tenantId
:
ctx
.
headers
[
'
qg-tenant-id
'
]
}});
const
pageData
=
await
ctx
.
model
.
PageInfo
.
find
({
where
:
{
id
:
+
ctx
.
params
.
pageId
,
tenantId
:
ctx
.
headers
[
'
qg-tenant-id
'
]
}});
await
ctx
.
model
.
PageHistory
.
destroy
({
where
:
{
uuid
:
pageData
.
dataValues
.
uu
id
}});
await
ctx
.
model
.
PageHistory
.
destroy
({
where
:
{
pageId
:
pageData
.
dataValues
.
id
}});
ctx
.
body
=
ctx
.
helper
.
ok
(
pageInfo
);
}
public
async
getServerTime
(
ctx
:
Context
)
{
...
...
app/model/pageHistory.ts
View file @
98b13b21
/**
* @desc 页面信息表
*/
import
{
AutoIncrement
,
Column
,
DataType
,
Model
,
PrimaryKey
,
Table
,
AllowNull
,
ForeignKey
,
BelongsTo
}
from
'
sequelize-typescript
'
;
import
{
PageInfo
}
from
'
./pageInfo
'
;
import
{
AutoIncrement
,
Column
,
DataType
,
Model
,
PrimaryKey
,
Table
,
AllowNull
,
ForeignKey
,
BelongsTo
,
DefaultScope
,
Scopes
}
from
'
sequelize-typescript
'
;
import
{
PageInfo
}
from
'
./pageInfo
'
;
// @DefaultScope(() => ({
// attributes: ['id', 'primaryColor', 'secondaryColor', 'producedAt'],
// }))
@
Scopes
({
relative
:
{
attributes
:
[
'
id
'
,
'
author
'
,
'
updatedAt
'
,
'
createdAt
'
]
}
})
@
Table
({
modelName
:
'
page_history
'
,
freezeTableName
:
true
...
...
@@ -41,15 +51,14 @@
})
pageKeywords
:
string
;
@
ForeignKey
(()
=>
PageInfo
)
@
Column
({
field
:
'
uuid
'
,
type
:
DataType
.
UUID
})
uuid
:
string
;
@
BelongsTo
(()
=>
PageInfo
)
pageInfo
:
PageInfo
;
//
@BelongsTo(() => PageInfo)
//
pageInfo: PageInfo;
@
Column
({
field
:
'
redirectUrl
'
,
...
...
@@ -121,6 +130,24 @@
})
updatedAt
:
string
;
@
Column
({
type
:
DataType
.
DATE
,
field
:
'
created_at
'
,
get
()
{
const
moment
=
require
(
'
moment
'
);
const
createdAt
=
this
.
getDataValue
(
'
createdAt
'
);
return
moment
(
createdAt
).
format
(
'
YYYY-MM-DD HH:mm:ss
'
);
},
})
createdAt
:
string
;
@
ForeignKey
(()
=>
PageInfo
)
@
Column
({
field
:
'
page_id
'
,
type
:
DataType
.
INTEGER
(
11
)
})
pageId
:
number
;
@
Column
({
type
:
DataType
.
INTEGER
(
11
),
field
:
'
tenant_id
'
,
...
...
app/model/pageInfo.ts
View file @
98b13b21
...
...
@@ -127,4 +127,5 @@ export class PageInfo extends Model<PageInfo> {
pageHistory
:
PageHistory
[];
}
export
default
()
=>
PageInfo
;
\ No newline at end of file
app/web/page/editor/component/QgTable/components/records.vue
0 → 100644
View file @
98b13b21
<
template
>
<Modal
width=
"700"
v-model=
"show"
title=
"历史记录"
@
on-visible-change=
"change"
>
<Table
:columns=
"columns"
:data=
"records"
class=
"tableStyle"
/>
<span
slot=
"footer"
></span>
</Modal>
</
template
>
<
script
>
export
default
{
props
:
{
value
:
{
type
:
Boolean
,
default
:
false
},
records
:
{
type
:
Array
,
default
()
{
return
[]
}
}
},
watch
:
{
value
(
val
)
{
this
.
show
=
val
;
}
},
data
()
{
return
{
show
:
false
,
columns
:
[
{
title
:
'
版本
'
,
align
:
'
center
'
,
render
:
(
h
,
params
)
=>
{
console
.
log
(
params
);
return
h
(
'
span
'
,
this
.
records
.
length
-
params
.
index
)
}
},
{
title
:
'
更新时间
'
,
key
:
'
updatedAt
'
,
align
:
'
center
'
},
{
key
:
'
author
'
,
title
:
'
操作人
'
,
align
:
'
center
'
}
]
}
},
created
()
{
this
.
show
=
this
.
value
;
console
.
log
(
this
.
records
,
123
)
},
methods
:
{
change
(
val
)
{
if
(
!
val
)
{
this
.
close
();
}
},
close
()
{
this
.
$emit
(
'
close
'
);
}
}
}
</
script
>
\ No newline at end of file
app/web/page/editor/component/QgTable/index.vue
View file @
98b13b21
...
...
@@ -82,15 +82,16 @@
/>
</
template
>
</div>
<recordsModal
v-model=
"showRecordsModal"
:records=
"records"
@
close=
"showRecordsModal = false"
/>
</div>
</template>
<
script
>
import
Treeselect
from
'
@riophae/vue-treeselect
'
;
import
'
@riophae/vue-treeselect/dist/vue-treeselect.css
'
;
import
{
cloneDeep
}
from
'
lodash
'
;
import
recordsModal
from
'
./components/records.vue
'
export
default
{
components
:
{
Treeselect
},
components
:
{
Treeselect
,
recordsModal
},
props
:
{
columns
:
{
type
:
Array
,
...
...
@@ -114,7 +115,9 @@ export default {
},
showSelected
:
false
,
// todo
searchCondition
:
[],
selectedTab
:
'
1
'
selectedTab
:
'
1
'
,
records
:
[],
showRecordsModal
:
false
};
},
watch
:
{
...
...
@@ -133,6 +136,11 @@ export default {
}
},
methods
:
{
showRecords
(
data
)
{
// 展示历史记录
this
.
records
=
data
||
[];
this
.
showRecordsModal
=
true
;
},
changePageNo
(
page
)
{
this
.
query
(
page
);
this
.
$emit
(
'
on-page-change
'
,
page
);
...
...
app/web/page/editor/view/pageList/index.vue
View file @
98b13b21
...
...
@@ -145,6 +145,22 @@ export default {
},
'
修改
'
),
h
(
'
Button
'
,
{
props
,
style
:
{
...
style
,
display
:
params
.
row
.
pageHistory
&&
params
.
row
.
pageHistory
.
length
?
'
inline-block
'
:
'
none
'
},
on
:
{
click
:
()
=>
{
this
.
$refs
.
qgTable
.
showRecords
(
params
.
row
.
pageHistory
);
},
},
},
'
历史记录
'
),
h
(
'
Poptip
'
,
{
...
...
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