调整机构查询
This commit is contained in:
parent
81f5da6acc
commit
b421a65858
@ -88,8 +88,8 @@ export const PersonApi = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// 查询会员开通数量
|
// 查询会员开通数量
|
||||||
getMemberRegisterCount: async (startDate: string, endDate: string) => {
|
getMemberRegisterCount: async (startDate: string, endDate: string,orgid:number) => {
|
||||||
return await request.get({ url: `/system/person/get-member-register-count?startDate=` + startDate + `&endDate=` + endDate })
|
return await request.get({ url: `/system/person/get-member-register-count?startDate=` + startDate + `&endDate=` + endDate + `&orgid=` + orgid })
|
||||||
},
|
},
|
||||||
|
|
||||||
// 获取会员增长数据
|
// 获取会员增长数据
|
||||||
|
|||||||
@ -145,7 +145,11 @@ const memberLineOptions = ref<any>({
|
|||||||
const getAlertData = async (orgid: number) => {
|
const getAlertData = async (orgid: number) => {
|
||||||
try {
|
try {
|
||||||
const data = await AlertMessageApi.getAlertStatistics(orgid)
|
const data = await AlertMessageApi.getAlertStatistics(orgid)
|
||||||
Object.assign(alertData, data)
|
// 使用安全的数据合并,保留默认值
|
||||||
|
if (data) {
|
||||||
|
alertData.alertTotal = data.alertTotal ?? alertData.alertTotal
|
||||||
|
alertData.alertUnhandled = data.alertUnhandled ?? alertData.alertUnhandled
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取预警数据失败:', error)
|
console.error('获取预警数据失败:', error)
|
||||||
ElMessage.error('获取预警数据失败')
|
ElMessage.error('获取预警数据失败')
|
||||||
@ -156,7 +160,12 @@ const getAlertData = async (orgid: number) => {
|
|||||||
const getDeviceStats = async (orgid: number) => {
|
const getDeviceStats = async (orgid: number) => {
|
||||||
try {
|
try {
|
||||||
const data = await DeviceApi.getDeviceStatistics(orgid)
|
const data = await DeviceApi.getDeviceStatistics(orgid)
|
||||||
Object.assign(deviceStats, data)
|
// 使用安全的数据合并,保留默认值
|
||||||
|
if (data) {
|
||||||
|
deviceStats.totalCount = data.totalCount ?? deviceStats.totalCount
|
||||||
|
deviceStats.onlineCount = data.onlineCount ?? deviceStats.onlineCount
|
||||||
|
deviceStats.offlineCount = data.offlineCount ?? deviceStats.offlineCount
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取设备统计数据失败:', error)
|
console.error('获取设备统计数据失败:', error)
|
||||||
ElMessage.error('获取设备统计数据失败')
|
ElMessage.error('获取设备统计数据失败')
|
||||||
@ -168,14 +177,20 @@ const getDeviceMapData = async (orgid: number) => {
|
|||||||
try {
|
try {
|
||||||
const data = await DeviceApi.getDeviceMapData(orgid)
|
const data = await DeviceApi.getDeviceMapData(orgid)
|
||||||
|
|
||||||
|
// 使用安全的数据合并,保留默认值
|
||||||
// 更新地图数据
|
if (data) {
|
||||||
Object.assign(mapData, data)
|
mapData.totalCount = data.totalCount ?? mapData.totalCount
|
||||||
|
mapData.onlineCount = data.onlineCount ?? mapData.onlineCount
|
||||||
|
mapData.offlineCount = data.offlineCount ?? mapData.offlineCount
|
||||||
|
mapData.alertTotal = data.alertTotal ?? mapData.alertTotal
|
||||||
|
mapData.alertUnhandled = data.alertUnhandled ?? mapData.alertUnhandled
|
||||||
|
mapData.mapData = Array.isArray(data.mapData) ? data.mapData : mapData.mapData
|
||||||
|
mapData.scatterData = Array.isArray(data.scatterData) ? data.scatterData : mapData.scatterData
|
||||||
|
}
|
||||||
|
|
||||||
// 更新地图配置 - 组件会自动监听options变化
|
// 更新地图配置 - 组件会自动监听options变化
|
||||||
updateMapOptions()
|
updateMapOptions()
|
||||||
|
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取设备分布数据失败:', error)
|
console.error('获取设备分布数据失败:', error)
|
||||||
ElMessage.error('获取设备分布数据失败')
|
ElMessage.error('获取设备分布数据失败')
|
||||||
|
|||||||
@ -44,10 +44,11 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted, watch, nextTick } from 'vue'
|
import { ref, onMounted, watch, nextTick } from 'vue'
|
||||||
import * as echarts from 'echarts'
|
import * as echarts from 'echarts'
|
||||||
import ShortcutDateRangePicker from '@/components/ShortcutDateRangePicker/index.vue'
|
|
||||||
import ContentWrap from '@/components/ContentWrap/src/ContentWrap.vue'
|
import ContentWrap from '@/components/ContentWrap/src/ContentWrap.vue'
|
||||||
import { PersonApi } from '@/api/person'
|
import { PersonApi } from '@/api/person'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
|
import { getUserProfile } from '@/api/system/user/profile'
|
||||||
|
const userinfo = ref()
|
||||||
// 图表类型:'line' 折线图,'bar' 柱状图
|
// 图表类型:'line' 折线图,'bar' 柱状图
|
||||||
const chartType = ref<'line' | 'bar'>('line')
|
const chartType = ref<'line' | 'bar'>('line')
|
||||||
// 会员注册数据
|
// 会员注册数据
|
||||||
@ -120,7 +121,8 @@ const renderChart = () => {
|
|||||||
// 获取会员注册数量数据(调用PersonApi)
|
// 获取会员注册数量数据(调用PersonApi)
|
||||||
const fetchData = async () => {
|
const fetchData = async () => {
|
||||||
if (!dateRange.value || !dateRange.value[0] || !dateRange.value[1]) return
|
if (!dateRange.value || !dateRange.value[0] || !dateRange.value[1]) return
|
||||||
const res = await PersonApi.getMemberRegisterCount(dateRange.value[0], dateRange.value[1])
|
|
||||||
|
const res = await PersonApi.getMemberRegisterCount(dateRange.value[0], dateRange.value[1],userinfo.value.dept.orgid)
|
||||||
chartData.value = Array.isArray(res) ? res : []
|
chartData.value = Array.isArray(res) ? res : []
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,6 +141,9 @@ watch([chartData, chartType], () => {
|
|||||||
|
|
||||||
// 默认一周,首次渲染
|
// 默认一周,首次渲染
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
getUserProfile().then(res => {
|
||||||
|
userinfo.value = res
|
||||||
|
})
|
||||||
fetchData()
|
fetchData()
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
renderChart()
|
renderChart()
|
||||||
|
|||||||
@ -339,10 +339,10 @@ const params = ref({
|
|||||||
const fetchData = async () => {
|
const fetchData = async () => {
|
||||||
try {
|
try {
|
||||||
const userProfile = await getUserProfile()
|
const userProfile = await getUserProfile()
|
||||||
params.value.orgid = userProfile.dept.orgid
|
if(userProfile.dept.orgid!=0){
|
||||||
|
params.value.orgid = userProfile.dept.orgid
|
||||||
|
}
|
||||||
const res = await AlertMessageApi.getAlertMessageStatistics(params.value)
|
const res = await AlertMessageApi.getAlertMessageStatistics(params.value)
|
||||||
console.log(res)
|
|
||||||
// 处理返回的数据格式
|
// 处理返回的数据格式
|
||||||
if (res && res.dailyData && Array.isArray(res.dailyData)) {
|
if (res && res.dailyData && Array.isArray(res.dailyData)) {
|
||||||
chartData.value = res.dailyData.map((item: any) => {
|
chartData.value = res.dailyData.map((item: any) => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user