Browse Source

加液配置

feature/layout_0214
zhangjiming 6 months ago
parent
commit
ab146709c8
  1. 13
      src/App.vue
  2. 2
      src/router/index.ts
  3. 12
      src/services/sysConfig/sysConfig.ts
  4. 41
      src/stores/setting.ts
  5. 32
      src/views/addLiquid/addLiquid.vue
  6. 28
      src/views/oreManage/components/StepItemEx.vue

13
src/App.vue

@ -3,8 +3,9 @@ import { useRouter } from "vue-router";
import { exceptionOb } from "./services/httpRequest";
import { createWebSocket, sharedWsUrl } from "./services/socket";
import { onMounted } from "vue";
import { getConfig } from "./services/sysConfig/sysConfig";
import { getConfig, getContainerList } from "./services/sysConfig/sysConfig";
import { useSettingStore } from "./stores/setting";
import { getLiquidList } from "./services/liquid/liquidManage";
const router = useRouter();
const settingStore = useSettingStore();
@ -20,6 +21,16 @@ onMounted(() => {
settingStore.setConfigs(res.data);
}
});
getLiquidList({ pageNum: 1, pageSize: 9999 }).then(res => {
if (res.success) {
settingStore.setLiquidList(res.data.list)
}
});
getContainerList().then(res => {
if (res.success) {
settingStore.setContainerConf(res.data);
}
});
});
</script>

2
src/router/index.ts

