no message
parent
8840675dc5
commit
4f93f73786
|
|
@ -1,39 +0,0 @@
|
||||||
/**
|
|
||||||
* 收货单位-定义TS类型
|
|
||||||
*/
|
|
||||||
|
|
||||||
//查询类型定义
|
|
||||||
export interface AddressQueryForm {
|
|
||||||
addressId?: number;
|
|
||||||
pageNum: number;
|
|
||||||
pageSize: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
//表格数据类型定义
|
|
||||||
export interface AddressTableDate {
|
|
||||||
addressId: number;
|
|
||||||
name: string;
|
|
||||||
person: string;
|
|
||||||
telephone: string;
|
|
||||||
address: string;
|
|
||||||
createTime: Date;
|
|
||||||
}
|
|
||||||
|
|
||||||
//新增或修改表单类型定义
|
|
||||||
export interface AddressAddOrUpdateForm {
|
|
||||||
addressId?: number;
|
|
||||||
name?: string;
|
|
||||||
person?: string;
|
|
||||||
telephone?: string;
|
|
||||||
address?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
//下拉查询
|
|
||||||
interface AddressSelect {
|
|
||||||
addressId: number;
|
|
||||||
name: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -7,13 +7,13 @@
|
||||||
<a-select
|
<a-select
|
||||||
v-model:value="selectValue"
|
v-model:value="selectValue"
|
||||||
:style="`width: ${width}`"
|
:style="`width: ${width}`"
|
||||||
:placeholder="props.placeholder"
|
:placeholder="placeholder"
|
||||||
:showSearch="true"
|
:showSearch="true"
|
||||||
:allowClear="true"
|
:allowClear="true"
|
||||||
:size="size"
|
:size="size"
|
||||||
@change="handleChange"
|
@change="handleChange"
|
||||||
:disabled="disabled"
|
:disabled="disabled"
|
||||||
:mode="multiple ? 'multiple' : ''"
|
:mode="multiple ? 'multiple' : undefined"
|
||||||
optionFilterProp="label"
|
optionFilterProp="label"
|
||||||
>
|
>
|
||||||
<a-select-option v-for="address in addressList" :key="address.addressId" :label="address.name">
|
<a-select-option v-for="address in addressList" :key="address.addressId" :label="address.name">
|
||||||
|
|
@ -25,11 +25,18 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {onMounted, ref, watch} from 'vue';
|
import {onMounted, ref, watch} from 'vue';
|
||||||
import {addressApi} from "/@/api/business/wms/base/address/address-api";
|
import {addressApi} from "/@/api/business/wms/base/address/address-api";
|
||||||
import {AddressSelect} from "/@/api/business/wms/base/address/address";
|
import {smartSentry} from '/@/lib/smart-sentry';
|
||||||
|
|
||||||
|
interface AddressItem {
|
||||||
|
addressId: number;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
value: [Number, String, Object, Array],
|
modelValue: {
|
||||||
|
type: [Number, String, Object, Array],
|
||||||
|
default: undefined
|
||||||
|
},
|
||||||
width: {
|
width: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '200px',
|
default: '200px',
|
||||||
|
|
@ -52,40 +59,43 @@ const props = defineProps({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const addressList = ref<AddressSelect[]>([]);
|
const addressList = ref<AddressItem[]>([]);
|
||||||
const selectValue = ref(props.value);
|
const selectValue = ref(props.modelValue);
|
||||||
|
|
||||||
async function queryData() {
|
async function queryData() {
|
||||||
let res = await addressApi.queryAddress({});
|
try {
|
||||||
addressList.value = res.data;
|
const res = await addressApi.queryAddress({});
|
||||||
|
addressList.value = res.data;
|
||||||
|
} catch (e) {
|
||||||
|
smartSentry.captureError(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const emit = defineEmits(['update:value', 'change']);
|
const emit = defineEmits(['update:modelValue', 'change']);
|
||||||
|
|
||||||
// 箭头value变化
|
// 监听modelValue变化
|
||||||
watch(
|
watch(
|
||||||
() => props.value,
|
() => props.modelValue,
|
||||||
(newValue) => {
|
(newValue) => {
|
||||||
selectValue.value = newValue;
|
selectValue.value = newValue;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
function getSelectedAddress(value: number | number[] | undefined): AddressSelect | AddressSelect[] | undefined {
|
function querySelectedAddress(value: any) {
|
||||||
if (Array.isArray(value)) {
|
if (Array.isArray(value)) {
|
||||||
return value
|
// 多选情况
|
||||||
.map(id => addressList.value.find(item => item.addressId === id))
|
return value.map((id) => addressList.value.find(item => item.addressId === id)).filter(Boolean);
|
||||||
.filter((item): item is AddressSelect => Boolean(item));
|
|
||||||
} else {
|
} else {
|
||||||
|
// 单选情况
|
||||||
return addressList.value.find(item => item.addressId === value);
|
return addressList.value.find(item => item.addressId === value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleChange(value: number | number[] | undefined) {
|
function handleChange(value: any) {
|
||||||
const selectedAddress = getSelectedAddress(value);
|
const selectedAddress = querySelectedAddress(value);
|
||||||
emit('update:value', value);
|
emit('update:modelValue', value);
|
||||||
emit('change', selectedAddress);
|
emit('change', selectedAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
onMounted(queryData);
|
onMounted(queryData);
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue