From dc91db9bb3473c3ed058f86f74359e15c035a8a5 Mon Sep 17 00:00:00 2001
From: zhengpz <1838927346@qq.com>
Date: Mon, 23 Aug 2021 22:13:10 +0800
Subject: [PATCH] 表查询完善

---
 src/views/securityUnitOperation/operationTable.vue |  236 +++++++++++++++++++++++++++++++++-------------------------
 1 files changed, 133 insertions(+), 103 deletions(-)

diff --git a/src/views/securityUnitOperation/operationTable.vue b/src/views/securityUnitOperation/operationTable.vue
index 0ac115f..a78a129 100644
--- a/src/views/securityUnitOperation/operationTable.vue
+++ b/src/views/securityUnitOperation/operationTable.vue
@@ -2,25 +2,34 @@
   <basic-container>
     <avue-crud
       :option="tableOption"
-      :data="tableData"
       :table-loading="loading"
-      :page.sync="tablePage"
+      :data="tableData"
+      :page.sync="page"
       :permission="permissionList"
-      :before-open="beforeOpen"
-      @date-change="dateChange"
+      ref="crud"
+      @search-change="searchChange"
+      @search-reset="searchReset"
+      @current-change="currentChange"
+      @size-change="sizeChange"
+      @refresh-change="refreshChange"
+      
     >
     </avue-crud>
   </basic-container>
 </template>
 <script>