@ -47,7 +47,7 @@ const router = createRouter({
{
path: "/addLiquid",
name: "addLiquid",
component: () => import("../views/addLiquid/index.vue"),
component: () => import("../views/addLiquid/addLiquid.vue"),
},
{
path: "/liquidConfig",

12
src/services/sysConfig/sysConfig.ts

@ -25,3 +25,15 @@ export function getConfig() {
export function updateConfig(params: { id: number; value: string }[]) {
return httpRequest<BaseResponse>({ url: "/api/sys/updateConfig", method: "PUT", params });
}
export type Container = {
id: number;
type: 0 | 1; // 0:酸液 1:废液
solutionId: number;
};
export function getContainerList() {
return httpRequest<BaseResponse<Container[]>>({ url: "/api/container/list" });
}
export function updateContainer(id: number, solutionId: number) {
return httpRequest<BaseResponse>({ url: `/api/container/${id}`, method: "PUT", params: { solutionId } });
}

41
src/stores/setting.ts

@ -1,6 +1,8 @@
import type { ConfigItem } from "@/services/sysConfig/sysConfig";
import type { Liquid } from "@/services/liquid/liquidManage";
import type { ConfigItem, Container } from "@/services/sysConfig/sysConfig";
import { defineStore } from "pinia";
import { computed, ref } from "vue";
import * as R from 'ramda';
export const useSettingStore = defineStore("setting", () => {
const configs = ref<ConfigItem[] | undefined>();
@ -8,6 +10,24 @@ export const useSettingStore = defineStore("setting", () => {
configs.value = usr;
};
const containerConf = ref<Container[] | undefined>();
const setContainerConf = (containers: Container[]) => {
containerConf.value = containers;
};
const liquidList = ref<Liquid[] | undefined>();
const setLiquidList = (liquids: Liquid[]) => {
liquidList.value = liquids;
};
const heatContainers = computed(() => {
if (!containerConf.value) return [];
return containerConf.value.filter(c => c.type === 0);
});
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 heatAreaConfig = computed(() => {
if (!configs.value) return [];
return (configs.value.find(c => c.code === "heat_area")?.children || []).map(c => {
@ -17,14 +37,14 @@ export const useSettingStore = defineStore("setting", () => {
});
const actionAreaConfig = computed(() => {
if (!configs.value) return { valueObj: {x: 0, y: 0, z: 0}};
if (!configs.value) return { valueObj: { x: 0, y: 0, z: 0 } };
const c = configs.value.find(c => c.code === "solution_area")?.children[0];
const [x, y, z] = c!.value.split(",");
return { ...c, valueObj: { x: +x, y: +y, z: +z } };
});
const capAreaConfig = computed(() => {
if (!configs.value) return { valueObj: {x: 0, y: 0, z: 0}};
if (!configs.value) return { valueObj: { x: 0, y: 0, z: 0 } };
const c = configs.value.find(c => c.code === "lid_area")?.children[0];
const [x, y, z] = c!.value.split(",");
return { ...c, valueObj: { x: +x, y: +y, z: +z } };
@ -39,5 +59,18 @@ export const useSettingStore = defineStore("setting", () => {
return heatAreaConfig.value.map(c => ({ label: c.name, value: c.id }));
});
return { heatAreaConfig,areaOptions, actionAreaConfig, capAreaConfig, systemSetting, setConfigs };
return {
heatAreaConfig,
areaOptions,
actionAreaConfig,
capAreaConfig,
systemSetting,
containerConf,
liquidList,
heatContainers,
availableLiquids,
setLiquidList,
setContainerConf,
setConfigs,
};
});

32
src/views/addLiquid/addLiquid.vue

@ -0,0 +1,32 @@
<template>
<div class="component-page">
<section class="overflow-auto">
<div v-for="container in settingStore.heatContainers" :key="container.id" class="flex items-center gap-4 p-2">
<p class="min-w-16">容器 {{ container.id }}:</p>
<el-select
v-model="container.solutionId"
placeholder="Select"
style="width: 200px"
@change="onChange($event, container)">
<el-option v-for="item in settingStore.liquidList" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
</div>
</section>
</div>
</template>
<script setup lang="ts">
import { useSettingStore } from "@/stores/setting";
import { updateContainer, type Container } from "@/services/sysConfig/sysConfig";
import { showToast } from "vant";
const settingStore = useSettingStore();
function onChange(value: number, container: Container) {
updateContainer(container.id, value).then(res => {
if (res.success) {
} else {
showToast(res.msg);
}
});
}
</script>

28
src/views/oreManage/components/StepItemEx.vue

@ -7,12 +7,18 @@
</section>
<template v-if="step.method !== 'takePhoto'">
<section v-if="step.method === 'addLiquid'" class="bg-[#f4f4f4] h-12 flex items-center px-10 text-[#5e5e5e] gap-5">
<div class="h-[1.875rem] rounded-sm bg-[#eaeaea] flex items-center px-3 min-w-[8.125rem]">
<!-- <div class="h-[1.875rem] rounded-sm bg-[#eaeaea] flex items-center px-3 min-w-[8.125rem]">
<span>盐酸</span>
<img class="ml-auto w-2" src="@/assets/icon_arr_s.svg" alt="arr" />
</div>
</div> -->
<el-select v-model="step.params.solId" placeholder="Select" style="width: 100px">
<el-option v-for="item in settingStore.availableLiquids" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
<div class="flex items-center">
<input type="number" v-model="step.params.volume" class="h-[1.875rem] rounded-sm bg-[#eaeaea] px-3 w-[6.25rem] mr-2" />
<input
type="number"
v-model="step.params.volume"
class="h-[1.875rem] rounded-sm bg-[#eaeaea] px-3 w-[6.25rem] mr-2" />
<span>ml</span>
</div>
</section>
@ -20,7 +26,10 @@
v-if="step.method === 'shaking' || step.method === 'delay'"
class="bg-[#f4f4f4] h-12 flex items-center px-10 text-[#5e5e5e] gap-5">
<div class="flex items-center">
<input type="number" v-model="step.params.second" class="h-[1.875rem] rounded-sm bg-[#eaeaea] px-3 w-[6.25rem] mr-2" />
<input
type="number"
v-model="step.params.second"
class="h-[1.875rem] rounded-sm bg-[#eaeaea] px-3 w-[6.25rem] mr-2" />
<span></span>
</div>
</section>
@ -43,9 +52,7 @@
</el-select>
</div>
</section>
<section
v-if="step.method === 'startHeating'"
class="bg-[#f4f4f4] h-12 flex items-center px-10 text-[#5e5e5e] gap-5">
<section v-if="step.method === 'startHeating'" class="bg-[#f4f4f4] h-12 flex items-center px-10 text-[#5e5e5e] gap-5">
<div class="flex items-center gap-3">
<el-select v-model="step.params.heaterId" placeholder="Select" style="width: 100px">
<el-option
@ -54,7 +61,10 @@
:label="item.label"
:value="item.value" />
</el-select>
<input type="number" v-model="step.params.temperature" class="h-[1.875rem] rounded-sm bg-[#eaeaea] px-3 w-[6.25rem] mr-2" />
<input
type="number"
v-model="step.params.temperature"
class="h-[1.875rem] rounded-sm bg-[#eaeaea] px-3 w-[6.25rem] mr-2" />
<span></span>
</div>
</section>
@ -64,7 +74,7 @@
<script setup lang="ts">
import { StepCmdDescMap, type StepStruct } from "@/services/globalCmd/globalCmd";
import { useSettingStore } from "@/stores/setting";
const settingStore = useSettingStore()
const settingStore = useSettingStore();
const props = defineProps<{ order: number; step: StepStruct }>();
const emit = defineEmits<{

Loading…
Cancel
Save