| | |
| | | |
| | | <script> |
| | | import OutpatientPicker from "./OutpatientPicker.vue"; |
| | | import { getTypeByKey, loadArchives, saveArchives } from "../types"; |
| | | import { getTypeByKey } from "../types"; |
| | | import { listArchives, removeArchives } from "../apiAdapter"; |
| | | |
| | | export default { |
| | | name: "ArchiveList", |
| | |
| | | methods: { |
| | | getList() { |
| | | this.loading = true; |
| | | const all = loadArchives().filter((item) => item.subType === this.type); |
| | | let filtered = [...all]; |
| | | if (this.queryParams.patname) filtered = filtered.filter((i) => i.patname && i.patname.includes(this.queryParams.patname)); |
| | | if (this.queryParams.diagname) filtered = filtered.filter((i) => i.diagname && i.diagname.includes(this.queryParams.diagname)); |
| | | const params = { |
| | | pageNum: this.queryParams.pageNum, |
| | | pageSize: this.queryParams.pageSize, |
| | | }; |
| | | if (this.queryParams.patname) params.patname = this.queryParams.patname; |
| | | if (this.queryParams.diagname) params.diagname = this.queryParams.diagname; |
| | | if (this.dateRange && this.dateRange.length === 2) { |
| | | filtered = filtered.filter((i) => { |
| | | const d = (i.createTime || "").substring(0, 10); |
| | | return d >= this.dateRange[0] && d <= this.dateRange[1]; |
| | | }); |
| | | params.params = { beginTime: this.dateRange[0], endTime: this.dateRange[1] }; |
| | | } |
| | | this.total = filtered.length; |
| | | const start = (this.queryParams.pageNum - 1) * this.queryParams.pageSize; |
| | | this.displayList = filtered.slice(start, start + this.queryParams.pageSize); |
| | | this.loading = false; |
| | | listArchives(this.type, params) |
| | | .then((res) => { |
| | | this.displayList = res.rows || []; |
| | | this.total = res.total || 0; |
| | | }) |
| | | .catch(() => { |
| | | this.displayList = []; |
| | | this.total = 0; |
| | | }) |
| | | .finally(() => { this.loading = false; }); |
| | | }, |
| | | handleQuery() { this.queryParams.pageNum = 1; this.getList(); }, |
| | | resetQuery() { |
| | |
| | | handleDelete() { |
| | | if (this.ids.length === 0) { this.$modal.msgWarning("请至少选择一条"); return; } |
| | | this.$modal.confirm("确认删除选中档案?").then(() => { |
| | | const remaining = loadArchives().filter((item) => !this.ids.includes(item.id)); |
| | | saveArchives(remaining); |
| | | return removeArchives(this.type, this.ids).then(() => { |
| | | this.$modal.msgSuccess("删除成功"); |
| | | this.getList(); |
| | | }); |
| | | }).catch(() => {}); |
| | | }, |
| | | handleSingleDelete(row) { this.ids = [row.id]; this.handleDelete(); }, |
| | | handleCreate() { this.pickerVisible = true; }, |
| | | onPicked(record) { |
| | | this.getList(); |
| | | this.$router.push({ path: this.typeConfig.detailRoute, query: { id: record.id, edit: 1 } }); |
| | | this.$router.push({ path: this.typeConfig.detailRoute, query: { id: record.id, type: this.type, detailId: record.detailId || "", edit: 1 } }); |
| | | }, |
| | | goDetail(row) { |
| | | this.$router.push({ path: this.typeConfig.detailRoute, query: { id: row.id } }); |
| | | this.$router.push({ path: this.typeConfig.detailRoute, query: { id: row.id, type: this.type, detailId: row.detailId || "" } }); |
| | | }, |
| | | getProp(obj, path) { |
| | | if (!path) return ""; |