WXL
2026-01-28 bcb9976e7680ce67fadb6fec7ab5fca36552cdbc
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
<template>
  <div class="app-container">
    <!-- 搜索筛选区域 -->
    <el-card class="filter-card">
      <el-form
        :model="queryParams"
        ref="queryForm"
        :inline="true"
        v-show="showSearch"
        label-width="70px"
      >
        <el-form-item label="姓名" prop="name">
          <el-input
            v-model="queryParams.name"
            placeholder="请输入姓名"
            clearable
            size="small"
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="证件号码" prop="idcardno">
          <el-input
            v-model="queryParams.idcardno"
            placeholder="请输入证件号码"
            clearable
            size="small"
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="状态" prop="recordstate">
          <el-select
            v-model="queryParams.recordstate"
            placeholder="请选择状态"
            clearable
            size="small"
          >
            <el-option label="全部" value="" />
            <el-option label="维护中" value="0" />
            <el-option label="已完成" value="1" />
            <el-option label="已终止" value="99" />
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button
            type="primary"
            icon="el-icon-search"
            size="mini"
            @click="handleQuery"
            >搜索</el-button
          >
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
            >重置</el-button
          >
        </el-form-item>
      </el-form>
    </el-card>
 
    <!-- 统计卡片 -->
    <el-row :gutter="20" class="stats-row">
      <el-col :span="6">
        <el-card class="stats-card total" shadow="hover">
          <div class="stat-content">
            <div class="stat-icon">📊</div>
            <div class="stat-info">
              <div class="stat-count">{{ stats.totalCount }}</div>
              <div class="stat-label">总捐献者</div>
            </div>
          </div>
        </el-card>
      </el-col>
      <el-col :span="6">
        <el-card class="stats-card pending" shadow="hover">
          <div class="stat-content">
            <div class="stat-icon">⏳</div>
            <div class="stat-info">
              <div class="stat-count">{{ stats.pendingCount }}</div>
              维护中
            </div>
          </div>
        </el-card>
      </el-col>
      <el-col :span="6">
        <el-card class="stats-card approved" shadow="hover">
          <div class="stat-content">
            <div class="stat-icon">✅</div>
            <div class="stat-info">
              <div class="stat-count">{{ stats.approvedCount }}</div>
              <div class="stat-label">已完成</div>
            </div>
          </div>
        </el-card>
      </el-col>
      <el-col :span="6">
        <el-card class="stats-card terminated" shadow="hover">
          <div class="stat-content">
            <div class="stat-icon">❌</div>
            <div class="stat-info">
              <div class="stat-count">{{ stats.terminatedCount }}</div>
              <div class="stat-label">已终止</div>
            </div>
          </div>
        </el-card>
      </el-col>
    </el-row>
 
    <!-- 数据表格 -->
    <el-table
      v-loading="loading"
      :data="donatebaseinfoList"
      border
      :default-sort="{ prop: 'reporttime', order: 'descending' }"
      style="width: 100%; margin-top: 20px;"
    >
      <el-table-column
        label="上报时间"
        align="center"
        prop="reporttime"
        width="110"
        fixed="left"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.reporttime, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
 
      <el-table-column
        label="捐献状态"
        align="center"
        prop="recordstate"
        width="100"
        fixed="left"
      >
        <template slot-scope="scope">
          <el-tag :type="getStatusTag(scope.row.recordstate)">
            {{ getStatusText(scope.row.recordstate) }}
          </el-tag>
        </template>
      </el-table-column>
 
      <el-table-column label="姓名" align="center" prop="name" width="100" />
 
      <el-table-column label="性别" align="center" prop="sex" width="80">
        <template slot-scope="scope">
          <span>{{ scope.row.sex === "1" ? "男" : "女" }}</span>
        </template>
      </el-table-column>
 
      <el-table-column label="年龄" align="center" prop="age" width="80" />
 
      <el-table-column
        label="证件号码"
        align="center"
        prop="idcardno"
        width="180"
      />
 
      <el-table-column
        label="治疗医院"
        align="center"
        prop="treatmenthospitalname"
        width="150"
      />
 
      <el-table-column
        label="协调员"
        align="center"
        prop="coordinatorName"
        width="100"
      />
 
      <el-table-column
        label="案例编号"
        align="center"
        prop="caseNo"
        width="120"
      />
 
      <!-- 第一次医学评估 -->
      <el-table-column
        label="第一次评估结论"
        align="center"
        prop="firstAssessState"
        width="120"
      >
        <template slot-scope="scope">
          <dict-tag
            :options="dict.type.sys_BaseAssessConclusion"
            :value="scope.row.firstAssessState"
          />
        </template>
      </el-table-column>
 
      <el-table-column
        label="第一次评估时间"
        align="center"
        prop="assessFirstTime"
        width="110"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.assessFirstTime, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
 
      <!-- 第二次医学评估 -->
      <el-table-column
        label="第二次评估结论"
        align="center"
        prop="secondAssessState"
        width="120"
      >
        <template slot-scope="scope">
          <dict-tag
            :options="dict.type.sys_BaseAssessConclusion"
            :value="scope.row.secondAssessState"
          />
        </template>
      </el-table-column>
 
      <el-table-column
        label="第二次评估时间"
        align="center"
        prop="assessSecondTime"
        width="110"
      >
        <template slot-scope="scope">
          <span>{{
            parseTime(scope.row.assessSecondTime, "{y}-{m}-{d}")
          }}</span>
        </template>
      </el-table-column>
 
      <el-table-column
        label="亲属确认时间"
        align="center"
        prop="signDate"
        width="110"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.signDate, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
 
      <el-table-column
        label="伦理审查结论"
        align="center"
        prop="expertConclusion"
        width="120"
      >
        <template slot-scope="scope">
          <dict-tag
            :options="dict.type.sys_EthicalReview"
            :value="scope.row.expertConclusion"
          />
        </template>
      </el-table-column>
 
      <el-table-column
        label="伦理审查时间"
        align="center"
        prop="expertTime"
        width="110"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.expertTime, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
 
      <el-table-column
        label="器官分配数量"
        align="center"
        prop="organCount"
        width="100"
      />
 
      <el-table-column
        label="获取见证时间"
        align="center"
        prop="operationBegTime"
        width="110"
      >
        <template slot-scope="scope">
          <span>{{
            parseTime(scope.row.operationBegTime, "{y}-{m}-{d}")
          }}</span>
        </template>
      </el-table-column>
 
      <el-table-column
        label="完成登记时间"
        align="center"
        prop="completeTime"
        width="110"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.completeTime, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
 
      <!-- 捐献进度列 -->
      <el-table-column
        label="捐献进度"
        align="center"
        prop="recordstate"
        width="120"
      >
        <template slot-scope="scope">
          <div v-if="scope.row.terminationCase == 0">
            <dict-tag
              :options="dict.type.sys_donornode"
              :value="scope.row.recordstate"
            />
          </div>
          <div v-else>
            <el-tag type="danger">任务终止</el-tag>
          </div>
        </template>
      </el-table-column>
 
      <!-- 操作列:只保留终止和查看详情 -->
      <el-table-column label="操作" align="center" width="150" fixed="right">
        <template slot-scope="scope">
          <el-button size="mini" type="text" @click="handleDetail(scope.row)"
            >查看详情</el-button
          >
          <el-button
            size="mini"
            type="text"
            style="color: #f56c6c;"
            @click="handleTerminate(scope.row)"
            v-if="
              scope.row.terminationCase === 0 && scope.row.recordstate !== '99'
            "
            >终止</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"
    />
 
    <!-- 详情弹框 -->
    <el-dialog
      :title="`捐献者详情 - ${currentRecord.name || ''}`"
      :visible.sync="detailVisible"
      width="1000px"
      append-to-body
    >
      <donor-detail :donorData="currentRecord" @close="detailVisible = false" />
    </el-dialog>
 
    <!-- 终止确认弹框 -->
    <el-dialog
      title="终止确认"
      :visible.sync="terminateVisible"
      width="400px"
      append-to-body
    >
      <div style="margin-bottom: 20px;">
        <p>
          确定要终止捐献者
          <strong>{{ currentRecord.name }}</strong> 的捐献进程吗?
        </p>
        <p style="color: #f56c6c; font-size: 12px;">
          此操作不可逆,请谨慎操作!
        </p>
      </div>
      <div slot="footer">
        <el-button @click="terminateVisible = false">取消</el-button>
        <el-button type="danger" @click="submitTerminate">确认终止</el-button>
      </div>
    </el-dialog>
  </div>