-import FileSaver from "file-saver";
-import XLSX from "xlsx";
 import { selectTb } from "../../api/securityUnitOperation/securityUnitOperation";
 import { lazyTreeJu } from "../../api/index/index";
 export default {
   name: "公司运营情况智能分析详情表",
   data() {
     return {
+      page: {
+        pageSize: 10,
+        currentPage: 1,
+        total: 0
+      },
+      query:{},
       value1: "",
       value2: "",
       tableData: [
@@ -64,11 +73,6 @@
         //   bz: ""
         // }
       ],
-      tablePage: {
-        pageSize: 10,
-        currentPage: 1,
-        total: 0
-      },
       tableOption: {
         excelBtn: true,
         delBtn: false,
@@ -88,63 +92,62 @@
         viewBtn: true,
         dialogClickModal: false,
         column: [
-          {
-            label: "类别",
-            hide: true,
-            prop: "",
-            search: true,
-            searchSpan: 4,
-            display: true,
-            type: "select",
-            props: {
-              label: "label",
-              value: "value"
-            },
-            // cascaderItem: ["city", "area"],
-            // dicUrl:subofficeOptions,
-            dicData: [
-              {
-                value: "0",
-                label: "全部"
-              },
-              {
-                value: "1",
-                label: "总保安人数"
-              },
-              {
-                value: "2",
-                label: "正常保安数"
-              },
-              {
-                value: "3",
-                label: "持证保安数"
-              },
-              {
-                value: "4",
-                label: "保安派遣数"
-              },
-              {
-                value: "5",
-                label: "过考保安数"
-              },
-              {
-                value: "6",
-                label: "服务单位数"
-              },
-              {
-                value: "7",
-                label: "缴纳社保保安数"
-              }
-            ],
-            search: true,
-            rules: [
-              {
-                required: true,
-                message: "请选择类别",
-                trigger: "blur"
-              }
-            ]
-          },
+          // {
+          //   label: "类别",
+          //   hide: true,
+          //   prop: "",
+          //   search: true,
+          //   searchSpan: 4,
+          //   display: true,
+          //   type: "select",
+          //   props: {
+          //     label: "label",
+          //     value: "value"
+          //   },
+          //   // cascaderItem: ["city", "area"],
+          //   // dicUrl:subofficeOptions,
+          //   dicData: [
+          //     {
+          //       value: "0",
+          //       label: "全部"
+          //     },
+          //     {
+          //       value: "1",
+          //       label: "总保安人数"
+          //     },
+          //     {
+          //       value: "2",
+          //       label: "正常保安数"
+          //     },
+          //     {
+          //       value: "3",
+          //       label: "持证保安数"
+          //     },
+          //     {
+          //       value: "4",
+          //       label: "保安派遣数"
+          //     },
+          //     {
+          //       value: "5",
+          //       label: "过考保安数"
+          //     },
+          //     {
+          //       value: "6",
+          //       label: "服务单位数"
+          //     },
+          //     {
+          //       value: "7",
+          //       label: "缴纳社保保安数"
+          //     }
+          //   ],
+          //   rules: [
+          //     {
+          //       required: true,
+          //       message: "请选择类别",
+          //       trigger: "blur"
+          //     }
+          //   ]
+          // },
           {
             label: "公司名称",
             prop: "enterpriseName",
@@ -154,17 +157,19 @@
           },
           {
             label: "所属辖区",
-            prop: "jurname",
+            prop: "jurisdiction",
             searchSpan: 4,
-            type: "select",
+            // cascaderItem: ["city", "area"],
+            // dicUrl: "/api/information/lazyTreeJu",
+            // dicMethod:'post',
             props: {
               label: "title",
-              value: "value"
+              value: "id"
             },
-            // cascaderItem: ["city", "area"],
-            // dicUrl:subofficeOptions,
-            dicData: this.subOfficeData,
+            dicData: [],
             search: true,
+            // overHidden: true,
+            type: "tree",
             rules: [
               {
                 required: true,
@@ -235,47 +240,72 @@
     };
   },
   methods: {
+    searchChange(params, done) {
+      this.query = params;
+      this.page.currentPage = 1;
+      this.onLoad(this.page, params);
+      done();
+    },
+
+    searchReset() {
+      this.query = {};
+      this.onLoad(this.page);
+    },
+    currentChange(currentPage) {
+      this.page.currentPage = currentPage;
+      this.onLoad(this.page, this.query)
+    },
+    sizeChange(pageSize) {
+      this.page.pageSize = pageSize;
+      this.onLoad(this.page, this.query)
+    },
+    refreshChange() {
+      this.onLoad(this.page, this.query);
+    },
+    onLoad(page, params = {}) {
+      this.loading = true;
+      let param = {};
+      param["jurisdiction"] = params["jurisdiction"] || "";
+      param["enterpriseName"] = params["enterpriseName"] || "";
+      param["current"] = page.currentPage;
+      param["size"] = page.pageSize;
+      selectTb(param).then(res => {
+        const data = res.data.data;
+        this.page.total = data.total;
+        this.tableData = data.records;
+        this.loading = false;
+      });
+    },
     getSubOfficeData() {
       lazyTreeJu().then(res => {
         if (res.data.code === 200) {
-          this.subOfficeData = res.data.data;
-          this.subOfficeValue = this.subOfficeData[0].value || "";
+          this.tableOption.column.forEach(item => {
+            if (item.label == "所属辖区") {
+              item.dicData = res.data.data;
+            }
+          });
         } else {
           this.$message.error(res.msg);
         }
       });
     },
-    getTableData() {
-      selectTb().then(res => {
-        if (res.data.code === 200) {
-          this.tableData = res.data.data;
-          this.loading = false;
-        }
-      });
+    getLocationParams() {
+      let url = window.location.href;
+      let urlArr = url.split("?")[1].split("&");
+      var object = new Object();
+      for (var i = 0; i < urlArr.length; i++) {
+        let mm = urlArr[i].split("=");
+        object[decodeURIComponent(mm[0])] = decodeURIComponent(mm[1]);
+      }
+      let jurisdiction = object["jurisdiction1"] || "";
+      let enterpriseName = object["enterpriseName"] || "";
+      let obj = { jurisdiction: jurisdiction, enterpriseName: enterpriseName };
+      this.onLoad(this.page, obj);
     }
-    // downExcel() {
-    //   let et = XLSX.utils.table_to_book(document.getElementById("table"));
-    //   let etout = XLSX.write(et, {
-    //     bookType: "xlsx",
-    //     bookSST: true,
-    //     type: "array"
-    //   });
-    //   try {
-    //     FileSaver.saveAs(
-    //       new Blob([etout], {
-    //         type: "application/octet-stream"
-    //       }),
-    //       `表.xlsx`
-    //     ); //导出的文件名
-    //   } catch (e) {
-    //     console.log(e, etout);
-    //   }
-    //   return etout;
-    // }
   },
   mounted() {
+    this.getLocationParams();
     this.getSubOfficeData();
-    this.getTableData();
   }
 };
 </script>

--
Gitblit v1.9.3