南昌市物联网技防平台-前端
Administrator
2021-05-06 ab947e7f017989bf4abe12293ddaf372818fd00c
设备管理,用户管理新增时选择坐标报错修复
2 files modified
79 ■■■■■ changed files
src/views/clientManagement/clientManagement.vue 61 ●●●●● patch | view | raw | blame | history
src/views/system/cs.vue 18 ●●●● patch | view | raw | blame | history
src/views/clientManagement/clientManagement.vue
@@ -231,6 +231,7 @@
        initFlag: true,
        loading: true,
        menuVisible:false,
        isEdit:false,
        page: {
          pageSize: 10,
          currentPage: 1,
@@ -707,30 +708,36 @@
          if (val) {
            var that = this;
            //重新加载一次页面详情数据,解决新的省市区无法写入问题
            getclient(this.form.id).then(res => {
              this.province = res.data.province;
              this.city = res.data.city;
              this.district = res.data.district;
              //经纬度替换
              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(that.isEdit){
                getclient(this.form.id).then(res => {
                  debugger;
                  that.province = res.data.data.province;
                  that.city = res.data.data.city;
                  that.district = res.data.data.district;
                });
              }
              if(address.search("区") != -1){
                this.form.street = address.substring(address.indexOf("区")+1,address.length);
              }
              //写入新的省市区
              that.form.province = val.addressComponent.province;
              if(val.addressComponent.city==""){
                  that.form.city = val.addressComponent.province;
              }else{
                  that.form.city = val.addressComponent.city;
              }
              that.form.district = val.addressComponent.district;
            });
            //经纬度替换
            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;
            if(val.addressComponent.city==""){
                that.form.city = val.addressComponent.province;
            }else{
                that.form.city = val.addressComponent.city;
            }
            that.form.district = val.addressComponent.district;
          }
        },
        immediate: true,
@@ -855,9 +862,6 @@
        });
      },
      rowUpdate(row, index, done, loading) {
        row.deptId = row.deptId.join(",");
        // row.jd=row.map.latitude;
        // row.wd=row.map.longitude;
        update(row).then(() => {
          // this.initFlag = false;
          this.onLoad(this.page);
@@ -930,11 +934,16 @@
          });
      },
      beforeOpen(done, type) {
        debugger;
        if (["edit", "view"].includes(type)) {
          getclient(this.form.id).then(res => {
            this.form = res.data.data;
            this.isEdit=true;
          });
        }
        if (["add"].includes(type)) {
          this.isEdit=false;
        }
        // this.initFlag = true;
        done();
      },
src/views/system/cs.vue
@@ -177,6 +177,7 @@
      datas: [], //cc
      loadings: true, //等待
      querys: {}, //搜索
      isEdit:false,
      pages: {
        pageSize: 10,
        currentPage: 1,
@@ -727,11 +728,13 @@
      // form是表单或者表格绑定的数据集,v-model='form'
      handler(val) {
        if (val) {
          getDetail(this.form.id).then((res) => {
            this.form = res.data.data;
          });
          this.form.wd = val.latitude;
          this.form.jd = val.longitude;
          if(that.isEdit){
            getDetail(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) {
@@ -902,6 +905,7 @@
    },
    beforeOpen(done, type) {
      if (["edit"].includes(type)) {
        that.isEdit=true;
        getDetail(this.form.id).then((res) => {
          if (this.form.type == "1") {
            const data = res.data.data;
@@ -994,6 +998,10 @@
          }
        });
      }
      if (["edit"].includes(type)) {
        that.isEdit=false;
      }
      done();
    },
    searchReset() {