From 6416b40cf242340eaa163c498bd49d8103e73610 Mon Sep 17 00:00:00 2001
From: linwe <872216996@qq.com>
Date: Mon, 29 Jul 2024 17:01:52 +0800
Subject: [PATCH] 代码优化

---
 src/views/cGovernance/punchCard.vue |  446 ++++++++++++++++++++++++++++++-------------------------
 1 files changed, 245 insertions(+), 201 deletions(-)

diff --git a/src/views/cGovernance/punchCard.vue b/src/views/cGovernance/punchCard.vue
index 1471279..6a5cf31 100644
--- a/src/views/cGovernance/punchCard.vue
+++ b/src/views/cGovernance/punchCard.vue
@@ -1,225 +1,269 @@
 <!-- 走访日志 -->
 <template>
-    <basic-container>
-        <avue-crud :option="option" :table-loading="loading" :data="data" :page.sync="page" ref="crud" v-model="form"
-            :permission="permissionList" @search-change="searchChange" @search-reset="searchReset"
-            @selection-change="selectionChange" @current-change="currentChange" @size-change="sizeChange"
-            @refresh-change="refreshChange" @on-load="onLoad">
-        </avue-crud>
-    </basic-container>
+  <basic-container>
+    <avue-crud :option="option" :table-loading="loading" :data="data" :page.sync="page" ref="crud" v-model="form"
+      :permission="permissionList" @search-change="searchChange" @search-reset="searchReset"
+      @selection-change="selectionChange" @current-change="currentChange" @size-change="sizeChange"
+      @refresh-change="refreshChange" @on-load="onLoad">
+    </avue-crud>
+  </basic-container>
 </template>
 
 <script>
-import { getList } from "@/api/punch_card"
-import { mapGetters } from "vuex"
-import website from '@/config/website'
+  import {
+    getList
+  } from "@/api/punch_card"
+  import {
+    mapGetters
+  } from "vuex"
+  import website from '@/config/website'
 
