From 2d8e2c3c2b15e1425ab2b5e5816ff37c7096fdcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BE=99=E8=BF=90=E6=A8=A1?= <1724894114@qq.com> Date: Wed, 9 Apr 2025 20:08:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=85=8D=E4=BB=B6=E6=95=85?= =?UTF-8?q?=E9=9A=9C=E7=8E=87=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/model/setup.js | 14 +++++++ src/components/scImport/index.vue | 2 +- .../setting/advanced/setup/spareParts.vue | 39 +++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) diff --git a/src/api/model/setup.js b/src/api/model/setup.js index 3498a39..3f24bd7 100644 --- a/src/api/model/setup.js +++ b/src/api/model/setup.js @@ -285,6 +285,20 @@ export default { return await http.post(this.url, data); }, }, + import:{ + url: `${config.API_URL}/spare.parts.failure.rate.batch.import`, + name: "备件故障导入", + post: async function (params) { + return await http.post(this.url,params,{'Content-Type': 'multipart/form-data'}); + } + }, + template:{ + url: `${config.API_URL}/spare.parts.failure.rate.import.template`, + name: "备件故障率导入模版", + post: async function (params) { + return await http.get(this.url,params,{responseType: 'arraybuffer'}); + } + }, }, bom:{ list:{ diff --git a/src/components/scImport/index.vue b/src/components/scImport/index.vue index e03ca72..793fe4d 100644 --- a/src/components/scImport/index.vue +++ b/src/components/scImport/index.vue @@ -112,7 +112,7 @@ export default { }, methods:{ getWsResult(res){ - if(res.data && (res.data.type == 4 || res.data.type == 5 || res.data.type == 10 || res.data.type == 17 || res.data.type == 18 || res.data.type == 27 || res.data.type == 28 || res.data.type == 31 || res.data.type == 42 || res.data.type == 44 || res.data.type == 45)){ + if(res.data && (res.data.type == 4 || res.data.type == 5 || res.data.type == 10 || res.data.type == 17 || res.data.type == 18 || res.data.type == 27 || res.data.type == 28 || res.data.type == 31 || res.data.type == 42 || res.data.type == 44 || res.data.type == 45 || res.data.type == 48)){ if(this.type == res.data.type){ this.importInfo = res.data; this.progressShow = true; diff --git a/src/views/setting/advanced/setup/spareParts.vue b/src/views/setting/advanced/setup/spareParts.vue index e678663..3bd47d3 100644 --- a/src/views/setting/advanced/setup/spareParts.vue +++ b/src/views/setting/advanced/setup/spareParts.vue @@ -5,6 +5,14 @@
新增 + + + +
@@ -45,6 +53,7 @@ export default { data(){ return{ size:'small', + httpDisabled:false, setMap:{ }, @@ -73,6 +82,36 @@ export default { handleSuccess(){ this.$refs.table.refresh() }, + // 批量导入 + importFile(){ + this.$nextTick(()=>{ + this.$refs.scImport.importFile(); + }) + }, + async importTemplate() { + const res = await this.$API.setup.spare.template.post(); + const blob = new Blob([res]); + const text = new Date().getTime(); + const eLink = document.createElement('a'); + eLink.download = "配件故障率配置模版_"+text+'.xlsx'; + eLink.style.display = 'none'; + eLink.href = URL.createObjectURL(blob); + document.body.appendChild(eLink); + eLink.click(); + URL.revokeObjectURL(eLink.href); + document.body.removeChild(eLink); + }, + async importUpload(params) { + this.httpDisabled = true; + const res = await this.$API.setup.spare.import.post(params); + if(res.code == 200){ + this.$message.success('上传成功,开始导入数据'); + } + }, + importSuccess(){ + this.httpDisabled = false; + this.$refs.table.refresh() + }, //表格选择后回调事件 selectionChange(selection){ this.selection = selection;