WXL
2 天以前 2cc85c64f1c64a2dbaeae276a3e2ca8420de76b7
pages/case/transferinfo.vue
@@ -4,7 +4,7 @@
    <scroll-view scroll-y class="form-scroll" :show-scrollbar="false">
      <view class="form-content">
        <!-- 案例信息卡片 -->
        <view class="form-section" v-if="transportData.caseNo">
        <view class="form-section" v-if="transportData.reportId">
          <view class="section-header">
            <view class="section-icon">📋</view>
            <text class="section-title">关联案例信息</text>
@@ -54,7 +54,7 @@
          </view>
          <view class="form-grid">
            <view class="form-item">
            <!-- <view class="form-item">
              <text class="item-label">转运单号</text>
              <u-input
                v-model="transportData.reportId"
@@ -63,7 +63,7 @@
                :disabledColor="disabledColor"
                border="none"
              />
            </view>
            </view> -->
            <view class="form-item">
              <text class="item-label required">出发地点</text>
@@ -249,47 +249,6 @@
          </view>
        </view>
        <!-- 附件信息 -->
        <view
          class="form-section"
          v-if="
            transportData.annexfilesList &&
            transportData.annexfilesList.length > 0
          "
        >
          <view class="section-header">
            <view class="section-icon">📎</view>
            <text class="section-title"
              >附件信息 ({{ transportData.annexfilesList.length }})</text
            >
          </view>
          <view class="attachment-list">
            <view
              v-for="(file, index) in transportData.annexfilesList"
              :key="index"
              class="attachment-item"
              @click="previewFile(file)"
            >
              <view class="file-info">
                <u-icon
                  name="file-text"
                  color="#409EFF"
                  size="20"
                  class="file-icon"
                ></u-icon>
                <view class="file-details">
                  <text class="file-name">{{ file.fileName }}</text>
                  <text class="file-time">{{
                    formatTime(file.createTime)
                  }}</text>
                </view>
              </view>
              <u-icon name="arrow-right" color="#999" size="16"></u-icon>
            </view>
          </view>
        </view>
        <!-- 备注信息 -->
        <view class="form-section">
          <view class="section-header">
@@ -334,9 +293,9 @@
            >
              完成转运
            </u-button>
            <u-button v-if="canDelete" class="btn error" @click="handleDelete">
            <!-- <u-button v-if="canDelete" class="btn error" @click="handleDelete">
              删除
            </u-button>
            </u-button> -->
          </template>
          <!-- 编辑模式 -->
@@ -354,7 +313,15 @@
        </view>
      </view>
    </scroll-view>
    <attachment-upload
      ref="attachment"
      :files="attachments"
      :readonly="isReadonly"
      :maxCount="5"
      @update:files="handleFilesUpdate"
      @upload-base="handleBaseUpload"
      @preview="handlePreview"
    />
    <!-- 时间选择器 -->
    <u-datetime-picker
      :show="showTimePicker"
