2024-07-23 14:50:17 +08:00
|
|
|
<template>
|
2024-08-01 22:42:33 +08:00
|
|
|
<div class="pl-6" v-if="storageLocationsTree.length" v-for="storageLocationTree in storageLocationsTree"
|
2024-07-23 14:50:17 +08:00
|
|
|
:key="storageLocationTree.storage_location.id">
|
|
|
|
<div class="flex items-center">
|
|
|
|
<i v-if="storageLocationTree.children.length > 0"
|
|
|
|
:class="{'sn-icon-up': opendedStorageLocations[storageLocationTree.storage_location.id],
|
|
|
|
'sn-icon-down': !opendedStorageLocations[storageLocationTree.storage_location.id]}"
|
|
|
|
@click="opendedStorageLocations[storageLocationTree.storage_location.id] = !opendedStorageLocations[storageLocationTree.storage_location.id]"
|
|
|
|
class="sn-icon p-2 pr-1 cursor-pointer"></i>
|
|
|
|
<i v-else class="sn-icon sn-icon-up p-2 pr-1 opacity-0"></i>
|
2024-08-06 21:13:21 +08:00
|
|
|
<div @click="selectStorageLocation(storageLocationTree)"
|
|
|
|
class="flex items-center pl-1 flex-1 gap-2"
|
|
|
|
:class="{
|
|
|
|
'!bg-sn-super-light-blue': storageLocationTree.storage_location.id == value,
|
|
|
|
'text-sn-blue cursor-pointer hover:bg-sn-super-light-grey': (
|
2024-09-30 19:42:05 +08:00
|
|
|
(moveMode === 'locations' || storageLocationTree.storage_location.container) && managePermission(storageLocationTree)
|
2024-08-06 21:13:21 +08:00
|
|
|
)
|
|
|
|
}">
|
2024-07-29 21:41:40 +08:00
|
|
|
<i v-if="storageLocationTree.storage_location.container" class="sn-icon sn-icon-item"></i>
|
2024-07-23 14:50:17 +08:00
|
|
|
<div class="flex-1 truncate p-2 pl-0" :title="storageLocationTree.storage_location.name">
|
|
|
|
{{ storageLocationTree.storage_location.name }}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<MoveTree v-if="opendedStorageLocations[storageLocationTree.storage_location.id]"
|
2024-08-01 22:42:33 +08:00
|
|
|
:storageLocationsTree="storageLocationTree.children"
|
2024-07-23 14:50:17 +08:00
|
|
|
:value="value"
|
2024-09-30 19:42:05 +08:00
|
|
|
:canManage="managePermission(storageLocationTree)"
|
2024-08-06 21:13:21 +08:00
|
|
|
:moveMode="moveMode"
|
2024-07-23 14:50:17 +08:00
|
|
|
@selectStorageLocation="$emit('selectStorageLocation', $event)" />
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
name: 'MoveTree',
|
|
|
|
emits: ['selectStorageLocation'],
|
|
|
|
props: {
|
2024-08-01 22:42:33 +08:00
|
|
|
storageLocationsTree: Array,
|
2024-08-06 21:13:21 +08:00
|
|
|
value: Number,
|
2024-09-30 19:42:05 +08:00
|
|
|
moveMode: String,
|
|
|
|
canManage: Boolean
|
2024-07-23 14:50:17 +08:00
|
|
|
},
|
|
|
|
components: {
|
|
|
|
MoveTree: () => import('./move_tree.vue')
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
opendedStorageLocations: {}
|
|
|
|
};
|
2024-08-06 21:13:21 +08:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
selectStorageLocation(storageLocationTree) {
|
2024-09-30 19:42:05 +08:00
|
|
|
if (!this.managePermission(storageLocationTree)) return;
|
|
|
|
|
2024-08-06 21:13:21 +08:00
|
|
|
if (this.moveMode === 'locations' || storageLocationTree.storage_location.container) {
|
|
|
|
this.$emit('selectStorageLocation', storageLocationTree.storage_location.id);
|
|
|
|
}
|
2024-09-30 19:42:05 +08:00
|
|
|
},
|
|
|
|
managePermission(loc) {
|
|
|
|
return loc.storage_location.parent_id ? this.canManage : loc.can_manage;
|
2024-08-06 21:13:21 +08:00
|
|
|
}
|
2024-07-23 14:50:17 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|