<template>
|
<el-dialog
|
:title="standalone ? '新建建档' : '选择建档类型'"
|
:visible.sync="dialogVisible"
|
width="640px"
|
:close-on-click-modal="false"
|
append-to-body
|
@close="handleClose"
|
>
|
<!-- 已选患者预览(关联建档模式) -->
|
<div class="archive-section" v-if="!standalone && selectedPatients.length > 0">
|
<div class="section-title">已选患者({{ selectedPatients.length }}人)</div>
|
<el-table :data="selectedPatients" border size="small" max-height="180">
|
<el-table-column prop="patname" label="姓名" width="80" align="center" />
|
<el-table-column label="性别" width="60" align="center">
|
<template slot-scope="scope">{{ scope.row.sex == 1 ? "男" : "女" }}</template>
|
</el-table-column>
|
<el-table-column prop="age" label="年龄" width="60" align="center" />
|
<el-table-column prop="deptname" label="科室" align="center" />
|
<el-table-column prop="diagname" label="诊断" align="center" show-overflow-tooltip />
|
</el-table>
|
<el-divider />
|
</div>
|
|
<!-- 独立建档:录入患者信息 -->
|
<div class="archive-section" v-if="standalone">
|
<div class="section-title">患者基本信息</div>
|
<el-form :model="standalonePatient" label-width="100px" size="small" inline>
|
<el-form-item label="姓名" required>
|
<el-input v-model="standalonePatient.patname" placeholder="请输入" style="width:150px" />
|
</el-form-item>
|
<el-form-item label="性别" required>
|
<el-select v-model="standalonePatient.sex" style="width:80px">
|
<el-option :value="1" label="男" />
|
<el-option :value="2" label="女" />
|
</el-select>
|
</el-form-item>
|
<el-form-item label="年龄">
|
<el-input v-model="standalonePatient.age" placeholder="年龄" style="width:80px" />
|
</el-form-item>
|
<el-form-item label="联系电话">
|
<el-input v-model="standalonePatient.telcode" placeholder="联系电话" style="width:150px" />
|
</el-form-item>
|
<el-form-item label="科室">
|
<el-input v-model="standalonePatient.deptname" placeholder="科室" style="width:150px" />
|
</el-form-item>
|
<el-form-item label="诊断">
|
<el-input v-model="standalonePatient.diagname" placeholder="诊断" style="width:200px" />
|
</el-form-item>
|
</el-form>
|
<el-divider />
|
</div>
|
|
<!-- 专案类型选择 -->
|
<div class="archive-section">
|
<div class="section-title">选择专案类型</div>
|
<el-radio-group v-model="subType" size="medium">
|
<el-radio-button v-for="t in typeOptions" :key="t.key" :label="t.key">{{ t.entryLabel }}</el-radio-button>
|
</el-radio-group>
|
</div>
|
|
<div slot="footer" class="dialog-footer">
|
<el-button @click="dialogVisible = false">取 消</el-button>
|
<el-button type="primary" :loading="submitting" @click="handleSubmit" :disabled="!canSubmit">确认建档</el-button>
|
</div>
|
</el-dialog>
|
</template>
|
|
<script>
|
import { ARCHIVE_TYPES, loadArchives, saveArchives, buildArchiveRecord } from "../types";
|
|
export default {
|
name: "ArchiveDialog",
|
props: {
|
visible: { type: Boolean, default: false },
|
patients: { type: Array, default: () => [] },
|
sourcePage: { type: String, default: "outpatient" },
|
standalone: { type: Boolean, default: false },
|
},
|
data() {
|
return {
|
dialogVisible: false,
|
subType: "",
|
submitting: false,
|
standalonePatient: { patname: "", sex: 2, age: "", telcode: "", deptname: "", diagname: "" },
|
};
|
},
|
computed: {
|
typeOptions() { return ARCHIVE_TYPES; },
|
canSubmit() {
|
if (!this.subType) return false;
|
if (this.standalone && !this.standalonePatient.patname) return false;
|
if (!this.standalone && this.selectedPatients.length === 0) return false;
|
return true;
|
},
|
selectedPatients() { return this.patients || []; },
|
},
|
watch: {
|
visible(val) {
|
this.dialogVisible = val;
|
if (val) this.resetForm();
|
},
|
dialogVisible(val) {
|
if (!val) this.$emit("update:visible", false);
|
},
|
},
|
methods: {
|
resetForm() {
|
this.subType = "";
|
this.standalonePatient = { patname: "", sex: 2, age: "", telcode: "", deptname: "", diagname: "" };
|
},
|
handleSubmit() {
|
if (!this.subType) { this.$message.warning("请选择专案类型"); return; }
|
if (this.standalone && !this.standalonePatient.patname) { this.$message.warning("请输入姓名"); return; }
|
if (!this.standalone && this.selectedPatients.length === 0) { this.$message.warning("请选择患者"); return; }
|
this.submitting = true;
|
|
const patientList = this.standalone ? [this.standalonePatient] : this.selectedPatients;
|
const sourcePage = this.standalone ? "standalone" : this.sourcePage;
|
const records = patientList.map((p) => buildArchiveRecord(p, this.subType, sourcePage));
|
saveArchives([...loadArchives(), ...records]);
|
|
this.submitting = false;
|
this.dialogVisible = false;
|
this.$message.success(`成功创建 ${records.length} 条建档记录`);
|
this.$emit("created");
|
|
// 进入详情页(编辑态)
|
const first = records[0];
|
const type = ARCHIVE_TYPES.find((t) => t.key === this.subType);
|
if (first && type) {
|
this.$router.push({ path: type.detailRoute, query: { id: first.id, edit: 1 } });
|
}
|
},
|
handleClose() { this.resetForm(); },
|
},
|
};
|
</script>
|
|
<style lang="scss" scoped>
|
.archive-section { margin-bottom: 18px; }
|
.section-title { font-size: 15px; font-weight: 600; color: #303133; margin-bottom: 12px; padding-left: 10px; border-left: 3px solid #409eff; }
|
.dialog-footer { text-align: right; }
|
</style>
|