gaoluyang
2025-12-19 841c8675a4fbf9fdcabf5cdc10390cb2c8e65e8f
src/views/salesManagement/invoiceLedger/index.vue
@@ -108,7 +108,7 @@
            <el-form-item label="附件材料:" prop="remark">
              <el-upload v-model:file-list="fileList" :action="upload.url" multiple ref="fileUpload" auto-upload
                :headers="upload.headers" accept=".pdf" :limit="10" :before-upload="handleBeforeUpload"
                :on-error="handleUploadError" :on-success="handleUploadSuccess" :on-remove="handleRemove">
                :on-error="handleUploadError" :on-success="handleUploadSuccess">
                <el-button type="primary">上传</el-button>
                <template #tip>
                  <!--                  文件格式支持 doc,docx,xls,xlsx,ppt,pptx,pdf,txt,xml,jpg,jpeg,png,gif,bmp,rar,zip,7z-->
@@ -165,8 +165,7 @@
  commitFile,
  registrationProductPage,
  delInvoiceLedgerByRegProductId,
} from "../../../api/salesManagement/invoiceLedger.js";
import { getSalesLedgerWithProducts } from "@/api/salesManagement/salesLedger.js";
} from "@/api/salesManagement/invoiceLedger.js";
import useUserStore from "@/store/modules/user.js";
import useFormData from "@/hooks/useFormData";
import dayjs from "dayjs";
@@ -279,6 +278,10 @@
  invoiceLedgerProductInfo({ id: row.id }).then((res) => {
    form.value = { ...res.data };
    fileList.value = res.data.fileList;
    // 保存ticketRegistrationId到表单数据中
    if (row.ticketRegistrationId) {
      form.value.ticketRegistrationId = row.ticketRegistrationId;
    }
    if (!form.value.invoicePerson) {
      form.value.invoicePerson = userStore.nickName;
      // 移除录入日期默认值设置,只处理范围日期字段
@@ -321,20 +324,26 @@
  proxy.$modal.closeLoading();
  console.log('handleUploadSuccess');
  if (res.code === 200) {
    // proxy.$refs["fileUpload"].handleRemove(file);
    // fileList.value.push(res.data);
    proxy.$modal.msgSuccess("上传成功");
    // 将上传成功的文件信息添加到fileList中
    const fileInfo = {
      name: file.name,
      url: res.data.url || file.response?.data?.url || file.url,
      response: file.response
    };
    // 检查是否已存在相同文件,避免重复添加
    const existingFileIndex = fileList.value.findIndex(f => f.name === fileInfo.name);
    if (existingFileIndex === -1) {
      fileList.value.push(fileInfo);
    } else {
      fileList.value[existingFileIndex] = fileInfo;
    }
    // 确保表单数据中的fileList也更新
    form.value.fileList = fileList.value;
  } else {
    proxy.$modal.msgError(res.msg);
    proxy.$refs.fileUpload.handleRemove(file);
  }
}
// 移除文件
function handleRemove(file) {
  // let index = fileList.value.findIndex((item) => item.url === file.url);
  // if (index > -1) {
  //   fileList.value.splice(index, 1);
  // }
}
// 提交表单
const submitForm = () => {
@@ -367,13 +376,6 @@
    .catch(() => {
      proxy.$modal.msg("已取消");
    });
};
// 打开附件上传弹窗
const handleDownload = (val) => {
  fileList.value = [];
  uploadModal.value = true;
  currentId.value = val.id;
};
// 确认文件上传
@@ -443,9 +445,9 @@
const fileListRef = ref(null)
//查看附件
const downLoadFile = (row) => {
  getSalesLedgerWithProducts({ id: row.id, type: 1 }).then((res) => {
    fileListRef.value.open(res.salesLedgerFiles)
  });
   invoiceLedgerProductInfo({ id: row.id }).then((res) => {
      fileListRef.value.open(res.data.fileList)
   });
}
onMounted(() => {