Răsfoiți Sursa

风险监控合作企业导入

liu1tian 11 luni în urmă
părinte
comite
10ddeeb3c0

+ 11 - 1
src/api/ctyc/info.js

@@ -67,4 +67,14 @@ export function query(companyId) {
     url: '/ctyc/alog/query/' + companyId,
     method: 'get'
   })
-}
+}
+
+// 导入文件 
+export function fileImport(data) {
+  return request({
+    url: '/ctyc/info/imports',
+    method: 'post',
+    data: data
+  })
+}
+  

+ 222 - 0
src/components/BatchImport/indexa.vue

@@ -0,0 +1,222 @@
+<script>
+export default {
+  name: "BatchImport",
+  props: {
+    disabled: {
+      type: Boolean,
+      default: false,
+    },
+    limit: {
+      type: Number,
+      default: 1,
+    },
+    fileType: {
+      type: Array,
+      default: () => ["xls", "xlsx"],
+    },
+    size: {
+      type: String,
+      default: "mini",
+    },
+    isShowTip: {
+      type: Boolean,
+      default: true,
+    },
+    isTemplate: {
+      type: Boolean,
+      default: true,
+    },
+    fileSize: {
+      type: Number,
+      default: 100,
+    },
+  },
+  computed: {
+    // 是否显示提示
+    showTip() {
+      return this.isShowTip && (this.fileType || this.fileSize);
+    },
+    accept() {
+      return this.fileType.map((item) => `.${item}`).join(",");
+    },
+  },
+  data() {
+    return {
+      title: "导入",
+      visible: false,
+      loading: false,
+      fileList: [],
+      number: 0,
+    };
+  },
+  methods: {
+    // 确认上传
+    async submitUpload() {
+      if (this.fileList.length) {
+        this.$emit("import", this.fileList);
+      } else {
+        this.$notify.warning({
+          title: "警告",
+          message: "请上传文件之后在确认!",
+        });
+      }
+    },
+    // 模板下载
+    async templateDownload() {
+      this.$emit("temDownload");
+    },
+    //
+    beforeClose(done) {
+      this.fileList = [];
+      // 关闭前清空
+      done();
+    },
+    // 预览
+    handlePreview() {},
+    // 移除
+    handleRemove(file, fileList) {
+      this.fileList = fileList;
+    },
+    // 文件改变
+    onChange(file, fileList) {
+      this.fileList = fileList;
+      // 校检文件类型
+      if (this.fileType) {
+        const fileName = file.name.split(".");
+        const fileExt = fileName[fileName.length - 1];
+        console.log(fileExt, "fileExt");
+        console.log(
+          this.fileType.indexOf(fileExt),
+          "this.fileType.indexOf(fileExt)"
+        );
+        const isTypeOk = this.fileType.indexOf(fileExt) >= 0;
+        if (!isTypeOk) {
+          this.$modal.msgError(
+            `文件格式不正确, 请上传${this.fileType.join("/")}格式文件!`
+          );
+          return this.fileList.pop();
+        }
+      }
+      // 校检文件大小
+      if (this.fileSize) {
+        const isLt = file.size / 1024 / 1024 < this.fileSize;
+        if (!isLt) {
+          this.$modal.msgError(`上传文件大小不能超过 ${this.fileSize} MB!`);
+          return this.fileList.pop();
+        }
+      }
+    },
+    setVisible(prop) {
+      this.visible = prop;
+      if (!prop) {
+        this.fileList = [];
+      }
+    },
+    open() {
+      this.setVisible(true);
+    },
+    // 取消
+    cancal() {
+      this.setVisible(false);
+    },
+    // 上传前校检格式和大小
+    handleBeforeUpload(file) {
+      console.log(file, "file");
+      // 校检文件类型
+      if (this.fileType) {
+        const fileName = file.name.split(".");
+        const fileExt = fileName[fileName.length - 1];
+        console.log(fileExt, "fileExt");
+        console.log(
+          this.fileType.indexOf(fileExt),
+          "this.fileType.indexOf(fileExt)"
+        );
+        const isTypeOk = this.fileType.indexOf(fileExt) >= 0;
+        if (!isTypeOk) {
+          this.$modal.msgError(
+            `文件格式不正确, 请上传${this.fileType.join("/")}格式文件!`
+          );
+          return false;
+        }
+      }
+      // 校检文件大小
+      if (this.fileSize) {
+        const isLt = file.size / 1024 / 1024 < this.fileSize;
+        if (!isLt) {
+          this.$modal.msgError(`上传文件大小不能超过 ${this.fileSize} MB!`);
+          return false;
+        }
+      }
+      this.$modal.loading("正在上传文件,请稍候...");
+      this.number++;
+      return true;
+    },
+  },
+  created() {},
+};
+</script>
+
+<template>
+  <el-button
+    :disabled="disabled"
+    :size="size"
+    @click="open"
+    type="primary"
+    v-bind="$attrs"
+    v-on="$listeners"
+  >
+    {{ title }}
+    <el-dialog
+      :title="title"
+      :visible.sync="visible"
+      v-loading="loading"
+      width="35%"
+      center
+      :before-close="beforeClose"
+      append-to-body
+    >
+      <!-- :before-upload="handleBeforeUpload" -->
+      <el-upload
+        ref="upload"
+        action="#"
+        :on-preview="handlePreview"
+        :accept="accept"
+        :on-remove="handleRemove"
+        :file-list="fileList"
+        :auto-upload="false"
+        :on-change="onChange"
+        :limit="limit"
+        :disabled="disabled"
+        style="text-align: center"
+      >
+        <el-button slot="trigger" :size="size" type="primary"
+          >选取文件</el-button
+        >
+        <el-button
+          v-if="isTemplate"
+          style="margin-left: 10px"
+          :size="size"
+          type="success"
+          @click="templateDownload"
+          >下载模板</el-button
+        >
+        <div slot="tip" class="el-upload__tip" v-if="isShowTip">
+          请上传
+          <template v-if="fileSize">
+            大小不超过 <b style="color: #f56c6c">{{ fileSize }}MB</b>
+          </template>
+          <template v-if="fileType">
+            格式为 <b style="color: #f56c6c">{{ fileType.join("/") }}</b>
+          </template>
+        </div>
+      </el-upload>
+
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitUpload" :size="size"
+          >确 定</el-button
+        >
+        <el-button @click="cancal" :size="size">取 消</el-button>
+      </div>
+    </el-dialog>
+  </el-button>
+</template>

