From 6e9d725f6d9b04f05db6b9414fbbad2dab02bdf2 Mon Sep 17 00:00:00 2001 From: "pikachu1995@126.com" Date: Thu, 27 Jun 2024 17:09:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=BA=97=E9=93=BA=E9=80=9A?= =?UTF-8?q?=E8=BF=87excel=E6=89=B9=E9=87=8F=E6=9B=B4=E6=96=B0=E5=95=86?= =?UTF-8?q?=E5=93=81=E5=BA=93=E5=AD=98=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../goods/goods-seller/alertQuantity.vue | 1019 ++++++++++------- 1 file changed, 613 insertions(+), 406 deletions(-) diff --git a/seller/src/views/goods/goods-seller/alertQuantity.vue b/seller/src/views/goods/goods-seller/alertQuantity.vue index 3e2367f4..708d8ff3 100644 --- a/seller/src/views/goods/goods-seller/alertQuantity.vue +++ b/seller/src/views/goods/goods-seller/alertQuantity.vue @@ -1,420 +1,627 @@ - - - - \ No newline at end of file + //切换分页 + switchTabs() { + this.handleReset(); + this.getDataList(); + }, + // 改变页数 + changePageSize(v) { + this.searchForm.pageSize = v; + this.getDataList(); + }, + //改变页码 + changePage(v) { + this.searchForm.pageNumber = v; + this.getDataList(); + this.clearSelectAll(); + }, + // 搜索 + handleSearch() { + this.searchForm.pageNumber = 1; + this.searchForm.pageSize = 10; + this.searchForm.categoryPath = this.category ? this.category.join(",") : null; + this.getDataList(); + }, + // 重置搜索条件 + handleReset() { + this.searchForm = {}; + this.category = []; + this.searchForm.pageNumber = 1; + this.searchForm.pageSize = 10; + // 重新加载数据 + this.getDataList(); + }, + // 获取商品列表数据 + getDataList() { + this.loading = true; + // 带多条件搜索参数获取表单数据 + if (this.stockType == 'warnList') { + //调用预警库存 + getGoodsListDataByStockSeller(this.searchForm).then(res => { + if (res.success) { + this.warnData = res.result.records + this.total = res.result.total + this.loading = false; + } + }) + } else if (this.stockType == 'warnSetting') { + //调用获取全部sku + getGoodsSkuListDataSeller(this.searchForm).then(res => { + if (res.success) { + this.skuAllData = res.result.records + this.total = res.result.total + this.loading = false; + } + }) + } else if (this.stockType == 'stockManage') { + //调用获取全部sku + getGoodsSkuListDataSeller(this.searchForm).then(res => { + if (res.success) { + this.stockAllData = res.result.records + this.total = res.result.total + this.loading = false; + } + }) + } + }, + //组织分类树 + deepGroup() { + getGoodsCategoryAll().then(res => { + if (res.success) { + res.result.forEach((item) => { + let childWay = []; //第二级 + // 第二层 + if (item.children) { + item.children.forEach((child) => { + // // 第三层 + if (child.children) { + child.children.forEach((grandson, index, arr) => { + arr[index] = { + value: grandson.id, + label: grandson.name, + children: "", + }; + }); + } + let children = { + value: child.id, + label: child.name, + children: child.children, + }; + childWay.push(children); + }); + } + // 第一层 + let way = { + value: item.id, + label: item.name, + children: childWay, + }; + this.categoryList.push(way); + }); + } + }) + }, + // 导出订单 + async exportStock() { + let randomNumber = ''; + for (let i = 0; i < 10; i++) { + randomNumber += Math.floor(Math.random() * 10); + } + ; + queryExportStock(this.searchForm) + .then((res) => { + const blob = new Blob([res], { + type: "application/vnd.ms-excel;charset=utf-8", + }); + //对于标签,只有 Firefox 和 Chrome(内核) 支持 download 属性 + //IE10以上支持blob但是依然不支持download + if ("download" in document.createElement("a")) { + //支持a标签download的浏览器 + const link = document.createElement("a"); //创建a标签 + link.download = randomNumber + ".xlsx"; //a标签添加属性 + link.style.display = "none"; + link.href = URL.createObjectURL(blob); + document.body.appendChild(link); + link.click(); //执行下载 + URL.revokeObjectURL(link.href); //释放url + document.body.removeChild(link); //释放标签 + } else { + navigator.msSaveBlob(blob, fileName); + } + }) + .catch((err) => { + console.log(err); + }); + }, + openImportStock() { + this.importModal = true; + }, + // 上传数据 + handleUpload(file) { + this.file = file; + this.upload(); + return false; + }, + /** + * 上传文件 + */ + upload() { + let fd = new FormData(); + fd.append("files", this.file); + this.spinShow = true; + + importStockExcel(fd).then(res => { + if (res.success) { + this.spinShow = false; + this.$Message.success("导入成功"); + this.importModal = false; + this.getDataList(); + } + }) + }, + }, + mounted() { + this.init(); + }, +}; + +