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
62542656
authored
Jan 18, 2025
by
puhui999
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【代码优化】MALL: 修复模板装修时组件属性响应式丢失的问题
parent
ae0cc94d
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
44 deletions
+46
-44
src/components/DiyEditor/components/mobile/NavigationBar/index.vue
+3
-3
src/components/DiyEditor/index.vue
+27
-9
src/components/InputWithColor/index.vue
+4
-28
src/views/mall/promotion/diy/template/decorate.vue
+12
-4
No files found.
src/components/DiyEditor/components/mobile/NavigationBar/index.vue
View file @
62542656
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
<div
v-for=
"(cell, cellIndex) in cellList"
:key=
"cellIndex"
:style=
"getCellStyle(cell)"
>
<div
v-for=
"(cell, cellIndex) in cellList"
:key=
"cellIndex"
:style=
"getCellStyle(cell)"
>
<span
v-if=
"cell.type === 'text'"
>
{{
cell
.
text
}}
</span>
<span
v-if=
"cell.type === 'text'"
>
{{
cell
.
text
}}
</span>
<img
v-else-if=
"cell.type === 'image'"
:src=
"cell.imgUrl"
alt=
""
class=
"h-full w-full"
/>
<img
v-else-if=
"cell.type === 'image'"
:src=
"cell.imgUrl"
alt=
""
class=
"h-full w-full"
/>
<SearchBar
v-else
:property=
"getSearchProp"
/>
<SearchBar
v-else
:property=
"getSearchProp
(cell)
"
/>
</div>
</div>
</div>
</div>
<img
<img
...
@@ -51,14 +51,14 @@ const getCellStyle = (cell: NavigationBarCellProperty) => {
...
@@ -51,14 +51,14 @@ const getCellStyle = (cell: NavigationBarCellProperty) => {
}
as
StyleValue
}
as
StyleValue
}
}
// 获得搜索框属性
// 获得搜索框属性
const
getSearchProp
=
(
cell
:
NavigationBarCellProperty
)
=>
{
const
getSearchProp
=
computed
(()
=>
(
cell
:
NavigationBarCellProperty
)
=>
{
return
{
return
{
height
:
30
,
height
:
30
,
showScan
:
false
,
showScan
:
false
,
placeholder
:
cell
.
placeholder
,
placeholder
:
cell
.
placeholder
,
borderRadius
:
cell
.
borderRadius
borderRadius
:
cell
.
borderRadius
}
as
SearchProperty
}
as
SearchProperty
}
}
)
</
script
>
</
script
>
<
style
lang=
"scss"
scoped
>
<
style
lang=
"scss"
scoped
>
.navigation-bar
{
.navigation-bar
{
...
...
src/components/DiyEditor/index.vue
View file @
62542656
...
@@ -110,7 +110,7 @@
...
@@ -110,7 +110,7 @@
<el-tag
<el-tag
v-if=
"showPageConfig"
v-if=
"showPageConfig"
:effect=
"selectedComponent?.uid === pageConfigComponent.uid ? 'dark' : 'plain'"
:effect=
"selectedComponent?.uid === pageConfigComponent.uid ? 'dark' : 'plain'"
:type=
"selectedComponent?.uid === pageConfigComponent.uid ? '' : 'info'"
:type=
"selectedComponent?.uid === pageConfigComponent.uid ? '
primary
' : 'info'"
size=
"large"
size=
"large"
@
click=
"handleComponentSelected(pageConfigComponent)"
@
click=
"handleComponentSelected(pageConfigComponent)"
>
>
...
@@ -121,7 +121,7 @@
...
@@ -121,7 +121,7 @@
<el-tag
<el-tag
v-if=
"component.position === 'fixed'"
v-if=
"component.position === 'fixed'"
:effect=
"selectedComponent?.uid === component.uid ? 'dark' : 'plain'"
:effect=
"selectedComponent?.uid === component.uid ? 'dark' : 'plain'"
:type=
"selectedComponent?.uid === component.uid ? '' : 'info'"
:type=
"selectedComponent?.uid === component.uid ? '
primary
' : 'info'"
closable
closable
size=
"large"
size=
"large"
@
click=
"handleComponentSelected(component)"
@
click=
"handleComponentSelected(component)"
...
@@ -191,7 +191,7 @@ import { cloneDeep, includes } from 'lodash-es'
...
@@ -191,7 +191,7 @@ import { cloneDeep, includes } from 'lodash-es'
import
{
component
as
PAGE_CONFIG_COMPONENT
}
from
'@/components/DiyEditor/components/mobile/PageConfig/config'
import
{
component
as
PAGE_CONFIG_COMPONENT
}
from
'@/components/DiyEditor/components/mobile/PageConfig/config'
import
{
component
as
NAVIGATION_BAR_COMPONENT
}
from
'./components/mobile/NavigationBar/config'
import
{
component
as
NAVIGATION_BAR_COMPONENT
}
from
'./components/mobile/NavigationBar/config'
import
{
component
as
TAB_BAR_COMPONENT
}
from
'./components/mobile/TabBar/config'
import
{
component
as
TAB_BAR_COMPONENT
}
from
'./components/mobile/TabBar/config'
import
{
isString
}
from
'@/utils/is'
import
{
is
Empty
,
is
String
}
from
'@/utils/is'
import
{
DiyComponent
,
DiyComponentLibrary
,
PageConfig
}
from
'@/components/DiyEditor/util'
import
{
DiyComponent
,
DiyComponentLibrary
,
PageConfig
}
from
'@/components/DiyEditor/util'
import
{
componentConfigs
}
from
'@/components/DiyEditor/components/mobile'
import
{
componentConfigs
}
from
'@/components/DiyEditor/components/mobile'
import
{
array
,
oneOfType
}
from
'vue-types'
import
{
array
,
oneOfType
}
from
'vue-types'
...
@@ -238,24 +238,42 @@ const props = defineProps({
...
@@ -238,24 +238,42 @@ const props = defineProps({
watch
(
watch
(
()
=>
props
.
modelValue
,
()
=>
props
.
modelValue
,
()
=>
{
()
=>
{
const
modelValue
=
isString
(
props
.
modelValue
)
const
modelValue
=
isString
(
props
.
modelValue
)
&&
!
isEmpty
(
props
.
modelValue
)
?
(
JSON
.
parse
(
props
.
modelValue
)
as
PageConfig
)
?
(
JSON
.
parse
(
props
.
modelValue
)
as
PageConfig
)
:
props
.
modelValue
:
props
.
modelValue
pageConfigComponent
.
value
.
property
=
modelValue
?.
page
||
PAGE_CONFIG_COMPONENT
.
property
pageConfigComponent
.
value
.
property
=
(
typeof
modelValue
!==
'string'
&&
modelValue
?.
page
)
||
PAGE_CONFIG_COMPONENT
.
property
navigationBarComponent
.
value
.
property
=
navigationBarComponent
.
value
.
property
=
modelValue
?.
navigationBar
||
NAVIGATION_BAR_COMPONENT
.
property
(
typeof
modelValue
!==
'string'
&&
modelValue
?.
navigationBar
)
||
tabBarComponent
.
value
.
property
=
modelValue
?.
tabBar
||
TAB_BAR_COMPONENT
.
property
NAVIGATION_BAR_COMPONENT
.
property
tabBarComponent
.
value
.
property
=
(
typeof
modelValue
!==
'string'
&&
modelValue
?.
tabBar
)
||
TAB_BAR_COMPONENT
.
property
// 查找对应的页面组件
// 查找对应的页面组件
pageComponents
.
value
=
(
modelValue
?.
components
||
[]).
map
((
item
)
=>
{
pageComponents
.
value
=
((
typeof
modelValue
!==
'string'
&&
modelValue
?.
components
)
||
[]).
map
(
(
item
)
=>
{
const
component
=
componentConfigs
[
item
.
id
]
const
component
=
componentConfigs
[
item
.
id
]
return
{
...
component
,
property
:
item
.
property
}
return
{
...
component
,
property
:
item
.
property
}
})
}
)
},
},
{
{
immediate
:
true
immediate
:
true
}
}
)
)
/** 选择组件修改其属性后更新它的配置 */
watch
(
selectedComponent
,
(
val
:
any
)
=>
{
if
(
!
val
||
selectedComponentIndex
.
value
===
-
1
)
{
return
}
pageComponents
.
value
[
selectedComponentIndex
.
value
]
=
selectedComponent
.
value
!
},
{
deep
:
true
}
)
// 保存
// 保存
const
handleSave
=
()
=>
{
const
handleSave
=
()
=>
{
// 发送保存通知
// 发送保存通知
...
...
src/components/InputWithColor/index.vue
View file @
62542656
<
template
>
<
template
>
<el-input
v-model=
"
valueRef
"
v-bind=
"$attrs"
>
<el-input
v-model=
"
modelValue
"
v-bind=
"$attrs"
>
<template
#
append
>
<template
#
append
>
<el-color-picker
v-model=
"color
Ref
"
:predefine=
"PREDEFINE_COLORS"
/>
<el-color-picker
v-model=
"color"
:predefine=
"PREDEFINE_COLORS"
/>
</
template
>
</
template
>
</el-input>
</el-input>
</template>
</template>
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
<
script
lang=
"ts"
setup
>
<
script
lang=
"ts"
setup
>
import
{
propTypes
}
from
'@/utils/propTypes'
import
{
propTypes
}
from
'@/utils/propTypes'
import
{
PREDEFINE_COLORS
}
from
'@/utils/color'
import
{
PREDEFINE_COLORS
}
from
'@/utils/color'
import
{
useVModels
}
from
'@vueuse/core'
/**
/**
* 带颜色选择器输入框
* 带颜色选择器输入框
...
@@ -19,33 +20,8 @@ const props = defineProps({
...
@@ -19,33 +20,8 @@ const props = defineProps({
modelValue
:
propTypes
.
string
.
def
(
''
).
isRequired
,
modelValue
:
propTypes
.
string
.
def
(
''
).
isRequired
,
color
:
propTypes
.
string
.
def
(
''
).
isRequired
color
:
propTypes
.
string
.
def
(
''
).
isRequired
})
})
watch
(
()
=>
props
.
modelValue
,
(
val
:
string
)
=>
{
if
(
val
===
unref
(
valueRef
))
return
valueRef
.
value
=
val
}
)
const
emit
=
defineEmits
([
'update:modelValue'
,
'update:color'
])
const
emit
=
defineEmits
([
'update:modelValue'
,
'update:color'
])
const
{
modelValue
,
color
}
=
useVModels
(
props
,
emit
)
// 输入框的值
const
valueRef
=
ref
(
props
.
modelValue
)
watch
(
()
=>
valueRef
.
value
,
(
val
:
string
)
=>
{
emit
(
'update:modelValue'
,
val
)
}
)
// 颜色
const
colorRef
=
ref
(
props
.
color
)
watch
(
()
=>
colorRef
.
value
,
(
val
:
string
)
=>
{
emit
(
'update:color'
,
val
)
}
)
</
script
>
</
script
>
<
style
scoped
lang=
"scss"
>
<
style
scoped
lang=
"scss"
>
:deep
(
.el-input-group__append
)
{
:deep
(
.el-input-group__append
)
{
...
...
src/views/mall/promotion/diy/template/decorate.vue
View file @
62542656
...
@@ -52,7 +52,9 @@ const formLoading = ref(false) // 表单的加载中:1)修改时的数据加
...
@@ -52,7 +52,9 @@ const formLoading = ref(false) // 表单的加载中:1)修改时的数据加
const
formData
=
ref
<
DiyTemplateApi
.
DiyTemplatePropertyVO
>
()
const
formData
=
ref
<
DiyTemplateApi
.
DiyTemplatePropertyVO
>
()
const
formRef
=
ref
()
// 表单 Ref
const
formRef
=
ref
()
// 表单 Ref
// 当前编辑的属性
// 当前编辑的属性
const
currentFormData
=
ref
<
DiyTemplateApi
.
DiyTemplatePropertyVO
|
DiyPageApi
.
DiyPageVO
>
()
const
currentFormData
=
ref
<
DiyTemplateApi
.
DiyTemplatePropertyVO
|
DiyPageApi
.
DiyPageVO
>
({
property
:
''
}
as
DiyPageApi
.
DiyPageVO
)
// templateItem 对应的缓存
// templateItem 对应的缓存
const
currentFormDataMap
=
ref
<
const
currentFormDataMap
=
ref
<
Map
<
string
,
DiyTemplateApi
.
DiyTemplatePropertyVO
|
DiyPageApi
.
DiyPageVO
>
Map
<
string
,
DiyTemplateApi
.
DiyTemplatePropertyVO
|
DiyPageApi
.
DiyPageVO
>
...
@@ -92,17 +94,21 @@ const handleTemplateItemChange = (val: number) => {
...
@@ -92,17 +94,21 @@ const handleTemplateItemChange = (val: number) => {
// 编辑模板
// 编辑模板
if
(
val
===
0
)
{
if
(
val
===
0
)
{
libs
.
value
=
templateLibs
libs
.
value
=
templateLibs
currentFormData
.
value
=
isEmpty
(
data
)
?
formData
.
value
:
data
currentFormData
.
value
=
(
isEmpty
(
data
)
?
formData
.
value
:
data
)
as
|
DiyTemplateApi
.
DiyTemplatePropertyVO
|
DiyPageApi
.
DiyPageVO
return
return
}
}
// 编辑页面
// 编辑页面
libs
.
value
=
PAGE_LIBS
libs
.
value
=
PAGE_LIBS
currentFormData
.
value
=
isEmpty
(
data
)
currentFormData
.
value
=
(
isEmpty
(
data
)
?
formData
.
value
!
.
pages
.
find
(
?
formData
.
value
!
.
pages
.
find
(
(
page
:
DiyPageApi
.
DiyPageVO
)
=>
page
.
name
===
templateItems
[
val
].
name
(
page
:
DiyPageApi
.
DiyPageVO
)
=>
page
.
name
===
templateItems
[
val
].
name
)
)
:
data
:
data
)
as
DiyTemplateApi
.
DiyTemplatePropertyVO
|
DiyPageApi
.
DiyPageVO
}
}
// 提交表单
// 提交表单
...
@@ -170,7 +176,9 @@ const recoverPageIndex = () => {
...
@@ -170,7 +176,9 @@ const recoverPageIndex = () => {
sessionStorage
.
removeItem
(
DIY_PAGE_INDEX_KEY
)
sessionStorage
.
removeItem
(
DIY_PAGE_INDEX_KEY
)
// 重新初始化数据
// 重新初始化数据
currentFormData
.
value
=
formData
.
value
currentFormData
.
value
=
formData
.
value
as
|
DiyTemplateApi
.
DiyTemplatePropertyVO
|
DiyPageApi
.
DiyPageVO
currentFormDataMap
.
value
=
new
Map
<
currentFormDataMap
.
value
=
new
Map
<
string
,
string
,
DiyTemplateApi
.
DiyTemplatePropertyVO
|
DiyPageApi
.
DiyPageVO
DiyTemplateApi
.
DiyTemplatePropertyVO
|
DiyPageApi
.
DiyPageVO
...
...
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