1
lkk
2025-06-10 c1cf70d01a5b11075170cfc6278a213833d1f799
src/components/jianqianwenzhen/index.vue
@@ -1,6 +1,6 @@
<template>
  <div>
    <span class="txt">问诊信息</span>
    <span class="txt"></span>
    <el-form
      ref="form"
      :model="form"
@@ -53,17 +53,53 @@
              </el-select>
            </el-form-item>
            <el-form-item label="工种" prop="gongZhong">
              <el-input v-model="form.gongZhong" placeholder="请输入工种" />
              <el-input
                v-model="form.gongZhong"
                placeholder="请输入工种"
                style="width: 710px"
              />
            </el-form-item>
            <el-form-item label="工龄" prop="gongLing">
            <el-form-item label="单位名称" prop="dwmc">
              <el-input
                v-model="form.dwmc"
                placeholder="请输入单位名称"
                style="width: 710px"
              />
            </el-form-item>
            <el-form-item label="用工单位" prop="ygdw">
              <el-input
                v-model="form.ygdw"
                placeholder="请输入用工单位"
                style="width: 710px"
              />
            </el-form-item>
            <el-form-item label="总工龄" prop="gongLing">
              <!-- <el-input v-model="form.cusName" placeholder="请输入工龄" style="width: 150px" />年 -->
              <el-input-number
                v-model="form.gongLing"
                label="请输入工龄"
                label="请输入总工龄"
              ></el-input-number
              >年
            </el-form-item>
            <el-form-item label="接触毒物" prop="contactPoison">
            <el-form-item
              label="接触有害物工龄"
              prop="jhgl"
              label-width="150px"
            >
              <!-- <el-input v-model="form.cusName" placeholder="请输入工龄" style="width: 150px" />年 -->
              <el-input-number
                v-model="form.jhgl"
                label="请输入接触有害物工龄"
              ></el-input-number
              >年
            </el-form-item>
            <el-form-item label="是否复诊" prop="">
              <el-radio-group v-model="radio">
                <el-radio :label="1">是</el-radio>
                <el-radio :label="2">否</el-radio>
              </el-radio-group>
            </el-form-item>
            <!--  <el-form-item label="接触毒物" prop="contactPoison">
              <el-input
                type="textarea"
                rows="4"
@@ -71,17 +107,78 @@
                placeholder="请输入接触毒物"
                style="width: 700px"
              />
            </el-form-item> -->
            <el-form-item label="体检危害因素" prop="tjwhys">
              <el-select
                filterable
                v-model="form.tjwhys"
                @change="handleTjwhysChange"
                placeholder="请选择体检危害因素"
                clearable
                style="width: 180px"
              >
                <el-option
                  v-for="dict in dict.type.tj_work_status"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                />
              </el-select>
            </el-form-item>
            <el-form-item label="其他" prop="medicalHistory">
            <el-form-item
              label="接触危害因素"
              prop="jcwhys"
              style="margin-left: 30px"
            >
              <el-select
                filterable
                v-model="form.jcwhys"
                placeholder="请选择接触危害因素"
                clearable
                style="width: 180px"
              >
                <el-option
                  v-for="dict in dict.type.tj_work_status"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                />
              </el-select>
            </el-form-item>
            <el-form-item label="既往病史" prop="mediHistoryq">
              <el-select
                v-model="form.mediHistoryq"
                multiple
                allow-create
                filterable
                placeholder="请选择或输入既往病史"
                style="width: 700px"
              >
                <!-- <el-option
                  v-for="item in rulesList"
                  :key="item.id"
                  :label="item.icdname"
                  :value="item.icdname"
                /> -->
                <el-option
                  v-for="item in rulesList"
                  :key="item.id"
                  :label="item.icdname"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
            <el-form-item label="既往病史" prop="medicalHistoryOther">
              <el-input
                type="textarea"
                rows="4"
                v-model="form.medicalHistory"
                placeholder="请输入"
                v-model="form.medicalHistoryOther"
                placeholder="请输入既往病史"
                style="width: 700px"
              />
            </el-form-item>
            <el-form-item label="症状" prop="zzsjj">
            <!--  <el-form-item label="症状" prop="zzsjj">
              <el-select
                multiple
                filterable
