Files
django-vue3-admin/web/src/components/dept-format/index.vue
猿小天 7f184b2a9a 新功能:
1.部门显示组件
2023-12-27 19:08:55 +08:00

29 lines
643 B
Vue

<template>
<div>
{{ data }}
</div>
</template>
<script setup lang="ts">
import {defineProps,ref,watch} from 'vue'
import {useDeptInfoStore} from '/@/stores/modules/dept'
const props = defineProps({
modelValue:{
type: Number || String
}
})
const data = ref()
watch(()=>{
return props.modelValue
},async (newVal)=>{
const deptInfoStore = useDeptInfoStore()
const result = await deptInfoStore.getParentDeptById(newVal)
if(result?.nodes){
let name = ""
result.nodes.forEach((item:any,index:number)=>{
name += index>0?`/${item.name}`:item.name
})
data.value = name
}
},{immediate: true} )
</script>