+ 12 - 2
src/views/ctyc/info/approval.vue

@@ -144,8 +144,8 @@
         </el-form-item>
         <el-form-item label="" prop="">
           <el-col :span="20">
-            <el-button @click="bt1()">企业信息变更({{infoForm.companyInfo.staffNum + infoForm.companyInfo.inverstNum + infoForm.companyInfo.changeinfoNum}}+ {{infoForm.companyInfo.staffAdd + infoForm.companyInfo.inverstAdd + infoForm.companyInfo.changeinfoAdd}})</el-button> 
-            <el-button @click="bt2()">法律诉讼({{infoForm.companyInfo.courtRegisterNum + infoForm.companyInfo.dishonestNum}}+{{infoForm.companyInfo.courtRegisterAdd + infoForm.companyInfo.dishonestAdd}})</el-button>
+            <el-button @click="bt1()" type="primary" :plain="bp1">企业信息变更({{infoForm.companyInfo.staffNum + infoForm.companyInfo.inverstNum + infoForm.companyInfo.changeinfoNum}}+ {{infoForm.companyInfo.staffAdd + infoForm.companyInfo.inverstAdd + infoForm.companyInfo.changeinfoAdd}})</el-button> 
+            <el-button @click="bt2()" type="primary" :plain="bp2">法律诉讼({{infoForm.companyInfo.courtRegisterNum + infoForm.companyInfo.dishonestNum}}+{{infoForm.companyInfo.courtRegisterAdd + infoForm.companyInfo.dishonestAdd}})</el-button>
           </el-col>
           <el-col :span="4">
             <el-button type="warning" @click="handleAlog()">风险审阅</el-button> <br/> <span style="margin-left:20px" @click="handleAlogInfo()">审阅记录  </span>