@@ -97,9 +194,100 @@
                  :value="dict.proName"
                />
              </el-select>
            </el-form-item>
            </el-form-item> -->
          </div>
        </el-collapse-item>
        <el-collapse-item title="职业症状" name="6">
          <div style="width: 900px">
            <el-row :gutter="10" class="mb8">
              <el-col :span="1.5">
                <el-button
                  type="primary"
                  icon="el-icon-plus"
                  size="mini"
                  @click="addzj()"
                  >添加
                </el-button>
              </el-col>
              <el-col :span="1.5">
                <el-button
                  type="danger"
                  icon="el-icon-delete"
                  size="mini"
                  @click="delezz()"
                  >删除
                </el-button>
              </el-col>
            </el-row>
            <el-table
              border
              :data="form.zhiyezzList"
              ref="zhiyezzList"
              style="width: 98%"
              @selection-change="handlezzChange"
            >
              <el-table-column type="selection" width="40" align="center" />
              <el-table-column
                label="序号"
                width="80"
                align="center"
                type="index"
                :index="indexMethod"
              />
              <el-table-column label="症状名称" prop="name" align="center">
                <template slot-scope="scope">
                  <el-select
                    :remote-method="getZzData"
                    v-model="scope.row.diseaseName"
                    remote
                    filterable
                    placeholder="请选择症状名称"
                    clearable
                    @change="zz"
                  >
                    <el-option
                      v-for="dict in zhenghuzangList"
                      :key="dict.id"
                      :label="dict.proName"
                      :value="dict.proName"
                    />
                  </el-select>
                </template>
              </el-table-column>
              <el-table-column
                label="症状日期"
                width="160"
                prop="diseaseData"
                align="center"
              >
                <template slot-scope="scope">
                  <el-date-picker
                    size="mini"
                    v-model="scope.row.diseaseData"
                    align="right"
                    type="date"
                    placeholder="选择日期"
                    :picker-options="pickerOptions"
                    style="width: 130px"
                    value-format="yyyy-MM-dd"
                  >
                  </el-date-picker>
                </template>
              </el-table-column>
              <el-table-column label="备注" prop="bz" align="center">
                <template slot-scope="scope">
                  <el-input
                    size="mini"
                    v-model="scope.row.bz"
                    placeholder="请输入备注"
                  />
                </template>
              </el-table-column>
            </el-table>
          </div>
        </el-collapse-item>
        <el-collapse-item title="月经史" name="2" v-show="sex">
          <div style="width: 900px">
            <el-form-item label="初潮(岁)" prop="chuchao">
@@ -120,7 +308,8 @@
                v-model="form.yjsfyc"
                placeholder="请选择是否异常"
                clearable
                style="width: 150px"
                style="width: 70px"
                @change="onYjsfycChange"
              >
                <el-option
                  v-for="dict in dict.type.sys_yes_no"
@@ -129,6 +318,9 @@
                  :value="dict.value"
                />
              </el-select>
            </el-form-item>
            <el-form-item label="月经异常描述" prop="ycms">
              <el-input v-model="form.ycms" style="width: 490px" />
            </el-form-item>
          </div>
        </el-collapse-item>
@@ -177,7 +369,7 @@
              <el-input
                v-model="form.xiyanyear"
                style="width: 70px"
              />年 </el-form-item
              />月 </el-form-item
            ><br />
            <el-form-item label="是否饮酒" prop="yinjiu">
              <!-- <el-input v-model="form.yinjiupinlv" placeholder="请输入饮酒频率" /> -->
@@ -200,7 +392,7 @@
              <el-input v-model="form.yinjiupinlv" style="width: 70px" />ml/天
            </el-form-item>
            <el-form-item label="饮酒时间" prop="yinjiuyear">
              <el-input v-model="form.yinjiuyear" style="width: 70px" />年
              <el-input v-model="form.yinjiuyear" style="width: 70px" />月
            </el-form-item>
            <el-form-item label="其他" prop="qita">
              <el-input
