save
This commit is contained in:
@@ -27,11 +27,10 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent, type PropType, ref, watch } from 'vue';
|
||||
import { defineComponent, onMounted, type PropType, ref } from 'vue';
|
||||
import { safePreventDefault, safeStopPropagation } from '@/utils/event';
|
||||
import { findPlatformWithComponents } from './api';
|
||||
import { type Scenario } from './types';
|
||||
import { type PlatformWithComponents } from '../types';
|
||||
import {findPlatformWithComponents} from './api'
|
||||
import { type PlatformWithComponents, type Scenario } from './types';
|
||||
|
||||
export default defineComponent({
|
||||
emits: ['drag-item-start', 'drag-item-end'],
|
||||
@@ -41,14 +40,21 @@ export default defineComponent({
|
||||
required: true,
|
||||
}
|
||||
},
|
||||
setup(props, { emit }) {
|
||||
setup(_props, { emit }) {
|
||||
|
||||
const activeKey = ref<number>(1);
|
||||
const templateData = ref<PlatformWithComponents[]>([]);
|
||||
const isDraggingOver = ref<boolean>(false);
|
||||
const draggedNodeData = ref<PlatformWithComponents | null>(null);
|
||||
const currentScenario = ref<Scenario|null>(props.scenario)
|
||||
|
||||
const currentScenario = ref<Scenario|null>(_props.scenario)
|
||||
|
||||
const loadTress = () => {
|
||||
templateData.value = []
|
||||
findPlatformWithComponents(_props.scenario?.id).then(r => {
|
||||
templateData.value = r.data ?? []
|
||||
});
|
||||
};
|
||||
|
||||
const handleDragStart = (e: DragEvent, nm: PlatformWithComponents) => {
|
||||
let dragNode: PlatformWithComponents = { ...nm };
|
||||
draggedNodeData.value = dragNode as PlatformWithComponents;
|
||||
@@ -86,17 +92,16 @@ export default defineComponent({
|
||||
};
|
||||
|
||||
|
||||
const load = (id: number)=> {
|
||||
findPlatformWithComponents(id).then(re=> {
|
||||
templateData.value = re.data ?? []
|
||||
const load = ()=> {
|
||||
findPlatformWithComponents(1).then(re=> {
|
||||
console.error(re);
|
||||
})
|
||||
}
|
||||
|
||||
watch(()=> props.scenario,(n: Scenario|null|undefined )=> {
|
||||
if(n){
|
||||
load(n.id);
|
||||
}
|
||||
}, {deep: true, immediate: true} )
|
||||
onMounted(() => {
|
||||
loadTress();
|
||||
load();
|
||||
});
|
||||
|
||||
return {
|
||||
activeKey,
|
||||
|
||||
Reference in New Issue
Block a user