feat: 新增地域下拉组件
This commit is contained in:
parent
2b512d0960
commit
7082fb015d
9
api/area.js
Normal file
9
api/area.js
Normal file
@ -0,0 +1,9 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 获取地域列表
|
||||
export const getAreaList = () => {
|
||||
return request({
|
||||
method: 'get',
|
||||
url: '/system/dept/regionals',
|
||||
})
|
||||
}
|
||||
36
components/Area.vue
Normal file
36
components/Area.vue
Normal file
@ -0,0 +1,36 @@
|
||||
<template>
|
||||
<uni-data-select
|
||||
v-model="modelValue"
|
||||
:localdata="options"
|
||||
v-bind="omit($attrs,['change'])"
|
||||
placeholder="请选择地域"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {defineModel, defineOptions, defineProps, getCurrentInstance, onMounted, ref} from 'vue'
|
||||
import {omit} from "radash";
|
||||
import UniDataSelect from "../uni_modules/uni-data-select/components/uni-data-select/uni-data-select.vue";
|
||||
import {getAreaList} from "../api/area";
|
||||
|
||||
defineOptions({
|
||||
name: "Area",
|
||||
inheritAttrs: false
|
||||
})
|
||||
|
||||
const modelValue = defineModel()
|
||||
const props = defineProps([])
|
||||
const {proxy} = getCurrentInstance()
|
||||
|
||||
const options = ref([])
|
||||
|
||||
onMounted(async () => {
|
||||
const {data} = await getAreaList()
|
||||
options.value = data.sort((a, b) => {
|
||||
return a.deptName.localeCompare(b.deptName, 'zh-CN');
|
||||
}).map(i => ({
|
||||
value: i.deptId,
|
||||
text: i.deptName
|
||||
}))
|
||||
})
|
||||
</script>
|
||||
Loading…
x
Reference in New Issue
Block a user