|
@@ -15,7 +15,7 @@
|
|
<div class="config-content">
|
|
<div class="config-content">
|
|
<component
|
|
<component
|
|
:is="configComponent"
|
|
:is="configComponent"
|
|
- @change="handleConfigChange"
|
|
|
|
|
|
+ @change="handleContentConfigChange"
|
|
v-bind="currentElementProps"
|
|
v-bind="currentElementProps"
|
|
/>
|
|
/>
|
|
</div>
|
|
</div>
|
|
@@ -28,7 +28,7 @@
|
|
</TabPane>
|
|
</TabPane>
|
|
<TabPane key="4" tab="组件">
|
|
<TabPane key="4" tab="组件">
|
|
<div class="config-content">
|
|
<div class="config-content">
|
|
- <CusForm :columns="formItems"/>
|
|
|
|
|
|
+ <CusForm :columns="formItems" @change="handleComponentConfigChange" />
|
|
</div>
|
|
</div>
|
|
</TabPane>
|
|
</TabPane>
|
|
</Tabs>
|
|
</Tabs>
|
|
@@ -36,247 +36,18 @@
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
-import { computed, shallowRef, watch, } from "vue";
|
|
|
|
|
|
+import { shallowRef, watch } from "vue";
|
|
import { Tabs, TabPane } from "ant-design-vue";
|
|
import { Tabs, TabPane } from "ant-design-vue";
|
|
import { useProjectStore } from "@/store/modules/project";
|
|
import { useProjectStore } from "@/store/modules/project";
|
|
import PageConfig from "./PageConfig.vue";
|
|
import PageConfig from "./PageConfig.vue";
|
|
-import { asyncComponentAll, CusForm } from 'shalu-dashboard-ui';
|
|
|
|
-import type { IFormItem } from 'shalu-dashboard-ui';
|
|
|
|
|
|
+import { asyncComponentAll, CusForm } from "shalu-dashboard-ui";
|
|
|
|
+import { set, defaultsDeep, cloneDeep } from "lodash";
|
|
|
|
+import { useComponentConfig } from "./useComponentConfig";
|
|
|
|
|
|
const projectStore = useProjectStore();
|
|
const projectStore = useProjectStore();
|
|
const configComponent = shallowRef<null | string>(null);
|
|
const configComponent = shallowRef<null | string>(null);
|
|
const currentElementProps = shallowRef<any>({});
|
|
const currentElementProps = shallowRef<any>({});
|
|
-
|
|
|
|
-const formItems = computed((): IFormItem[] => {
|
|
|
|
- const element = projectStore.currentSelectedElements[0];
|
|
|
|
- return [
|
|
|
|
- {
|
|
|
|
- label: "组件样式",
|
|
|
|
- prop: "style",
|
|
|
|
- type: "group",
|
|
|
|
- children: [
|
|
|
|
- {
|
|
|
|
- label: "边框背景",
|
|
|
|
- prop: "bakcground",
|
|
|
|
- type: "backgroundSelect",
|
|
|
|
- defaultValue: element?.container?.style?.background ?? {
|
|
|
|
- type: 'none',
|
|
|
|
- color: "",
|
|
|
|
- image: "",
|
|
|
|
- fillType: "cover",
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- label: "不透明度",
|
|
|
|
- prop: "opacity",
|
|
|
|
- type: "slider",
|
|
|
|
- defaultValue: element?.container?.style?.opacity ?? 1
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- label: "边框线",
|
|
|
|
- prop: "borderStyle",
|
|
|
|
- type: "select",
|
|
|
|
- fieldProps: {
|
|
|
|
- options: [
|
|
|
|
- { label: "无", value: "none" },
|
|
|
|
- { label: "实线", value: "solid" },
|
|
|
|
- { label: "虚线", value: "dashed" },
|
|
|
|
- { label: "点线", value: "dotted" }
|
|
|
|
- ]
|
|
|
|
- },
|
|
|
|
- defaultValue: element?.container?.style?.borderStyle || "none"
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- label: "边框颜色",
|
|
|
|
- prop: "borderColor",
|
|
|
|
- type: "colorSelect",
|
|
|
|
- defaultValue: element?.container?.style?.borderColor ?? "#EEEEEEFF"
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- label: "边框宽度",
|
|
|
|
- prop: "borderWidth",
|
|
|
|
- type: "inputNumber",
|
|
|
|
- fieldProps: {
|
|
|
|
- min: 0,
|
|
|
|
- addonAfter: "px"
|
|
|
|
- },
|
|
|
|
- defaultValue: element?.container?.style?.borderWidth ?? 1
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- label: "圆角",
|
|
|
|
- prop: "borderRadius",
|
|
|
|
- type: "inputNumber",
|
|
|
|
- fieldProps: {
|
|
|
|
- min: 0,
|
|
|
|
- addonAfter: "px"
|
|
|
|
- },
|
|
|
|
- defaultValue: element?.container?.style?.borderRadius ?? 0
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- label: "毛玻璃",
|
|
|
|
- prop: "backdropFilter",
|
|
|
|
- type: "checkboxGroup",
|
|
|
|
- fieldProps: {
|
|
|
|
- options: [
|
|
|
|
- { label: "开启", value: "blur(10px)" }
|
|
|
|
- ]
|
|
|
|
- },
|
|
|
|
- defaultValue: element?.container?.style?.backdropFilter ? ["blur(10px)"] : []
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- label: "阴影",
|
|
|
|
- prop: "boxShadow",
|
|
|
|
- type: "checkboxGroup",
|
|
|
|
- fieldProps: {
|
|
|
|
- options: [
|
|
|
|
- { label: "开启", value: "0 0 10px rgba(0,0,0,0.1)" }
|
|
|
|
- ]
|
|
|
|
- },
|
|
|
|
- defaultValue: element?.container?.style?.boxShadow ? ["0 0 10px rgba(0,0,0,0.1)"] : []
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- label: "倒影",
|
|
|
|
- prop: "webkitBoxReflect",
|
|
|
|
- type: "checkboxGroup",
|
|
|
|
- fieldProps: {
|
|
|
|
- options: [
|
|
|
|
- { label: "开启", value: "below 2px linear-gradient(transparent, rgba(0,0,0,0.5))" }
|
|
|
|
- ]
|
|
|
|
- },
|
|
|
|
- defaultValue: element?.container?.style?.webkitBoxReflect ? ["below 2px linear-gradient(transparent, rgba(0,0,0,0.5))"] : []
|
|
|
|
- }
|
|
|
|
- ]
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- label: "组件属性",
|
|
|
|
- prop: "props",
|
|
|
|
- type: "group",
|
|
|
|
- children: [
|
|
|
|
- {
|
|
|
|
- label: "名称",
|
|
|
|
- prop: "name",
|
|
|
|
- type: "input",
|
|
|
|
- defaultValue: element?.name ?? ""
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- label: "宽度",
|
|
|
|
- prop: "width",
|
|
|
|
- type: "inputNumber",
|
|
|
|
- fieldProps: {
|
|
|
|
- min: 0,
|
|
|
|
- addonAfter: "px"
|
|
|
|
- },
|
|
|
|
- defaultValue: element?.container?.props?.width ?? 400
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- label: "高度",
|
|
|
|
- prop: "height",
|
|
|
|
- type: "inputNumber",
|
|
|
|
- fieldProps: {
|
|
|
|
- min: 0,
|
|
|
|
- addonAfter: "px"
|
|
|
|
- },
|
|
|
|
- defaultValue: element?.container?.props?.height ?? 260
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- label: "距离左侧",
|
|
|
|
- prop: "x",
|
|
|
|
- type: "inputNumber",
|
|
|
|
- fieldProps: {
|
|
|
|
- min: 0,
|
|
|
|
- addonAfter: "px"
|
|
|
|
- },
|
|
|
|
- defaultValue: element?.container?.props?.x ?? 0
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- label: "距离顶部",
|
|
|
|
- prop: "y",
|
|
|
|
- type: "inputNumber",
|
|
|
|
- fieldProps: {
|
|
|
|
- min: 0,
|
|
|
|
- addonAfter: "px"
|
|
|
|
- },
|
|
|
|
- defaultValue: element?.container?.props?.y ?? 0
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- label: "顶边距",
|
|
|
|
- prop: "paddingTop",
|
|
|
|
- type: "inputNumber",
|
|
|
|
- fieldProps: {
|
|
|
|
- min: 0,
|
|
|
|
- addonAfter: "px"
|
|
|
|
- },
|
|
|
|
- defaultValue: element?.container?.props?.paddingTop ?? 0
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- label: "右边距",
|
|
|
|
- prop: "paddingRight",
|
|
|
|
- type: "inputNumber",
|
|
|
|
- fieldProps: {
|
|
|
|
- min: 0,
|
|
|
|
- addonAfter: "px"
|
|
|
|
- },
|
|
|
|
- defaultValue: element?.container?.props?.paddingRight ?? 0
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- label: "底边距",
|
|
|
|
- prop: "paddingBottom",
|
|
|
|
- type: "inputNumber",
|
|
|
|
- fieldProps: {
|
|
|
|
- min: 0,
|
|
|
|
- addonAfter: "px"
|
|
|
|
- },
|
|
|
|
- defaultValue: element?.container?.props?.paddingBottom ?? 0
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- label: "左边距",
|
|
|
|
- prop: "paddingLeft",
|
|
|
|
- type: "inputNumber",
|
|
|
|
- fieldProps: {
|
|
|
|
- min: 0,
|
|
|
|
- addonAfter: "px"
|
|
|
|
- },
|
|
|
|
- defaultValue: element?.container?.props?.paddingLeft ?? 0
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- label: "X轴旋转",
|
|
|
|
- prop: "xRotate",
|
|
|
|
- type: "inputNumber",
|
|
|
|
- fieldProps: {
|
|
|
|
- min: 0,
|
|
|
|
- addonAfter: "deg"
|
|
|
|
- },
|
|
|
|
- defaultValue: element?.container?.props?.xRotate ?? 0
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- label: "Y轴旋转",
|
|
|
|
- prop: "yRotate",
|
|
|
|
- type: "inputNumber",
|
|
|
|
- fieldProps: {
|
|
|
|
- min: 0,
|
|
|
|
- addonAfter: "deg"
|
|
|
|
- },
|
|
|
|
- defaultValue: element?.container?.props?.yRotate ?? 0
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- label: "Z轴旋转",
|
|
|
|
- prop: "zRotate",
|
|
|
|
- type: "inputNumber",
|
|
|
|
- fieldProps: {
|
|
|
|
- min: 0,
|
|
|
|
- addonAfter: "deg"
|
|
|
|
- },
|
|
|
|
- defaultValue: element?.container?.props?.zRotate ?? 0
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- label: "不透明度",
|
|
|
|
- prop: "opacity",
|
|
|
|
- type: "slider",
|
|
|
|
- defaultValue: element?.container?.props?.opacity ?? 100
|
|
|
|
- }
|
|
|
|
- ]
|
|
|
|
- }
|
|
|
|
-]});
|
|
|
|
|
|
+const { formItems } = useComponentConfig();
|
|
|
|
|
|
watch(
|
|
watch(
|
|
() => projectStore.currentSelectedElements,
|
|
() => projectStore.currentSelectedElements,
|
|
@@ -295,9 +66,26 @@ watch(
|
|
{ immediate: true, deep: true }
|
|
{ immediate: true, deep: true }
|
|
);
|
|
);
|
|
|
|
|
|
-const handleConfigChange = (config: any) => {
|
|
|
|
|
|
+// 组件内容配置
|
|
|
|
+const handleContentConfigChange = (config: any) => {
|
|
|
|
+ const key = projectStore.selectedElementKeys[0];
|
|
|
|
+ projectStore.updateElement(key, "props", config);
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+// 组件配置
|
|
|
|
+const handleComponentConfigChange = (config: Record<string, any>) => {
|
|
|
|
+ const container: Record<string, any> = {};
|
|
|
|
+ const currentContainer = cloneDeep(
|
|
|
|
+ projectStore.currentSelectedElements[0].container
|
|
|
|
+ );
|
|
|
|
+ Object.entries(config).forEach(([key, value]) => {
|
|
|
|
+ set(container, key, value);
|
|
|
|
+ });
|
|
|
|
+ defaultsDeep(container, currentContainer);
|
|
const key = projectStore.selectedElementKeys[0];
|
|
const key = projectStore.selectedElementKeys[0];
|
|
- projectStore.updateElement(key, 'props', config);
|
|
|
|
|
|
+ console.log(container);
|
|
|
|
+ projectStore.updateElement(key, "container", container);
|
|
|
|
+ projectStore.updateElement(key, "name", container?.name);
|
|
};
|
|
};
|
|
</script>
|
|
</script>
|
|
|
|
|
|
@@ -318,6 +106,9 @@ const handleConfigChange = (config: any) => {
|
|
background-color: @bg-color;
|
|
background-color: @bg-color;
|
|
padding-top: 12px;
|
|
padding-top: 12px;
|
|
}
|
|
}
|
|
|
|
+ :deep(.ant-tabs-content) {
|
|
|
|
+ background-color: @bg-color;
|
|
|
|
+ }
|
|
.config-content {
|
|
.config-content {
|
|
padding: 12px;
|
|
padding: 12px;
|
|
padding-top: 0;
|
|
padding-top: 0;
|