This commit is contained in:
parent
c847bd29e1
commit
d9856230e6
@ -1,35 +1,35 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import {ref, watch} from 'vue';
|
import {onMounted, ref, watch} from 'vue';
|
||||||
import {Select} from 'ant-design-vue';
|
import {Select} from 'ant-design-vue';
|
||||||
import {resident_unitList,resident_unitInfo} from "#/api/property/resident/unit";
|
import {resident_unitList, resident_unitInfo} from "#/api/property/resident/unit";
|
||||||
|
|
||||||
defineOptions({name: 'QueryUnitList'});
|
defineOptions({name: 'QueryUnitList'});
|
||||||
|
|
||||||
const props= withDefaults(defineProps<{
|
const props = withDefaults(defineProps<{
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
isUpdate?:boolean;
|
isUpdate?: boolean;
|
||||||
unitId?:string;
|
unitId?: string;
|
||||||
}>(), {
|
}>(), {
|
||||||
disabled: false,
|
disabled: false,
|
||||||
placeholder: '可根据单位名称进行搜索...',
|
placeholder: '可根据单位名称进行搜索...',
|
||||||
isUpdate:false,
|
isUpdate: false,
|
||||||
unitId:'',
|
unitId: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
async function queryUnit(value: string, callback: any) {
|
async function queryUnit(value: string|undefined, callback: any) {
|
||||||
const queryData = {
|
const queryData = {
|
||||||
name: value,
|
name: value,
|
||||||
pageSize: 100,
|
pageSize: 100,
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
state:1,
|
state: 1,
|
||||||
}
|
}
|
||||||
const res = await resident_unitList(queryData);
|
const res = await resident_unitList(queryData);
|
||||||
const options = res.rows.map((unit) => ({
|
const options = res.rows.map((unit) => ({
|
||||||
label: unit.name+'-'+unit.id,
|
label: unit.name + '-' + unit.id,
|
||||||
value: unit.id,
|
value: unit.id,
|
||||||
name:unit.name,
|
name: unit.name,
|
||||||
unitNumber:unit.unitNumber,
|
unitNumber: unit.unitNumber,
|
||||||
}));
|
}));
|
||||||
callback(options);
|
callback(options);
|
||||||
}
|
}
|
||||||
@ -46,24 +46,28 @@ const handleChange = (val: string) => {
|
|||||||
emit('update:unitInfo', unitInfo);
|
emit('update:unitInfo', unitInfo);
|
||||||
};
|
};
|
||||||
|
|
||||||
async function getUnitInfo(val:string) {
|
async function getUnitInfo(val: string) {
|
||||||
const unit = await resident_unitInfo(val)
|
const unit = await resident_unitInfo(val)
|
||||||
if (unit) {
|
if (unit) {
|
||||||
data.value = [{
|
data.value = [{
|
||||||
label: unit.name+'-'+unit.id,
|
label: unit.name + '-' + unit.id,
|
||||||
value: unit.id,
|
value: unit.id,
|
||||||
name:unit.name,
|
name: unit.name,
|
||||||
unitNumber:unit.id,
|
unitNumber: unit.id,
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(() => props.unitId,
|
watch(() => props.unitId,
|
||||||
(newX) => {
|
(newX) => {
|
||||||
if (props.isUpdate&&newX) {
|
if (props.isUpdate && newX) {
|
||||||
getUnitInfo(newX)
|
getUnitInfo(newX)
|
||||||
}
|
}
|
||||||
}, {immediate: true})
|
}, {immediate: true})
|
||||||
|
|
||||||
|
onMounted(()=>{
|
||||||
|
queryUnit(undefined, (d: any[]) => (data.value = d));
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
Loading…
Reference in New Issue
Block a user