WXL
18 小时以前 888f941ae16c850c0f1a844ec9436058840920bd
pages/case/CaseDetails.vue
@@ -16,51 +16,41 @@
          </view>
          <view class="form-grid">
            <!-- 修改后:治疗医院输入框 -->
            <view class="form-item">
              <text class="item-label">案例编号</text>
              <text class="item-label required">治疗医院</text>
              <u-input
                v-model="form.caseNo"
                placeholder="上报后自动生成"
                disabled
                :disabledColor="disabledColor"
                border="none"
                v-model="form.treatmenthospitalname"
                placeholder="请输入治疗医院名称"
                maxlength="100"
                class="custom-input"
              />
            </view>
            <!-- 改造后的医疗机构选择 -->
            <!-- 新增:上报医院 -->
            <view class="form-item">
              <text class="item-label">医疗机构</text>
              <picker
                mode="selector"
                :range="hospitalLabels"
                :value="hospitalIndex"
                @change="onHospitalChange"
              >
                <view class="picker">
                  <text>{{ currentHospital }}</text>
                  <text class="icon-arrow">›</text>
                </view>
              </picker>
              <text class="item-label">上报医院</text>
              <u-input
                v-model="form.toHospital"
                placeholder="请输入上报医院"
                maxlength="100"
                class="custom-input"
              />
            </view>
            <!-- 改造后的科室选择 -->
            <!-- 新增:部门名称 -->
            <view class="form-item">
              <text class="item-label">科室</text>
              <picker
                mode="selector"
                :range="deptLabels"
                :value="deptIndex"
                @change="onDeptChange"
              >
                <view class="picker">
                  <text>{{ currentDept }}</text>
                  <text class="icon-arrow">›</text>
                </view>
              </picker>
              <text class="item-label">部门名称</text>
              <u-input
                v-model="form.deptName"
                placeholder="请输入部门名称"
                maxlength="50"
                class="custom-input"
              />
            </view>
            <view class="form-item">
              <text class="item-label required">姓名</text>
              <text class="item-label required">患者姓名</text>
              <u-input
                type="text"
                v-model="form.name"
@@ -201,7 +191,7 @@
            <view class="form-item">
              <text class="item-label">GCS评分</text>
              <u-input
                v-model="form.gscScore"
                v-model="form.gcsScore"
                placeholder="请输入GCS评分"
                border="none"
              />
@@ -217,7 +207,23 @@
                :customStyle="textareaStyle(!form.diagnosisname)"
              />
            </view>
            <view class="form-item">
              <text class="item-label">是否需要转运</text>
              <view class="radio-group horizontal">
                <view
                  v-for="bloodType in isTransportOptions"
                  :key="bloodType.value"
                  class="radio-item"
                  @click="form.isTransport = bloodType.value"
                >
                  <view
                    class="radio-dot"
                    :class="{ active: form.isTransport === bloodType.value }"
                  ></view>
                  <text class="radio-label">{{ bloodType.label }}</text>
                </view>
              </view>
            </view>
            <view class="form-item">
              <text class="item-label">血型</text>
              <view class="radio-group horizontal">
@@ -225,11 +231,11 @@
                  v-for="bloodType in bloodTypeOptions"
                  :key="bloodType.value"
                  class="radio-item"
                  @click="form.bloodtype = bloodType.value"
                  @click="form.bloodType = bloodType.value"
                >
                  <view
                    class="radio-dot"
                    :class="{ active: form.bloodtype === bloodType.value }"
                    :class="{ active: form.bloodType === bloodType.value }"
                  ></view>
                  <text class="radio-label">{{ bloodType.label }}</text>
                </view>
@@ -246,7 +252,7 @@
                >
                  <view
                    class="radio-dot"
                    :class="{ active: form.bloodtype === bloodType.value }"
                    :class="{ active: form.infectious == bloodType.value }"
                  ></view>
                  <text class="radio-label">{{ bloodType.label }}</text>
                </view>
@@ -256,7 +262,7 @@
              <text class="item-label">其他</text>
              <u-input
                v-model="form.infectiousOther"
                placeholder="请输入住院号"
                placeholder="请输入其他传染病"
                border="none"
              />
            </view>
