1
wwl
2025-04-03 599dc1a68be60373048aff95bd53ef8fdd138b4e
src/views/doctor/checkAll/index.vue
@@ -97,18 +97,12 @@
    <!-- 点击弹出框 -->
    <el-drawer custom-class="tanchu" :visible.sync="drawer" :before-close="handleClose" :with-header="false" size="100%"
      show-close="true">
      :show-close="true">
      <div class="top">
        <table style="
            width: 100%;
            margin: 10px 10px;
            border: 1px solid #dfe6ec;
            border-collapse: collapse;
          " cellspacing="4">
        <table style="width: 100%; margin: 10px 10px; border: 1px solid #dfe6ec; border-collapse: collapse;"
          cellspacing="4">
          <caption style="background-color: #f8f8f9; font-size: 18px">
            {{
              tableAll.cusName
            }}的体检资料
            {{ tableAll.cusName }}的体检资料
          </caption>
          <tr style="
              border: 1px solid #dfe6ec;
@@ -377,11 +371,13 @@
                              style="margin-bottom: 10px">
                              <div>
                                标题:
                                <el-input v-model="jianyi.bt" size="small" type="textarea" autosize></el-input>
                                <el-input v-model="jianyi.bt" size="small" type="textarea" autosize
                                  @blur="handleAdviceBlur(props.row, index1)"></el-input>
                              </div>
                              <div>
                                内容:
                                <el-input v-model="jianyi.nr" size="small" type="textarea" autosize></el-input>
                                <el-input v-model="jianyi.nr" size="small" type="textarea" autosize
                                  @blur="handleAdviceBlur(props.row, index1)"></el-input>
                              </div>
                            </div>
                          </div>
@@ -390,14 +386,15 @@
                          <div v-else>
                            <div>
                              标题:
                              <el-input v-model="emptyAdvice.bt" size="small" type="textarea" autosize></el-input>
                              <el-input v-model="emptyAdvice.bt" size="small" type="textarea" autosize
                                @blur="handleAdviceBlur(props.row, -1)"></el-input>
                            </div>
                            <div>
                              内容:
                              <el-input v-model="emptyAdvice.nr" size="small" type="textarea" autosize></el-input>
                              <el-input v-model="emptyAdvice.nr" size="small" type="textarea" autosize
                                @blur="handleAdviceBlur(props.row, -1)"></el-input>
                            </div>
                          </div>
                          <div style="margin-top: 10px;">
                            <el-button @click="shanchu(props.row)" type="danger" size="small">删除</el-button>
@@ -434,11 +431,13 @@
                              style="margin-bottom: 10px">
                              <div>
                                标题:
                                <el-input v-model="jianyi.bt" size="small" type="textarea" autosize></el-input>
                                <el-input v-model="jianyi.bt" size="small" type="textarea" autosize
                                  @blur="handleAdviceBlur(props.row, index1)"></el-input>
                              </div>
                              <div>
                                内容:
                                <el-input v-model="jianyi.nr" size="small" type="textarea" autosize></el-input>
                                <el-input v-model="jianyi.nr" size="small" type="textarea" autosize
                                  @blur="handleAdviceBlur(props.row, index1)"></el-input>
                              </div>
                            </div>
                          </div>
@@ -447,14 +446,15 @@
                          <div v-else>
                            <div>
                              标题:
                              <el-input v-model="emptyAdvice.bt" size="small" type="textarea" autosize></el-input>
                              <el-input v-model="emptyAdvice.bt" size="small" type="textarea" autosize
                                @blur="handleAdviceBlur(props.row, -1)"></el-input>
                            </div>
                            <div>
                              内容:
                              <el-input v-model="emptyAdvice.nr" size="small" type="textarea" autosize></el-input>
                              <el-input v-model="emptyAdvice.nr" size="small" type="textarea" autosize
                                @blur="handleAdviceBlur(props.row, -1)"></el-input>
                            </div>
                          </div>
                          <div style="margin-top: 10px;">
                            <el-button @click="shanchu(props.row)" type="danger" size="small">删除</el-button>
@@ -502,6 +502,7 @@
                </el-table>
              </div>
            </template>
            <el-button type="primary" @click="addnew" :disabled="isdisabled">新增</el-button>
          </div>
        </div>
      </div>
