Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion 123.sql
Original file line number Diff line number Diff line change
Expand Up @@ -695,5 +695,4 @@ INSERT INTO `zhenduanbingli` VALUES (11, '2025-03-27 16:20:25', '1743063617739',
INSERT INTO `zhenduanbingli` VALUES (12, '2025-04-24 15:46:06', '1745480759774', '123', '13646446880', '', '2025-04-24 15:45:59', '123456', '19558692219', '<p>11</p>');
INSERT INTO `zhenduanbingli` VALUES (13, '2025-05-08 10:16:51', '1746670607518', '123', '13646446880', '', '2025-05-08 10:16:47', '123456', '19558692219', '<p>1</p>');


SET FOREIGN_KEY_CHECKS = 1;
13 changes: 13 additions & 0 deletions client_code/src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ import chatMessageAdd from '@/views/pages/chatMessage/formAdd'
import chatFriendList from '@/views/pages/chatFriend/list'
import chatFriendDetail from '@/views/pages/chatFriend/formModel'
import chatFriendAdd from '@/views/pages/chatFriend/formAdd'
<<<<<<< HEAD
import dakaList from '@/views/pages/daka/list'
=======
>>>>>>> main

const routes = [{
path: '/',
Expand Down Expand Up @@ -222,9 +226,18 @@ const routes = [{
path: 'chatFriendDetail',
component: chatFriendDetail
}, {
<<<<<<< HEAD
path: 'chatFriendAdd',
component: chatFriendAdd
}, {
path: 'dakaList',
component: dakaList
}]}
=======
path: 'chatFriendAdd',
component: chatFriendAdd
}
>>>>>>> main
]
},
{
Expand Down
237 changes: 237 additions & 0 deletions client_code/src/views/pages/daka/list.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,237 @@
<template>
<div class="list-page" :style='{}'>
<div class="breadcrumb-wrapper" style="width: 100%;">
<div class="bread_view">
<el-breadcrumb separator="Ξ" class="breadcrumb">
<el-breadcrumb-item class="first_breadcrumb" :to="{ path: '/' }">首页</el-breadcrumb-item>
<el-breadcrumb-item class="second_breadcrumb" v-for="(item,index) in breadList" :key="index">{{item.name}}</el-breadcrumb-item>
</el-breadcrumb>
</div>
</div>
<div class="daka-container">
<div class="daka-status">
<h2>当前状态:{{ currentStatus }}</h2>
<div class="status-time">
<span v-if="currentStatus === '已打卡上班'">上班时间:{{ workStartTime }}</span>
<span v-if="currentStatus === '暂停工作'">暂停时间:{{ pauseStartTime }}</span>
</div>
</div>
<div class="daka-buttons">
<el-button v-if="currentStatus === '未打卡'" type="primary" size="large" @click="dakaStart">
打卡上班
</el-button>
<el-button v-if="currentStatus === '已打卡上班'" type="warning" size="large" @click="dakaPause">
暂停工作
</el-button>
<el-button v-if="currentStatus === '暂停工作'" type="success" size="large" @click="dakaResume">
恢复工作
</el-button>
<el-button v-if="currentStatus !== '未打卡'" type="danger" size="large" @click="dakaEnd">
打卡下班
</el-button>
</div>
<div class="daka-record">
<h3>今日打卡记录</h3>
<el-table :data="recordList" border>
<el-table-column label="打卡类型" prop="type" />
<el-table-column label="打卡时间" prop="time" />
<el-table-column label="时长" prop="duration" />
</el-table>
</div>
</div>
</div>
</template>

<script setup>
import {
ref,
getCurrentInstance,
computed
} from 'vue';
import {
useStore
} from 'vuex';
import moment from 'moment'
const store = useStore()
const user = computed(()=>store.getters['user/session'])
const context = getCurrentInstance()?.appContext.config.globalProperties;

//基础信息
const tableName = 'daka'
const formName = '打卡管理'
const breadList = ref([{
name: formName
}])

//打卡状态
const currentStatus = ref('未打卡')
const workStartTime = ref('')
const pauseStartTime = ref('')
const recordList = ref([])

//打卡上班
const dakaStart = () => {
context?.$http({
url: 'daka/start',
method: 'post',
data: {
userId: user.value.id,
userType: user.value.role
}
}).then(res => {
if (res.data.code === 200) {
context?.$toolUtil.message('打卡上班成功', 'success')
currentStatus.value = '已打卡上班'
workStartTime.value = moment().format('YYYY-MM-DD HH:mm:ss')
recordList.value.push({
type: '打卡上班',
time: workStartTime.value,
duration: ''
})
} else {
context?.$toolUtil.message(res.data.msg, 'error')
}
})
}

//暂停工作
const dakaPause = () => {
context?.$http({
url: 'daka/pause',
method: 'post',
data: {
userId: user.value.id
}
}).then(res => {
if (res.data.code === 200) {
context?.$toolUtil.message('暂停工作成功', 'warning')
currentStatus.value = '暂停工作'
pauseStartTime.value = moment().format('YYYY-MM-DD HH:mm:ss')
recordList.value.push({
type: '暂停工作',
time: pauseStartTime.value,
duration: ''
})
} else {
context?.$toolUtil.message(res.data.msg, 'error')
}
})
}

//恢复工作
const dakaResume = () => {
context?.$http({
url: 'daka/resume',
method: 'post',
data: {
userId: user.value.id
}
}).then(res => {
if (res.data.code === 200) {
context?.$toolUtil.message('恢复工作成功', 'success')
currentStatus.value = '已打卡上班'
recordList.value.push({
type: '恢复工作',
time: moment().format('YYYY-MM-DD HH:mm:ss'),
duration: moment().diff(moment(pauseStartTime.value), 'minutes') + '分钟'
})
} else {
context?.$toolUtil.message(res.data.msg, 'error')
}
})
}

//打卡下班
const dakaEnd = () => {
context?.$http({
url: 'daka/end',
method: 'post',
data: {
userId: user.value.id
}
}).then(res => {
if (res.data.code === 200) {
context?.$toolUtil.message('打卡下班成功', 'success')
currentStatus.value = '未打卡'
recordList.value.push({
type: '打卡下班',
time: moment().format('YYYY-MM-DD HH:mm:ss'),
duration: moment().diff(moment(workStartTime.value), 'hours', true).toFixed(2) + '小时'
})
} else {
context?.$toolUtil.message(res.data.msg, 'error')
}
})
}

//初始化打卡状态
const initDakaStatus = () => {
context?.$http({
url: 'daka/status',
method: 'get',
params: {
userId: user.value.id
}
}).then(res => {
if (res.data.code === 200) {
const data = res.data.data
currentStatus.value = data.status
if (data.startTime) {
workStartTime.value = moment(data.startTime).format('YYYY-MM-DD HH:mm:ss')
}
if (data.pauseTime) {
pauseStartTime.value = moment(data.pauseTime).format('YYYY-MM-DD HH:mm:ss')
}
recordList.value = data.records || []
}
})
}

const init = async() => {
if(context.$toolUtil.storageGet('frontToken') && !user.value.id){
await store.dispatch("user/getSession")
}
initDakaStatus()
}
init()
</script>

<style lang="scss" scoped>
.daka-container {
padding: 20px;
max-width: 800px;
margin: 0 auto;
}

.daka-status {
background: #f5f7fa;
padding: 20px;
border-radius: 8px;
margin-bottom: 20px;

h2 {
margin: 0 0 10px 0;
color: #333;
}

.status-time {
color: #666;
font-size: 14px;
}
}

.daka-buttons {
display: flex;
gap: 15px;
margin-bottom: 30px;
flex-wrap: wrap;
}

.daka-record {

h3 {
margin: 0 0 15px 0;
color: #333;
}
}
</style>
14 changes: 14 additions & 0 deletions server_code/sql/daka.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
CREATE TABLE `daka` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键id',
`user_id` bigint(20) DEFAULT NULL COMMENT '用户ID',
`user_type` varchar(255) DEFAULT NULL COMMENT '用户类型',
`status` varchar(255) DEFAULT NULL COMMENT '打卡状态',
`start_time` datetime DEFAULT NULL COMMENT '上班时间',
`end_time` datetime DEFAULT NULL COMMENT '下班时间',
`pause_time` datetime DEFAULT NULL COMMENT '暂停时间',
`resume_time` datetime DEFAULT NULL COMMENT '恢复时间',
`total_duration` double DEFAULT NULL COMMENT '总工作时长',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='打卡记录';
Loading