WXL
4 天以前 dc082351978a1e9f75d7a1471a0ca7ebeac552a5
src/views/business/decide/index.vue
@@ -8,27 +8,27 @@
        :inline="true"
        label-width="100px"
      >
        <el-form-item label="住院号" prop="hospitalNo">
        <el-form-item label="住院号" prop="inpatientno">
          <el-input
            v-model="queryParams.hospitalNo"
            v-model="queryParams.inpatientno"
            placeholder="请输入住院号"
            clearable
            style="width: 200px"
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="捐献者姓名" prop="donorName">
        <el-form-item label="捐献者姓名" prop="name">
          <el-input
            v-model="queryParams.donorName"
            v-model="queryParams.name"
            placeholder="请输入捐献者姓名"
            clearable
            style="width: 200px"
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="死亡原因" prop="deathReason">
        <el-form-item label="死亡原因" prop="deathreason">
          <el-select
            v-model="queryParams.deathReason"
            v-model="queryParams.deathreason"
            placeholder="请选择死亡原因"
            clearable
            style="width: 200px"
@@ -62,23 +62,25 @@
    <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="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="danger"
            icon="el-icon-delete"
            :disabled="multiple"
            @click="handleDelete"
            >删除</el-button
          >
          > -->
          <el-button
            type="warning"
            icon="el-icon-download"
