fix: 修改大屏使用情况接口
							parent
							
								
									e4d390c1ec
								
							
						
					
					
						commit
						5cf9e98765
					
				| 
						 | 
				
			
			@ -54,3 +54,8 @@ export function getResourceCount(type) {
 | 
			
		|||
    params: { type }
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
export function getCapacityCountNew(params) {
 | 
			
		||||
  return request.get('/ims/v1/cloudResource/vendors/resource/capacity', {
 | 
			
		||||
    params: params
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -42,36 +42,36 @@ export const overviewConfigs = [
 | 
			
		|||
      //   value: 0,
 | 
			
		||||
      // },
 | 
			
		||||
    ]
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    title: '私有云使用情况',
 | 
			
		||||
    icon: 'el-icon-data-line',
 | 
			
		||||
    type: 'PROGRESS',
 | 
			
		||||
    titleStyle: {
 | 
			
		||||
      fontSize: '14px'
 | 
			
		||||
    },
 | 
			
		||||
    data: [
 | 
			
		||||
      {
 | 
			
		||||
        title: 'CPU总量/剩余量',
 | 
			
		||||
        unit: '核',
 | 
			
		||||
        color: '#3AE13A',
 | 
			
		||||
        used: 0,
 | 
			
		||||
        total: 0
 | 
			
		||||
      },
 | 
			
		||||
      {
 | 
			
		||||
        title: '内存总量/剩余量',
 | 
			
		||||
        unit: 'G',
 | 
			
		||||
        color: '#FFC400',
 | 
			
		||||
        used: 0,
 | 
			
		||||
        total: 0
 | 
			
		||||
      },
 | 
			
		||||
      {
 | 
			
		||||
        title: '存储总量/剩余量',
 | 
			
		||||
        unit: 'T',
 | 
			
		||||
        color: '#33A1FF',
 | 
			
		||||
        used: 0,
 | 
			
		||||
        total: 0
 | 
			
		||||
      }
 | 
			
		||||
    ]
 | 
			
		||||
  }
 | 
			
		||||
  // {
 | 
			
		||||
  //   title: "私有云使用情况",
 | 
			
		||||
  //   icon: "el-icon-data-line",
 | 
			
		||||
  //   type: "PROGRESS",
 | 
			
		||||
  //   titleStyle: {
 | 
			
		||||
  //     fontSize: "14px",
 | 
			
		||||
  //   },
 | 
			
		||||
  //   data: [
 | 
			
		||||
  //     {
 | 
			
		||||
  //       title: "CPU总量/剩余量",
 | 
			
		||||
  //       unit: "核",
 | 
			
		||||
  //       color: "#3AE13A",
 | 
			
		||||
  //       used: 0,
 | 
			
		||||
  //       total: 0,
 | 
			
		||||
  //     },
 | 
			
		||||
  //     {
 | 
			
		||||
  //       title: "内存总量/剩余量",
 | 
			
		||||
  //       unit: "G",
 | 
			
		||||
  //       color: "#FFC400",
 | 
			
		||||
  //       used: 0,
 | 
			
		||||
  //       total: 0,
 | 
			
		||||
  //     },
 | 
			
		||||
  //     {
 | 
			
		||||
  //       title: "存储总量/剩余量",
 | 
			
		||||
  //       unit: "T",
 | 
			
		||||
  //       color: "#33A1FF",
 | 
			
		||||
  //       used: 0,
 | 
			
		||||
  //       total: 0,
 | 
			
		||||
  //     },
 | 
			
		||||
  //   ],
 | 
			
		||||
  // },
 | 
			
		||||
]
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,16 +8,16 @@
 | 
			
		|||
          <div class="card-body">
 | 
			
		||||
            <el-row :gutter="15" class="resource-count">
 | 
			
		||||
              <el-col :span="12">
 | 
			
		||||
                <ResourceCount title="云主机总数(台)" :value="resourceCount.serverNum" color=""></ResourceCount>
 | 
			
		||||
                <ResourceCount title="云主机总数(台)" :value="resourceCount.vmCount" color=""></ResourceCount>
 | 
			
		||||
              </el-col>
 | 
			
		||||
              <el-col :span="12">
 | 
			
		||||
                <ResourceCount title="CPU总量(核)" :value="resourceCount.cpu" color="#18BE6A" icon="/scr-web/static/img/sip/cpu.png"></ResourceCount>
 | 
			
		||||
                <ResourceCount title="CPU分配量(C)" :value="resourceCount.assignedCpu" color="#18BE6A" icon="/scr-web/static/img/sip/cpu.png"></ResourceCount>
 | 
			
		||||
              </el-col>
 | 
			
		||||
              <el-col :span="12">
 | 
			
		||||
                <ResourceCount title="内存总量(GB)" :value="resourceCount.mem" color="#1890FF" icon="/scr-web/static/img/sip/mem.png"></ResourceCount>
 | 
			
		||||
                <ResourceCount title="内存分配量(GB)" :value="resourceCount.assignedMemory" color="#1890FF" icon="/scr-web/static/img/sip/mem.png"></ResourceCount>
 | 
			
		||||
              </el-col>
 | 
			
		||||
              <el-col :span="12">
 | 
			
		||||
                <ResourceCount title="存储总量(TB)" :value="resourceCount.disk" color="#FF6600" icon="/scr-web/static/img/sip/storage.png"></ResourceCount>
 | 
			
		||||
                <ResourceCount title="存储分配量(TB)" :value="resourceCount.assignedDisk" color="#FF6600" icon="/scr-web/static/img/sip/storage.png"></ResourceCount>
 | 
			
		||||
              </el-col>
 | 
			
		||||
            </el-row>
 | 
			
		||||
          </div>
 | 
			
		||||
| 
						 | 
				
			
			@ -75,18 +75,7 @@ import OverviewState from 'components/OverviewState'
 | 
			
		|||
import PlatformCard from './PlatformCard'
 | 
			
		||||
import ResourceCount from '../count_screen/ResourceCount'
 | 
			
		||||
import { overviewConfigs } from './data'
 | 
			
		||||
import {
 | 
			
		||||
  getOverview,
 | 
			
		||||
  getPlatformOverview,
 | 
			
		||||
  getUsed,
 | 
			
		||||
  getPlatforms,
 | 
			
		||||
  getAlarmPieChart,
 | 
			
		||||
  getResourceApply,
 | 
			
		||||
  getResourceTrend,
 | 
			
		||||
  getResTops,
 | 
			
		||||
  getHostStatus,
 | 
			
		||||
  getResourceCount
 | 
			
		||||
} from 'services/screen/resource'
 | 
			
		||||
import { getOverview, getPlatformOverview, getUsed, getPlatforms, getAlarmPieChart, getResourceApply, getResourceTrend, getResTops, getHostStatus, getResourceCount, getCapacityCountNew } from 'services/screen/resource'
 | 
			
		||||
export default {
 | 
			
		||||
  components: {
 | 
			
		||||
    ScreenWrapper,
 | 
			
		||||
| 
						 | 
				
			
			@ -114,6 +103,7 @@ export default {
 | 
			
		|||
        // 处理数据对configs赋值
 | 
			
		||||
        const { hosts, servers, running } = res.data
 | 
			
		||||
        const unit = state.overviewConfigs[0]
 | 
			
		||||
        console.log(unit, '....')
 | 
			
		||||
        ;[hosts, servers, running].forEach((item, index) => {
 | 
			
		||||
          unit.data[index].value = item
 | 
			
		||||
        })
 | 
			
		||||
| 
						 | 
				
			
			@ -131,30 +121,6 @@ export default {
 | 
			
		|||
        })
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    // 使用情况
 | 
			
		||||
    const getUsedState = async () => {
 | 
			
		||||
      const res = await getUsed()
 | 
			
		||||
      if (res.success) {
 | 
			
		||||
        // 处理数据对configs赋值
 | 
			
		||||
        const {
 | 
			
		||||
          menUnused,
 | 
			
		||||
          memTotal,
 | 
			
		||||
          cpuUnused,
 | 
			
		||||
          cpuTotal,
 | 
			
		||||
          diskTotal,
 | 
			
		||||
          diskUnused
 | 
			
		||||
        } = res.data
 | 
			
		||||
        const unit = state.overviewConfigs[2]
 | 
			
		||||
        ;[
 | 
			
		||||
          { used: cpuUnused, total: cpuTotal },
 | 
			
		||||
          { used: menUnused, total: memTotal },
 | 
			
		||||
          { used: diskUnused, total: diskTotal }
 | 
			
		||||
        ].forEach((item, index) => {
 | 
			
		||||
          unit.data[index].used = item.used
 | 
			
		||||
          unit.data[index].total = item.total
 | 
			
		||||
        })
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    // 公有私有统计
 | 
			
		||||
    const getPlatformCount = async () => {
 | 
			
		||||
      const colors = ['#1890FF', '#19BE6B', '#4144E3', '#ecbc1e']
 | 
			
		||||
| 
						 | 
				
			
			@ -181,9 +147,25 @@ export default {
 | 
			
		|||
    }
 | 
			
		||||
    // 云资源统计
 | 
			
		||||
    const getResource = async () => {
 | 
			
		||||
      const res = await getResourceCount(state.vendorType)
 | 
			
		||||
      const params = {
 | 
			
		||||
        vendorTypes: 'VMWARE,INSPURRAIL,USPHERE',
 | 
			
		||||
        realTime: false
 | 
			
		||||
      }
 | 
			
		||||
      const res = await getCapacityCountNew(params)
 | 
			
		||||
      if (res.success) {
 | 
			
		||||
        state.resourceCount = res.data
 | 
			
		||||
        // 2
 | 
			
		||||
        const { hostLastMemory, hostTotalMemory, hostTotalCpuHz, hostLastCpuHz, hostTotalDisk, hostLastDisk } = res.data
 | 
			
		||||
 | 
			
		||||
        const unit2 = state.overviewConfigs[2]
 | 
			
		||||
        ;[
 | 
			
		||||
          { used: hostLastCpuHz, total: hostTotalCpuHz },
 | 
			
		||||
          { used: hostLastMemory, total: hostTotalMemory },
 | 
			
		||||
          { used: hostLastDisk, total: hostTotalDisk }
 | 
			
		||||
        ].forEach((item, index) => {
 | 
			
		||||
          unit2.data[index].used = item.used
 | 
			
		||||
          unit2.data[index].total = item.total
 | 
			
		||||
        })
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    // 云主机状态
 | 
			
		||||
| 
						 | 
				
			
			@ -237,27 +219,14 @@ export default {
 | 
			
		|||
      }
 | 
			
		||||
    }
 | 
			
		||||
    // 切换平台
 | 
			
		||||
    const change = async (type) => {
 | 
			
		||||
    const change = async type => {
 | 
			
		||||
      state.vendorType = type
 | 
			
		||||
      const proArr = [
 | 
			
		||||
        getApplyCount(),
 | 
			
		||||
        getUsedCount(),
 | 
			
		||||
        getCpuTop5(),
 | 
			
		||||
        getMemTop5(),
 | 
			
		||||
        getHostCount(),
 | 
			
		||||
        getResource()
 | 
			
		||||
      ]
 | 
			
		||||
      const proArr = [getApplyCount(), getUsedCount(), getCpuTop5(), getMemTop5(), getHostCount(), getResource()]
 | 
			
		||||
      await Promise.all(proArr)
 | 
			
		||||
    }
 | 
			
		||||
    const init = async () => {
 | 
			
		||||
      try {
 | 
			
		||||
        await Promise.all([
 | 
			
		||||
          getOverviewState(),
 | 
			
		||||
          getUsedState(),
 | 
			
		||||
          getPlatformState(),
 | 
			
		||||
          getAlarmCount(),
 | 
			
		||||
          change()
 | 
			
		||||
        ])
 | 
			
		||||
        await Promise.all([getOverviewState(), getPlatformState(), getAlarmCount(), change()])
 | 
			
		||||
      } catch (error) {}
 | 
			
		||||
      state.loading = false
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue