From c4e67a8942e514b65ab41bb19781d50576c15725 Mon Sep 17 00:00:00 2001
From: liuyg <376836862@qq.com>
Date: Fri, 24 Sep 2021 19:56:52 +0800
Subject: [PATCH] 用户

---
 src/views/securityEquipment/equipments.vue |  120 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 115 insertions(+), 5 deletions(-)

diff --git a/src/views/securityEquipment/equipments.vue b/src/views/securityEquipment/equipments.vue
index 2373581..1d7800b 100644
--- a/src/views/securityEquipment/equipments.vue
+++ b/src/views/securityEquipment/equipments.vue
@@ -25,8 +25,34 @@
             @click="handleDelete"
             >删 除
           </el-button>
+          <el-button
+            type="success"
+            size="small"
+            plain
+            icon="el-icon-upload2"
+            @click="handleImport"
+            >批量导入
+          </el-button>
         </template>
       </avue-crud>
+      <el-dialog
+        title="装备附件批量导入"
+        append-to-body
+        :visible.sync="excelBox"
+        width="555px"
+      >
+        <avue-form
+          :option="excelOption"
+          v-model="excelForm"
+          :upload-after="uploadAfter"
+        >
+          <template slot="excelTemplate">
+            <el-button type="primary" @click="handleTemplate">
+              点击下载<i class="el-icon-download el-icon--right"></i>
+            </el-button>
+          </template>
+        </avue-form>
+      </el-dialog>
     </div>
   </basic-container>
 </template>
@@ -36,8 +62,37 @@
 import { getdata, adddata, update, remove } from "@/api/equipments/equipments";
 
 export default {
+  props: ["fromDeptId"],
   data() {
     return {
+      excelBox: false,
+      excelForm: {},
+      excelOption: {
+        submitBtn: false,
+        emptyBtn: false,
+        column: [
+          {
+            label: "文件上传",
+            prop: "excelFile",
+            type: "upload",
+            drag: true,
+            loadText: "文件上传中,请稍等",
+            span: 24,
+            propsHttp: {
+              res: "data",
+            },
+            tip: "请上传 .xls,.xlsx 标准格式文件",
+            action: "/api/equipage/import-equipage",
+          },
+          {
+            label: "模板下载",
+            prop: "excelTemplate",
+            formslot: true,
+            span: 24,
+          },
+        ],
+      },
+
       loading: true,
       selectionList: [],
       page: {
@@ -55,9 +110,11 @@
         height: 583,
         index: true,
         menuWidth: 160,
+        border: true,
         align: "center",
         selection: true,
         column: column,
+        labelWidth: 110,
       },
     };
   },
@@ -71,6 +128,18 @@
     },
   },
   methods: {
+    handleImport() {
+      this.excelBox = true;
+    },
+    uploadAfter(res, done, loading, column) {
+      window.console.log(column);
+      this.excelBox = false;
+      this.refreshChange();
+      done();
+    },
+    handleTemplate() {
+      window.open(`/api/equipage/export-template`);
+    },
     sizeChange(val) {
       this.page1.currentPage = 1;
       this.page1.pageSize = val;
@@ -87,8 +156,14 @@
       //   var form = this.data[0];
       //   delete form.id;
       //   for (var k = 0; k < 13; k++) {
-      form["deptId"] = form.tenantName;
-      delete form.tenantName;
+      // console.log(form, "12135");
+      // form["deptId"] = form.tenantName;
+      // delete form.tenantName;
+      // console.log(this.fromDeptId);
+      // console.log(form);
+      if (this.fromDeptId != undefined) {
+        form["deptId"] = this.fromDeptId;
+      }
       adddata(form).then(
         (res) => {
           this.onLoad(this.page);
@@ -106,6 +181,7 @@
       //   }
     },
     searchChange(params, done) {
+      params = JSON.parse(JSON.stringify(params));
       this.query = params;
       this.page.currentPage = 1;
       this.onLoad(this.page, params);
@@ -116,9 +192,12 @@
       this.onLoad(this.page);
     },
     rowUpdate(row, index, done, loading) {
-      // console.log(row);
-      row["deptId"] = row.tenantName;
-      delete row.tenantName;
+      // row["deptId"] = row.tenantName;
+      // delete row.tenantName;
+      // console.log(row.deptId);
+      if (this.fromDeptId != undefined) {
+        row["deptId"] = this.fromDeptId;
+      }
       update(row).then(
         () => {
           this.onLoad(this.page);
@@ -181,6 +260,37 @@
     },
     onLoad(page, params = {}) {
       this.loading = true;
+      // console.log(params.deptId);
+      if (this.fromDeptId != undefined) {
+        params["deptId"] = this.fromDeptId;
+        for (let k in this.option.column) {
+          if (this.option.column[k].prop == "deptId") {
+            this.option.column[k].search = false;
+            this.option.column[k].hide = true;
+            this.option.column[k].addDisplay = false;
+            this.option.column[k].editDisplay = false;
+          }
+        }
+        // this.option.column[4].  = false;
+        // this.option.column[6].search = false;
+        // this.option.column[6].hide = true;
+        // this.option.column[6].addDisplay = false;
+        // this.option.column[6].editDisplay = false;
+      } else {
+        for (let k in this.option.column) {
+          if (this.option.column[k].prop == "deptId") {
+            this.option.column[k].search = true;
+            this.option.column[k].hide = false;
+            this.option.column[k].addDisplay = true;
+            this.option.column[k].editDisplay = true;
+          }
+        }
+        // this.option.column[4].search = true;
+        //   this.option.column[6].search = true;
+        // this.option.column[6].hide = false;
+        // this.option.column[6].addDisplay = true;
+        // this.option.column[6].editDisplay = true;
+      }
       getdata(
         page.currentPage,
         page.pageSize,

--
Gitblit v1.9.3