|
@ -2,7 +2,7 @@ import type { Liquid } from "@/services/liquid/liquidManage"; |
|
|
import type { ConfigItem, Container } from "@/services/sysConfig/sysConfig"; |
|
|
import type { ConfigItem, Container } from "@/services/sysConfig/sysConfig"; |
|
|
import { defineStore } from "pinia"; |
|
|
import { defineStore } from "pinia"; |
|
|
import { computed, ref } from "vue"; |
|
|
import { computed, ref } from "vue"; |
|
|
import * as R from 'ramda'; |
|
|
|
|
|
|
|
|
import * as R from "ramda"; |
|
|
|
|
|
|
|
|
export const useSettingStore = defineStore("setting", () => { |
|
|
export const useSettingStore = defineStore("setting", () => { |
|
|
const configs = ref<ConfigItem[] | undefined>(); |
|
|
const configs = ref<ConfigItem[] | undefined>(); |
|
@ -10,24 +10,35 @@ export const useSettingStore = defineStore("setting", () => { |
|
|
configs.value = usr; |
|
|
configs.value = usr; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// 所有容器 : 8酸桶+1废桶
|
|
|
const containerConf = ref<Container[] | undefined>(); |
|
|
const containerConf = ref<Container[] | undefined>(); |
|
|
const setContainerConf = (containers: Container[]) => { |
|
|
const setContainerConf = (containers: Container[]) => { |
|
|
containerConf.value = containers; |
|
|
containerConf.value = containers; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// 酸液列表
|
|
|
const liquidList = ref<Liquid[] | undefined>(); |
|
|
const liquidList = ref<Liquid[] | undefined>(); |
|
|
const setLiquidList = (liquids: Liquid[]) => { |
|
|
const setLiquidList = (liquids: Liquid[]) => { |
|
|
liquidList.value = liquids; |
|
|
liquidList.value = liquids; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// 酸液列表 ID映射表: 使用方法 liquidIdMap[液体ID] -> Liquid对象
|
|
|
|
|
|
const liquidIdMap = computed(() => { |
|
|
|
|
|
//@ts-ignore
|
|
|
|
|
|
return R.groupBy(l => l.id, liquidList.value || []); |
|
|
|
|
|
}); |
|
|
|
|
|
// 8个酸桶
|
|
|
const heatContainers = computed(() => { |
|
|
const heatContainers = computed(() => { |
|
|
if (!containerConf.value) return []; |
|
|
if (!containerConf.value) return []; |
|
|
return containerConf.value.filter(c => c.type === 0); |
|
|
return containerConf.value.filter(c => c.type === 0); |
|
|
}); |
|
|
}); |
|
|
|
|
|
// 配置了酸液的桶
|
|
|
|
|
|
const heatContainerWithLiquid = computed(() => { |
|
|
|
|
|
return heatContainers.value.filter(c => c.solutionId); |
|
|
|
|
|
}); |
|
|
|
|
|
// 配置了桶的酸液
|
|
|
const availableLiquids = computed(() => { |
|
|
const availableLiquids = computed(() => { |
|
|
const solIds = heatContainers.value.filter(h => h.solutionId).map(h => h.solutionId) |
|
|
|
|
|
return R.innerJoin((record, id) => record.id === id, liquidList.value || [], solIds) |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
const solIds = heatContainers.value.filter(h => h.solutionId).map(h => h.solutionId); |
|
|
|
|
|
return R.innerJoin((record, id) => record.id === id, liquidList.value || [], solIds); |
|
|
|
|
|
}); |
|
|
const heatAreaConfig = computed(() => { |
|
|
const heatAreaConfig = computed(() => { |
|
|
if (!configs.value) return []; |
|
|
if (!configs.value) return []; |
|
|
return (configs.value.find(c => c.code === "heat_area")?.children || []).map(c => { |
|
|
return (configs.value.find(c => c.code === "heat_area")?.children || []).map(c => { |
|
@ -67,6 +78,8 @@ export const useSettingStore = defineStore("setting", () => { |
|
|
systemSetting, |
|
|
systemSetting, |
|
|
containerConf, |
|
|
containerConf, |
|
|
liquidList, |
|
|
liquidList, |
|
|
|
|
|
liquidIdMap, |
|
|
|
|
|
heatContainerWithLiquid, |
|
|
heatContainers, |
|
|
heatContainers, |
|
|
availableLiquids, |
|
|
availableLiquids, |
|
|
setLiquidList, |
|
|
setLiquidList, |
|
|