wenhongquan 2 лет назад
Родитель
Сommit
d481568ff6
2 измененных файлов с 29 добавлено и 2 удалено
  1. 15 0
      src/api/system/facilities.js
  2. 14 2
      src/views/system/facilities/index.vue

+ 15 - 0
src/api/system/facilities.js

@@ -50,3 +50,18 @@ export function delFacilities(id) {
         method: 'delete'
     })
 }
+
+
+export function uploadFacilities(files) {
+
+  const form = new FormData();
+  form.append('file', files);
+  return request({
+    url: "/system/facilities/upload",
+    method: "post",
+    headers: {
+      "Content-Type": "multipart/form-data",
+    },
+    data: form,
+  });
+}

+ 14 - 2
src/views/system/facilities/index.vue

@@ -105,11 +105,13 @@
             </el-col>
 
                 <el-col :span="1.5">
+                  <el-upload :limit="1"  v-model:file-list="fileList"  :auto-upload="false"   :on-change="inportexcel3">
                   <el-button
                    type="success"
-                      @click.stop="inportexcel3()"
+
                       >导入
                     </el-button>
+                    </el-upload>
               </el-col>
 
       <el-col :span="1.5">
@@ -449,6 +451,7 @@ import {
   delFacilities,
   addFacilities,
   updateFacilities,
+  uploadFacilities
 } from "@/api/system/facilities";
 import ImageUpload from "@/components/ImageUpload";
 import { useDict } from "@/utils/dict";
@@ -550,6 +553,9 @@ const facilities_obj = ref({
 
 const alldept = ref([]);
 
+const fileList = ref([])
+
+
 listDept().then((response) => {
   alldept.value = cloneDeep(response.data);
 });
@@ -663,7 +669,13 @@ const exportexcel3 = () => {
 
 }
 
-const inportexcel3 = () => {
+const inportexcel3 = (files, uploadFiles) => {
+  // console.log(files)
+  //  console.log(uploadFiles)
+  uploadFacilities(files.raw).then(() => {
+     proxy.$modal.msgSuccess("上传成功");
+    getList();
+  })
 
 }