@@ -213,7 +405,7 @@
            </el-form-item>
          </div>
        </el-collapse-item>
        <el-collapse-item title="职业病" name="5">
        <el-collapse-item title="职业病史" name="5" v-show="zhiyebingshi">
          <div style="width: 900px">
            <el-row :gutter="10" class="mb8">
              <el-col :span="1.5">
@@ -243,26 +435,14 @@
              @selection-change="handlebingChange"
            >
              <el-table-column type="selection" width="40" align="center" />
              <!-- <el-table-column
            label="序号"
            align="center"
            prop="index"
            width="50"
          /> -->
              <el-table-column label="疾病类型" prop="type">
                <template slot-scope="scope">
                  <!-- <el-input
                    size="mini"
                    v-model="scope.row.diseaseName"
                    placeholder="请输入疾病名称"
                  /> -->
                  <el-select
                    v-model="scope.row.type"
                    remote
                    filterable
                    placeholder="请选择疾病类型"
                    clearable
                    @change="jibing"
                  >
                    <el-option
                      v-for="item in options"
@@ -273,13 +453,25 @@
                  </el-select>
                </template>
              </el-table-column>
              <el-table-column label="疾病id" prop="icdId" v-if="false">
                <el-select
                  :remote-method="getRemoteData"
                  v-model="icdId"
                  remote
                  filterable
                  placeholder="请选择病种名"
                  clearable
                >
                  <el-option
                    v-for="dict in rulesList"
                    :key="dict.id"
                    :label="dict.icdname"
                    :value="dict.id"
                  />
                </el-select>
              </el-table-column>
              <el-table-column label="疾病名称" prop="diseaseName">
                <template slot-scope="scope">
                  <!-- <el-input
                    size="mini"
                    v-model="scope.row.diseaseName"
                    placeholder="请输入疾病名称"
                  /> -->
                  <el-select
                    :remote-method="getRemoteData"
                    v-model="scope.row.diseaseName"
@@ -291,19 +483,15 @@
                  >
                    <el-option
                      v-for="dict in rulesList"
                      :key="dict.aid"
                      :label="dict.bingzhong"
                      :value="dict.bingzhong"
                      :key="dict.id"
                      :label="dict.icdname"
                      :value="dict.icdname"
                    />
                  </el-select>
                </template>
              </el-table-column>
              <el-table-column label="诊断日期" prop="diseaseData">
                <template slot-scope="scope">
                  <!-- <el-input
                v-model="scope.row.diseaseData"
                placeholder="请输入诊断日期"
              /> -->
                  <el-date-picker
                    size="mini"
                    v-model="scope.row.diseaseData"
@@ -328,7 +516,6 @@
              </el-table-column>
              <el-table-column label="是否痊愈" prop="isOk">
                <template slot-scope="scope">
                  <!-- <el-input v-model="scope.row.isOk" placeholder="请输入是否痊愈" /> -->
                  <el-select
                    filterable
                    size="mini"
