From 8c6cf205affbbc8ada74f00a7ca25ebca867e9ed Mon Sep 17 00:00:00 2001
From: liuyg <376836862@qq.com>
Date: Mon, 27 Sep 2021 11:44:44 +0800
Subject: [PATCH] 图表颜色

---
 src/views/securityEquipment/car.vue |  161 +++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 155 insertions(+), 6 deletions(-)

diff --git a/src/views/securityEquipment/car.vue b/src/views/securityEquipment/car.vue
index 9d99626..3ef1064 100644
--- a/src/views/securityEquipment/car.vue
+++ b/src/views/securityEquipment/car.vue
@@ -25,8 +25,35 @@
             @click="handleDelete"
             >删 除
           </el-button>
+          <el-button
+            style="display: none"
+            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>
@@ -34,10 +61,39 @@
 <script>
 import { data, column } from "./car";
 import { getdata, adddata, update, remove } from "@/api/car/car";
-
+import { mapGetters } from "vuex";
 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/car/import-examSubject",
+          },
+          {
+            label: "模板下载",
+            prop: "excelTemplate",
+            formslot: true,
+            span: 24,
+          },
+        ],
+      },
+
       loading: true,
       selectionList: [],
       page: {
@@ -52,16 +108,20 @@
         tip: false,
         index: true,
         searchSize: "mini",
+        border: true,
         searchMenuSpan: 6,
         height: 583,
         menuWidth: 160,
         align: "center",
         selection: true,
+        labelWidth: 110,
         column: column,
       },
+      useifid: 266,
     };
   },
   computed: {
+    ...mapGetters(["userInfo"]),
     ids() {
       let ids = [];
       this.selectionList.forEach((ele) => {
@@ -70,7 +130,37 @@
       return ids.join(",");
     },
   },
+  created() {
+    var that = this;
+    if (
+      this.userInfo.role_name == "装备管理员" ||
+      this.userInfo.role_name == "保安公司管理员"
+    ) {
+      this.useifid = this.userInfo.dept_id;
+    }
+    //公安局进入
+    if (this.userInfo.role_name == "公安管理员") {
+      that.option.column[4].dicUrl =
+        "/api/blade-system/dept/security_lazy-tree?parentId=1413470343230877697&jurisdiction=" +
+        that.userInfo.jurisdiction;
+    } else {
+      that.option.column[4].dicUrl =
+        "/api/blade-system/dept/security_lazy-tree?parentId=1413470343230877697";
+    }
+  },
   methods: {
+    handleImport() {
+      this.excelBox = true;
+    },
+    uploadAfter(res, done, loading, column) {
+      window.console.log(column);
+      this.excelBox = false;
+      this.refreshChange();
+      done();
+    },
+    handleTemplate() {
+      window.open(`/api/car/export-template`);
+    },
     sizeChange(val) {
       this.page1.currentPage = 1;
       this.page1.pageSize = val;
@@ -88,8 +178,15 @@
       //   delete form.id;
       //   for (var k = 0; k < 13; k++) {
       // console.log
-      form["deptId"] = form.tenantName;
-      delete form.tenantName;
+      // form["deptId"] = form.tenantName;
+      // delete form.tenantName;
+      // console.log(form);
+      if (this.fromDeptId != undefined) {
+        form["deptId"] = this.fromDeptId;
+      }
+      if (this.useifid != 266) {
+        form["deptId"] = this.useifid;
+      }
       adddata(form).then(
         (res) => {
           this.onLoad(this.page);
@@ -117,9 +214,15 @@
       this.onLoad(this.page);
     },
     rowUpdate(row, index, done, loading) {
-      console.log(row);
-      row["deptId"] = row.tenantName;
-      delete row.tenantName;
+      // console.log(row);
+      // row["deptId"] = row.tenantName;
+      // delete row.tenantName;
+      if (this.fromDeptId != undefined) {
+        row["deptId"] = this.fromDeptId;
+      }
+      if (this.useifid != 266) {
+        row["deptId"] = this.useifid;
+      }
       update(row).then(
         () => {
           this.onLoad(this.page);
@@ -180,8 +283,54 @@
     refreshChange() {
       this.onLoad(this.page, this.query);
     },
+    closeDep(name) {
+      for (let k in this.option.column) {
+        if (this.option.column[k].prop == name) {
+          this.option.column[k].search = false;
+          this.option.column[k].hide = true;
+          this.option.column[k].addDisplay = false;
+          this.option.column[k].editDisplay = false;
+        }
+      }
+    },
+    openDep(name) {
+      for (let k in this.option.column) {
+        if (this.option.column[k].prop == name) {
+          this.option.column[k].search = true;
+          this.option.column[k].hide = false;
+          this.option.column[k].addDisplay = true;
+          this.option.column[k].editDisplay = true;
+        }
+      }
+    },
     onLoad(page, params = {}) {
       this.loading = true;
+      var that = this;
+      // console.log(params.deptId);
+      if (this.fromDeptId != undefined) {
+        params["deptId"] = this.fromDeptId;
+        // this.closeDep("deptId");
+      } else if (this.useifid != 266) {
+        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");
+      }
+
+      //公安局进入
+      if (this.userInfo.role_name == "公安管理员") {
+        params["jurisdiction"] = that.userInfo.jurisdiction;
+      }
+
       getdata(
         page.currentPage,
         page.pageSize,

--
Gitblit v1.9.3