fix
This commit is contained in:
@ -11,28 +11,50 @@
|
|||||||
<div class="left">
|
<div class="left">
|
||||||
<div class="title">组件</div>
|
<div class="title">组件</div>
|
||||||
<VueDraggable
|
<VueDraggable
|
||||||
v-model="store.components"
|
v-model="list0"
|
||||||
:animation="150"
|
:animation="150"
|
||||||
:group="{ name: 'people', pull: 'clone', put: false }"
|
:group="{ name: 'designer', pull: 'clone', put: false }"
|
||||||
:sort="false"
|
:sort="false"
|
||||||
:clone="clone"
|
@clone="clone"
|
||||||
@start="onStart"
|
@start="onStart"
|
||||||
@end="onEnd"
|
@end="onEnd"
|
||||||
>
|
>
|
||||||
<div v-for="item in store.components" :key="item.id" class="tem_btn">
|
<div v-for="item in list0" :key="item.id" class="tem_btn">
|
||||||
{{ item.name }}
|
{{ item.name }}
|
||||||
</div>
|
</div>
|
||||||
</VueDraggable>
|
</VueDraggable>
|
||||||
</div>
|
</div>
|
||||||
<div ref="targetContent" class="center">
|
<div ref="targetContent" class="center">
|
||||||
<VueDraggable
|
<VueDraggable
|
||||||
v-model="store.previewScheme"
|
v-model="list"
|
||||||
:group="{name: 'designer', pull: 'clone', put: false}"
|
:sort="true"
|
||||||
|
:animation="150"
|
||||||
|
group="designer"
|
||||||
ghost-class="ghost"
|
ghost-class="ghost"
|
||||||
class="canvas"
|
class="canvas"
|
||||||
|
@start="onPreviewStart"
|
||||||
|
@update="onPreviewUpdate"
|
||||||
|
@stop="onPreviewStop"
|
||||||
>
|
>
|
||||||
<NestedFunction v-model="store.previewScheme"></NestedFunction>
|
{{list}}
|
||||||
|
<!-- {{store.previewScheme}}-->
|
||||||
|
<!-- <template v-for="item in store.previewScheme" :key="item.id">-->
|
||||||
|
<!-- <component :id="item.id" :is="item.type" v-bind="item.props"-->
|
||||||
|
<!-- :class="item.class" :style="item.style">-->
|
||||||
|
<!-- {{ item.text }}-->
|
||||||
|
<!--<!– <template v-for="child in componentChildren" :key="child.id">–>-->
|
||||||
|
<!--<!– <DynamicComponent :component-data="child" />–>-->
|
||||||
|
<!--<!– </template>–>-->
|
||||||
|
<!--<!– <template v-for="(slot, key, index) in componentSlots" :key="index" v-slot:[key]>–>-->
|
||||||
|
<!--<!– <DynamicComponent :component-data="slot" />–>-->
|
||||||
|
<!--<!– </template>–>-->
|
||||||
|
<!-- </component>-->
|
||||||
|
<!-- </template>-->
|
||||||
|
<!-- <DynamicComponent v-for="component in store.previewScheme" :key="component.id" :componentData="component">-->
|
||||||
|
<!-- {{ component.id }}-->
|
||||||
|
<!-- </DynamicComponent>-->
|
||||||
</VueDraggable>
|
</VueDraggable>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<!-- <div class="right">-->
|
<!-- <div class="right">-->
|
||||||
<!-- <component :is="componentsList[store?.nowComponent?.set]"></component>-->
|
<!-- <component :is="componentsList[store?.nowComponent?.set]"></component>-->
|
||||||
@ -41,20 +63,22 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {VueDraggable} from "vue-draggable-plus";
|
import {DraggableEvent, VueDraggable} from "vue-draggable-plus";
|
||||||
import {onMounted, watch} from 'vue';
|
import {onMounted, ref, watch} from 'vue';
|
||||||
import {uuid} from 'lsp-uuid';
|
import {uuid} from 'lsp-uuid';
|
||||||
import {componentScheme} from "@/schemes/scheme";
|
import {componentScheme} from "@/schemes/scheme";
|
||||||
import {useSchemeStore} from '@/stores/useSchemeStore';
|
import {useSchemeStore} from '@/stores/useSchemeStore';
|
||||||
import {IComponent} from "@/type/IComponent";
|
import {IComponent} from "@/type/IComponent";
|
||||||
import NestedFunction from "@/components/NestedFunction.vue";
|
|
||||||
|
|
||||||
|
let list0=ref([])
|
||||||
|
|
||||||
|
let list=ref([])
|
||||||
|
|
||||||
let componentsList = [];
|
let componentsList = [];
|
||||||
const store = useSchemeStore();
|
const store = useSchemeStore();
|
||||||
|
|
||||||
watch(store, (n) => {
|
watch(store, (n) => {
|
||||||
console.log("数据", n);
|
console.log("store发生了变化", n);
|
||||||
});
|
});
|
||||||
|
|
||||||
const baseScheme =
|
const baseScheme =
|
||||||
@ -84,7 +108,7 @@ store.$onAction(
|
|||||||
onError, // action 抛出或拒绝的钩子
|
onError, // action 抛出或拒绝的钩子
|
||||||
}) => {
|
}) => {
|
||||||
after((result) => {
|
after((result) => {
|
||||||
console.log(result);
|
console.log(`store action-${name}回调后:`+result);
|
||||||
})
|
})
|
||||||
// 如果 action 抛出或返回一个拒绝的 promise,这将触发
|
// 如果 action 抛出或返回一个拒绝的 promise,这将触发
|
||||||
onError((error) => {
|
onError((error) => {
|
||||||
@ -103,11 +127,23 @@ const initScheme = () => {
|
|||||||
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
list0.value.push(
|
||||||
|
{
|
||||||
|
"id":123,
|
||||||
|
"name":"www"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id":125,
|
||||||
|
"name":"rrr"
|
||||||
|
}
|
||||||
|
);
|
||||||
|
list.value=[]
|
||||||
initScheme();
|
initScheme();
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
});
|
});
|
||||||
|
|
||||||
const clone = function (element: IComponent) {
|
function clone (element: Record<'name' | 'id'|'type'|'props'|'class'|'text'|'style'|'slots', IComponent>) {
|
||||||
|
console.log("clone",element)
|
||||||
return {
|
return {
|
||||||
id: `${element.type}-${uuid()}`,
|
id: `${element.type}-${uuid()}`,
|
||||||
name: element.name,
|
name: element.name,
|
||||||
@ -125,17 +161,27 @@ const clone = function (element: IComponent) {
|
|||||||
loop: {},
|
loop: {},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
const onEnd = (event:DraggableEvent) => {
|
||||||
const onEnd = (obj: any) => {
|
console.log("onEnd",event)
|
||||||
console.log(obj)
|
|
||||||
// const {oldDraggableIndex} = obj;
|
// const {oldDraggableIndex} = obj;
|
||||||
// store.previewData(store.component[oldDraggableIndex]);
|
// store.previewData(store.component[oldDraggableIndex]);
|
||||||
// store.nowComponentsData(store.component[oldDraggableIndex]);
|
// store.nowComponentsData(store.component[oldDraggableIndex]);
|
||||||
};
|
};
|
||||||
|
|
||||||
const onStart = function () {
|
const onStart = function (event) {
|
||||||
console.log("start")
|
console.log("onStart",event)
|
||||||
}
|
}
|
||||||
|
const onPreviewStart = function (event) {
|
||||||
|
console.log("onPreviewStart",event)
|
||||||
|
}
|
||||||
|
const onPreviewUpdate = function (event) {
|
||||||
|
console.log("onPreviewUpdate",event)
|
||||||
|
}
|
||||||
|
|
||||||
|
const onPreviewStop = function (event) {
|
||||||
|
console.log(event)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const view = () => {
|
const view = () => {
|
||||||
localStorage.setItem("lowcode", JSON.stringify(store.previewScheme));
|
localStorage.setItem("lowcode", JSON.stringify(store.previewScheme));
|
||||||
|
|||||||
Reference in New Issue
Block a user