Browse Source

fix: 加班展示功能

chenzhen2 2 years ago
parent
commit
25042d7cb7

+ 15 - 2
src/apis/envmonitor.ts

@@ -169,7 +169,20 @@ export const getWorkTimeList = (params: any) => {
   return https().request<any>(`${duoduoenvService}customScene/queryCustomAndScence?${params}`)
 }
 
-export const querySpaceSceneConfig=(params: any)=>{
-  return https().request<any>(`${setupService}scene/querySpaceSceneConfig${params}`, Method.GET, undefined, ContentType.json)
+/**
+ * 
+ * @param params 查询场景配置
+ * @returns 
+ */
+export const querySpaceSceneConfig = (params: any) => {
+  return https().request<any>(`${setupService}scene/querySpaceSceneConfig?${comParams}&${params}`, Method.GET, undefined, ContentType.json)
 }
 
+/**
+ *  查询加班记录
+ */
+export const queryCustomAndScence = (params: any) => {
+  return https().request<any>(`${duoduoenvService}customScene/queryCustomAndScence?${comParams}&${params}`, Method.GET, undefined, ContentType.json)
+}
+
+

+ 15 - 1
src/apis/user.ts

@@ -3,8 +3,13 @@ import { https } from '@/utils/https'
 import { ContentType, Method } from 'axios-mapper'
 import { setupService, testApi } from '@/config'
 
+/**
+ * 
+ * @param data 获取用户信息
+ * @returns 
+ */
 export const getUsersInfo = () => {
-  return https().request<RootObject<any>>(`${setupService}user/zjCheckToken`, Method.GET, undefined, ContentType.json)
+  return https().request(`server1/userInfo`, Method.GET, undefined, ContentType.json)
 }
 /**
  * 获取企业用户列表
@@ -12,3 +17,12 @@ export const getUsersInfo = () => {
 export const getCompanyUsers = () => {
   return https().request('/api/user/companyUsers', Method.GET, undefined, ContentType.json)
 }
+
+/**
+ * 
+ * @param data 登录
+ * @returns 
+ */
+export const login = (data: any) => {
+  return https().request(`server/login`, Method.POST, data, ContentType.json)
+}

+ 1 - 0
src/utils/https.ts

@@ -11,6 +11,7 @@ export const https = (configobj: any = { timeout: '' }) => {
     baseURL: networkConfig.host,
     headers: {
       'token': getToken(),
+      'sso-token': getToken(),
       'X-Forwarded-Token': getToken()
     }
   }

+ 67 - 29
src/utils/index.ts

@@ -95,7 +95,7 @@ export const toggleClass = (ele: HTMLElement, className: string) => {
   }
   ele.className = classString
 }