@@ -719,6 +720,81 @@
        <el-button @click="jianqians = false">取 消</el-button>
      </span>
    </el-dialog>
    <el-dialog title="新增异常结果" :visible.sync="addNewDialogVisible" width="900px" class="custom-dialog">
      <el-form :model="newItem" ref="newItemForm" label-width="100px" class="custom-form">
        <el-form-item label="项目分类" prop="parentName">
          <el-select v-model="newItem.parentName" placeholder="请选择项目分类" clearable filterable
            @change="handleCategoryChange">
            <el-option v-for="item in projectCategories" :key="item.proId" :label="item.proName"
              :value="item.proName" />
          </el-select>
        </el-form-item>
        <el-form-item label="检测项目" prop="jcxm">
          <el-input v-model="newItem.jcxm" placeholder="请输入检测项目或从分类选择" clearable></el-input>
        </el-form-item>
        <el-form-item label="检测结果" prop="jcjg">
          <el-input v-model="newItem.jcjg" placeholder="请输入检测结果" clearable></el-input>
        </el-form-item>
        <el-form-item label="参考范围" prop="ckfw">
          <el-input v-model="newItem.ckfw" placeholder="请输入参考范围" clearable></el-input>
        </el-form-item>
        <el-form-item label="单位" prop="dw">
          <el-input v-model="newItem.dw" placeholder="请输入单位" clearable></el-input>
        </el-form-item>
        <!-- 动态建议组 -->
        <div v-for="(advice, index) in newItem.map" :key="index" class="advice-group">
          <el-form-item label="建议标题" :prop="'map.' + index + '.bt'">
            <el-input v-model="advice.bt" placeholder="请输入建议标题" clearable @focus="tan"></el-input>
          </el-form-item>
          <el-form-item label="建议内容" :prop="'map.' + index + '.nr'">
            <el-input v-model="advice.nr" type="textarea" rows="3" placeholder="请输入建议内容" resize="none"
              @focus="tan"></el-input>
          </el-form-item>
          <el-button v-if="index > 0" type="danger" size="small" @click="removeAdvice(index)"
            style="margin-left: 100px; margin-bottom: 10px;">删除</el-button>
        </div>
        <el-form-item>
          <el-button type="primary" size="small" @click="addAdvice" style="margin-left: 100px;">添加建议</el-button>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="addNewDialogVisible = false">取消</el-button>
        <el-button type="primary" @click="submitNewItem">确定</el-button>
      </span>
    </el-dialog>
    <el-dialog title="快捷建议选择" :visible.sync="showjianyi" width="1000px" class="custom-dialog">
      <!-- 替换为输入框 -->
      <div style="margin-bottom: 15px;">
        <el-form :inline="true">
          <el-form-item label="建议名称">
            <el-input v-model="queryParams1.zyzd" placeholder="请输入建议名称进行筛选" clearable style="width: 200px"
              @input="filterAdvices(true)" onkeydown="if(event.keyCode === 32 || event.keyCode === 13) return false;" />
          </el-form-item>
        </el-form>
      </div>
      <el-table :data="advicerulesList" ref="adviceTable" border highlight-current-row
        @current-change="handleCurrentChangeAdvice" style="max-height: 400px; overflow-y: auto;">
        <el-table-column label="科室" prop="ks" width="100" align="center" />
        <el-table-column label="建议名称" prop="jymc" align="center" />
        <el-table-column label="建议内容" prop="jynr" align="center" />
      </el-table>
      <!-- 分页组件 -->
      <div class="pag">
        <div class="pag2">
          <pagination v-show="total1 > 0" :total="total1" :page.sync="queryParams1.pageNum"
            :limit.sync="queryParams1.pageSize" @pagination="filterAdvices(false)" />
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="showjianyi = false">取消</el-button>
        <el-button type="primary" @click="applySelectedAdvice" :disabled="!selectedAdvice">确定</el-button>
      </span>
    </el-dialog>
    <Packages ref="bbb" :baogao="baogao" />
    <Prescription ref="Pre" :preObj="preObj" />
    <proposal ref="proposal" :cusobj="cusobj" @event1="eventchange($event)" />
