gaoluyang
7 天以前 742643e009dfd72591392f0d7dcf07c2a9a3ec9a
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-->
@@ -321,20 +321,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 +373,6 @@
    .catch(() => {
      proxy.$modal.msg("已取消");
    });
};
// 打开附件上传弹窗
const handleDownload = (val) => {
  fileList.value = [];
  uploadModal.value = true;
  currentId.value = val.id;
};
// 确认文件上传
@@ -443,9 +442,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(() => {