chenhj
2026-04-30 5ecd9ec941e92d6398141c6080f0e27350171e0a
采购文件上传
已修改1个文件
77 ■■■■ 文件已修改
src/views/procurementManagement/procurementLedger/index.vue 77 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/procurementManagement/procurementLedger/index.vue
@@ -44,7 +44,8 @@
          </el-form-item>
          <el-form-item>
            <el-button type="primary"
                       @click="handleQuery"> 搜索 </el-button>
                       @click="handleQuery"> 搜索
            </el-button>
          </el-form-item>
        </el-form>
      </div>
@@ -52,12 +53,14 @@
    <div class="table_list">
      <div style="display: flex;justify-content: flex-end;margin-bottom: 20px;">
        <el-button type="primary"
                   @click="openForm('add')">新增台账</el-button>
                   @click="openForm('add')">新增台账
        </el-button>
        <el-button type="primary" plain @click="handleImport">导入</el-button>
        <el-button @click="handleOut">导出</el-button>
        <el-button type="danger"
                   plain
                   @click="handleDelete">删除</el-button>
                   @click="handleDelete">删除
        </el-button>
      </div>
      <el-table :data="tableData"
                border
@@ -174,10 +177,12 @@
            <el-button link
                       type="primary"
                       @click="openForm('edit', scope.row)"
                       :disabled="scope.row.approvalStatus !== 1 && scope.row.approvalStatus !== 4">编辑</el-button>
                       :disabled="scope.row.approvalStatus !== 1 && scope.row.approvalStatus !== 4">编辑
            </el-button>
            <el-button link
                       type="primary"
                       @click="downLoadFile(scope.row)">附件</el-button>
                       @click="downLoadFile(scope.row)">附件
            </el-button>
          </template>
        </el-table-column>
      </el-table>
@@ -236,7 +241,8 @@
                <el-option v-for="item in supplierList"
                           :key="item.id"
                           :label="item.supplierName"
                                                     :value="item.id" >{{item.supplierName + '---' + item.supplierType}}</el-option>
                           :value="item.id">{{ item.supplierName + '---' + item.supplierType }}
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
@@ -294,10 +300,12 @@
          <el-form-item label="产品信息:"
                        prop="entryDate">
            <el-button type="primary"
                       @click="openProductForm('add')">添加</el-button>
                       @click="openProductForm('add')">添加
            </el-button>
            <el-button plain
                       type="danger"
                       @click="deleteProduct">删除</el-button>
                       @click="deleteProduct">删除
            </el-button>
          </el-form-item>
          <div class="select-button-group"
               style="width: 500px; margin: 20px 0;"
@@ -397,7 +405,8 @@
            <template #default="scope">
              <el-button link
                         type="primary"
                         @click="openProductForm('edit', scope.row, scope.$index)">编辑</el-button>
                         @click="openProductForm('edit', scope.row, scope.$index)">编辑
              </el-button>
            </template>
          </el-table-column>
        </el-table>
@@ -417,24 +426,7 @@
          <el-col :span="24">
            <el-form-item label="附件材料:"
                          prop="purchaseLedgerFiles">
              <el-upload v-model:file-list="fileList"
                         :action="upload.url"
                         multiple
                         ref="fileUpload"
                         auto-upload
                         :headers="upload.headers"
                         :before-upload="handleBeforeUpload"
                         :on-error="handleUploadError"
                         :on-success="handleUploadSuccess"
                         :on-remove="handleRemove">
                <el-button type="primary">上传</el-button>
                <template #tip>
                  <div class="el-upload__tip">
                    文件格式支持
                    doc,docx,xls,xlsx,ppt,pptx,pdf,txt,xml,jpg,jpeg,png,gif,bmp,rar,zip,7z
                  </div>
                </template>
              </el-upload>
              <FileUpload v-model:file-list="fileList"/>
            </el-form-item>
          </el-col>
        </el-row>
@@ -696,6 +688,7 @@
  const salesContractList = ref([]);
  const supplierList = ref([]);
  const tableLoading = ref(false);
