| | |
| | | </template> |
| | | |
| | | <script> |
| | | import { ARCHIVE_TYPES, loadArchives, saveArchives, buildArchiveRecord } from "../types"; |
| | | import { ARCHIVE_TYPES } from "../types"; |
| | | import { createArchive } from "../apiAdapter"; |
| | | |
| | | export default { |
| | | name: "ArchiveDialog", |
| | |
| | | |
| | | 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 } }); |
| | | } |
| | | |
| | | Promise.all(patientList.map((p) => createArchive(p, this.subType, sourcePage))) |
| | | .then((records) => { |
| | | this.submitting = false; |
| | | this.dialogVisible = false; |
| | | this.$message.success(`成功创建 ${records.length} 条建档记录`); |
| | | this.$emit("created"); |
| | | |
| | | // 进入详情页(编辑态) |
| | | const first = records[0]; |
| | | if (first && type && first.id) { |
| | | this.$router.push({ path: type.detailRoute, query: { id: first.id, type: this.subType, edit: 1 } }); |
| | | } |
| | | }) |
| | | .catch(() => { |
| | | this.submitting = false; |
| | | this.$message.error("建档失败,请稍后重试"); |
| | | }); |
| | | }, |
| | | handleClose() { this.resetForm(); }, |
| | | }, |