WXL
14 小时以前 9b2c74ee4f08fad01c2a16bc6e36df073bfa1dd5
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
<template>
  <el-card class="basic-info-card" v-loading="loading">
    <div slot="header" class="clearfix">
      <span>案例基本信息</span>
      <el-button
        v-if="showAttachment && hasAttachments"
        style="float: right; padding: 3px 0"
        type="text"
        @click="handleAttachmentPreview"
      >
        <i class="el-icon-folder-opened"></i> 查看附件
      </el-button>
    </div>
 
    <el-descriptions v-if="basicData" :column="column" border>
      <!-- 1. 案例编号 -->
      <el-descriptions-item label="案例编号">
        {{ basicData.caseNo || "--" }}
      </el-descriptions-item>
 
      <!-- 2. 潜在捐献者姓名 -->
      <el-descriptions-item label="捐献者姓名">
        {{ basicData.name || basicData.donorName || "--" }}
      </el-descriptions-item>
 
      <!-- 3. 性别/年龄 -->
      <el-descriptions-item label="性别/年龄">
        <span v-if="basicData.sex">
          <dict-tag
            v-if="useDict"
            :options="sexOptions"
            :value="basicData.sex"
          />
          <template v-else>{{ basicData.sex == "1" ? "男" : "女" }}</template>
        </span>
        <span v-if="basicData.age">
          / {{ basicData.age }}{{ basicData.ageunit || "岁" }}</span
        >
        <span v-if="!basicData.sex && !basicData.age">--</span>
      </el-descriptions-item>
 
      <!-- 4. 证件号码 -->
      <el-descriptions-item label="证件号码">
        {{ basicData.idcardno || basicData.idCardNo || "--" }}
      </el-descriptions-item>
 
      <!-- 5. 血型 -->
      <el-descriptions-item label="血型">
        <template v-if="basicData.bloodType || basicData.bloodtype">
          {{ basicData.bloodType || basicData.bloodtype }}
        </template>
        <template v-else>--</template>
      </el-descriptions-item>
 
      <!-- 6. 疾病诊断 -->
      <el-descriptions-item label="疾病诊断">
        {{ basicData.diagnosisname || basicData.diagnosis || "--" }}
      </el-descriptions-item>
 
      <!-- 7. 所在医疗机构 -->
      <el-descriptions-item label="所在医疗机构">
        {{ basicData.treatmenthospitalname || basicData.hospitalName || "--" }}
      </el-descriptions-item>
 
      <!-- 8. 协调员 -->
      <el-descriptions-item label="协调员">
        {{ basicData.coordinatorName || basicData.contactPerson || "--" }}
      </el-descriptions-item>
 
      <!-- 9. 上报时间 -->
      <el-descriptions-item label="上报时间">
        {{ formatDateTime(basicData.reportTime) || "--" }}
      </el-descriptions-item>
 
      <!-- 10. 案例状态 -->
      <el-descriptions-item label="案例进度">
        <!-- <el-tag :type="getReportStatusType(basicData.workflow)" size="small">
          {{ getReportStatusText(basicData.workflow) }}
        </el-tag> -->
        <div>
          <dict-tag
            :options="dict.type.sys_donornode"
            :value="basicData.workflow"
          />
        </div>
      </el-descriptions-item>
 
      <!-- 11. 转运状态(根据需求可选) -->
      <el-descriptions-item v-if="showTransport" label="转运状态">
        <el-tag
          :type="getTransportStatusType(basicData.isTransport)"
          size="small"
        >
          {{ getTransportStatusText(basicData.isTransport) }}
        </el-tag>
      </el-descriptions-item>
    </el-descriptions>
 
    <!-- 空状态 -->
    <div v-else class="empty-state">
      <el-empty description="暂无案例信息" :image-size="100"></el-empty>
    </div>
  </el-card>
</template>
 
<script>
import { getDonatebaseinfo } from "@/api/project/donatebaseinfo";
 