const fileListDialogVisible = ref(false)
  const page = reactive({
    current: 1,
    size: 100,
@@ -705,6 +698,7 @@
  import useUserStore from "@/store/modules/user";
  import { modelList, productTreeList } from "@/api/basicData/product.js";
  import dayjs from "dayjs";
import FileUpload from "@/components/AttachmentUpload/file/index.vue";
  const userStore = useUserStore();
@@ -1249,7 +1243,7 @@
          const purchaseRes = await getPurchaseById({ id: row.id, type: 2 });
          form.value = { ...purchaseRes };
          productData.value = purchaseRes.productData || [];
          fileList.value = purchaseRes.salesLedgerFiles || [];
        fileList.value = purchaseRes.storageBlobVOS || [];
        } catch (error) {
          console.error("加载采购台账数据失败:", error);
          proxy.$modal.msgError("加载数据失败");
@@ -1267,6 +1261,7 @@
      proxy.$modal.msgError("加载基础数据失败");
    }
  };
  // 上传前校检
  function handleBeforeUpload(file) {
    // 校检文件大小
@@ -1277,11 +1272,13 @@
    proxy.$modal.loading("正在上传文件,请稍候...");
    return true;
  }
  // 上传失败
  function handleUploadError(err) {
    proxy.$modal.msgError("上传文件失败");
    proxy.$modal.closeLoading();
  }
  // 上传成功回调
  function handleUploadSuccess(res, file, uploadFiles) {
    proxy.$modal.closeLoading();
@@ -1293,6 +1290,7 @@
      proxy.$refs.fileUpload.handleRemove(file);
    }
  }
  // 移除文件
  async function handleRemove(file) {
    if (!file?.id) {
@@ -1314,6 +1312,7 @@
      }
    }
  }
  // 提交表单
  const submitForm = () => {
    proxy.$refs["formRef"].validate(valid => {
@@ -1332,11 +1331,7 @@
          proxy.$modal.msgWarning("请添加产品信息");
          return;
        }
        let tempFileIds = [];
        if (fileList.value.length > 0) {
          tempFileIds = fileList.value.map(item => item.tempId);
        }
        form.value.tempFileIds = tempFileIds;
      form.value.storageBlobDTOS = fileList.value;
        form.value.type = 2;
        // 如果salesLedgerId为空,则不传递salesContractNo
@@ -1484,6 +1479,7 @@
    }
    return null; // 没有找到节点,返回null
  };
  function convertIdToValue(data) {
    return data.map(item => {
      const { id, children, ...rest } = item;
@@ -1498,6 +1494,7 @@
      return newItem;
    });
  }
  // 提交产品表单
  const submitProduct = () => {
    proxy.$refs["productFormRef"].validate(valid => {
@@ -1613,6 +1610,7 @@
        proxy.$modal.msg("已取消");
      });
  };
  // 获取当前日期并格式化为 YYYY-MM-DD
  function getCurrentDate() {
    const today = new Date();
@@ -1621,6 +1619,7 @@
    const day = String(today.getDate()).padStart(2, "0");
    return `${year}-${month}-${day}`;
  }
  const mathNum = () => {
    if (!productForm.value.taxRate) {
      proxy.$modal.msgWarning("请先选择税率");
@@ -1753,14 +1752,6 @@
    }
  };
  const fileListRef = ref(null);
  const fileListDialogVisible = ref(false);
  const downLoadFile = row => {
    if (fileListRef.value) {
      fileListRef.value.open(row.salesLedgerFiles);
    }
  };
  // 获取模板信息
  const getTemplateList = async () => {
    let res = await getPurchaseTemplateList();
@@ -1828,13 +1819,16 @@
    opacity: 0.6;
    background-color: #f5f7fa;
  }
  .el-row {
    justify-content: space-between;
    align-items: center;
  }
  .no-arrow-select {
    --el-select-suffix-icon-color: transparent; /* 隐藏默认下拉箭头 */
  }
  .select-button-group {
    display: flex;
    align-items: center;
@@ -1894,6 +1888,7 @@
  // 删除图标样式
  .delete-icon {
    transition: all 0.3s;
    &:hover {
      color: #f56c6c !important;
      transform: scale(1.2);