@@ -268,11 +274,11 @@
                  v-for="rh in rhOptions"
                  :key="rh.value"
                  class="radio-item"
                  @click="form.rhyin = rh.value"
                  @click="form.rhYin = rh.value"
                >
                  <view
                    class="radio-dot"
                    :class="{ active: form.rhyin === rh.value }"
                    :class="{ active: form.rhYin === rh.value }"
                  ></view>
                  <text class="radio-label">{{ rh.label }}</text>
                </view>
@@ -452,8 +458,8 @@
  ageunit: "", // 新增:年龄单位
  inpatientno: "",
  diagnosisname: "",
  bloodtype: "",
  rhyin: "",
  bloodType: "",
  rhYin: "",
  infoname: "",
  infophone: "",
  reportername: userStore.name || "",
@@ -493,6 +499,8 @@
// 选择器状态
const attachments = ref([]);
const infectiousDiseaselist = ref([]);
const nationLabel = ref([]);
const isReadonly = ref(false);
const id = ref(null);
const selectShow = ref(false);
@@ -543,15 +551,18 @@
]);
const bloodTypeOptions = ref([
  { label: "A型", value: "A" },
  { label: "B型", value: "B" },
  { label: "O型", value: "O" },
  { label: "AB型", value: "AB" },
  { label: "A型", value: "A型" },
  { label: "B型", value: "B型" },
  { label: "O型", value: "O型" },
  { label: "AB型", value: "AB型" },
]);
const isTransportOptions = ref([
  { label: "需要", value: "2" },
  { label: "不需要", value: "1" },
]);
const rhOptions = ref([
  { label: "阳性", value: "positive" },
  { label: "阴性", value: "negative" },
  { label: "阳性", value: "1" },
  { label: "阴性", value: "0" },
]);
const reporterOptions = ref([
@@ -566,7 +577,12 @@
// 计算属性
const isFormValid = computed(() => {
  return form.value.name && form.value.idcardno && form.value.diagnosisname;
  return (
    form.value.name &&
    form.value.idcardno &&
    form.value.diagnosisname &&
    form.value.toHospital
  );
});
// 选择器索引
const hospitalIndex = ref(-1);
@@ -576,11 +592,11 @@
// 计算属性 - 标签数组
const hospitalLabels = computed(() =>
  hospitalOptions.value.map((item) => item.label)
  hospitalOptions.value.map((item) => item.label),
);
const ageDisplay = computed(() => {
  if (!form.value.age || !form.value.ageunit) {
    return '自动计算';
    return "自动计算";
  }
  return `${form.value.age}${form.value.ageunit}`;
});
@@ -588,10 +604,10 @@
  return pickerColumns.value[0].map((item) => item.label);
});
const nationLabels = computed(() =>
  nationOptions.value.map((item) => item.label)
  nationLabel.value.map((item) => item.label),
);
const idCardTypeLabels = computed(() =>
  idCardTypeOptions.value.map((item) => item.label)
  idCardTypeOptions.value.map((item) => item.label),
);
// 计算属性 - 当前选中显示文本
@@ -619,29 +635,18 @@
    : "请选择证件类型";
});
// 选择器变更事件
const onHospitalChange = (e) => {
  const index = parseInt(e.detail.value);
  hospitalIndex.value = index;
  form.value.treatmenthospitalname = hospitalOptions.value[index].label;
};
const onDeptChange = (e) => {
  const index = parseInt(e.detail.value);
  deptIndex.value = index;
  form.value.treatmentdeptname = pickerColumns.value[0][index].label;
};
const onNationChange = (e) => {
  const index = parseInt(e.detail.value);
  nationIndex.value = index;
  form.value.nation = nationOptions.value[index].label;
  console.log(form.value.nation, "form.value.nation");
};
const onIdCardTypeChange = (e) => {
  const index = parseInt(e.detail.value);
  idCardTypeIndex.value = index;
  form.value.idcardtype = idCardTypeOptions.value[index].value;
  console.log(form.value.idcardtype, "form.value.idcardtype");
};
const onBirthdayChange = (e) => {
@@ -650,12 +655,12 @@
};
const onDateConfirm = (e) => {
  const date = new Date(e.value);
  // 格式化日期为 YYYY-MM-DD
  form.value.birthday = `${date.getFullYear()}-${(date.getMonth() + 1)
    .toString()
    .padStart(2, "0")}-${date.getDate().toString().padStart(2, "0")}`;
  calculateAge();
  showDatePicker.value = false;
};
@@ -710,12 +715,12 @@
  dict.value = await useDict(
    "sys_IDType",
    "sys_user_sex",
    "sys_Nation",
    "sys_BloodType",
    "sys_Infectious",
    "sys_AgeUnit", // 新增年龄单位
    "sys_education", // 新增学历
    "sys_nation", // 新增民族
    "sys_occupation" // 新增职业
    "sys_occupation", // 新增职业
  );
  initOptions();
  updateCurrentTime();
