Ver Fonte

1、新增文件导入整体处理组件页面。
2、新增组织架构数据导入功能

mazheng há 1 ano atrás
pai
commit
aba5e94139

+ 20 - 1
src/api/system/file/index.js

@@ -16,7 +16,7 @@ export async function uploadFile (data) {
   return Promise.reject(new Error(res.data.message));
 }
 /**
- * 上传文件 批量
+ * 导入文件 批量
  * @param file 文件
  */
 export async function uploadBatch (data) {
@@ -83,3 +83,22 @@ export async function getFileList (data) {
   }
   return Promise.reject(new Error(res.data.message));
 }
+
+/**
+ * 导入文件 批量
+ * @param file 文件
+ */
+export async function importBatch (data) {
+  const formData = new FormData();
+  data.multiPartFiles.forEach((item, index) => {
+    formData.append(`multiPartFiles`, item);
+  });
+  const res = await request.post(
+    `/main/file/importBatch?module=${data.module}`,
+    formData
+  );
+  if (res.data.code === '0') {
+    return res.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 120 - 0
src/components/upload/import-dialog.vue

@@ -0,0 +1,120 @@
+<template>
+  <!-- 上传 -->
+  <el-dialog title="导入文件上传" :visible.sync="dialogVisible" width="40%">
+    <el-form label-width="110px" class="zw-criterion">
+      <el-form-item label="选择文件">
+        <el-upload
+          class="avatar-uploader"
+          action="#"
+          :show-file-list="false"
+          :http-request="handlSuccess"
+          :before-upload="beforeUpload"
+        >
+          <el-button icon="el-icon-plus" size="small" type="primary"
+            >文件上传</el-button
+          >
+          <div slot="tip" class="el-upload__tip"
+            >只能上传excel文件,或批量上传打包成zip、rar压缩文件,单文件不超过10mb</div
+          >
+        </el-upload>
+      </el-form-item>
+      <el-form-item label="上传列表">
+        <div class="imgs-box">
+          <p v-for="(item, index) in attaments" :key="index" class="imgs-p">
+            <span> {{ item.name }}</span>
+            <el-link @click="delFileList(index)" type="primary">删除</el-link>
+          </p>
+        </div>
+      </el-form-item>
+    </el-form>
+    <div slot="footer" class="dialog-footer">
+      <el-button size="small" @click="dialogVisible = false">关 闭</el-button>
+      <el-button size="small" @click="upload" type="primary">上 传</el-button>
+    </div>
+  </el-dialog>
+</template>
+
+<script>
+  import { importBatch } from '@/api/system/file/index.js';
+
+  export default {
+    props: {
+      // eslint-disable-next-line vue/require-prop-type-constructor
+      defModule: ''
+    },
+    //注册组件
+    data() {
+      return {
+        showViewer: false, // 显示查看器
+        dialogVisible: false,
+        uploadShow: false,
+        module: '',
+        attaments: [], //上传文件
+        file: ''
+      };
+    },
+    created() {},
+    methods: {
+      open() {
+        this.attaments = [];
+        this.module = '';
+        this.dialogVisible = true;
+      },
+      //删除附件
+      delFileList(index) {
+        this.attaments.splice(index, 1);
+      },
+      //上传限制
+      beforeUpload(file) {
+        const isLt10M = file.size / 1024 / 1024 < 10;
+        if (!isLt10M) {
+          this.$message.error('导入单文件大小不能超过 10MB!');
+        }
+        return isLt10M;
+      },
+      //图片上传
+      handlSuccess(param) {
+        this.file = param.file;
+        this.attaments.push(param.file);
+      },
+      // 文件上传
+      async upload() {
+        if (this.attaments.length == 0) {
+          return this.$message.warning('文件不能为空!');
+        }
+        this.module = this.$props.defModule;
+
+        await importBatch({
+          module: this.module,
+          multiPartFiles: this.attaments
+        });
+        this.$message.success('操作成功!');
+        this.dialogVisible = false;
+        this.$emit('success');
+      }
+    }
+  };
+</script>
+
+<style lang="scss">
+  .zw-table-header {
+    float: right;
+  }
+
+  .imgs-box .imgs-p {
+    height: 30px;
+    background: #f0f3f3;
+    line-height: 30px;
+    width: 372px;
+    margin-bottom: 5px;
+    padding: 0 10px;
+    display: flex;
+    justify-content: space-between;
+  }
+  .zw-criterion-normal {
+    padding: 20px 0 0 0;
+  }
+  .el-main {
+    overflow: hidden;
+  }
+</style>

+ 117 - 0
src/views/classifyManage/treeClassify/components/upload-dialog.vue

@@ -0,0 +1,117 @@
+<template>
+  <!-- 上传 -->
+  <el-dialog title="导入文件上传" :visible.sync="dialogVisible" width="40%">
+    <el-form label-width="110px" class="zw-criterion">
+      <el-form-item label="选择文件">
+        <el-upload
+          class="avatar-uploader"
+          action="#"
+          :show-file-list="false"
+          :http-request="handlSuccess"
+          :before-upload="beforeUpload"
+        >
+          <el-button icon="el-icon-plus" size="small" type="primary"
+            >文件上传</el-button
+          >
+          <div slot="tip" class="el-upload__tip">只能上传excel文件,或批量上传打包成zip、rar压缩文件,单文件不超过10mb</div>
+        </el-upload>
+      </el-form-item>
+      <el-form-item label="上传列表">
+        <div class="imgs-box">
+          <p v-for="(item, index) in attaments" :key="index" class="imgs-p">
+            <span> {{ item.name }}</span>
+            <el-link @click="delFileList(index)" type="primary">删除</el-link>
+          </p>
+        </div>
+      </el-form-item>
+    </el-form>
+    <div slot="footer" class="dialog-footer">
+      <el-button size="small" @click="dialogVisible = false">关 闭</el-button>
+      <el-button size="small" @click="upload" type="primary">上 传</el-button>
+    </div>
+  </el-dialog>
+</template>
+
+<script>
+import {importBatch, uploadBatch} from '@/api/system/file/index.js';
+
+  export default {
+    props: {
+      defModule: ''
+    },
+    //注册组件
+    data () {
+      return {
+        showViewer: false, // 显示查看器
+        dialogVisible: false,
+        uploadShow: false,
+        module: '',
+        attaments: [], //上传文件
+        file: ''
+      };
+    },
+    created () {},
+    methods: {
+      open () {
+        this.attaments = [];
+        this.module = '';
+        this.dialogVisible = true;
+      },
+      //删除附件
+      delFileList (index) {
+        this.attaments.splice(index, 1);
+      },
+      //上传限制
+      beforeUpload (file) {
+        const isLt10M = file.size / 1024 / 1024 < 10;
+        if (!isLt10M) {
+          this.$message.error('上传文件大小不能超过 10MB!');
+        }
+        return isLt10M;
+      },
+      //图片上传
+      handlSuccess (param) {
+        this.file = param.file;
+        this.attaments.push(param.file);
+      },
+      // 文件上传
+      async upload () {
+        if (this.attaments.length == 0) {
+          return this.$message.warning('文件不能为空!');
+        }
+        this.module = this.$props.defModule;
+
+        await importBatch({
+          module: this.module,
+          multiPartFiles: this.attaments
+        });
+        this.$message.success('操作成功!');
+        this.dialogVisible = false;
+        this.$emit('success');
+      }
+    }
+  };
+</script>
+
+<style lang="scss">
+  .zw-table-header {
+    float: right;
+  }
+
+  .imgs-box .imgs-p {
+    height: 30px;
+    background: #f0f3f3;
+    line-height: 30px;
+    width: 372px;
+    margin-bottom: 5px;
+    padding: 0 10px;
+    display: flex;
+    justify-content: space-between;
+  }
+  .zw-criterion-normal {
+    padding: 20px 0 0 0;
+  }
+  .el-main {
+    overflow: hidden;
+  }
+</style>

+ 19 - 4
src/views/classifyManage/treeClassify/index.vue

@@ -14,7 +14,15 @@
           >
             新建
           </el-button>
-        </template> 
+          <!--<el-button
+            size="small"
+            icon="el-icon-upload"
+            class="ele-btn-icon"
+            @click="uploadFile()"
+          >
+            导入
+          </el-button>-->
+        </template>
         <!-- 操作列 -->
         <template v-slot:action="{ row }">
 
@@ -30,7 +38,7 @@
           <el-link
             type="primary"
             :underline="false"
-           
+
             @click="junmpEdit(row)"
           >
            下级分类
@@ -51,17 +59,21 @@
     </el-card>
 
     <list-edit ref="editRef" @done="reload" />
+    <importDialog :defModule="moudleName" ref="importDialogRef" @success="reload" />
   </div>
 </template>
 <script>
   import ListEdit from './components/list-edit.vue';
   import ClassifyManageSearch from './components/classifyManageSearch.vue';
+  import importDialog from "@/components/upload/import-dialog.vue";
+
   import { getSubPage, deleteCategory } from '@/api/classifyManage';
   export default {
-    components: { ClassifyManageSearch, ListEdit },
+    components: { ClassifyManageSearch, ListEdit, importDialog},
     data () {
       return {
         editData: null,
+        moudleName : "mainCategoryLevel",
         columns: [
           {
             prop: 'code',
@@ -135,7 +147,10 @@
             id
           }
         });
-      }
+      },
+      uploadFile () {
+        this.$refs.importDialogRef.open();
+      },
     }
   };
 </script>

