WXL
5 天以前 631c8f37b449b09d19345b76400a39abdb7800f6
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
<template>
  <div class="app-container">
    <!-- 搜索筛选区域 -->
    <el-card class="filter-card">
      <el-form
        :model="queryParams"
        ref="queryForm"
        :inline="true"
        class="demo-form-inline"
      >
        <el-form-item label="案例编号" prop="caseNo">
          <el-input
            v-model="queryParams.caseNo"
            placeholder="请输入案例编号"
            clearable
            style="width: 200px"
          />
        </el-form-item>
        <el-form-item label="捐献者姓名" prop="name">
          <el-input
            v-model="queryParams.name"
            placeholder="请输入捐献者姓名"
            clearable
            style="width: 200px"
          />
        </el-form-item>
        <el-form-item label="案例状态" prop="reportStatus">
          <el-select
            v-model="queryParams.reportStatus"
            placeholder="请选择状态"
            clearable
            style="width: 200px"
          >
            <el-option label="全部" value="" />
            <el-option label="已阅读" value="2" />
            <el-option label="已同意" value="3" />
            <el-option label="已驳回" value="4" />
          </el-select>
        </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-row :gutter="10" class="mb8">
      <!-- <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" @click="handleAdd"
          >新增案例</el-button
        >
      </el-col> -->
 
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          :disabled="multiple"
          @click="handleDelete"
          >删除</el-button
        >
      </el-col>
    </el-row>
 
    <!-- 数据表格 -->
    <el-table
      v-loading="loading"
      :data="caseList"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column
        label="上报时间"
        align="center"
        prop="reporttime"
        width="160"
      />
 
      <el-table-column
        label="捐献者姓名"
        align="center"
        prop="name"
        width="100"
      />
      <el-table-column label="性别" align="center" prop="sex" width="80">
        <template slot-scope="scope">
          <dict-tag
            :options="dict.type.sys_user_sex"
            :value="parseInt(scope.row.sex)"
          />
        </template>
      </el-table-column>
      <el-table-column label="年龄" align="center" prop="age" width="80" />
      <el-table-column label="血型" align="center" prop="bloodType" width="80">
        <template slot-scope="scope">
          <dict-tag
            :options="dict.type.sys_BloodType"
            :value="scope.row.bloodtype"
          />
        </template>
      </el-table-column>
 
      <el-table-column
        label="GCS评分"
        align="center"
        prop="gscScore"
        width="80"
        show-overflow-tooltip
      />
      <el-table-column
        label="疾病诊断"
        align="center"
        prop="diagnosisname"
        min-width="200"
        show-overflow-tooltip
      />
      <el-table-column
        label="治疗医院"
        align="center"
        prop="treatmenthospitalname"
        width="150"
      />
      <el-table-column
        label="状态"
        align="center"
        prop="reportStatus"
        width="100"
      >
        <template slot-scope="scope">
          <el-tag :type="scope.row.reportStatus | statusFilter">
            {{ scope.row.reportStatus | statusTextFilter }}
          </el-tag>
        </template>
      </el-table-column>
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
        width="200"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-view"
            @click="handleDetail(scope.row)"
            >详情</el-button
          >
 
          <el-button
            size="mini"
            type="text"
            icon="el-icon-check"
            @click="handleApprove(scope.row)"
            v-if="scope.row.reportStatus === '2'"
            >审批</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="detailTitle"
      :visible.sync="detailOpen"
      width="900px"
      append-to-body
      :close-on-click-modal="false"
    >
      <case-detail :caseData="currentCase" @close="detailOpen = false" />
    </el-dialog>
 
    <!-- 审批弹框 -->
    <el-dialog
      title="案例审批"
      :visible.sync="approveOpen"
      width="80vw"
      append-to-body
      class="approve-dialog"
    >
      <el-container style="height: 800px;">
        <!-- 左侧:案例详情 -->
        <el-aside
          width="50vw"
          style="background: #f8f9fa; padding: 20px; overflow-y: auto;"
        >
          <div class="approve-detail-preview">
            <h3 style="margin-bottom: 15px; color: #303133;">案例详情预览</h3>
            <case-detail :caseData="currentCase" :showtitle="false" />
          </div>
        </el-aside>
 
        <!-- 右侧:审批表单 -->
        <el-main style="padding: 20px;">
          <el-form
            ref="approveForm"
            :model="approveForm"
            :rules="approveRules"
            label-width="100px"
          >
            <el-form-item label="审批结果" prop="approveResult">
              <el-radio-group v-model="approveForm.approveResult">
                <el-radio label="3">同意</el-radio>
                <el-radio label="4">驳回</el-radio>
              </el-radio-group>
            </el-form-item>
            <el-form-item label="审批意见" prop="approveOpinion">
              <el-input
                type="textarea"
                v-model="approveForm.approveOpinion"
                placeholder="请输入详细的审批意见,包括通过或驳回的理由"
                :rows="6"
                maxlength="500"
                show-word-limit
              />
            </el-form-item>
          </el-form>
        </el-main>
      </el-container>
 
      <div slot="footer" class="dialog-footer">
        <el-button @click="approveOpen = false">取消</el-button>
        <el-button type="primary" @click="submitApprove">确定</el-button>
      </div>
    </el-dialog>
  </div>
