fix: 协议子资源单事务保存,并补齐样本编码/OA/质检等近期能力

锁定缴费校验失败时整单回滚,避免样本半成功落库;前端禁止删除锁定缴费样本,改码走更正编码。同步落地样本更正、采集微信通知、OA提及未读、细胞产品套餐与相关迁移文档。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
zlwuandCursor committed 2026-10-26 11:02:25 +08:00
1 parent 19bc66ba45
commit 5dad1bb0e3
142 files changed
+95584 -65717

No files matched your search

@@ -213,6 +213,7 @@
:unit-options="unitOptions"
:unit-options-loading="unitLoading"
:show-price="true"
:sample-payments="formData.samplePayments"
@price-change="onSamplePriceChange"
@search-sample-code="remoteSearchSampleCodes"
@search-sample-type="remoteSearchSampleTypes"
@@ -372,6 +372,7 @@
parsePreferentialPrice,
resolvePerSamplePaymentDefaults,
samplePaymentHasConfirmedTransfer,
samplePaymentHasLockedTransfer,
schedulePaidArrears,
shouldAutoFillLastPeriodDue,
shouldReplaceContractWithPreferentialPrice
@@ -569,19 +570,13 @@
}
}
function paymentHasLockedTransfer(pay: Record<string, any>) {
return (pay.schedules || []).some((s: Record<string, any>) =>
(s.transfers || []).some((t: Record<string, any>) => t.payStatus === 'yjf')
)
}
/** 优惠价变更时同步合同;打开编辑不覆盖库内金额(仅合同为空时补齐) */
function applyPreferentialPriceToPayment(
pay: Record<string, any>,
sample: Record<string, any>,
force = false
): Record<string, any> {
if (paymentHasLockedTransfer(pay)) return pay
if (samplePaymentHasLockedTransfer(pay)) return pay
const price = parsePreferentialPrice(sample)
if (price == null) return pay
if (!force && !shouldReplaceContractWithPreferentialPrice(pay.contractAmount, price)) {
@@ -1114,6 +1109,26 @@
next.push(emptyDjPayment(sample))
}
}
// 锁定缴费不可因样本删改/换码从提交列表中消失(对齐后端「不能省略或删除」)
const keptCodes = new Set(next.map((p) => String(p.sampleCode || '')))
const keptIds = new Set(
next.map((p) => String(p.id || p.samplePaymentId || '')).filter(Boolean)
)
let restoredLocked = false
for (const pay of existing) {
if (!samplePaymentHasLockedTransfer(pay)) continue
const id = String(pay.id || pay.samplePaymentId || '')
const code = String(pay.sampleCode || '')
if ((id && keptIds.has(id)) || (code && keptCodes.has(code))) continue
next.push(pay)
restoredLocked = true
}
if (restoredLocked) {
ElMessage.warning(
'存在锁定缴费方案的样本不可删除或改码,请使用客户服务「更正编码」'
)
}
lastPreferentialByCode.value = nextPriceMap
const same =
next.length === existing.length &&
@@ -0,0 +1,217 @@
<template>
<el-dialog
v-model="visible"
title="更正样本编码"
width="640px"
class="dialog-form-layout"
append-to-body
modal-class="protocol-dialog-mask"
destroy-on-close
@closed="onClosed"
>
<el-form ref="formRef" :model="form" :rules="rules" label-position="top" class="form-grid-2">
<el-form-item label="当前样本编码" class="form-col-span-2">
<el-input :model-value="oldSampleCode" disabled />
</el-form-item>
<el-form-item label="新样本编码" prop="newSampleCode" class="form-col-span-2">
<el-input
v-model="form.newSampleCode"
placeholder="请输入正确的样本编码"
clearable
maxlength="32"
/>
</el-form-item>
<el-form-item label="更正原因" prop="reason" class="form-col-span-2">
<el-input
v-model="form.reason"
type="textarea"
:rows="2"
placeholder="例如:客户填错编码"
maxlength="512"
show-word-limit
/>
</el-form-item>
</el-form>
<div v-if="preview" class="preview-block">
<div v-if="!preview.ok" class="preview-blockers">
<div v-for="(b, i) in preview.blockers" :key="i" class="blocker-line">{{ b }}</div>
</div>
<template v-else>
<div class="preview-summary">
预计影响 <strong>{{ preview.totalAffectedRows }}</strong> 行(含源表)
</div>
<el-table :data="preview.impacts" size="small" stripe class="preview-table" max-height="220">
<el-table-column prop="label" label="业务表" min-width="160" />
<el-table-column prop="table" label="表名" min-width="200" show-overflow-tooltip />
<el-table-column prop="count" label="行数" min-width="72" align="center" />
</el-table>
<ul class="preview-hints">
<li>实验室入库编码不会修改</li>
<li>细胞产品码不会自动修改(同名产品码:旧 {{ hintOld }} / 新 {{ hintNew }})</li>
</ul>
</template>
</div>
<template #footer>
<el-button @click="visible = false">
<el-icon><Close /></el-icon>
取消
</el-button>
<el-button :loading="previewing" @click="handlePreview">
<el-icon><View /></el-icon>
预览影响
</el-button>
<el-button
type="primary"
:loading="applying"
:disabled="!preview?.ok"
@click="handleApply"
>
<el-icon><Check /></el-icon>
确认更正
</el-button>
</template>
</el-dialog>
</template>
<script setup lang="ts">
import { Check, Close, View } from '@element-plus/icons-vue'
import { ElMessage, ElMessageBox, type FormInstance, type FormRules } from 'element-plus'
import {
fetchApplySampleCodeCorrection,
fetchPreviewSampleCodeCorrection,
type SampleCodeCorrectionPreview,
type SampleCodeCorrectionSource
} from '@/api/sample-code-correction'
const props = defineProps<{
modelValue: boolean
receptionSource: SampleCodeCorrectionSource
oldSampleCode: string
}>()
const emit = defineEmits<{
'update:modelValue': [boolean]
success: []
}>()
const visible = computed({
get: () => props.modelValue,
set: (v) => emit('update:modelValue', v)
})
const formRef = ref<FormInstance>()
const form = reactive({
newSampleCode: '',
reason: ''
})
const rules: FormRules = {
newSampleCode: [{ required: true, message: '请输入新样本编码', trigger: 'blur' }],
reason: [{ required: true, message: '请填写更正原因', trigger: 'blur' }]
}
const preview = ref<SampleCodeCorrectionPreview | null>(null)
const previewing = ref(false)
const applying = ref(false)
const hintOld = computed(() => preview.value?.hints?.sameProductCodeAsOld ?? 0)
const hintNew = computed(() => preview.value?.hints?.sameProductCodeAsNew ?? 0)
watch(
() => props.modelValue,
(open) => {
if (open) {
form.newSampleCode = ''
form.reason = ''
preview.value = null
}
}
)
function onClosed() {
preview.value = null
}
async function handlePreview() {
const ok = await formRef.value?.validate().catch(() => false)
if (!ok) return
previewing.value = true
try {
const data = await fetchPreviewSampleCodeCorrection({
receptionSource: props.receptionSource,
oldSampleCode: props.oldSampleCode,
newSampleCode: form.newSampleCode.trim(),
reason: form.reason.trim()
})
preview.value = data
if (!data.ok) {
ElMessage.warning(data.blockers?.[0] || '无法更正')
}
} catch (e: any) {
ElMessage.error(e?.message || '预览失败')
} finally {
previewing.value = false
}
}
async function handleApply() {
if (!preview.value?.ok) {
ElMessage.warning('请先预览并通过校验')
return
}
try {
await ElMessageBox.confirm(
`确认将样本编码「${props.oldSampleCode}」更正为「${form.newSampleCode.trim()}」?将级联更新 ${preview.value.totalAffectedRows} 行相关数据。`,
'确认更正',
{ type: 'warning', confirmButtonText: '确认更正', cancelButtonText: '取消' }
)
} catch {
return
}
applying.value = true
try {
await fetchApplySampleCodeCorrection({
receptionSource: props.receptionSource,
oldSampleCode: props.oldSampleCode,
newSampleCode: form.newSampleCode.trim(),
reason: form.reason.trim()
})
ElMessage.success('样本编码已更正')
visible.value = false
emit('success')
} catch (e: any) {
ElMessage.error(e?.message || '更正失败')
} finally {
applying.value = false
}
}
</script>
<style scoped lang="scss">
.preview-block {
margin-top: 12px;
padding-top: 12px;
border-top: 1px solid var(--el-border-color-lighter);
}
.preview-blockers {
color: var(--el-color-danger);
font-size: 13px;
line-height: 1.6;
}
.preview-summary {
margin-bottom: 8px;
font-size: 13px;
color: var(--mint-text, #334155);
}
.preview-hints {
margin: 8px 0 0;
padding-left: 18px;
font-size: 12px;
color: var(--mint-text-muted, #64748b);
line-height: 1.6;
}
</style>
@@ -393,17 +393,24 @@
</el-table-column>
</template>
<el-table-column label="操作" min-width="280" fixed="right" align="center" header-align="center">
<el-table-column label="操作" min-width="360" fixed="right" align="center" header-align="center">
<template #default="{ row }">
<el-button class="btn-op-item primary" @click="handleView(row)">
<el-icon><View /></el-icon>查看
</el-button>
<el-button
class="btn-op-item"
:disabled="!row.sampleCode"
@click="openCodeCorrection(row)"
>
<el-icon><EditPen /></el-icon>更正编码
</el-button>
<el-button
v-if="isCellStorage && supportsStorageCertQc(row.sampleTypeName)"
class="btn-op-item"
@click="openStorageCertQcView(row)"
@click="openStorageCertQcEdit(row)"
>
<el-icon><Document /></el-icon>查看储存证的质检信息
<el-icon><Document /></el-icon>填写储存证质检信息
</el-button>
</template>
</el-table-column>
@@ -447,10 +454,16 @@
/>
<StorageCertQcDialog
v-model:visible="storageCertQcVisible"
mode="view"
mode="edit"
:sample-code="storageCertQcSampleCode"
:sample-type-name="storageCertQcSampleTypeName"
/>
<SampleCodeCorrectionDialog
v-model="codeCorrectionVisible"
:reception-source="activeSource"
:old-sample-code="codeCorrectionOldCode"
@success="loadData"
/>
</div>
</template>
@@ -460,6 +473,7 @@
ChatDotRound,
Collection,
Document,
EditPen,
Files,
Location,
Phone,
@@ -480,6 +494,7 @@
import DonationViewDialog from '@/views/research-donation/list/DonationViewDialog.vue'
import SampleCodeWithSpecialDisplay from '@/components/business/sample-code-with-special-display/index.vue'
import SampleInfoQuickRegisterDialog from './SampleInfoQuickRegisterDialog.vue'
import SampleCodeCorrectionDialog from './SampleCodeCorrectionDialog.vue'
import {
donationStatusDisplayLabel,
donationStatusTagType,
@@ -535,6 +550,8 @@
const storageCertQcVisible = ref(false)
const storageCertQcSampleCode = ref('')
const storageCertQcSampleTypeName = ref('')
const codeCorrectionVisible = ref(false)
const codeCorrectionOldCode = ref('')
function sexLabel(sex: unknown) {
const s = String(sex || '').trim()
@@ -543,16 +560,26 @@
return s || '—'
}
function openStorageCertQcView(row: Record<string, unknown>) {
function openStorageCertQcEdit(row: Record<string, unknown>) {
storageCertQcSampleCode.value = String(row.sampleCode || '')
storageCertQcSampleTypeName.value = String(row.sampleTypeName || '')
if (!storageCertQcSampleCode.value) {
ElMessage.warning('缺少样本编码,无法查看')
ElMessage.warning('缺少样本编码,无法填写')
return
}
storageCertQcVisible.value = true
}
function openCodeCorrection(row: Record<string, unknown>) {
const code = String(row.sampleCode || '').trim()
if (!code) {
ElMessage.warning('缺少样本编码,无法更正')
return
}
codeCorrectionOldCode.value = code
codeCorrectionVisible.value = true
}
function statusLabel(row: Record<string, unknown>) {
if (isCellStorage.value) {
return protocolStatusDisplayLabel(String(row.protocolStatus || ''), String(row.voidType || ''))