王飞
2025-03-07 c5e49c10499435802a6551b98772f95660c6f85a
pages/index/fence.vue
@@ -2,7 +2,7 @@
   <view class="template-job tn-safe-area-inset-bottom tn-skeleton">
      <!-- 顶部自定义导航 -->
      <tn-nav-bar fixed style="position: absolute;z-index: 999999999;">
      <tn-nav-bar :isBack="false" fixed style="position: absolute;z-index: 999999999;">
         <text class="title_linespan" @click="goTag">绘制</text>
         <text v-if="isAchor==false" class="title_linespan"
@@ -45,7 +45,7 @@
                  </view>
                  <view style="display: flex;margin-top: 10px;font-size: 17px;">
                     {{item.baoliu7}}
                     是否启用:<tn-switch v-model="item.baoliu7==1 ? true : false"
                        style="position: absolute;left: 85%;" @change="isopen(item, $event)"
                        :size="num"></tn-switch>
@@ -67,10 +67,12 @@
                     <tn-input disabled v-model="form.type" @click="show1 = true" inputAlign="right" />
                  </tn-form-item>
                  <tn-form-item label="关联部门:" labelWidth='100rpx'>
                     <tn-input v-model="form.bumen" type="select" @click="show2 = true" inputAlign="right"
                        placeholder="请选择关联部门" />
                     <tn-action-sheet :disabled="form.disable" :list="bumenList" v-model="show2"
                        @click="bymenCallback"></tn-action-sheet>
                     <!-- <tn-input v-model="form.bumen" type="select" @click="show2 = true" inputAlign="right"
                        placeholder="请选择关联部门" /> -->
                     <uni-data-select placeholder="请选择关联部门" v-show="form.disable" v-model="form.bumen"
                        :localdata="bumenList" @change="bymenCallback"></uni-data-select>
                     <!-- <tn-action-sheet :disabled="form.disable" :list="bumenList" v-model="show2"
                        @click="bymenCallback"></tn-action-sheet> -->
                  </tn-form-item>
                  <tn-form-item label="围栏高度:" labelWidth='100rpx'>
                     <tn-input disabled v-model="form.baoliu1" inputAlign="right"
@@ -88,7 +90,7 @@
      <tn-skeleton :show="showSkeleton"></tn-skeleton>
      <successCom ref="refSuccess"></successCom>
      <drawCom v-show="lock==true" :formfence="formfence" @goAchor="goAchor"></drawCom>
      <drawCom v-show="lock==true" @goAchor="goAchor" @manualRefresh="manualRefresh"></drawCom>
      <tn-modal v-model="show" :title="title" :content="content" :button="button" @click="modalclick"></tn-modal>
   </view>
</template>
@@ -189,6 +191,7 @@
               type: '进入报警',
               list: [],
               disable: false,
               company: this.company,
            },
            num: 40,
            isAchor: false,
