From 7edeaaa39078fcbc9fc773a86aa0cc9775d48306 Mon Sep 17 00:00:00 2001
From: tangzy <tangzy123456>
Date: Tue, 16 Nov 2021 10:21:23 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 src/views/securityEquipment/gun.vue |  101 +++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 79 insertions(+), 22 deletions(-)

diff --git a/src/views/securityEquipment/gun.vue b/src/views/securityEquipment/gun.vue
index 897bc12..4a3b3db 100644
--- a/src/views/securityEquipment/gun.vue
+++ b/src/views/securityEquipment/gun.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>
@@ -41,6 +67,34 @@
   data() {
     return {
       loading: true,
+      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/gun/import-gun?deptId=" + this.deptIds,
+          },
+          {
+            label: "模板下载",
+            prop: "excelTemplate",
+            formslot: true,
+            span: 24,
+          },
+        ],
+      },
+      deptIds:"",
       selectionList: [],
       page: {
         pageSize: 10,
@@ -95,24 +149,29 @@
     }
   },
   methods: {
+    handleImport() {
+      this.excelBox = true;
+    },
+    uploadAfter(res, done, loading, column) {
+      window.console.log(column);
+      this.excelBox = false;
+      this.refreshChange();
+      done();
+    },
+    handleTemplate() {
+      window.open(`/api/gun/export-template-gun`);
+    },
     sizeChange(val) {
       this.page1.currentPage = 1;
       this.page1.pageSize = val;
       this.getData();
-      //   this.$message.success("行数" + val);
     },
     currentChange(val) {
       this.page1.currentPage = val;
       this.getData();
-      //   this.$message.success("页码" + val);
     },
     rowSave(form, done, loading) {
       var that = this;
-      //   var form = this.data[0];
-      //   delete form.id;
-      //   for (var k = 0; k < 13; k++) {
-      // form["deptId"] = form.tenantName;
-      // delete form.tenantName;
       if (this.fromDeptId != undefined) {
         form["deptId"] = this.fromDeptId;
       }
@@ -146,9 +205,6 @@
       this.onLoad(this.page);
     },
     rowUpdate(row, index, done, loading) {
-      // console.log(row);
-      // row["deptId"] = row.tenantName;
-      // delete row.tenantName;
       if (this.fromDeptId != undefined) {
         row["deptId"] = this.fromDeptId;
       }
@@ -243,17 +299,8 @@
         params["deptId"] = this.fromDeptId;
         // this.closeDep("deptId");
       } else if (this.useifid != 266) {
-        console.log(123);
+        // console.log(123);
         params["deptId"] = this.useifid;
-        // this.closeDep("deptId");
-        // for (let k in this.option.column) {
-        // if (this.option.column[k].prop == "deptId") {
-        // this.option.column[4].search = false;
-        // this.option.column[k].hide = true;
-        // this.option.column[k].addDisplay = false;
-        // this.option.column[k].editDisplay = false;
-        // }
-        // }
       } else {
         this.openDep("deptId");
       }
@@ -261,16 +308,26 @@
       if (this.userInfo.role_name == "公安管理员") {
         params["jurisdiction"] = that.userInfo.jurisdiction;
       }
+      //保安公司进入
+      if (this.userInfo.role_name == "保安公司管理员") {
+        params["deptId"] = that.userInfo.dept_id;
+        //导入action 修改
+        const importColumn = that.findObject(
+          that.excelOption.column,
+          "excelFile"
+        );
+        importColumn.action =
+          "/api/gun/import-gun?deptId=" + that.userInfo.dept_id;
+      }
       getdata(
         page.currentPage,
         page.pageSize,
         Object.assign(params, this.query)
       ).then((res) => {
-        // console.log(res);
         const data = res.data.data;
         this.page.total = data.total;
         this.data = data.records;
-        console.log(this.data);
+        // console.log(this.data);
         this.loading = false;
       });
     },

--
Gitblit v1.9.3