From 5e2aafeede13d337380f736567caf74f49713be7 Mon Sep 17 00:00:00 2001
From: linwe <872216996@qq.com>
Date: Fri, 09 Aug 2024 14:38:32 +0800
Subject: [PATCH] 代码优化

---
 src/views/task/index.vue |  765 +++++++++++++++++++++++++++++-----------------------------
 1 files changed, 384 insertions(+), 381 deletions(-)

diff --git a/src/views/task/index.vue b/src/views/task/index.vue
index 69cb516..3c1e6c2 100644
--- a/src/views/task/index.vue
+++ b/src/views/task/index.vue
@@ -1,409 +1,412 @@
 <!-- 走访日志 -->
 <template>
-    <basic-container>
-        <avue-crud :option="option" :table-loading="loading" :data="data" :page.sync="page" ref="crud" @row-del="rowDel"
-            v-model="form" :permission="permissionList" @row-update="rowUpdate" @row-save="rowSave"
-            :before-open="beforeOpen" @search-change="searchChange" @search-reset="searchReset"
-            @selection-change="selectionChange" @current-change="currentChange" @size-change="sizeChange"
-            @refresh-change="refreshChange" @on-load="onLoad">
-            <template slot="menuLeft">
-                <el-button size="small" icon="el-icon-delete" plain v-if="permission.article_delete" @click="handleDelete">删
-                    除
-                </el-button>
-            </template>
-            <template slot-scope="{row, size}" slot="phone">
-                <el-button :size="size" type="text" @click="showStringDispose(row, 'phoneflag')"
-                    v-text="textDispose(row, 'phoneflag', 'phone')">
-                </el-button>
-            </template>
-            <!-- <template slot-scope="scope" slot="menu">
+  <basic-container>
+    <avue-crud :option="option" :table-loading="loading" :data="data" :page.sync="page" ref="crud" @row-del="rowDel"
+      v-model="form" :permission="permissionList" @row-update="rowUpdate" @row-save="rowSave" :before-open="beforeOpen"
+      @search-change="searchChange" @search-reset="searchReset" @selection-change="selectionChange"
+      @current-change="currentChange" @size-change="sizeChange" @refresh-change="refreshChange" @on-load="onLoad">
+      <template slot="menuLeft">
+        <el-button size="small" icon="el-icon-delete" plain v-if="permission.article_delete" @click="handleDelete">删
+          除
+        </el-button>
+      </template>
+      <template slot-scope="{row, size}" slot="phone">
+        <el-button :size="size" type="text" @click="showStringDispose(row, 'phoneflag')"
+          v-text="textDispose(row, 'phoneflag', 'phone')">
+        </el-button>
+      </template>
+      <!-- <template slot-scope="scope" slot="menu">
         <el-button type="text" icon="el-icon-circle-plus-outline" size="small"
           @click="taskApply(scope.row)">任务分发
         </el-button>
       </template> -->
-        </avue-crud>
-        <!-- <el-dialog title="任务分发" append-to-body :visible.sync="taskVisible" width="70%" height="60%">
+    </avue-crud>
+    <!-- <el-dialog title="任务分发" append-to-body :visible.sync="taskVisible" width="70%" height="60%">
       <avue-form :option="taskOption"
              v-model="taskForm"> </avue-form>
         </el-dialog> -->
-    </basic-container>
+  </basic-container>
 </template>
 
 <script>
-import { getList, remove, update, add, getReportForRepairs } from "@/api/task/reportForRepairs"
-import { mapGetters } from "vuex"
-import website from '@/config/website'
+  import {
+    getList,
+    remove,
+    update,
+    add,
+    getReportForRepairs
+  } from "@/api/task/reportForRepairs"
+  import {
+    mapGetters
+  } from "vuex"
+  import website from '@/config/website'
 