@@ -731,6 +807,7 @@
<script>
import _ from 'lodash';
import jianqianwenzhen from "@/components/jianqianwenzhen";
import Packages from "@/components/Packages";
import Prescription from "@/components/Prescription";
@@ -749,6 +826,7 @@
  getModified,
  isPdfOrJimu,
  addOrder,
  addOrder1
} from "@/api/doctor/checkAll";
import { getInfoById } from "@/api/hosp/history";
import { getInfo } from "@/api/login";
@@ -764,7 +842,9 @@
import { getconfigKey } from "@/api/login";
import moment from "moment";
import { get } from "sortablejs";
import {
  listAdvicerules,
} from "@/api/hosp/advicerules";
export default {
  components: {
    ViewPdf,
@@ -789,6 +869,23 @@
  name: "checkAll",
  data() {
    return {
      selectedAdvice: null,
      activeAdviceIndex: 0,
      advicerulesList: [],
      showjianyi: false,
      addNewDialogVisible: false,
      newItem: {
        parentName: '',   // 项目分类,对应模板中的 parentName
        jcxm: '',         // 检测项目,对应模板中的 jcxm
        jcjg: '',         // 检测结果,对应模板中的 jcjg
        ckfw: '',         // 参考范围,对应模板中的 ckfw
        dw: '',           // 单位,对应模板中的 dw
        map: [{           // 建议列表,对应模板中的动态建议组 map
          bt: '',         // 建议标题,对应模板中的 map[index].bt
          nr: ''          // 建议内容,对应模板中的 map[index].nr
        }]
      },
      projectCategories: [],
      // 更新总检建议
      emptyAdvice: {
        bt: "",
@@ -920,6 +1017,12 @@
        tjCategory: undefined,
        payType: undefined,
      },
      total1: 0,
      queryParams1: {
        pageNum: 1,
        pageSize: 10,
        zyzd: ''
      },
      status1: 0, // 0展示异常1展示项目情况
      viewportHeight: 0,
      expends: [],
@@ -940,38 +1043,245 @@
    });
  },
  methods: {
    handleAdviceBlur(row, index) {
      // 构造 advices 数据
      let advicesToSubmit = [];
      if (index === -1) {
        // advices 为空,使用 emptyAdvice 的值
        if (this.emptyAdvice.bt || this.emptyAdvice.nr) {
          advicesToSubmit = [{ bt: this.emptyAdvice.bt || '', nr: this.emptyAdvice.nr || '' }];
          // 将 emptyAdvice 的值赋值给 row.advices
          this.$set(row, 'advices', advicesToSubmit);
        }
      } else {
        // advices 不为空,直接使用 row.advices
        advicesToSubmit = row.advices;
      }
      // 如果 advicesToSubmit 为空或没有有效数据,不提交
      if (!advicesToSubmit || advicesToSubmit.length === 0) {
        return;
      }
      const parentItem = this.yichangList.find(item =>
        item.sone.some(soneItem => soneItem.orderDetailId === row.orderDetailId)
      );
      if (!parentItem) {
        this.$message.error('未找到对应的父级项目');
        return;
      }
      const data = {
        tjh: this.tableAll.tjNumber, // 体检号
        parentName: parentItem.proName, // 父级项目名称
        jcxm: row.proName, // 检测项目
        jcjg: row.proResult, // 检测结果
        ckfw: row.stanId, // 参考范围
        dw: row.proAdvice, // 单位
        map: advicesToSubmit, // 建议列表
        jyjc: parentItem.jyjc, // 检查类型(0 或 1)
        id: row.orderDetailId, // 当前项的 orderDetailId
      };
      addOrder1(data).then((res) => {
        if (res.code === 200) {
        } else {
          this.$message.error('建议更新失败:' + (res.msg || '未知错误'));
        }
      }).catch((error) => {
        console.error('建议更新失败:', error);
        this.$message.error('建议更新失败:' + error.message);
      });
    },
    handleCurrentChangeAdvice(currentRow) {
      this.selectedAdvice = currentRow; // 存储选中的建议项
    },
    applySelectedAdvice() {
      if (this.selectedAdvice) {
        this.$set(this.newItem.map, this.activeAdviceIndex, {
          bt: this.selectedAdvice.jymc, // 建议名称赋值给标题
          nr: this.selectedAdvice.jynr  // 建议内容赋值给内容
        });
        this.showjianyi = false; // 关闭弹窗
        this.selectedAdvice = null; // 清空选中项
      } else {
        this.$message.warning('请先选择一条建议');
      }
    },
    handleSelectionChange(selection) {
      console.log(selection);
    },
    tan(event) {
      // 获取当前建议组的索引
      this.activeAdviceIndex = event.target.closest('.advice-group')
        ? Array.from(event.target.closest('.el-form').querySelectorAll('.advice-group'))
          .indexOf(event.target.closest('.advice-group'))
        : 0;
      // 重置分页参数和筛选条件
      this.queryParams1.pageNum = 1;
      this.queryParams1.pageSize = 10;
      this.queryParams1.zyzd = ''; // 清空建议名称输入框
      // 移除科室筛选条件
      delete this.queryParams1.ks; // 确保不携带 ks 参数
      // 加载所有快捷建议列表
      this.filterAdvices();
      this.showjianyi = true;
    },
    // 下拉框筛选快捷建议(包含分页逻辑)
    filterAdvices: _.debounce(function (resetPage = false) {
      if (resetPage) {
        this.queryParams1.pageNum = 1;
      }
      listAdvicerules(this.queryParams1).then((response) => {
        this.advicerulesList = response.rows;
        this.total1 = response.total;
      }).catch((error) => {
        console.error('筛选快捷建议失败:', error);
        this.$message.error('筛选快捷建议失败');
      });
    }, 300),
    submitNewItem() {
      const data = {
        tjh: this.tableAll.tjNumber, // 体检号,从 tableAll 中获取
        parentName: this.newItem.parentName,
        jcxm: this.newItem.jcxm,
        jcjg: this.newItem.jcjg,
        ckfw: this.newItem.ckfw,
        dw: this.newItem.dw,
        map: this.newItem.map,
        jyjc: this.newItem.ckfw ? "0" : "1"
      };
      addOrder1(data).then((res) => {
        console.log(res);
        if (res.code === 200) {
          this.$message.success('新增异常结果成功');
          this.addNewDialogVisible = false;
          this.yichangjieguo();
        } else {
          this.$message.error('新增失败');
        }
      }).catch((error) => {
        console.error('新增异常结果失败:', error);
        this.$message.error('新增异常结果失败');
      });
    },
    addnew() {
      this.newItem = {
        parentName: '',
        jcxm: '',
        jcjg: '',
        ckfw: '',
        dw: '',
        map: [{ bt: '', nr: '' }]
      };
      this.addNewDialogVisible = true;
      cSWebGetPro(this.tjNumber).then((res) => {
        console.log(res);
        if (res.data && Array.isArray(res.data)) {
          this.projectCategories = res.data;
        } else {
          this.$message.warning('未获取到项目分类数据');
          this.projectCategories = [];
        }
      }).catch((error) => {
        console.error('获取项目分类失败:', error);
        this.$message.error('获取项目分类失败');
        this.projectCategories = [];
      });
    },
    handleCategoryChange(value) {
      if (value) {
        this.newItem.jcxm = value; // 将选择的项目分类赋值给检测项目
      }
    },
    // 添加新的建议组
    addAdvice() {
      this.newItem.map.push({ bt: '', nr: '' });
    },
    removeAdvice(index) {
      if (this.newItem.map.length > 1) {
        this.newItem.map.splice(index, 1);
      } else {
        this.$message.warning('至少保留一组建议');
      }
    },
    shanchu(row) {
      // 禁用删除按钮,防止重复点击
      this.isdisabled = true;
      // 调用后端接口删除数据
      shanchu({
        id: row.orderDetailId,
      }).then((res) => {
        console.log(res);
        // 找到要删除项所在的父级数组
        const parentItem = this.yichangList.find(item =>
          item.sone.some(soneItem => soneItem.proId === row.proId)
        );
        if (res.code === 200) {  // 后端删除成功
          // 找到要删除项所在的父级数组
          const parentItem = this.yichangList.find(item =>
            item.sone.some(soneItem => soneItem.orderDetailId === row.orderDetailId)
          );
        if (parentItem) {
          // 从父级的 sone 数组中删除该项
          const index = parentItem.sone.findIndex(item => item.proId === row.proId);
          if (index > -1) {
            parentItem.sone.splice(index, 1);
          if (parentItem) {
            // 从父级的 sone 数组中删除该项
            const index = parentItem.sone.findIndex(item => item.orderDetailId === row.orderDetailId);
            if (index > -1) {
              parentItem.sone.splice(index, 1);
            // 如果删除后 sone 数组为空,则删除整个父级项
            if (parentItem.sone.length === 0) {
              const parentIndex = this.yichangList.indexOf(parentItem);
              if (parentIndex > -1) {
                this.yichangList.splice(parentIndex, 1);
              // 如果删除后 sone 数组为空,则删除整个父级项
              if (parentItem.sone.length === 0) {
                const parentIndex = this.yichangList.indexOf(parentItem);
                if (parentIndex > -1) {
                  this.yichangList.splice(parentIndex, 1);
                }
              }
              // 更新 expends 数组,确保展开状态正确
              this.getExpends();
              // 强制刷新表格
              this.$forceUpdate();
              this.$message.success('删除成功');
              // 可选:调用 yichangjieguo 刷新数据(如果需要与后端同步)
              // this.yichangjieguo();
            } else {
              this.$message.error('未找到要删除的子项');
            }
            // 更新 expends 数组
            this.getExpends();
            this.$message.success('删除成功');
          } else {
            this.$message.error('未找到要删除的父项');
          }
        } else {
          this.$message.error('后端删除失败:' + (res.msg || '未知错误'));
        }
      })
      }).catch((error) => {
        console.error('删除失败:', error);
        this.$message.error('删除操作失败:' + error.message);
      }).finally(() => {
        // 恢复删除按钮状态
        this.isdisabled = false;
      });
    },
    // 确保 getExpends 方法存在,用于更新展开状态
    getExpends() {
      this.expends = this.yichangList.flatMap(item =>
        item.sone.map(soneItem => soneItem.orderDetailId)
      );
      console.log('Updated expends:', this.expends);
    },
    getConfigKey() {
      getconfigKey("sfkqtwbg").then((res) => {
@@ -985,15 +1295,10 @@
      });
    },
    //设置table中的扩展项,展开的id,此处我需要全部展开
    getExpends() {
      // 通过flatMap将每个sone数组中的ID提取出来,并返回一个扁平化的ID数组
      this.expends = this.yichangList.flatMap((item) =>
        item.sone.map((subItem) => subItem.proId)
      );
    },
    getRowKeys(row) {
      return row.proId;
      return row.orderDetailId;
    },
    // 项目情况
    xiangmuqingkuang() {
@@ -1017,8 +1322,7 @@
      }).then((res) => {
        this.yichangList = res.data;
        console.log(this.yichangList, 3232);
        this.getExpends();
        this.yichangList.forEach((item) => {
          item.sone.forEach((soneItem) => {
@@ -1145,7 +1449,7 @@
                loading.close();
              }, 3000);
              this.$message({
                message: "报告正在生成,请两分钟后预览!",
                message: "请撤回重新生成报告",
                type: "error"
              });
            } else {
@@ -1308,8 +1612,14 @@
      if (this.textarea1 == null) {
        this.textarea1 = "";
      }
      console.log(data)
      data.forEach((item) => {
        this.textarea1 += item.advice;
        if(item.advice){
          this.textarea1 += item.advice;
        }else{
          this.textarea1 += item.jynr;
        }
      });
    },
    proposalChange() {
@@ -2155,10 +2465,40 @@
  width: 100%;
  display: flex;
  justify-content: center;
  /* 确保分页器整体居中 */
  align-items: center;
  /* 垂直居中 */
  margin-top: 15px;
  /* 与表格的间距 */
}
.pag2 {
  width: auto;
  /* 移除固定宽度,让分页器根据内容自适应 */
  min-width: 750px;
  /* 设置最小宽度,确保分页器不会太窄 */
  text-align: center;
  /* 确保分页器内部元素居中 */
}
@media (max-width: 750px) {
  .pag2 {
    min-width: 300px;
    /* 移动端最小宽度 */
    overflow-x: auto;
    /* 允许横向滚动 */
    padding: 10px;
    /* 移动端内边距 */
  }
}
.pag1 {
  width: 30%;
  width: auto;
  /* 移除固定宽度,让分页器根据内容自适应 */
  min-width: 300px;
  /* 设置最小宽度,确保分页器不会太窄 */
  text-align: center;
  /* 确保分页器内部元素居中 */
}
.dialog-footers {
@@ -2282,4 +2622,66 @@
::v-deep .el-drawer {
  padding: 0 0 50px;
}
</style>
.custom-dialog {
  ::v-deep .el-dialog__header {
    padding: 15px 20px;
    background-color: #f5f7fa;
    border-bottom: 1px solid #e8ecef;
  }
  ::v-deep .el-dialog__title {
    font-size: 18px;
    color: #303133;
    font-weight: 600;
  }
  ::v-deep .el-dialog__body {
    padding: 20px; // 增加内边距
    background-color: #fff;
  }
  ::v-deep .el-dialog__footer {
    padding: 10px 20px;
    border-top: 1px solid #e8ecef;
    text-align: right;
  }
  .custom-form {
    .advice-group {
      border: 1px solid #e8ecef;
      border-radius: 4px;
      padding: 10px;
      margin-bottom: 15px;
      background-color: #f9fbfc;
      .el-form-item {
        margin-bottom: 15px;
      }
      .el-button {
        margin-top: 5px;
      }
    }
  }
}
.dialog-pager {
  display: flex;
  justify-content: center;
  /* 水平居中 */
  align-items: center;
  /* 垂直居中 */
  margin-top: 15px;
  /* 与表格的间距 */
  padding: 0 20px;
  /* 增加内边距,避免过于贴边 */
  box-sizing: border-box;
  /* 确保内边距不影响宽度 */
}
// .dialog-pager-inner {
//   width: auto; /* 自适应宽度 */
//   min-width: 300px; /* 设置最小宽度,确保分页器不会太窄 */
//   text-align: center; /* 确保分页器内部元素居中 */
// }</style>