|
@@ -2,7 +2,7 @@ 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 { Config } from '@/views/vent/deviceManager/configurationTable/types';
|
|
|
-import { getBDDustData, getBDFireData, getHomeData } from '../configurable.api';
|
|
|
+import { getDisHome, getHomeData } from '../configurable.api';
|
|
|
import { getFormattedText } from '../../../deviceManager/configurationTable/adapters';
|
|
|
import { get } from 'lodash-es';
|
|
|
// import mapComponent from './components/3Dmap/index.vue';
|
|
@@ -23,6 +23,7 @@ import { get } from 'lodash-es';
|
|
|
// };
|
|
|
// }
|
|
|
|
|
|
+/** 初始化配置以及根据配置获取数据 */
|
|
|
export function useInitConfigs() {
|
|
|
const configs = ref<Config[]>([]);
|
|
|
const isOriginal = computed(() => {
|
|
@@ -44,6 +45,7 @@ export function useInitConfigs() {
|
|
|
function fetchConfigs(pageType?: string) {
|
|
|
return cfgList({ pageType }).then(({ records }) => {
|
|
|
configs.value = records;
|
|
|
+ return records;
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -126,7 +128,7 @@ export function useInitDevices(devicekind: string, config: Config['moduleData'])
|
|
|
}
|
|
|
|
|
|
/** 保德专用-初始化设备信息,包含了适配了 header config 的下拉框选项、已选择设备的各个详细子项等,如果模块不需要展示 header 那么会将全部信息提供给已选择设备以供消费 */
|
|
|
-export function useInitDevicesBD(devicekind: string, pageType: string, config: Config['moduleData']) {
|
|
|
+export function useInitDevicesBD(devicekind: string, config: Config['moduleData']) {
|
|
|
const { header, mock } = config;
|
|
|
const devices = ref<Record<string, any>[]>([]);
|
|
|
const options = ref<{ label: string; value: string }[]>([]);
|
|
@@ -152,11 +154,7 @@ export function useInitDevicesBD(devicekind: string, pageType: string, config: C
|
|
|
// 获取设备数据,赋值并以选项格式返回给 Header 消费
|
|
|
function fetchDevices({ init = false } = {}) {
|
|
|
const { value } = header.selector;
|
|
|
- const apiMap = {
|
|
|
- BD_dust: getBDDustData,
|
|
|
- BD_fire: getBDFireData,
|
|
|
- };
|
|
|
- const promise = mock ? Promise.resolve(mock) : apiMap[pageType]();
|
|
|
+ const promise = mock ? Promise.resolve(mock) : getDisHome({ dataList: devicekind.split('.')[0] });
|
|
|
return promise.then((result) => {
|
|
|
if (header.show && header.showSelector) {
|
|
|
// 如果配置里指明需要 header,检验后初始化设备信息
|
|
@@ -198,21 +196,32 @@ export function useInitDevicesBD(devicekind: string, pageType: string, config: C
|
|
|
};
|
|
|
}
|
|
|
|
|
|
-export function useInitScene(scenekind: string) {
|
|
|
- const scene = ref<Record<string, any>[]>([]);
|
|
|
-
|
|
|
- // 获取设备数据,赋值并以选项格式返回给 Header 消费
|
|
|
- function fetchScene() {
|
|
|
- return getHomeData({}).then((result) => {
|
|
|
- if (!result[scenekind]) return;
|
|
|
- // 如果数据只有一条,转为数据
|
|
|
- const records: { strinstallpos: string; id: string }[] = result[scenekind];
|
|
|
- scene.value = records;
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- return {
|
|
|
- fetchScene,
|
|
|
- scene,
|
|
|
- };
|
|
|
-}
|
|
|
+/**
|
|
|
+ * 根据模块的配置初始化基准 Module 组件需要的数据,包括选择框、设备等信息
|
|
|
+ * @param apidata api 返回的数据
|
|
|
+ * @param config 本模块的配置
|
|
|
+ */
|
|
|
+// export function useInitModule(moduleData: Config['moduleData'], apidata?: any) {
|
|
|
+// const { header, mock } = moduleData;
|
|
|
+// const data = mock || apidata;
|
|
|
+// 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;
|
|
|
+// }) || {}
|
|
|
+// );
|
|
|
+// });
|
|
|
+// const selectedDeviceLabel = computed(() => {
|
|
|
+// const res = options.value.find((e) => {
|
|
|
+// return e.value === selectedDeviceID.value;
|
|
|
+// });
|
|
|
+// return res ? res.label : '';
|
|
|
+// });
|
|
|
+// const selectedDeviceSlot = computed(() => {
|
|
|
+// return getFormattedText(selectedDevice.value, header.slot.value);
|
|
|
+// });
|
|
|
+// }
|