@@ -372,13 +339,18 @@
<script setup>
import { ref, computed, onMounted } from "vue";
import attachmentUpload from "@/components/attachment";
import { useUserStore } from "@/stores/user";
import { onLoad } from "@dcloudio/uni-app";
// 字典数据
const dict = ref({});
// 数据
const transportData = ref({});
const transportData = ref({
  annexfilesList: [], // 附件文件地址集合
});
const loading = ref(false);
const saving = ref(false);
const isEdit = ref(false);
@@ -386,6 +358,9 @@
const showTimePicker = ref(false);
const departureTimeValue = ref(0);
const statusSelectVisible = ref(false);
const isReadonly = ref(false);
const attachments = ref([]);
// 字典选项
const statusOptions = ref([
@@ -459,10 +434,18 @@
const loadTransportData = async (id) => {
  loading.value = true;
  try {
    const res = await uni.$uapi.post(`/project/transport/list`, { id: id });
    const res = await uni.$uapi.get(`/project/transport/getInfo/${id}`);
    if (res) {
      transportData.value = res[0];
    if (res.data) {
      transportData.value = res.data;
        if (res.data.annexfilesList) {
           attachments.value = res.data.annexfilesList;
        attachments.value.forEach(item=>{
          item.url=item.opath,
          item.name=item.fileName
        })
        }
    } else {
      throw new Error(res.msg || "数据加载失败");
    }
@@ -482,26 +465,28 @@
  try {
    // 如果有案例ID,加载案例信息
    if (caseId) {
      const res = await uni.$uapi.post(
        `/project/transport/list`,
        { id: caseId },
      const res = await uni.$uapi.get(
        `/project/donatebaseinforeport/getInfo/${caseId}`,
      );
      if (res) {
        const caseData = res[0];
      if (res.data) {
        const caseData = res.data;
        console.log(caseData);
        transportData.value = {
          ...transportData.value,
          caseNo: caseNo || caseData.caseNo,
          patName: caseData.patName,
          sex: caseData.sex,
          age: caseData.age,
          diagnosisname: caseData.diagnosisname,
          treatmentHospitalName: caseData.treatmenthospitalname,
          transitStatus: 1, // 待转运
          createTime: new Date()
            .toISOString()
            .replace("T", " ")
            .substring(0, 19),
          caseNo: caseData.caseNo || "",
          patName: caseData.name || "",
          sex: caseData.sex || "",
          age: caseData.age || "",
          reportId: caseData.id || null,
          diagnosisname: caseData.diagnosisname || "",
          treatmentHospitalName: caseData.treatmenthospitalname || "",
          treatmentDeptName: caseData.treatmentdeptname || "",
          // 可以设置一些默认值
          transportStartPlace: caseData.treatmenthospitalname || "",
          contactPerson: caseData.coordinatorName || "",
        };
        console.log(transportData.value, "transportData.value");
      }
    } else {
      transportData.value = {
@@ -560,6 +545,7 @@
// 时间确认
const onTimeConfirm = (e) => {
  const date = new Date(e.value);
  // 添加秒的部分
  transportData.value.transportStartTime = `${date.getFullYear()}-${(
    date.getMonth() + 1
  )
@@ -567,7 +553,11 @@
    .padStart(2, "0")}-${date.getDate().toString().padStart(2, "0")} ${date
    .getHours()
    .toString()
    .padStart(2, "0")}:${date.getMinutes().toString().padStart(2, "0")}`;
    .padStart(2, "0")}:${date.getMinutes().toString().padStart(2, "0")}:${date
    .getSeconds()
    .toString()
    .padStart(2, "0")}`; // 添加秒
  showTimePicker.value = false;
};
@@ -641,10 +631,18 @@
  saving.value = true;
  try {
    // const submitData = {
    //   ...transportData.value,
    // };
    const submitData = {
      ...transportData.value,
      annexfilesList: attachments.value.map((file) => ({
        path: file.url,
        fileName: file.name,
        type: file.type,
      })),
    };
    let res;
    if (transportId.value) {
      // 修改
@@ -737,9 +735,15 @@
    const updateData = {
      id: transportId.value,
      transitStatus: newStatus,
      ...transportData.value,
       annexfilesList: attachments.value.map((file) => ({
        path: file.url,
        fileName: file.name,
        type: file.type,
      })),
    };
    const res = await uni.$uapi.post("/system/transport/edit", updateData);
    const res = await uni.$uapi.post("/project/transport/edit", updateData);
    if (res.code === 200) {
      uni.showToast({ title: `${actionName}成功`, icon: "success" });
@@ -753,32 +757,63 @@
  }
};
// 删除转运单
const handleDelete = () => {
  uni.showModal({
    title: "确认删除",
    content: `确定要删除转运单 ${transportData.value.reportId} 吗?`,
    success: async (res) => {
      if (res.confirm) {
        try {
          const result = await uni.$uapi.delete(
            `/system/transport/${transportId.value}`,
          );
          if (result.code === 200) {
            uni.showToast({ title: "删除成功", icon: "success" });
            setTimeout(() => {
              uni.navigateBack();
            }, 1500);
          } else {
            uni.showToast({ title: result.msg || "删除失败", icon: "none" });
          }
        } catch (error) {
          console.error("删除失败:", error);
          uni.showToast({ title: "删除失败", icon: "none" });
        }
      }
    },
  });
// 处理基础附件上传
const handleBaseUpload = (file) => {
  console.log("基础附件上传成功:", file);
  attachments.value.push(file);
};
// 处理其他附件上传
const handleFilesUpdate = (files) => {
  console.log(files,'files');
  attachments.value = files.map((file) => ({
    ...file,
    // 确保只存储半路径
    // url: file.url.startsWith("http")
    //   ? file.url.replace(baseUrlHt, "")
    //   : file.url,
  }));
  console.log(attachments.value);
};
// 预览文件 - 修改为使用完整URL
const handlePreview = (file) => {
  const fullUrl = file.url.startsWith("http")
    ? file.url
    : baseUrlHt + (file.url.startsWith("/") ? "" : "/") + file.url;
  if (file.type.includes("image")) {
    uni.previewImage({
      urls: attachments.value
        .filter((f) => f.type.includes("image"))
        .map((f) =>
          f.url.startsWith("http")
            ? f.url
            : baseUrlHt + (f.url.startsWith("/") ? "" : "/") + f.url,
        ),
      current: fullUrl,
    });
  } else if (file.type.includes("pdf")) {
    uni.downloadFile({
      url: fullUrl,
      success: (res) => {
        uni.openDocument({
          filePath: res.tempFilePath,
          fileType: "pdf",
          showMenu: true,
        });
      },
      fail: (err) => {
        console.error("打开文档失败:", err);
        uni.showToast({ title: "打开文件失败", icon: "none" });
      },
    });
  } else {
    uni.showToast({ title: "暂不支持此文件类型预览", icon: "none" });
  }
};
</script>
@@ -1006,7 +1041,7 @@
  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: 100;
  z-index: 9;
}
.btn {