</template>
 
<script>
import CaseDetail from "./caseDetail";
import {
  donateList,
  donateInfo,
  donateDel,
  donateEdit
} from "@/api/businessApi/index";
 
export default {
  name: "CaseList",
  components: { CaseDetail },
  dicts: ["sys_user_sex", "sys_BloodType"],
  data() {
    return {
      // 遮罩层
      loading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 总条数
      total: 0,
      // 案例表格数据
      caseList: [],
      // 详情弹框是否显示
      detailOpen: false,
      // 审批弹框是否显示
      approveOpen: false,
      // 详情弹框标题
      detailTitle: "",
      // 当前操作的案例
      currentCase: {},
      // 性别选项
      genderOptions: [
        { value: "0", label: "男" },
        { value: "1", label: "女" }
      ],
      // 血型选项
      bloodTypeOptions: [
        { value: "A", label: "A型" },
        { value: "B", label: "B型" },
        { value: "O", label: "O型" },
        { value: "AB", label: "AB型" }
      ],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        caseNo: undefined,
        name: undefined,
        reportStatus: undefined
      },
      // 审批表单
      approveForm: {
        id: null,
        approveResult: "3",
        approveOpinion: ""
      },
      // 审批表单验证
      approveRules: {
        approveResult: [
          { required: true, message: "请选择审批结果", trigger: "change" }
        ],
        approveOpinion: [
          { required: true, message: "请输入审批意见", trigger: "blur" }
        ]
      }
    };
  },
  filters: {
    statusFilter(reportStatus) {
      const statusMap = {
        "1": "info", // 已上报
        "2": "warning", // 已阅读(待审批)
        "3": "success", // 已同意
        "4": "danger" // 已驳回
      };
      return statusMap[reportStatus] || "info";
    },
    statusTextFilter(reportStatus) {
      const statusMap = {
        "1": "已上报",
        "2": "已阅读",
        "3": "已同意",
        "4": "已驳回"
      };
      return statusMap[reportStatus] || "未知状态";
    }
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询案例列表 */
    async getList() {
      this.loading = true;
      try {
        const response = await donateList(this.queryParams);
        this.caseList = response.rows || response.data || [];
        this.total = response.total || this.caseList.length;
      } catch (error) {
        console.error("获取案例列表失败:", error);
        this.$modal.msgError("获取案例列表失败");
        // 模拟数据
        this.caseList = this.getMockData();
        this.total = this.caseList.length;
      } finally {
        this.loading = false;
      }
    },
 
    /** 模拟数据 */
    getMockData() {
      return [
        {
          id: 1,
          caseNo: "DON20241219001",
          name: "张三",
          sex: "0",
          age: 38,
          bloodType: "A",
          gscScore: "1",
          diagnosisname:
            "脑外伤导致脑死亡,经抢救无效宣布脑死亡。家属同意器官捐献。",
          treatmenthospitalname: "青岛大学附属医院",
          reportStatus: "2",
          reporttime: "2024-12-19 09:30:00",
          reportername: "李医生",
          idcardno: "370203198510123456",
          nation: "汉族",
          phone: "13800138000",
          registeraddress: "山东省青岛市市南区香港中路100号",
          inpatientno: "ZY20241219001",
          treatmentdeptname: "神经外科",
          doctorname: "王主任",
          infectious: "无",
          illnessoverview:
            "患者因交通事故导致严重脑外伤,经抢救无效宣布脑死亡。",
          hospitalLevel: "三级甲等",
          contactperson: "张护士",
          contactphone: "13900139000",
          hospitalAddress: "山东省青岛市市南区江苏路1号"
        },
        {
          id: 2,
          caseNo: "DON20241218001",
          name: "李四",
          sex: "0",
          age: 45,
          bloodType: "O",
          gscScore: "3",
          diagnosisname: "急性心肌梗死,心脏功能衰竭",
          treatmenthospitalname: "青岛市立医院",
          reportStatus: "3",
          reporttime: "2024-12-18 14:20:00",
          approvetime: "2024-12-18 16:30:00",
          reportername: "刘医生",
          approvername: "审核专员A",
          approveopinion: "资料齐全,符合捐献条件,同意通过。"
        }
      ];
    },
 
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
 
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
 
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
 
    /** 详情按钮操作 */
    async handleDetail(row) {
      try {
        // 先获取案例详情
        const response = await donateInfo(row.id);
        this.currentCase = response.data || response || row;
 
        // 如果状态是"已上报"(1),则使用完整数据更新为"已阅读"(2)
        if (this.currentCase.reportStatus === "1") {
          try {
            // 使用完整的案例数据作为更新基础,确保所有字段都被保留
            const updateData = {
              ...this.currentCase, // 展开所有现有字段
              reportStatus: "2", // 更新状态为已阅读
              updateTime: new Date()
                .toISOString()
                .replace("T", " ")
                .substring(0, 19),
              updateBy: "当前用户" // 添加更新人信息
            };
 
            await donateEdit(updateData);
 
            // 更新本地数据和当前显示的数据
            this.currentCase.reportStatus = "2";
            this.currentCase.updateTime = updateData.updateTime;
            row.reportStatus = "2"; // 更新列表中的状态
 
            this.$modal.msgSuccess("状态已更新为已阅读");
          } catch (updateError) {
            console.error("状态更新失败:", updateError);
            this.$modal.msgError("状态更新失败,但将继续显示详情");
            // 更新失败时,继续使用原始状态显示详情
          }
        }
 
        this.detailTitle = `案例详情 - ${this.currentCase.caseNo ||
          row.caseNo}`;
        this.detailOpen = true;
      } catch (error) {
        console.error("获取案例详情失败:", error);
        // 如果获取详情失败,使用行数据作为后备
        this.currentCase = row;
        this.detailTitle = `案例详情 - ${row.caseNo}`;
        this.detailOpen = true;
 
        // 即使获取详情失败,也尝试更新状态(使用行数据)
        if (row.reportStatus === "1") {
          try {
            const updateData = {
              id: row.id,
              reportStatus: "2",
              updateTime: new Date()
                .toISOString()
                .replace("T", " ")
                .substring(0, 19),
              updateBy: "当前用户"
              // 注意:这里只能传递部分字段,因为详情获取失败了
            };
 
            await donateEdit(updateData);
            row.reportStatus = "2";
            this.currentCase.reportStatus = "2";
            this.$modal.msgSuccess("状态已更新为已阅读");
          } catch (updateError) {
            console.error("状态更新失败:", updateError);
          }
        }
      }
    },
 
    /** 审批按钮操作 */
    async handleApprove(row) {
      try {
        // 先获取案例详情数据,确保有完整数据
        const response = await donateInfo(row.id);
        this.currentCase = response.data || response || row;
 
        this.approveForm.id = row.id;
        this.approveForm.approveResult = "3";
        this.approveForm.approveOpinion = "";
 
        this.$nextTick(() => {
          if (this.$refs.approveForm) {
            this.$refs.approveForm.clearValidate();
          }
        });
 
        this.approveOpen = true;
      } catch (error) {
        console.error("获取案例详情失败:", error);
        // 如果获取详情失败,使用行数据作为后备
        this.currentCase = row;
        this.approveForm.id = row.id;
        this.approveForm.approveResult = "3";
        this.approveForm.approveOpinion = "";
        this.approveOpen = true;
        this.$modal.msgError("获取详情失败,但已打开审批窗口");
      }
    },
 
    /** 提交审批 */
    async submitApprove() {
      try {
        const valid = await this.$refs.approveForm.validate();
        if (valid) {
          // 使用完整的案例数据作为基础,确保所有字段都被保留
          const approveData = {
            ...this.currentCase, // 展开所有现有字段
            reportStatus: this.approveForm.approveResult,
            approveOpinion: this.approveForm.approveOpinion,
            approvername: "当前用户", // 实际项目中应该获取当前登录用户
            approvetime: new Date()
              .toISOString()
              .replace("T", " ")
              .substring(0, 19),
            updateTime: new Date()
              .toISOString()
              .replace("T", " ")
              .substring(0, 19),
            updateBy: "当前用户"
          };
 
          // 移除可能不需要的字段(根据实际API需求调整)
          delete approveData.createTime; // 创建时间不应被更新
          delete approveData.createBy; // 创建人不应变
 
          await donateEdit(approveData);
          this.$modal.msgSuccess("审批成功");
          this.approveOpen = false;
          this.getList(); // 重新加载列表
        }
      } catch (error) {
        console.error("审批失败:", error);
        if (error !== "cancel") {
          this.$modal.msgError("审批失败");
        }
      }
    },
 
    /** 新增按钮操作 */
    handleAdd() {
      this.$router.push("/case/add");
    },
 
    /** 删除按钮操作 */
    async handleDelete(row) {
      const ids = row.id || this.ids;
      try {
        await this.$modal.confirm(
          '是否确认删除案例编号为"' + ids + '"的数据项?'
        );
        await donateDel(ids);
        this.$modal.msgSuccess("删除成功");
        this.getList();
      } catch (error) {
        if (error !== "cancel") {
          console.error("删除失败:", error);
          this.$modal.msgError("删除失败");
        }
      }
    }
  }
};
</script>
 
<style scoped>
.filter-card {
  margin-bottom: 20px;
}
.mb8 {
  margin-bottom: 8px;
}
/* 详情页面样式优化 */
.case-detail-container {
  max-height: 70vh;
  overflow-y: auto;
  padding: 0 10px;
}
 
.detail-section {
  margin-bottom: 16px;
}
 
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
 
.section-title {
  font-size: 16px;
  font-weight: bold;
  color: #303133;
}
 
/* 审批弹框样式 */
.approve-dialog >>> .el-dialog__body {
  padding: 0;
}
 
.approve-detail-preview {
  height: 100%;
}
 
/* 响应式设计 */
@media (max-width: 1200px) {
  .approve-dialog {
    width: 95% !important;
  }
 
  .el-aside {
    width: 50% !important;
  }
}
</style>