buhuazhen
2025-09-23 99a3c5eff1f52bf07235e60c4a2a1922e45e3fcb
附件上传
已修改5个文件
已删除2个文件
145 ■■■■■ 文件已修改
.husky/commit-msg 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.husky/pre-commit 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/product/attachment.ts 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/production/twist/attachment/index.vue 56 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/production/twist/report/index.vue 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/production/wire/attachment/index.vue 58 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/production/wire/report/wire.vue 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.husky/commit-msg
ÎļþÒÑɾ³ý
.husky/pre-commit
ÎļþÒÑɾ³ý
src/api/product/attachment.ts
@@ -63,7 +63,7 @@
  },
  // æŠ¥å·¥æ·»åР附件
  addOutputAttachments(params: { id: number; attachmentIds: string }) {
  addOutputAttachments(params: { id: number; attachmentId: string }) {
    return request<BaseResult<any>>({
      url: "/app/addOutputAttachments",
      method: "POST",
src/pages/production/twist/attachment/index.vue
@@ -55,21 +55,27 @@
const reportType = ref("绞线");
const attachmentList = ref<any[]>([]);
const detailData = ref<any>({});
// èŽ·å–é™„ä»¶åˆ—è¡¨
const getAttachmentList = async () => {
const getAttachmentList = async (data: any) => {
  try {
    detailData.value = data;
    console.log(" detailData.value", detailData.value);
    const pages = getCurrentPages();
    const currentPage = pages[pages.length - 1];
    const options = (currentPage as any).options;
    const currentReportId = options?.reportId;
    const currentReportId = detailData.value.id;
    if (currentReportId) {
      reportId.value = currentReportId;
      // ç›´æŽ¥è°ƒç”¨é€šç”¨æŸ¥çœ‹æŽ¥å£æŸ¥è¯¢é™„件列表
      // ä½¿ç”¨ç¤ºä¾‹ä¸­çš„附件ID数组 [850,851]
      const attachmentIds: number[] = [850, 851]; // ä½¿ç”¨HTTP文件中的示例数据
      const attachmentIds: number[] = detailData.value.attachmentId !== null? detailData.value.attachmentId.split(",") : []; // ä½¿ç”¨HTTP文件中的示例数据
      if (attachmentIds.length === 0) {
        return;
      }
      const { data } = await AttachmentAPI.listAttachmentFiles(attachmentIds);
      attachmentList.value = data || [];
    } else {
@@ -95,20 +101,30 @@
        const filePaths = Array.isArray(res.tempFilePaths)
          ? res.tempFilePaths
          : [res.tempFilePaths];
        const uploadResults = await AttachmentAPI.uploadAttachmentFiles(filePaths);
        const uploadResults: any = await AttachmentAPI.uploadAttachmentFiles(filePaths);
        const result = uploadResults.map((it) => {
          return it.data;
        });
        console.log("result", result);
        // æ›´æ–°é™„件列表
        const flattenedResult = result.flat();
        attachmentList.value.push(...flattenedResult);
        console.log(attachmentList.value);
        // æå–附件ID
        const attachmentIds = uploadResults.map((result) => result.data.id).join(",");
        const attachmentId = attachmentList.value.map((item: any) => item.id).join(",");
        // å…³è”到报工
        await AttachmentAPI.addOutputAttachments({
          id: parseInt(reportId.value),
          attachmentIds: attachmentIds,
        });
        if (attachmentId) {
          await AttachmentAPI.addOutputAttachments({
            id: parseInt(detailData.value.id),
            attachmentId: attachmentId,
          });
          detailData.value.attachmentId = attachmentId;
        }
        toast.show("上传成功");
        // é‡æ–°èŽ·å–é™„ä»¶åˆ—è¡¨
        await getAttachmentList();
        // await getAttachmentList();
      } catch (error) {
        console.error("上传失败:", error);
        toast.show("上传失败");
@@ -122,7 +138,7 @@
};
// åˆ é™¤é™„ä»¶
const deleteAttachment = async (attachmentId: number) => {
const deleteAttachment = async (aid: number) => {
  try {
    uni.showModal({
      title: "确认删除",
@@ -130,18 +146,17 @@
      success: async (res) => {
        if (res.confirm) {
          // å‰ç«¯æ‰‹åŠ¨åˆ é™¤ï¼šç›´æŽ¥ä»Žåˆ—è¡¨ä¸­ç§»é™¤è¿™æ¡æ•°æ®
          attachmentList.value = attachmentList.value.filter((item) => item.id !== attachmentId);
          attachmentList.value = attachmentList.value.filter((item) => item.id !== aid);
          // èŽ·å–å‰©ä½™çš„é™„ä»¶ID组合
          const remainingIds = attachmentList.value.map((item) => item.id);
          const attachmentIds = remainingIds.join(",");
          const attachmentId = attachmentList.value.map((item) => item.id).join(",");
          // è°ƒç”¨æŠ¥å·¥æ·»åŠ é™„ä»¶æŽ¥å£ï¼Œæ›´æ–°é™„ä»¶å…³è”
          await AttachmentAPI.addOutputAttachments({
            id: parseInt(reportId.value),
            attachmentIds: attachmentIds,
            id: parseInt(detailData.value.id),
            attachmentId: attachmentId,
          });
          detailData.value.attachmentId = attachmentId;
          toast.show("删除成功");
        }
      },
@@ -235,7 +250,10 @@
};
onMounted(() => {
  getAttachmentList();
  uni.$on("detailData", (data) => {
    // å¤„理接收到的数据
    getAttachmentList(data);
  });
});
</script>
src/pages/production/twist/report/index.vue
@@ -17,7 +17,7 @@
        </template>
        <ProductionCard :data="cardAttr" :value="item" />
        <template #footer>
          <wd-button size="small" plain @click="toAttachment(item.id)" style="margin-right: 10px">
          <wd-button size="small" plain @click="toAttachment(item)" style="margin-right: 10px">
            é™„ä»¶
          </wd-button>
          <wd-button size="small" plain @click="toCheck(item.id)">自检</wd-button>
@@ -103,17 +103,17 @@
  dialog.visible = false;
};
const toAttachment = (id: number) => {
const toAttachment = (item: any) => {
  uni.navigateTo({
    url: `/pages/production/twist/attachment/index?reportId=${id}`,
    url: "/pages/production/twist/attachment/index",
    success: () => {
      // é¡µé¢è·³è½¬æˆåŠŸåŽå‘é€äº‹ä»¶ä¼ é€’æ•°æ®
      uni.$emit("detailData", item);
    },
  });
};
const toCheck = (id: number) => {
  uni.navigateTo({
    url: `/pages/production/twist/selfInspect/index?id=${id}`,
  });
};
// èŽ·å–æ‹‰ä¸æŠ¥å·¥åˆ—è¡¨
const getTwistReportList = async () => {
src/pages/production/wire/attachment/index.vue
@@ -52,24 +52,30 @@
// é¡µé¢å‚æ•°
const reportId = ref("");
const reportType = ref("拉丝");
const reportType = ref("绞线");
const attachmentList = ref<any[]>([]);
const detailData = ref<any>({});
// èŽ·å–é™„ä»¶åˆ—è¡¨
const getAttachmentList = async () => {
const getAttachmentList = async (data: any) => {
  try {
    detailData.value = data;
    console.log(" detailData.value", detailData.value);
    const pages = getCurrentPages();
    const currentPage = pages[pages.length - 1];
    const options = (currentPage as any).options;
    const currentReportId = options?.reportId;
    const currentReportId = detailData.value.id;
    if (currentReportId) {
      reportId.value = currentReportId;
      // ç›´æŽ¥è°ƒç”¨é€šç”¨æŸ¥çœ‹æŽ¥å£æŸ¥è¯¢é™„件列表
      // ä½¿ç”¨ç¤ºä¾‹ä¸­çš„附件ID数组 [850,851]
      const attachmentIds: number[] = [850, 851]; // ä½¿ç”¨HTTP文件中的示例数据
      const attachmentIds: number[] = detailData.value.attachmentId !== null? detailData.value.attachmentId.split(",") : []; // ä½¿ç”¨HTTP文件中的示例数据
      if (attachmentIds.length === 0) {
        return;
      }
      const { data } = await AttachmentAPI.listAttachmentFiles(attachmentIds);
      attachmentList.value = data || [];
    } else {
@@ -95,20 +101,30 @@
        const filePaths = Array.isArray(res.tempFilePaths)
          ? res.tempFilePaths
          : [res.tempFilePaths];
        const uploadResults = await AttachmentAPI.uploadAttachmentFiles(filePaths);
        const uploadResults: any = await AttachmentAPI.uploadAttachmentFiles(filePaths);
        const result = uploadResults.map((it) => {
          return it.data;
        });
        console.log("result", result);
        // æ›´æ–°é™„件列表
        const flattenedResult = result.flat();
        attachmentList.value.push(...flattenedResult);
        console.log(attachmentList.value);
        // æå–附件ID
        const attachmentIds = uploadResults.map((result) => result.data.id).join(",");
        const attachmentId = attachmentList.value.map((item: any) => item.id).join(",");
        // å…³è”到报工
        await AttachmentAPI.addOutputAttachments({
          id: parseInt(reportId.value),
          attachmentIds: attachmentIds,
        });
        if (attachmentId) {
          await AttachmentAPI.addOutputAttachments({
            id: parseInt(detailData.value.id),
            attachmentId: attachmentId,
          });
          detailData.value.attachmentId = attachmentId;
        }
        toast.show("上传成功");
        // é‡æ–°èŽ·å–é™„ä»¶åˆ—è¡¨
        await getAttachmentList();
        // await getAttachmentList();
      } catch (error) {
        console.error("上传失败:", error);
        toast.show("上传失败");
@@ -122,7 +138,7 @@
};
// åˆ é™¤é™„ä»¶
const deleteAttachment = async (attachmentId: number) => {
const deleteAttachment = async (aid: number) => {
  try {
    uni.showModal({
      title: "确认删除",
@@ -130,18 +146,17 @@
      success: async (res) => {
        if (res.confirm) {
          // å‰ç«¯æ‰‹åŠ¨åˆ é™¤ï¼šç›´æŽ¥ä»Žåˆ—è¡¨ä¸­ç§»é™¤è¿™æ¡æ•°æ®
          attachmentList.value = attachmentList.value.filter((item) => item.id !== attachmentId);
          attachmentList.value = attachmentList.value.filter((item) => item.id !== aid);
          // èŽ·å–å‰©ä½™çš„é™„ä»¶ID组合
          const remainingIds = attachmentList.value.map((item) => item.id);
          const attachmentIds = remainingIds.join(",");
          const attachmentId = attachmentList.value.map((item) => item.id).join(",");
          // è°ƒç”¨æŠ¥å·¥æ·»åŠ é™„ä»¶æŽ¥å£ï¼Œæ›´æ–°é™„ä»¶å…³è”
          await AttachmentAPI.addOutputAttachments({
            id: parseInt(reportId.value),
            attachmentIds: attachmentIds,
            id: parseInt(detailData.value.id),
            attachmentId: attachmentId,
          });
          detailData.value.attachmentId = attachmentId;
          toast.show("删除成功");
        }
      },
@@ -235,7 +250,10 @@
};
onMounted(() => {
  getAttachmentList();
  uni.$on("detailData", (data) => {
    // å¤„理接收到的数据
    getAttachmentList(data);
  });
});
</script>
src/pages/production/wire/report/wire.vue
@@ -22,7 +22,7 @@
        </template>
        <ProductionCard :data="cardAttr" :value="item" />
        <template #footer>
          <wd-button size="small" plain @click="toAttachment(item.id)" style="margin-right: 10px">
          <wd-button size="small" plain @click="toAttachment(item)" style="margin-right: 10px">
            é™„ä»¶
          </wd-button>
          <wd-button size="small" plain @click="toCheck(item.id)">自检</wd-button>
@@ -123,9 +123,13 @@
  dialog.visible = false;
};
const toAttachment = (id: number) => {
const toAttachment = (item: any) => {
  uni.navigateTo({
    url: `/pages/production/wire/attachment/index?reportId=${id}`,
    url: "/pages/production/wire/attachment/index",
    success: () => {
      // é¡µé¢è·³è½¬æˆåŠŸåŽå‘é€äº‹ä»¶ä¼ é€’æ•°æ®
      uni.$emit("detailData", item);
    },
  });
};