From 513d93bed0618f5fc0e6f147a9e23a545c9b6f65 Mon Sep 17 00:00:00 2001
From: YDKD <1606354057@qq.com>
Date: Fri, 8 Apr 2022 10:37:06 +0800
Subject: [PATCH] feat(person): complete person attendance functional
---
.eslintrc.js | 1 +
index.html | 2 +-
src/api/getApi.ts | 8 ++
src/api/type.ts | 1 +
src/components/Button/src/Button.vue | 13 +--
src/components/Icon/src/Icon.vue | 3 +-
src/components/Icon/types.ts | 8 --
src/utils/getKey.ts | 3 +
.../attendance/components/count-panel.vue | 81 ++++++++++++++++++-
src/views/attendance/hooks/index.ts | 26 ++++++
src/views/attendance/hooks/useTable.ts | 51 ++++++++++++
types/components.d.ts | 8 +-
types/system.d.ts | 3 +-
13 files changed, 187 insertions(+), 21 deletions(-)
delete mode 100644 src/components/Icon/types.ts
create mode 100644 src/utils/getKey.ts
create mode 100644 src/views/attendance/hooks/index.ts
create mode 100644 src/views/attendance/hooks/useTable.ts
diff --git a/.eslintrc.js b/.eslintrc.js
index 7ff6239..9985178 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -34,6 +34,7 @@ module.exports = {
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'vue/no-multiple-template-root': 'off',
+ 'vue/no-v-model-argument': 'off',
'no-useless-escape': 'off',
'vue/html-self-closing': [
'error',
diff --git a/index.html b/index.html
index e2a940b..9ba8b3b 100644
--- a/index.html
+++ b/index.html
@@ -4,7 +4,7 @@
-
+
diff --git a/src/api/getApi.ts b/src/api/getApi.ts
index 1e69fac..ffecda7 100644
--- a/src/api/getApi.ts
+++ b/src/api/getApi.ts
@@ -66,3 +66,11 @@ export function getSerialNum() {
method: 'GET'
})
}
+
+export function getWorkerAttendance(params: any) {
+ return defaultRequest.request({
+ url: '/sys/person/attendance',
+ method: 'GET',
+ params
+ })
+}
diff --git a/src/api/type.ts b/src/api/type.ts
index c30463d..8dfb05d 100644
--- a/src/api/type.ts
+++ b/src/api/type.ts
@@ -7,6 +7,7 @@ interface BaseReturnType {
interface dataStructure {
result?: any
code: number
+ total: number
}
export interface ReutrnDataType extends BaseReturnType {
diff --git a/src/components/Button/src/Button.vue b/src/components/Button/src/Button.vue
index 59c3d4a..a576302 100644
--- a/src/components/Button/src/Button.vue
+++ b/src/components/Button/src/Button.vue
@@ -3,14 +3,14 @@
* @Autor: YDKD
* @Date: 2022-04-01 10:57:59
* @LastEditors: YDKD
- * @LastEditTime: 2022-04-07 14:58:26
+ * @LastEditTime: 2022-04-07 17:52:39
-->
{{ text }}
@@ -29,9 +29,12 @@ const prefixCls = useDesign('prefix', 'button')
const props = defineProps({
text: propTypes.string.def(''),
- type: propTypes.oneOf([]).def('primary'),
- size: propTypes.oneOf([]).def(),
- icon: propTypes.string.def('')
+ type: propTypes.oneOf(['primary']).def('primary'),
+ size: propTypes
+ .oneOf(['default', 'large', 'small'])
+ .def('small'),
+ icon: propTypes.string.def(''),
+ iconType: propTypes.oneOf(['iconify', 'iconfont']).def('iconify')
})
diff --git a/src/components/Icon/src/Icon.vue b/src/components/Icon/src/Icon.vue
index 8194159..75b8694 100644
--- a/src/components/Icon/src/Icon.vue
+++ b/src/components/Icon/src/Icon.vue
@@ -3,7 +3,7 @@
* @Autor: YDKD
* @Date: 2022-03-28 15:08:36
* @LastEditors: YDKD
- * @LastEditTime: 2022-04-07 14:51:07
+ * @LastEditTime: 2022-04-08 09:06:21
-->
@@ -20,7 +20,6 @@
import { defineProps, computed, PropType } from 'vue'
import { useDesign } from '@/hooks'
-import type { IconType } from '../types'
import { propTypes } from '@/utils/propTypes'
const prefixCls = useDesign('prefix', 'icon')
diff --git a/src/components/Icon/types.ts b/src/components/Icon/types.ts
deleted file mode 100644
index d1a83dd..0000000
--- a/src/components/Icon/types.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-/*
- * @Version: 1.0
- * @Autor: YDKD
- * @Date: 2022-04-01 11:25:17
- * @LastEditors: YDKD
- * @LastEditTime: 2022-04-01 11:25:17
- */
-export type IconType = 'iconify' | 'iconfont'
diff --git a/src/utils/getKey.ts b/src/utils/getKey.ts
new file mode 100644
index 0000000..00b8e0c
--- /dev/null
+++ b/src/utils/getKey.ts
@@ -0,0 +1,3 @@
+export const getKey = (record: T, key: K): T[K] => {
+ return record[key]
+}
diff --git a/src/views/attendance/components/count-panel.vue b/src/views/attendance/components/count-panel.vue
index 00d4a74..8a670fa 100644
--- a/src/views/attendance/components/count-panel.vue
+++ b/src/views/attendance/components/count-panel.vue
@@ -3,20 +3,97 @@
* @Autor: YDKD
* @Date: 2022-04-06 10:11:27
* @LastEditors: YDKD
- * @LastEditTime: 2022-04-07 16:30:18
+ * @LastEditTime: 2022-04-08 10:34:15
-->
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ getKey(vacationType, row.status) }}
+
+
+
+
+
+
+
+
+
+ {{
+ moment(row.createTime).utcOffset(8).format('YYYY/MM/DD HH:mm:ss')
+ }}
+
+
+
+
+ {{ moment(row.endTime).utcOffset(8).format('YYYY/MM/DD HH:mm:ss') }}
+
+
+
+
+
+
diff --git a/src/views/attendance/hooks/index.ts b/src/views/attendance/hooks/index.ts
new file mode 100644
index 0000000..5a92d11
--- /dev/null
+++ b/src/views/attendance/hooks/index.ts
@@ -0,0 +1,26 @@
+/*
+ * @Version: 1.0
+ * @Autor: YDKD
+ * @Date: 2022-04-07 17:14:27
+ * @LastEditors: YDKD
+ * @LastEditTime: 2022-04-08 10:31:04
+ */
+import {
+ getInitData,
+ tableData,
+ total,
+ queryData,
+ hideSinglePage,
+ record,
+ vacationType
+} from './useTable'
+
+export {
+ getInitData,
+ tableData,
+ total,
+ queryData,
+ hideSinglePage,
+ record,
+ vacationType
+}
diff --git a/src/views/attendance/hooks/useTable.ts b/src/views/attendance/hooks/useTable.ts
new file mode 100644
index 0000000..84f000f
--- /dev/null
+++ b/src/views/attendance/hooks/useTable.ts
@@ -0,0 +1,51 @@
+/*
+ * @Version: 1.0
+ * @Autor: YDKD
+ * @Date: 2022-04-07 17:14:45
+ * @LastEditors: YDKD
+ * @LastEditTime: 2022-04-08 10:30:41
+ */
+
+import { getWorkerAttendance } from '@/api/getApi'
+import { ref, unref, computed } from 'vue'
+
+const queryData = ref({
+ search: '',
+ page: 1,
+ pageSize: 10
+})
+
+const tableData = ref([])
+const total = ref(0)
+
+const getInitData = async () => {
+ const params = unref(queryData)
+ const { data } = await getWorkerAttendance(params)
+ tableData.value = data.result
+ total.value = data.total
+}
+
+const record = {
+ 0: 'icon-icon-test',
+ 1: 'icon-zhengque'
+}
+
+const vacationType = {
+ 0: '出勤',
+ 1: '矿工',
+ 2: '病假',
+ 3: '休假',
+ 4: '事假',
+ 5: '其他'
+}
+
+const hideSinglePage = computed(() => total.value < queryData.value.pageSize)
+export {
+ getInitData,
+ tableData,
+ total,
+ queryData,
+ hideSinglePage,
+ record,
+ vacationType
+}
diff --git a/types/components.d.ts b/types/components.d.ts
index 0248863..5a0dfe9 100644
--- a/types/components.d.ts
+++ b/types/components.d.ts
@@ -8,17 +8,21 @@ declare module 'vue' {
EchartsSrcEcharts: typeof import('./../src/components/Echarts/src/Echarts.vue')['default']
ElAside: typeof import('element-plus/es')['ElAside']
ElAvatar: typeof import('element-plus/es')['ElAvatar']
- ElCard: typeof import('element-plus/es')['ElCard']
+ ElButton: typeof import('element-plus/es')['ElButton']
+ ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
ElContainer: typeof import('element-plus/es')['ElContainer']
ElDropdown: typeof import('element-plus/es')['ElDropdown']
ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem']
ElDropdownMenu: typeof import('element-plus/es')['ElDropdownMenu']
+ ElForm: typeof import('element-plus/es')['ElForm']
+ ElFormItem: typeof import('element-plus/es')['ElFormItem']
ElHeader: typeof import('element-plus/es')['ElHeader']
ElIcon: typeof import('element-plus/es')['ElIcon']
+ ElInput: typeof import('element-plus/es')['ElInput']
ElMain: typeof import('element-plus/es')['ElMain']
+ ElPagination: typeof import('element-plus/es')['ElPagination']
ElTable: typeof import('element-plus/es')['ElTable']
ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
- ElTooltip: typeof import('element-plus/es')['ElTooltip']
FossBg: typeof import('./../src/components/foss-bg/index.vue')['default']
HeaderSrcHeader: typeof import('./../src/components/Header/src/Header.vue')['default']
IconSrcIcon: typeof import('./../src/components/Icon/src/Icon.vue')['default']
diff --git a/types/system.d.ts b/types/system.d.ts
index 0263a9f..fd40dc4 100644
--- a/types/system.d.ts
+++ b/types/system.d.ts
@@ -3,7 +3,7 @@
* @Autor: YDKD
* @Date: 2022-04-01 16:19:48
* @LastEditors: YDKD
- * @LastEditTime: 2022-04-04 19:35:02
+ * @LastEditTime: 2022-04-07 17:46:05
*/
import vue from 'vue'
@@ -43,4 +43,5 @@ declare global {
// 入职时间
workTime: Date | string
}
+ type IconType = 'iconify' | 'iconfont'
}