feat 项目管理
This commit is contained in:
parent
790f31dc1d
commit
74616bcfa6
@ -29,7 +29,7 @@ export class CultureProtocolApi extends HttpClient {
|
||||
this.request<CultureProtocolOutput>({
|
||||
path: `/api/admin/culture-protocol/get`,
|
||||
method: 'GET',
|
||||
query: params,
|
||||
query: { id: params.id },
|
||||
...requestParams,
|
||||
})
|
||||
|
||||
|
63
src/api/admin/ProjectApi.ts
Normal file
63
src/api/admin/ProjectApi.ts
Normal file
@ -0,0 +1,63 @@
|
||||
import { ProjectPageInput, ProjectPageResponse, ProjectOutput, ProjectAddInput, ProjectUpdateInput } from '/@/api/types/projectType'
|
||||
import { RequestParams } from './http-client'
|
||||
import { ContentType, HttpClient } from './http-client'
|
||||
|
||||
export class ProjectApi extends HttpClient {
|
||||
/**
|
||||
* 获取分页列表
|
||||
*/
|
||||
getPage = (data: ProjectPageInput, params: RequestParams = {}) =>
|
||||
this.request<ProjectPageResponse>({
|
||||
path: `/api/admin/project/get-page`,
|
||||
method: 'POST',
|
||||
body: data,
|
||||
type: ContentType.Json,
|
||||
...params,
|
||||
})
|
||||
|
||||
/**
|
||||
* 获取单条数据
|
||||
*/
|
||||
get = (params: { id: number }, requestParams: RequestParams = {}) =>
|
||||
this.request<ProjectOutput>({
|
||||
path: `/api/admin/project/get`,
|
||||
method: 'GET',
|
||||
query: params,
|
||||
...requestParams,
|
||||
})
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
add = (data: ProjectAddInput, params: RequestParams = {}) =>
|
||||
this.request<any>({
|
||||
path: `/api/admin/project/add`,
|
||||
method: 'POST',
|
||||
body: data,
|
||||
type: ContentType.Json,
|
||||
...params,
|
||||
})
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*/
|
||||
update = (data: ProjectUpdateInput, params: RequestParams = {}) =>
|
||||
this.request<any>({
|
||||
path: `/api/admin/project/update`,
|
||||
method: 'PUT',
|
||||
body: data,
|
||||
type: ContentType.Json,
|
||||
...params,
|
||||
})
|
||||
|
||||
/**
|
||||
* 软删除
|
||||
*/
|
||||
softDelete = (params: { id: number }, requestParams: RequestParams = {}) =>
|
||||
this.request<any>({
|
||||
path: `/api/admin/project/soft-delete`,
|
||||
method: 'DELETE',
|
||||
query: params,
|
||||
...requestParams,
|
||||
})
|
||||
}
|
58
src/api/types/projectType.ts
Normal file
58
src/api/types/projectType.ts
Normal file
@ -0,0 +1,58 @@
|
||||
import { ServiceResponse } from './response';
|
||||
import { ServiceRequestPage } from './pageInput'
|
||||
import { PageResponse } from './pageResponse'
|
||||
|
||||
// 过滤条件
|
||||
export interface ProjectFilter {
|
||||
/** 关键字搜索 */
|
||||
keyWord?: string | null
|
||||
/** 部门ID */
|
||||
departmentId?: number | null
|
||||
}
|
||||
|
||||
// 项目DTO
|
||||
export interface ProjectDto {
|
||||
/** 主键Id */
|
||||
id?: number
|
||||
/** 部门ID */
|
||||
departmentId?: number
|
||||
/** 部门名称 */
|
||||
departmentName?: string | null
|
||||
/** 项目编号 */
|
||||
projectNo?: string | null
|
||||
/** 项目名称 */
|
||||
projectName?: string | null
|
||||
/** 责任人ID */
|
||||
principalId?: number
|
||||
/** 责任人姓名 */
|
||||
principalName?: string | null
|
||||
/** 状态 */
|
||||
status?: boolean
|
||||
/** 创建时间 */
|
||||
createdTime?: string | null
|
||||
/** 修改时间 */
|
||||
modifiedTime?: string | null
|
||||
}
|
||||
|
||||
/** 项目添加和更新输入接口 */
|
||||
export interface ProjectAddInputAndUpdateInput {
|
||||
/** 主键Id */
|
||||
id?: number
|
||||
/** 部门ID */
|
||||
departmentId?: number
|
||||
/** 项目编号 */
|
||||
projectNo?: string | null
|
||||
/** 项目名称 */
|
||||
projectName?: string | null
|
||||
/** 责任人ID */
|
||||
principalId?: number
|
||||
/** 状态 */
|
||||
status?: boolean
|
||||
}
|
||||
|
||||
// API 类型定义
|
||||
export type ProjectPageInput = ServiceRequestPage<ProjectFilter>;
|
||||
export type ProjectPageResponse = PageResponse<ProjectDto>;
|
||||
export type ProjectOutput = ServiceResponse<ProjectDto>;
|
||||
export type ProjectAddInput = ProjectAddInputAndUpdateInput;
|
||||
export type ProjectUpdateInput = ProjectAddInputAndUpdateInput;
|
184
src/views/admin/project/components/project-form.vue
Normal file
184
src/views/admin/project/components/project-form.vue
Normal file
@ -0,0 +1,184 @@
|
||||
<template>
|
||||
<el-dialog v-model="dialogVisible" :title="title" width="600px" append-to-body class="project-form-dialog">
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="100px" class="project-form">
|
||||
<el-form-item label="部门" prop="departmentId">
|
||||
<el-select v-model="form.departmentId" placeholder="请选择部门" style="width: 100%" filterable>
|
||||
<el-option v-for="item in state.departmentOptions" :key="item.id" :label="item.name" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="项目编号" prop="projectNo">
|
||||
<el-input v-model="form.projectNo" placeholder="请输入项目编号" />
|
||||
</el-form-item>
|
||||
<el-form-item label="项目名称" prop="projectName">
|
||||
<el-input v-model="form.projectName" placeholder="请输入项目名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="责任人" prop="principalId">
|
||||
<el-select v-model="form.principalId" placeholder="请选择责任人" style="width: 100%" filterable>
|
||||
<el-option v-for="item in state.principalOptions" :key="item.id" :label="item.name" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-switch v-model="form.status" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="OnCancel" size="default">取 消</el-button>
|
||||
<el-button type="primary" :loading="state.sureLoading" @click="submitForm" size="default">确 定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="admin/project/form">
|
||||
import { ref, reactive, onMounted, getCurrentInstance } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
import { ProjectApi } from '../../../../api/admin/ProjectApi'
|
||||
import { OrgApi } from '/@/api/admin/Org'
|
||||
import { UserApi } from '/@/api/admin/User'
|
||||
import { ProjectAddInputAndUpdateInput } from '/@/api/types/projectType'
|
||||
import eventBus from '/@/utils/mitt'
|
||||
|
||||
const { proxy } = getCurrentInstance() as any
|
||||
|
||||
const props = defineProps<{
|
||||
title: string
|
||||
}>()
|
||||
|
||||
const dialogVisible = ref(false)
|
||||
const formRef = ref<FormInstance>()
|
||||
const form = reactive<ProjectAddInputAndUpdateInput>({
|
||||
departmentId: undefined,
|
||||
projectNo: '',
|
||||
projectName: '',
|
||||
principalId: undefined,
|
||||
status: true
|
||||
})
|
||||
|
||||
const state = reactive({
|
||||
sureLoading: false,
|
||||
departmentOptions: [] as Array<{ id: number; name: string }>,
|
||||
principalOptions: [] as Array<{ id: number; name: string }>
|
||||
})
|
||||
|
||||
const rules = reactive<FormRules>({
|
||||
departmentId: [{ required: true, message: '请选择部门', trigger: 'change' }],
|
||||
projectNo: [{ required: true, message: '请输入项目编号', trigger: 'blur' }],
|
||||
projectName: [{ required: true, message: '请输入项目名称', trigger: 'blur' }],
|
||||
principalId: [{ required: true, message: '请选择责任人', trigger: 'change' }]
|
||||
})
|
||||
|
||||
/** 获取部门列表 */
|
||||
const getDepartmentOptions = async () => {
|
||||
try {
|
||||
const res = await new OrgApi().getList()
|
||||
if (res?.success && res.data) {
|
||||
state.departmentOptions = res.data.map((item: any) => ({
|
||||
id: item.id,
|
||||
name: item.name
|
||||
}))
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取部门列表失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
/** 获取负责人列表 */
|
||||
const getPrincipalOptions = async () => {
|
||||
try {
|
||||
const res = await new UserApi().getPage({
|
||||
currentPage: 1,
|
||||
pageSize: 1000,
|
||||
filter: {}
|
||||
})
|
||||
|
||||
state.principalOptions = res.data?.list?.map((item: any) => ({
|
||||
id: item.id,
|
||||
name: item.userName
|
||||
})) || []
|
||||
} catch (error) {
|
||||
console.error('获取用户列表失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
const open = async (id?: number) => {
|
||||
proxy.$modal.loading()
|
||||
|
||||
if (id && id > 0) {
|
||||
const res = await new ProjectApi().get({ id }, { loading: true })
|
||||
if (res?.success && res.data) {
|
||||
const formData = res.data as unknown as ProjectAddInputAndUpdateInput
|
||||
Object.assign(form, formData)
|
||||
}
|
||||
} else {
|
||||
Object.assign(form, {
|
||||
departmentId: undefined,
|
||||
projectNo: '',
|
||||
projectName: '',
|
||||
principalId: undefined,
|
||||
status: true
|
||||
})
|
||||
}
|
||||
proxy.$modal.closeLoading()
|
||||
dialogVisible.value = true
|
||||
|
||||
await Promise.all([
|
||||
getDepartmentOptions(),
|
||||
getPrincipalOptions()
|
||||
])
|
||||
}
|
||||
|
||||
/** 取消 */
|
||||
const OnCancel = () => {
|
||||
dialogVisible.value = false
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
|
||||
/** 提交表单 */
|
||||
const submitForm = async () => {
|
||||
if (!formRef.value) return
|
||||
await formRef.value.validate(async (valid) => {
|
||||
if (valid) {
|
||||
state.sureLoading = true
|
||||
try {
|
||||
const api = new ProjectApi()
|
||||
const res = form.id ? await api.update(form) : await api.add(form)
|
||||
if (res.success) {
|
||||
ElMessage.success(form.id ? '修改成功' : '新增成功')
|
||||
dialogVisible.value = false
|
||||
eventBus.emit('refreshProject')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('提交失败:', error)
|
||||
ElMessage.error('操作失败,请重试')
|
||||
} finally {
|
||||
state.sureLoading = false
|
||||
}
|
||||
} else {
|
||||
ElMessage.warning('存在未填写的必填项')
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getDepartmentOptions()
|
||||
getPrincipalOptions()
|
||||
})
|
||||
|
||||
defineExpose({
|
||||
open
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.project-form-dialog {
|
||||
:deep(.el-dialog__body) {
|
||||
padding: 20px 30px;
|
||||
}
|
||||
}
|
||||
|
||||
.project-form {
|
||||
.el-form-item {
|
||||
margin-bottom: 22px;
|
||||
}
|
||||
}
|
||||
</style>
|
186
src/views/admin/project/index.vue
Normal file
186
src/views/admin/project/index.vue
Normal file
@ -0,0 +1,186 @@
|
||||
<template>
|
||||
<my-layout>
|
||||
<el-card class="box-card">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<el-form :inline="true" :model="state.filter" class="demo-form-inline">
|
||||
<el-form-item label="关键字">
|
||||
<el-input v-model="state.filter.keyWord" placeholder="请输入关键字" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="部门">
|
||||
<el-select v-model="state.filter.departmentId" placeholder="请选择部门" clearable filterable>
|
||||
<el-option v-for="item in state.departmentOptions" :key="item.id" :label="item.name" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="handleQuery">查询</el-button>
|
||||
<el-button @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-button v-auth="'api:admin:project:add'" type="primary" @click="handleAdd">新增</el-button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<el-table v-loading="loading" :data="state.projectList" style="width: 100%">
|
||||
<el-table-column type="index" label="序号" width="60" />
|
||||
<el-table-column prop="projectNo" label="项目编号" />
|
||||
<el-table-column prop="projectName" label="项目名称" />
|
||||
<el-table-column prop="departmentName" label="部门" />
|
||||
<el-table-column prop="principalName" label="责任人" />
|
||||
<el-table-column prop="status" label="状态" width="80">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="row.status ? 'success' : 'danger'">{{ row.status ? '启用' : '禁用' }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="createdTime" label="创建时间" width="180" />
|
||||
<el-table-column label="操作" width="180" fixed="right" header-align="center" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button v-auth="'api:admin:project:update'" icon="ele-EditPen" size="small" text type="primary"
|
||||
@click="handleEdit(row)">编辑</el-button>
|
||||
<el-button v-auth="'api:admin:project:soft-delete'" icon="ele-Delete" size="small" text type="danger"
|
||||
@click="handleDelete(row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div class="my-flex my-flex-end" style="margin-top: 10px">
|
||||
<el-pagination v-model:current-page="state.pageInput.currentPage" v-model:page-size="state.pageInput.pageSize"
|
||||
:total="state.total" :page-sizes="[10, 20, 50, 100]" size="small" background @size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange" layout="total, sizes, prev, pager, next, jumper" />
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<project-form ref="formRef" :title="state.formTitle" @ok="getList" />
|
||||
</my-layout>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted, defineAsyncComponent } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { ProjectApi } from '../../../api/admin/ProjectApi'
|
||||
import { OrgApi } from '/@/api/admin/Org'
|
||||
import type { ProjectPageInput, ProjectDto } from '/@/api/types/projectType'
|
||||
import eventBus from '/@/utils/mitt'
|
||||
|
||||
const ProjectForm = defineAsyncComponent(() => import('./components/project-form.vue'))
|
||||
|
||||
const loading = ref(false)
|
||||
const formRef = ref()
|
||||
|
||||
const state = reactive({
|
||||
loading: false,
|
||||
formTitle: '',
|
||||
total: 0,
|
||||
filter: {
|
||||
keyWord: '',
|
||||
departmentId: undefined as number | undefined
|
||||
},
|
||||
pageInput: {
|
||||
currentPage: 1,
|
||||
pageSize: 20,
|
||||
} as ProjectPageInput,
|
||||
projectList: [] as Array<ProjectDto>,
|
||||
departmentOptions: [] as Array<{ id: number; name: string }>
|
||||
})
|
||||
|
||||
/** 查询列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
state.pageInput.filter = state.filter
|
||||
try {
|
||||
const res = await new ProjectApi().getPage(state.pageInput)
|
||||
state.projectList = res.list || []
|
||||
state.total = res.total || 0
|
||||
} catch (error) {
|
||||
console.error('获取列表失败:', error)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 获取部门列表 */
|
||||
const getDepartmentOptions = async () => {
|
||||
try {
|
||||
const res = await new OrgApi().getList()
|
||||
if (res?.success && res.data) {
|
||||
state.departmentOptions = res.data.map((item: any) => ({
|
||||
id: item.id,
|
||||
name: item.name
|
||||
}))
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取部门列表失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
state.pageInput.currentPage = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
state.filter = {
|
||||
keyWord: '',
|
||||
departmentId: undefined
|
||||
}
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
/** 新增按钮操作 */
|
||||
const handleAdd = () => {
|
||||
state.formTitle = '新增项目'
|
||||
formRef.value?.open()
|
||||
}
|
||||
|
||||
/** 修改按钮操作 */
|
||||
const handleEdit = (row: ProjectDto) => {
|
||||
state.formTitle = '编辑项目'
|
||||
formRef.value?.open(row.id)
|
||||
}
|
||||
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = (row: ProjectDto) => {
|
||||
ElMessageBox.confirm('确认要删除该记录吗?', '警告', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(async () => {
|
||||
try {
|
||||
const res = await new ProjectApi().softDelete({ id: row.id! })
|
||||
if (res.success) {
|
||||
ElMessage.success('删除成功')
|
||||
getList()
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('删除失败:', error)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/** 每页条数改变 */
|
||||
const handleSizeChange = (val: number) => {
|
||||
state.pageInput.pageSize = val
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 当前页改变 */
|
||||
const handleCurrentChange = (val: number) => {
|
||||
state.pageInput.currentPage = val
|
||||
getList()
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getList()
|
||||
getDepartmentOptions()
|
||||
eventBus.on('refreshProject', getList)
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.card-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
@ -371,7 +371,7 @@ import {
|
||||
PumpConfig,
|
||||
defaultPumpConfig,
|
||||
ReactorTypeEnumItem
|
||||
} from '/@/api/types/ReactorType'
|
||||
} from '/@/api/types/reactorType'
|
||||
import { toOptionsByValue } from '/@/utils/enum'
|
||||
import { EnumPressureUnit } from '/@/api/admin/enum-contracts'
|
||||
import eventBus from '/@/utils/mitt'
|
||||
|
@ -357,7 +357,8 @@ const state = reactive({
|
||||
selectedReactor: null as any,
|
||||
feedingTypeOptions: toOptionsByValue(EnumFeedingType),
|
||||
feedingOperatorOptions: toOptionsByValue(EnumFeedingOperator),
|
||||
feedingCalculationModeOptions: toOptionsByValue(EnumFeedingCalculationMode)
|
||||
feedingCalculationModeOptions: toOptionsByValue(EnumFeedingCalculationMode),
|
||||
cultureProtocol: null as any
|
||||
})
|
||||
|
||||
const { form } = toRefs(state)
|
||||
@ -381,8 +382,27 @@ const feedingPumpTabs = computed(() => {
|
||||
|
||||
// 添加判断是否存在糖补料的计算属性
|
||||
const hasGlucosePump = computed(() => {
|
||||
return state.form.fixedFeedingPumps.some(pump => pump.isGlucose)
|
||||
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,
|
||||
@ -483,20 +503,34 @@ onMounted(() => {
|
||||
})
|
||||
|
||||
// 打开对话框
|
||||
const open = async (row: any = {}, isCopy = false) => {
|
||||
proxy.$modal.loading()
|
||||
|
||||
if (row.id > 0) {
|
||||
const res = await new CultureProtocolApi().get({ id: row.id }, { loading: true })
|
||||
const open = async (id?: number) => {
|
||||
// 重置对话框状态
|
||||
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 })
|
||||
if (res?.success) {
|
||||
let formData = res.data as CultureProtocolDto
|
||||
if (isCopy) {
|
||||
formData.id = 0
|
||||
formData.cultureProtocolName = formData.cultureProtocolName + ' - 副本'
|
||||
}
|
||||
state.form = formData
|
||||
const formData = { ...res.data } as CultureProtocolDto
|
||||
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)
|
||||
}
|
||||
} else {
|
||||
// 设置默认值
|
||||
state.form = {
|
||||
id: 0,
|
||||
cultureProtocolName: '',
|
||||
@ -514,9 +548,11 @@ const open = async (row: any = {}, isCopy = false) => {
|
||||
fixedFeedingPumps: defaultPumps
|
||||
}
|
||||
}
|
||||
|
||||
state.showDialog = true
|
||||
proxy.$modal.closeLoading()
|
||||
// 等待 DOM 更新
|
||||
await nextTick()
|
||||
// tab渲染条件日志
|
||||
console.log('【hasGlucosePump】', hasGlucosePump.value)
|
||||
console.log('【activeTab】', activeTab.value)
|
||||
}
|
||||
|
||||
const defaultPumps = [
|
||||
@ -628,6 +664,7 @@ const checkGlucose = () => {
|
||||
const onSure = async () => {
|
||||
if (!formRef.value) return
|
||||
|
||||
// 处理补料时间格式
|
||||
state.form.feedingTasks.forEach(task => {
|
||||
if (task.feedingTime) {
|
||||
// 兼容 Date 对象或字符串
|
||||
@ -663,6 +700,8 @@ const onSure = async () => {
|
||||
console.error(state.form.id ? '修改失败:' : '新增失败:', error)
|
||||
} finally {
|
||||
state.sureLoading = false
|
||||
activeTab.value = 'basic'
|
||||
lastActiveTab.value = 'basic'
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -840,11 +879,13 @@ const handleMediumChange = (index: number) => {
|
||||
const row = state.form.fixedFeedingPumps[index]
|
||||
if (!row) return
|
||||
|
||||
row.isGlucose = state.mediumOptions.find(item => item.id == row.itemDefFeedingMediumID)?.isGlucose ?? false
|
||||
// 更新isGlucose状态
|
||||
const selectedMedium = state.mediumOptions.find(item => item.id === row.itemDefFeedingMediumID)
|
||||
row.isGlucose = selectedMedium?.isGlucose ?? false
|
||||
|
||||
// 校验重复的糖补料
|
||||
if (row.isGlucose) {
|
||||
const glucose = state.form.fixedFeedingPumps.find(item => item.isGlucose == true && item.feedingPumpNo != row.feedingPumpNo)
|
||||
const glucose = state.form.fixedFeedingPumps.find(item => item.isGlucose === true && item.feedingPumpNo !== row.feedingPumpNo)
|
||||
if (glucose) {
|
||||
ElMessageBox.confirm('糖补料不能重复,请检查', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
@ -861,7 +902,11 @@ const handleMediumChange = (index: number) => {
|
||||
}
|
||||
|
||||
// 校验重复的补料培养基
|
||||
const medium = state.form.fixedFeedingPumps.find(item => item.itemDefFeedingMediumID != undefined && item.itemDefFeedingMediumID == row.itemDefFeedingMediumID && item.feedingPumpNo != row.feedingPumpNo)
|
||||
const medium = state.form.fixedFeedingPumps.find(item =>
|
||||
item.itemDefFeedingMediumID !== undefined &&
|
||||
item.itemDefFeedingMediumID === row.itemDefFeedingMediumID &&
|
||||
item.feedingPumpNo !== row.feedingPumpNo
|
||||
)
|
||||
if (medium) {
|
||||
proxy.$modal.msgWarning('补料培养基存在重复')
|
||||
}
|
||||
|
@ -82,7 +82,7 @@
|
||||
size="small"
|
||||
text
|
||||
type="primary"
|
||||
@click="onEdit(row)"
|
||||
@click="onEdit(row.id)"
|
||||
>编辑</el-button
|
||||
>
|
||||
<el-button
|
||||
|
Loading…
x
Reference in New Issue
Block a user