Bläddra i källkod

feat: 日报周报统计

qiny 1 år sedan
förälder
incheckning
811bf11dc4

+ 1 - 1
client/src/router/modules/remaining.ts

@@ -270,7 +270,7 @@ const remainingRouter: AppRouteRecordRaw[] = [
         component: () => import('@/views/OaSystem/personnelManagement/mySendLog/index.vue'),
         name: 'mySendLog',
         meta: {
-          title: '发出的日志'
+          title: '发出的日志'
         }
       }
     ]

+ 14 - 3
client/src/views/OaSystem/personnelManagement/dailyStatistic/index.vue

@@ -41,9 +41,11 @@
             <div>{{ getPercent(scope.row.fillRate) }}%</div>
           </template>
         </el-table-column>
-        <el-table-column prop="address" label="操作">
-          <template #default>
-            <el-button link type="primary" size="small">查看</el-button>
+        <el-table-column label="操作">
+          <template #default="scope">
+            <el-button link type="primary" size="small" @click="jumpToMyLog(scope.row)"
+              >查看</el-button
+            >
           </template>
         </el-table-column>
       </el-table>
@@ -82,6 +84,15 @@ const handleSizeChange = (size): void => {
   getDailyStatisticData()
 }
 
+// 点击查看
+const { push } = useRouter()
+const jumpToMyLog = (row: any): void => {
+  const { userId, nickName, reportYear, reportMonth } = row
+  push(
+    `/mySendLog?type=daily&userId=${userId}&userName=${nickName}&date=${reportYear}-${reportMonth}`
+  )
+}
+
 onMounted(() => {
   // 获取日报数据
   getDailyStatisticData()

+ 25 - 10
client/src/views/OaSystem/personnelManagement/mySendLog/index.vue

@@ -1,6 +1,6 @@
 <template>
   <div class="dailyStatisticBox">
-    <h4 class="title">我发出的日志</h4>
+    <h4 class="title">{{ currentRoute.query.userName ?? '' }}发出的日志</h4>
     <div class="searchBox">
       <el-form :inline="true" class="demo-form-inline">
         <el-form-item label="日志类型:">
@@ -28,7 +28,7 @@
         <div class="box-title">
           <div class="user-name">
             <el-avatar :size="40" :src="userInfo.avatar" />
-            <span class="name">{{ userInfo.nickname }}</span>
+            <span class="name">{{ currentRoute.query.userName ?? userInfo.nickname }}</span>
           </div>
           <div v-if="isDaily" class="log-time">{{
             moment(item.reportStartDate).format('YYYY-MM-DD')
@@ -73,14 +73,15 @@ import { Search } from '@element-plus/icons-vue'
 import moment from 'moment'
 import { getUserInfo } from '@/utils/tool'
 
-const { push } = useRouter()
+const { push, currentRoute } = useRouter()
 
 // 查看详情
 const jumpLogDetail = (id: number): void => {
+  const userId = currentRoute.value.query.userId ?? userInfo.id ?? ''
   if (isDaily.value) {
-    push('/dailyLogDetail?id=' + id)
+    push(`/dailyLogDetail?id=${id}&userId=${userId}`)
   } else {
-    push('/weeklyLogDetail?id=' + id)
+    push(`/weeklyLogDetail?id=${id}&userId=${userId}`)
   }
 }
 
@@ -99,23 +100,31 @@ const handleSizeChange = (size): void => {
 }
 
 onMounted(() => {
+  // 获取当前路由id及日报详情
+  const query: any = currentRoute.value.query ?? null
+  if (query.date) {
+    dateRange.value = [
+      moment(query.date).startOf('month').format('YYYY-MM-DD'),
+      moment(query.date).endOf('month').format('YYYY-MM-DD')
+    ]
+  }
   // 获取日报数据
-  getDailyStatisticData()
+  getDailyStatisticData(query)
 })
 
 const userInfo = getUserInfo()
 const tableData = ref<any[]>([])
 const reportType = ref<'daily' | 'weekly'>('daily')
-const dateRange = ref([])
+const dateRange = ref<string[]>([])
 const userId = ref<string>(userInfo.id ?? '')
 const pageSize = ref<number>(20)
 const pageNo = ref<number>(1)
 const total = ref<number>(0)
 // 获取日报统计数据
-const getDailyStatisticData = async (): Promise<void> => {
+const getDailyStatisticData = async (data?): Promise<void> => {
   const params: any = {
-    reportType: reportType.value,
-    userId: userId.value,
+    reportType: data.type ?? reportType.value,
+    userId: data.userId ?? userId.value,
     pageSize: pageSize.value,
     pageNo: pageNo.value
   }
@@ -125,6 +134,12 @@ const getDailyStatisticData = async (): Promise<void> => {
       moment(dateRange.value[1]).format('YYYY-MM-DD HH:mm:ss')
     ]
   }
+  if (data.date) {
+    params.reportDate = [
+      moment(data.date).startOf('month').format('YYYY-MM-DD HH:mm:ss'),
+      moment(data.date).endOf('month').format('YYYY-MM-DD HH:mm:ss')
+    ]
+  }
   const { list = [], total: resTotal = 0 } = await request.get({ url: '/adm/report/page', params })
   tableData.value = list
   total.value = resTotal

+ 14 - 3
client/src/views/OaSystem/personnelManagement/weeklyStatistic/index.vue

@@ -41,9 +41,11 @@
             <div>{{ getPercent(scope.row.fillRate) }}%</div>
           </template>
         </el-table-column>
-        <el-table-column prop="address" label="操作">
-          <template #default>
-            <el-button link type="primary" size="small">查看</el-button>
+        <el-table-column label="操作">
+          <template #default="scope">
+            <el-button link type="primary" size="small" @click="jumpToMyLog(scope.row)"
+              >查看</el-button
+            >
           </template>
         </el-table-column>
       </el-table>
@@ -82,6 +84,15 @@ const handleSizeChange = (size): void => {
   getWeeklyStatisticData()
 }
 
+// 点击查看
+const { push } = useRouter()
+const jumpToMyLog = (row: any): void => {
+  const { userId, nickName, reportYear, reportMonth } = row
+  push(
+    `/mySendLog?type=weekly&userId=${userId}&userName=${nickName}&date=${reportYear}-${reportMonth}`
+  )
+}
+
 onMounted(() => {
   // 获取周报数据
   getWeeklyStatisticData()