| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- 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<ModuleData>({});
- return {
- fetchConfig,
- configs,
- };
- }
- export function useInitDevices(devicekind: string) {
- const devices = ref<Record<string, any>[]>([]);
- const options = ref<{ label: string; value: string }[]>([]);
- const selectedDeviceID = ref<string>('');
- 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,
- };
- }
|