gaoluyang
14 小时以前 076bb96b437258f0e8cdbe184040e1e302b60d4b
src/views/index.vue
@@ -16,6 +16,10 @@
                     <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">
@@ -118,11 +122,11 @@
         <div class="main-panel">
            <div style="display: flex;justify-content: space-between;">
               <div class="section-title">应收应付统计</div>
               <el-radio-group v-model="radio1" size="large" @change="statisticsReceivable">
                  <el-radio-button label="按周" :value="1" />
                  <el-radio-button label="按月" :value="2" />
                  <el-radio-button label="按季度" :value="3" />
               </el-radio-group>
<!--               <el-radio-group v-model="radio1" size="large" @change="statisticsReceivable">-->
<!--                  <el-radio-button label="按周" :value="1" />-->
<!--                  <el-radio-button label="按月" :value="2" />-->
<!--                  <el-radio-button label="按季度" :value="3" />-->
<!--               </el-radio-group>-->
            </div>
            <Echarts ref="chart"
                         :color="barColors2"
@@ -165,17 +169,23 @@
</template>
<script setup>
import { ref, onMounted } from 'vue'
import { ref, reactive, onMounted } from 'vue'
import { ElNotification } from 'element-plus'
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,
   homeTodos,
   qualityStatistics,
   statisticsReceivablePayable
   statisticsReceivablePayable,
   approveAndDeviceTodos,
   noticesCount
} from "@/api/viewIndex.js";
import { getCurrentUserLatestScheduling } from "@/api/personnelManagement/scheduling.js";
import dayjs from "dayjs";
const userStore = useUserStore()
@@ -341,6 +351,10 @@
const todoList = ref([])
const radio1 = ref(1)
// 排班时间
const scheduleTime = ref('')
const scheduleInfo = ref({})
// 图表引用
const barChart = ref(null)
const lineChart = ref(null)
@@ -358,6 +372,9 @@
   statisticsReceivable()
   qualityStatisticsInfo()
   getAmountHalfYearNum()
   getCurrentUserSchedule()
   getApproveAndDeviceTodos()
   getOngoingAnnouncementNoticeNumber()
})
// 数据统计
const getBusinessData = () => {
@@ -409,6 +426,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)
@@ -484,6 +530,44 @@
      }
   ]
}
// 协同待审批和报修待办事项
const getApproveAndDeviceTodos = async () => {
   try {
      const res = await approveAndDeviceTodos()
      const { approveTodo, deviceRepairTodo } = res.data
      // 显示通知
      ElNotification({
            title: '待办事项提醒',
            message: `当前有${approveTodo}条待审批事项,${deviceRepairTodo}条待维修事项`,
            type: 'warning',
            duration: 5000
         })
   } catch (error) {
      console.error('获取协同待办事项失败:', error)
   }
}
// 进行中公告通知
const getOngoingAnnouncementNoticeNumber = async () => {
   try {
      const res = await noticesCount()
      // const { approveTodo, deviceRepairTodo } = res.data
      const _noticesCount = res.data
      if(!_noticesCount){
         return
      }
      // 显示通知
      ElNotification({
            title: '通知公告通知',
            message: `当前有${_noticesCount}条公告通知,注意查看`,
            type: 'warning',
            duration: 5000
         })
   } catch (error) {
      console.error('获取协同待办事项失败:', error)
   }
}
</script>
<style scoped>