@@ -357,8 +544,147 @@
            </el-table>
          </div>
        </el-collapse-item>
        <!-- <el-collapse-item title="既往病史" name="5" v-show="jiwangbingshi">
          <div style="width: 900px">
            <el-row :gutter="10" class="mb8">
              <el-col :span="1.5">
                <el-button
                  type="primary"
                  icon="el-icon-plus"
                  size="mini"
                  @click="addmembers()"
                  >添加
                </el-button>
              </el-col>
              <el-col :span="1.5">
                <el-button
                  type="danger"
                  icon="el-icon-delete"
                  size="mini"
                  @click="delemembers()"
                  >删除
                </el-button>
              </el-col>
            </el-row>
            <el-table
              border
              :data="form.tjAskHistorysList"
              ref="tjAskHistorys"
              style="width: 98%"
              @selection-change="handlebingChange"
            >
              <el-table-column type="selection" width="40" align="center" />
              <el-table-column label="疾病类型" prop="type">
                <template slot-scope="scope">
                  <el-select
                    v-model="scope.row.type"
                    remote
                    filterable
                    placeholder="请选择疾病类型"
                    clearable
                  >
                    <el-option
                      v-for="item in options"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    />
                  </el-select>
                </template>
              </el-table-column>
              <el-table-column label="疾病id" prop="icdId" v-if="false">
                <el-select
                  :remote-method="getRemoteData"
                  v-model="icdId"
                  remote
                  filterable
                  placeholder="请选择病种名"
                  clearable
                >
                  <el-option
                    v-for="dict in rulesList"
                    :key="dict.id"
                    :label="dict.icdname"
                    :value="dict.id"
                  />
                </el-select>
              </el-table-column>
              <el-table-column label="疾病名称" prop="diseaseName">
                <template slot-scope="scope">
                  <el-select
                    :remote-method="getRemoteData"
                    v-model="scope.row.diseaseName"
                    remote
                    filterable
                    placeholder="请选择病种名"
                    clearable
                    @change="jibing"
                  >
                    <el-option
                      v-for="dict in rulesList"
                      :key="dict.id"
                      :label="dict.icdname"
                      :value="dict.icdname"
                    />
                  </el-select>
                </template>
              </el-table-column>
              <el-table-column label="诊断日期" prop="diseaseData">
                <template slot-scope="scope">
                  <el-date-picker
                    size="mini"
                    v-model="scope.row.diseaseData"
                    align="right"
                    type="date"
                    placeholder="选择日期"
                    :picker-options="pickerOptions"
                    style="width: 130px"
                    value-format="yyyy-MM-dd"
                  >
                  </el-date-picker>
                </template>
              </el-table-column>
              <el-table-column label="诊断单位" prop="diseaseCompany">
                <template slot-scope="scope">
                  <el-input
                    size="mini"
                    v-model="scope.row.diseaseCompany"
                    placeholder="请输入诊断单位"
                  />
                </template>
              </el-table-column>
              <el-table-column label="是否痊愈" prop="isOk">
                <template slot-scope="scope">
                  <el-select
                    filterable
                    size="mini"
                    v-model="scope.row.isOk"
                    placeholder="请选择是否痊愈"
                    clearable
                  >
                    <el-option
                      v-for="dict in dict.type.sys_yes_no"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"
                    />
                  </el-select>
                </template>
              </el-table-column>
              <el-table-column label="备注" prop="remark">
                <template slot-scope="scope">
                  <el-input
                    size="mini"
                    v-model="scope.row.remark"
                    placeholder="请输入备注"
                  />
                </template>
              </el-table-column>
            </el-table>
          </div>
        </el-collapse-item> -->
        <el-collapse-item title="职业史" name="7" v-show="zhiye">
        <!--  <el-collapse-item title="职业史" name="7" v-show="zhiye">
          <div style="width: 900px">
            <el-row :gutter="10" class="mb8">
              <el-col :span="1.5">
@@ -387,12 +713,6 @@
              @selection-change="handlezhiyeChange"
            >
              <el-table-column type="selection" width="40" align="center" />
              <!-- <el-table-column
            label="序号"
            align="center"
            prop="index"
            width="50"
          /> -->
              <el-table-column label="开始时间" prop="beginTime">
                <template slot-scope="scope">
                  <el-date-picker
@@ -450,7 +770,6 @@
              </el-table-column>
              <el-table-column label="有害因素" prop="harmTypeLogs">
                <template slot-scope="scope">
                  <!-- <el-input v-model="scope.row.isOk" placeholder="请输入是否痊愈" /> -->
                  <el-select
                    filterable
                    size="mini"
@@ -479,7 +798,7 @@
              </el-table-column>
            </el-table>
          </div>
        </el-collapse-item>
        </el-collapse-item> -->
      </el-collapse>
    </el-form>
    <div slot="footer" class="dialog-footer">
