WXL (wul)
16 小时以前 a9d2b856e0f6be6475319c2dc36bf405c2f908fc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<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>