index.vue
1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<template>
<a-collapse class="card-collapse" v-for="(item, index) in list" :key="index" :default-active-key="['1']">
<a-collapse-item :header="`子数据${item.name}`" key="1">
<!-- {{item}}-->
<a-form-item field="name" label="选择变量">
<a-input-search search-button>
<template #button-icon>
<icon-search />
</template>
<template #button-default> 选择变量 </template>
</a-input-search>
</a-form-item>
<a-form-item field="name" label="变量编码">
<a-input />
</a-form-item>
<a-form-item label="子数据区">
<a-space style="width: 100%" direction="vertical" fill :size="16">
<a-button type="primary" @click="handleAddChildList(item,index)">
<template #icon>
<icon-plus />
</template>
添加子数据区
</a-button>
<node-sankey :list="item.children" :level="item.level + 1" />
</a-space>
</a-form-item>
</a-collapse-item>
</a-collapse>
</template>
<script setup lang="ts">
import {defineComponent} from "vue";
const props = defineProps({
list: {
type: Array,
default: []
},
level: {
type: String,
default:[]
}
})
const emit = defineEmits(["handleAddChildList"])
const handleAddChildList = (parent) => {
let obj = {
a: 1,
children: []
}
if (parent.children) {
let childName = `${parent.children.length + 1}`;
let childLevel = parent.level + 1;
parent.children.push({
name: `${parent.name}-${childName}`,
level: childLevel,
children: []
});
} else {
console.log("Cannot add child item to this menu item.");
}
// emit("handleAddChildList", {obj,index})
}
</script>
<script lang="ts">
export default {
name: 'node-sankey',
}
</script>
<style scoped>
</style>