Bladeren bron

工作台

CzRger 1 jaar geleden
bovenliggende
commit
a5342d34c2
4 gewijzigde bestanden met toevoegingen van 106 en 6 verwijderingen
  1. 10 0
      src/api/modules/sign.ts
  2. 1 0
      src/router/index.ts
  3. 24 2
      src/store/modules/app.ts
  4. 71 4
      src/views/staging/zby/center/index.vue

+ 10 - 0
src/api/modules/sign.ts

@@ -19,4 +19,14 @@ export const signExport = (params: any) => handle({
   method: 'post',
   params,
   config: {responseType: 'blob'}
+})
+//  当前签卡状态查询
+export const getSignSearch = () => handle({
+  url: `/${suffix}/sign/search`,
+  method: 'get',
+})
+//  签卡
+export const signIn = () => handle({
+  url: `/${suffix}/sign/in`,
+  method: 'get',
 })

+ 1 - 0
src/router/index.ts

@@ -100,6 +100,7 @@ export const initMainRouter = async () => {
                 store.dispatch('app/LOAD_PUBLIC_CONFIG', {key: 'week.submit.date'})
                 store.dispatch('app/LOAD_PUBLIC_CONFIG', {key: 'week.submit.time'})
                 store.dispatch('app/LOAD_PUBLIC_CONFIG', {key: 'week.remind.time'})
+                store.dispatch('app/LOAD_SIGN_INFO')
             } else {
                 ElMessage({
                     duration: 0,

+ 24 - 2
src/store/modules/app.ts

@@ -1,5 +1,5 @@
 import {getUserInfo} from "@/api/modules/account";
-import {getSignTime} from "@/api/modules/sign";
+import {getSignTime, getSignSearch} from "@/api/modules/sign";
 import {ElMessage} from "element-plus";
 import {getSeatDutyPersonSearch} from "@/api/modules/seat";
 import {getConfigConfigKey, editConfigEditConfigKey} from "@/api/modules/config";
@@ -13,6 +13,7 @@ const state = {
 	userInfo: <any>{},
 	userRoleList: [],
 	timestamp: new Date().getTime(),
+	tempTimestamp: new Date().getTime(),
 	weekStart: 6,	//	日历起始日期,周六
 	weeklySubmitDay: 5,	// 周报提交日期,周五
 	dutyInfo: {},
@@ -25,7 +26,8 @@ const state = {
 		'week.submit.date': '',
 		'week.submit.time': '',
 		'week.remind.time': '',
-	}
+	},
+	signInfo: null
 }
 
 const getters = {
@@ -83,8 +85,13 @@ const mutations = {
 	},
 	SET_TIMESTAMP(state: any, data: any) {
 		state.timestamp = new Date(data).getTime()
+		state.tempTimestamp = new Date(data).getTime()
 		setInterval(() => {
 			state.timestamp += 1000
+			if (new Date(state.tempTimestamp).getDay() !== new Date(state.timestamp).getDay()) {
+				state.tempTimestamp = new Date(state.timestamp).getTime()
+				state.signInfo = null
+			}
 		}, 1000)
 	},
 	SET_DUTY_INFO(state: any, data: any) {
@@ -93,6 +100,9 @@ const mutations = {
 	SET_PUBLIC_CONFIG(state: any, {data, key}) {
 		state.publicConfig[key] = data
 	},
+	SET_SIGN_INFO(state: any, data) {
+		state.signInfo = data
+	},
 }
 
 const actions = {
@@ -163,6 +173,18 @@ const actions = {
 			}
 		})
 	},
+	LOAD_SIGN_INFO({ commit }: any) {
+		return new Promise((resolve, reject) => {
+			getSignSearch().then((res) => {
+				if (res.code === 200) {
+					commit('SET_SIGN_INFO', res.data)
+					resolve(res.message)
+				} else {
+					ElMessage.error(res.message)
+				}
+			})
+		})
+	},
 }
 
 export default {

+ 71 - 4
src/views/staging/zby/center/index.vue

@@ -7,13 +7,20 @@
         </div>
         <div class="label">日志</div>
       </div>
-      <div class="operation-item">
+      <div class="operation-item __hover" @click="onSign">
         <div class="icon">
           <img src="@/assets/images/business/operation-sign.png"/>
         </div>
-        <div class="label">下班打卡</div>
+        <div class="label">
+          <template v-if="isSignCpt">
+            下班打卡
+          </template>
+          <template v-else>
+            上班打卡
+          </template>
+        </div>
       </div>
-      <div class="operation-item" :style="`opacity: ${$store.getters['app/isWeeklyDay'] ? 1 : 0.3};`">
+      <div class="operation-item" :class="{'__hover': $store.getters['app/isWeeklyDay']}" :style="`opacity: ${$store.getters['app/isWeeklyDay'] ? 1 : 0.3};`" @click="$store.getters['app/isWeeklyDay'] ? onWeekly() : undefined">
         <div class="icon">
           <img src="@/assets/images/business/operation-weekly.png"/>
         </div>
@@ -44,6 +51,7 @@
       </template>
     </div>
     <DailyDetailCom v-model:show="showDailyDetail" :transfer="transferDaily"/>
+    <WeeklyDetailCom v-model:show="showWeeklyDetail" :transfer="transferWeekly"/>
   </div>
 </template>
 
@@ -66,6 +74,9 @@ import ButtonSwitchCom from '../../common/button-switch.vue'
 import CalendarCom from './calendar.vue'
 import StatisticCom from './statistic.vue'
 import DailyDetailCom from '@/views/system/daily-manage/detail.vue'
+import WeeklyDetailCom from '@/views/system/weekly-manage/detail.vue'
+import {ElMessage, ElMessageBox} from "element-plus";
+
 
 export default defineComponent({
   name: '',
@@ -74,6 +85,7 @@ export default defineComponent({
     CalendarCom,
     StatisticCom,
     DailyDetailCom,
+    WeeklyDetailCom,
   },
   setup(props, {emit}) {
     const store = useStore();
@@ -84,6 +96,8 @@ export default defineComponent({
       sourceType: '1',
       showDailyDetail: false,
       transferDaily: {},
+      showWeeklyDetail: false,
+      transferWeekly: {},
     })
     const onDaily = () => {
       state.transferDaily = {
@@ -91,9 +105,62 @@ export default defineComponent({
       }
       state.showDailyDetail = true
     }
+    const onWeekly = () => {
+      state.transferWeekly = {
+        method: 'add',
+      }
+      state.showWeeklyDetail = true
+    }
+    const isSignCpt = computed(() => {
+      return store.state.app.signInfo?.id
+    })
+    const onSign = () => {
+      const sign = (msg) => {
+        that.$api.signIn().then(res => {
+          if (res.code === 200) {
+            ElMessage.success(msg)
+            store.dispatch('app/LOAD_SIGN_INFO')
+          } else {
+            ElMessage.error(res.message)
+          }
+        }).catch(() => {
+        })
+      }
+      const signStart = new Date(`${that.$util.YMD(store.state.app.timestamp)} ${store.state.app.publicConfig["sign.begin.time"]}`).getTime()
+      const signEnd = new Date(`${that.$util.YMD(store.state.app.timestamp)} ${store.state.app.publicConfig["sign.end.time"]}`).getTime()
+      const now = new Date(store.state.app.timestamp).getTime()
+      if (!isSignCpt.value) {
+        if (now > signStart) {
+          ElMessageBox.confirm(`当前已过签到时间,是否继续签到?`, "提示", {
+            confirmButtonText: "确定",
+            cancelButtonText: "取消",
+            type: "warning",
+          }).then(() => {
+            sign('签到成功!')
+          }).catch(() => {})
+        } else {
+          sign('签到成功!')
+        }
+      } else {
+        if (now < signEnd) {
+          ElMessageBox.confirm(`当前未到签退时间,是否继续签退?`, "提示", {
+            confirmButtonText: "确定",
+            cancelButtonText: "取消",
+            type: "warning",
+          }).then(() => {
+            sign('签退成功!')
+          }).catch(() => {})
+        } else {
+          sign('签退成功!')
+        }
+      }
+    }
     return {
       ...toRefs(state),
-      onDaily
+      onDaily,
+      onWeekly,
+      isSignCpt,
+      onSign
     }
   },
 })