@@ -237,6 +240,7 @@
         }
      },
      mounted() {
         console.log(111111);
         this.findbumenall()
         this.topheight = this.vuex_custom_bar_height + 15
         setTimeout(() => {
@@ -251,6 +255,21 @@
      },
      methods: {
         manualRefresh() { //保存围栏成功刷新围栏列表页面
            this.isAchor = false
            this.lock = false
            // 调用 handleRefresh 方法,刷新 dataList 组件
            this.handleRefresh({
               page: 1,
               size: this.pageSize
            }, () => {
               // 可选:刷新完成后执行的操作
               // this.$refs.refSuccess.showBox({
               //    type: 'success',
               //    txt: '刷新成功'
               // });
            });
         },
         isopen(item, e) {
            this.form.name = item.name
            if (item.baoliu7 == 1) {
@@ -263,23 +282,20 @@
               // size: data.size,
            }
            // item.baoliu7 = e ? 1 : 0; // 根据开关状态更新
            if (this.vuex_is_login) {
            if (e == true) {
               FenceGuanBi(params).then((res) => {
               })
                  FenceGuanBi(params).then((res) => {})
            } else {
               FenceKaiQi(params).then((res) => {
               })
                  FenceKaiQi(params).then((res) => {})
               }
            }
         },
         submitForm() {
            this.form.list = this.list
            if (this.form.shape=="圆形") {
               console.log(this.form);
               if (this.vuex_is_login) {
               submitper(this.form).then((res) => {
                  console.log(res);
                  if (res.code == 0) {
                     // this.form.lonlat=res.data.baoliu2+";"+res.data.baoliu3
                     // this.tips=false
@@ -291,6 +307,7 @@
                     });
                  }
               })
               }
            }else{
            if (this.form.tagId=='') {
               this.$refs.refSuccess.showBox({
@@ -335,11 +352,11 @@
               }
            }
            }
            console.log(this.form);
            console.log();
            updateFence(this.form).then((res) => {
               console.log(res);
            const json = {}
            json.name = this.form.name
            json.bumen = this.form.bumen
            if (this.vuex_is_login) {
               updateFence(json).then((res) => {
               if (res.code == 0) {
                  this.showpopup = false
                  // this.list.splice(this.deleindex,1) 
@@ -355,13 +372,11 @@
                  });
               }
            })
            }
         },
         shapeCallback(index) {
            this.form.shape = this.shapeList[index].text;
            // this.form.baoliu6 = this.actionSheetList[index].text;
            console.log(this.shapeList[index].text);
            if (this.shapeList[index].text == '圆形') {
               this.isshape = true
            } else {
@@ -371,28 +386,25 @@
         bymenCallback(index) {
            this.form.bumen = this.bumenList[index].text;
            // this.form.baoliu6 = this.actionSheetList[index].text;
            console.log(this.bumenList[index].text);
         },
         typeCallback(index) {
            this.form.type = this.typeList[index].text;
            // this.form.baoliu6 = this.actionSheetList[index].text;
            console.log(this.typeList[index].text);
         },
         findbumenall() {
            if (this.vuex_is_login) {
            findbumen().then((res) => {
               console.log(res);
               if (res.code == 0) {
                  for (var i = 0; i < res.data.length; i++) {
                     var json = {}
                     json.text = res.data[i].departmentName
                     // .textres.data[i]
                     this.bumenList.push(json)
                  }
                     // for (var i = 0; i < res.data.length; i++) {
                     //    var json = {}
                     //    json.text = res.data[i].departmentName
                     //    // .textres.data[i]
                     //    this.bumenList.push(json)
                     this.bumenList = res.data.map(item => ({
                        value: item.departmentName,
                        text: item.departmentName
                     }));
                     // }
                  // this.form.lonlat=res.data.baoliu2+";"+res.data.baoliu3
                  // this.tips=false
                  // this.disable=false
@@ -403,33 +415,30 @@
                  });
               }
            })
            }
         },
         modalclick(e) {
            console.log(e);
            if (e.index == 1) {
               const params = {
                  name: this.delename,
                  // size: data.size,
               }
               if (this.vuex_is_login) {
               deleFence(params).then((res) => {
                  console.log(res);
                  if (res.code == 0) {
                     this.delename = ''
                     console.log(this.list);
                     console.log(e.index);
                     this.list.splice(this.deleindex, 1)
                     console.log(this.list);
                     this.deleindex = -1
                  }
               })
               }
            }
            this.show = false;
         },
         editClick(e, i) {
            this.editindex = i
            this.showpopup = true
            // console.log(e);
            this.formfence.name = e.name
            this.formfence.baoliu1 = e.baoliu1
            this.formfence.zuobiao = e.zuobiao
@@ -439,37 +448,21 @@
            this.formfence.tagId = e.tagId
            this.formfence.bumen = e.bumen
            this.formfence.disable = true
            this.formfence.company = this.company
            this.form = this.formfence
            console.log(this.formfence);
            // this.lock = true
            console.log(1111111);
         },
         deleteClick(e, i) {
            console.log(e);
            this.deleindex = i
            this.delename = e.name
            console.log(2222222);
            this.show = true;
         },
         goAchor() {
            this.isAchor = false
            this.lock = false
            console.log(2323323);
            // uni.reLaunch({
            //    url: '/pages/index/equipmentCom'
            // });
            // this.$emit('goAchor');
         },
         goTag() {
            // this.isAchor = true
            this.lock = true
            console.log(2323323);
            // findTag
         },
         // 模拟请求加载数据
@@ -479,9 +472,9 @@
               size: data.size,
               company: this.company,
            }
            if (this.vuex_is_login) {
            findFence(params).then((res) => {
               console.log(res);
               if (res.code == 0) {
                  let list = [];
                  setTimeout(() => {
@@ -489,7 +482,7 @@
                     for (var i = 0; i < res.data.records.length; i++) {
                        list.push(res.data.records[i]);
                     }
                     console.log(list);
                     this.list = [...this.list, ...list];
                     callback({
                        list: this.list,
@@ -498,18 +491,24 @@
                  }, 1500);
               }
            })
            }else{
               callback({
                  list: [],
                  total: 0
               });
            }
         },
         handleSearch(data, callback) {
            console.log(555555555);
            const params = {
               current: 1,
               size: 10,
               objectid: this.keyword,
               company: this.company,
            }
            if (this.vuex_is_login) {
            findFence(params).then((res) => {
               console.log(res);
               this.list = []
               if (res.code == 0) {
                  let list = [];
@@ -518,7 +517,6 @@
                     for (var i = 0; i < res.data.records.length; i++) {
                        list.push(res.data.records[i]);
                     }
                     console.log(list);
                     this.list = [...this.list, ...list];
                     callback({
                        list: this.list,
@@ -527,31 +525,19 @@
                  }, 1500);
               }
            })
            // let name = this.keyword
            // console.log();
            // findPerson(name).then((res) => {
            //    if (res.code == 0) {
            //       this.perlist = res.data
            //       console.log(this.perlist);
            //    } else {
            //       this.$refs.refSuccess.showBox({
            //          type: 'error',
            //          txt: res.msg
            //       });
            //    }
            // })
            }
         },
         // 模拟请求数据刷新
         handleRefresh(data, callback) {
            console.log(555555555555555);
            const params = {
               current: data.page,
               size: data.size,
               objectid: data.objectid,
               company: this.company,
            }
            console.log(data);
            findFence(data).then((res) => {
            if (this.vuex_is_login) {
               findFence(params).then((res) => {
               if (res.code == 0) {
                  let list = [];
                  setTimeout(() => {
@@ -559,10 +545,8 @@
                     for (var i = 0; i < res.data.records.length; i++) {
                        list.push(res.data.records[i]);
                     }
                     console.log(list);
                     this.list = []
                     this.list = [...this.list, ...list];
                     console.log(this.list);
                     callback({
                        list: this.list,
                        total: res.data.total
@@ -570,14 +554,7 @@
                  }, 1500);
               }
            })
            // console.log(2222222222);
            // setTimeout(() => {
            //    this.list = [];
            //    for (var i = 0; i < 3; i++) {
            //       this.list.push(i);
            //    }
            //    callback({ list: this.list, total: 30 });
            // }, 1500);
            }
         },
      }
   }