提交
This commit is contained in:
1 parent
7541a167c0
commit
b0eb80a2d4
37 files changed
+6279
-4732
No files matched your search
@@ -678,16 +678,6 @@
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="排序号" min-width="100" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-input
|
||||
v-model="row.orderNum"
|
||||
placeholder="排序号"
|
||||
class="inner-cell-input"
|
||||
@change="saveDataCollections"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" min-width="120" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-input v-model="row.remark" placeholder="备注" class="inner-cell-input" @change="saveDataCollections" />
|
||||
@@ -703,6 +693,12 @@
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</div>
|
||||
<div class="route-config-right-footer">
|
||||
<el-button class="btn-main" type="primary" :loading="manualSaveLoading" @click="handleManualSave">
|
||||
<el-icon><Check /></el-icon>
|
||||
保存
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="route-config-right-empty">
|
||||
@@ -1021,6 +1017,16 @@
|
||||
reagentMasterById.value = next
|
||||
}
|
||||
|
||||
/** 通过 reagentCode 在已缓存的主表数据中反查 masterId */
|
||||
function resolveReagentMasterId(row: Record<string, any>): string | null {
|
||||
const code = (row.reagentCode || '').trim()
|
||||
if (!code) return null
|
||||
for (const master of Object.values(reagentMasterById.value)) {
|
||||
if ((master.reagentCode || '').trim() === code) return master.id
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
async function searchReagentOptions(query: string) {
|
||||
reagentOptionsLoading.value = true
|
||||
try {
|
||||
@@ -1054,6 +1060,14 @@
|
||||
}
|
||||
return
|
||||
}
|
||||
// reagentId 为空(后端不存储该字段)— 通过 reagentCode 反查主表真实 ID
|
||||
const masterId = resolveReagentMasterId(row)
|
||||
if (masterId) {
|
||||
row.reagentId = masterId
|
||||
// 主表选项已在 searchReagentOptions 中加载,无需重复添加
|
||||
return
|
||||
}
|
||||
// 实在找不到主表记录才走 legacy 兜底
|
||||
const code = (row.reagentCode || '').trim()
|
||||
const name = (row.reagentName || '').trim()
|
||||
if (!code && !name) return
|
||||
@@ -1080,6 +1094,16 @@
|
||||
saveReagents()
|
||||
return
|
||||
}
|
||||
// 重复校验:同一试剂 ID 不可出现多次
|
||||
const reagents = selectedStep.value?.reagents || []
|
||||
const duplicate = reagents.find(
|
||||
(r: Record<string, any>) => r !== row && r.reagentId === reagentId
|
||||
)
|
||||
if (duplicate) {
|
||||
ElMessage.warning('该试剂已添加,不可重复选择')
|
||||
row.reagentId = ''
|
||||
return
|
||||
}
|
||||
const master = reagentMasterById.value[reagentId]
|
||||
if (!master) {
|
||||
saveReagents()
|
||||
@@ -1111,6 +1135,16 @@
|
||||
consumableMasterById.value = next
|
||||
}
|
||||
|
||||
/** 通过 consumableCode 在已缓存的主表数据中反查 masterId */
|
||||
function resolveConsumableMasterId(row: Record<string, any>): string | null {
|
||||
const code = (row.consumableCode || '').trim()
|
||||
if (!code) return null
|
||||
for (const master of Object.values(consumableMasterById.value)) {
|
||||
if ((master.consumableCode || '').trim() === code) return master.id
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
async function searchConsumableOptions(query: string) {
|
||||
consumableOptionsLoading.value = true
|
||||
try {
|
||||
@@ -1143,6 +1177,14 @@
|
||||
}
|
||||
return
|
||||
}
|
||||
// consumableId 为空(后端不存储该字段)— 通过 consumableCode 反查主表真实 ID
|
||||
const masterId = resolveConsumableMasterId(row)
|
||||
if (masterId) {
|
||||
row.consumableId = masterId
|
||||
// 主表选项已在 searchConsumableOptions 中加载,无需重复添加
|
||||
return
|
||||
}
|
||||
// 实在找不到主表记录才走 legacy 兜底
|
||||
const code = (row.consumableCode || '').trim()
|
||||
const name = (row.consumableName || '').trim()
|
||||
if (!code && !name) return
|
||||
@@ -1169,6 +1211,16 @@
|
||||
saveConsumables()
|
||||
return
|
||||
}
|
||||
// 重复校验:同一耗材 ID 不可出现多次
|
||||
const consumables = selectedStep.value?.consumables || []
|
||||
const duplicate = consumables.find(
|
||||
(c: Record<string, any>) => c !== row && c.consumableId === consumableId
|
||||
)
|
||||
if (duplicate) {
|
||||
ElMessage.warning('该耗材已添加,不可重复选择')
|
||||
row.consumableId = ''
|
||||
return
|
||||
}
|
||||
const master = consumableMasterById.value[consumableId]
|
||||
if (!master) {
|
||||
saveConsumables()
|
||||
@@ -1449,16 +1501,32 @@
|
||||
|
||||
async function saveReagents() {
|
||||
if (!selectedStep.value || configSuppressSave.value) return
|
||||
const reagents = selectedStep.value.reagents || []
|
||||
// 按 reagentId(如有)或 reagentCode 检查重复
|
||||
const seen = new Map<string, number>()
|
||||
for (let i = 0; i < reagents.length; i++) {
|
||||
const r = reagents[i]
|
||||
const key = r.reagentId
|
||||
? String(r.reagentId)
|
||||
: (r.reagentCode || '').trim()
|
||||
if (!key) continue
|
||||
if (seen.has(key)) {
|
||||
ElMessage.warning(`试剂"${r.reagentName || r.reagentCode}"重复,请移除重复项`)
|
||||
return
|
||||
}
|
||||
seen.set(key, i)
|
||||
}
|
||||
try {
|
||||
await fetchUpdateStepReagents({
|
||||
stepId: selectedStep.value.id,
|
||||
items: (selectedStep.value.reagents || []).map((r: Record<string, any>) => ({
|
||||
items: reagents.map((r: Record<string, any>, idx: number) => ({
|
||||
reagentCode: r.reagentCode,
|
||||
reagentName: r.reagentName,
|
||||
spec: r.spec,
|
||||
standardUsage: r.standardUsage,
|
||||
unit: r.unit,
|
||||
isKeyMaterial: toApiFlag(r.isKeyMaterial),
|
||||
orderNum: idx,
|
||||
remark: r.remark || ''
|
||||
}))
|
||||
})
|
||||
@@ -1491,16 +1559,32 @@
|
||||
|
||||
async function saveConsumables() {
|
||||
if (!selectedStep.value || configSuppressSave.value) return
|
||||
const consumables = selectedStep.value.consumables || []
|
||||
// 按 consumableId(如有)或 consumableCode 检查重复
|
||||
const seen = new Map<string, number>()
|
||||
for (let i = 0; i < consumables.length; i++) {
|
||||
const c = consumables[i]
|
||||
const key = c.consumableId
|
||||
? String(c.consumableId)
|
||||
: (c.consumableCode || '').trim()
|
||||
if (!key) continue
|
||||
if (seen.has(key)) {
|
||||
ElMessage.warning(`耗材"${c.consumableName || c.consumableCode}"重复,请移除重复项`)
|
||||
return
|
||||
}
|
||||
seen.set(key, i)
|
||||
}
|
||||
try {
|
||||
await fetchUpdateStepConsumables({
|
||||
stepId: selectedStep.value.id,
|
||||
items: (selectedStep.value.consumables || []).map((c: Record<string, any>) => ({
|
||||
items: consumables.map((c: Record<string, any>, idx: number) => ({
|
||||
consumableCode: c.consumableCode,
|
||||
consumableName: c.consumableName,
|
||||
specModel: c.specModel,
|
||||
standardUsage: c.standardUsage,
|
||||
unit: c.unit,
|
||||
isRequired: toApiFlag(c.isRequired),
|
||||
orderNum: idx,
|
||||
remark: c.remark || ''
|
||||
}))
|
||||
})
|
||||
@@ -1532,10 +1616,11 @@
|
||||
try {
|
||||
await fetchUpdateStepOutputs({
|
||||
stepId: selectedStep.value.id,
|
||||
items: (selectedStep.value.outputs || []).map((o: Record<string, any>) => ({
|
||||
items: (selectedStep.value.outputs || []).map((o: Record<string, any>, idx: number) => ({
|
||||
outputTypeId: o.outputTypeId,
|
||||
outputName: o.outputName,
|
||||
outputBarcode: o.outputBarcode,
|
||||
orderNum: idx,
|
||||
remark: o.remark || ''
|
||||
}))
|
||||
})
|
||||
@@ -1573,10 +1658,10 @@
|
||||
try {
|
||||
await fetchUpdateStepDataCollections({
|
||||
stepId: selectedStep.value.id,
|
||||
items: (selectedStep.value.dataCollections || []).map((d: Record<string, any>) => ({
|
||||
items: (selectedStep.value.dataCollections || []).map((d: Record<string, any>, idx: number) => ({
|
||||
collectionName: d.collectionName,
|
||||
unit: d.unit,
|
||||
orderNum: parseOrderNum(d.orderNum),
|
||||
orderNum: idx,
|
||||
remark: d.remark || ''
|
||||
}))
|
||||
})
|
||||
@@ -1585,6 +1670,30 @@
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// 右侧区域手动保存
|
||||
// ---------------------------------------------------------------------------
|
||||
const manualSaveLoading = ref(false)
|
||||
|
||||
async function handleManualSave() {
|
||||
if (!selectedStep.value) return
|
||||
manualSaveLoading.value = true
|
||||
try {
|
||||
await Promise.all([
|
||||
saveStepBasic(),
|
||||
saveReagents(),
|
||||
saveConsumables(),
|
||||
saveOutputs(),
|
||||
saveDataCollections()
|
||||
])
|
||||
ElMessage.success('保存成功')
|
||||
} catch {
|
||||
ElMessage.error('保存失败,请重试')
|
||||
} finally {
|
||||
manualSaveLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// 初始化
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -1874,6 +1983,14 @@
|
||||
padding: 12px 16px;
|
||||
}
|
||||
|
||||
.route-config-right-footer {
|
||||
padding: 12px 16px;
|
||||
border-top: 1px solid #e5e7eb;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.route-config-right-empty {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
Reference in new issue
Block a user