@@ -100,98 +102,190 @@
        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="hospitalNo"
          prop="inpatientno"
          width="120"
          fixed="left"
        />
        <el-table-column
          label="捐献者姓名"
          label="姓名"
          align="center"
          prop="donorName"
          width="120"
          prop="name"
          width="100"
          fixed="left"
        />
        <el-table-column label="性别" align="center" prop="gender" width="80">
        <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="parseInt(scope.row.gender)"
              :value="scope.row.sex"
            />
          </template>
        </el-table-column>
        <el-table-column label="年龄" align="center" prop="age" width="80" />
        <el-table-column
          label="年龄"
          align="center"
          prop="age"
          width="80"
          fixed="left"
        />
        <el-table-column
          label="疾病诊断"
          align="center"
          prop="diagnosis"
          min-width="180"
          prop="diagnosisname"
          min-width="200"
          show-overflow-tooltip
        />
        <!-- 状态信息 -->
        <el-table-column
          label="死亡原因"
          label="判定状态"
          align="center"
          prop="deathReason"
          width="120"
        >
          <template slot-scope="scope">
            <el-tag :type="reasonFilter(scope.row.deathReason)">
              {{ reasonTextFilter(scope.row.deathReason) }}
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column
          label="死亡时间"
          align="center"
          prop="deathTime"
          width="160"
        >
          <template slot-scope="scope">
            <span>{{
              scope.row.deathTime
                ? parseTime(scope.row.deathTime, "{y}-{m}-{d} {h}:{i}")
                : "-"
            }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="判定医生"
          align="center"
          prop="judgmentDoctor"
          width="120"
        />
          <el-table-column
          label="判定医生二"
          align="center"
          prop="judgmentDoctortwo"
          width="120"
        />
        <el-table-column
          label="登记时间"
          align="center"
          prop="registrationTime"
          width="160"
        >
          <template slot-scope="scope">
            <span>{{
              scope.row.registrationTime
                ? parseTime(scope.row.registrationTime, "{y}-{m}-{d} {h}:{i}")
                : "-"
            }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="登记人"
          align="center"
          prop="registrant"
          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="danger"
              >
                {{ 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">
                {{ 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="210"
          width="200"
          fixed="right"
          class-name="small-padding fixed-width"
        >
          <template slot-scope="scope">
@@ -202,21 +296,23 @@
              @click="handleView(scope.row)"
              >详情</el-button
            >
            <el-button
            <el-dropdown
              size="mini"
              type="text"
              icon="el-icon-edit"
              @click="handleUpdate(scope.row)"
              >修改</el-button
              @command="command => handleUpdateDropdown(scope.row, command)"
            >
            <el-button
              size="mini"
              type="text"
              icon="el-icon-delete"
              style="color: #F56C6C"
              @click="handleDelete(scope.row)"
              >删除</el-button
            >
              <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>
@@ -234,13 +330,17 @@
</template>
<script>
import { listDeathJudgment, delDeathJudgment, exportDeathJudgment } from "./mockDeathJudgmentApi";
import {
  queryDathInfoBaseInfo,
  deathinfoedit,
  deathinfoInfo
} from "@/api/businessApi";
import Pagination from "@/components/Pagination";
export default {
  name: "DeathJudgmentList",
  components: { Pagination },
  dicts: ["sys_user_sex"],
  dicts: ["sys_user_sex", "decide_type"],
  data() {
    return {
      // 遮罩层
@@ -259,10 +359,32 @@
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        hospitalNo: undefined,
        donorName: undefined,
        deathReason: undefined,
        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" }
      }
    };
  },
@@ -270,99 +392,242 @@
    this.getList();
  },
  methods: {
    // 死亡原因过滤器
    reasonFilter(reason) {
      const reasonMap = {
        "brain_death": "primary", // 脑死亡
        "heart_death": "danger", // 心死亡
        "other": "info" // 其他
      };
      return reasonMap[reason] || "info";
    // 获取死亡原因标签类型
    getDeathReasonTagType(reason) {
      return this.deathReasonMap[reason]?.type || "info";
    },
    reasonTextFilter(reason) {
      const reasonMap = {
        "brain_death": "脑死亡",
        "heart_death": "心死亡",
        "other": "其他"
      };
      return reasonMap[reason] || "未知";
    // 获取死亡原因文本
    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}");
    },
    // 查询死亡判定列表
    getList() {
    async getList() {
      this.loading = true;
      listDeathJudgment(this.queryParams)
        .then(response => {
          if (response.code === 200) {
            this.deathJudgmentList = response.data.rows;
            this.total = response.data.total;
          } else {
            this.$message.error("获取数据失败");
          }
          this.loading = false;
        })
        .catch(error => {
          console.error("获取死亡判定列表失败:", error);
          this.loading = false;
          this.$message.error("获取数据失败");
        });
      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.handleQuery();
      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 }
        query: {
          id: row.id,
          infoid: row.infoid,
          type: this.getDeathType(row) // 传递死亡类型
        }
      });
    },
    // 新增按钮操作
    handleCreate() {
      this.$router.push("/case/DecideInfo");
    // 获取死亡类型
    getDeathType(row) {
      if (row.deathreason && row.deathreason.includes("brain")) {
        return "brain";
      } else if (row.heartdeathreason) {
        return "heart";
      }
      return "brain"; // 默认脑死亡
    },
    // 修改按钮操作
    handleUpdate(row) {
      const id = row.id || this.ids[0];
    // 新增脑死亡判定
    handleCreate() {
      this.$router.push({
        path: "/case/DecideInfo",
        query: { id: id }
        query: { type: "brain" }
      });
    },
    // 删除按钮操作
    handleDelete(row) {
      const ids = row.id ? [row.id] : this.ids;
      this.$confirm("是否确认删除选中的数据项?", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          return delDeathJudgment(ids);
        })
        .then(response => {
          if (response.code === 200) {
            this.$message.success("删除成功");
            this.getList();
          }
        })
        .catch(() => {});
    // 新增心死亡判定
    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() {
      const queryParams = this.queryParams;
      this.$confirm("是否确认导出所有死亡判定数据?", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
@@ -370,12 +635,13 @@
      })
        .then(() => {
          this.loading = true;
          return exportDeathJudgment(queryParams);
          // 这里调用导出接口
          return this.exportData();
        })
        .then(response => {
          if (response.code === 200) {
            this.$message.success("导出成功");
            // 实际项目中这里处理文件下载
            this.downloadExportFile(response);
          }
          this.loading = false;
        })
@@ -383,7 +649,35 @@
          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}";
@@ -438,6 +732,73 @@
}
.fixed-width .el-button {
  margin: 0 5px;
  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>