feat 修复一些bug

This commit is contained in:
Asoka.Wang 2025-06-19 17:54:01 +08:00
parent 74616bcfa6
commit 09eb888093

View File

@ -128,7 +128,7 @@
style="display: flex; align-items: center; justify-content: center; gap: 6px; height: 32px;">
<el-input-number v-model="scope.row.day" :min="1" style="width: 190px; height: 28px;"
placeholder="天数" />
<el-button size="mini" type="primary"
<el-button size="small" type="primary"
style="padding: 0 8px; height: 28px; display: flex; align-items: center; justify-content: center; font-size: 13px;"
@click="addDayCopy(scope.row, pump.feedingPumpNo)">
<el-icon style="margin-right:2px;">
@ -143,9 +143,9 @@
<template #default="scope">
<div style="display: flex; align-items: center; gap: 4px; justify-content: center;">
<el-time-picker v-model="scope.row.feedingTime" format="HH:mm:ss" style="width: 100%;"
placeholder="补料时间" />
placeholder="补料时间" editable />
<el-tooltip content="将当前时间批量赋值给本泵所有任务" placement="top">
<el-button size="mini"
<el-button size="small"
style="padding: 0 6px; height: 28px; display: flex; align-items: center; justify-content: center;"
@click="pasteFeedingTime(scope.row, pump.feedingPumpNo)">
<el-icon>
@ -166,7 +166,7 @@
:value="item.value" />
</el-select>
<el-tooltip content="将当前类型批量赋值给本泵所有任务" placement="top">
<el-button size="mini"
<el-button size="small"
style="padding: 0 6px; height: 28px; display: flex; align-items: center;"
@click="pasteFeedingType(scope.row, pump.feedingPumpNo)">
<el-icon>
@ -185,7 +185,7 @@
<el-input-number v-model="scope.row.feedingVolume" v-bind="getFeedingVolumeProps(scope.row)"
style="width: 100%" placeholder="补料体积" />
<el-tooltip content="将当前体积批量赋值给本泵所有任务" placement="top">
<el-button size="mini"
<el-button size="small"
style="padding: 0 6px; height: 28px; display: flex; align-items: center;"
@click="pasteFeedingVolume(scope.row, pump.feedingPumpNo)">
<el-icon>
@ -198,7 +198,7 @@
</el-table-column>
<el-table-column label="操作" width="80" align="right" header-align="center">
<template #default="scope">
<el-button type="danger" icon="ele-Delete" circle size="mini"
<el-button type="danger" icon="ele-Delete" circle size="small"
@click="removeTaskByPump(pump.feedingPumpNo, scope.$index)"
v-if="getTasksByPumpNo(pump.feedingPumpNo).length > 1" class="pretty-delete-btn" />
</template>
@ -274,7 +274,7 @@
<el-table-column label="操作" width="80" align="center" header-align="center">
<template #default="scope">
<el-button type="danger" icon="ele-Delete" circle size="mini" @click="removeRule(scope.$index)"
<el-button type="danger" icon="ele-Delete" circle size="small" @click="removeRule(scope.$index)"
v-if="form.autoGlucoseFeedingRules.length > 1" class="pretty-delete-btn" />
</template>
</el-table-column>
@ -312,6 +312,8 @@ import { ElMessageBox, ElMessage } from 'element-plus'
import { toOptionsByValue } from '/@/utils/enum'
import { EnumFeedingType, EnumFeedingOperator, EnumFeedingCalculationMode } from '/@/api/admin/enum-contracts'
import { DocumentCopy, Plus } from '@element-plus/icons-vue'
import { c } from 'vite/dist/node/moduleRunnerTransport.d-DJ_mE5sf'
import { setAddRoute } from '/@/router/backEnd'
const { proxy } = getCurrentInstance() as any
@ -330,6 +332,7 @@ const formRef = ref()
const state = reactive({
showDialog: false,
sureLoading: false,
id: 0,
form: {
id: 0,
cultureProtocolName: '',
@ -351,7 +354,7 @@ const state = reactive({
scaleOptions: [] as Array<{ id: number; name: string }>,
mediumOptions: [] as Array<{ id: number; name: string; glucoseConc: number; isGlucose: boolean; }>,
bagOptions: [] as Array<{ id: number; name: string; lowerLimitVolume: number; }>,
pumpOptions: [] as Array<{ id: number; name: string }>,
pumpOptions: [] as Array<{ id: number; name: string; pumpSpeed: number; configId: number }>,
cellTypeOptions: [],
configOptions: [] as Array<{ id: number; name: string; isTwo: number; }>,
selectedReactor: null as any,
@ -365,134 +368,16 @@ const { form } = toRefs(state)
const activeTab = ref('basic')
const lastActiveTab = ref('basic')
const feedingTaskActiveTab = ref('')
const feedingPumpTabs = computed(() => {
//
return state.form.fixedFeedingPumps
.filter(pump => pump.itemDefFeedingMediumID)
.map(pump => {
const medium = state.mediumOptions.find(m => m.id === pump.itemDefFeedingMediumID)
return {
feedingPumpNo: pump.feedingPumpNo,
feedingPumpName: pump.feedingPumpName,
mediumName: medium ? medium.name : ''
}
})
})
//
const hasGlucosePump = computed(() => {
console.log('检查糖补料泵:', state.form.fixedFeedingPumps)
const hasGlucose = state.form.fixedFeedingPumps.some(pump => {
const isGlucose = pump.isGlucose === true
console.log(`${pump.feedingPumpNo} isGlucose:`, isGlucose)
return isGlucose
})
console.log('是否存在糖补料泵:', hasGlucose)
return hasGlucose
})
//
watch(() => state.form.fixedFeedingPumps, (newPumps) => {
console.log('补料泵配置变化:', newPumps)
newPumps.forEach(pump => {
if (pump.itemDefFeedingMediumID) {
const medium = state.mediumOptions.find(m => m.id === pump.itemDefFeedingMediumID)
pump.isGlucose = medium?.isGlucose ?? false
console.log(`${pump.feedingPumpNo} 更新isGlucose:`, pump.isGlucose)
}
})
}, { deep: true })
watch(
() => feedingPumpTabs.value,
(tabs) => {
// tab
if (tabs.length && !feedingTaskActiveTab.value) {
feedingTaskActiveTab.value = String(tabs[0].feedingPumpNo)
} else if (!tabs.length) {
feedingTaskActiveTab.value = ''
}
},
{ immediate: true }
)
function getTasksByPumpNo(pumpNo: number) {
return state.form.feedingTasks.filter(task => task.feedingPumpNo === pumpNo)
}
function addTaskByPump(pumpNo: number) {
state.form.feedingTasks.push({
id: 0,
cultureProtocolId: 0,
feedingPumpNo: pumpNo,
day: 0,
feedingTime: '',
feedingType: 1,
feedingVolumePercent: 0,
feedingVolume: 0
})
}
function removeTaskByPump(pumpNo: number, index: number) {
// index
const tasks = getTasksByPumpNo(pumpNo)
const task = tasks[index]
const globalIndex = state.form.feedingTasks.findIndex(t => t === task)
if (globalIndex !== -1) {
state.form.feedingTasks.splice(globalIndex, 1)
}
}
//
watch(() => state.form.equReactorId, (newVal, oldVal) => {
if (newVal !== oldVal) {
//
state.selectedReactor = state.reactorOptions.find(r => r.id === newVal)
if (state.selectedReactor) {
state.form.fixedFeedingPumps.forEach(pump => {
pump.feedingPumpName = state.selectedReactor.name + ' - PUMP' + pump.feedingPumpNo
// ID
if (pump.feedingPumpNo == 1) {
pump.pumpSpeed = state.selectedReactor.pumpSpeed1
pump.configId = state.selectedReactor.pump1ConfigId
} else if (pump.feedingPumpNo == 2) {
pump.pumpSpeed = state.selectedReactor.pumpSpeed2
pump.configId = state.selectedReactor.pump2ConfigId
} else if (pump.feedingPumpNo == 3) {
pump.pumpSpeed = state.selectedReactor.pumpSpeed3
pump.configId = state.selectedReactor.pump3ConfigId
} else if (pump.feedingPumpNo == 4) {
pump.pumpSpeed = state.selectedReactor.pumpSpeed4
pump.configId = state.selectedReactor.pump4ConfigId
} else if (pump.feedingPumpNo == 5) {
pump.pumpSpeed = state.selectedReactor.pumpSpeed5
pump.configId = state.selectedReactor.pump5ConfigId
} else if (pump.feedingPumpNo == 6) {
pump.pumpSpeed = state.selectedReactor.pumpSpeed6
pump.configId = state.selectedReactor.pump6ConfigId
} else if (pump.feedingPumpNo == 7) {
pump.pumpSpeed = state.selectedReactor.pumpSpeed7
pump.configId = state.selectedReactor.pump7ConfigId
} else if (pump.feedingPumpNo == 8) {
pump.pumpSpeed = state.selectedReactor.pumpSpeed8
pump.configId = state.selectedReactor.pump8ConfigId
}
// ID
if (!state.selectedReactor.needExternalPump) {
pump.equPumpId = undefined
}
})
//
if (state.selectedReactor.needExternalPump) {
getPumpOptions()
}
}
}
}, { immediate: true })
const defaultPumps = [
{ id: 0, feedingPumpName: '', cultureProtocolId: undefined, configId: undefined, feedingPumpNo: 1, itemDefBagID: undefined, itemDefFeedingMediumID: undefined, equPumpId: undefined, isGlucose: false },
{ id: 0, feedingPumpName: '', cultureProtocolId: undefined, configId: undefined, feedingPumpNo: 2, itemDefBagID: undefined, itemDefFeedingMediumID: undefined, equPumpId: undefined, isGlucose: false },
{ id: 0, feedingPumpName: '', cultureProtocolId: undefined, configId: undefined, feedingPumpNo: 3, itemDefBagID: undefined, itemDefFeedingMediumID: undefined, equPumpId: undefined, isGlucose: false },
{ id: 0, feedingPumpName: '', cultureProtocolId: undefined, configId: undefined, feedingPumpNo: 4, itemDefBagID: undefined, itemDefFeedingMediumID: undefined, equPumpId: undefined, isGlucose: false },
{ id: 0, feedingPumpName: '', cultureProtocolId: undefined, configId: undefined, feedingPumpNo: 5, itemDefBagID: undefined, itemDefFeedingMediumID: undefined, equPumpId: undefined, isGlucose: false },
{ id: 0, feedingPumpName: '', cultureProtocolId: undefined, configId: undefined, feedingPumpNo: 6, itemDefBagID: undefined, itemDefFeedingMediumID: undefined, equPumpId: undefined, isGlucose: false },
{ id: 0, feedingPumpName: '', cultureProtocolId: undefined, configId: undefined, feedingPumpNo: 7, itemDefBagID: undefined, itemDefFeedingMediumID: undefined, equPumpId: undefined, isGlucose: false },
{ id: 0, feedingPumpName: '', cultureProtocolId: undefined, configId: undefined, feedingPumpNo: 8, itemDefBagID: undefined, itemDefFeedingMediumID: undefined, equPumpId: undefined, isGlucose: false }
]
onMounted(() => {
getReactorOptions()
@ -500,17 +385,21 @@ onMounted(() => {
getMediumOptions()
getBagOptions()
getConfigOptions()
getPumpOptions()
})
//
const open = async (id?: number) => {
state.id = id ?? 0
//
state.showDialog = true
activeTab.value = 'basic'
lastActiveTab.value = 'basic'
feedingTaskActiveTab.value = 'fixed'
//
reset()
//
if (id) {
const res = await new CultureProtocolApi().get({ id: id }, { loading: true })
@ -519,13 +408,9 @@ const open = async (id?: number) => {
formData.feedingTasks = formData.feedingTasks || []
formData.autoGlucoseFeedingRules = formData.autoGlucoseFeedingRules || []
formData.fixedFeedingPumps = formData.fixedFeedingPumps || []
console.log('【编辑回显数据】', JSON.parse(JSON.stringify(formData)))
// Object.assign
Object.assign(state.form, formData)
//
console.log('【fixedFeedingPumps】', state.form.fixedFeedingPumps)
console.log('【feedingTasks】', state.form.feedingTasks)
console.log('【autoGlucoseFeedingRules】', state.form.autoGlucoseFeedingRules)
} else {
console.warn('【编辑获取数据失败】', res)
}
@ -548,6 +433,7 @@ const open = async (id?: number) => {
fixedFeedingPumps: defaultPumps
}
}
// DOM
await nextTick()
// tab
@ -555,133 +441,16 @@ const open = async (id?: number) => {
console.log('【activeTab】', activeTab.value)
}
const defaultPumps = [
{ id: 0, feedingPumpName: '', cultureProtocolId: undefined, configId: undefined, feedingPumpNo: 1, itemDefBagID: undefined, itemDefFeedingMediumID: undefined, equPumpId: undefined, isGlucose: false },
{ id: 0, feedingPumpName: '', cultureProtocolId: undefined, configId: undefined, feedingPumpNo: 2, itemDefBagID: undefined, itemDefFeedingMediumID: undefined, equPumpId: undefined, isGlucose: false },
{ id: 0, feedingPumpName: '', cultureProtocolId: undefined, configId: undefined, feedingPumpNo: 3, itemDefBagID: undefined, itemDefFeedingMediumID: undefined, equPumpId: undefined, isGlucose: false },
{ id: 0, feedingPumpName: '', cultureProtocolId: undefined, configId: undefined, feedingPumpNo: 4, itemDefBagID: undefined, itemDefFeedingMediumID: undefined, equPumpId: undefined, isGlucose: false },
{ id: 0, feedingPumpName: '', cultureProtocolId: undefined, configId: undefined, feedingPumpNo: 5, itemDefBagID: undefined, itemDefFeedingMediumID: undefined, equPumpId: undefined, isGlucose: false },
{ id: 0, feedingPumpName: '', cultureProtocolId: undefined, configId: undefined, feedingPumpNo: 6, itemDefBagID: undefined, itemDefFeedingMediumID: undefined, equPumpId: undefined, isGlucose: false },
{ id: 0, feedingPumpName: '', cultureProtocolId: undefined, configId: undefined, feedingPumpNo: 7, itemDefBagID: undefined, itemDefFeedingMediumID: undefined, equPumpId: undefined, isGlucose: false },
{ id: 0, feedingPumpName: '', cultureProtocolId: undefined, configId: undefined, feedingPumpNo: 8, itemDefBagID: undefined, itemDefFeedingMediumID: undefined, equPumpId: undefined, isGlucose: false }
]
//
const addRule = () => {
state.form.autoGlucoseFeedingRules.push({
id: 0,
cultureProtocolId: 0,
cultureDayStarting: 0,
cultureDayEnding: 0,
lowerLimit: 0,
feedingTo: 0,
lowerLimitOperator: '',
calculationMode: 1
})
}
//
const removeRule = (index: number) => {
state.form.autoGlucoseFeedingRules.splice(index, 1)
}
const handleTabClick = async (tab: any, event: any) => {
if (lastActiveTab.value == 'pumps') {
//
if (!checkPumps()) {
await nextTick()
activeTab.value = lastActiveTab.value
return
}
lastActiveTab.value = tab.paneName
}
else if (lastActiveTab.value == 'glucose') {
if (!checkGlucose()) {
await nextTick()
activeTab.value = lastActiveTab.value
return
}
}
else {
lastActiveTab.value = tab.paneName
}
}
const checkPumps = () => {
let valid = true
state.form.fixedFeedingPumps.forEach(pump => {
if (pump.equPumpId != undefined || pump.itemDefBagID != undefined || pump.itemDefFeedingMediumID != undefined) {
let msg = ''
if (pump.equPumpId == undefined && state.selectedReactor?.needExternalPump) {
msg += '外置泵 '
}
if (pump.itemDefBagID == undefined) {
msg += '耗材 '
}
if (pump.itemDefFeedingMediumID == undefined) {
msg += '补料培养基 '
}
if (pump.configId == undefined) {
msg += '泵速策略 '
}
if (msg != '') {
msg = pump.feedingPumpName + ': 请选择' + msg
valid = false
proxy.$modal.msgError(msg)
}
}
})
return valid
}
const checkGlucose = () => {
let valid = true
state.form.autoGlucoseFeedingRules.forEach(rule => {
if (rule.cultureDayStarting > rule.cultureDayEnding) {
valid = false
proxy.$modal.msgError('培养天数(开始)不能大于培养天数(结束)')
}
})
// () ()
const rules = state.form.autoGlucoseFeedingRules
for (let i = 0; i < rules.length; i++) {
for (let j = i + 1; j < rules.length; j++) {
if (rules[i].cultureDayStarting < rules[j].cultureDayEnding && rules[i].cultureDayEnding > rules[j].cultureDayStarting) {
valid = false
proxy.$modal.msgError('培养天数(开始)和培养天数(结束)存在重叠')
}
return valid
}
}
return valid
}
//
const onSure = async () => {
if (!formRef.value) return
//
state.form.feedingTasks.forEach(task => {
if (task.feedingTime) {
// Date
let dateObj = typeof task.feedingTime === 'string'
? new Date(`1970-01-01T${task.feedingTime}`)
: task.feedingTime;
if (dateObj instanceof Date && !isNaN(dateObj.getTime())) {
const h = String(dateObj.getHours()).padStart(2, '0');
const m = String(dateObj.getMinutes()).padStart(2, '0');
const s = String(dateObj.getSeconds()).padStart(2, '0');
task.feedingTime = `${h}:${m}:${s}`;
} else if (typeof task.feedingTime === 'string' && task.feedingTime.length >= 8) {
//
task.feedingTime = task.feedingTime.slice(0, 8);
}
if (!task.feedingTime) {
task.feedingTime = '00:00:00'
}
});
})
await formRef.value.validate(async (valid: boolean) => {
if (valid) {
@ -736,115 +505,130 @@ const reset = () => {
}
}
const getReactorOptions = async () => {
try {
const res = await new ReactorApi().getList()
if (res?.success) {
state.reactorOptions = res.data?.map(item => ({
id: item.id ?? 0,
name: item.productID ?? '',
needExternalPump: item.isExternalPump === true,
spec: item.specification ?? '',
pumpSpeed1: item.pump1Speed ?? 0,
pumpSpeed2: item.pump2Speed ?? 0,
pumpSpeed3: item.pump3Speed ?? 0,
pumpSpeed4: item.pump4Speed ?? 0,
pumpSpeed5: item.pump5Speed ?? 0,
pumpSpeed6: item.pump6Speed ?? 0,
pumpSpeed7: item.pump7Speed ?? 0,
pumpSpeed8: item.pump8Speed ?? 0,
pump1ConfigId: item.pump1ConfigId ?? 0,
pump2ConfigId: item.pump2ConfigId ?? 0,
pump3ConfigId: item.pump3ConfigId ?? 0,
pump4ConfigId: item.pump4ConfigId ?? 0,
pump5ConfigId: item.pump5ConfigId ?? 0,
pump6ConfigId: item.pump6ConfigId ?? 0,
pump7ConfigId: item.pump7ConfigId ?? 0,
pump8ConfigId: item.pump8ConfigId ?? 0
})) ?? []
const handleTabClick = async (tab: any, event: any) => {
if (lastActiveTab.value == 'pumps') {
//
if (!checkPumps()) {
await nextTick()
activeTab.value = lastActiveTab.value
return
}
lastActiveTab.value = tab.paneName
}
else if (lastActiveTab.value == 'glucose') {
if (!checkGlucose()) {
await nextTick()
activeTab.value = lastActiveTab.value
return
}
}
else {
lastActiveTab.value = tab.paneName
}
//
if(tab.paneName == 'tasks'){
// feedingPumpTabs computed name
if (feedingPumpTabs.value.length > 0) {
feedingTaskActiveTab.value = String(feedingPumpTabs.value[0].feedingPumpNo)
} else {
feedingTaskActiveTab.value = ''
}
} catch (error) {
console.error('获取反应器列表失败:', error)
}
}
const getScaleOptions = async () => {
const res = await new UspscaleApi().getPage({
currentPage: 1,
pageSize: 10000
function addTaskByPump(pumpNo: number) {
state.form.feedingTasks.push({
id: 0,
cultureProtocolId: 0,
feedingPumpNo: pumpNo,
day: 0,
feedingTime: '',
feedingType: 1,
feedingVolumePercent: 0,
feedingVolume: 0
})
}
if (res?.success) {
state.scaleOptions = res.data?.list?.filter(item => item.isFeedingScale === true).map(item => ({
id: item.id ?? 0,
name: item.deviceNo ?? ''
})) ?? []
function removeTaskByPump(pumpNo: number, index: number) {
// index
const tasks = getTasksByPumpNo(pumpNo)
const task = tasks[index]
const globalIndex = state.form.feedingTasks.findIndex(t => t === task)
if (globalIndex !== -1) {
state.form.feedingTasks.splice(globalIndex, 1)
}
}
//
const getMediumOptions = async () => {
const res = await new ItemDefFeedingMediumApi().getPage({
currentPage: 1,
pageSize: 10000
//
const addRule = () => {
state.form.autoGlucoseFeedingRules.push({
id: 0,
cultureProtocolId: 0,
cultureDayStarting: 0,
cultureDayEnding: 0,
lowerLimit: 0,
feedingTo: 0,
lowerLimitOperator: '',
calculationMode: 1
})
if (res?.success) {
state.mediumOptions = res.data?.list?.map(item => ({
id: item.id ?? 0,
name: item.mediumName ?? '',
glucoseConc: item.glucoseConc ?? 0,
isGlucose: item.isGlucose ?? false
})) ?? []
}
}
//
const getBagOptions = async () => {
const res = await new ItemDefBagApi().getPage({
currentPage: 1,
pageSize: 10000
})
if (res?.success) {
state.bagOptions = res.data?.list?.map(item => ({
id: item.id ?? 0,
name: item.itemDescription ?? '',
lowerLimitVolume: item.lowerLimitVolume ?? 0,
})) ?? []
}
//
const removeRule = (index: number) => {
state.form.autoGlucoseFeedingRules.splice(index, 1)
}
const getPumpOptions = async () => {
const res = await new PumpApi().getPage({
currentPage: 1,
pageSize: 10000,
filter: {
isAirPump: false
const checkPumps = () => {
let valid = true
state.form.fixedFeedingPumps.forEach(pump => {
if (pump.equPumpId != undefined || pump.itemDefBagID != undefined || pump.itemDefFeedingMediumID != undefined) {
let msg = ''
if (pump.equPumpId == undefined && state.selectedReactor?.needExternalPump) {
msg += '外置泵 '
}
if (pump.itemDefBagID == undefined) {
msg += '耗材 '
}
if (pump.itemDefFeedingMediumID == undefined) {
msg += '补料培养基 '
}
if (pump.configId == undefined) {
msg += '泵速策略 '
}
if (msg != '') {
msg = pump.feedingPumpName + ': 请选择' + msg
valid = false
proxy.$modal.msgError(msg)
}
}
})
if (res?.success) {
state.pumpOptions = res.data?.list?.map((item: { id: number; deviceNo: string }) => ({
id: item.id ?? 0,
name: item.deviceNo ?? ''
})) ?? []
}
return valid
}
const getConfigOptions = async () => {
const res = await new UspFeedingConfigApi().getPage({
currentPage: 1,
pageSize: 10000
const checkGlucose = () => {
let valid = true
state.form.autoGlucoseFeedingRules.forEach(rule => {
if (rule.cultureDayStarting > rule.cultureDayEnding) {
valid = false
proxy.$modal.msgError('培养天数(开始)不能大于培养天数(结束)')
}
})
if (res?.success) {
state.configOptions = res.data?.list?.map((item) => ({
id: item.id ?? 0,
name: item.configName ?? '',
isTwo: item.isTwoStep ?? 0
})) ?? []
// () ()
const rules = state.form.autoGlucoseFeedingRules
for (let i = 0; i < rules.length; i++) {
for (let j = i + 1; j < rules.length; j++) {
if (rules[i].cultureDayStarting < rules[j].cultureDayEnding && rules[i].cultureDayEnding > rules[j].cultureDayStarting) {
valid = false
proxy.$modal.msgError('培养天数(开始)和培养天数(结束)存在重叠')
}
return valid
}
}
return valid
}
//
@ -861,14 +645,8 @@ const handlePumpChange = async (index: number) => {
}
try {
//
const res = await new PumpApi().get({ id: pumpId })
if (res?.success && res.data) {
//
row.pumpSpeed = res.data.pumpSpeed || 0
//
row.configId = res.data.configId
}
row.pumpSpeed = state.pumpOptions.find(item => item.id == pumpId)?.pumpSpeed ?? 0
row.configId = state.pumpOptions.find(item => item.id == pumpId)?.configId ?? 0
} catch (error) {
console.error('获取泵信息失败:', error)
proxy.$modal.msgError('获取泵信息失败')
@ -902,9 +680,9 @@ const handleMediumChange = (index: number) => {
}
//
const medium = state.form.fixedFeedingPumps.find(item =>
item.itemDefFeedingMediumID !== undefined &&
item.itemDefFeedingMediumID === row.itemDefFeedingMediumID &&
const medium = state.form.fixedFeedingPumps.find(item =>
item.itemDefFeedingMediumID !== undefined &&
item.itemDefFeedingMediumID === row.itemDefFeedingMediumID &&
item.feedingPumpNo !== row.feedingPumpNo
)
if (medium) {
@ -997,6 +775,207 @@ function pasteFeedingVolume(row: any, pumpNo: number) {
});
}
const feedingPumpTabs = computed(() => {
//
return state.form.fixedFeedingPumps
.filter(pump => pump.itemDefFeedingMediumID)
.map(pump => {
const medium = state.mediumOptions.find(m => m.id === pump.itemDefFeedingMediumID)
return {
feedingPumpNo: pump.feedingPumpNo,
feedingPumpName: pump.feedingPumpName,
mediumName: medium ? medium.name : ''
}
})
})
//
const hasGlucosePump = computed(() => {
console.log('检查糖补料泵:', state.form.fixedFeedingPumps)
const hasGlucose = state.form.fixedFeedingPumps.some(pump => {
const isGlucose = pump.isGlucose === true
console.log(`${pump.feedingPumpNo} isGlucose:`, isGlucose)
return isGlucose
})
console.log('是否存在糖补料泵:', hasGlucose)
return hasGlucose
})
const getReactorOptions = async () => {
try {
const res = await new ReactorApi().getList()
if (res?.success) {
state.reactorOptions = res.data?.map(item => ({
id: item.id ?? 0,
name: item.productID ?? '',
needExternalPump: item.isExternalPump === true,
spec: item.specification ?? '',
pumpSpeed1: item.pump1Speed ?? 0,
pumpSpeed2: item.pump2Speed ?? 0,
pumpSpeed3: item.pump3Speed ?? 0,
pumpSpeed4: item.pump4Speed ?? 0,
pumpSpeed5: item.pump5Speed ?? 0,
pumpSpeed6: item.pump6Speed ?? 0,
pumpSpeed7: item.pump7Speed ?? 0,
pumpSpeed8: item.pump8Speed ?? 0,
pump1ConfigId: item.pump1ConfigId ?? 0,
pump2ConfigId: item.pump2ConfigId ?? 0,
pump3ConfigId: item.pump3ConfigId ?? 0,
pump4ConfigId: item.pump4ConfigId ?? 0,
pump5ConfigId: item.pump5ConfigId ?? 0,
pump6ConfigId: item.pump6ConfigId ?? 0,
pump7ConfigId: item.pump7ConfigId ?? 0,
pump8ConfigId: item.pump8ConfigId ?? 0
})) ?? []
}
} catch (error) {
console.error('获取反应器列表失败:', error)
}
}
const getScaleOptions = async () => {
const res = await new UspscaleApi().getPage({
currentPage: 1,
pageSize: 10000
})
if (res?.success) {
state.scaleOptions = res.data?.list?.filter(item => item.isFeedingScale === true).map(item => ({
id: item.id ?? 0,
name: item.deviceNo ?? ''
})) ?? []
}
}
//
const getMediumOptions = async () => {
const res = await new ItemDefFeedingMediumApi().getPage({
currentPage: 1,
pageSize: 10000
})
if (res?.success) {
state.mediumOptions = res.data?.list?.map(item => ({
id: item.id ?? 0,
name: item.mediumName ?? '',
glucoseConc: item.glucoseConc ?? 0,
isGlucose: item.isGlucose ?? false
})) ?? []
}
}
//
const getBagOptions = async () => {
const res = await new ItemDefBagApi().getPage({
currentPage: 1,
pageSize: 10000
})
if (res?.success) {
state.bagOptions = res.data?.list?.map(item => ({
id: item.id ?? 0,
name: item.itemDescription ?? '',
lowerLimitVolume: item.lowerLimitVolume ?? 0,
})) ?? []
}
}
const getPumpOptions = async () => {
const res = await new PumpApi().getPage({
currentPage: 1,
pageSize: 10000,
filter: {
isAirPump: false
}
})
if (res?.success) {
state.pumpOptions = res.data?.list?.map((item: { id: number; deviceNo: string, pumpSpeed: number, configId: number }) => ({
id: item.id ?? 0,
name: item.deviceNo ?? '',
pumpSpeed: item.pumpSpeed ?? 0,
configId: item.configId ?? 0
})) ?? []
}
}
const getConfigOptions = async () => {
const res = await new UspFeedingConfigApi().getPage({
currentPage: 1,
pageSize: 10000
})
if (res?.success) {
state.configOptions = res.data?.list?.map((item) => ({
id: item.id ?? 0,
name: item.configName ?? '',
isTwo: item.isTwoStep ?? 0
})) ?? []
}
}
function getTasksByPumpNo(pumpNo: number) {
return state.form.feedingTasks.filter(task => task.feedingPumpNo === pumpNo)
}
//
watch(() => state.form.fixedFeedingPumps, (newPumps) => {
newPumps.forEach(pump => {
if (pump.itemDefFeedingMediumID) {
const medium = state.mediumOptions.find(m => m.id === pump.itemDefFeedingMediumID)
pump.isGlucose = medium?.isGlucose ?? false
}
})
}, { deep: true })
//
watch(() => state.form.equReactorId, (newVal, oldVal) => {
if (newVal !== oldVal) {
console.log(" ssssssss", state.selectedReactor);
//
state.selectedReactor = state.reactorOptions.find(r => r.id === newVal)
if (state.selectedReactor) {
state.form.fixedFeedingPumps.forEach(pump => {
pump.feedingPumpName = state.selectedReactor.name + ' - PUMP' + pump.feedingPumpNo
// ID
if (state.id == 0) {
if (pump.feedingPumpNo == 1) {
pump.pumpSpeed = state.selectedReactor.pumpSpeed1
pump.configId = state.selectedReactor.pump1ConfigId
} else if (pump.feedingPumpNo == 2) {
pump.pumpSpeed = state.selectedReactor.pumpSpeed2
pump.configId = state.selectedReactor.pump2ConfigId
} else if (pump.feedingPumpNo == 3) {
pump.pumpSpeed = state.selectedReactor.pumpSpeed3
pump.configId = state.selectedReactor.pump3ConfigId
} else if (pump.feedingPumpNo == 4) {
pump.pumpSpeed = state.selectedReactor.pumpSpeed4
pump.configId = state.selectedReactor.pump4ConfigId
} else if (pump.feedingPumpNo == 5) {
pump.pumpSpeed = state.selectedReactor.pumpSpeed5
pump.configId = state.selectedReactor.pump5ConfigId
} else if (pump.feedingPumpNo == 6) {
pump.pumpSpeed = state.selectedReactor.pumpSpeed6
pump.configId = state.selectedReactor.pump6ConfigId
} else if (pump.feedingPumpNo == 7) {
pump.pumpSpeed = state.selectedReactor.pumpSpeed7
pump.configId = state.selectedReactor.pump7ConfigId
} else if (pump.feedingPumpNo == 8) {
pump.pumpSpeed = state.selectedReactor.pumpSpeed8
pump.configId = state.selectedReactor.pump8ConfigId
}
// ID
if (!state.selectedReactor.needExternalPump) {
pump.equPumpId = undefined
}
}
})
}
}
}, { immediate: true })
defineExpose({
open
})