Otsuka-APP/components/BusinessCompany.vue

67 lines
1.4 KiB
Vue
Raw Normal View History

<template>
<uni-data-select
v-model="modelValue"
:localdata="options"
placeholder="请选择商业公司"
v-bind="omit($attrs,['change'])"
/>
</template>
<script setup>
import {defineModel, defineOptions, defineProps, getCurrentInstance, nextTick, onMounted, ref, watch} from 'vue'
import {omit} from "radash";
import {getBusinessCompanyList} from "../api/orderManager";
defineOptions({
name: "BusinessCompany",
inheritAttrs: false
})
const modelValue = defineModel()
// default: type = all_name
/**
* type:
* all_name = 显示所有名称
* id = value 值是 ID
*/
const props = defineProps({
type: {
type: String,
default: 'all_name'
},
areaId: {
type: Number,
default: 0
}
})
const {proxy} = getCurrentInstance()
const options = ref([])
const handleQuery = async () => {
const {data} = await getBusinessCompanyList({
isUnit: 0,
queryParam: {
areaId: props.areaId
}
})
options.value = data.map(item => {
return {
value: props.type === 'id' ? item.userid : item.businessname,
text: item.businessname
}
})
}
onMounted(async () => {
await nextTick()
await handleQuery()
})
watch(() => props.areaId, async (newValue) => {
if (newValue) {
await handleQuery()
}
})
</script>