南昌市物联网技防平台-前端
liuyg
2021-04-26 7c4b47852e921718259c3e27421f44f8d2edb7fc
src/views/clientManagement/clientManagement.vue
@@ -44,7 +44,6 @@
            </span>
          </template>
          <template slot-scope="{ row }" slot="devicestate">
            <el-tag>{{
              row.devicestate == "0" ? "撤防" : row.devicestate == "1" ? "布防" : "无"
@@ -198,10 +197,12 @@
<script>
  import {getList, remove, update, add, getclient, getDeptLazyTree, getAll, updates,getBaTree} from "@/api/client/client";
  // import {getDeptTree} from "@/api/system/dept";
  import {mapGetters} from "vuex";
  import axios from "axios";
  import Legend from '../../components/liu-legend/Legend'
  import AvueMap from "avue-plugin-map";
  import website from '@/config/website';
  export default {
    components:{
@@ -268,9 +269,9 @@
        option: {
          height: 'auto',
          indexLabel: '序号',
          calcHeight: 80,
          calcHeight: 54,
          labelWidth: '125',
          dialogWidth: 960,
          dialogWidth: 1150,
          menuWidth: 150,
          align:"center",
          size: "mini",
@@ -335,13 +336,18 @@
            },
            {
              label: "使用方",
              prop: "deptName",
              display: false
            },
            {
              label: "使用方",
              prop: "deptId",
              width: 200,
              type: "tree",
              type: "cascader",
              dicUrl: "/api/blade-system/dept/trees",
              multiple: true,
              dicData: [],
              checkStrictly:true,
              hide:true,
              props: {
                label: "title"
              },
@@ -360,6 +366,7 @@
            //   type: "cascader",
            //   dicUrl: "/api/blade-system/dept/trees",
            //   multiple: true,
            //   checkStrictly:true,
            //   dicData: [],
            //   props: {
            //     label: "title"
@@ -443,14 +450,24 @@
              prop: "reason",
              addDisplay: false,
              editDisplay: false
            },{
              label: "心跳时间",
              prop: "heartbeat",
              type: "datetime",
              format: "yyyy-MM-dd",
              valueFormat: "yyyy-MM-dd HH:mm:ss",
              width: 130,
              hide: true,
              addDisplay: true,
              editDisplay: true,
              viewDisplay: true,
            },
            {
              label: "省份",
              prop: "province",
              search: true,
              searchSpan: 2,
              labelWidth: '112',
              labelWidth: '110',
              searchLabelWidth: 45,
              placeholder: "省份",
              type: "select",
@@ -460,7 +477,7 @@
              },
              cascaderItem: ["city", "district"],
              dicUrl: "/api/blade-system/region/select",
              span: 6,
              span: 8,
              className: "city1",
              hide: true,
              addDisplay: true,
@@ -481,7 +498,7 @@
                value: "code"
              },
              dicUrl: "/api/blade-system/region/select?code={{key}}",
              span: 3,
              span: 2,
              labelWidth: "0",
              className: "city2",
              hide: true,
@@ -503,7 +520,7 @@
                value: "code"
              },
              dicUrl: "/api/blade-system/region/select?code={{key}}",
              span: 3,
              span: 2,
              labelWidth: "0",
              className: "city3",
              hide: true,
@@ -513,10 +530,7 @@
            }, {
              label: "地址",
              prop: "street",
              // type:"map",
              span:10,
              labelWidth: '142',
              width:100,
              hide: true,
            },
            {
@@ -535,6 +549,8 @@
              hide: true,
              prop: "jd",
              searchSpan:2,
              width:"100",
              labelWidth: "120",
              formatter: (row,value,label,column)=>{
                  return value = value.substring(0,11);
              },
@@ -542,7 +558,7 @@
            },
            {
              label: "纬度",
              labelWidth:50,
              labelWidth: "45",
              hide: true,
              prop: "wd",
              formatter: (row,value,label,column) => {
@@ -550,20 +566,9 @@
              },
              span:5,
            },
             {
              label: "心跳时间",
              prop: "heartbeat",
              type: "datetime",
              format: "yyyy-MM-dd",
              valueFormat: "yyyy-MM-dd HH:mm:ss",
              width: 130,
              hide: true,
              addDisplay: true,
              editDisplay: true,
              viewDisplay: true,
            },
            {
              label: "负责人1",
              label: "主要负责人",
              prop: "oneId",
              type: "tree",
              dicUrl: "/api/blade-system/dept/Batrees",
@@ -577,12 +582,12 @@
              viewDisplay: true,
              rules: [{
                required: true,
                message: "请选择负责人",
                message: "请选择主要负责人",
                trigger: "blur"
              }],
            },
            {
              label: "负责人1电话",
              label: "主要负责人电话",
              prop: "onePhone",
              width: 110,
              hide: true,
@@ -595,7 +600,7 @@
                trigger: "blur"
              }],
            }, {
              label: "负责人2",
              label: "负责人1",
              prop: "twoId",
              type: "tree",
              dicUrl: "/api/blade-system/dept/Batrees",
@@ -609,7 +614,7 @@
              viewDisplay: true,
            },
            {
              label: "负责人2电话",
              label: "负责人1电话",
              prop: "twoPhone",
              width: 110,
              hide: true,
@@ -617,7 +622,7 @@
              editDisplay: true,
              viewDisplay: true,
            }, {
              label: "负责人3",
              label: "负责人2",
              prop: "threeId",
              type: "tree",
              dicUrl: "/api/blade-system/dept/Batrees",
@@ -631,7 +636,7 @@
              viewDisplay: true,
            },
            {
              label: "负责人3电话",
              label: "负责人2电话",
              prop: "threePhone",
              width: 110,
              hide: true,
@@ -679,22 +684,26 @@
        // form是表单或者表格绑定的数据集,v-model='form'
        handler(val) {
          if (val) {
            console.log(val,111);
            this.form.wd = val.latitude.toString().substring(0,10);
            this.form.jd = val.longitude.toString().substring(0,11);
            //地址截取,从县/区开始截取,并且取从县区第一个出现的位置开始
            var address = val.formattedAddress.toString();
            if(address.search("县") != -1){
                this.form.street = address.substring(address.indexOf("县")+1,address.length);
            }
            if(address.search("区") != -1){
              this.form.street = address.substring(address.indexOf("区")+1,address.length);
            }
            // this.form.province = val.addressComponent.province;
            // console.log( val.addressComponent.city,123456)
            // this.form.city = val.addressComponent.city;
            // this.form.district = val.addressComponent.district;
            var that = this;
            //重新加载一次页面详情数据,解决新的省市区无法写入问题
            getclient(this.form.id).then(res => {
              this.form = res.data.data;
              //经纬度替换
              this.form.wd = val.latitude;
              this.form.jd = val.longitude;
              //地址截取,从县/区开始截取,并且取从县区第一个出现的位置开始
              var address = val.formattedAddress.toString();
              if(address.search("县") != -1){
                  this.form.street = address.substring(address.indexOf("县")+1,address.length);
              }
              if(address.search("区") != -1){
                this.form.street = address.substring(address.indexOf("区")+1,address.length);
              }
              //写入新的省市区
              that.form.province = val.addressComponent.province;
              that.form.city = val.addressComponent.city;
              that.form.district = val.addressComponent.district;
            });
          }
        },
        immediate: true,
@@ -737,7 +746,14 @@
            });
          }
        },
      }
      },
      //随意一个
      // 'form.deviceName'() {
      //   if (this.initFlag) {
      //     this.initData();
      //   }
      // }
      
    },
    computed: {
@@ -758,6 +774,11 @@
        return ids.join(",");
      }
    },
    mounted(){
      // 租户模式默认加载管理组数据
      // var that = this;
      //that.tenantId = website.tenantId;
    },
    methods: {
      generate(row) {
        updates(row.expireTime, row.deviceNumber).then(() => {
@@ -772,12 +793,20 @@
          window.console.log(error);
        });
      },
      //初始化数据
      // initData() {
      //   //部门tree数据
      //   getDeptTree().then(res => {
      //     const column = this.findObject(this.option.column, "deptId");
      //     column.dicData = res.data.data;
      //   });
      // },
      
      handleClick(row) {
        this.form = row;
        this.dialogTableVisible = true;
        this.realjf = true;
      },
      nodeClick(data) {
        this.treeDeptId = data.id;
@@ -798,10 +827,10 @@
        });
      },
      rowUpdate(row, index, done, loading) {
        debugger;
        row.jd=row.map.latitude;
        row.wd=row.map.longitude;
        // row.jd=row.map.latitude;
        // row.wd=row.map.longitude;
        update(row).then(() => {
          // this.initFlag = false;
          this.onLoad(this.page);
          this.$message({
            type: "success",
@@ -872,11 +901,13 @@
          });
      },
      beforeOpen(done, type) {
        debugger;
        if (["edit", "view"].includes(type)) {
          getclient(this.form.id).then(res => {
            this.form = res.data.data;
          });
        }
        // this.initFlag = true;
        done();
      },
      currentChange(currentPage) {
@@ -919,11 +950,6 @@
        this.loading = true;
        getList(page.currentPage, page.pageSize, values, this.treeDeptId).then(res => {
          // debugger;
          console.log(page.currentPage)
          console.log(page.pageSize)
          console.log(values)
          console.log(this.treeDeptId)
          const data = res.data.data;
          this.page.total = data.total;