From aa102c7ba6977ff40f3e02eba32a00a168fb3564 Mon Sep 17 00:00:00 2001
From: yaozc <unbelievers@yeah.net>
Date: Tue, 31 Jan 2023 00:52:00 +0000
Subject: [PATCH] Merge branch 'master' of http://192.168.1.110:5678/r/pms-upgrade into yaozc

---
 eladmin-web-master/src/views/home.vue |  172 ++++++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 144 insertions(+), 28 deletions(-)

diff --git a/eladmin-web-master/src/views/home.vue b/eladmin-web-master/src/views/home.vue
index cdd3790..1562763 100644
--- a/eladmin-web-master/src/views/home.vue
+++ b/eladmin-web-master/src/views/home.vue
@@ -1,37 +1,23 @@
 <template>
   <div class="dashboard-container">
     <div class="dashboard-editor-container">
-      <panel-group @handleSetLineChartData="handleSetLineChartData" />
+      <panel-group :user-info="userInfo" @handleSetLineChartData="handleSetLineChartData" />
       <el-row style="background:#fff;padding:16px 16px 0;margin-bottom:32px;">
-        <line-chart :chart-data="lineChartData" />
-      </el-row>
-      <el-row :gutter="32">
-        <el-col :xs="24" :sm="24" :lg="8">
-          <div class="chart-wrapper">
-            <radar-chart />
-          </div>
-        </el-col>
-        <el-col :xs="24" :sm="24" :lg="8">
-          <div class="chart-wrapper">
-            <pie-chart />
-          </div>
-        </el-col>
-        <el-col :xs="24" :sm="24" :lg="8">
-          <div class="chart-wrapper">
-            <bar-chart />
-          </div>
-        </el-col>
+        <FullCalendar ref="fullCalendar" :options="calendarOptions" class="eventDeal-wrap" />
       </el-row>
     </div>
   </div>
 </template>
 
 <script>
+import crudUser from '@/api/system/user'
 import PanelGroup from './dashboard/PanelGroup'
-import LineChart from './dashboard/LineChart'
-import RadarChart from '@/components/Echarts/RadarChart'
-import PieChart from '@/components/Echarts/PieChart'
-import BarChart from '@/components/Echarts/BarChart'
+import '@fullcalendar/core/vdom'
+import FullCalendar from '@fullcalendar/vue'
+import dayGridPlugin from '@fullcalendar/daygrid'
+import interactionPlugin from '@fullcalendar/interaction'
+import timeGridPlugin from '@fullcalendar/timegrid'
+import moment from 'moment'
 
 const lineChartData = {
   newVisitis: {
@@ -56,19 +42,149 @@
   name: 'Dashboard',
   components: {
     PanelGroup,
-    LineChart,
-    RadarChart,
-    PieChart,
-    BarChart
+    FullCalendar
   },
   data() {
     return {
-      lineChartData: lineChartData.newVisitis
+      lineChartData: lineChartData.newVisitis,
+      calendarOptions: {
+        // 引入的插件
+        plugins: [dayGridPlugin, timeGridPlugin, interactionPlugin],
+        // 日历头部按钮位置
+        headerToolbar: {
+          left: '',
+          center: 'title',
+          right: 'prev,today,next'
+        },
+        // 日历头部按钮中文转换
+        buttonText: {
+          today: '今天',
+          month: '月',
+          week: '周',
+          day: '天'
+        },
+        initialView: 'dayGridMonth',
+        locale: 'zh-ch',
+        firstDay: '1',
+        weekNumberCalculation: 'ISO',
+        eventCOlor: '#3d8eec',
+        timeGridEventMinHeight: '20',
+        aspectRatio: '1.5',
+        displayEventTime: false,
+        allDaySlot: false,
+        eventLimit: true,
+        fixedWeekCount: false,
+        eventTimeFormat: {
+          hour: 'numeric',
+          minute: '2-digit',
+          hour12: false
+        },
+        slotLabelFormat: {
+          hour: '2-digit',
+          minute: '2-digit',
+          meridiem: false,
+          hour12: false
+        },
+        businessHours: {
+          dow: [1, 2, 3, 4, 5],
+          start: '9:00',
+          end: '18:00'
+        },
+        events: [],
+        // 事件
+        editable: false,
+        eventStartEditable: false,
+        eventDurationEditable: false,
+        selectable: false,
+        selectMirror: true,
+        selectMinDistance: 0,
+        weekends: true,
+        navLinks: true,
+        selectHelper: false,
+        selectEventOverlap: false,
+        dayMaxEvents: true,
+        dateClick: this.handleDateClick, // 点击日期触发
+        eventsSet: this.handleEvents,
+        eventClick: this.handleEventClick, // 点击日程触发
+        eventDrop: this.handleEventDrop,
+        eventResize: this.eventResize,
+        height: 'auto',
+        customButtons: {
+          prev: {
+            click: () => {
+              this.monthClick('prev')
+            }
+          },
+          today: {
+            text: '今天',
+            click: () => {
+              this.monthClick('')
+            }
+          },
+          next: {
+            click: () => {
+              this.monthClick('next')
+            }
+          }
+        }
+      },
+      userInfo: {}
     }
+  },
+  mounted() {
+    this.monthClick('')
+    this.getUserBaseInfo()
   },
   methods: {
     handleSetLineChartData(type) {
       this.lineChartData = lineChartData[type]
+    },
+    // 箭头点击事件
+    monthClick(type) {
+      const calendarApi = this.$refs['fullCalendar'].getApi()
+      if (type === 'prev') {
+        calendarApi.prev()
+      } else if (type === 'next') {
+        calendarApi.next()
+      } else {
+        calendarApi.today()
+      }
+      // this.calendarOptions.events = [{title: '上班打卡时间', color: 'red',start: '2023-01-28',date: '2023-01-28'}]
+      this.getUserCalendarInfo(moment(calendarApi.view.currentStart).format('YYYY-MM-DD').toString())
+    },
+    // 获取打卡信息
+    getUserCalendarInfo(month) {
+      crudUser.getUserCalendarInfo(month).then(res => {
+        this.calendarOptions.events = res.map(function(obj) {
+          obj.start = obj.date
+          obj.color = obj.isOk ? 'green' : 'red'
+          obj.date1 = obj.date
+          return obj
+        })
+      }).catch(() => {
+        this.calendarOptions.events = []
+      })
+    },
+    // 日期点击
+    handleDateClick(selectInfo) {
+      console.log('handleDateClick.info:', selectInfo)
+    },
+    // 日程点击信息展示
+    handleEventClick(info) {
+      if (info.event._def.extendedProps.type === 1) {
+        this.$router.push({
+          path: '/attendance/attendance',
+          query: { date: info.event._def.extendedProps.date1 }
+        })
+      } else {
+        this.$router.push({ path: '/task/taskDaliy', query: { date: info.event._def.extendedProps.date1 }})
+      }
+    },
+    // 获取用户信息
+    getUserBaseInfo() {
+      crudUser.getUserBaseInfo().then(res => {
+        this.userInfo = res
+      })
     }
   }
 }

--
Gitblit v1.9.3