002390 1 éve
szülő
commit
488ce5e225

+ 28 - 0
src/api/changeApply/basic.js

@@ -70,3 +70,31 @@ export function getRecordList(params) {
     params: params
   })
 }
+
+// 模板下载
+export function changeDownload(data) {
+  return request({
+    url: `/material/change/download`,
+    method: 'post',
+    data: data
+  })
+}
+
+// 导入
+export function changeImport(data) {
+  return request({
+    url: `/material/change/import`,
+    method: 'post',
+    data: data
+  })
+}
+
+// 下载失败导入文件数据
+export function downloadFailData(data) {
+  return request({
+    url: `/material/change/downloadFailData`,
+    method: 'post',
+    data: data,
+    responseType: 'blob',
+  })
+}

+ 45 - 39
src/views/material/changeApply/batchImport/index.vue

@@ -1,5 +1,6 @@
 <script>
 import { importData, fileImport} from '@/api/requisition/basic';
+import { changeImport, downloadFailData} from '@/api/changeApply/basic';
 export default {
   name:'BatchImport',
   props:{},
@@ -7,52 +8,57 @@ export default {
     return {
       title:'批量导入',
       visible:false,
-      fileData:[]
+      fileData:[],
+      size:'mini',
     }
   },
   methods:{
-    beforeColse(){},
+    beforeColse(done){
+      this.cancal();
+      done();
+
+    },
     handleClick(){
       this.visible = true;
     },
     confirmUpdate(){
-  if (this.fileData.length) {
+      if (this.fileData.length) {
 
-    let formData = new FormData();
+        let formData = new FormData();
 
-    formData.append('file', this.fileData[0].raw);
-    importData(formData).then(res => {
-      if (res.code == 200) {
-        this.visible = false;
-        this.fileData = [];
-        if (res.data.flag) {
-          this.failLoad = true;
-          console.log(res.data.datas)
-          let param = {failDatas: res.data.datas}
-          if (null != param) {
+        formData.append('file', this.fileData[0].raw);
+        importData(formData).then(res => {
+          if (res.code == 200) {
+            this.visible = false;
+            this.fileData = [];
+            if (res.data.flag) {
+              this.failLoad = true;
+              console.log(res.data.datas)
+              let param = {failDatas: res.data.datas}
+              if (null != param) {
 
-            fileImport(param).then(res => {
-              console.log('res',res)
-              const isBlob = blobValidate(res);
-              if (isBlob) {
-                const blob = new Blob([res]);
-                saveAs(blob, '导入失败的物料申请单数据.xlsx');
+                fileImport(param).then(res => {
+                  console.log('res',res)
+                  const isBlob = blobValidate(res);
+                  if (isBlob) {
+                    const blob = new Blob([res]);
+                    saveAs(blob, '导入失败的物料申请单数据.xlsx');
+                  }
+                  this.failLoad = false;
+                })
               }
-              this.failLoad = false;
-            })
+            }
+            this.$notify({
+              message: res.data.msg,
+              type: res.data.flag ? 'warning' : 'success'
+            });
+          } else {
+            this.$notify({
+              message: res.msg,
+              type: res.code == 200 ? 'success' : 'warning'
+            });
           }
-        }
-        this.$notify({
-          message: res.data.msg,
-          type: res.data.flag ? 'warning' : 'success'
-        });
-      } else {
-        this.$notify({
-          message: res.msg,
-          type: res.code == 200 ? 'success' : 'warning'
-        });
-      }
-    })
+        })
       } else {
       this.$notify({
         title:'警告',
@@ -96,7 +102,7 @@ export default {
       append-to-body
       :before-close="beforeColse"
     >
-      <div>
+      <div style="display: flex;justify-content: center;">
         <el-upload 
           accept=".xls, .xlsx" 
           ref="upload" 
@@ -107,10 +113,10 @@ export default {
           :on-change="handleChangeFile" 
           :limit="1"
         >
-          <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
+          <el-button slot="trigger" :size="size" type="primary">选取文件</el-button>
           <el-button 
             style="margin-left: 10px;" 
-            size="small" 
+            :size="size"
             type="success"
             @click="handleDownTemplate"
           >下载模板
@@ -120,8 +126,8 @@ export default {
 
       </div>
       <span slot="footer">
-        <el-button @click="cancal">取 消</el-button>
-        <el-button type="primary" @click="confirmUpdate">确 定</el-button>
+        <el-button :size="size" @click="cancal">取 消</el-button>
+        <el-button type="primary" :size="size" @click="confirmUpdate">确 定</el-button>
       </span>
     </el-dialog>
   </el-button>

+ 3 - 2
src/views/material/changeApply/index.vue

@@ -40,8 +40,8 @@
         style="margin-top: 20px;"
       >
         <el-col :span="1.5">
-          <el-button type="primary" size="small" @click="newAdd">新增</el-button>
-          
+          <el-button type="primary" size="mini" @click="newAdd">新增</el-button>
+          <!-- <BatchImport></BatchImport> -->
         </el-col>
       </el-row>
 
@@ -79,6 +79,7 @@ export default {
   components: {
     AddChangeOrders:() => import('./add/index.vue'),
     SeeChangeOrders:() => import('./see/index.vue'),
+    BatchImport:() => import('./batchImport/index.vue'),
     ElSuperTable: () => import("@/components/super-table/index.vue"),
     ElSuperSearch: () => import("@/components/super-search/index.vue"),
   },