</template>
 
<script>
import { courselist, terminateDonor } from "@/api/businessApi";
 
export default {
  name: "Donatebaseinfo",
  dicts: ["sys_donornode", "sys_EthicalReview", "sys_BaseAssessConclusion"],
  data() {
    return {
      // 遮罩层
      loading: false,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 捐献基础表格数据
      donatebaseinfoList: [],
      // 详情弹框显示
      detailVisible: false,
      // 终止确认弹框显示
      terminateVisible: false,
      // 当前操作记录
      currentRecord: {},
      // 统计数据
      stats: {
        totalCount: 0,
        pendingCount: 0,
        approvedCount: 0,
        terminatedCount: 0
      },
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        name: undefined,
        idcardno: undefined,
        recordstate: undefined
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询捐献基础列表 */
    async getList() {
      this.loading = true;
      try {
        const response = await courselist(this.queryParams);
 
        // 根据实际接口返回结构调整
        let realData = [];
        realData = response.data.donatebaseinfoProgressDTOS;
        this.total = response.total;
        this.stats.pendingCount = response.data.terminationCase[0];
        this.stats.approvedCount = response.data.terminationCase[1];
        this.stats.terminatedCount = response.data.terminationCase[2];
        this.stats.totalCount = response.total;
        // 存储所有数据用于前端筛选和分页
        this.allTableData = realData;
 
        // 应用前端筛选条件(如果接口不支持后端筛选)
        let filteredData = this.applyFrontendFilter(realData);
 
        // 前端分页处理(如果接口不支持后端分页)
        if (!response.total && !response.data) {
          const startIndex =
            (this.queryParams.pageNum - 1) * this.queryParams.pageSize;
          const endIndex = startIndex + this.queryParams.pageSize;
          this.donatebaseinfoList = filteredData.slice(startIndex, endIndex);
          this.total = filteredData.length;
        } else {
          // 接口已分页,直接使用返回数据
          this.donatebaseinfoList = filteredData;
        }
 
        // 更新统计数据
        // this.updateStats(realData);
      } catch (error) {
        console.error("获取数据失败:", error);
        this.$message.error("数据加载失败");
        this.donatebaseinfoList = [];
        this.total = 0;
        // this.updateStats([]);
      } finally {
        this.loading = false;
      }
    },
 
    /** 应用前端筛选 */
    applyFrontendFilter(data) {
      let filteredData = data;
 
      if (this.queryParams.name) {
        filteredData = filteredData.filter(
          item => item.name && item.name.includes(this.queryParams.name)
        );
      }
 
      if (this.queryParams.idcardno) {
        filteredData = filteredData.filter(
          item =>
            item.idcardno && item.idcardno.includes(this.queryParams.idcardno)
        );
      }
 
      if (this.queryParams.recordstate) {
        filteredData = filteredData.filter(
          item => item.recordstate === this.queryParams.recordstate
        );
      }
 
      return filteredData;
    },
 
    /** 更新统计数据 */
    updateStats(data) {
      this.stats.totalCount = data.length;
      this.stats.pendingCount = data.filter(
        item => item.recordstate === "0" || item.recordstate === 0
      ).length;
      this.stats.approvedCount = data.filter(
        item => item.recordstate === "1" || item.recordstate === 1
      ).length;
      this.stats.terminatedCount = data.filter(
        item => item.recordstate === "99" || item.recordstate === 99
      ).length;
    },
 
    /** 获取状态标签样式 */
    getStatusTag(status) {
      const statusMap = {
        "0": "warning", // 维护中
        "1": "success", // 已完成
        "99": "danger" // 已终止
      };
      return statusMap[status] || "info";
    },
 
    /** 获取状态文本 */
    getStatusText(status) {
      const textMap = {
        "0": "维护中",
        "1": "已完成",
        "99": "已终止"
      };
      return textMap[status] || "未知状态";
    },
 
    /** 时间格式化 */
    parseTime(time, format) {
      if (!time) return "-";
 
      // 处理时间戳和日期字符串
      const date = new Date(time);
      if (isNaN(date.getTime())) return time;
 
      const year = date.getFullYear();
      const month = (date.getMonth() + 1).toString().padStart(2, "0");
      const day = date
        .getDate()
        .toString()
        .padStart(2, "0");
 
      if (format === "{y}-{m}-{d}") {
        return `${year}-${month}-${day}`;
      }
      return time;
    },
 
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
 
    /** 重置按钮操作 */
    resetQuery() {
      this.$refs.queryForm.resetFields();
      this.queryParams.pageNum = 1;
      this.getList();
    },
 
    /** 查看详情 */
    handleDetail(row) {
      this.currentRecord = { ...row };
      this.detailVisible = true;
    },
 
    /** 终止操作 */
    handleTerminate(row) {
      this.currentRecord = { ...row };
      this.terminateVisible = true;
    },
 
    /** 提交终止 */
    async submitTerminate() {
      try {
        // 调用终止接口
        await terminateDonor({
          id: this.currentRecord.id,
          caseNo: this.currentRecord.caseNo,
          terminationReason: "管理员手动终止"
        });
 
        this.$message.success("终止成功");
        this.terminateVisible = false;
        this.getList(); // 重新加载更新数据
      } catch (error) {
        this.$message.error("终止失败");
        console.error("终止错误:", error);
      }
    }
  }
};
</script>
 
<style scoped>
.filter-card {
  margin-bottom: 20px;
}
 
.stats-row {
  margin-bottom: 20px;
}
 
.stats-card {
  border-radius: 8px;
  transition: all 0.3s ease;
}
 
.stats-card:hover {
  transform: translateY(-2px);
}
 
.stats-card.total {
  border-left: 4px solid #409eff;
}
 
.stats-card.pending {
  border-left: 4px solid #e6a23c;
}
 
.stats-card.approved {
  border-left: 4px solid #67c23a;
}
 
.stats-card.terminated {
  border-left: 4px solid #f56c6c;
}
 
.stat-content {
  display: flex;
  align-items: center;
  padding: 10px;
}
 
.stat-icon {
  font-size: 32px;
  margin-right: 15px;
}
 
.stat-info {
  flex: 1;
}
 
.stat-count {
  font-size: 24px;
  font-weight: bold;
  color: #303133;
  margin-bottom: 5px;
}
 
.stat-label {
  font-size: 14px;
  color: #909399;
}
 
/* 表格样式优化 */
::v-deep .el-table .cell {
  padding: 8px 4px;
}
 
::v-deep .el-table th {
  background-color: #f5f7fa;
  font-weight: bold;
}
 
/* 操作按钮样式 */
::v-deep .el-button--text {
  padding: 4px 8px;
}
</style>