@@ -495,19 +814,19 @@
</template>
<script>
import { updateHistory, getInfoById, getZhengZhuang } from "@/api/hosp/history";
import { listRules } from "@/api/hosp/rules";
import { listIcd } from "@/api/system/icd";
import {
  updateHistory,
  getInfoById,
  getZhengZhuang,
  removeAskHistorys,
} from "@/api/hosp/history";
import { list } from "@/api/hosp/rules";
export default {
  dicts: ["tj_smoking_pinlv", "sys_yes_no", "tj_work_status", "tj_work"],
  name: "jianqianwenzhen",
  props: {
    jianqianwenzhendata: {
      type: Array, //数组类型
      default: null,
    },
     jianqianwenzhendatas: {
      type: Array, //字符串类型
      default: null,
    },
  },
@@ -523,6 +842,9 @@
      }
    };
    return {
      zhiyebingshi: true,
      jiwangbingshi: true,
      diseaseNames: "",
      zhenghuzangList: [],
      options: [
        {
@@ -534,11 +856,12 @@
          label: "职业病",
        },
      ],
      icd: "",
      icdId: "",
      radio: 1,
      zhiye: true,
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        pageSize: 100,
      },
      dataList: [],
      pickerOptions: {
@@ -578,13 +901,37 @@
      multiple: true,
      // ${subTable.functionName}表格数据
      tjAskHistorysList: [],
      zhiyezzList: [],
      // 弹出层标题
      title: "",
      harmTypeList: [],
      // 表单参数
      form: {},
      form: {
        cusName: "",
        work: "",
        workStatus: "",
        gongZhong: "",
        dwmc: "",
        ygdw: "",
        gongLing: "",
        jhgl: "",
        yjsfyc: "", // 是否异常
        ycms: "", // 异常描述
        tjwhys: "",
        jcwhys: "",
        xiyan: "",
        xiyanpinlv: "",
        xiyanyear: "",
        yinjiu: "",
        yinjiupinlv: "",
        yinjiuyear: "",
        qita: "",
        medicalHistoryOther: "",
        mediHistoryq: [],
      },
      chageall: [],
      bingshiall: [],
      selectedZhiyezz: [],
      // 疾病字典表格数据
      icdList: [],
      rulesList: [],
@@ -597,26 +944,55 @@
            trigger: "blur",
          },
        ],
        ycms: [
          {
            validator: (rule, value, callback) => {
              if (this.form.yjsfyc === "Y" && !value) {
                callback(new Error("月经异常描述不能为空"));
              } else {
                callback();
              }
            },
            trigger: "blur",
          },
        ], // 初始不设置为必填
      },
    };
  },
  watch: {
    jianqianwenzhendata(val, newVla) {
      console.log(val, 555);
      if (val) {
        val.forEach((item) => {
          let tjNumber = item;
          getInfoById(tjNumber).then((response) => {
            this.form = response.data;
            // this.form = response.data;
            Object.assign(this.form, response.data);
            console.log(response.data.medicalHistoryIds, 8888);
            const medicalHistoryIds = response.data.medicalHistoryIds;
            const splitIds = medicalHistoryIds
              ? medicalHistoryIds.split(",")
              : [];
            this.form.mediHistoryq = splitIds;
            // this.form.medicalHistoryOther = response.data.medicalHistoryOther;
            if (this.form.cusSex === "1") {
              this.sex = true;
            } else {
              this.sex = false;
            }
            if (this.form.tjLx === "02") {
            /* if (this.form.tjLx === "02") {
              this.zhiye = true;
              this.zhiyebingshi = true;
              this.jiwangbingshi = false;
            } else {
              this.zhiye = false;
            }
              this.zhiyebingshi = false;
              this.jiwangbingshi = true;
            } */
            if (this.form.xiyan == null) {
              this.form.xiyan = "1";
            }
@@ -638,77 +1014,90 @@
            if (this.form.yinjiuyear == null) {
              this.form.yinjiuyear = "0";
            }
            // 设置默认值
            if (this.form.gongLing == null) {
              this.form.gongLing = 1; // 工龄默认值
            }
            this.form.tjAskHistorysList = response.data.tjAskHistorysList;
            this.form.zhiyezzList = response.data.zhiyezzList;
            // this.isdisabled= true
          });
        });
        this.loading = false;
      }
      // if (this.fList) {
      //     this.getList()
      // }
    },
    jianqianwenzhendatas(valse, newVla) {
      console.log(valse);
      if (valse) {
        console.log(valse);
          let tjNumber = valse.tjNum;
          console.log(tjNumber,111);
          getInfoById(tjNumber).then((response) => {
            this.form = response.data;
            if (this.form.cusSex === "1") {
              this.sex = true;
            } else {
              this.sex = false;
            }
            if (this.form.tjLx === "02") {
              this.zhiye = true;
            } else {
              this.zhiye = false;
            }
            if (this.form.xiyan == null) {
              this.form.xiyan = "1";
            }
            if (this.form.yjsfyc == null) {
              this.form.yjsfyc = "N";
            }
            if (this.form.xiyanpinlv == null) {
              this.form.xiyanpinlv = "0";
            }
            if (this.form.xiyanyear == null) {
              this.form.xiyanyear = "0";
            }
            if (this.form.yinjiu == null) {
              this.form.yinjiu = "1";
            }
            if (this.form.yinjiupinlv == null) {
              this.form.yinjiupinlv = "0";
            }
            if (this.form.yinjiuyear == null) {
              this.form.yinjiuyear = "0";
            }
            this.form.tjAskHistorysList = response.data.tjAskHistorysList;
            // this.isdisabled= true
          });
        this.loading = false;
      }
      // if (this.fList) {
      //     this.getList()
      // }
    },
  },
  created() {
    this.getList();
    this.getzhenzhuangList();
    // console.log(this.form.cusSex, 15555);
    // console.log("接收", this.jianqianwenzhendata);
    if (this.jianqianwenzhendata.length == 1) {
      this.jianqianwenzhendata.forEach((item) => {
        let tjNumber = item;
        getInfoById(tjNumber).then((response) => {
          // this.form = response.data;
          Object.assign(this.form, response.data);
          const splitIds = response.data.medicalHistoryIds.split(",");
          this.form.mediHistoryq = splitIds;
          this.form.medicalHistoryOther = response.data.medicalHistoryOther;
          if (this.form.cusSex === "1") {
            this.sex = true;
          } else {
            this.sex = false;
          }
          if (this.form.tjLx === "02") {
            this.zhiye = true;
            this.zhiyebingshi = true;
            this.jiwangbingshi = false;
          } else {
            this.zhiye = false;
            this.zhiyebingshi = false;
            this.jiwangbingshi = true;
          }
          if (this.form.xiyan == null) {
            this.form.xiyan = "1";
          }
          if (this.form.yjsfyc == null) {
            this.form.yjsfyc = "N";
          }
          if (this.form.xiyanpinlv == null) {
            this.form.xiyanpinlv = "0";
          }
          if (this.form.xiyanyear == null) {
            this.form.xiyanyear = "0";
          }
          if (this.form.yinjiu == null) {
            this.form.yinjiu = "1";
          }
          if (this.form.yinjiupinlv == null) {
            this.form.yinjiupinlv = "0";
          }
          if (this.form.yinjiuyear == null) {
            this.form.yinjiuyear = "0";
          }
          this.form.tjAskHistorysList = response.data.tjAskHistorysList;
          this.form.zhiyezzList = response.data.zhiyezzList;
          // this.isdisabled= true
        });
      });
      this.loading = false;
    }
  },
  methods: {
    /** 查询疾病字典列表 */
    getList() {
      listRules(this.queryParams).then((response) => {
      list(this.queryParams).then((response) => {
        this.rulesList = response.rows;
      });
    },
    handleTjwhysChange(val) {
      console.log("tjwhys changed:", val);
    },
    getzhenzhuangList() {
@@ -717,25 +1106,105 @@
      });
    },
    jibing(sel) {
      console.log(sel);
      this.rulesList.forEach((item) => {
        console.log(item);
        if (sel == item.bingzhong) {
          this.icd = item.aid;
    /*  addzj() {
      if (this.form.cusName) {
        if (!this.form.zhiyezzList) {
          this.form.zhiyezzList = [];
          this.form.zhiyezzList.push({
            id: parseInt(length),
            diseaseName: "",
            diseaseData: "",
            diseaseCompany: "",
            isOk: "",
            remark: "",
            icdId: "",
            type: "",
          });
        } else {
          this.form.zhiyezzList.push({
            id: parseInt(length),
            diseaseName: "",
            diseaseData: "",
            diseaseCompany: "",
            isOk: "",
            remark: "",
            icdId: "",
            type: "",
          });
        }
      });
    },
    // 搜索
    getRemoteData(query) {
      if (query) {
        let data = {
          bingzhong: query,
        };
        listRules(data).then((response) => {
          this.rulesList = response.rows;
        });
      } else {
        this.$message.warning("请先填写客户名");
      }
      this.$forceUpdate();
    }, */
    addzj() {
      if (!this.form.cusName) {
        this.$message.warning("请先填写客户名");
        return;
      }
      if (!this.form.zhiyezzList) {
        this.form.zhiyezzList = [];
      }
      this.form.zhiyezzList.push({
        id: Date.now(), // 用时间戳当本地唯一 id
        diseaseId: null, // 关键!明确标识“还没存进数据库”
        isLocal: true, // 可选,便于后续处理
        diseaseName: "",
        diseaseData: "",
        diseaseCompany: "",
        isOk: "",
        remark: "",
        icdId: "",
        type: "",
      });
      this.$forceUpdate(); // 强制刷新(如果需要)
    },
    async delezz() {
      if (!this.selectedZhiyezz?.length) {
        this.$message.warning("请先选择要删除的项");
        return;
      }
      // 拆分“本地数据”和“数据库数据”
      const localItems = this.selectedZhiyezz.filter((item) => !item.diseaseId);
      const dbItems = this.selectedZhiyezz.filter((item) => item.diseaseId);
      // 先备份一下当前列表,方便出错时恢复
      const backupList = [...this.form.zhiyezzList];
      // 删除本地新增项(不需要调接口)
      this.form.zhiyezzList = this.form.zhiyezzList.filter(
        (item) => !localItems.includes(item)
      );
      try {
        // 如果有数据库项,要调用接口删除
        if (dbItems.length) {
          const deletedIds = dbItems.map((item) => item.diseaseId);
          const res = await removeAskHistorys(deletedIds);
          if (res?.code !== 200) throw new Error("删除失败");
          // 接口成功,再从页面移除数据库数据
          this.form.zhiyezzList = this.form.zhiyezzList.filter(
            (item) => !dbItems.includes(item)
          );
          this.$message.success("删除成功");
        }
      } catch (err) {
        // 删除失败
        this.form.zhiyezzList = backupList;
        this.$message.error("删除失败");
        console.error(err);
      }
      // 清空选中
      this.selectedZhiyezz = [];
      this.$forceUpdate();
    },
    // 新增行
@@ -805,6 +1274,73 @@
      }
      this.$forceUpdate();
    },
    indexMethod(index) {
      return (
        (this.queryParams.pageNum - 1) * this.queryParams.pageSize + index + 1
      );
    },
    onYjsfycChange() {
      // 手动触发“月经异常描述”的校验
      this.$nextTick(() => {
        this.$refs.form.validateField("ycms");
      });
    },
    jibing(sel) {
      this.diseaseNames = sel;
      this.rulesList.forEach((item) => {
        if (sel == item.icdname) {
          this.icdId = item.id;
        }
      });
      this.form.tjAskHistorysList.forEach((item) => {
        if (item.diseaseName == sel) {
          item.icdId = this.icdId;
        }
      });
    },
    zz(sel) {
      this.name = sel;
      this.zhenghuzangList.forEach((item) => {
        if (sel == item.icdname) {
          this.icdId = item.id;
        }
      });
      this.form.zhiyezzList.forEach((item) => {
        if (item.name == sel) {
          item.icdId = this.icdId;
        }
      });
    },
    // 搜索
    getRemoteData(query) {
      if (query) {
        let data = {
          icdname: query,
          pageNum: 1,
          pageSize: 200,
        };
        list(data).then((response) => {
          this.rulesList = response.rows;
        });
      }
    },
    getZzData(query) {
      if (query) {
        let data = {
          icdname: query,
          pageNum: 1,
          pageSize: 200,
        };
        getZhengZhuang(data).then((response) => {
          this.zhenghuzangList = response.data;
        });
      }
    },
    delememberss() {
      let that = this;
      if (that.form.workLogs.length == that.chageall.length) {
@@ -819,34 +1355,128 @@
        });
      }
    },
    delemembers() {
      let that = this;
      if (that.form.tjAskHistorysList.length == that.bingshiall.length) {
        that.form.tjAskHistorysList = [];
      } else {
        that.bingshiall.forEach((item1, index1) => {
          that.form.tjAskHistorysList.forEach((item, index) => {
            if (item == item1) {
              that.form.tjAskHistorysList.splice(index, 1);
            }
          });
        });
      if (!this.bingshiall || this.bingshiall.length === 0) {
        this.$message.warning("请先选择要删除的项");
        return;
      }
      // 区分新增项和数据库项
      const localItems = this.bingshiall.filter((item) => !item.diseaseId); // 新增的
      const dbItems = this.bingshiall.filter((item) => item.diseaseId); // 数据库已有的
      // 先删除新增的(本地直接删)
      if (localItems.length > 0) {
        this.form.tjAskHistorysList = this.form.tjAskHistorysList.filter(
          (item) => !localItems.includes(item)
        );
      }
      if (dbItems.length === 0) {
        // 只有新增项,无需调用接口,直接清空选中,退出
        this.bingshiall = [];
        this.$forceUpdate();
        return;
      }
      // 调接口删除数据库项
      const historyId = dbItems.map((item) => item.diseaseId);
      removeAskHistorys(historyId)
        .then((res) => {
          this.$message.success("删除成功");
          // 接口成功后删除数据库项
          this.form.tjAskHistorysList = this.form.tjAskHistorysList.filter(
            (item) =>
              !dbItems.some((selected) => selected.diseaseId === item.diseaseId)
          );
          this.bingshiall = [];
          this.$forceUpdate();
        })
        .catch(() => {
          this.$message.warning("删除失败");
        });
    },
    /*  delemembers() {
      if (this.bingshiall && this.bingshiall.length > 0) {
        const historyId = this.bingshiall.map((item) => item.diseaseId);
        // 发请求
        removeAskHistorys(historyId).then((res) => {
          console.log(res, "删除接口响应");
          this.$message.success("删除成功");
          // 接口成功后再本地删除
          this.form.tjAskHistorysList = this.form.tjAskHistorysList.filter(
            (item) =>
              !this.bingshiall.some(
                (selected) => selected.diseaseId === item.diseaseId
              )
          );
          this.bingshiall = [];
          this.$forceUpdate();
        });
      } else {
        this.$message.warning("请先选择要删除的项");
      }
    }, */
    handlebingChange(selection) {
      this.bingshiall = [];
      this.bingshiall = selection;
    },
    handlezzChange(val) {
      // 更新选中的项
      this.selectedZhiyezz = val;
    },
    handlezhiyeChange(selection) {
      this.chageall = [];
      this.chageall = selection;
    },
    /** 提交按钮 */
    submitForm() {
      // this.form.tjNum = this.jianqianwenzhendata.tjNum;
      // this.form.tjAskHistorysList.icdId = this.icd;
      updateHistory(this.form).then((response) => {
        this.$modal.msgSuccess("修改成功");
      // console.log("提交前 form:", JSON.parse(JSON.stringify(this.form)));
      this.$refs.form.validate((valid) => {
        // console.log("校验后 form:", JSON.parse(JSON.stringify(this.form)));
        if (valid) {
          this.$emit("submitLoading", true);
          const selected = this.form.mediHistoryq || [];
          this.form.medicalHistory = selected.map((name) => {
            const match = this.rulesList.find((item) => item.id === name);
            // console.log(match);
            return {
              icdname: match ? match.icdname : "",
              id: match ? match.id : "",
            };
          });
          // console.log(this.form, 1236);
          updateHistory(this.form)
            .then((response) => {
              console.log("接口返回数据", response.data);
              this.$message.success("修改成功");
              // this.form = response.data; // 更新表单数据
              Object.assign(this.form, response.data);
              const splitIds = response.data.medicalHistoryIds.split(",");
              this.form.medicalHistoryOther = response.data.medicalHistoryOther;
              this.form.mediHistoryq = splitIds;
            })
            .catch((error) => {
              this.$message.error("修改失败");
            })
            .finally(() => {
              this.$emit("submitLoading", false);
            });
        } else {
          this.$message.error("请检查表单内容");
        }
      });
    },
  },