<template>
|
<div>
|
<!-- 终止确认弹框 -->
|
<el-dialog
|
:title="terminateTitle"
|
:visible.sync="terminateVisible"
|
width="800px"
|
append-to-body
|
:close-on-click-modal="false"
|
@close="handleTerminateClose"
|
>
|
<div class="patient-info">
|
<el-alert
|
:title="
|
`当前操作患者:${currentRecord.name} (${currentRecord.idcardno ||
|
'无证件号'})`
|
"
|
type="info"
|
:closable="false"
|
show-icon
|
/>
|
</div>
|
|
<el-form
|
:model="terminateForm"
|
:rules="terminateRules"
|
ref="terminateFormRef"
|
label-width="100px"
|
class="terminate-form"
|
>
|
<el-form-item label="终止类型" prop="terminationType">
|
<el-select
|
v-model="terminateForm.terminationType"
|
placeholder="请选择终止类型"
|
style="width: 100%;"
|
>
|
<el-option
|
v-for="item in terminationTypes"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
/>
|
</el-select>
|
</el-form-item>
|
|
<el-form-item label="详细原因" prop="terminationResult">
|
<el-input
|
v-model="terminateForm.terminationResult"
|
type="textarea"
|
:rows="3"
|
placeholder="请输入终止的详细原因"
|
maxlength="200"
|
show-word-limit
|
/>
|
</el-form-item>
|
|
<el-form-item label="二次确认" prop="confirmText">
|
<el-input
|
v-model="terminateForm.confirmText"
|
placeholder="请输入'确认终止'以完成操作"
|
@input="handleConfirmTextChange"
|
/>
|
</el-form-item>
|
</el-form>
|
|
<div slot="footer">
|
<el-button @click="handleTerminateClose" :disabled="terminateLoading"
|
>取消</el-button
|
>
|
<el-button
|
type="danger"
|
:disabled="!canSubmitTerminate"
|
@click="handleTerminateSubmit"
|
:loading="terminateLoading"
|
>
|
确认终止
|
</el-button>
|
</div>
|
</el-dialog>
|
|
<!-- 恢复确认弹框 -->
|
<el-dialog
|
:title="restoreTitle"
|
:visible.sync="restoreVisible"
|
width="600px"
|
append-to-body
|
:close-on-click-modal="false"
|
>
|
<div class="patient-info">
|
<el-alert
|
:title="
|
`当前操作患者:${currentRecord.name} (${currentRecord.idcardno ||
|
'无证件号'})`
|
"
|
type="info"
|
:closable="false"
|
show-icon
|
/>
|
</div>
|
|
<div style="margin: 20px 0;">
|
<p>
|
确定要恢复捐献者
|
<strong>{{ currentRecord.name }}</strong> 的捐献进程吗?
|
</p>
|
<p style="color: #67c23a; font-size: 12px; margin-top: 10px;">
|
恢复后,该案例将重新进入捐献流程
|
</p>
|
</div>
|
<div slot="footer">
|
<el-button @click="restoreVisible = false" :disabled="restoreLoading"
|
>取消</el-button
|
>
|
<el-button
|
type="success"
|
@click="handleRestoreSubmit"
|
:loading="restoreLoading"
|
>
|
确认恢复
|
</el-button>
|
</div>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script>
|
import { updateDonatebaseinfo } from "@/api/project/donatebaseinfo";
|
|
export default {
|
name: "TerminateRestoreModal",
|
props: {
|
// 当前操作记录
|
currentRecord: {
|
type: Object,
|
default: () => ({})
|
},
|
// 弹框显示状态
|
visible: {
|
type: Object,
|
default: () => ({
|
terminate: false,
|
restore: false
|
})
|
},
|
// 自定义标题
|
titles: {
|
type: Object,
|
default: () => ({
|
terminate: "终止捐献进程",
|
restore: "恢复捐献进程"
|
})
|
}
|
},
|
data() {
|
return {
|
// 终止表单
|
terminateForm: {
|
terminationType: "",
|
terminationResult: "",
|
confirmText: ""
|
},
|
// 终止类型选项
|
terminationTypes: [
|
{ label: "好转", value: "1" },
|
{ label: "死亡", value: "2" },
|
{ label: "不符合捐献进程", value: "3" },
|
{ label: "家属放弃捐献", value: "4" },
|
{ label: "其他", value: "5" }
|
],
|
// 验证规则
|
terminateRules: {
|
terminationType: [
|
{ required: true, message: "请选择终止类型", trigger: "change" }
|
],
|
terminationResult: [
|
{ required: true, message: "请输入终止原因", trigger: "blur" },
|
{ min: 5, message: "终止原因至少5个字符", trigger: "blur" }
|
]
|
},
|
// 加载状态
|
terminateLoading: false,
|
restoreLoading: false,
|
// 控制提交
|
canSubmitTerminate: false
|
};
|
},
|
computed: {
|
terminateVisible: {
|
get() {
|
return this.visible.terminate;
|
},
|
set(value) {
|
this.$emit("update:visible", { ...this.visible, terminate: value });
|
}
|
},
|
restoreVisible: {
|
get() {
|
return this.visible.restore;
|
},
|
set(value) {
|
this.$emit("update:visible", { ...this.visible, restore: value });
|
}
|
},
|
terminateTitle() {
|
return this.titles.terminate;
|
},
|
restoreTitle() {
|
return this.titles.restore;
|
},
|
// 患者信息显示
|
patientInfo() {
|
return `${this.currentRecord.name} (${this.currentRecord.idcardno ||
|
"无证件号"})`;
|
}
|
},
|
watch: {
|
"visible.terminate": {
|
handler(newVal) {
|
if (newVal) {
|
this.resetTerminateForm();
|
}
|
},
|
immediate: true
|
}
|
},
|
methods: {
|
/** 重置终止表单 */
|
resetTerminateForm() {
|
this.terminateForm = {
|
terminationType: "",
|
terminationResult: "",
|
confirmText: ""
|
};
|
this.canSubmitTerminate = false;
|
this.terminateLoading = false;
|
|
// 重置表单验证
|
this.$nextTick(() => {
|
if (this.$refs.terminateFormRef) {
|
this.$refs.terminateFormRef.clearValidate();
|
}
|
});
|
},
|
|
/** 确认文本变化处理 */
|
handleConfirmTextChange(value) {
|
this.canSubmitTerminate = value === "确认终止";
|
},
|
|
/** 终止弹框关闭处理 */
|
handleTerminateClose() {
|
this.terminateVisible = false;
|
this.resetTerminateForm();
|
},
|
|
/** 终止前的二次确认 */
|
async confirmTermination() {
|
try {
|
await this.$confirm(
|
`是否确认终止患者 ${this.patientInfo} 的捐献案例?此操作将终止该患者的捐献进程。`,
|
"警告",
|
{
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning",
|
closeOnClickModal: false,
|
closeOnPressEscape: false
|
}
|
);
|
return true;
|
} catch (error) {
|
console.log("用户取消终止操作");
|
return false;
|
}
|
},
|
|
/** 恢复前的二次确认 */
|
async confirmRestoration() {
|
try {
|
await this.$confirm(
|
`是否确认恢复患者 ${this.patientInfo} 的捐献案例?恢复后该案例将重新进入捐献流程。`,
|
"确认恢复",
|
{
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "info",
|
closeOnClickModal: false,
|
closeOnPressEscape: false
|
}
|
);
|
return true;
|
} catch (error) {
|
console.log("用户取消恢复操作");
|
return false;
|
}
|
},
|
|
/** 提交终止 */
|
async handleTerminateSubmit() {
|
try {
|
// 表单验证
|
await this.$refs.terminateFormRef.validate();
|
|
if (!this.canSubmitTerminate) {
|
this.$message.warning('请输入"确认终止"完成验证');
|
return;
|
}
|
console.log(66);
|
|
// 二次确认
|
const userConfirmed = await this.confirmTermination();
|
if (!userConfirmed) {
|
return;
|
}
|
|
this.terminateLoading = true;
|
|
// 调用终止接口
|
await updateDonatebaseinfo({
|
id: this.currentRecord.id,
|
caseNo: this.currentRecord.caseNo,
|
terminationType: this.terminateForm.terminationType,
|
terminationResult: this.terminateForm.terminationResult,
|
terminationCase: 1
|
});
|
|
this.$message.success("终止成功");
|
this.terminateVisible = false;
|
|
// 通知父组件操作完成,需要刷新数据
|
this.$emit("operation-success", {
|
type: "terminate",
|
record: this.currentRecord,
|
terminationType: this.terminateForm.terminationType
|
});
|
} catch (error) {
|
if (error instanceof Error) {
|
this.$message.error("终止失败");
|
console.error("终止错误:", error);
|
}
|
// 验证失败不显示错误消息
|
} finally {
|
this.terminateLoading = false;
|
}
|
},
|
|
/** 提交恢复 */
|
async handleRestoreSubmit() {
|
try {
|
// 二次确认
|
const userConfirmed = await this.confirmRestoration();
|
if (!userConfirmed) {
|
return;
|
}
|
|
this.restoreLoading = true;
|
|
// 调用恢复接口
|
await updateDonatebaseinfo({
|
id: this.currentRecord.id,
|
caseNo: this.currentRecord.caseNo,
|
terminationCase: 0
|
});
|
|
this.$message.success("恢复成功");
|
this.restoreVisible = false;
|
|
// 通知父组件操作完成,需要刷新数据
|
this.$emit("operation-success", {
|
type: "restore",
|
record: this.currentRecord
|
});
|
} catch (error) {
|
this.$message.error("恢复失败");
|
console.error("恢复错误:", error);
|
} finally {
|
this.restoreLoading = false;
|
}
|
}
|
}
|
};
|
</script>
|
|
<style scoped>
|
.patient-info {
|
margin-bottom: 20px;
|
font-size: 18px;
|
}
|
|
.terminate-form {
|
margin-top: 15px;
|
}
|
|
/* 响应式调整 */
|
@media (max-width: 768px) {
|
.patient-info ::v-deep .el-alert {
|
padding: 8px 16px;
|
}
|
|
.terminate-form ::v-deep .el-form-item__label {
|
width: 80px !important;
|
}
|
|
.terminate-form ::v-deep .el-form-item__content {
|
margin-left: 80px !important;
|
}
|
}
|
</style>
|