WXL
2026-05-17 d4b9b197632366be60796f059030394aef6802ea
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
<template>
  <div class="death-judgment-list">
    <!-- 查询条件 -->
    <el-card class="search-card">
      <el-form
        :model="queryParams"
        ref="queryForm"
        :inline="true"
        label-width="100px"
      >
        <el-form-item label="住院号" prop="inpatientno">
          <el-input
            v-model="queryParams.inpatientno"
            placeholder="请输入住院号"
            clearable
            style="width: 200px"
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="捐献者姓名" prop="name">
          <el-input
            v-model="queryParams.name"
            placeholder="请输入捐献者姓名"
            clearable
            style="width: 200px"
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="死亡原因" prop="deathreason">
          <el-select
            v-model="queryParams.deathreason"
            placeholder="请选择死亡原因"
            clearable
            style="width: 200px"
          >
            <el-option label="脑死亡" value="brain_death" />
            <el-option label="心死亡" value="heart_death" />
            <el-option label="其他" value="other" />
          </el-select>
        </el-form-item>
        <el-form-item label="死亡时间范围" prop="deathTimeRange">
          <el-date-picker
            v-model="queryParams.deathTimeRange"
            type="daterange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            value-format="yyyy-MM-dd"
            style="width: 240px"
          />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" @click="handleQuery"
            >搜索</el-button
          >
          <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>
    </el-card>
 
    <!-- 操作按钮 -->
    <el-card class="tool-card">
      <el-row :gutter="10">
        <el-col :span="16">
          <!-- <el-button
            type="primary"
            icon="el-icon-plus"
            @click="handleCreate"
            >新增脑死亡判定</el-button
          >
          <el-button
            type="success"
            icon="el-icon-plus"
            @click="handleCreateHeartDeath"
            >新增心死亡判定</el-button
          >
          <el-button
            type="warning"
            icon="el-icon-edit"
            :disabled="single"
            @click="handleUpdate"
            >修改</el-button
          > -->
          <el-button
            type="warning"
            icon="el-icon-download"
            @click="handleExport"
            >导出</el-button
          >
        </el-col>
        <el-col :span="8" style="text-align: right">
          <el-tooltip content="刷新" placement="top">
            <el-button icon="el-icon-refresh" circle @click="getList" />
          </el-tooltip>
        </el-col>
      </el-row>
    </el-card>
 
    <!-- 数据表格 -->
    <el-card>
      <el-table
        v-loading="loading"
        :data="deathJudgmentList"
        @selection-change="handleSelectionChange"
        :header-cell-style="{ background: '#f5f7fa', 'font-weight': 'bold' }"
      >
        <el-table-column type="selection" width="55" align="center" />
 
        <!-- 基础信息列 -->
        <el-table-column
          label="住院号"
          align="center"
          prop="inpatientno"
          width="120"
          fixed="left"
        />
        <el-table-column
          label="姓名"
          align="center"
          prop="name"
          width="100"
          fixed="left"
        />
        <el-table-column
          label="性别"
          align="center"
          prop="sex"
          width="80"
          fixed="left"
        >
          <template slot-scope="scope">
            <dict-tag
              :options="dict.type.sys_user_sex"
              :value="scope.row.sex"
            />
          </template>
        </el-table-column>
        <el-table-column
          label="年龄"
          align="center"
          prop="age"
          width="80"
          fixed="left"
        />
 
        <el-table-column
          label="疾病诊断"
          align="center"
          prop="diagnosisname"
          min-width="200"
          show-overflow-tooltip
        />
        <!-- 状态信息 -->
        <el-table-column
          label="判定状态"
          align="center"
          prop="state"
          width="100"
        >
          <template slot-scope="scope">
            <dict-tag
              :options="dict.type.decide_type"
              :value="scope.row.state"
            />
          </template>
        </el-table-column>
        <!-- 脑死亡判定信息 -->
        <el-table-column label="脑死亡判定" align="center">
          <el-table-column
            label="死亡原因"
            align="center"
            prop="deathreason"
            width="120"
          >
            <template slot-scope="scope">
              <el-tag
                v-if="scope.row.deathreason"
                :type="getDeathReasonTagType(scope.row.deathreason)"
              >
                {{ getDeathReasonText(scope.row.deathreason) }}
              </el-tag>
              <span v-else>-</span>
            </template>
          </el-table-column>
          <el-table-column
            label="死亡时间"
            align="center"
            prop="deathtime"
            width="160"
          >
            <template slot-scope="scope">
              <span>{{
                scope.row.deathtime ? formatTime(scope.row.deathtime) : "-"
              }}</span>
            </template>
          </el-table-column>
          <el-table-column
            label="判定医生一"
            align="center"
            prop="deathjudgedocto"
            width="120"
          >
            <template slot-scope="scope">
              {{ scope.row.deathjudgedocto || "-" }}
            </template>
          </el-table-column>
          <el-table-column
            label="判定医生二"
            align="center"
            prop="deathjudgedoctt"
            width="120"
          >
            <template slot-scope="scope">
              {{ scope.row.deathjudgedoctt || "-" }}
            </template>
          </el-table-column>
        </el-table-column>
 
        <!-- 心死亡判定信息 -->
        <el-table-column label="心死亡判定" align="center">
          <el-table-column
            label="死亡原因"
            align="center"
            prop="heartdeathreason"
            width="120"
          >
            <template slot-scope="scope">
              <el-tag v-if="scope.row.heartdeathreason" type="danger">
                {{ getHeartDeathReasonText(scope.row.heartdeathreason) }}
              </el-tag>
              <span v-else>-</span>
            </template>
          </el-table-column>
          <el-table-column
            label="死亡时间"
            align="center"
            prop="heartdeathtime"
            width="160"
          >
            <template slot-scope="scope">
              <span>{{
                scope.row.heartdeathtime
                  ? formatTime(scope.row.heartdeathtime)
                  : "-"
              }}</span>
            </template>
          </el-table-column>
          <el-table-column
            label="判定医生一"
            align="center"
            prop="heartdeathjudgedocto"
            width="120"
          >
            <template slot-scope="scope">
              {{ scope.row.heartdeathjudgedocto || "-" }}
            </template>
          </el-table-column>
          <el-table-column
            label="判定医生二"
            align="center"
            prop="heartdeathjudgedoctt"
            width="120"
          >
            <template slot-scope="scope">
              {{ scope.row.heartdeathjudgedoctt || "-" }}
            </template>
          </el-table-column>
        </el-table-column>
 
        <!-- 判定时间和操作列 -->
        <el-table-column
          label="判定时间"
          align="center"
          prop="createTime"
          width="160"
        >
          <template slot-scope="scope">
            <span>{{
              scope.row.createTime ? formatTime(scope.row.createTime) : "-"
            }}</span>
          </template>
        </el-table-column>
 
        <el-table-column
          label="操作"
          align="center"
          width="200"
          fixed="right"
          class-name="small-padding fixed-width"
        >
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              icon="el-icon-view"
              @click="handleView(scope.row)"
              >详情</el-button
            >
            <el-dropdown
              size="mini"
              @command="command => handleUpdateDropdown(scope.row, command)"
            >
              <el-button
                size="mini"
                type="text"
                icon="el-icon-edit"
                class="el-button--text"
              >
                修改<i class="el-icon-arrow-down el-icon--right"></i>
              </el-button>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item command="brainDeath">脑死亡</el-dropdown-item>
                <el-dropdown-item command="heartDeath">心死亡</el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </template>
        </el-table-column>
      </el-table>
 
      <!-- 分页组件 -->
      <pagination
        v-show="total > 0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </el-card>
  </div>
