Files
zkxw/web-admin/src/components/business/sample-void-dialog/index.vue
T
zlwuandCursor 0b4c8dfda8 feat(sample): 展示样本状态并支持样本废弃与作废原因
生产/质检入库卡片展示样本状态并支持【样本废弃】;市场 Web 列表与移动市场部卡片补充样本状态及问号查看作废原因;样本表新增 void_desc,人工作废不联动接收但全部作废时自动作废协议(#131)。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-19 14:25:24 +08:00

140 lines
3.7 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!-- 样本废弃:填写作废原因后提交 -->
<template>
<el-dialog
v-model="dialogVisible"
title="样本废弃"
width="560px"
class="dialog-form-layout"
align-center
append-to-body
modal-class="protocol-dialog-mask"
destroy-on-close
:close-on-click-modal="false"
@close="handleClose"
>
<el-form
ref="formRef"
:model="form"
:rules="rules"
label-position="top"
class="biz-dialog-form"
>
<div class="form-grid-2">
<el-form-item v-if="sampleCode" label="样本编码" class="form-col-span-2">
<span class="sample-void-dialog__code">{{ sampleCode }}</span>
</el-form-item>
<el-form-item label="作废原因" prop="voidDesc" class="form-col-span-2">
<el-input
v-model="form.voidDesc"
type="textarea"
:rows="4"
maxlength="512"
show-word-limit
placeholder="请填写作废原因"
/>
</el-form-item>
</div>
</el-form>
<template #footer>
<el-button class="btn-ghost" @click="handleClose">
<el-icon><Close /></el-icon>取消
</el-button>
<el-button class="btn-main" type="primary" :loading="submitting" @click="handleSubmit">
<el-icon><Check /></el-icon>确定
</el-button>
</template>
</el-dialog>
</template>
<script setup lang="ts">
import { computed, reactive, ref, watch } from 'vue'
import { Check, Close } from '@element-plus/icons-vue'
import { ElMessage, type FormInstance, type FormRules } from 'element-plus'
import { fetchVoidBusinessSample, type SampleVoidTarget } from '@/api/business-sample'
defineOptions({ name: 'SampleVoidDialog' })
const props = defineProps<{
visible: boolean
target: SampleVoidTarget | null
}>()
const emit = defineEmits<{
'update:visible': [visible: boolean]
success: []
}>()
const dialogVisible = ref(false)
const submitting = ref(false)
const formRef = ref<FormInstance>()
const form = reactive({
voidDesc: ''
})
const rules: FormRules = {
voidDesc: [
{
required: true,
validator: (_rule, value, callback) => {
if (!String(value || '').trim()) callback(new Error('请填写作废原因'))
else callback()
},
trigger: 'blur'
}
]
}
const sampleCode = computed(() => String(props.target?.sampleCode || '').trim())
watch(
() => props.visible,
(visible) => {
dialogVisible.value = visible
if (visible) form.voidDesc = ''
},
{ immediate: true }
)
watch(dialogVisible, (visible) => {
emit('update:visible', visible)
})
function handleClose() {
dialogVisible.value = false
}
async function handleSubmit() {
const target = props.target
if (!target?.receptionSource || (!target.sampleId && !target.sampleCode)) {
ElMessage.warning('缺少样本信息,无法废弃')
return
}
const valid = await formRef.value?.validate().catch(() => false)
if (!valid) return
submitting.value = true
try {
await fetchVoidBusinessSample({
receptionSource: target.receptionSource,
sampleId: target.sampleId,
sampleCode: target.sampleCode,
protocolId: target.protocolId,
voidDesc: form.voidDesc.trim()
})
ElMessage.success('样本已废弃')
emit('success')
handleClose()
} finally {
submitting.value = false
}
}
</script>
<style scoped lang="scss">
.sample-void-dialog__code {
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
font-size: 14px;
font-weight: 600;
color: #1e293b;
}
</style>