设备数据查询绑定查询下拉框成功
This commit is contained in:
parent
dffb5a9fad
commit
c1a85a5d30
@ -19,6 +19,9 @@ const route = useRoute();
|
|||||||
const { DeviceType, DeviceId, FocusAddress } = route.query;
|
const { DeviceType, DeviceId, FocusAddress } = route.query;
|
||||||
const formOptions: VbenFormProps = {
|
const formOptions: VbenFormProps = {
|
||||||
schema: querySchema.value,
|
schema: querySchema.value,
|
||||||
|
initialValues: {
|
||||||
|
FocusAddress: FocusAddress as string,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
const gridOptions: VxeGridProps<any> = {
|
const gridOptions: VxeGridProps<any> = {
|
||||||
checkboxConfig: {
|
checkboxConfig: {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||||
|
|
||||||
import { computed, ref } from 'vue';
|
import { computed } from 'vue';
|
||||||
|
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
@ -8,34 +8,6 @@ import { $t } from '#/locales';
|
|||||||
|
|
||||||
import { getSelectResultList } from '#/api-client';
|
import { getSelectResultList } from '#/api-client';
|
||||||
|
|
||||||
// 手动加载选项数据
|
|
||||||
const systemNameOptions = ref<Array<{ label: string; value: string }>>([]);
|
|
||||||
|
|
||||||
const loadSystemNameOptions = async () => {
|
|
||||||
try {
|
|
||||||
const { data } = await getSelectResultList({
|
|
||||||
params: {
|
|
||||||
query: {
|
|
||||||
TypeName: 'BusinessSystemEnum',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
console.log('API Response:', data);
|
|
||||||
if (data?.items) {
|
|
||||||
systemNameOptions.value = data.items.map((item: any) => ({
|
|
||||||
label: item.secondValue || '',
|
|
||||||
value: item.value || '',
|
|
||||||
}));
|
|
||||||
console.log('Processed Options:', systemNameOptions.value);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Failed to load system name options:', error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// 立即加载数据
|
|
||||||
loadSystemNameOptions();
|
|
||||||
|
|
||||||
export const querySchema = computed(() => [
|
export const querySchema = computed(() => [
|
||||||
{
|
{
|
||||||
component: 'Input',
|
component: 'Input',
|
||||||
@ -43,13 +15,38 @@ export const querySchema = computed(() => [
|
|||||||
label: $t('abp.focus.focusAddress'),
|
label: $t('abp.focus.focusAddress'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
component: 'Select',
|
component: 'ApiSelect',
|
||||||
fieldName: 'SystemName',
|
fieldName: 'SystemName',
|
||||||
label: $t('abp.IoTDBBase.SystemName'),
|
label: $t('abp.IoTDBBase.SystemName'),
|
||||||
componentProps: computed(() => ({
|
componentProps: {
|
||||||
options: systemNameOptions.value,
|
api: getSelectResultList,
|
||||||
allowClear: true,
|
params: {
|
||||||
})),
|
query: {
|
||||||
|
TypeName: 'BusinessSystemEnum',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
labelField: 'secondValue',
|
||||||
|
valueField: 'value',
|
||||||
|
optionsPropName: 'options',
|
||||||
|
immediate: true,
|
||||||
|
afterFetch: (res: any) => {
|
||||||
|
console.log('ApiSelect afterFetch result:', res);
|
||||||
|
// 确保返回的是数组格式
|
||||||
|
if (Array.isArray(res)) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
// 如果是包装在 items 中的,提取出来
|
||||||
|
if (res && Array.isArray(res.items)) {
|
||||||
|
return res.items;
|
||||||
|
}
|
||||||
|
// 如果是包装在 data 中的,提取出来
|
||||||
|
if (res && Array.isArray(res.data)) {
|
||||||
|
return res.data;
|
||||||
|
}
|
||||||
|
// 如果都不是,返回空数组
|
||||||
|
return [];
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
export const tableSchema: any = computed((): VxeGridProps['columns'] => [
|
export const tableSchema: any = computed((): VxeGridProps['columns'] => [
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user