@@ -407,6 +407,9 @@ export default {
   name: "Info",
   data() {
     return {
+      // 按钮模拟默认点击
+      bp1: false,
+      bp2: true,
       // 详情弹出层标题
       alogInfoTitle: "",
       // 详情是否显示弹出层
@@ -600,6 +603,8 @@ export default {
         this.infoOpen = true;
         this.ef1 = true;
         this.ef2 = false;
+        this.bp1 = false;
+        this.bp2 = true;
         this.infoTitle = "审阅";
       })
     },
@@ -649,6 +654,7 @@ export default {
               addAlog(this.alogForm).then(response => {
                 this.$modal.msgSuccess("审阅提交成功");
                 this.alogOpen = false;
+                this.getList();
               });
           }else{
               this.$message.error('请选择审阅等级!');
@@ -676,10 +682,14 @@ export default {
     bt1(){
       this.ef2 = false;
       this.ef1 = true;
+      this.bp1 = false;
+      this.bp2 = true;
     },
     bt2(){
       this.ef1 = false;
       this.ef2 = true;
+      this.bp1 = true;
+      this.bp2 = false;
     }
   }
 };

+ 13 - 3
src/views/ctyc/info/approved.vue

@@ -163,10 +163,10 @@
         <el-form-item label="" prop="">
          <hr class="shr">
         </el-form-item>
-        <el-form-item label="" prop="">
+        <el-form-item label="" prop=""> 
           <el-col :span="20">
-            <el-button @click="bt1()">企业信息变更({{infoForm.companyInfo.staffNum + infoForm.companyInfo.inverstNum + infoForm.companyInfo.changeinfoNum}}+ {{infoForm.companyInfo.staffAdd + infoForm.companyInfo.inverstAdd + infoForm.companyInfo.changeinfoAdd}})</el-button> 
-            <el-button @click="bt2()">法律诉讼({{infoForm.companyInfo.courtRegisterNum + infoForm.companyInfo.dishonestNum}}+{{infoForm.companyInfo.courtRegisterAdd + infoForm.companyInfo.dishonestAdd}})</el-button>
+            <el-button @click="bt1()" type="primary" :plain="bp1">企业信息变更({{infoForm.companyInfo.staffNum + infoForm.companyInfo.inverstNum + infoForm.companyInfo.changeinfoNum}}+ {{infoForm.companyInfo.staffAdd + infoForm.companyInfo.inverstAdd + infoForm.companyInfo.changeinfoAdd}})</el-button> 
+            <el-button @click="bt2()" type="primary" :plain="bp2">法律诉讼({{infoForm.companyInfo.courtRegisterNum + infoForm.companyInfo.dishonestNum}}+{{infoForm.companyInfo.courtRegisterAdd + infoForm.companyInfo.dishonestAdd}})</el-button>
           </el-col>
           <el-col :span="4">
             <el-button type="warning" @click="handleAlog()">风险审阅</el-button> <br/> <span style="margin-left:20px" @click="handleAlogInfo()">审阅记录  </span>
@@ -428,6 +428,9 @@ export default {
   name: "Info",
   data() {
     return {
+      // 按钮模拟默认点击
+      bp1: false,
+      bp2: true,
       // 风险等级
       levelTaps: [{
           value: '',
@@ -635,6 +638,8 @@ export default {
         this.infoOpen = true;
         this.ef1 = true;
         this.ef2 = false;
+        this.bp1 = false;
+        this.bp2 = true;
         this.infoTitle = "审阅";
       })
     },
@@ -684,6 +689,7 @@ export default {
               addAlog(this.alogForm).then(response => {
                 this.$modal.msgSuccess("审阅提交成功");
                 this.alogOpen = false;
+                this.getList();
               });
           }else{
               this.$message.error('请选择审阅等级!');
@@ -711,10 +717,14 @@ export default {
     bt1(){
       this.ef2 = false;
       this.ef1 = true;
+      this.bp1 = false;
+      this.bp2 = true;
     },
     bt2(){
       this.ef1 = false;
       this.ef2 = true;
+      this.bp1 = true;
+      this.bp2 = false;
     }
   }
 };

+ 31 - 9
src/views/ctyc/info/index.vue

@@ -26,14 +26,11 @@
 
     <el-row :gutter="10" class="mb8">
       <el-col :span="1.5">
-        <el-button
-          type="warning"
-          plain
-          icon="el-icon-download"
-          size="mini"
-          @click="handleExport"
-          v-hasPermi="['ctyc:info:export']"
-        >这里有个导入还没做</el-button>
+          <BatchImport
+            ref="batchImport"
+            @import="handelImport"
+            @temDownload="handleTemDownload"
+            :fileSize="1"></BatchImport>
       </el-col>
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
     </el-row>
@@ -89,10 +86,13 @@
 </template>
 
 <script>
-import { listInfo, getInfo, delInfo, addInfo, updateInfo } from "@/api/ctyc/info";
+import { listInfo, getInfo, delInfo, addInfo, updateInfo, fileImport } from "@/api/ctyc/info";
 
 export default {
   name: "Info",
+  components: {
+    BatchImport: () => import("@/components/BatchImport/indexa.vue"),
+  },
   data() {
     return {
       // 遮罩层
@@ -141,6 +141,28 @@ export default {
     this.getList();
   },
   methods: {
+    // 确认导入
+    handelImport(fileList) {
+      this.$modal.loading("加载中...");
+      let formData = new FormData();
+      formData.append("file", fileList[0].raw);
+      fileImport(formData).then((res) => {
+        if (res.code == 200) {
+          this.$modal.closeLoading();
+          this.$notify({
+            message: res.msg,
+            type: res.code == 200 ? "success" : "warning",
+          });
+          let { setVisible } = this.$refs.batchImport;
+          setVisible(false);
+          this.getList();
+        }
+      });
+    },
+    // 模板下载
+    handleTemDownload() {
+      this.download("/ctyc/info/download", {}, `合作企业.xlsx`);
+    },
     /** 查询合作企业列表 */
     getList() {
       this.loading = true;