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 |  715 ++++++++++++++++++++++++++++++----------------------------
 1 files changed, 371 insertions(+), 344 deletions(-)

diff --git a/src/views/task/index.vue b/src/views/task/index.vue
index 1def95d..3c1e6c2 100644
--- a/src/views/task/index.vue
+++ b/src/views/task/index.vue
@@ -1,4 +1,4 @@
-<!-- 工作日志 -->
+<!-- 走访日志 -->
 <template>
   <basic-container>
     <avue-crud :option="option" :table-loading="loading" :data="data" :page.sync="page" ref="crud" @row-del="rowDel"
@@ -6,7 +6,13 @@
       @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 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">
@@ -23,363 +29,384 @@
 </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: [
-          {
+  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: {
-        height: "auto",
-        calcHeight: 54,
-        dialogWidth: 950,
-        tip: false,
-        searchShow: true,
-        searchMenuSpan: 3,
-        menuWidth: 280,
-        border: true,
-        //stripe:true,
-        index: true,
-        editBtnText:"任务分发",
-        editTitle:"任务分发",
-        updateBtnText:"确定",
-        viewBtn: true,
-        selection: true,
-        // excelBtn: true,
-        dialogClickModal: false,
-        column: [
-          {
-            label: "类型",
-            prop: "type",
-            span: 12,
-            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,
-            span:15,
-            row:true,
-            labelWidth:110,
-          },
-          {
-            label: "姓名",
-            prop: "realName",
-            span: 12,
-            searchSpan: 4,
-            width: 100,
-            search: true,
-            editDisabled:true,
-            labelWidth:110,
-          },
-          {
-            label: "手机号",
-            prop: "phone",
-            span: 12,
-            width: 100,
-            searchSpan: 4,
-            search: true,
-            editDisabled:true,
-            labelWidth:110,
-          },
-          {
-            label: "图片",
-            prop: "imageUrls",
-            width: 80,
-            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,
-            labelWidth:110,
-          },
-          {
-            label: "上报事发地址",
-            prop: "address",
-            overHidden: true,
-            editDisabled:true,
-            labelWidth:110,
-            span:24
-          },
-          // {
-          //   label: "地点",
-          //   prop: "addressName",
-          //   overHidden:true
-          // },
-          {
-            label: "上报时间",
-            prop: "createTime",
-            width: 160,
-            addDisplay: false,
-            editDisplay: false,
-            type: "date",
-            format: "yyyy-MM-dd HH:mm:ss",
-            valueFormat: "yyyy-MM-dd HH:mm:ss",
-            editDisabled:true,
-            labelWidth:110,
-          },
-          {
-            label: "描述",
-            prop: "remark",
-            type: "textarea",
-            span: 24,
-            editDisabled:true,
-            labelWidth:110,
-          },
-          {
-            label: "接收员",
-            prop: "userIds",
-            type: "tree",
-            hide:true,
-            labelWidth:110,
-            dicUrl:"/api/blade-gridman/gridman/getGridmanList",
-            props: {
-              label: "gridmanName",
-              value: "id",
-            },
-          }
-        ],
-      },
-      data: [],
-    };
-  },
-  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(",");
-    },
-  },
-  methods: {
-    // 任务派发
-    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();
+        taskVisible: false,
+        form: {},
+        query: {},
+        loading: true,
+        page: {
+          pageSize: 10,
+          currentPage: 1,
+          total: 0,
         },
-        (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;
+        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",
+              },
+            }
+          ],
+        },
+        data: [],
       }
-      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(",")
+    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")
             }
           }
-        });
+        }
       }
-      // 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 = {
+    methods: {
+      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,
-          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 => {
-          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(",")
-            }
+        }
+        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()
         })
-        this.loading = false;
-        this.selectionClear();
-      });
-    }
-  },
-};
+      }
+    },
+  }
 </script>
 
 <style>
-.avue-upload__icon {
-  line-height: 6;
-}
-</style>
+  .avue-upload__icon {
+    line-height: 6;
+  }
+</style>
\ No newline at end of file

--
Gitblit v1.9.3