-export const setQueryConfig = function(queryConfig: any) {
+export const setQueryConfig = function (queryConfig: any) {
   let _str = ''
   for (const o in queryConfig) {
     if (queryConfig[o] !== -1) {
@@ -107,7 +107,7 @@ export const setQueryConfig = function(queryConfig: any) {
 }
 
 // 获取用户信息
-export const getUserInfo = function() {
+export const getUserInfo = function () {
   let userInfo = store.state.user
   const paramsInfo: any = {
     openid: Keys.openid,
@@ -124,7 +124,7 @@ export const getUserInfo = function() {
 }
 
 // 地址通用参赛携带
-export const getComparams = function() {
+export const getComparams = function () {
   let userInfo = store.state.user
   let paramsInfo: any = {
     openid: Keys.openid,
@@ -144,7 +144,7 @@ export const getComparams = function() {
   return paramsInfo
 }
 
-export const formatDate = function(split: string = 'YYYYMMDD', date: any = new Date()) {
+export const formatDate = function (split: string = 'YYYYMMDD', date: any = new Date()) {
   //三目运算符
   const dates = date ? date : new Date()
   //年份
@@ -174,14 +174,14 @@ export const formatDate = function(split: string = 'YYYYMMDD', date: any = new D
 }
 
 // 把字符串 (yyyymmdd) 转换成日期格式(yyyy-mm-dd)
-export const formatDateStr = function(date: any) {
-  if(date){
+export const formatDateStr = function (date: any) {
+  if (date) {
     return date.replace(/^(\d{4})(\d{2})(\d{2})$/, '$1-$2-$3')
-  }else{
+  } else {
     return ''
   }
 }
-export const getTomorrow = function(split: any = '') {
+export const getTomorrow = function (split: any = '') {
   let dates = new Date()
   dates.setTime(dates.getTime() + 24 * 60 * 60 * 1000)
   const Year: number = dates.getFullYear()
@@ -263,7 +263,7 @@ export function getPreMonth(formatType: any = '') {
 /**
  * 格式化日期 3月21日
  */
-export const formatEnergyDate = function(time: any) {
+export const formatEnergyDate = function (time: any) {
   //三目运算符
   const dates = time ? new Date(time) : new Date()
   //月份下标是0-11
@@ -282,14 +282,14 @@ export const formatEnergyDate = function(time: any) {
   ]
 }
 
-export const setSession = function(key: any = '', obj: any = '') {
+export const setSession = function (key: any = '', obj: any = '') {
   if (obj) {
     let str = JSON.stringify(obj)
     sessionStorage.setItem(key, str)
   }
 }
 
-export const getSession = function(key: any = '') {
+export const getSession = function (key: any = '') {
   if (key) {
     let obj: any = sessionStorage.getItem(key)
     if (obj) {
@@ -304,7 +304,7 @@ export const getSession = function(key: any = '') {
  * @param key
  * @param obj
  */
-export const setLocalStorage = function(key: any = '', obj: any = '') {
+export const setLocalStorage = function (key: any = '', obj: any = '') {
   if (obj) {
     if (obj instanceof Object) {
       let str = JSON.stringify(obj)
@@ -319,7 +319,7 @@ export const setLocalStorage = function(key: any = '', obj: any = '') {
  * 获取本地存储
  * @param key
  */
-export const getLocalStorage = function(key: any) {
+export const getLocalStorage = function (key: any) {
   if (key) {
     let obj: any = localStorage.getItem(key)
     if (obj) {
@@ -335,14 +335,14 @@ export const getLocalStorage = function(key: any) {
  * 存储最新的空间信息
  * @param spaceInfo
  */
-export const setLocalNewSpaceInfo = function(spaceInfo: any) {
+export const setLocalNewSpaceInfo = function (spaceInfo: any) {
   setLocalStorage(Keys.storageSpaceInfoKey, spaceInfo)
 }
 
 /**
  * 获取最新的空间信息
  */
-export const getLocalNewSpaceInfo = function() {
+export const getLocalNewSpaceInfo = function () {
   let spaceInfo: any = getLocalStorage(Keys.storageSpaceInfoKey)
   return spaceInfo
 }
@@ -350,13 +350,13 @@ export const getLocalNewSpaceInfo = function() {
 /**
  * 本地缓存建筑,楼层,空间
  */
-export const localStorageSpaceId = function(buildingId: any, floorId: any, spaceId: any) {
+export const localStorageSpaceId = function (buildingId: any, floorId: any, spaceId: any) {
   let spaceMap: any = getLocalStorage(Keys.storageSpaceKey) ? getLocalStorage(Keys.storageSpaceKey) : {}
   let key: any = `${buildingId},${floorId}`
   spaceMap[key] = spaceId
   setLocalStorage(Keys.storageSpaceKey, spaceMap)
 }
-export const getStorageSpaceId = function() {
+export const getStorageSpaceId = function () {
   let spaceMap: any = getLocalStorage(Keys.storageSpaceKey)
   return spaceMap
 }
@@ -364,7 +364,7 @@ export const getStorageSpaceId = function() {
 /**
  *  本地缓存建筑对应的楼层
  */
-export const localStorageFloor = function(buildingId: any, floorId: any) {
+export const localStorageFloor = function (buildingId: any, floorId: any) {
   let floorMap: any = getLocalStorage(Keys.storageFloorKey) ? getLocalStorage(Keys.storageFloorKey) : {}
   floorMap[buildingId] = floorId
   setLocalStorage(Keys.storageFloorKey, floorMap)
@@ -374,7 +374,7 @@ export const localStorageFloor = function(buildingId: any, floorId: any) {
  * @param buildingId
  * @param floorId
  */
-export const getLocalStorageFloor = function() {
+export const getLocalStorageFloor = function () {
   let floorMap: any = getLocalStorage(Keys.storageFloorKey)
   return floorMap
 }
@@ -383,7 +383,7 @@ export const getLocalStorageFloor = function() {
  * 缓存搜索页面最近查找的数据
  * @param item
  */
-export const setLocalSearchSpace = function(item: any) {
+export const setLocalSearchSpace = function (item: any) {
   let historySearch: any = getLocalStorage(Keys.historySearchSpaceKey)
   let flag = false
   historySearch = historySearch ? historySearch : []
@@ -401,14 +401,14 @@ export const setLocalSearchSpace = function(item: any) {
 /**
  * 获取搜索页面最近查找的数据
  */
-export const getLocalSearchSpace = function() {
+export const getLocalSearchSpace = function () {
   return getLocalStorage(Keys.historySearchSpaceKey) ? getLocalStorage(Keys.historySearchSpaceKey) : []
 }
 
 /**
  *存储当前项目id
  */
-export const setLocalProjectId = function(projectId: any) {
+export const setLocalProjectId = function (projectId: any) {
   setLocalStorage(Keys.projectId, projectId)
 }
 
@@ -416,20 +416,20 @@ export const setLocalProjectId = function(projectId: any) {
  * 获取当前项目id
  * @param projectId
  */
-export const getLocalProjectId = function() {
+export const getLocalProjectId = function () {
   return localStorage.getItem(Keys.projectId)
 }
 /**
  * 清楚当前所有的存储数据
  */
-export const clearAllLocalData = function() {
+export const clearAllLocalData = function () {
   localStorage.clear()
   Cookies.remove('userInfo')
   Cookies.remove('projectId')
   Cookies.remove('accessToken')
 }
 
-export const doHandleMonth = function(month: any) {
+export const doHandleMonth = function (month: any) {
   let m: any = month
   if (month.toString().length == 1) {
     m = '0' + month
@@ -437,7 +437,7 @@ export const doHandleMonth = function(month: any) {
   return m
 }
 
-export const getWeekDate = function(day: any) {
+export const getWeekDate = function (day: any) {
   let weeks: any = new Array(
     '周日',
     '周一',
@@ -451,14 +451,14 @@ export const getWeekDate = function(day: any) {
   return week
 }
 
-export const getDate = function(date: any) {
+export const getDate = function (date: any) {
   return date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
 }
 
 /**
  * 初始化24:00
  */
-export const getTimers = function() {
+export const getTimers = function () {
   let timers: any = new Array()
   for (let i = 0; i <= 24; i++) {
     let str: any = '00'
@@ -475,7 +475,7 @@ export const getTimers = function() {
   return timers
 }
 
-export const getNowTime = function() {
+export const getNowTime = function () {
   let date: any = new Date()
   let hours: any = date.getHours()
   let minute: any = date.getMinutes()
@@ -489,3 +489,41 @@ export const getNowTime = function() {
   }
   return [hours, index]
 }
+
+// 获取当前真实时间
+export const getRelNowTime = function () {
+  let date: any = new Date()
+  let hours: any = date.getHours()
+  let minute: any = date.getMinutes()
+  return hours + "" + minute + "00"
+}
+
+/**
+ * 
+ * @returns js获取mac地址
+ */
+export const getMacAddress = function () {
+  let obj: any = new ActiveXObject("WbemScripting.SWbemLocator");
+  let s: any = obj.ConnectServer(".");
+  let properties: any = s.ExecQuery("Select * from Win32_NetworkAdapterConfiguration");
+  let e: any = new Enumerator(properties);
+  let output: any = '';
+  while (!e.atEnd()) {
+    e.moveNext();
+    var p = e.item();
+    if (!p) continue;
+    if (p.IPEnabled) return p.MACAddress;
+  }
+  return "";
+}
+
+/**
+ * 19000转成19:00
+ */
+export const formatTimerStr = function (timer: any) {
+  if (timer) {
+    return (timer / 10000).toFixed(2)
+  } else {
+    return ''
+  }
+}

+ 2 - 1
src/utils/mapIcon.ts

@@ -259,7 +259,8 @@ export const getWorkType = function(type: string) {
   } else if (type === '313' || type === '314' || type === '315') {
     typeName = '开放'
   } else {
-    typeName = '其它'
+    // typeName = '其它'
+    typeName = '开放'
   }
   return typeName
 }

+ 28 - 11
src/views/choiceSpace/choiceProject.vue

@@ -2,10 +2,14 @@
   <div class="choice-project">
     <van-search placeholder="请输入搜索关键词" />
     <div class="choice-content">
-      <div class="choice-item" 
-      :key="index"
-      @click="goCheckSpace(item)"
-      v-for="(item,index) in 5">博锐尚格科技股份有限公司</div>
+      <div
+        class="choice-item"
+        :key="index"
+        @click="goCheckSpace(item)"
+        v-for="(item, index) in projects"
+      >
+        {{ item.localName }}
+      </div>
     </div>
   </div>
 </template>
@@ -15,6 +19,7 @@ import { defineComponent, nextTick, onMounted, reactive, toRefs } from "vue";
 import { useRoute, onBeforeRouteUpdate } from "vue-router";
 import { Search } from "vant";
 import router from "@/router";
+import { getUsersInfo } from "@/apis/user";
 
 export default defineComponent({
   components: {
@@ -22,17 +27,29 @@ export default defineComponent({
   },
   setup() {
     const route: any = useRoute();
-    const data = reactive({
+    const projects: any = [];
+    const proxyData = reactive({
       route: route,
       transitionName: "slide-right",
       showHeader: false,
       // 去选择空间
-      goCheckSpace(item:any){
-        router.push({path:'/choice-space'})
-      }
+      goCheckSpace(item: any) {
+        router.push({ path: "/choice-space", query: { id: item.id } });
+      },
+      projects: projects,
+      getUsersInfo() {
+        getUsersInfo().then((res) => {
+          let resData: any = res;
+          let projects: any = resData?.projects ?? [];
+          proxyData.projects = projects;
+        });
+      },
+    });
+    onMounted(() => {
+      proxyData.getUsersInfo();
     });
     return {
-      ...toRefs(data),
+      ...toRefs(proxyData),
     };
   },
 });
@@ -40,7 +57,7 @@ export default defineComponent({
 <style lang="scss" scoped>
 .choice-project {
   width: 100%;
-  height: 100%;
+  // height: 100%;
   background: #fff;
   padding: 5px 20px;
 }
@@ -83,7 +100,7 @@ export default defineComponent({
       font-size: 16px;
       line-height: 26px;
       color: #1f2429;
-      border-bottom: 1px solid #E4E6E7;;
+      border-bottom: 1px solid #e4e6e7;
     }
   }
 }

+ 19 - 8
src/views/envmonitor/components/ScenarioConfig.vue

@@ -4,15 +4,9 @@
       class="scene-item"
       :key="'scene' + index"
       @click="checkScenario(item)"
-      :style="{
-        flex:
-          scenarioArr.length && scenarioArr.length == 2 && item.id === activeId
-            ? 2
-            : 1,
-      }"
+      :style="{flex: scenarioArr.length && scenarioArr.length == 2 && item.id === activeId? 2 : 1,}"
       :class="item.id === activeId ? 'scene-active' : ''"
-      v-for="(item, index) in scenarioArr"
-    >
+      v-for="(item, index) in scenarioArr">
       <img :src="item.img" alt="" />
       <span>{{ item.name }}</span>
     </div>
@@ -27,6 +21,7 @@ import {
   onBeforeMount,
   onMounted,
   ref,
+  watch
 } from "vue";
 import { useRouter } from "vue-router";
 import { parseImgUrl } from "@/utils";
@@ -34,6 +29,12 @@ import { UserActionTypes } from "@/store/modules/user/action-types";
 import { useStore } from "@/store";
 
 export default defineComponent({
+  props: {
+    projectId: {
+      type: String,
+      default: () => ''
+    }
+  },
   setup(props) {
     let router: any = useRouter();
     const store = useStore();
@@ -65,6 +66,15 @@ export default defineComponent({
         proxyData.activeId = item.id;
       },
     });
+    watch(
+        props,
+        (newProps: any) => {
+          proxyData.scenarioArr = newProps.scenarioArr
+          // if (newProps.spaceId) {   // 空间id改变的重新获取值调用接口
+          //
+          // }
+        }
+    )
     return {
       ...toRefs(proxyData),
     };
@@ -106,4 +116,5 @@ export default defineComponent({
 }
 </style>
 <style lang="scss">
+
 </style>

+ 92 - 3
src/views/envmonitor/components/WorkConfig.vue

@@ -7,7 +7,7 @@
         <span>工作时间</span>
         <span>09:00~20:00</span>
       </div>
-      <div class="time-btn">
+      <div class="time-btn" @click="triggerWork">
         <span> 预约</span>
         <span>延时</span>
       </div>
@@ -30,21 +30,104 @@ import {
   onBeforeMount,
   onMounted,
   ref,
+  watch,
 } from "vue";
 import { useRouter } from "vue-router";
-import { parseImgUrl } from "@/utils";
+import {
+  formatDate,
+  formatDateStr,
+  formatTimerStr,
+  getRelNowTime,
+  parseImgUrl,
+} from "@/utils";
 import { UserActionTypes } from "@/store/modules/user/action-types";
 import { useStore } from "@/store";
 
 export default defineComponent({
-  setup(props) {
+  props: {
+    scenarioArr: {
+      type: Array,
+      default: () => [],
+    },
+    workkArr: {
+      type: Array,
+      default: () => [],
+    },
+  },
+  setup(props, contx) {
     let router: any = useRouter();
+    let timerText: any = {
+      timer: "", // 工作时间
+      showDel: false, // 是否展示我要离开按钮
+      classColor: "grey",
+    };
     const store = useStore();
     const proxyData = reactive({
       parseImgUrl: parseImgUrl,
+      scenarioArr: props.scenarioArr,
+      workkArr: props.workkArr,
       onSubmit(values: any) {
         router.push({ path: "/choice-project" });
       },
+      // 触发加班按钮
+      triggerWork() {
+        contx.emit("triggerWork");
+      },
+      timerText: timerText,
+      // 格式化日期
+      formateWorkTime() {
+        let data: any = proxyData.workkArr;
+        let nowDate: any = formatDate("YYYY-MM-DD");
+        for (let i = 0; i < data.length; i++) {
+          let date: any = formatDateStr(data[i].date);
+          let cusStartTime: any = data[i].cusStartTime;
+          let cusEndTime: any = data[i].cusEndTime;
+          let customSceneList: any = data[i]?.customSceneList ?? [];
+          let nowTime: any = getRelNowTime();
+          console.log("nowTime===" + nowTime);
+          if (date === nowDate) {
+            // 1.当天没有服务定制时间和加班时间
+            /**a.未来有服务定制和加班**/
+            // 2.当天有服务定制时间无加班时间
+            // a.在服务定制之内
+            // b.已过了服务定制和1相同处理
+            // 3.当天有服务定制和加班时间
+            // a.在服务定制之内,并和加班时间不连着
+            // b.在服务定制之内,并和加班连续
+            // c.在加班时间之内,并和后面加班时间连续
+            // d.在加班时间之内,并且和后面加班不连续
+            // e.不在服务定制之内,也不在加班时间内,但是当天和未来都有预约时间
+            /**f.不在服务定制之内,也不在加班时间内,但是当天没有预约时间,未来有预约加班 */
+
+            if ((!cusStartTime || !cusEndTime) && !customSceneList.length) {
+              proxyData.timerText.timer ===
+                "请选择工作时间段将自动开启办公服务";
+              proxyData.timerText.showDel = false;
+              proxyData.timerText.classColor = "grey";
+            } else if (cusStartTime && cusEndTime && !customSceneList.length) {
+              if (nowTime >= cusStartTime && nowTime <= cusEndTime) {
+                proxyData.timerText.timer =
+                  formatTimerStr(cusStartTime) +
+                  "~" +
+                  formatTimerStr(cusEndTime);
+                proxyData.timerText.showDel = false;
+                proxyData.timerText.classColor = "yellow";
+              } else {
+                proxyData.timerText.timer ===
+                  "请选择工作时间段将自动开启办公服务";
+                proxyData.timerText.showDel = false;
+                proxyData.timerText.classColor = "grey";
+              }
+            } else if (cusStartTime && cusEndTime && customSceneList.length) {
+              
+            }
+          }
+        }
+      },
+    });
+    watch(props, (newProps: any) => {
+      proxyData.scenarioArr = newProps.scenarioArr;
+      proxyData.workkArr = newProps.workkArr;
     });
     return {
       ...toRefs(proxyData),
@@ -63,6 +146,12 @@ export default defineComponent({
   background: #ffffff;
   box-shadow: 0px 0px 2px rgba(0, 0, 0, 0.07), 0px 4px 10px rgba(0, 0, 0, 0.05);
   border-radius: 25px;
+  .grey {
+    background: rgba(159, 183, 205, 0.15) !important;
+  }
+  .yellow {
+    background: #ffe723;
+  }
   .time-box {
     position: relative;
     // width: 69%;

+ 56 - 4
src/views/envmonitor/index.vue

@@ -4,8 +4,18 @@
     <div class="main-right popup-content">
       <!--加班start-->
       <div class="work-btn">
-        <!-- <work-config  @click="triggerWork"></work-config> -->
-        <scenario-config></scenario-config>
+        <!-- {{roomType}} -->
+        <work-config
+          v-if="
+            roomType === '开放' &&
+            scenarioArr &&
+            scenarioArr.length &&
+            scenarioArr[0].sceneType === 'OVERTIME'"
+          :scenarioArr="scenarioArr"
+          :workkArr="workkArr"
+          @triggerWork="triggerWork"
+        ></work-config>
+        <scenario-config v-if="roomType === '会议室'"></scenario-config>
       </div>
       <!--加班end-->
       <Air
@@ -45,7 +55,7 @@
       teleport="#app"
     >
       <div class="work-content">
-        <work-overtime v-if="isShowWork"></work-overtime>
+        <work-overtime v-if="isShowWork"  :workkArr="workkArr"></work-overtime>
       </div>
     </van-popup>
   </div>
@@ -85,6 +95,8 @@ import {
   getUserControlAuth,
   getSpaceMode,
   getSpaceTemp,
+  querySpaceSceneConfig,
+  queryCustomAndScence,
 } from "@/apis/envmonitor";
 import Keys from "@/constant/key";
 import {
@@ -274,7 +286,9 @@ export default defineComponent({
         code: "shidu",
       },
     ];
+    let scenarioArr: any = [];
     let realEevList: any = []; // 解决v-if报错的问题临时使用
+    let workkArr: any = [];
     const proxyData = reactive({
       parseImgUrl: parseImgUrl,
       isShowWork: false,
@@ -1439,10 +1453,47 @@ export default defineComponent({
         }, 2000);
       },
       /**
+       * 获取场景列表
+       */
+      scenarioArr: scenarioArr,
+      querySpaceSceneConfig() {
+        let params: any = {
+          spaceId: proxyData.spaceInfo.spaceId,
+        };
+        let str: any = setQueryConfig(params);
+        querySpaceSceneConfig(str).then((res) => {
+          let resData: any = res;
+          let data: any = resData?.data ?? [];
+          proxyData.scenarioArr = data;
+        });
+      },
+      /**
+       *查询空间加班记录
+       */
+      workkArr: workkArr,
+      queryCustomAndScence() {
+        let params: any = {
+          spaceId: proxyData.spaceInfo.spaceId,
+        };
+        let str: any = setQueryConfig(params);
+        queryCustomAndScence(str).then((res) => {
+          let resData: any = res?.data ?? [];
+          proxyData.workkArr = resData;
+        });
+      },
+      // 格式化当前页面展示的时间
+      formateWorkTime(){
+
+      },
+      /**
        * 空间相关的接口
        */
       init() {
         proxyData.getSpaceInfo();
+        // 获取场景配置
+        proxyData.querySpaceSceneConfig();
+        // 查询加班记录
+        proxyData.queryCustomAndScence();
         proxyData.timerSpaceInfo();
         // 获取空间下的设备信息
         proxyData.getEquipments();
@@ -1491,7 +1542,8 @@ export default defineComponent({
       }
       // 获取天气信息
       proxyData.spaceInfo = {
-        spaceId: "Sp1101080259ce19c0effb604fe380f3a00c37e3959e",
+        // spaceId: "Sp1101080259ce19c0effb604fe380f3a00c37e3959e",
+        spaceId: "Sp1101080259f55d2f60cac6450da22387e1b90567e7",
       };
       proxyData.init();
       proxyData.getWeather();

+ 15 - 4
src/views/envmonitor/workOvertime/index.vue

@@ -56,6 +56,7 @@ import {
   onMounted,
   onUpdated,
   nextTick,
+  watch
 } from "vue";
 import { swiper } from "@/utils/swiper";
 import {
@@ -68,13 +69,19 @@ import {
   parseImgUrl,
 } from "@/utils";
 import { myTime } from "@/model/workTimeData";
+import { propsToAttrMap } from "@vue/shared";
 
 export default defineComponent({
   components: {
     VanSlider: Slider,
   },
-  props: {},
-  setup() {
+  props: {
+    workkArr: {
+      type: Array,
+      default: () => [],
+    }
+  },
+  setup(props) {
     const screenInfo: any = {
       screenWidth: 0,
       screenHeight: 0,
@@ -86,6 +93,7 @@ export default defineComponent({
     let nowData: any = [];
     const proxyData = reactive({
       screenInfo: screenInfo,
+      workkArr:props.workkArr,
       startIndex: 0,
       endIndex: 0,
       nowData: nowData,
@@ -96,7 +104,6 @@ export default defineComponent({
         let addTimeEl: any = document.querySelector("#addTimeId");
         proxyData.screenInfo.screenWidth = addTimeEl.offsetWidth;
       },
-
       // 获取当前位置的坐标
       getNowPerstion(timerArr: any) {
         let nowIndex: any = getNowTime()[1];
@@ -422,7 +429,7 @@ export default defineComponent({
       dateArr: dateArr,
       myTimeArr: myTimeArr,
       getWorkTimeList() {
-        let data: any = myTime.data;
+        let data: any = proxyData.workkArr;
         proxyData.myTimeArr = data;
         proxyData.dateArr = [];
         let nowDate: any = formatDate("YYYY-MM-DD");
@@ -571,6 +578,10 @@ export default defineComponent({
     nextTick(() => {
       // proxyData.setScreennWidth()
     });
+    watch(props, (newProps: any) => {
+      proxyData.workkArr = newProps.workkArr
+      // proxyData.getWorkTimeList();
+    });
     onMounted(() => {
       // 设置dom最外层的宽
       proxyData.getWorkTimeList();

+ 31 - 9
src/views/home/index.vue

@@ -27,22 +27,20 @@
             <van-cell-group inset>
               <van-field
                 v-model="username"
-                name="用户名"
+                name="username"
                 placeholder="用户名"
                 :rules="[{ required: true, message: '请填写用户名' }]"
               />
               <van-field
                 v-model="password"
                 type="password"
-                name="密码"
+                name="password"
                 placeholder="密码"
                 :rules="[{ required: true, message: '请填写密码' }]"
               />
             </van-cell-group>
             <div>
-              <van-button round block native-type="submit">
-                提交
-              </van-button>
+              <van-button round block native-type="submit"> 提交 </van-button>
             </div>
           </van-form>
         </div>
@@ -63,10 +61,12 @@ import {
 } from "vue";
 import QrcodeVue from "qrcode.vue";
 import { useRouter } from "vue-router";
-import { parseImgUrl } from "@/utils";
+import { getMacAddress, parseImgUrl } from "@/utils";
 import { UserActionTypes } from "@/store/modules/user/action-types";
 import { useStore } from "@/store";
-import { Form, Field, CellGroup, Button } from "vant";
+import { login } from "@/apis/user";
+import { Form, Field, CellGroup, Button, Toast } from "vant";
+import { setToken } from "@/utils/cookies";
 
 export default defineComponent({
   components: {
@@ -94,9 +94,27 @@ export default defineComponent({
       username: "",
       password: "",
       onSubmit(values: any) {
-        // console.log("submit", values);
-        router.push({path:'/choice-project'})
+        console.log("submit", values);
+        let params: any = values;
+        login(params).then((res) => {
+          let resData: any = res;
+          if (resData.result === "success") {
+            setToken(resData.token);
+            router.push({ path: "/choice-project" });
+          } else {
+            Toast("登录失败!");
+          }
+        });
       },
+      /**
+       * 获取mac地址
+       */
+      getMacAddress() {
+        // let address: any = getMacAddress();
+      },
+    });
+    onMounted(() => {
+      proxyData.getMacAddress();
     });
     return {
       ...toRefs(proxyData),
@@ -251,5 +269,9 @@ export default defineComponent({
     order: 1;
     flex-grow: 0;
   }
+  .van-field__error-message {
+    position: absolute;
+    top: 15px;
+  }
 }
 </style>

+ 9 - 15
vue.config.js

@@ -62,32 +62,26 @@ module.exports = {
     proxy: {
       '/borui/duoduo-service/': {
         target: 'https://duoduoenv.sagacloud.cn',
+        // target: 'http://192.168.0.47:52015',
         changeOrigin: true,
         pathRewrite: {
           '^/borui/duoduo-service': '/duoduo-service'
         }
       },
-      '/sgh5/sso/': {
-        target: 'http://10.100.28.79/sgadmin/environment',
+      '/borui/server/': {
+        // target: 'https://duoduoenv.sagacloud.cn',
+        target: 'http://sso.sagacloud.cn',
         changeOrigin: true,
         pathRewrite: {
-          '^/sgh5/sso': '/sgh5/sso'
+          '^/borui/server': '/server'
         }
       },
-
-      '/sgh5/duoduo-service/': {
-        target: 'http://10.100.28.79',
-        // target: 'https://testenergy.zhejianglab.com',
-        changeOrigin: true,
-        pathRewrite: {
-          '^/sgh5/duoduo-service': '/sgh5/duoduo-service'
-        }
-      },
-      '/sgh5/test': {
-        target: 'http://192.168.0.65:52016',
+      '/borui/server1/': {
+        // target: 'https://duoduoenv.sagacloud.cn',
+        target: 'http://mng.sagacloud.cn',
         changeOrigin: true,
         pathRewrite: {
-          '^/sgh5/test': ''
+          '^/borui/server1': '/server'
         }
       },
       // '/api': {