From ef1fa671b060a727adfb6438ba665a443fa0ce63 Mon Sep 17 00:00:00 2001 From: lb Date: Thu, 6 Jul 2023 17:02:22 +0800 Subject: [PATCH] =?UTF-8?q?bugfix=200706=20=E7=89=A9=E6=96=99=E9=85=8D?= =?UTF-8?q?=E6=96=B9=20=E5=90=8C=E6=AD=A5=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/atomViews/ListView.vue | 73 +++++++++++----------- src/views/modules/pms/bomDetails/config.js | 4 +- 2 files changed, 39 insertions(+), 38 deletions(-) diff --git a/src/views/atomViews/ListView.vue b/src/views/atomViews/ListView.vue index 03a8636..f7b7b63 100644 --- a/src/views/atomViews/ListView.vue +++ b/src/views/atomViews/ListView.vue @@ -62,6 +62,8 @@ :dialog-visible.sync="dialogVisible" :configs="dialogConfigs" @refreshDataList="getList" /> + + @@ -69,6 +71,7 @@ import BaseListTable from "@/components/BaseListTable.vue"; import DialogWithMenu from "@/components/DialogWithMenu.vue"; import DialogJustForm from "@/components/DialogJustForm.vue"; +import Overlay from "@/components/Overlay.vue"; import moment from "moment"; const DIALOG_WITH_MENU = "DialogWithMenu"; @@ -76,7 +79,7 @@ const DIALOG_JUST_FORM = "DialogJustForm"; export default { name: "ListView", - components: { BaseListTable, DialogWithMenu, DialogJustForm }, + components: { BaseListTable, DialogWithMenu, DialogJustForm, Overlay }, props: { tableConfig: { type: Object, @@ -135,6 +138,7 @@ export default { dataList: [], tableLoading: false, refreshLayoutKey: null, + overlayVisible: false, }; }, inject: ["urls"], @@ -417,45 +421,42 @@ export default { }); } - // const dataview = new DataView(new ArrayBuffer(8)); - // dataview.setBigInt64(0, data); - // data = new Blob([dataview.buffer], { type: "application/octet-stream" }); case "sync": { - // console.log("sync ", data, typeof data, BigInt(data).toString()); - // 同步配方详情 - // data = BigInt(data).toString(2) - return ( - this.$http({ - url: this.urls.syncUrl, - method: "post", - data, + let shouldShowOverlay = false; + let payload = ""; + console.log("sync...", type, data); + if (typeof data === "object") { + const head = data.head; + const syncOpt = + ("options" in head && Array.isArray(head.options) && head.options.find((item) => item.name === "sync")) || + null; + if (syncOpt && "showOverlay" in syncOpt && syncOpt.showOverlay) { + this.overlayVisible = true; + shouldShowOverlay = true; + payload = data.id; + } + } else payload = data; + + this.$message({ + message: "正在发起同步...", + type: "success", + }); + + // 同步单个料仓数据 + this.$http + .post(this.urls.syncSingleUrl, payload, { headers: { - "Content-Type": "text/plain", + "Content-Type": "application/json", }, }) - // .post(this.urls.syncUrl, data: `id=${data}`, { headers: { "Content-Type": "text/plain", "data-id": data } }) - .then(({ data: res }) => { - if (res.code === 0) { - this.$message({ - message: "同步成功", - type: "success", - duration: 1500, - onClose: () => { - this.getList(); - }, - }); - } else { - throw new Error(res.msg); - } - }) - .catch((errMsg) => { - this.$message({ - message: "同步失败: " + errMsg, - type: "error", - duration: 1500, - }); - }) - ); + .then(({ data: res }) => { + this.$message({ + message: res.msg, + type: res.code === 0 ? "success" : "error", + }); + this.getList(); + if (shouldShowOverlay) this.overlayVisible = false; + }); } } }, diff --git a/src/views/modules/pms/bomDetails/config.js b/src/views/modules/pms/bomDetails/config.js index 2cb3a9a..a546197 100644 --- a/src/views/modules/pms/bomDetails/config.js +++ b/src/views/modules/pms/bomDetails/config.js @@ -48,7 +48,7 @@ export default function () { width: 160, subcomponent: TableOperaionComponent, options: [ - { name: "sync", label: "同步", icon: "refresh" }, + { name: "sync", label: "同步", icon: "refresh", emitFull: true, showOverlay: true }, { name: "copy", label: "复制", icon: "copy-document" }, { name: "edit", label: "编辑", icon: "edit-outline" }, { name: "delete", icon: "delete", label: "删除", emitFull: true, permission: "pms:bom:delete" }, @@ -215,7 +215,7 @@ export default function () { urls: { base: "/pms/bom", page: "/pms/bom/pageVersion", - syncUrl: "/pms/trans/bomSync", + syncSingleUrl: "/pms/trans/bomSync", copyUrl: "/pms/bom/copy", subase: "/pms/bomMaterial", subpage: "/pms/bomMaterial/page",