56 lines
1.3 KiB
Vue
56 lines
1.3 KiB
Vue
|
|
<template>
|
||
|
|
<el-select
|
||
|
|
v-if="hasCrossDomain"
|
||
|
|
:model-value="modelValue"
|
||
|
|
placeholder="全部部门/公司"
|
||
|
|
clearable
|
||
|
|
style="width: 180px;"
|
||
|
|
@update:model-value="$emit('update:modelValue', $event)"
|
||
|
|
@change="$emit('change', $event)"
|
||
|
|
>
|
||
|
|
<el-option label="全部部门/公司" value="" />
|
||
|
|
<el-option
|
||
|
|
v-for="c in companies"
|
||
|
|
:key="c"
|
||
|
|
:label="c"
|
||
|
|
:value="c"
|
||
|
|
/>
|
||
|
|
</el-select>
|
||
|
|
</template>
|
||
|
|
|
||
|
|
<script setup lang="ts">
|
||
|
|
import { ref, computed, onMounted } from 'vue'
|
||
|
|
import { useUserStore } from '@/stores/user'
|
||
|
|
import { getFilterOptions } from '@/api/inbound/buy'
|
||
|
|
|
||
|
|
const props = defineProps<{
|
||
|
|
modelValue?: string
|
||
|
|
}>()
|
||
|
|
|
||
|
|
defineEmits<{
|
||
|
|
'update:modelValue': [value: string]
|
||
|
|
change: [value: string]
|
||
|
|
}>()
|
||
|
|
|
||
|
|
const userStore = useUserStore()
|
||
|
|
const companies = ref<string[]>([])
|
||
|
|
|
||
|
|
const hasCrossDomain = computed(() => {
|
||
|
|
const role = (userStore.role || '').toUpperCase()
|
||
|
|
if (role === 'SUPER_ADMIN') return true
|
||
|
|
return userStore.hasPermission('crossDomain')
|
||
|
|
})
|
||
|
|
|
||
|
|
onMounted(async () => {
|
||
|
|
if (!hasCrossDomain.value) return
|
||
|
|
try {
|
||
|
|
const res: any = await getFilterOptions()
|
||
|
|
if (res.code === 200) {
|
||
|
|
companies.value = res.data.companies || []
|
||
|
|
}
|
||
|
|
} catch (e) {
|
||
|
|
console.error('获取公司列表失败', e)
|
||
|
|
}
|
||
|
|
})
|
||
|
|
</script>
|