소스 검색

fix checkSpaceControl 去掉空间权限

anxiaoxia 1 년 전
부모
커밋
44ec446b59
1개의 변경된 파일95개의 추가작업 그리고 95개의 파일을 삭제
  1. 95 95
      src/packagesEnv/pages/officehome/components/work-scene-hand.wpy

+ 95 - 95
src/packagesEnv/pages/officehome/components/work-scene-hand.wpy

@@ -175,20 +175,20 @@
 </template>
 <script>
 
-import wepy from '@wepy/core';
-import moment from 'moment';
-import store from '@/store';
-import config from '@/config';
-import { mapActions } from '@wepy/x';
+import wepy from '@wepy/core'
+import moment from 'moment'
+import store from '@/store'
+import config from '@/config'
+import { mapActions } from '@wepy/x'
 import { saveBatchCustomScene } from '@/packagesEnv/api/officehome.js'
 import { checkSpaceControl } from '@/packagesEnv/pages/common.js'
 function HHmm(time, num) {
-  const HH = time.slice(num, num + 2);
-  const mm = time.slice(num + 2, num + 4);
+  const HH = time.slice(num, num + 2)
+  const mm = time.slice(num + 2, num + 4)
   return `${HH}:${mm}`
 }
-let timer = null;
-let isClickTimer = null;
+let timer = null
+let isClickTimer = null
 wepy.component({
 
   props: {
@@ -212,18 +212,18 @@ wepy.component({
   watch: {
     workDayTime(newVal) {
       if (newVal.data) {
-        clearInterval(timer);
-        timer = null;
+        clearInterval(timer)
+        timer = null
         this.getData()
         timer = setInterval(() => {
-          this.getData();
-        }, 1000 * 10);
+          this.getData()
+        }, 1000 * 10)
       }
     }
   },
   detached() {
-    clearInterval(timer);
-    timer = null;
+    clearInterval(timer)
+    timer = null
   },
   methods: {
     ...mapActions([
@@ -232,7 +232,7 @@ wepy.component({
     ]),
 
     isHasWorkTime() { // 有工作时间
-      let flag = false;
+      let flag = false
       this.workTimeList.forEach((item, idx) => {
         if (item.length !== 0) {
           flag = true
@@ -244,7 +244,7 @@ wepy.component({
       return flag
     },
     concatText(today, val) {
-      let text = '';
+      let text = ''
       if (today === val) {
         text = '今日'
       }
@@ -252,9 +252,9 @@ wepy.component({
         text = '次日'
       }
       if (Number(val) > (Number(today) + 1)) {
-        const weekDay = moment(val).weekday();
-        const weekArr = ['周日', '周一', '周二', '周三', '周四', '周五', '周六' ];
-        text = weekArr[weekDay];
+        const weekDay = moment(val).weekday()
+        const weekArr = ['周日', '周一', '周二', '周三', '周四', '周五', '周六' ]
+        text = weekArr[weekDay]
       }
       return text
     },
@@ -263,11 +263,11 @@ wepy.component({
         return '工作时间'
       }
       if (!val.length) return ''
-      const startDate = val[0].slice(0, 8);
-      const endDate = val[1].slice(0, 8);
-      const today = moment().format('YYYYMMDD');
-      let startText = this.concatText(today, startDate);
-      let endText = this.concatText(today, endDate);
+      const startDate = val[0].slice(0, 8)
+      const endDate = val[1].slice(0, 8)
+      const today = moment().format('YYYYMMDD')
+      let startText = this.concatText(today, startDate)
+      let endText = this.concatText(today, endDate)
       if (startText === endText) {
         return `已预约-${endText}`
       } else {
@@ -275,164 +275,164 @@ wepy.component({
       }
     },
     showTimeText(val, cusFlag) {  // 显示时间文案
-      const nowTime = moment().format('YYYYMMDDHHmmss');
-      let nowtimeFlag = false;
+      const nowTime = moment().format('YYYYMMDDHHmmss')
+      let nowtimeFlag = false
       val.forEach((item, idx) => {
-        const start = item[0];
-        const end = item[1];
+        const start = item[0]
+        const end = item[1]
         if (nowTime >= end) {
-          this.workTimeList.splice(idx, 1, []);  // 已经过去的从列表删除
+          this.workTimeList.splice(idx, 1, [])  // 已经过去的从列表删除
         }
         if (start <= nowTime && nowTime <= end) { // 当前在这个区间内
           this.timeText = '工作时间'
           this.setIsNowTime(true)
-          this.isWorkOff = true; // 过服务定制时间
-          this.currentTimeRange = item;
-          nowtimeFlag = true;
+          this.isWorkOff = true // 过服务定制时间
+          this.currentTimeRange = item
+          nowtimeFlag = true
         }
       })
-      if (!this.hasWorkTime) return;
+      if (!this.hasWorkTime) return
       if (!nowtimeFlag) {
-        this.currentTimeRange = this.workTimeList.find(item => item.length !== 0);
+        this.currentTimeRange = this.workTimeList.find(item => item.length !== 0)
       }
-      const startTime = HHmm(this.currentTimeRange[0], 8);
-      const endTime = HHmm(this.currentTimeRange[1], 8);
+      const startTime = HHmm(this.currentTimeRange[0], 8)
+      const endTime = HHmm(this.currentTimeRange[1], 8)
       this.timeRange = `${startTime} ~ ${endTime}`
       this.setCusTime({ startTime: startTime, endTime: endTime })
-      this.timeText = this.bookDayText(this.currentTimeRange, cusFlag); // 预约显示日期
+      this.timeText = this.bookDayText(this.currentTimeRange, cusFlag) // 预约显示日期
     },
     arrTrans(num, arr) { // 一维数组转换为二维数组
-      const iconsArr = []; // 声明数组
+      const iconsArr = [] // 声明数组
       arr.forEach((item, index) => {
-        const page = Math.floor(index / num); // 计算该元素为第几个素组内
+        const page = Math.floor(index / num) // 计算该元素为第几个素组内
         if (!iconsArr[page]) { // 判断是否存在
-          iconsArr[page] = [];
+          iconsArr[page] = []
         }
-        iconsArr[page].push(item);
-      });
-      const nowDayTime = moment().format('YYYYMMDDHHmmss');
-      let resultArr = [];
+        iconsArr[page].push(item)
+      })
+      const nowDayTime = moment().format('YYYYMMDDHHmmss')
+      let resultArr = []
       iconsArr.find((item, idx) => {
-        let itemEnd = item[1];
+        let itemEnd = item[1]
         if (nowDayTime > itemEnd) {
         } else {
           resultArr.push(item)
         }
       })
-      return resultArr;
+      return resultArr
     },
     getData() {
       this.setIsNowTime(false)
-      this.isWorkOff = false;
+      this.isWorkOff = false
       let resData = this.workDayTime.data || []
-      let timeArr = []; // 时间组
-      let cusFlag = false; // 服务定制内
-      let cusEle = {};
+      let timeArr = [] // 时间组
+      let cusFlag = false // 服务定制内
+      let cusEle = {}
       this.setCusTime({
         startTime: '',
         endTime: ''
       })
       resData.forEach((ele, eleIdx) => {
-        const nowDay = moment().format('YYYYMMDD');
-        const nowTime = moment().format('HHmmss');
-        this.inCusRangeTime = false;
+        const nowDay = moment().format('YYYYMMDD')
+        const nowTime = moment().format('HHmmss')
+        this.inCusRangeTime = false
         if (ele.date === nowDay) { // 是当天且有服务定制
-          const list = ele.spaceCustomContentList || [];
+          const list = ele.spaceCustomContentList || []
           for (let i = 0; i < list.length; i++) {
             const spaceItem = list[i]
             if (spaceItem.startTime && nowTime >= spaceItem.startTime && nowTime < spaceItem.endTime) {
-              cusFlag = true;
-              cusEle = spaceItem;
-              timeArr.push(`${ele.date}${spaceItem.startTime}`);
-              timeArr.push(`${ele.date}${spaceItem.endTime}`);
+              cusFlag = true
+              cusEle = spaceItem
+              timeArr.push(`${ele.date}${spaceItem.startTime}`)
+              timeArr.push(`${ele.date}${spaceItem.endTime}`)
             }
           }
         }
         if (ele.customSceneList) {
-          let bookItemArr = ele.customSceneList;
+          let bookItemArr = ele.customSceneList
           bookItemArr.forEach((item, idx) => {
             // 审批通过 或者 没有审批条件 时间存入展示列表中
             if (item.approvalStatus === 1 || !item.hasOwnProperty('approvalStatus')) {
-              timeArr.push(`${item.startDate}${item.startTime}`);
-              timeArr.push(`${item.startDate}${item.endTime}`);
+              timeArr.push(`${item.startDate}${item.startTime}`)
+              timeArr.push(`${item.startDate}${item.endTime}`)
             }
           })
         }
       })
       if (cusFlag) { // 服务定制时间
-        this.isWorkOff = false;
-        this.inCusRangeTime = true;
-        this.hasWorkTime = true;
+        this.isWorkOff = false
+        this.inCusRangeTime = true
+        this.hasWorkTime = true
         this.setIsNowTime(true)
       }
 
       if (timeArr.length === 0) {  // 没有预约时间
-        this.workTimeList = [];
-        this.hasWorkTime = false;
+        this.workTimeList = []
+        this.hasWorkTime = false
         return
       }
 
-      timeArr.sort(); //  排序
-      let timeArrCopy = JSON.parse(JSON.stringify(timeArr));
+      timeArr.sort() //  排序
+      let timeArrCopy = JSON.parse(JSON.stringify(timeArr))
       timeArrCopy.forEach((item, idx) => {
-        let date = Number(item.slice(0, 8));
-        let time = item.slice(8, 16);
-        let nextItem = timeArrCopy[idx + 1] || '';
-        let nextDate = Number(nextItem.slice(0, 8));
-        let nextTime = nextItem.slice(8, 16);
+        let date = Number(item.slice(0, 8))
+        let time = item.slice(8, 16)
+        let nextItem = timeArrCopy[idx + 1] || ''
+        let nextDate = Number(nextItem.slice(0, 8))
+        let nextTime = nextItem.slice(8, 16)
         if (time === nextTime && nextDate === date) { // 去重
-          timeArr.splice(timeArr.findIndex(jtem => jtem === item), 1);
-          timeArr.splice(timeArr.findIndex(jtem => jtem === nextItem), 1);
+          timeArr.splice(timeArr.findIndex(jtem => jtem === item), 1)
+          timeArr.splice(timeArr.findIndex(jtem => jtem === nextItem), 1)
         }
         if (time === '240000' && nextTime === '000000' && (nextDate - 1 === date)) { // 时间段跨天相邻
-          timeArr.splice(timeArr.findIndex(jtem => jtem === item), 1);
-          timeArr.splice(timeArr.findIndex(jtem => jtem === nextItem), 1);
+          timeArr.splice(timeArr.findIndex(jtem => jtem === item), 1)
+          timeArr.splice(timeArr.findIndex(jtem => jtem === nextItem), 1)
         }
       })
       let timeArrResult = this.arrTrans(2, timeArr) // 一维数组转换为二维数组
       if (timeArrResult.length === 0) {
-        this.hasWorkTime = false;
+        this.hasWorkTime = false
         return
       }
-      this.workTimeList = JSON.parse(JSON.stringify(timeArrResult));
-      this.hasWorkTime = this.isHasWorkTime();
-      this.showTimeText(timeArrResult, cusFlag);// 显示时间文案
+      this.workTimeList = JSON.parse(JSON.stringify(timeArrResult))
+      this.hasWorkTime = this.isHasWorkTime()
+      this.showTimeText(timeArrResult, cusFlag)// 显示时间文案
     },
     handleWorkOff() { // 我要离开
-      if (!checkSpaceControl(this.isControl)) return;
+    //   if (!checkSpaceControl(this.isControl)) return
       if (wx.canIUse('vibrateShort')) {
-        wx.vibrateShort();
+        wx.vibrateShort()
       } else {
-        wx.vibrateLong();
+        wx.vibrateLong()
       }
       this.$emit('component-open-sceneShowpop', 'showWorkOff')
-      const currentStart = this.currentTimeRange[0];
-      const currenEnd = this.currentTimeRange[1];
-      let paramsArr = [];
+      const currentStart = this.currentTimeRange[0]
+      const currenEnd = this.currentTimeRange[1]
+      let paramsArr = []
       this.workDayTime.data.forEach((ele, eleIdx) => {
-        let bookItemArr = ele.customSceneList || [];
+        let bookItemArr = ele.customSceneList || []
         if (bookItemArr.length > 0) {
           bookItemArr.find(item => {
             const itemStart = `${item.startDate}${item.startTime}`
             const itemEnd = `${item.startDate}${item.endTime}`
             if (currentStart <= itemStart && itemEnd <= currenEnd) {
               item.type = 3
-              item.endTimeReal = moment().format('HHmmss');
-              paramsArr.push(item);
+              item.endTimeReal = moment().format('HHmmss')
+              paramsArr.push(item)
             }
           })
         }
       })
       saveBatchCustomScene({ 'historyBookList': paramsArr, 'type': 'workOff' }).then(res => {
-        this.$emit('component-get-workTimeData');
-        clearTimeout(isClickTimer);
+        this.$emit('component-get-workTimeData')
+        clearTimeout(isClickTimer)
       })
     },
 
     changeWorkStatus() {
-      if (!checkSpaceControl(this.isControl)) return;
+    //   if (!checkSpaceControl(this.isControl)) return
       this.$emit('component-open-workTimePop', true)
-      this.$emit('component-EquipType-workTimePop', 'all');
+      this.$emit('component-EquipType-workTimePop', 'all')
     }
   }