|
@@ -64,23 +64,25 @@
|
|
|
<div class="w-full">
|
|
<div class="w-full">
|
|
|
<StylePart
|
|
<StylePart
|
|
|
v-model="part"
|
|
v-model="part"
|
|
|
- :hasStyle="!!styleFormData"
|
|
|
|
|
- @change="onChangeStyleByState"
|
|
|
|
|
|
|
+ :formData="styleFormData"
|
|
|
:widgetData="projectStore.activeWidget!"
|
|
:widgetData="projectStore.activeWidget!"
|
|
|
|
|
+ :formItemsSchema="formConfig.styles"
|
|
|
:componentProps="
|
|
:componentProps="
|
|
|
formConfig.styles.find((item) => item.field === 'part')?.componentProps
|
|
formConfig.styles.find((item) => item.field === 'part')?.componentProps
|
|
|
"
|
|
"
|
|
|
|
|
+ @change="onChangeStyleByState"
|
|
|
/>
|
|
/>
|
|
|
</div>
|
|
</div>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
|
|
|
|
|
- <el-row :gutter="12" v-if="styleFormData">
|
|
|
|
|
|
|
+ <el-row :gutter="12" v-show="part.expandStyle">
|
|
|
<CusFormItem
|
|
<CusFormItem
|
|
|
v-for="(item, index) in formConfig.styles || []"
|
|
v-for="(item, index) in formConfig.styles || []"
|
|
|
:key="item.valueType + '_' + index"
|
|
:key="item.valueType + '_' + index"
|
|
|
:schema="item"
|
|
:schema="item"
|
|
|
:formData="styleFormData"
|
|
:formData="styleFormData"
|
|
|
:widgetData="projectStore.activeWidget!"
|
|
:widgetData="projectStore.activeWidget!"
|
|
|
|
|
+ @change-state-style="onChangeStateStyle"
|
|
|
/>
|
|
/>
|
|
|
</el-row>
|
|
</el-row>
|
|
|
</el-form>
|
|
</el-form>
|
|
@@ -100,6 +102,7 @@ import type { ScrollbarInstance } from 'element-plus'
|
|
|
import { LuSliders } from 'vue-icons-plus/lu'
|
|
import { LuSliders } from 'vue-icons-plus/lu'
|
|
|
import { IoColorPaletteOutline } from 'vue-icons-plus/io'
|
|
import { IoColorPaletteOutline } from 'vue-icons-plus/io'
|
|
|
import { klona } from 'klona'
|
|
import { klona } from 'klona'
|
|
|
|
|
+import { assign, get } from 'lodash-es'
|
|
|
|
|
|
|
|
const projectStore = useProjectStore()
|
|
const projectStore = useProjectStore()
|
|
|
const activeKeys = ref<string[]>(['props', 'style'])
|
|
const activeKeys = ref<string[]>(['props', 'style'])
|
|
@@ -107,9 +110,11 @@ const scrollbarRef = ref<ScrollbarInstance>()
|
|
|
const part = ref<{
|
|
const part = ref<{
|
|
|
name: string
|
|
name: string
|
|
|
state: string
|
|
state: string
|
|
|
|
|
+ expandStyle: boolean
|
|
|
}>({
|
|
}>({
|
|
|
name: '',
|
|
name: '',
|
|
|
- state: ''
|
|
|
|
|
|
|
+ state: '',
|
|
|
|
|
+ expandStyle: true
|
|
|
})
|
|
})
|
|
|
// 样式表单数据
|
|
// 样式表单数据
|
|
|
const styleFormData = computed(() => {
|
|
const styleFormData = computed(() => {
|
|
@@ -139,6 +144,7 @@ watch(
|
|
|
if (first) {
|
|
if (first) {
|
|
|
part.value.name = first.part.name
|
|
part.value.name = first.part.name
|
|
|
part.value.state = first.part.state
|
|
part.value.state = first.part.state
|
|
|
|
|
+ part.value.expandStyle = true
|
|
|
}
|
|
}
|
|
|
scrollbarRef.value?.scrollTo(0, 0)
|
|
scrollbarRef.value?.scrollTo(0, 0)
|
|
|
},
|
|
},
|
|
@@ -160,19 +166,45 @@ watch(
|
|
|
}
|
|
}
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
-const onChangeStyleByState = (type: 'add' | 'delete') => {
|
|
|
|
|
- if (type === 'add') {
|
|
|
|
|
- // 从全局样式查找控件样式
|
|
|
|
|
- const widgetType = projectStore.activeWidget?.type
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * 获取控件预设样式
|
|
|
|
|
+ */
|
|
|
|
|
+const getWidgetDefaultStyle = () => {
|
|
|
|
|
+ const widgetType = projectStore.activeWidget?.type
|
|
|
|
|
+
|
|
|
|
|
+ const state = projectStore.globalStyle
|
|
|
|
|
+ ?.find((item) => item.widget === widgetType)
|
|
|
|
|
+ ?.part?.find((item) => item.partName === part.value.name)?.state
|
|
|
|
|
|
|
|
- const state = projectStore.globalStyle
|
|
|
|
|
|
|
+ const defaultStyle =
|
|
|
|
|
+ projectStore.globalStyle
|
|
|
?.find((item) => item.widget === widgetType)
|
|
?.find((item) => item.widget === widgetType)
|
|
|
- ?.part?.find((item) => item.partName === part.value.name)?.state
|
|
|
|
|
- const style = state?.find((item) => item.state === part.value.state)?.style
|
|
|
|
|
- // 找多对应样式时添加
|
|
|
|
|
- if (style) {
|
|
|
|
|
|
|
+ ?.part?.find((item) => item.partName === part.value.name)?.defaultStyle || {}
|
|
|
|
|
+
|
|
|
|
|
+ const stateStyle = state?.find((item) => item.state === part.value.state)?.style || {}
|
|
|
|
|
+
|
|
|
|
|
+ return {
|
|
|
|
|
+ defaultStyle,
|
|
|
|
|
+ stateStyle
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 设置控件状态部分样式
|
|
|
|
|
+ * @param field 样式字段名
|
|
|
|
|
+ * @param type 修改类型
|
|
|
|
|
+ */
|
|
|
|
|
+const onChangeStateStyle = (field: string, type: 'add' | 'delete') => {
|
|
|
|
|
+ if (type === 'add') {
|
|
|
|
|
+ const { defaultStyle, stateStyle } = getWidgetDefaultStyle()
|
|
|
|
|
+
|
|
|
|
|
+ const style = get(assign({}, defaultStyle, stateStyle), field)
|
|
|
|
|
+
|
|
|
|
|
+ if (styleFormData.value) {
|
|
|
|
|
+ styleFormData.value[field] = style
|
|
|
|
|
+ } else {
|
|
|
const result = klona({
|
|
const result = klona({
|
|
|
- ...style,
|
|
|
|
|
|
|
+ [field]: style,
|
|
|
part: {
|
|
part: {
|
|
|
name: part.value.name,
|
|
name: part.value.name,
|
|
|
state: part.value.state
|
|
state: part.value.state
|
|
@@ -180,6 +212,29 @@ const onChangeStyleByState = (type: 'add' | 'delete') => {
|
|
|
})
|
|
})
|
|
|
projectStore.activeWidget?.style?.push(result)
|
|
projectStore.activeWidget?.style?.push(result)
|
|
|
}
|
|
}
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if (styleFormData.value?.[field]) {
|
|
|
|
|
+ delete styleFormData.value[field]
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 开启/关闭控件部件状态样式
|
|
|
|
|
+ * @param type
|
|
|
|
|
+ */
|
|
|
|
|
+const onChangeStyleByState = (type: 'add' | 'delete') => {
|
|
|
|
|
+ if (type === 'add') {
|
|
|
|
|
+ const { defaultStyle, stateStyle } = getWidgetDefaultStyle()
|
|
|
|
|
+ // 找多对应样式时添加 状态的样式合并到默认样式
|
|
|
|
|
+ const result = klona({
|
|
|
|
|
+ ...assign({}, defaultStyle, stateStyle),
|
|
|
|
|
+ part: {
|
|
|
|
|
+ name: part.value.name,
|
|
|
|
|
+ state: part.value.state
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ projectStore.activeWidget?.style?.push(result)
|
|
|
} else {
|
|
} else {
|
|
|
// 删除样式
|
|
// 删除样式
|
|
|
const index =
|
|
const index =
|