gaoluyang
2025-11-26 37612543bb0afcc0769fd7148940d39144580fea
src/views/index.vue
@@ -13,9 +13,13 @@
                     <div class="company-meta">{{userStore.roleName}}</div>
                  </div>
                  <div style="display: flex;align-items: center;gap: 8px">
                     <el-icon color="#5053B5" size="22"><Clock /></el-icon>
                     <span>登陆日期:{{userStore.currentLoginTime}}</span>
                  </div>
                  <el-icon color="#5053B5" size="22"><Clock /></el-icon>
                  <span>登陆日期:{{userStore.currentLoginTime}}</span>
               </div>
               <div style="display: flex;align-items: center;gap: 8px">
                  <el-icon color="#5053B5" size="22"><Calendar /></el-icon>
                  <span>排班时间:{{scheduleTime}}</span>
               </div>
               </div>
            </div>
            <div class="data-cards">
@@ -165,10 +169,11 @@
</template>
<script setup>
import { ref, onMounted } from 'vue'
import { ref, reactive, onMounted } from 'vue'
import Echarts from "@/components/Echarts/echarts.vue";
import * as echarts from 'echarts';
import useUserStore from "@/store/modules/user.js";
import { Clock, Calendar } from '@element-plus/icons-vue'
import {
   analysisCustomerContractAmounts, getAmountHalfYear,
   getBusiness,
@@ -176,6 +181,8 @@
   qualityStatistics,
   statisticsReceivablePayable
} from "@/api/viewIndex.js";
import { getCurrentUserLatestScheduling } from "@/api/personnelManagement/scheduling.js";
import dayjs from "dayjs";
const userStore = useUserStore()
@@ -341,6 +348,10 @@
const todoList = ref([])
const radio1 = ref(1)
// 排班时间
const scheduleTime = ref('')
const scheduleInfo = ref({})
// 图表引用
const barChart = ref(null)
const lineChart = ref(null)
@@ -358,6 +369,7 @@
   statisticsReceivable()
   qualityStatisticsInfo()
   getAmountHalfYearNum()
   getCurrentUserSchedule()
})
// 数据统计
const getBusinessData = () => {
@@ -386,7 +398,6 @@
}
// 应付应收统计
const statisticsReceivable = (type) => {
   console.log(type)
   statisticsReceivablePayable({type: radio1.value}).then((res) => {
      barSeries.value[0].data = [
         // { value: res.data.prepayMoney, itemStyle: { color: barColors2[0] } },
@@ -410,6 +421,35 @@
      qualityStatisticsObject.value.factoryNum = res.data.factoryNum
   })
}
// 获取当前用户排班信息
const getCurrentUserSchedule = async () => {
  try {
    const res = await getCurrentUserLatestScheduling()
    if (res.data) {
      const currentSchedule = res.data
      scheduleInfo.value = currentSchedule
      // 格式化排班时间显示
      if (currentSchedule.startTime && currentSchedule.endTime) {
        scheduleTime.value = `${currentSchedule.startTime} - ${currentSchedule.endTime}`
      } else if (currentSchedule.workStartTime && currentSchedule.workEndTime) {
        const startTime = dayjs(currentSchedule.workStartTime).format('HH:mm')
        const endTime = dayjs(currentSchedule.workEndTime).format('HH:mm')
        scheduleTime.value = `${startTime} - ${endTime}`
      } else {
        scheduleTime.value = '今日无排班'
      }
    } else {
      scheduleTime.value = '今日无排班'
      scheduleInfo.value = {}
    }
  } catch (error) {
    console.error('获取排班信息失败:', error)
    scheduleTime.value = '获取排班信息失败'
  }
}
const getAmountHalfYearNum = async () => {
   const res = await getAmountHalfYear()
   console.log(res)