<template>
|
<div class="app-container">
|
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="80px">
|
<el-form-item label="姓名">
|
<el-input v-model="queryParams.patname" placeholder="请输入姓名" clearable @keyup.enter.native="handleQuery" style="width:180px" />
|
</el-form-item>
|
<el-form-item label="诊断">
|
<el-input v-model="queryParams.diagname" placeholder="请输入诊断" clearable @keyup.enter.native="handleQuery" style="width:180px" />
|
</el-form-item>
|
<el-form-item label="建档日期">
|
<el-date-picker v-model="dateRange" style="width:240px" value-format="yyyy-MM-dd" type="daterange"
|
range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" />
|
</el-form-item>
|
<el-form-item>
|
<el-button type="primary" icon="el-icon-search" size="medium" @click="handleQuery">搜索</el-button>
|
<el-button icon="el-icon-refresh" size="medium" @click="resetQuery">重置</el-button>
|
</el-form-item>
|
</el-form>
|
|
<el-row :gutter="10" class="mb8">
|
<el-col :span="1.5">
|
<el-button type="primary" plain icon="el-icon-plus" size="medium" @click="handleCreate">新建建档</el-button>
|
</el-col>
|
<el-col :span="1.5">
|
<el-button type="danger" plain icon="el-icon-delete" size="medium" :disabled="multiple" @click="handleDelete">删除</el-button>
|
</el-col>
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList" />
|
</el-row>
|
|
<el-table v-loading="loading" :data="displayList" @selection-change="handleSelectionChange">
|
<el-table-column type="selection" width="50" align="center" />
|
<el-table-column
|
v-for="col in typeConfig.columns"
|
:key="col.prop"
|
:label="col.label"
|
align="center"
|
show-overflow-tooltip
|
>
|
<template slot-scope="scope">
|
<el-tag v-if="col.type === 'closeStatus'" :type="scope.row.closeStatus == 1 ? 'info' : 'success'" size="mini">
|
{{ cellValue(scope.row, col) }}
|
</el-tag>
|
<span v-else>{{ cellValue(scope.row, col) }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column label="操作" align="center" fixed="right" width="120">
|
<template slot-scope="scope">
|
<el-button size="medium" type="text" @click="goDetail(scope.row)">
|
<span class="button-textsc"><i class="el-icon-zoom-in" />查看</span>
|
</el-button>
|
<el-button size="medium" type="text" @click="handleSingleDelete(scope.row)">
|
<span style="color:#f56c6c"><i class="el-icon-delete" />删除</span>
|
</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
|
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
|
@pagination="getList" />
|
|
<OutpatientPicker :visible.sync="pickerVisible" :type="type" @picked="onPicked" />
|
</div>
|
</template>
|
|
<script>
|
import OutpatientPicker from "./OutpatientPicker.vue";
|
import { getTypeByKey, loadArchives, saveArchives } from "../types";
|
|
export default {
|
name: "ArchiveList",
|
components: { OutpatientPicker },
|
props: {
|
type: { type: String, default: "" },
|
},
|
data() {
|
return {
|
loading: false, showSearch: true, multiple: true, ids: [], dateRange: [],
|
total: 0, allList: [], displayList: [], pickerVisible: false,
|
queryParams: { pageNum: 1, pageSize: 10, patname: "", diagname: "" },
|
};
|
},
|
computed: {
|
typeConfig() {
|
return getTypeByKey(this.type) || { columns: [], detailRoute: "/filing/maternalDetail" };
|
},
|
},
|
created() { this.getList(); },
|
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));
|
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];
|
});
|
}
|
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;
|
},
|
handleQuery() { this.queryParams.pageNum = 1; this.getList(); },
|
resetQuery() {
|
this.dateRange = [];
|
this.queryParams = { pageNum: 1, pageSize: 10, patname: "", diagname: "" };
|
this.getList();
|
},
|
handleSelectionChange(s) { this.ids = s.map((i) => i.id); this.multiple = !s.length; },
|
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);
|
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 } });
|
},
|
goDetail(row) {
|
this.$router.push({ path: this.typeConfig.detailRoute, query: { id: row.id } });
|
},
|
getProp(obj, path) {
|
if (!path) return "";
|
return path.split(".").reduce((o, k) => (o == null ? o : o[k]), obj);
|
},
|
cellValue(row, col) {
|
const val = this.getProp(row, col.prop);
|
if (col.type === "sex") return val == 1 ? "男" : "女";
|
if (col.type === "date") return val ? String(val).substring(0, 10) : "-";
|
if (col.type === "closeStatus") return val == 1 ? "已结案" : "未结案";
|
return val || "-";
|
},
|
},
|
};
|
</script>
|
|
<style lang="scss" scoped>
|
.button-textsc { color: #3664d9; }
|
</style>
|