-export default {
-    data () {
-        return {
-            taskForm: {},
-            taskOption: {
-                column: [
-                    {
-                        label: '姓名',
-                        prop: 'name',
-                        value: 'small'
-                    }
-                ]
+  export default {
+    data() {
+      return {
+        taskForm: {},
+        taskOption: {
+          column: [{
+            label: '姓名',
+            prop: 'name',
+            value: 'small'
+          }]
+        },
+        taskVisible: false,
+        form: {},
+        query: {},
+        loading: true,
+        page: {
+          pageSize: 10,
+          currentPage: 1,
+          total: 0,
+        },
+        datetime: "",
+        selectionList: [],
+        option: {
+          labelWidth: 120,
+          searchLabelWidth: 66,
+          searchShow: true,
+          searchMenuSpan: 3,
+          menuWidth: 160,
+          height: "auto",
+          calcHeight: 54,
+          dialogWidth: 950,
+          tip: false,
+          border: true,
+          //stripe:true,
+          index: true,
+          editBtnText: "任务分发",
+          editTitle: "任务分发",
+          updateBtnText: "确定",
+          viewBtn: true,
+          selection: true,
+          // excelBtn: true,
+          dialogClickModal: false,
+          column: [{
+              label: "类型",
+              prop: "type",
+              span: 24,
+              searchSpan: 4,
+              dataType: "number",
+              type: "select",
+              width: 100,
+              editDisabled: true,
+              dicUrl: "/api/blade-system/dict-biz/dictionary?code=reportForRepairsType",
+              props: {
+                label: "dictValue",
+                value: "dictKey",
+              },
+              search: true,
+              searchLabelWidth: 46,
+              row: true,
             },
-            taskVisible: false,
-            form: {},
-            query: {},
-            loading: true,
-            page: {
-                pageSize: 10,
-                currentPage: 1,
-                total: 0,
+            {
+              width: 110,
+              label: "姓名",
+              prop: "realName",
+              span: 12,
+              searchSpan: 4,
+              search: true,
+              editDisabled: true,
             },
-            datetime: "",
-            selectionList: [],
-            option: {
-                labelWidth: 120,
-                searchLabelWidth: 66,
-                searchShow: true,
-                searchMenuSpan: 3,
-                menuWidth: 160,
-
-                height: "auto",
-                calcHeight: 54,
-                dialogWidth: 950,
-                tip: false,
-                border: true,
-                //stripe:true,
-                index: true,
-                editBtnText: "任务分发",
-                editTitle: "任务分发",
-                updateBtnText: "确定",
-                viewBtn: true,
-                selection: true,
-                // excelBtn: true,
-                dialogClickModal: false,
-                column: [
-                    {
-                        label: "类型",
-                        prop: "type",
-                        span: 24,
-                        searchSpan: 4,
-                        dataType: "number",
-                        type: "select",
-                        width: 100,
-                        editDisabled: true,
-                        dicUrl: "/api/blade-system/dict-biz/dictionary?code=reportForRepairsType",
-                        props: {
-                            label: "dictValue",
-                            value: "dictKey",
-                        },
-                        search: true,
-                        searchLabelWidth: 46,
-                        row: true,
-                    },
-                    {
-                        width: 110,
-                        label: "姓名",
-                        prop: "realName",
-                        span: 12,
-                        searchSpan: 4,
-                        search: true,
-                        editDisabled: true,
-                    },
-                    {
-                        width: 120,
-                        label: "手机号",
-                        prop: "phone",
-                        span: 12,
-                        searchSpan: 4,
-                        searchLabelWidth: 76,
-                        search: true,
-                        editDisabled: true,
-                        slot: true
-                    },
-                    {
-                        width: 110,
-                        label: "图片",
-                        prop: "imageUrls",
-                        type: "upload",
-                        listType: "picture-card",
-                        dataType: "string",
-                        multiple: true,
-                        action: "/api/blade-resource/oss/endpoint/put-file",
-                        propsHttp: {
-                            res: "data",
-                            name: 'name',
-                            url: "link",
-                        },
-                        span: 24,
-                        editDisabled: true,
-                    },
-                    {
-                        overHidden: true,
-                        label: "上报事发地址",
-                        prop: "address",
-                        editDisabled: true,
-                        span: 24
-                    },
-                    // {
-                    //   label: "地点",
-                    //   prop: "addressName",
-                    //   overHidden:true
-                    // },
-                    {
-                        width: 144,
-                        label: "上报时间",
-                        prop: "createTime",
-                        addDisplay: false,
-                        editDisplay: false,
-                        type: "date",
-                        format: "yyyy-MM-dd HH:mm:ss",
-                        valueFormat: "yyyy-MM-dd HH:mm:ss",
-                        editDisabled: true,
-                    },
-                    {
-                        overHidden: true,
-                        label: "描述",
-                        prop: "remark",
-                        type: "textarea",
-                        span: 24,
-                        editDisabled: true,
-                    },
-                    {
-                        label: "接收员",
-                        prop: "userIds",
-                        type: "tree",
-                        hide: true,
-                        dicUrl: "/api/blade-gridman/gridman/getGridmanList",
-                        props: {
-                            label: "gridmanName",
-                            value: "id",
-                        },
-                    }
-                ],
+            {
+              width: 120,
+              label: "手机号",
+              prop: "phone",
+              span: 12,
+              searchSpan: 4,
+              searchLabelWidth: 76,
+              search: true,
+              editDisabled: true,
+              slot: true
             },
-            data: [],
-        }
+            {
+              width: 110,
+              label: "图片",
+              prop: "imageUrls",
+              type: "upload",
+              listType: "picture-card",
+              dataType: "string",
+              multiple: true,
+              action: "/api/blade-resource/oss/endpoint/put-file",
+              propsHttp: {
+                res: "data",
+                name: 'name',
+                url: "link",
+              },
+              span: 24,
+              editDisabled: true,
+            },
+            {
+              overHidden: true,
+              label: "上报事发地址",
+              prop: "address",
+              editDisabled: true,
+              span: 24
+            },
+            // {
+            //   label: "地点",
+            //   prop: "addressName",
+            //   overHidden:true
+            // },
+            {
+              width: 144,
+              label: "上报时间",
+              prop: "createTime",
+              addDisplay: false,
+              editDisplay: false,
+              type: "date",
+              format: "yyyy-MM-dd HH:mm:ss",
+              valueFormat: "yyyy-MM-dd HH:mm:ss",
+              editDisabled: true,
+            },
+            {
+              overHidden: true,
+              label: "描述",
+              prop: "remark",
+              type: "textarea",
+              span: 24,
+              editDisabled: true,
+            },
+            {
+              label: "接收员",
+              prop: "userIds",
+              type: "tree",
+              hide: true,
+              dicUrl: "/api/blade-gridman/gridman/getGridmanList",
+              props: {
+                label: "gridmanName",
+                value: "id",
+              },
+            }
+          ],
+        },
+        data: [],
+      }
     },
-    watch: {
-    },
+    watch: {},
     computed: {
-        ...mapGetters(["permission", "userInfo"]),
-        permissionList () {
-            return {
-                addBtn: this.vaildData(this.permission.reportForRepairs_add, false),
-                viewBtn: this.vaildData(this.permission.reportForRepairs_view, true),
-                delBtn: this.vaildData(this.permission.reportForRepairs_delete, false),
-                editBtn: this.vaildData(this.permission.reportForRepairs_edit, true),
-            }
-        },
-        ids () {
-            let ids = []
-            this.selectionList.forEach((ele) => {
-                ids.push(ele.id)
-            })
-            return ids.join(",")
-        },
-
-        textDispose () {
-            return (row, flag, type) => {
-                if (row[flag] || row[type] == null) {
-                    return row[type]
-                } else {
-                    if (type == 'principalIdCard') {
-                        return row[type].replace(/^(.{6})(?:\d+)(.{4})$/, "$1******$2")
-                    } else {
-                        return row[type].replace(/^(.{3})(?:\d+)(.{4})$/, "$1****$2")
-                    }
-                }
-            }
+      ...mapGetters(["permission", "userInfo"]),
+      permissionList() {
+        return {
+          addBtn: this.vaildData(this.permission.reportForRepairs_add, false),
+          viewBtn: this.vaildData(this.permission.reportForRepairs_view, true),
+          delBtn: this.vaildData(this.permission.reportForRepairs_delete, false),
+          editBtn: this.vaildData(this.permission.reportForRepairs_edit, true),
         }
+      },
+      ids() {
+        let ids = []
+        this.selectionList.forEach((ele) => {
+          ids.push(ele.id)
+        })
+        return ids.join(",")
+      },
+
+      textDispose() {
+        return (row, flag, type) => {
+          if (row[flag] || row[type] == null) {
+            return row[type]
+          } else {
+            if (type == 'principalIdCard') {
+              return row[type].replace(/^(.{6})(?:\d+)(.{4})$/, "$1******$2")
+            } else {
+              return row[type].replace(/^(.{3})(?:\d+)(.{4})$/, "$1****$2")
+            }
+          }
+        }
+      }
     },
     methods: {
-        showStringDispose (row, type) {
-            row[type] = !row[type]
-        },
+      showStringDispose(row, type) {
+        row[type] = !row[type]
+      },
 
-        // 任务派发
-        taskApply (row) {
-            var that = this
-            this.taskVisible = true
-            this.$nextTick(() => {
-            })
-        },
-        rowSave (row, done, loading) {
-            if (row.imageUrls.length > 0) {
-                var urls = []
-                var split = row.imageUrls.split(",")
-                split.forEach(url => {
-                    var names = url.split("jczz/")
-                    urls.push(names[1])
-                })
-                row.imageUrls = urls.join(",")
-            }
-            add(row).then(
-                () => {
-                    this.onLoad(this.page)
-                    this.$message({
-                        type: "success",
-                        message: "操作成功!",
-                    })
-                    done()
-                },
-                (error) => {
-                    window.console.log(error)
-                    loading()
-                }
-            )
-        },
-        rowUpdate (row, index, done, loading) {
-            if (row.imageUrls.length > 0) {
-                var urls = []
-                var split = row.imageUrls.split(",")
-                split.forEach(url => {
-                    var names = url.split("jczz/")
-                    urls.push(names[1])
-                })
-                row.imageUrls = urls.join(",")
-            }
-            update(row).then(
-                () => {
-                    this.onLoad(this.page)
-                    this.$message({
-                        type: "success",
-                        message: "操作成功!",
-                    })
-                    done()
-                },
-                (error) => {
-                    window.console.log(error)
-                    loading()
-                }
-            )
-        },
-        rowDel (row) {
-            this.$confirm("确定将选择数据删除?", {
-                confirmButtonText: "确定",
-                cancelButtonText: "取消",
-                type: "warning",
-            })
-                .then(() => {
-                    return remove(row.id)
-                })
-                .then(() => {
-                    this.onLoad(this.page)
-                    this.$message({
-                        type: "success",
-                        message: "操作成功!",
-                    })
-                })
-        },
-        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()
-        },
-        handleDelete () {
-            if (this.selectionList.length === 0) {
-                this.$message.warning("请选择至少一条数据")
-                return
-            }
-            this.$confirm("确定将选择数据删除?", {
-                confirmButtonText: "确定",
-                cancelButtonText: "取消",
-                type: "warning",
-            })
-                .then(() => {
-                    return remove(this.ids)
-                })
-                .then(() => {
-                    this.onLoad(this.page)
-                    this.$message({
-                        type: "success",
-                        message: "操作成功!",
-                    })
-                    this.$refs.crud.toggleSelection()
-                })
-        },
-        beforeOpen (done, type) {
-            if (["edit", "view"].includes(type)) {
-                getReportForRepairs(this.form.id).then((res) => {
-                    this.form = res.data.data
-                    if (this.form.imageUrls) {
-                        if (this.form.imageUrls.length > 0) {
-                            var urls = []
-                            var names = this.form.imageUrls.split(",")
-                            names.forEach(name => {
-                                urls.push(website.minioUrl + name)
-                            })
-                            this.form.imageUrls = urls.join(",")
-                        }
-                    }
-                })
-            }
-            // con
-            done()
-        },
-        currentChange (currentPage) {
-            this.page.currentPage = currentPage
-        },
-        sizeChange (pageSize) {
-            this.page.pageSize = pageSize
-        },
-        refreshChange () {
-            this.onLoad(this.page, this.query)
-        },
-        onLoad (page, params = {}) {
-            const { dateTime } = this.query
-            let values = {
-                ...params,
-            }
-            if (dateTime) {
-                values = {
-                    ...params,
-                    startTime: dateTime[0],
-                    endTime: dateTime[1],
-                    ...this.query,
-                }
-                values.dateTime = null
-            }
-            this.loading = true
-            getList(page.currentPage, page.pageSize, values).then((res) => {
-                const data = res.data.data
-                this.page.total = data.total
-                this.data = data.records
-                this.data.forEach(item => {
-                    this.$set(item, 'phoneflag', false)
-                    if (item.imageUrls) {
-                        if (item.imageUrls.length > 0) {
-                            var urls = []
-                            var names = item.imageUrls.split(",")
-                            names.forEach(name => {
-                                urls.push(website.minioUrl + name)
-                            })
-                            item.imageUrls = urls.join(",")
-                        }
-                    }
-                })
-                this.loading = false
-                this.selectionClear()
-            })
+      // 任务派发
+      taskApply(row) {
+        var that = this
+        this.taskVisible = true
+        this.$nextTick(() => {})
+      },
+      rowSave(row, done, loading) {
+        if (row.imageUrls.length > 0) {
+          var urls = []
+          var split = row.imageUrls.split(",")
+          split.forEach(url => {
+            var names = url.split("jczz/")
+            urls.push(names[1])
+          })
+          row.imageUrls = urls.join(",")
         }
+        add(row).then(
+          () => {
+            this.onLoad(this.page)
+            this.$message({
+              type: "success",
+              message: "操作成功!",
+            })
+            done()
+          },
+          (error) => {
+            window.console.log(error)
+            loading()
+          }
+        )
+      },
+      rowUpdate(row, index, done, loading) {
+        if (row.imageUrls.length > 0) {
+          var urls = []
+          var split = row.imageUrls.split(",")
+          split.forEach(url => {
+            var names = url.split("jczz/")
+            urls.push(names[1])
+          })
+          row.imageUrls = urls.join(",")
+        }
+        update(row).then(
+          () => {
+            this.onLoad(this.page)
+            this.$message({
+              type: "success",
+              message: "操作成功!",
+            })
+            done()
+          },
+          (error) => {
+            window.console.log(error)
+            loading()
+          }
+        )
+      },
+      rowDel(row) {
+        this.$confirm("确定将选择数据删除?", {
+            confirmButtonText: "确定",
+            cancelButtonText: "取消",
+            type: "warning",
+          })
+          .then(() => {
+            return remove(row.id)
+          })
+          .then(() => {
+            this.onLoad(this.page)
+            this.$message({
+              type: "success",
+              message: "操作成功!",
+            })
+          })
+      },
+      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()
+      },
+      handleDelete() {
+        if (this.selectionList.length === 0) {
+          this.$message.warning("请选择至少一条数据")
+          return
+        }
+        this.$confirm("确定将选择数据删除?", {
+            confirmButtonText: "确定",
+            cancelButtonText: "取消",
+            type: "warning",
+          })
+          .then(() => {
+            return remove(this.ids)
+          })
+          .then(() => {
+            this.onLoad(this.page)
+            this.$message({
+              type: "success",
+              message: "操作成功!",
+            })
+            this.$refs.crud.toggleSelection()
+          })
+      },
+      beforeOpen(done, type) {
+        if (["edit", "view"].includes(type)) {
+          getReportForRepairs(this.form.id).then((res) => {
+            this.form = res.data.data
+            if (this.form.imageUrls) {
+              if (this.form.imageUrls.length > 0) {
+                var urls = []
+                var names = this.form.imageUrls.split(",")
+                names.forEach(name => {
+                  urls.push(website.minioUrl + name)
+                })
+                this.form.imageUrls = urls.join(",")
+              }
+            }
+          })
+        }
+        // con
+        done()
+      },
+      currentChange(currentPage) {
+        this.page.currentPage = currentPage
+      },
+      sizeChange(pageSize) {
+        this.page.pageSize = pageSize
+      },
+      refreshChange() {
+        this.onLoad(this.page, this.query)
+      },
+      onLoad(page, params = {}) {
+        const {
+          dateTime
+        } = this.query
+        let values = {
+          ...params,
+        }
+        if (dateTime) {
+          values = {
+            ...params,
+            startTime: dateTime[0],
+            endTime: dateTime[1],
+            ...this.query,
+          }
+          values.dateTime = null
+        }
+        this.loading = true
+        getList(page.currentPage, page.pageSize, values).then((res) => {
+          const data = res.data.data
+          this.page.total = data.total
+          this.data = data.records
+          this.data.forEach(item => {
+            this.$set(item, 'phoneflag', false)
+            if (item.imageUrls) {
+              if (item.imageUrls.length > 0) {
+                var urls = []
+                var names = item.imageUrls.split(",")
+                names.forEach(name => {
+                  urls.push(website.minioUrl + name)
+                })
+                item.imageUrls = urls.join(",")
+              }
+            }
+          })
+          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