+ 11 - 1
src/views/enterpriseModel/dept/index.vue

@@ -30,6 +30,7 @@
           <el-button class="ele-btn-icon" size="small" @click="foldAll">
             折叠全部
           </el-button>
+          <el-button type="primary" size="mini" icon="el-icon-upload2" plain @click="uploadFile">导入</el-button>
         </template>
         <!-- 标题列 -->
         <template v-slot:name="{ row }">
@@ -103,12 +104,16 @@
       :organization-list="data"
       @done="reload"
     />
+
+    <importDialog :defModule="moudleName" ref="importDialogRef" @success="reload" />
   </div>
 </template>
 
 <script>
 
 import OrgEdit from './components/org-edit.vue';
+import importDialog from "@/components/upload/import-dialog.vue";
+
 import {
   listOrganizations,
   removeOrganization
@@ -116,9 +121,11 @@ import {
 
 export default {
   name: 'SystemOrganization',
-  components: {OrgEdit},
+  components: {OrgEdit, importDialog},
   data() {
     return {
+      //模块名称
+      moudleName : "mainGroup",
       // 加载状态
       loading: false,
       // 列表数据
@@ -263,6 +270,9 @@ export default {
         })
         .catch(() => {
         });
+    },
+    uploadFile () {
+      this.$refs.importDialogRef.open();
     }
   }
 };

+ 2 - 2
vue.config.js

@@ -31,9 +31,9 @@ module.exports = {
     proxy: {
       // 当我们的本地的请求 有/api的时候,就会代理我们的请求地址向另外一个服务器发出请求
       '/api': {
-        // target: 'http://124.71.68.31:50001',
+        // target: 'http://192.168.1.124:50001',
         // target: 'http://192.168.1.147:18086',
-        target: 'http://192.168.1.125:18086',
+        target: 'http://localhost:18086',
         changeOrigin: true, // 只有这个值为true的情况下 才表示开启跨域
         pathRewrite: {
           '^/api': ''