| | |
| | | </view> |
| | | </view> |
| | | </view> |
| | | <view v-if="isEdit" |
| | | class="item-actions"> |
| | | <up-button size="mini" |
| | | type="primary" |
| | | @click.stop="emitEdit">编辑</up-button> |
| | | <up-button size="mini" |
| | | type="success" |
| | | @click.stop="emitAddChild">添加</up-button> |
| | | <up-button size="mini" |
| | | type="error" |
| | | @click.stop="emitRemove">删除</up-button> |
| | | </view> |
| | | </view> |
| | | </view> |
| | | <!-- 递归展示子节点 --> |
| | | <view v-if="hasChildren && isExpanded" |
| | | class="children-container"> |
| | | <BomStructureItem v-for="(child, index) in item.children" |
| | | :key="index" |
| | | :key="child.tempId || child.id || index" |
| | | :item="child" |
| | | :level="level + 1" |
| | | :isLast="index === item.children.length - 1" |
| | | :processOptions="processOptions" /> |
| | | :processOptions="processOptions" |
| | | :isEdit="isEdit" |
| | | @edit="$emit('edit', $event)" |
| | | @add-child="$emit('add-child', $event)" |
| | | @remove="$emit('remove', $event)" /> |
| | | </view> |
| | | </view> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { ref, computed, defineProps } from "vue"; |
| | | import { ref, computed, defineProps, defineEmits } from "vue"; |
| | | |
| | | const props = defineProps({ |
| | | item: { |
| | |
| | | type: Array, |
| | | default: () => [], |
| | | }, |
| | | isEdit: { |
| | | type: Boolean, |
| | | default: false, |
| | | }, |
| | | }); |
| | | const emit = defineEmits(["edit", "add-child", "remove"]); |
| | | |
| | | const isExpanded = ref(true); |
| | | const hasChildren = computed( |
| | |
| | | const getProcessName = id => { |
| | | const process = props.processOptions.find(p => p.id === id); |
| | | return process ? process.name : "-"; |
| | | }; |
| | | |
| | | const emitEdit = () => { |
| | | emit("edit", props.item); |
| | | }; |
| | | const emitAddChild = () => { |
| | | emit("add-child", props.item); |
| | | }; |
| | | const emitRemove = () => { |
| | | emit("remove", props.item); |
| | | }; |
| | | </script> |
| | | |
| | |
| | | .children-container { |
| | | position: relative; |
| | | } |
| | | |
| | | .item-actions { |
| | | display: flex; |
| | | justify-content: flex-end; |
| | | gap: 16rpx; |
| | | margin-top: 16rpx; |
| | | } |
| | | </style> |