import { computed, ref } from 'vue'; import { list as cfgList } from '@/views/vent/deviceManager/configurationTable/configuration.api'; import { list } from '@/views/vent/deviceManager/deviceTable/device.api'; import { ModuleData } from '@/views/vent/deviceManager/configurationTable/adapters'; // import mapComponent from './components/3Dmap/index.vue'; export function useInitConfig(deviceType: string) { function fetchConfig() { cfgList({ deviceType, }).then(({ records }) => { configs.value = records[0]?.moduleData; }); } const configs = ref({}); return { fetchConfig, configs, }; } export function useInitDevices(devicekind: string) { const devices = ref[]>([]); const options = ref<{ label: string; value: string }[]>([]); const selectedDeviceID = ref(''); const selectedDevice = computed(() => { return ( devices.value.find((e) => { return e.id === selectedDeviceID.value; }) || {} ); }); // 获取设备数据,赋值并以选项格式返回给 Header 消费 function fetchDevices() { return list({ devicekind, }).then(({ records }) => { devices.value = records; selectedDeviceID.value = records[0]?.id; options.value = records.map((e) => { return { label: e.strinstallpos, value: e.id, }; }); }); } return { fetchDevices, selectedDevice, selectedDeviceID, options, }; }