You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
927 B
41 lines
927 B
<template> |
|
<el-tree-select :data="data" :props="{label: 'shortName', value: 'id'}" node-key="id" :default-expanded-keys="['12630']" clearable filterable check-strictly /> |
|
</template> |
|
<script setup> |
|
import useCatchStore from '@/stores/modules/catch' |
|
import { ROOT_DEPART_ID } from '@/enums/appEnums'; |
|
|
|
const data = ref([]) |
|
|
|
const props = defineProps({ |
|
showRoot: { |
|
type: Boolean, |
|
default: false |
|
}, |
|
auth: { |
|
type: Boolean, |
|
default: true |
|
} |
|
}) |
|
|
|
const catchSotre = useCatchStore(); |
|
const departs = props.auth ? catchSotre.getDeparts() : catchSotre.getDepartsAll(); |
|
|
|
onMounted(() => { |
|
getData() |
|
}) |
|
watch(departs, () => { |
|
getData() |
|
}) |
|
|
|
function getData() { |
|
if (!props.showRoot && departs.length && departs[0].id === ROOT_DEPART_ID) { |
|
data.value = departs[0].children |
|
} else { |
|
data.value = departs |
|
} |
|
} |
|
</script> |
|
<style lang="scss" scoped> |
|
|
|
</style> |