Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
881c4f3a
authored
Oct 31, 2023
by
owen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
营销:完善商城装修
1. 拆分页面设计用的属性修改接口 2. 增加模板的页面保存 3. 增加唯一名称校验 4. 增加页面编辑器,默认选中组件判断
parent
c1534bf1
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
88 additions
and
14 deletions
+88
-14
src/api/mall/promotion/diy/page.ts
+10
-0
src/api/mall/promotion/diy/template.ts
+17
-0
src/components/DiyEditor/index.vue
+28
-3
src/views/mall/promotion/diy/page/decorate.vue
+3
-2
src/views/mall/promotion/diy/template/decorate.vue
+30
-9
No files found.
src/api/mall/promotion/diy/page.ts
View file @
881c4f3a
...
@@ -33,3 +33,13 @@ export const updateDiyPage = async (data: DiyPageVO) => {
...
@@ -33,3 +33,13 @@ export const updateDiyPage = async (data: DiyPageVO) => {
export
const
deleteDiyPage
=
async
(
id
:
number
)
=>
{
export
const
deleteDiyPage
=
async
(
id
:
number
)
=>
{
return
await
request
.
delete
({
url
:
`/promotion/diy-page/delete?id=`
+
id
})
return
await
request
.
delete
({
url
:
`/promotion/diy-page/delete?id=`
+
id
})
}
}
// 获得装修页面属性
export
const
getDiyPageProperty
=
async
(
id
:
number
)
=>
{
return
await
request
.
get
({
url
:
`/promotion/diy-page/get-property?id=`
+
id
})
}
// 更新装修页面属性
export
const
updateDiyPageProperty
=
async
(
data
:
DiyPageVO
)
=>
{
return
await
request
.
put
({
url
:
`/promotion/diy-page/update-property`
,
data
})
}
src/api/mall/promotion/diy/template.ts
View file @
881c4f3a
import
request
from
'@/config/axios'
import
request
from
'@/config/axios'
import
{
DiyPageVO
}
from
'@/api/mall/promotion/diy/page'
export
interface
DiyTemplateVO
{
export
interface
DiyTemplateVO
{
id
?:
number
id
?:
number
...
@@ -10,6 +11,10 @@ export interface DiyTemplateVO {
...
@@ -10,6 +11,10 @@ export interface DiyTemplateVO {
property
:
string
property
:
string
}
}
export
interface
DiyTemplatePropertyVO
extends
DiyTemplateVO
{
pages
:
DiyPageVO
[]
}
// 查询装修模板列表
// 查询装修模板列表
export
const
getDiyTemplatePage
=
async
(
params
:
any
)
=>
{
export
const
getDiyTemplatePage
=
async
(
params
:
any
)
=>
{
return
await
request
.
get
({
url
:
`/promotion/diy-template/page`
,
params
})
return
await
request
.
get
({
url
:
`/promotion/diy-template/page`
,
params
})
...
@@ -39,3 +44,15 @@ export const deleteDiyTemplate = async (id: number) => {
...
@@ -39,3 +44,15 @@ export const deleteDiyTemplate = async (id: number) => {
export
const
useDiyTemplate
=
async
(
id
:
number
)
=>
{
export
const
useDiyTemplate
=
async
(
id
:
number
)
=>
{
return
await
request
.
put
({
url
:
`/promotion/diy-template/use?id=`
+
id
})
return
await
request
.
put
({
url
:
`/promotion/diy-template/use?id=`
+
id
})
}
}
// 获得装修模板属性
export
const
getDiyTemplateProperty
=
async
(
id
:
number
)
=>
{
return
await
request
.
get
<
DiyTemplatePropertyVO
>
({
url
:
`/promotion/diy-template/get-property?id=`
+
id
})
}
// 更新装修模板属性
export
const
updateDiyTemplateProperty
=
async
(
data
:
DiyTemplateVO
)
=>
{
return
await
request
.
put
({
url
:
`/promotion/diy-template/update-property`
,
data
})
}
src/components/DiyEditor/index.vue
View file @
881c4f3a
...
@@ -59,7 +59,7 @@
...
@@ -59,7 +59,7 @@
}"
}"
>
>
<draggable
<draggable
class=
"
drag-area page-prop
-area"
class=
"
page-prop-area drag
-area"
v-model=
"pageComponents"
v-model=
"pageComponents"
item-key=
"index"
item-key=
"index"
:animation=
"200"
:animation=
"200"
...
@@ -200,18 +200,25 @@ const navigationBarComponent = ref<DiyComponent<any>>(cloneDeep(NAVIGATION_BAR_C
...
@@ -200,18 +200,25 @@ const navigationBarComponent = ref<DiyComponent<any>>(cloneDeep(NAVIGATION_BAR_C
const
tabBarComponent
=
ref
<
DiyComponent
<
any
>>
(
cloneDeep
(
TAB_BAR_COMPONENT
))
const
tabBarComponent
=
ref
<
DiyComponent
<
any
>>
(
cloneDeep
(
TAB_BAR_COMPONENT
))
// 选中的组件,默认选中顶部导航栏
// 选中的组件,默认选中顶部导航栏
const
selectedComponent
=
ref
<
DiyComponent
<
any
>>
(
unref
(
pageConfigComponent
)
)
const
selectedComponent
=
ref
<
DiyComponent
<
any
>>
()
// 选中的组件索引
// 选中的组件索引
const
selectedComponentIndex
=
ref
<
number
>
(
-
1
)
const
selectedComponentIndex
=
ref
<
number
>
(
-
1
)
// 组件列表
// 组件列表
const
pageComponents
=
ref
<
DiyComponent
<
any
>
[]
>
([])
const
pageComponents
=
ref
<
DiyComponent
<
any
>
[]
>
([])
// 定义属性
// 定义属性
const
props
=
defineProps
<
{
const
props
=
defineProps
<
{
// 页面配置,支持Json字符串
modelValue
:
string
|
PageConfig
modelValue
:
string
|
PageConfig
// 标题
title
:
string
title
:
string
libs
:
DiyComponentLibrary
[]
// 组件库
// 组件库
libs
:
DiyComponentLibrary
[]
// 是否显示顶部导航栏
showNavigationBar
:
boolean
showNavigationBar
:
boolean
// 是否显示底部导航菜单
showTabBar
:
boolean
showTabBar
:
boolean
// 是否显示页面配置
showPageConfig
:
boolean
}
>
()
}
>
()
// 监听传入的页面配置
// 监听传入的页面配置
...
@@ -255,6 +262,8 @@ const handleSave = () => {
...
@@ -255,6 +262,8 @@ const handleSave = () => {
// 处理页面选中:显示属性表单
// 处理页面选中:显示属性表单
const
handlePageSelected
=
(
event
:
any
)
=>
{
const
handlePageSelected
=
(
event
:
any
)
=>
{
if
(
!
props
.
showPageConfig
)
return
// 配置了样式 page-prop-area 的元素,才显示页面设置
// 配置了样式 page-prop-area 的元素,才显示页面设置
if
(
includes
(
event
?.
target
?.
classList
,
'page-prop-area'
))
{
if
(
includes
(
event
?.
target
?.
classList
,
'page-prop-area'
))
{
handleComponentSelected
(
unref
(
pageConfigComponent
))
handleComponentSelected
(
unref
(
pageConfigComponent
))
...
@@ -351,6 +360,22 @@ const handlePreview = () => {
...
@@ -351,6 +360,22 @@ const handlePreview = () => {
message
.
warning
(
'开发中~'
)
message
.
warning
(
'开发中~'
)
emits
(
'preview'
)
emits
(
'preview'
)
}
}
// 设置默认选中的组件
const
setDefaultSelectedComponent
=
()
=>
{
if
(
props
.
showPageConfig
)
{
selectedComponent
.
value
=
unref
(
pageConfigComponent
)
}
else
if
(
props
.
showNavigationBar
)
{
selectedComponent
.
value
=
unref
(
navigationBarComponent
)
}
else
if
(
props
.
showTabBar
)
{
selectedComponent
.
value
=
unref
(
tabBarComponent
)
}
}
watch
(
()
=>
[
props
.
showPageConfig
,
props
.
showNavigationBar
,
props
.
showTabBar
],
()
=>
setDefaultSelectedComponent
()
)
onMounted
(()
=>
setDefaultSelectedComponent
())
</
script
>
</
script
>
<
style
lang=
"scss"
scoped
>
<
style
lang=
"scss"
scoped
>
.editor
{
.editor
{
...
...
src/views/mall/promotion/diy/page/decorate.vue
View file @
881c4f3a
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
v-model=
"formData.property"
v-model=
"formData.property"
:title=
"formData.name"
:title=
"formData.name"
:libs=
"componentLibs"
:libs=
"componentLibs"
:show-page-config=
"true"
:show-navigation-bar=
"true"
:show-navigation-bar=
"true"
:show-tab-bar=
"false"
:show-tab-bar=
"false"
@
save=
"submitForm"
@
save=
"submitForm"
...
@@ -51,7 +52,7 @@ const formRef = ref() // 表单 Ref
...
@@ -51,7 +52,7 @@ const formRef = ref() // 表单 Ref
const
getPageDetail
=
async
(
id
:
any
)
=>
{
const
getPageDetail
=
async
(
id
:
any
)
=>
{
formLoading
.
value
=
true
formLoading
.
value
=
true
try
{
try
{
formData
.
value
=
await
DiyPageApi
.
getDiyPage
(
id
)
formData
.
value
=
await
DiyPageApi
.
getDiyPage
Property
(
id
)
}
finally
{
}
finally
{
formLoading
.
value
=
false
formLoading
.
value
=
false
}
}
...
@@ -63,7 +64,7 @@ const submitForm = async () => {
...
@@ -63,7 +64,7 @@ const submitForm = async () => {
// 提交请求
// 提交请求
formLoading
.
value
=
true
formLoading
.
value
=
true
try
{
try
{
await
DiyPageApi
.
updateDiyPage
(
unref
(
formData
)
!
)
await
DiyPageApi
.
updateDiyPage
Property
(
unref
(
formData
)
!
)
message
.
success
(
'保存成功'
)
message
.
success
(
'保存成功'
)
}
finally
{
}
finally
{
formLoading
.
value
=
false
formLoading
.
value
=
false
...
...
src/views/mall/promotion/diy/template/decorate.vue
View file @
881c4f3a
<
template
>
<
template
>
<DiyEditor
<DiyEditor
v-if=
"formData && !formLoading"
v-if=
"formData && !formLoading"
v-model=
"
formData
.property"
v-model=
"
currentFormData!
.property"
:title=
"templateItems[selectedTemplateItem].name"
:title=
"templateItems[selectedTemplateItem].name"
:libs=
"libs"
:libs=
"libs"
:show-page-config=
"selectedTemplateItem !== 0"
:show-tab-bar=
"selectedTemplateItem === 0"
:show-tab-bar=
"selectedTemplateItem === 0"
:show-navigation-bar=
"selectedTemplateItem
>
0"
:show-navigation-bar=
"selectedTemplateItem
!==
0"
@
save=
"submitForm"
@
save=
"submitForm"
>
>
<template
#
toolBarLeft
>
<template
#
toolBarLeft
>
...
@@ -25,6 +26,7 @@
...
@@ -25,6 +26,7 @@
</template>
</template>
<
script
setup
lang=
"ts"
>
<
script
setup
lang=
"ts"
>
import
*
as
DiyTemplateApi
from
'@/api/mall/promotion/diy/template'
import
*
as
DiyTemplateApi
from
'@/api/mall/promotion/diy/template'
import
*
as
DiyPageApi
from
'@/api/mall/promotion/diy/page'
import
{
useTagsViewStore
}
from
'@/store/modules/tagsView'
import
{
useTagsViewStore
}
from
'@/store/modules/tagsView'
import
{
DiyComponentLibrary
}
from
'@/components/DiyEditor/util'
import
{
DiyComponentLibrary
}
from
'@/components/DiyEditor/util'
...
@@ -42,14 +44,17 @@ const templateItems = reactive([
...
@@ -42,14 +44,17 @@ const templateItems = reactive([
const
message
=
useMessage
()
// 消息弹窗
const
message
=
useMessage
()
// 消息弹窗
const
formLoading
=
ref
(
false
)
// 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
const
formLoading
=
ref
(
false
)
// 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
const
formData
=
ref
<
DiyTemplateApi
.
DiyTemplateVO
>
()
const
formData
=
ref
<
DiyTemplateApi
.
DiyTemplate
Property
VO
>
()
const
formRef
=
ref
()
// 表单 Ref
const
formRef
=
ref
()
// 表单 Ref
// 当前编辑的属性
const
currentFormData
=
ref
<
DiyTemplateApi
.
DiyTemplatePropertyVO
|
DiyPageApi
.
DiyPageVO
>
()
// 获取详情
// 获取详情
const
getPageDetail
=
async
(
id
:
any
)
=>
{
const
getPageDetail
=
async
(
id
:
any
)
=>
{
formLoading
.
value
=
true
formLoading
.
value
=
true
try
{
try
{
formData
.
value
=
await
DiyTemplateApi
.
getDiyTemplate
(
id
)
formData
.
value
=
await
DiyTemplateApi
.
getDiyTemplateProperty
(
id
)
currentFormData
.
value
=
formData
.
value
}
finally
{
}
finally
{
formLoading
.
value
=
false
formLoading
.
value
=
false
}
}
...
@@ -82,12 +87,21 @@ const pageLibs = [
...
@@ -82,12 +87,21 @@ const pageLibs = [
]
as
DiyComponentLibrary
[]
]
as
DiyComponentLibrary
[]
// 当前组件库
// 当前组件库
const
libs
=
ref
<
DiyComponentLibrary
[]
>
(
templateLibs
)
const
libs
=
ref
<
DiyComponentLibrary
[]
>
(
templateLibs
)
// 模板选项切换
const
handleTemplateItemChange
=
()
=>
{
const
handleTemplateItemChange
=
()
=>
{
// 编辑模板
if
(
selectedTemplateItem
.
value
===
0
)
{
if
(
selectedTemplateItem
.
value
===
0
)
{
libs
.
value
=
templateLibs
libs
.
value
=
templateLibs
}
else
{
currentFormData
.
value
=
formData
.
value
libs
.
value
=
pageLibs
return
}
}
// 编辑页面
libs
.
value
=
pageLibs
currentFormData
.
value
=
formData
.
value
!
.
pages
.
find
(
(
page
:
DiyPageApi
.
DiyPageVO
)
=>
page
.
name
===
templateItems
[
selectedTemplateItem
.
value
].
name
)
console
.
log
(
currentFormData
.
value
)
}
}
// 提交表单
// 提交表单
...
@@ -97,7 +111,13 @@ const submitForm = async () => {
...
@@ -97,7 +111,13 @@ const submitForm = async () => {
// 提交请求
// 提交请求
formLoading
.
value
=
true
formLoading
.
value
=
true
try
{
try
{
await
DiyTemplateApi
.
updateDiyTemplate
(
unref
(
formData
)
!
)
if
(
selectedTemplateItem
.
value
===
0
)
{
// 提交模板属性
await
DiyTemplateApi
.
updateDiyTemplateProperty
(
unref
(
formData
)
!
)
}
else
{
// 提交页面属性
await
DiyPageApi
.
updateDiyPageProperty
(
unref
(
currentFormData
)
!
)
}
message
.
success
(
'保存成功'
)
message
.
success
(
'保存成功'
)
}
finally
{
}
finally
{
formLoading
.
value
=
false
formLoading
.
value
=
false
...
@@ -113,8 +133,9 @@ const resetForm = () => {
...
@@ -113,8 +133,9 @@ const resetForm = () => {
usedTime
:
undefined
,
usedTime
:
undefined
,
remark
:
''
,
remark
:
''
,
previewImageUrls
:
[],
previewImageUrls
:
[],
property
:
''
property
:
''
,
}
as
DiyTemplateApi
.
DiyTemplateVO
pages
:
[]
}
as
DiyTemplateApi
.
DiyTemplatePropertyVO
formRef
.
value
?.
resetFields
()
formRef
.
value
?.
resetFields
()
}
}
...
...
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