Przeglądaj źródła

批量导入静态页面

natasha 2 lat temu
rodzic
commit
4eebf727c3

+ 3 - 0
src/icons/svg/pause-fill.svg

@@ -0,0 +1,3 @@
+<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M3.5 2.91602H4.66667V11.0827H3.5V2.91602ZM9.33333 2.91602H10.5V11.0827H9.33333V2.91602Z" fill="currentColor"/>
+</svg>

+ 8 - 0
src/styles/index.scss

@@ -433,6 +433,10 @@ div:focus {
     border-color: #165DFF;
 }
 
+.el-checkbox__input.is-checked+.el-checkbox__label {
+    color: #165DFF;
+}
+
 .el-button--primary {
     background: #165DFF;
     border-color: #165DFF;
@@ -507,4 +511,8 @@ div:focus {
 
 ::-webkit-scrollbar {
     display: none;
+}
+
+.el-progress-bar__inner {
+    background-color: #165DFF;
 }

+ 334 - 0
src/views/organize_manage/BatchImport.vue

@@ -0,0 +1,334 @@
+<template>
+  <div class="batch-box">
+    <div class="batch-box-top tabs">
+        <a :class="[tabsIndex===0?'active':'']" @click="handleChangeTabs(0)">批量上传</a>
+        <a :class="[tabsIndex===1?'active':'']" @click="handleChangeTabs(1)">日志</a>
+    </div>
+    <div class="batch-box-center">
+        <template v-if="tabsIndex===0">
+            <div class="upload-box" v-if="!alreadyFile">
+                <el-upload
+                    class="upload-demo"
+                    :accept="'.xls,.xlsx'"
+                    :limit="1"
+                    :on-progress="uploadVideoProcess"
+                    :before-upload="handlebeforeUpload"
+                    :on-success="handleSuccess"
+                    drag
+                    :action="url"
+                    :show-file-list="false"
+                    multiple>
+                    <div class="el-upload__text">
+                        点击或拖拽文件到此处上传
+                        <span>只有 xlsx, xls 格式文件可以上传,文件大小不得超过 100MB</span>
+                    </div>
+                </el-upload>
+            </div>
+            <template v-else>
+                <div class="file-top">
+                    <div class="file-content">
+                        <svg-icon icon-class="xlsx"></svg-icon>
+                        <div class="file">
+                            <p>{{fileList[0].name}}</p>
+                            <el-progress v-if="progressFlag" :percentage="percentage" :show-text="false"></el-progress>
+                            <b>{{fileList[0].fileSize}}</b>
+                        </div>
+                    </div>
+                    <i class="el-icon-error" @click="handleErmoveFile"></i>
+                </div>
+                <div class="file-bottom">
+                    <p>批量上传内容与系统中有重复时</p>
+                    <el-radio-group v-model="sameUser">
+                        <el-radio label="false">跳过</el-radio>
+                        <el-radio label="true">覆盖</el-radio>
+                    </el-radio-group>
+                    <el-checkbox-group v-model="coverUser">
+                        <el-checkbox label="1">覆盖时忽略密码</el-checkbox>
+                        <el-checkbox label="2">上传完成后自动导出密码文件</el-checkbox>
+                    </el-checkbox-group>
+                </div>
+            </template>
+        </template>
+    </div>
+    <div class="batch-box-bottom">
+        <template v-if="tabsIndex===0">
+            <a class="downLoad">下载模板</a>
+            <div class="btn-box">
+                <el-button @click="closeDialog" size="small">取消</el-button>
+                <el-button type="primary" :disabled="!uploadFlag" v-if="!uploading&&!isStop"><svg-icon icon-class="upload"></svg-icon>开始上传</el-button>
+                <el-button type="primary" v-if="uploading&&!isStop"><svg-icon icon-class="pause-fill"></svg-icon>暂停</el-button>
+                <el-button type="warning" v-if="isStop"><i class="el-icon-refresh-right"></i>重试</el-button>
+            </div>
+        </template>
+        <template v-else>
+            <div class="btn-box" style="flex:1">
+                <el-button type="primary"><svg-icon icon-class="upload"></svg-icon>导出日志</el-button>
+            </div>
+        </template>
+    </div>
+  </div>
+</template>
+
+<script>
+import { getToken } from "../../utils/auth";
+export default {
+  components: {},
+  name: "batchImport",
+  props: [""],
+  data() {
+    return {
+      tabsIndex: 0,
+      alreadyFile: false, // 上传了需要解析的文件
+      file_id: '',
+      uploadFlag: false, // 是否可以点击开始上传按钮
+      uploading: false, // 上传中
+      isStop: false, // 暂停
+      fileList: [],
+      sameUser: 'false', // 存在相同的用户是否覆盖, true 覆盖,false 跳过。
+      coverUser: [], // 覆盖用户时是否更新用户密码, true 更新,false 不更新。
+      progressFlag:true,
+      percentage:0
+    };
+  },
+  watch: {},
+  computed: {
+    url() {
+      let userInfor = getToken();
+      let access_token = "";
+      if (userInfor) {
+        let user = JSON.parse(getToken());
+        access_token = user.access_token;
+      }
+      return (
+        process.env.VUE_APP_BASE_API +
+        "/FileServer/WebFileUpload?AccessToken=" +
+        access_token +
+        "&SecurityLevel=High"
+      );
+    },
+  },
+  methods: {
+    handleChangeTabs(value){
+        this.tabsIndex = value
+    },
+    closeDialog(){
+        this.$emit("closeDialog")
+    },
+    handlebeforeUpload(file) {
+      if (file.size > 100 * 1024 * 1024) {
+        this.$message.warning('上传文件大小不能超过100M');
+        return false; // 必须返回false
+      }
+      this.alreadyFile = true
+    },
+    handleSuccess(response, file, fileList) {
+      if (response.status == 1) {
+        this.$message.success("用户上传成功");
+        this.file_id = response.file_info_list[0].file_id
+        this.uploadFlag = true
+        this.fileList = fileList
+        this.fileList.forEach((item) => {
+            if (item.size > 1000 * 1000) {
+              if (item.size / 1000 / 1000 / 1000 > 1) {
+                item.fileSize =
+                  (item.size / 1000 / 1000 / 1000).toFixed(2) + "GB";
+              } else {
+                item.fileSize =
+                  (item.size / 1000 / 1000).toFixed(2) + "MB";
+              }
+            } else {
+              item.fileSize = (item.size / 1000).toFixed(2) + "KB";
+            }
+          });
+      } else {
+        this.fileList = [];
+        this.file_id = ''
+        this.uploadFlag = false
+        this.$message.warning(response.msg);
+        this.alreadyFile = false
+      }
+    },
+    handleErmoveFile(){
+        this.file_id = ''
+        this.uploadFlag = false
+        this.fileList = []
+        this.alreadyFile = false
+    },
+    uploadVideoProcess(event, file, fileList) {
+        // this.fileList = fileList
+        // this.progressFlag = true; // 显示进度条
+        // this.percentage = parseInt(event.percent); // 动态获取文件上传进度
+        // if (this.percentage >= 100) {
+        //     this.percentage = 100
+        //     setTimeout( () => {this.progressFlag = false}, 100) // 关闭进度条
+        // }
+    },
+  },
+  created() {
+  },
+  mounted() {
+  },
+  beforeDestroy() {
+  },
+};
+</script>
+
+<style lang="scss" scoped>
+.batch-box{
+    height: 358px;
+    background: #FFFFFF;
+    &-top{
+        height: 56px;
+        border-bottom: 1px solid rgba(0,0,0,0.08);
+    }
+    &-center{
+        height: 233px;
+        overflow: auto;
+    }
+    &-bottom{
+        height: 64px;
+        border-top: 1px solid rgba(0,0,0,0.08);
+        display: flex;
+        justify-content: space-between;
+        align-items: center;
+        padding: 16px 24px;
+        .btn-box{
+            display: flex;
+            align-items: center;
+            justify-content: center;
+            .el-button{
+                font-size: 14px;
+                padding: 5px 16px;
+                height: 32px;
+                .svg-icon,.el-icon-refresh-right{
+                    margin-right: 8px;
+                }
+                &.el-button--warning{
+                    background: #FF802B;
+                    border: none;
+                }
+            }
+        }
+    }
+    .tabs{
+        display: flex;
+        padding: 12px 0;
+        justify-content: center;
+        a{
+            font-size: 14px;
+            line-height: 22px;
+            color: #4E5969;
+            border-radius: 100px;
+            padding: 5px 16px;
+            margin-right: 12px;
+            &:hover{
+                background: #F2F3F5;
+            }
+            &.active{
+                background: #F2F3F5;
+                font-weight: 500;
+                color: #165DFF;
+            }
+        }
+    }
+    .downLoad{
+        color: #000;
+        font-size: 14px;
+        line-height: 22px;
+        &:hover{
+            color: #165DFF;
+        }
+    }
+    .upload-box{
+        background: #F5F5F5;
+        padding: 24px;
+        height: 233px;
+    }
+    .file-top{
+        height: 88px;
+        padding: 24px 24px 0 24px;
+        background: #F5F5F5;
+        display: flex;
+        .file-content{
+            flex: 1;
+            display: flex;
+            .file{
+                margin-left: 16px;
+                flex: 1;
+                b{
+                    font-size: 12px;
+                    font-style: normal;
+                    font-weight: 600;
+                    line-height: 14px;
+                    color: #242634;
+                }
+            }
+            p{
+                margin: 0 0 8px 0;
+                font-size: 14px;
+                font-weight: 500;
+                line-height: 16px;
+                color: #242634;
+            }
+        }
+        .el-icon-error{
+            width: 16px;
+            height: 16px;
+            color: #CCCCCC;
+            cursor: pointer;
+            margin: 11px 0 0 14px;
+        }
+    }
+    .file-bottom{
+        padding: 24px 24px 0 24px;
+        p{
+            margin: 0 0 8px 0;
+            font-size: 14px;
+            line-height: 22px;
+            color: #4E5969;
+        }
+        .el-radio-group,.el-checkbox-group{
+            padding: 5px 0;
+            margin-bottom: 8px;
+        }
+        .el-radio{
+            margin-right: 24px;
+        }
+        .el-checkbox{
+            margin-right: 16px;
+        }
+        .el-checkbox:last-of-type{
+            margin-right: 0;
+        }
+    }
+    .el-progress{
+        margin-bottom: 8px;
+    }
+}
+</style>
+<style lang="scss">
+.upload-box{
+    .el-upload,.el-upload-dragger{
+        width: 100%;
+    }
+    .el-upload-dragger{
+        background: #F5F5F5;
+        border-radius: 24px;
+        padding: 24px;
+        border: 2px dashed var(--grey-03, #E2E6EA);
+        display: flex;
+        align-items: center;
+        font-weight: 400;
+        line-height: 22px;
+        font-size: 14px;
+        color: #000;
+        span{
+            display: block;
+            font-size: 12px;
+            color: #86909C;
+            font-size: 12px;
+            line-height: 20px;
+        }
+    }
+}
+</style>

+ 27 - 2
src/views/organize_manage/PersonList.vue

@@ -9,7 +9,7 @@
                 <div class="common-title-box">
                     <h3>{{orgName}}<span class="total-number">共488人</span></h3>
                     <div class="btn-box">
-                        <el-button type="primary" size="small" @click="handleEdit">批量导入</el-button>
+                        <el-button type="primary" size="small" @click="handleBatchImport">批量导入</el-button>
                     </div>
                 </div>
                 <div class="tabs">
@@ -294,6 +294,16 @@
             </div>
         </div>
     </div>
+    <el-dialog
+        :visible.sync="importFlag"
+        :show-close="false"
+        :close-on-click-modal="false"
+        :modal-append-to-body="false"
+        width="398px"
+        class="login-dialog person-dialog"
+        v-if="importFlag">
+        <batch-import @closeDialog="closeDialog"></batch-import>
+    </el-dialog>
   </div>
 </template>
 
@@ -303,13 +313,14 @@
 import Header from "../../components/Header.vue";
 import NavMenu from "../../components/NavMenu.vue"
 import Breadcrumb from '../../components/Breadcrumb.vue';
+import BatchImport from './BatchImport.vue'
 import {
   provinceAndCityData
 } from "element-china-area-data";
 
 export default {
   //import引入的组件需要注入到对象中才能使用
-  components: { Header, NavMenu, Breadcrumb },
+  components: { Header, NavMenu, Breadcrumb, BatchImport },
   props: {},
   data() {
     //这里存放数据
@@ -545,6 +556,7 @@ export default {
         tabsIndex:0,
         pageSizes: window.localStorage.getItem('pageSize-check')?Number(window.localStorage.getItem('pageSize-check')):10, 
         pageNumbers: window.localStorage.getItem('pageNumber-check')?Number(window.localStorage.getItem('pageNumber-check')):1,
+        importFlag: false, // 批量导入flag
     }
   },
   //计算属性 类似于data概念
@@ -653,6 +665,14 @@ export default {
         this.tabsIndex = value
         this.pageNumber = 1
     },
+    // 批量导入
+    handleBatchImport(){
+        this.importFlag = true
+    },
+    // 关闭批量导入
+    closeDialog(){
+        this.importFlag = false
+    }
   },
   //生命周期 - 创建完成(可以访问当前this实例)
   created() {
@@ -779,4 +799,9 @@ export default {
         }
     }
 }
+.person-dialog{
+    .el-dialog{
+        border-radius: 8px;
+    }
+}
 </style>