-export default {
-    data () {
-        return {
-            form: {},
-            query: {},
-            loading: true,
-            page: {
-                pageSize: 10,
-                currentPage: 1,
-                total: 0,
+  export default {
+    data() {
+      return {
+        form: {},
+        query: {},
+        loading: true,
+        page: {
+          pageSize: 10,
+          currentPage: 1,
+          total: 0,
+        },
+        datetime: "",
+        selectionList: [],
+        option: {
+          labelWidth: 120,
+          searchLabelWidth: 96,
+          searchShow: true,
+          searchMenuSpan: 3,
+          menuWidth: 280,
+
+          menu: false,
+          addBtn: false,
+          border: true,
+          index: true,
+          selection: false,
+          height: "auto",
+          calcHeight: 54,
+          dialogWidth: 950,
+          tip: false,
+          //stripe:true,
+          viewBtn: true,
+          excelBtn: true,
+          dialogClickModal: false,
+          header: false,
+          column: [{
+              width: 96,
+              searchLabelWidth: 80,
+              searchSpan: 4,
+              addDisplay: false,
+              editDisplay: false,
+              viewDisplay: false,
+              label: "所属街道",
+              prop: "townStreetName",
+              search: true,
+              type: "tree",
+              dicUrl: "/api/blade-system/region/getTownTree",
+              props: {
+                label: "name",
+                value: "name"
+              },
+              rules: [{
+                required: true,
+                message: "请选择所属街道",
+                trigger: "blur",
+              }, ],
             },
-            datetime: "",
-            selectionList: [],
-            option: {
-                labelWidth: 120,
-                searchLabelWidth: 96,
-                searchShow: true,
-                searchMenuSpan: 3,
-                menuWidth: 280,
-
-                menu: false,
-                addBtn: false,
-                border: true,
-                index: true,
-                selection: false,
-                height: "auto",
-                calcHeight: 54,
-                dialogWidth: 950,
-                tip: false,
-                //stripe:true,
-                viewBtn: true,
-                excelBtn: true,
-                dialogClickModal: false,
-                header:false,
-                column: [
-                    {
-                        width: 110,
-                        label: "打卡人员",
-                        prop: "name",
-                        search: true,
-                        searchSpan: 4,
-                        searchLabelWidth: 76,
-                    },
-                    {
-                        label: "打卡时间",
-                        prop: "dateTime",
-                        type: "daterange",
-                        format: "yyyy-MM-dd",
-                        valueFormat: "yyyy-MM-dd",
-                        searchSpan: 5,
-                        searchRange: true,
-                        hide: true,
-                        addDisplay: false,
-                        editDisplay: false,
-                        viewDisplay: false,
-                        search: true,
-                        rules: [{
-                            required: true,
-                            message: "请选择打卡时间",
-                            trigger: "blur",
-                        },],
-                    },
-                    {
-                        width: 144,
-                        label: "打卡时间",
-                        prop: "createTime",
-                        type: "date",
-                        format: "yyyy-MM-dd HH:mm:ss",
-                        valueFormat: "yyyy-MM-dd HH:mm:ss",
-                        rules: [
-                            {
-                                required: true,
-                                message: "请输入走访时间",
-                                trigger: "blur",
-                            },
-                        ],
-                    },
-                    {
-                        label: "工作内容",
-                        prop: "workContent",
-                    },
-                    {
-                        width: 96,
-                        label: "经度",
-                        prop: "lng",
-                    },
-                    {
-                        width: 96,
-                        label: "纬度",
-                        prop: "lat",
-                    },
-                    {
-                        overHidden: true,
-                        label: "打卡地址",
-                        prop: "address",
-                    },
-                    {
-                        width: 110,
-                        label: "打卡图片",
-                        prop: "img",
-                        type: "upload",
-                        labelWidth: 120,
-                        listType: "picture-img",
-                        action: "/api/blade-resource/oss/endpoint/put-file",
-                        propsHttp: {
-                            res: "data",
-                            name: 'name',
-                            url: "link",
-                        },
-                        span: 24,
-                    },
-
-                ],
+            {
+              width: 160,
+              searchLabelWidth: 80,
+              searchSpan: 4,
+              parent: false,
+              label: "所属社区",
+              prop: "neiName",
+              search: true,
+              type: "tree",
+              dicUrl: "/api/blade-system/region/treeToCommunity",
+              props: {
+                label: "name",
+                value: "name",
+              },
+              rules: [{
+                required: true,
+                message: "请选择所属社区",
+                trigger: "blur",
+              }, ],
             },
-            data: [],
-        }
+            {
+              width: 110,
+              label: "打卡人员",
+              prop: "name",
+              search: true,
+              searchSpan: 4,
+              searchLabelWidth: 76,
+            },
+            {
+              label: "打卡时间",
+              prop: "dateTime",
+              type: "daterange",
+              format: "yyyy-MM-dd",
+              valueFormat: "yyyy-MM-dd",
+              searchSpan: 5,
+              searchRange: true,
+              hide: true,
+              addDisplay: false,
+              editDisplay: false,
+              viewDisplay: false,
+              search: true,
+              rules: [{
+                required: true,
+                message: "请选择打卡时间",
+                trigger: "blur",
+              }, ],
+            },
+            {
+              width: 144,
+              label: "打卡时间",
+              prop: "createTime",
+              type: "date",
+              format: "yyyy-MM-dd HH:mm:ss",
+              valueFormat: "yyyy-MM-dd HH:mm:ss",
+              rules: [{
+                required: true,
+                message: "请输入走访时间",
+                trigger: "blur",
+              }, ],
+            },
+            {
+              label: "工作内容",
+              prop: "workContent",
+            },
+            {
+              width: 96,
+              label: "经度",
+              prop: "lng",
+            },
+            {
+              width: 96,
+              label: "纬度",
+              prop: "lat",
+            },
+            {
+              overHidden: true,
+              label: "打卡地址",
+              prop: "address",
+            },
+            {
+              width: 110,
+              label: "打卡图片",
+              prop: "img",
+              type: "upload",
+              labelWidth: 120,
+              listType: "picture-img",
+              action: "/api/blade-resource/oss/endpoint/put-file",
+              propsHttp: {
+                res: "data",
+                name: 'name',
+                url: "link",
+              },
+              span: 24,
+            },
+
+          ],
+        },
+        data: [],
+      }
     },
-    watch: {
-    },
+    watch: {},
     computed: {
-        ...mapGetters(["permission", "userInfo"]),
-        permissionList () {
-            return {
-                addBtn: this.vaildData(this.permission.gridWorkLog_add, true),
-                viewBtn: this.vaildData(this.permission.gridWorkLog_view, true),
-                delBtn: this.vaildData(this.permission.gridWorkLog_delete, true),
-                editBtn: this.vaildData(this.permission.gridWorkLog_edit, true),
-            }
-        },
-        ids () {
-            let ids = []
-            this.selectionList.forEach((ele) => {
-                ids.push(ele.id)
-            })
-            return ids.join(",")
-        },
+      ...mapGetters(["permission", "userInfo"]),
+      permissionList() {
+        return {
+          addBtn: this.vaildData(this.permission.gridWorkLog_add, true),
+          viewBtn: this.vaildData(this.permission.gridWorkLog_view, true),
+          delBtn: this.vaildData(this.permission.gridWorkLog_delete, true),
+          editBtn: this.vaildData(this.permission.gridWorkLog_edit, true),
+        }
+      },
+      ids() {
+        let ids = []
+        this.selectionList.forEach((ele) => {
+          ids.push(ele.id)
+        })
+        return ids.join(",")
+      },
     },
     methods: {
-        searchReset () {
-            this.query = {}
-            this.onLoad(this.page)
-        },
-        searchChange (params, done) {
-            this.query = params
-            this.page.currentPage = 1
-            this.onLoad(this.page, params)
-            done()
-        },
-        selectionChange (list) {
-            this.selectionList = list
-        },
-        selectionClear () {
-            this.selectionList = []
-            this.$refs.crud.toggleSelection()
-        },
+      searchReset() {
+        this.query = {}
+        this.onLoad(this.page)
+      },
+      searchChange(params, done) {
+        this.query = params
+        this.page.currentPage = 1
+        this.onLoad(this.page, params)
+        done()
+      },
+      selectionChange(list) {
+        this.selectionList = list
+      },
+      selectionClear() {
+        this.selectionList = []
+        this.$refs.crud.toggleSelection()
+      },
 
-        currentChange (currentPage) {
-            this.page.currentPage = currentPage
-        },
-        sizeChange (pageSize) {
-            this.page.pageSize = pageSize
-        },
-        refreshChange () {
-            this.onLoad(this.page, this.query)
-        },
-        onLoad (page, params = {}) {
-            this.loading = true
+      currentChange(currentPage) {
+        this.page.currentPage = currentPage
+      },
+      sizeChange(pageSize) {
+        this.page.pageSize = pageSize
+      },
+      refreshChange() {
+        this.onLoad(this.page, this.query)
+      },
+      onLoad(page, params = {}) {
+        this.loading = true
 
-            const { dateTime } = this.query
+        const {
+          dateTime
+        } = this.query
 
-            if (dateTime) {
-                this.query = {
-                    startTime: dateTime[0],
-                    endTime: dateTime[1],
-                }
+        if (dateTime) {
+          this.query = {
+            startTime: dateTime[0],
+            endTime: dateTime[1],
+          }
+        }
+
+        getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
+          const data = res.data.data
+          this.page.total = data.total
+          this.data = data.records.map(item => {
+            if (item.img && item.img.length > 0) {
+              var urls = []
+              var names = item.img.split(",")
+              names.forEach(name => {
+                urls.push(website.minioUrl + name)
+              })
+              item.img = urls.join(",")
             }
 
-            getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
-                const data = res.data.data
-                this.page.total = data.total
-                this.data = data.records.map(item => {
-                    if (item.img && item.img.length > 0) {
-                        var urls = []
-                        var names = item.img.split(",")
-                        names.forEach(name => {
-                            urls.push(website.minioUrl + name)
-                        })
-                        item.img = urls.join(",")
-                    }
+            item.lat = Number(item.lat).toFixed(6)
+            item.lng = Number(item.lng).toFixed(6)
 
-                    item.lat = Number(item.lat).toFixed(6)
-                    item.lng = Number(item.lng).toFixed(6)
+            return item
+          })
 
-                    return item
-                })
-
-                this.loading = false
-                this.selectionClear()
-            })
-        }
+          this.loading = false
+          this.selectionClear()
+        })
+      }
     },
-}
+  }
 </script>
 
 <style>
-.avue-upload__icon {
+  .avue-upload__icon {
     line-height: 6;
-}
-</style>
+  }
+</style>
\ No newline at end of file

--
Gitblit v1.9.3