@@ -724,6 +729,7 @@
const initOptions = () => {
  infectiousDiseaselist.value = dict.value.sys_Infectious || [];
  idCardTypeOptions.value = dict.value.sys_IDType || [];
  nationLabel.value = dict.value.sys_Nation || [];
};
// 方法定义
const updateCurrentTime = () => {
@@ -753,18 +759,18 @@
const calculateAge = () => {
  if (!form.value.birthday) {
    form.value.age = '';
    form.value.ageunit = '';
    form.value.age = "";
    form.value.ageunit = "";
    return;
  }
  const birthDate = new Date(form.value.birthday);
  const today = new Date();
  // 检查日期有效性
  if (isNaN(birthDate.getTime())) {
    form.value.age = '';
    form.value.ageunit = '';
    form.value.age = "";
    form.value.ageunit = "";
    return;
  }
@@ -774,8 +780,8 @@
  if (daysDiff < 0) {
    // 未来日期处理
    form.value.age = '';
    form.value.ageunit = '';
    form.value.age = "";
    form.value.ageunit = "";
    return;
  }
@@ -789,14 +795,14 @@
  if (years >= 1) {
    // 大于等于1年:显示年
    let actualYears = years;
    // 处理月份和日期的边界情况
    if (months < 0 || (months === 0 && days < 0)) {
      actualYears = years - 1;
    }
    ageValue = actualYears.toString();
    ageUnit = '岁';
    ageUnit = "岁";
  } else if (daysDiff >= 30) {
    // 大于等于30天:显示月
    let totalMonths = years * 12 + months;
@@ -804,11 +810,11 @@
      totalMonths--;
    }
    ageValue = Math.max(1, totalMonths).toString(); // 确保至少1个月
    ageUnit = '个月';
    ageUnit = "个月";
  } else {
    // 小于30天:显示天
    ageValue = Math.max(1, daysDiff).toString(); // 确保至少1天
    ageUnit = '天';
    ageUnit = "天";
  }
  form.value.age = ageValue;
@@ -818,16 +824,19 @@
// 处理基础附件上传
const handleBaseUpload = (file) => {
  console.log("基础附件上传成功:", file);
  attachments.value.push(file);
};
// 处理其他附件上传
const handleFilesUpdate = (files) => {
  formData.attachments = files.map((file) => ({
  console.log(files, "files");
  attachments.value = files.map((file) => ({
    ...file,
    // 确保只存储半路径
    url: file.url.startsWith("http")
      ? file.url.replace(baseUrlHt, "")
      : file.url,
    // url: file.url.startsWith("http")
    //   ? file.url.replace(baseUrlHt, "")
    //   : file.url,
  }));
};
@@ -839,12 +848,12 @@
  if (file.type.includes("image")) {
    uni.previewImage({
      urls: formData.attachments
      urls: attachments.value
        .filter((f) => f.type.includes("image"))
        .map((f) =>
          f.url.startsWith("http")
            ? f.url
            : baseUrlHt + (f.url.startsWith("/") ? "" : "/") + f.url
            : baseUrlHt + (f.url.startsWith("/") ? "" : "/") + f.url,
        ),
      current: fullUrl,
    });
@@ -876,6 +885,8 @@
};
const onHospitalConfirm = (e) => {
  console.log(e, "民族");
  if (e.value && e.value[0]) {
    form.value.treatmenthospitalname = e.value[0].label;
  }
@@ -960,21 +971,19 @@
  try {
    uni.showLoading({ title: isEditMode.value ? "修改中..." : "提交中..." });
    // 准备提交数据
    const submitData = {
      ...form.value,
      age: parseInt(form.value.age) || 0,
      annexfilesList: attachments.value.map((file) => ({
        url: file.url,
        name: file.name,
        path: file.url,
        fileName: file.name,
        type: file.type,
      })),
      phone: form.value.infophone,
      isTransport: form.value.isTransport || "1",
      terminationCase: form.value.terminationCase || 0,
      reportStatus: form.value.reportStatus || "1",
    };
    let res;
@@ -982,13 +991,13 @@
      // 修改接口
      res = await uni.$uapi.post(
        "/project/donatebaseinforeport/edit",
        submitData
        submitData,
      );
    } else {
      // 新增接口
      res = await uni.$uapi.post(
        "/project/donatebaseinforeport/add",
        submitData
        submitData,
      );
    }
@@ -1028,49 +1037,28 @@
};
const loadCaseData = async (id) => {
  // 模拟加载编辑数据
  // form.value = {
  //   caseNo: "DON20241216001",
  //   treatmenthospitalname: "青岛镜湖医院",
  //   treatmentdeptname: "神经外科",
  //   name: "张三",
  //   nation: "汉族",
  //   nationality: "中国",
  //   idcardtype: "居民身份证",
  //   idcardno: "370203198510123456",
  //   sex: "1",
  //   birthday: "1985-10-12",
  //   age: "38",
  //   inpatientno: "ZY20241216001",
  //   diagnosisname: "脑外伤导致脑死亡",
  //   bloodtype: "A",
  //   rhyin: "positive",
  //   infoname: "李医生",
  //   infophone: "13800138000",
  //   reporterno: "张医生",
  //   reporttime: currentTime.value,
  // };
  try {
    loading.value = true;
    const res = await uni.$uapi.get(
      `/project/donatebaseinforeport/getInfo/${id}`
      `/project/donatebaseinforeport/getInfo/${id}`,
    );
    if (res.code === 200 && res.data) {
      // 填充表单数据
      Object.keys(form.value).forEach((key) => {
        if (res.data[key] !== undefined && res.data[key] !== null) {
          form.value[key] = res.data[key];
        }
      });
    if (res.code) {
      form.value = res.data;
      // 处理选择器索引
      updatePickerIndexes();
      // updatePickerIndexes();
      console.log(2, "res");
      // 处理附件
      if (res.data.annexfilesList) {
        attachments.value = res.data.annexfilesList;
        attachments.value.forEach((item) => {
          item.url = item.path;
          item.name = item.fileName;
        });
      }
      console.log(3, "res");
      uni.showToast({
        title: "数据加载成功",
@@ -1089,32 +1077,7 @@
    loading.value = false;
  }
};
// 更新选择器索引
const updatePickerIndexes = () => {
  // 医疗机构索引
  const hospitalIndex = hospitalOptions.value.findIndex(
    (item) => item.label === form.value.treatmenthospitalname
  );
  if (hospitalIndex !== -1) hospitalIndex.value = hospitalIndex;
  // 科室索引
  const deptIndex = pickerColumns.value[0].findIndex(
    (item) => item.label === form.value.treatmentdeptname
  );
  if (deptIndex !== -1) deptIndex.value = deptIndex;
  // 民族索引
  const nationIndex = nationOptions.value.findIndex(
    (item) => item.label === form.value.nation
  );
  if (nationIndex !== -1) nationIndex.value = nationIndex;
  // 证件类型索引
  const idCardTypeIndex = idCardTypeOptions.value.findIndex(
    (item) => item.value === form.value.idcardtype
  );
  if (idCardTypeIndex !== -1) idCardTypeIndex.value = idCardTypeIndex;
};
</script>
<style lang="scss" scoped>
.case-report-container {
@@ -1249,6 +1212,16 @@
  display: flex;
  gap: 20rpx;
  margin-top: 40rpx;
  // background: #fff;
  // padding: 20rpx 0;
  // position: fixed;
  // bottom: 0;
  // left: 0;
  // right: 0;
  // padding: 20rpx 30rpx;
  // padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
  // box-shadow: 0 -2rpx 20rpx rgba(0, 0, 0, 0.08);
  // z-index: 9;
}
.btn {
@@ -1472,12 +1445,6 @@
  border-radius: 12rpx !important;
  padding: 20rpx 24rpx !important;
  background: #fff !important;
}
.action-buttons {
  display: flex;
  gap: 20rpx;
  margin-top: 40rpx;
}
.btn {