</template>
 
<script>
import {
  queryDathInfoBaseInfo,
  deathinfoedit,
  deathinfoInfo
} from "@/api/businessApi";
import Pagination from "@/components/Pagination";
 
export default {
  name: "DeathJudgmentList",
  components: { Pagination },
  dicts: ["sys_user_sex", "decide_type"],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 总条数
      total: 0,
      // 死亡判定表格数据
      deathJudgmentList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        inpatientno: undefined,
        name: undefined,
        deathreason: undefined,
        deathTimeRange: []
      },
      // 所有数据(用于前端筛选)
      allTableData: [],
      // 死亡原因映射
      deathReasonMap: {
        brain_death: { text: "脑死亡", type: "primary" },
        heart_death: { text: "心死亡", type: "danger" },
        other: { text: "其他", type: "info" }
      },
      // 心死亡原因映射
      heartDeathReasonMap: {
        cardiac_arrest: { text: "心搏骤停", type: "danger" },
        myocardial_infarction: { text: "心肌梗死", type: "danger" },
        heart_failure: { text: "心力衰竭", type: "danger" },
        other: { text: "其他", type: "info" }
      },
      // 状态映射
      statusMap: {
        "0": { text: "维护中", type: "warning" },
        "1": { text: "已完成", type: "success" },
        "2": { text: "审核中", type: "info" },
        "99": { text: "已终止", type: "danger" }
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    // 获取死亡原因标签类型
    getDeathReasonTagType(reason) {
      return this.deathReasonMap[reason]?.type || "info";
    },
 
    // 获取死亡原因文本
    getDeathReasonText(reason) {
      return this.deathReasonMap[reason]?.text || "未知";
    },
 
    // 获取心死亡原因文本
    getHeartDeathReasonText(reason) {
      if (!reason) return "-";
      return this.heartDeathReasonMap[reason]?.text || reason;
    },
 
    // 获取状态标签类型
    getStatusTagType(status) {
      return this.statusMap[status]?.type || "info";
    },
 
    // 获取状态文本
    getStatusText(status) {
      return this.statusMap[status]?.text || "未知状态";
    },
 
    // 格式化时间
    formatTime(time) {
      if (!time) return "-";
      return this.parseTime(time, "{y}-{m}-{d} {h}:{i}");
    },
 
    // 查询死亡判定列表
    async getList() {
      this.loading = true;
      try {
        const response = await queryDathInfoBaseInfo(this.queryParams);
 
        // 根据实际接口返回结构调整
        let realData = [];
        if (response.code === 200) {
          realData = response.rows || response.data || [];
          this.total = response.total || realData.length;
        } else {
          realData = [];
          this.total = 0;
        }
 
        // 存储所有数据用于前端筛选
        this.allTableData = realData;
 
        // 应用前端筛选条件
        let filteredData = this.applyFrontendFilter(realData);
 
        // 前端分页处理(如果接口不支持后端分页)
        if (
          this.total === filteredData.length &&
          this.total > this.queryParams.pageSize
        ) {
          const startIndex =
            (this.queryParams.pageNum - 1) * this.queryParams.pageSize;
          const endIndex = startIndex + this.queryParams.pageSize;
          this.deathJudgmentList = filteredData.slice(startIndex, endIndex);
        } else {
          // 接口已分页,直接使用返回数据
          this.deathJudgmentList = filteredData;
        }
      } catch (error) {
        console.error("获取死亡判定数据失败:", error);
        this.$message.error("数据加载失败");
        this.deathJudgmentList = [];
        this.total = 0;
      } finally {
        this.loading = false;
      }
    },
 
    // 应用前端筛选
    applyFrontendFilter(data) {
      let filteredData = data;
 
      // 住院号筛选
      if (this.queryParams.inpatientno) {
        filteredData = filteredData.filter(
          item =>
            item.inpatientno &&
            item.inpatientno
              .toString()
              .toLowerCase()
              .includes(this.queryParams.inpatientno.toLowerCase())
        );
      }
 
      // 姓名筛选
      if (this.queryParams.name) {
        filteredData = filteredData.filter(
          item =>
            item.name &&
            item.name
              .toLowerCase()
              .includes(this.queryParams.name.toLowerCase())
        );
      }
 
      // 死亡原因筛选
      if (this.queryParams.deathreason) {
        filteredData = filteredData.filter(item => {
          // 同时筛选脑死亡和心死亡原因
          return (
            item.deathreason === this.queryParams.deathreason ||
            item.heartdeathreason === this.queryParams.deathreason
          );
        });
      }
 
      // 死亡时间范围筛选
      if (
        this.queryParams.deathTimeRange &&
        this.queryParams.deathTimeRange.length === 2
      ) {
        const [startDate, endDate] = this.queryParams.deathTimeRange;
        filteredData = filteredData.filter(item => {
          // 同时筛选脑死亡时间和心死亡时间
          const brainDeathTime = item.deathtime
            ? new Date(item.deathtime).getTime()
            : null;
          const heartDeathTime = item.heartdeathtime
            ? new Date(item.heartdeathtime).getTime()
            : null;
          const startTime = new Date(startDate).getTime();
          const endTime = new Date(endDate + " 23:59:59").getTime();
 
          return (
            (brainDeathTime &&
              brainDeathTime >= startTime &&
              brainDeathTime <= endTime) ||
            (heartDeathTime &&
              heartDeathTime >= startTime &&
              heartDeathTime <= endTime)
          );
        });
      }
 
      return filteredData;
    },
 
    // 搜索按钮操作
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
 
    // 重置按钮操作
    resetQuery() {
      this.$refs.queryForm.resetFields();
      this.queryParams.pageNum = 1;
      this.getList();
    },
 
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
 
    // 查看详情
    handleView(row) {
      this.$router.push({
        path: "/case/DecideInfo",
        query: {
          id: row.id,
          infoid: row.infoid,
          type: this.getDeathType(row) // 传递死亡类型
        }
      });
    },
 
    // 获取死亡类型
    getDeathType(row) {
      if (row.deathreason && row.deathreason.includes("brain")) {
        return "brain";
      } else if (row.heartdeathreason) {
        return "heart";
      }
      return "brain"; // 默认脑死亡
    },
 
    // 新增脑死亡判定
    handleCreate() {
      this.$router.push({
        path: "/case/DecideInfo",
        query: { type: "brain" }
      });
    },
 
    // 新增心死亡判定
    handleCreateHeartDeath() {
      this.$router.push({
        path: "/case/DecideInfo",
        query: { type: "heart" }
      });
    },
 
    // 修改按钮操作(下拉菜单)
    handleUpdateDropdown(row, command) {
      const id = row.id;
      const infoid = row.infoid;
 
      if (command === "brainDeath") {
        // 修改脑死亡判定
        this.$router.push({
          path: "/case/DecideInfo",
          query: {
            id: id,
            infoid: infoid,
            type: "brain",
            isEdit: true
          }
        });
      } else if (command === "heartDeath") {
        // 修改心死亡判定
        this.$router.push({
          path: "/case/DecideInfo",
          query: {
            id: id,
            infoid: infoid,
            type: "heart",
            isEdit: true
          }
        });
      }
    },
 
    // 导出按钮操作
    handleExport() {
      this.$confirm("是否确认导出所有死亡判定数据?", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          this.loading = true;
          // 这里调用导出接口
          return this.exportData();
        })
        .then(response => {
          if (response.code === 200) {
            this.$message.success("导出成功");
            this.downloadExportFile(response);
          }
          this.loading = false;
        })
        .catch(() => {
          this.loading = false;
        });
    },
 
    // 导出数据
    async exportData() {
      try {
        // 调用导出接口
        const response = await exportDeathJudgment(this.queryParams);
        return response;
      } catch (error) {
        console.error("导出失败:", error);
        this.$message.error("导出失败");
        throw error;
      }
    },
 
    // 下载导出文件
    downloadExportFile(response) {
      // 假设接口返回文件下载地址
      if (response.data && response.data.fileUrl) {
        const link = document.createElement("a");
        link.style.display = "none";
        link.href = response.data.fileUrl;
        link.download = "死亡判定数据.xlsx";
        document.body.appendChild(link);
        link.click();
        document.body.removeChild(link);
      }
    },
 
    // 时间格式化工具函数
    parseTime(time, pattern) {
      if (!time) return "";
      const format = pattern || "{y}-{m}-{d} {h}:{i}:{s}";
      let date;
      if (typeof time === "object") {
        date = time;
      } else {
        if (typeof time === "string" && /^[0-9]+$/.test(time)) {
          time = parseInt(time);
        }
        if (typeof time === "number" && time.toString().length === 10) {
          time = time * 1000;
        }
        date = new Date(time);
      }
      const formatObj = {
        y: date.getFullYear(),
        m: date.getMonth() + 1,
        d: date.getDate(),
        h: date.getHours(),
        i: date.getMinutes(),
        s: date.getSeconds(),
        a: date.getDay()
      };
      const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
        let value = formatObj[key];
        if (key === "a") {
          return ["日", "一", "二", "三", "四", "五", "六"][value];
        }
        if (result.length > 0 && value < 10) {
          value = "0" + value;
        }
        return value || 0;
      });
      return time_str;
    }
  }
};
</script>
 