export default {
  name: "CaseBasicInfoSimple",
  props: {
    // 案例ID
    caseId: {
      type: [String, Number],
      required: true
    },
    // 列数
    column: {
      type: Number,
      default: 2
    },
    // 是否显示附件按钮
    showAttachment: {
      type: Boolean,
      default: false
    },
    // 是否使用字典
    useDict: {
      type: Boolean,
      default: false
    },
    // 是否显示转运状态
    showTransport: {
      type: Boolean,
      default: false
    },
    // 是否自动加载
    autoLoad: {
      type: Boolean,
      default: true
    },
    // 外部传入的数据(不调用接口)
    externalData: {
      type: Object,
      default: null
    },
    // 自定义字段列表
    fields: {
      type: Array,
      default: () => [
        "caseNo", // 案例编号
        "name", // 姓名
        "sexAge", // 性别/年龄
        "idcardno", // 证件号码
        "bloodType", // 血型
        "diagnosis", // 疾病诊断
        "hospital", // 医疗机构
        "coordinator", // 协调员
        "reportTime", // 上报时间
        "status" // 案例状态
      ]
    }
  },
  dicts: [
    "sys_user_sex",
    "sys_BloodType",
    "sys_DonationCategory",
    "sys_donornode"
  ],
  data() {
    return {
      loading: false,
      basicData: null,
      // 字典选项
      sexOptions: [],
      bloodTypeOptions: []
    };
  },
  computed: {
    hasAttachments() {
      return (
        this.basicData &&
        (this.basicData.assessannex || this.basicData.attachments)
      );
    }
  },
  watch: {
    caseId: {
      handler(newVal) {
        if (newVal && this.autoLoad && !this.externalData) {
          this.loadBasicInfo();
        }
      },
      immediate: true
    },
    externalData: {
      handler(newVal) {
        if (newVal) {
          this.basicData = this.mapExternalData(newVal);
        }
      },
      immediate: true
    }
  },
  created() {
    if (this.useDict) {
      this.loadDicts();
    }
 
    if (this.caseId && this.autoLoad && !this.externalData) {
      this.loadBasicInfo();
    } else if (this.externalData) {
      this.basicData = this.mapExternalData(this.externalData);
    }
  },
  methods: {
    // 加载字典
    async loadDicts() {
      try {
        // 加载性别字典
        this.sexOptions = [
          { dictLabel: "男", dictValue: "1" },
          { dictLabel: "女", dictValue: "2" }
        ];
 
        // 加载血型字典
        this.bloodTypeOptions = [
          { dictLabel: "A型", dictValue: "A" },
          { dictLabel: "B型", dictValue: "B" },
          { dictLabel: "O型", dictValue: "O" },
          { dictLabel: "AB型", dictValue: "AB" }
        ];
      } catch (error) {
        console.warn("加载字典失败:", error);
      }
    },
 
    // 加载基本信息
    async loadBasicInfo() {
      if (!this.caseId) return;
 
      this.loading = true;
      try {
        const response = await getDonatebaseinfo(this.caseId);
 
        if (response.code === 200) {
          this.basicData = this.mapApiData(response.data);
          console.log(this.basicData );
 
          this.loading = false;
        } else {
          this.$message.error(
            "获取案例信息失败:" + (response.msg || "未知错误")
          );
        }
      } catch (error) {
        console.error("加载案例基本信息失败:", error);
        this.$message.error("加载失败,请重试");
      } finally {
        this.loading = false;
      }
    },
 
    // 映射API数据
    mapApiData(apiData) {
      if (!apiData) return null;
 
      return {
        // 核心字段
        caseNo: apiData.caseNo,
        name: apiData.name || apiData.donorName,
        donorName: apiData.donorName,
        sex: apiData.sex,
        age: apiData.age,
        ageunit: apiData.ageunit,
        workflow: apiData.workflow,
        bloodType: apiData.bloodType || apiData.bloodtype,
        idcardno: apiData.idcardno || apiData.idCardNo,
        diagnosisname: apiData.diagnosisname || apiData.diagnosis,
        treatmenthospitalname:
          apiData.treatmenthospitalname || apiData.hospitalName,
        coordinatorName: apiData.coordinatorName || apiData.contactPerson,
        reportTime: apiData.reporttime,
        reportStatus: apiData.reportStatus,
        isTransport: apiData.isTransport,
 
        // 附件字段
        assessannex: apiData.assessannex,
        attachments: apiData.attachments
      };
    },
 
    // 映射外部数据
    mapExternalData(externalData) {
      return this.mapApiData(externalData);
    },
 
    // 格式化日期时间
    formatDateTime(dateTimeStr) {
      if (!dateTimeStr) return "";
      try {
        const date = new Date(dateTimeStr);
        return date
          .toLocaleString("zh-CN", {
            year: "numeric",
            month: "2-digit",
            day: "2-digit",
            hour: "2-digit",
            minute: "2-digit",
            second: "2-digit"
          })
          .replace(/\//g, "-");
      } catch (e) {
        return dateTimeStr;
      }
    },
 
    // 上报状态相关
    getReportStatusType(status) {
      const statusMap = {
        "1": "warning", // 已上报
        "2": "primary", // 已阅读
        "3": "success", // 已同意
        "4": "danger" // 已驳回
      };
      return statusMap[status] || "info";
    },
 
    getReportStatusText(status) {
      const statusMap = {
        "0": "潜在捐献",
        "2": "已阅读",
        "3": "已同意",
        "4": "已驳回"
      };
      return statusMap[status] || "未知";
    },
 
    // 转运状态相关
    getTransportStatusType(status) {
      const statusMap = {
        "1": "warning", // 无需转运
        "2": "primary", // 需转运
        "3": "success", // 转运中
        "4": "danger" // 转运完成
      };
      return statusMap[status] || "info";
    },
 
    getTransportStatusText(status) {
      const statusMap = {
        "1": "无需转运",
        "2": "需转运",
        "3": "转运中",
        "4": "转运完成"
      };
      return statusMap[status] || "未知";
    },
 
    // 查看附件
    handleAttachmentPreview() {
      this.$emit("attachment-preview", this.basicData);
    },
 
    // 刷新数据
    async refresh() {
      await this.loadBasicInfo();
    },
 
    // 获取数据
    getData() {
      return this.basicData;
    }
  }
};
</script>
 
<style scoped>
.basic-info-card {
  margin-bottom: 20px;
}
 
.clearfix::after {
  content: "";
  display: table;
  clear: both;
}
 
.empty-state {
  padding: 40px 0;
  text-align: center;
}
 
/* 响应式设计 */
@media (max-width: 768px) {
  .basic-info-card {
    margin: 10px;
  }
}
</style>