+ placeholder="补料时间" editable />
-
@@ -166,7 +166,7 @@
:value="item.value" />
-
@@ -185,7 +185,7 @@
-
@@ -198,7 +198,7 @@
-
@@ -274,7 +274,7 @@
-
@@ -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
})