<style scoped>
.death-judgment-list {
  padding: 20px;
}
 
.search-card {
  margin-bottom: 20px;
}
 
.tool-card {
  margin-bottom: 20px;
}
 
.fixed-width .el-button {
  margin: 0 2px;
}
 
/* 表格样式优化 */
::v-deep .el-table {
  border: 1px solid #ebeef5;
  border-radius: 4px;
}
 
::v-deep .el-table th {
  background-color: #f5f7fa;
  font-weight: bold;
  color: #333;
}
 
::v-deep .el-table .cell {
  padding: 8px 4px;
  line-height: 1.5;
}
 
::v-deep .el-table--border td,
::v-deep .el-table--border th {
  border-right: 1px solid #ebeef5;
}
 
::v-deep .el-table--border {
  border: 1px solid #ebeef5;
  border-bottom: none;
}
 
/* 多级表头样式 */
::v-deep .el-table .el-table__header-wrapper tr:first-child th {
  background-color: #f8f9fa;
  border-bottom: 2px solid #409eff;
}
 
::v-deep .el-table .el-table__header-wrapper tr:nth-child(2) th {
  background-color: #f0f7ff;
}
 
/* 操作列按钮样式 */
.el-dropdown-link {
  cursor: pointer;
  color: #409eff;
}
 
.el-dropdown-link:hover {
  color: #66b1ff;
}
 
/* 标签样式优化 */
::v-deep .el-tag {
  margin: 2px;
  border-radius: 12px;
  font-size: 12px;
  padding: 0 8px;
  height: 24px;
  line-height: 22px;
}
 
/* 分页样式 */
.pagination-container {
  margin-top: 20px;
  padding: 10px 0;
  background: #fff;
  border: 1px solid #ebeef5;
  border-top: none;
  border-radius: 0 0 4px 4px;
}
</style>