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
6240e63b
Commit
6240e63b
authored
Dec 30, 2021
by
郭志伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(pageData): 完成数据结构优化
parent
0840f57f
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
62 additions
and
9 deletions
+62
-9
editor.ts
app/controller/editor.ts
+1
-0
index.ts
app/web/page/editor/component/DynamicComponent/index.ts
+1
-2
index.ts
app/web/page/editor/component/DynamicForm/index.ts
+7
-3
index.vue
app/web/page/editor/component/DynamicForm/index.vue
+2
-2
index.ts
app/web/page/editor/component/MaterialMenu/index.ts
+2
-1
index.ts
app/web/page/editor/view/dashboard/index.ts
+3
-1
index.ts
app/web/page/store/modules/editor/index.ts
+3
-0
scheme.ts
app/web/page/store/modules/editor/scheme.ts
+42
-0
state.ts
app/web/page/store/modules/editor/state.ts
+1
-0
No files found.
app/controller/editor.ts
View file @
6240e63b
...
...
@@ -42,6 +42,7 @@ export default class EditorController extends Controller {
for
(
let
i
=
0
;
i
<
page
.
elements
.
length
;
i
++
)
{
delete
page
.
elements
[
i
].
schame
}
delete
page
.
scheme
;
pageInfo
.
page
=
JSON
.
stringify
(
page
);
}
await
ctx
.
service
.
redis
.
set
(
`pageInfo:
${
ctx
.
params
.
uuid
}
`
,
pageInfo
);
...
...
app/web/page/editor/component/DynamicComponent/index.ts
View file @
6240e63b
...
...
@@ -61,7 +61,7 @@ export default class DynamicComponent extends Vue {
const
bussinessEleConfig
=
Object
.
values
(
this
.
eleConfigMap
).
reduce
((
pre
,
cur
)
=>
pre
.
concat
(
cur
.
children
),
[]);
const
rawEleConfig
=
this
.
type
===
'
business
'
?
bussinessEleConfig
:
this
.
eleConfig
;
const
eleConfig
=
flatten
(
rawEleConfig
).
find
(
cfg
=>
cfg
.
eleName
===
eleName
);
const
{
title
,
config
,
value
,
commonStyle
,
page
}
=
cloneDeep
(
eleConfig
);
const
{
title
,
value
,
commonStyle
,
page
}
=
cloneDeep
(
eleConfig
);
const
id
=
uuid
().
slice
(
19
);
const
pointH
=
eleName
===
'
freedom-container
'
?
360
:
105
;
return
{
...
...
@@ -70,7 +70,6 @@ export default class DynamicComponent extends Vue {
name
:
eleName
,
title
,
point
:
{
x
:
0
,
y
:
0
,
w
:
this
.
colNum
,
h
:
pointH
,
i
:
id
},
schame
:
config
,
props
:
{...
value
},
commonStyle
},
...
...
app/web/page/editor/component/DynamicForm/index.ts
View file @
6240e63b
...
...
@@ -15,8 +15,10 @@ import Textarea from './component/Textarea/index.vue';
import
Number
from
'
./component/Number/index.vue
'
;
import
ColumnSelector
from
'
./component/ColumnSelector/index.vue
'
;
import
{
resizeDiv
,
getStyle
}
from
'
@/service/utils.service
'
;
import
{
getAllScheme
}
from
'
../../../store/modules/editor/scheme
'
;
import
EventBus
from
'
@service/eventBus.service
'
;
const
allComponentsMap
=
getAllScheme
();
@
Component
({
components
:
{
Upload
,
ColorSelector
,
BaseSelect
,
FormList
,
Textarea
,
Number
,
ComponentSelect
,
GoodsTableModal
,
CouponTableModal
,
ColumnSelector
,
DiscountGoodsSelector
},
name
:
'
DynamicForm
'
})
export
default
class
DynamicForm
extends
Mixins
(
ContextMenuMixin
,
DynamicFormMixin
)
{
@
State
(
state
=>
state
.
editor
.
curEleIndex
)
curEleIndex
;
...
...
@@ -27,6 +29,7 @@ export default class DynamicForm extends Mixins(ContextMenuMixin, DynamicFormMix
paddingTop
:
0
,
paddingBottom
:
0
,
paddingLeft
:
0
,
paddingRight
:
0
};
form
:
object
=
{};
currentSchame
:
object
[]
=
[];
styleSchame
:
object
=
{
curEle
:
[
{
...
...
@@ -178,12 +181,12 @@ export default class DynamicForm extends Mixins(ContextMenuMixin, DynamicFormMix
}
get
hasGroup
()
{
return
this
.
cur
Element
?
.
schame
?.
some
(
v
=>
v
.
title
);
return
this
.
cur
rentSchame
.
schame
?.
some
(
v
=>
v
.
title
);
}
get
curFormKey
()
{
const
keys
=
[];
this
.
cur
Element
.
s
chame
?.
forEach
(
schame
=>
{
this
.
cur
rentS
chame
?.
forEach
(
schame
=>
{
if
(
schame
.
children
)
{
schame
.
children
.
forEach
(
child
=>
{
keys
.
push
(
child
.
key
);
...
...
@@ -234,13 +237,14 @@ export default class DynamicForm extends Mixins(ContextMenuMixin, DynamicFormMix
element
=
this
.
pageData
.
elements
[
this
.
curEleIndex
];
}
}
this
.
currentSchame
=
allComponentsMap
[
element
.
name
]
||
[];
return
element
;
}
setForm
(
newVal
,
type
)
{
this
.
form
=
{
id
:
`
${
type
}${
newVal
}
`
};
const
element
=
this
.
getCurElement
();
element
?.
s
chame
?.
forEach
(
schame
=>
{
this
.
currentS
chame
?.
forEach
(
schame
=>
{
if
(
schame
.
children
)
{
schame
.
children
.
forEach
(
child
=>
{
this
.
$set
(
this
.
form
,
child
.
key
,
element
.
props
[
child
.
key
]);
...
...
app/web/page/editor/component/DynamicForm/index.vue
View file @
6240e63b
...
...
@@ -4,9 +4,9 @@
<h2>
{{
curElement
.
title
}}
</h2>
<div>
{{
`组件ID: ${curElement.id
}
`
}}
<
/div
>
<
/div
>
<
Form
class
=
"
dynamic-form-component
"
@
submit
.
native
.
prevent
:
label
-
width
=
"
110
"
:
model
=
"
form
"
v
-
if
=
"
cur
Element.schame && curElement.s
chame.length
"
>
<
Form
class
=
"
dynamic-form-component
"
@
submit
.
native
.
prevent
:
label
-
width
=
"
110
"
:
model
=
"
form
"
v
-
if
=
"
cur
rentSchame && currentS
chame.length
"
>
<
h3
v
-
if
=
"
!hasGroup
"
>
组件属性
<
/h3
>
<
template
v
-
for
=
"
(item, index) in cur
Element.s
chame
"
>
<
template
v
-
for
=
"
(item, index) in cur
rentS
chame
"
>
<
div
v
-
if
=
"
item.title
"
>
<
h3
>
{{
item
.
title
}}
<
/h3
>
<
FormItem
:
label
=
"
child.name
"
:
key
=
"
curElement.id + child.key
"
v
-
for
=
"
child in item.children
"
>
...
...
app/web/page/editor/component/MaterialMenu/index.ts
View file @
6240e63b
import
{
Component
,
Vue
,
Prop
,
Watch
,
Emit
}
from
'
vue-property-decorator
'
;
import
DynamicComponent
from
'
@editor/component/DynamicComponent/index.vue
'
;
import
{
cloneDeep
}
from
'
lodash
'
;
import
{
basicComponents
,
businessComponents
}
from
'
@lib/config
'
;
import
{
State
}
from
'
vuex-class
'
;
@
Component
({
components
:
{
DynamicComponent
},
name
:
'
DynamicForm
'
})
@
Component
({
components
:
{
DynamicComponent
},
name
:
'
MaterialMenu
'
})
export
default
class
DynamicForm
extends
Vue
{
@
State
(
state
=>
state
.
editor
.
templateList
)
templateList
!
:
any
[];
...
...
app/web/page/editor/view/dashboard/index.ts
View file @
6240e63b
...
...
@@ -15,7 +15,8 @@ import localStorage from '@service/localStorage.service';
import
EventBus
from
'
@service/eventBus.service
'
;
import
{
getStyle
}
from
'
@service/utils.service
'
;
import
OperationPanel
from
'
@editor/component/OperationPanel/index.vue
'
;
import
type
{
PageInfo
,
Page
,
GridLayout
}
from
'
../../../store/modules/editor/state
'
;
import
type
{
PageInfo
,
Page
,
GridLayout
}
from
'
../../../store/modules/editor/state
'
;
import
{
pickAllScheme
}
from
'
../../../store/modules/editor/scheme
'
;
@
Component
({
components
:
{
GridLayout
:
VueGridLayout
.
GridLayout
,
GridItem
:
VueGridLayout
.
GridItem
,
BasicPageFormModal
,
RecordModal
,
MaterialMenu
,
DynamicFormTabs
,
OperationPanel
},
name
:
'
DashBoard
'
})
...
...
@@ -93,6 +94,7 @@ export default class DashBoard extends Mixins(ContextMenuMixin, GoodsTabsMixin,
pageData
.
props
.
diversion
=
diversion
;
pageData
.
props
.
shareCoverImage
=
shareCoverImage
;
pageData
.
props
.
shareOpenMethod
=
shareOpenMethod
;
pageData
.
scheme
=
pickAllScheme
(
pageData
.
elements
);
const
pageInfo
=
{
diversion
,
page
:
JSON
.
stringify
(
pageData
),
author
:
user
?.
account
,
isPublish
,
pageName
,
pageDescribe
,
pageKeywords
,
coverImage
,
isTemplate
,
shareCoverImage
,
shareOpenMethod
}
as
pageInfo
;
if
(
this
.
uuid
)
{
pageInfo
.
uuid
=
this
.
uuid
;
}
await
this
.
savePageData
({
pageInfo
,
pageData
:
this
.
pageData
});
...
...
app/web/page/store/modules/editor/index.ts
View file @
6240e63b
...
...
@@ -21,6 +21,7 @@ import {
import
{
v4
as
uuid
}
from
'
uuid
'
;
import
RootState
from
'
../../state
'
;
import
EditorState
,
{
PageInfo
,
defaultState
,
Page
,
PageElement
}
from
'
./state
'
;
import
{
separateAllScheme
,
pickAllScheme
}
from
'
./scheme
'
;
export
default
class
EditorModule
implements
Module
<
EditorState
,
RootState
>
{
state
:
EditorState
;
...
...
@@ -59,6 +60,8 @@ export default class EditorModule implements Module<EditorState, RootState> {
const
res
=
await
api
.
getPageById
(
condition
);
const
{
page
,
...
rest
}
=
res
as
PageInfo
;
const
pageObj
=
JSON
.
parse
(
page
as
string
);
pickAllScheme
(
pageObj
.
elements
);
// separateAllScheme(pageObj.elements);
commit
(
SET_PAGE_INFO
,
{
...
rest
,
page
:
pageObj
});
const
goodsTabs
=
{};
...
...
app/web/page/store/modules/editor/scheme.ts
0 → 100644
View file @
6240e63b
import
{
basicComponents
,
businessComponents
}
from
'
@lib/config
'
;
// 获取scheme
export
function
getAllScheme
()
{
let
businessComponentsMap
=
[];
businessComponents
.
forEach
(
item
=>
{
businessComponentsMap
=
[...
businessComponentsMap
,
...
item
.
children
];
});
const
schemeMap
=
{};
[...
basicComponents
,
...
businessComponentsMap
].
forEach
(
item
=>
{
schemeMap
[
item
.
eleName
]
=
item
.
config
;
});
return
schemeMap
;
}
// 批量移除schema
export
function
separateAllScheme
(
elements
)
{
elements
.
forEach
(
ele
=>
{
if
(
ele
.
schame
)
{
delete
ele
.
schame
;
}
if
(
ele
.
child
&&
ele
.
child
.
length
)
{
separateAllScheme
(
ele
.
child
);
}
});
}
// 提取schame
export
function
pickAllScheme
(
elements
)
{
const
allScheme
=
getAllScheme
();
let
scheme
=
{};
elements
.
forEach
(
ele
=>
{
const
{
name
}
=
ele
;
if
(
name
&&
!
scheme
[
name
])
{
scheme
[
name
]
=
allScheme
[
name
];
}
if
(
ele
.
child
&&
ele
.
child
.
length
)
{
scheme
=
Object
.
assign
({},
scheme
,
pickAllScheme
(
ele
.
child
));
}
});
return
scheme
;
}
app/web/page/store/modules/editor/state.ts
View file @
6240e63b
...
...
@@ -112,6 +112,7 @@ export const defaultState = {
],
},
elements
:
[],
scheme
:
{}
}
},
templateList
:
[],
...
...
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