Browse Source

fix: 配方去除系数

master
guoapeng 3 days ago
parent
commit
1d41e46fe4
  1. 2
      src/apis/crafts.ts
  2. 1
      src/apis/system.ts
  3. 12
      src/components/home/Receive/index.vue
  4. 64
      src/components/system/Delay/index.vue
  5. 38
      src/layouts/default.vue
  6. 2
      src/types/log.d.ts
  7. 23
      src/views/home/index.vue
  8. 8
      src/views/setting/index.vue

2
src/apis/crafts.ts

@ -7,3 +7,5 @@ export const createCraft = (params: Craft.CraftItem): Promise<null> => http.post
export const updateCraft = (params: Craft.CraftItem): Promise<null> => http.put(`/formulation`, params)
export const delCraft = (ids: string): Promise<null> => http.delete(`/formulation/${ids}`)
export const queryCraftList = (params: { solutionId?: number, concentration?: number }): Promise<Craft.CraftItem[]> => http.post(`/formulation/list`, params)

1
src/apis/system.ts

@ -10,3 +10,4 @@ export const getTime = (): Promise<{ epochMilli: number }> => http.get('/sys/get
export const setTime = (params: { epochMilli?: number }): Promise<null> => http.post('/sys/set-datetime', params)
export const configList = (params: System.Page = { pageNum: 1, pageSize: 999 }): Promise<System.PageResponse<System.SystemConfig>> => http.post('/system-config/list', params)
export const updateConfig = (params: System.SystemConfig): Promise<number> => http.put('/system-config', params)
export const sync = (params: any): Promise<number> => http.post('/device/sync', params)

12
src/components/home/Receive/index.vue

@ -2,6 +2,7 @@
import { addLog } from 'apis/log'
import { editSols, getSolsList, saveSols } from 'apis/solution'
import { userList as userListApi } from 'apis/user'
import FtButton from 'components/common/FTButton/index.vue'
import { FtMessage } from 'libs/message'
import { useSystemStore } from 'stores/systemStore'
import { inject, onMounted, ref } from 'vue'
@ -47,12 +48,14 @@ const okHandle = async () => {
if (!valid) {
return
}
await addLog({
const params = {
...form.value,
channelCode: props.data.channelCode,
})
}
await addLog(params)
FtMessage.success('保存成功')
emits('ok')
emits('ok', params)
}
catch (error) {
console.log(error)
@ -89,6 +92,9 @@ const channelMap = {
el-input(v-model="form.receivedVolume" placeholder="请输入容量")
template(#append)
span mL
template(#footer)
ft-button(type="primary" :click-handle="okHandle") 确认领酸
ft-button(@click="cancel") 取消
</template>
<style lang="stylus" scoped>

64
src/components/system/Delay/index.vue

@ -0,0 +1,64 @@
<script setup lang="ts">
import { editSols, saveSols } from 'apis/solution'
import { sync } from 'apis/system'
import { FtMessage } from 'libs/message'
import { inject, ref } from 'vue'
const emits = defineEmits(['ok', 'cancel'])
const form = ref({ delay: 1 })
const formRef = ref()
const rules = {
delay: [
{ required: true, message: '请选择间隔时间', trigger: 'change' },
],
}
const okHandle = async () => {
try {
const valid = await formRef.value.validate()
if (!valid) {
return
}
await sync(form.value)
FtMessage.success('保存成功')
emits('ok')
}
catch (error) {
console.log(error)
}
}
const cancel = () => {
emits('cancel')
}
</script>
<template lang="pug">
FtDialog(visible title="修改间隔时间" width="30%" :ok-handle="okHandle" @cancel="cancel")
el-form(ref="formRef" label-width="auto" :model="form" :rules="rules")
el-form-item(label="间隔时间" prop="delay")
div.form-item_content
el-select(v-model="form.delay" placeholder="请选择间隔时间" style="width: 100%")
el-option(v-for="item in 30" :key="item" :label="item" :value="item")
p
</template>
<style lang="stylus" scoped>
.el-form-item
align-items center
.form-item_content
width 100%
display flex
align-items center
p
padding 0 10px
height 32px
line-height 32px
border 1px solid #dcdfe6
background-color #F5F7FA
border-left none
border-radius 0 4px 4px 0
:deep(.el-select__wrapper)
border-radius 4px 0 0 4px
</style>

38
src/layouts/default.vue

@ -1,9 +1,11 @@
<script setup lang="ts">
import { getStatus, sync } from 'apis/system'
import autoIcon from 'assets/images/auto.svg'
import logoutIcon from 'assets/images/logout.svg'
import manualIcon from 'assets/images/manual.svg'
import FtDatetime from 'components/common/FTDatetime/index.vue'
import Check from 'components/system/Check/index.vue'
import Delay from 'components/system/Delay/index.vue'
import Stop from 'components/system/Stop/index.vue'
import { ElMessageBox } from 'element-plus'
import { useActivateDebug } from 'hooks/useActivateDebug'
@ -63,8 +65,9 @@ const receiveMessage = async (data: any) => {
}
watch (() => isClose.value, async (newVal) => {
if (newVal) {
// await checkCraft()
if (!newVal) {
const res = await getStatus()
systemStore.updateSystemStatus(res)
}
})
@ -136,6 +139,30 @@ const containerStatus = computed(() => {
return 'full'
// return 'empty'
})
const checkModel = async (mode: string) => {
await ElMessageBox.confirm(
`确认切换到${mode === 'AUTO' ? '自动' : '手动'}模式吗?`,
'提示',
{
confirmButtonText: '确认',
showClose: false,
showCancelButton: true,
closeOnClickModal: false,
closeOnPressEscape: false,
type: 'warning',
},
)
await sync({
mode,
})
FtMessage.success('切换成功')
}
const delayVisible = ref(false)
const changeDelay = () => {
delayVisible.value = true
}
</script>
<template lang="pug">
@ -179,15 +206,15 @@ const containerStatus = computed(() => {
router-view(class="content")
el-footer(class="footer" :class="{ 'footer-expand': !systemStore.menuExpand }")
div(v-if="systemStore.systemStatus.mode === 'AUTO'" class="model-box model-auto-box")
div(style="display: flex;align-items: center;")
div(style="display: flex;align-items: center;" @click="() => checkModel('CLICK')")
img(:src="autoIcon" alt="")
span 自动模式
div(class="right-box")
div(class="right-box" @click="changeDelay")
span 间隔:
span(style="color: #0D72EA;margin: 0 7px") {{ systemStore.systemStatus.delay }}
span
div(v-if="systemStore.systemStatus.mode === 'CLICK'" class="model-box model-manual-box")
div(style="display: flex;align-items: center;")
div(style="display: flex;align-items: center;" @click="() => checkModel('AUTO')")
img(:src="manualIcon" alt="")
span 手动模式
div(class="right-box")
@ -212,6 +239,7 @@ const containerStatus = computed(() => {
FtStream(:visible="systemStore.streamVisible")
Check(v-if="isCheck" @close="isCheck = false")
Stop(v-if="systemStore.systemStatus.emergencyStop")
Delay(v-if="delayVisible" @ok="delayVisible = false" @close="delayVisible = false")
</template>
<style scoped lang="stylus">

2
src/types/log.d.ts

@ -9,7 +9,7 @@ declare namespace Log {
receiverNickname?: string
solutionId?: number
solutionName?: string
concentration?: string
concentration?: number
receivedVolume?: number
channelCode?: 'CHANNEL_1' | 'CHANNEL_2' | 'CHANNEL_3' | 'CHANNEL_4'
}

23
src/views/home/index.vue

@ -1,9 +1,10 @@
<script setup lang="ts">
import { queryCraftList } from 'apis/crafts'
import { getSolsList } from 'apis/solution'
import solutionIcon from 'assets/images/solution.svg'
import Receive from 'components/home/Receive/index.vue'
import { useSystemStore } from 'stores/systemStore'
import { computed, onMounted, provide, ref, watch } from 'vue'
import { computed, onMounted, ref, watch } from 'vue'
const systemStore = useSystemStore()
@ -11,7 +12,6 @@ const loading = ref(false)
onMounted(async () => {
loading.value = true
// await getList()
await getSolutionList()
loading.value = false
})
@ -47,6 +47,20 @@ const channelMap = {
CHANNEL_3: '通道3',
CHANNEL_4: '通道4',
}
const volumeMap = ref<Record<string, Craft.CraftItem[]>>({
CHANNEL_1: [],
CHANNEL_2: [],
CHANNEL_3: [],
CHANNEL_4: [],
})
const receiveOkHandle = async (data: Log.LogItem & { channelCode: 'CHANNEL_1' | 'CHANNEL_2' | 'CHANNEL_3' | 'CHANNEL_4' }) => {
volumeMap.value[data.channelCode] = await queryCraftList({
solutionId: data.solutionId,
concentration: data.concentration,
})
}
</script>
<template lang="pug">
@ -63,7 +77,8 @@ const channelMap = {
img(:src="solutionIcon" alt="")
span 每次加液体积
div.solution-box
el-select
el-select(v-model="item.targetVolume" placeholder="请选择" no-data-text="无数据, 请添加对应配方" :disabled="!item.solutionName")
el-option(v-for="vol in volumeMap[item.channelCode]" :key="vol.id" :label="vol.volume" :value="vol.volume")
div.unit mL
div.input-box
p.label
@ -72,7 +87,7 @@ const channelMap = {
div.solution-box
div.content {{item.currentVolume}}
div.unit mL
Receive(v-if="receiveVisible" :data="currentData" @ok="() => receiveVisible = false" @cancel="() => receiveVisible = false")
Receive(v-if="receiveVisible" :data="currentData" @ok="receiveOkHandle" @cancel="() => receiveVisible = false")
</template>
<style scoped lang="stylus">

8
src/views/setting/index.vue

@ -34,7 +34,7 @@ const routerClickHandle = (path: string) => {
div(class="craft-box")
el-card
div(class="list-box")
p(v-for="item in settingList" :key="item.value" class="name" :class="{ 'active-name': activeName.value === item.value }" @click="() => routerClickHandle(item.value)")
p(v-for="item in settingList" :key="item.value" class="name" :class="{ 'active-name': activeName === item.value }" @click="() => routerClickHandle(item.value)")
| {{ item.label }}
el-card
router-view
@ -56,13 +56,13 @@ const routerClickHandle = (path: string) => {
flex-direction column
justify-content space-between
height 100%
padding 10px
padding 10px 0
.list-box
flex 1
padding 0 0 10px
padding 10px 0
overflow auto
.name
padding 10px 5px
padding 15px 5px
cursor pointer
border-left 3px solid transparent
transition all 0.5s

Loading…
Cancel
Save