shuishen
2024-01-02 edf1ed5e165dd6e7c14d76b3d59bfc73566ad0aa
网格巡查字段显示更改
1 files modified
267 ■■■■■ changed files
src/views/cGovernance/gridPatrolRecord.vue 267 ●●●●● patch | view | raw | blame | history
src/views/cGovernance/gridPatrolRecord.vue
@@ -1,45 +1,36 @@
<!-- 巡查记录 -->
<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"
    >
        <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 size="small" icon="el-icon-delete" plain v-if="permission.article_delete" @click="handleDelete">删
                    除
        </el-button>
            </template>
            <template slot-scope="{row}" slot="location">
                <span v-text="showLocation(row.location)"></span>
            </template>
            <template slot-scope="{row}" slot="longitude">
                <span v-text="decimalProcessing(row.longitude)"></span>
            </template>
            <template slot-scope="{row}" slot="latitude">
                <span v-text="decimalProcessing(row.latitude)"></span>
      </template>
    </avue-crud>
  </basic-container>
</template>
<script>
  import {getList, remove, update, add, getGridPatrolRecord} from "@/api/grid/gridPatrolRecord";
  import {mapGetters} from "vuex";
  import website from '@/config/website';
import { getList, remove, update, add, getGridPatrolRecord } from "@/api/grid/gridPatrolRecord"
import { mapGetters } from "vuex"
import website from '@/config/website'
  export default {
    data() {
@@ -91,6 +82,43 @@
              type: "textarea",
              span: 24,
            },
                    {
                        overHidden: true,
                        slot: true,
                        label: "地址",
                        prop: "location",
                        type: 'map',
                        dataType: "string",
                        span: 24,
                        value: [117.966460, 28.431002, ""],
                        rules: [
                            {
                                required: true,
                                message: "请输入地址",
                                trigger: "blur",
                            },
                        ],
                    },
                    {
                        slot: true,
                        addDisplay: false,
                        editDisplay: false,
                        viewDisplay: false,
                        label: "经度",
                        prop: "longitude",
                    },
                    {
                        slot: true,
                        addDisplay: false,
                        editDisplay: false,
                        viewDisplay: false,
                        label: "纬度",
                        prop: "latitude",
                    },
            {
              label: "巡查图片",
              prop: "url",
@@ -123,79 +151,123 @@
          ],
        },
        data: [],
      };
        }
    },
    watch: {
    },
    computed: {
      ...mapGetters(["permission","userInfo"]),
      permissionList() {
        return {
          addBtn: this.vaildData(this.permission.gridPatrolRecord_add, true),
          viewBtn: this.vaildData(this.permission.gridPatrolRecord_view, true),
          delBtn: this.vaildData(this.permission.gridPatrolRecord_delete, true),
          editBtn: this.vaildData(this.permission.gridPatrolRecord_edit, true),
        };
            }
      },
      ids() {
        let ids = [];
            let ids = []
        this.selectionList.forEach((ele) => {
          ids.push(ele.id);
        });
        return ids.join(",");
                ids.push(ele.id)
            })
            return ids.join(",")
      },
        showLocation () {
            return (data) => {
                if (data != null && data.indexOf(',') != -1) {
                    data = data.split(',')
                    return data[2]
                } else {
                    return data || ''
                }
            }
        },
        decimalProcessing () {
            return (data) => {
                if (data != null) {
                    return Number(data).toFixed(6)
                } else {
                    return ''
                }
            }
        }
    },
    methods: {
        locationDispose (data) {
            data = data.split(',')
            return {
                longitude: data[0],
                latitude: data[1],
                location: data[2]
            }
        },
      rowSave(row, done, loading) {
        if(row.url.length>0){
          var urls = []
          var split = row.url.split(",");
                var split = row.url.split(",")
          split.forEach(url=>{
             var names = url.split("jczz/");
                    var names = url.split("jczz/")
             urls.push(names[1])
          })
          row.url = urls.join(",")
        }
        add(row).then(
            add({
                ...row,
                ...this.locationDispose(row.location)
            }).then(
          () => {
            this.onLoad(this.page);
                    this.onLoad(this.page)
            this.$message({
              type: "success",
              message: "操作成功!",
            });
            done();
                    })
                    done()
          },
          (error) => {
            window.console.log(error);
            loading();
                    window.console.log(error)
                    loading()
          }
        );
            )
      },
      rowUpdate(row, index, done, loading) {
        if(row.url.length>0){
          var urls = []
          var split = row.url.split(",");
                var split = row.url.split(",")
          split.forEach(url=>{
             var names = url.split("jczz/");
                    var names = url.split("jczz/")
             urls.push(names[1])
          })
          row.url = urls.join(",")
        }
        update(row).then(
            update({
                ...row,
                ...this.locationDispose(row.location)
            }).then(
          () => {
            this.onLoad(this.page);
                    this.onLoad(this.page)
            this.$message({
              type: "success",
              message: "操作成功!",
            });
            done();
                    })
                    done()
          },
          (error) => {
            window.console.log(error);
            loading();
                    window.console.log(error)
                    loading()
          }
        );
            )
      },
      rowDel(row) {
        this.$confirm("确定将选择数据删除?", {
          confirmButtonText: "确定",
@@ -203,37 +275,39 @@
          type: "warning",
        })
          .then(() => {
            return remove(row.id);
                    return remove(row.id)
          })
          .then(() => {
            this.onLoad(this.page);
                    this.onLoad(this.page)
            this.$message({
              type: "success",
              message: "操作成功!",
            });
          });
                    })
                })
      },
      searchReset() {
        this.query = {};
        this.onLoad(this.page);
            this.query = {}
            this.onLoad(this.page)
      },
      searchChange(params, done) {
        this.query = params;
        this.page.currentPage = 1;
        this.onLoad(this.page, params);
        done();
            this.query = params
            this.page.currentPage = 1
            this.onLoad(this.page, params)
            done()
      },
      selectionChange(list) {
        this.selectionList = list;
            this.selectionList = list
      },
      selectionClear() {
        this.selectionList = [];
        this.$refs.crud.toggleSelection();
            this.selectionList = []
            this.$refs.crud.toggleSelection()
      },
      handleDelete() {
        if (this.selectionList.length === 0) {
          this.$message.warning("请选择至少一条数据");
          return;
                this.$message.warning("请选择至少一条数据")
                return
        }
        this.$confirm("确定将选择数据删除?", {
          confirmButtonText: "确定",
@@ -241,78 +315,81 @@
          type: "warning",
        })
          .then(() => {
            return remove(this.ids);
                    return remove(this.ids)
          })
          .then(() => {
            this.onLoad(this.page);
                    this.onLoad(this.page)
            this.$message({
              type: "success",
              message: "操作成功!",
            });
            this.$refs.crud.toggleSelection();
          });
                    })
                    this.$refs.crud.toggleSelection()
                })
      },
      beforeOpen(done, type) {
        if (["edit", "view"].includes(type)) {
          getGridPatrolRecord(this.form.id).then((res) => {
            this.form = res.data.data;
                    this.form = res.data.data
                    this.form.location = [this.form.longitude, this.form.latitude, this.form.location].join(',')
            if(this.form.url.length>0){
              var urls = []
              var names = this.form.url.split(",");
                        var names = this.form.url.split(",")
              names.forEach(name=>{
                urls.push(website.minioUrl + name)
              })
              this.form.url = urls.join(",")
            }
          });
                })
        }
        // con
        done();
            done()
      },
      currentChange(currentPage) {
        this.page.currentPage = currentPage;
            this.page.currentPage = currentPage
      },
      sizeChange(pageSize) {
        this.page.pageSize = pageSize;
            this.page.pageSize = pageSize
      },
      refreshChange() {
        this.onLoad(this.page, this.query);
            this.onLoad(this.page, this.query)
      },
      onLoad(page, params = {}) {
        const {dateTime} = this.query;
            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;
                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;
                const data = res.data.data
                this.page.total = data.total
                this.data = data.records
          this.data.forEach(item=>{
            if(item.url.length>0){
              var urls = []
              var names = item.url.split(",");
                        var names = item.url.split(",")
              names.forEach(name=>{
                urls.push(website.minioUrl + name)
              })
              item.url = urls.join(",")
            }
          })
          this.loading = false;
          this.selectionClear();
        });
                this.loading = false
                this.selectionClear()
            })
      }
    },
  };
}
</script>
<style>