This commit is contained in:
zlwu committed 2026-07-07 12:32:07 +08:00
1 parent f4bbe3e06e
commit df53d05193
12 files changed
+117 -44

No files matched your search

@@ -424,6 +424,7 @@
:loading="false"
:disabled="readonly"
hide-save-footer
:lab-storage-code="editor.taskDetail.value?.labStorageCode || ''"
:unit-options="editor.itemUnitOptions.value"
:unit-options-loading="editor.itemUnitOptionsLoading.value"
@update:items="(items: Record<string, any>[]) => (editor.taskOutputs.value = items)"
@@ -125,6 +125,7 @@
<TaskOutputProductDialog
v-model="dialogVisible"
:edit-item="editingItem"
:lab-storage-code="labStorageCode"
:occupied-slot-ids="dialogOccupiedSlotIds"
:existing-product-codes="dialogExistingProductCodes"
@confirm="handleDialogConfirm"
@@ -156,8 +157,10 @@
saving?: boolean
/** 任务执行弹窗:保存按钮由外层底栏承载 */
hideSaveFooter?: boolean
/** 任务关联实验室入库编码(产出新增弹窗造血干一键填充) */
labStorageCode?: string
}>(),
{ disabled: false, saving: false, hideSaveFooter: false }
{ disabled: false, saving: false, hideSaveFooter: false, labStorageCode: '' }
)
const emit = defineEmits<{
@@ -268,6 +268,14 @@
</div>
</el-form>
<template #footer>
<el-button
v-if="!isEdit"
class="btn-ghost"
@click="handleHscQuickFill"
>
<el-icon><MagicStick /></el-icon>
造血干一键填充
</el-button>
<el-button class="btn-ghost" @click="emit('update:modelValue', false)">
<el-icon><Close /></el-icon>
取消
@@ -281,7 +289,7 @@
</template>
<script setup lang="ts">
import { Close, Check } from '@element-plus/icons-vue'
import { Close, Check, MagicStick } from '@element-plus/icons-vue'
import { ElMessage } from 'element-plus'
import { fetchCellProductTypeList } from '@/api/admin'
import { fetchMaxPassageProductSeq, fetchMaxProductSuffixSeq, fetchCheckCellProductCode } from '@/api/cell-product'
@@ -314,9 +322,13 @@
viability: number | undefined
}
const STORAGE_PRODUCT_TYPE_NAME = '存储'
const props = defineProps<{
modelValue: boolean
editItem?: Record<string, any> | null
/** 任务关联的实验室入库编码(造血干一键填充) */
labStorageCode?: string
/** 本任务其他产出已占用的储物格(编辑时父级已排除当前条) */
occupiedSlotIds?: string[]
/** 本任务其他产出已使用的产品编码(编辑时父级已排除当前条,含未保存项) */
@@ -472,6 +484,7 @@
const originalProductCode = ref('')
const productLines = ref<ProductLine[]>([createEmptyProductLine()])
let lineCodeSyncToken = 0
let skipLineCodeAutoSync = false
const formData = reactive({
cellProductId: '',
@@ -613,9 +626,62 @@
/** 按入库份数同步明细行,并重算产品编码 */
async function applyProductCodeToLines() {
syncProductLines()
if (skipLineCodeAutoSync) return
await syncLineCodesFromBase()
}
function resolveStorageProductTypeOption() {
return productTypeOptions.value.find(
(item) =>
item.productTypeName === STORAGE_PRODUCT_TYPE_NAME ||
item.productTypeCode === STORAGE_PRODUCT_TYPE_NAME
)
}
async function ensureStorageProductTypeSelected() {
let match = resolveStorageProductTypeOption()
if (!match) {
await remoteSearchProductTypes(STORAGE_PRODUCT_TYPE_NAME)
match = resolveStorageProductTypeOption()
}
if (!match) {
ElMessage.warning(`未找到产品类型「${STORAGE_PRODUCT_TYPE_NAME}」,请手动选择`)
return false
}
formData.productTypeId = match.id
ensureProductTypeInOptions(match.id, match.productTypeName, match.productTypeCode)
return true
}
async function handleHscQuickFill() {
const labCode = (props.labStorageCode || '').trim()
if (!labCode) {
ElMessage.warning('暂无实验室入库编码,无法一键填充')
return
}
skipLineCodeAutoSync = true
try {
formData.productCode = labCode
formData.productName = labCode
formData.batchNo = labCode
const typeReady = await ensureStorageProductTypeSelected()
syncProductLines()
productLines.value.forEach((line) => {
line.productCode = labCode
})
await nextTick()
productLines.value.forEach((line) => {
line.productCode = labCode
})
formRef.value?.clearValidate?.()
if (typeReady) {
ElMessage.success('已填充造血干默认值')
}
} finally {
skipLineCodeAutoSync = false
}
}
function onDialogOpened() {
if (props.editItem) {
populateFormFromEditItem(props.editItem)