Authored by 王涛

性能曲线代码迁移到base

@@ -47,6 +47,21 @@ const routes = [{ @@ -47,6 +47,21 @@ const routes = [{
47 path: '/alarmsubscribe/excludeKpi', 47 path: '/alarmsubscribe/excludeKpi',
48 name: 'alarmSubscribeExcludeKpi', 48 name: 'alarmSubscribeExcludeKpi',
49 component: () => myImport('views/alarmsubscribe/index') 49 component: () => myImport('views/alarmsubscribe/index')
  50 + },
  51 + {
  52 + path: '/vue3/pieDetailLine',
  53 + name: 'pieDetailLine',
  54 + component: () => myImport('views/pieDetailLine/index')
  55 + },
  56 + {
  57 + path: '/vue3/portSenseSelect',
  58 + name: 'portSenseSelect',
  59 + component: () => myImport('views/portSenseSelect/index')
  60 + },
  61 + {
  62 + path: '/alarmsubscribe/excludeKpi',
  63 + name: 'alarmSubscribeExcludeKpi',
  64 + component: () => myImport('views/alarmsubscribe/index')
50 } 65 }
51 ]; 66 ];
52 67
  1 +<div class="pie-detail-line-container" >
  2 + <div class="pie-detail-title">
  3 + <span class="pie-detail-title-active">性能走势</span>
  4 + </div>
  5 + <!-- 趋势分析 预警分析-->
  6 + <div class="pie-detail-content">
  7 + <el-row class="detail-content-title">
  8 + <el-col :span="8"></el-col>
  9 + <el-col :span="16" class="pie-flex-end">
  10 + <div class="pie-date-range">
  11 + <cm-date-range-influx v-if="interval=='custom'" :keys="keys" @callbackinflux="getInfluxOption" @callbacksure="getOptionData" @callbacktime="callbacktime" @callbackrate="callbackrate"></cm-date-range-influx>
  12 + </div>
  13 + <div class="line-filter pie-line-filter">
  14 + <div class="linechartfrequency line-filter-content">
  15 + <div v-if="interval!='custom'" @click="changeInterval('DAY')" :class="['line-filter-item', {'active':interval=='DAY'}]" data-value="DAY" >一天</div>
  16 + <div v-if="interval!='custom'" @click="changeInterval('WEEK')" :class="['line-filter-item', {'active':interval=='WEEK'}]" data-value="WEEK">一周</div>
  17 + <div v-if="interval!='custom'" @click="changeInterval('MONTH')" :class="['line-filter-item', {'active':interval=='MONTH'}]" data-value="MONTH">一月</div>
  18 + <div v-if="interval!='custom'" @click="changeInterval('YEAR')" :class="['line-filter-item', {'active':interval=='YEAR'}]" data-value="YEAR">一年</div>
  19 + <div v-if="interval!='custom'" @click="changeInterval('custom')" :class="['line-filter-item', {'active':interval=='custom'}]" data-value="custom">自定义</div>
  20 + <div v-if="interval=='custom'" @click="changeInterval('DAY')" :class="['line-filter-item', {'active':interval=='custom'}]" data-value="custom">返 回</div>
  21 + </div>
  22 + </div>
  23 +
  24 + </el-col>
  25 +
  26 + </el-row>
  27 + <el-row class="detail-content">
  28 + <el-col :span="24" class="detail_linechart">
  29 + <LineChart :optionData="optionData" v-if="optionData"></LineChart>
  30 +
  31 +<!-- <div class="detail_linechart" id="indentKpiLineChart"></div>-->
  32 + <!-- <div class="detail_linechart" id="warningKpiLineChart" style="margin-top:35px;"></div>-->
  33 + <!-- <div class="detail_linechart" id="line-tingyun-trendKpiLineChart" style="margin-top:35px;"></div>-->
  34 +
  35 +
  36 + </el-col>
  37 + </el-row>
  38 + </div>
  39 +
  40 +</div>
  41 +
  1 +export default {
  2 + name: 'pieDetailLine',
  3 + template: '',
  4 + components:{
  5 + 'LineChart': Vue.defineAsyncComponent(
  6 + () => myImport('views/zjdaping/components/lineChart/index')
  7 + )
  8 + },
  9 + data() {
  10 + return{}
  11 + },
  12 + setup(props, {attrs, slots, emit}) {
  13 + const {proxy} = Vue.getCurrentInstance();
  14 + let interval=Vue.ref('DAY');
  15 + let optionData=Vue.ref('');
  16 + let names = Vue.ref(['00:00', '01:00', '02:00', '03:00', '04:00', '05:00', '06:00', '07:00', '08:00', '09:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00', '18:00', '19:00', '20:00', '21:00', '22:00', '23:00']);
  17 + let series = Vue.ref([]);
  18 + let rateData = Vue.ref([]);
  19 + let kpiUnit = Vue.ref('');
  20 + let kpiName = Vue.ref('');//指标名称
  21 + let startTime=Vue.ref('');
  22 + let endTime=Vue.ref('');
  23 + let colorsArr=Vue.ref([
  24 + {
  25 + start: '#46d6d8',
  26 + end: '#2883d0'
  27 + },
  28 + {
  29 + start: '#facf5b',
  30 + end: '#f77623'
  31 + },
  32 + {
  33 + start: '#C04DD8',
  34 + end: '#D81F72'
  35 + },
  36 + {
  37 + start: '#F5A1EB',
  38 + end: '#A04DE2'
  39 + },
  40 + {
  41 + start: '#F36093',
  42 + end: '#FF465C'
  43 + },
  44 + {
  45 + start: '#C2E74D',
  46 + end: '#00AE8B'
  47 + },
  48 + {
  49 + start: '#3DC3FF',
  50 + end: '#01FFFF'
  51 + },
  52 + {
  53 + start: '#B850ED',
  54 + end: '#9062EF'
  55 + },
  56 + {
  57 + start: '#305be6',
  58 + end: '#36a7d3'
  59 + },
  60 + {
  61 + start: '#FFA500',
  62 + end: '#FFEE00'
  63 + },
  64 + {
  65 + start: '#C4E64C',
  66 + end: '#2de078'
  67 + },
  68 + {
  69 + start: '#30ffb3',
  70 + end: '#01FFFF'
  71 + },
  72 + {
  73 + start: '#FF4488',
  74 + end: '#F13EFF'
  75 + },
  76 + {
  77 + start: '#A64CE2',
  78 + end: '#625AE7'
  79 + },
  80 + {
  81 + start: '#5AEBC7',
  82 + end: '#5FC9F8'
  83 + },
  84 + {
  85 + start: '#FFA500',
  86 + end: '#FFEE00'
  87 + },
  88 + {
  89 + start: '#00AAD6',
  90 + end: '#625AE7'
  91 + },
  92 + {
  93 + start: '#E48BDE',
  94 + end: '#FF9262'
  95 + },
  96 + {
  97 + start: '#B2797B',
  98 + end: '#FF4B51'
  99 + },
  100 + {
  101 + start: '#ffe393',
  102 + end: '#feff5b'
  103 + }
  104 + ])
  105 + let keys=Vue.ref('');
  106 + let getOptionData=(res)=>{
  107 + let nameArr=[];
  108 + let dataArr=[];
  109 + if(res && res.success){
  110 + if(res.map){
  111 + let resData=res.map;
  112 + kpiUnit.value = resData.kpiUnit == null ? "" : resData.kpiUnit;
  113 + Object.keys(resData).forEach(function(key){
  114 + Object.keys(resData[key]).sort(function (a, b) {
  115 + return a<b?1:-1;
  116 + }).forEach(function(time){
  117 + nameArr.unshift(time);
  118 + dataArr.unshift(resData[key][time])
  119 + })
  120 + })
  121 + rateData.value = {
  122 + names: nameArr,
  123 + series: [{
  124 + "data": dataArr,
  125 + "name": '平均值'
  126 + }],
  127 + kpiUnit: kpiUnit.value
  128 + }
  129 +
  130 + }
  131 +
  132 + }else{
  133 + proxy.$global.showMsg(res.msg,'warning');
  134 + }
  135 + setSeries();
  136 + }
  137 +
  138 + const getInfluxOption = (res) => {
  139 + let str = res.str;
  140 + if (res.map && Object.keys(res.map).length == 0) {
  141 + let defData = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
  142 + let seriesDefArr = [];
  143 + if(str == 'performance'){
  144 + seriesDefArr = [{
  145 + "data": defData,
  146 + "name": kpiName.value
  147 + }];
  148 + } else {
  149 + seriesDefArr = [{
  150 + "data": defData,
  151 + "name": "最大"
  152 + },{
  153 + "data": defData,
  154 + "name": "最小"
  155 + },{
  156 + "data": defData,
  157 + "name": "平均"
  158 + }];
  159 + }
  160 + rateData.value = {
  161 + names: ['00:00', '01:00', '02:00', '03:00', '04:00', '05:00', '06:00', '07:00', '08:00', '09:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00', '18:00', '19:00', '20:00', '21:00', '22:00', '23:00'],
  162 + series: seriesDefArr,
  163 + kpiUnit: kpiUnit.value
  164 + }
  165 + } else {
  166 + let names = [];
  167 + let max = [];
  168 + let min = [];
  169 + let avg = [];
  170 + let kpiValueArr = [];
  171 + let seriesArr = [];
  172 + let kpiName = '';
  173 + let kpiUnitVal = '';
  174 + let kpiList = res.data;
  175 +
  176 + Object.keys(res.map).forEach(function(key){
  177 + res.map[key].forEach(function(item){
  178 + names.push(item.dbTimeStr);
  179 + if(str == 'performance'){
  180 + kpiValueArr.push(item.kpiValue);
  181 + } else {
  182 + max.push(item.maxValue);
  183 + min.push(item.minValue);
  184 + avg.push(item.avgValue);
  185 + }
  186 + if(kpiName == '' && kpiUnitVal == ''){
  187 + kpiList.filter(function (v){
  188 + if(v.kpiId == item.kpiId){
  189 + kpiName = v.kpiName;
  190 + kpiUnitVal = v.unit;
  191 + }
  192 + })
  193 + }
  194 + })
  195 + })
  196 +
  197 + if(str == 'performance'){
  198 + seriesArr = [{
  199 + "data": kpiValueArr,
  200 + "name": kpiName
  201 + }];
  202 + } else {
  203 + seriesArr = [{
  204 + "data": max,
  205 + "name": "最大"
  206 + },{
  207 + "data": min,
  208 + "name": "最小"
  209 + },{
  210 + "data": avg,
  211 + "name": "平均"
  212 + }];
  213 + }
  214 +
  215 +
  216 + kpiUnit.value = kpiUnitVal;
  217 + rateData.value = {
  218 + names: names,
  219 + series: seriesArr,
  220 + kpiUnit: kpiUnit.value
  221 + };
  222 + }
  223 + setSeries();
  224 + }
  225 +
  226 +
  227 + const changeInterval=(val)=>{
  228 + interval.value=val;
  229 + if(val=='custom'){
  230 + }else{
  231 + getLineChart();
  232 +
  233 + }
  234 + }
  235 +
  236 + const getLineChart=()=>{
  237 + let params=proxy.$route.query
  238 + let resourceId=params.resId;//资源ID
  239 + let kpiId =params.kpiId; //指标ID
  240 + let flag =params.flag;//二级资源标识
  241 + let warning =params.warning;//预警指标标识
  242 + let ident =params.ident;//性能指标标识
  243 + let trend =params.trend;//趋势指标标识
  244 + keys.value=resourceId+":"+kpiId+":"+flag;
  245 + kpiName.value = params.name;//指标名称
  246 + let url = '/api-web/detail/performance/line/chart?interval=' + interval.value + '&startTime='
  247 + + startTime.value + '&endTime=' + endTime.value + '&resId=' + resourceId + '&kpiIds=' + kpiId + '&subResId=' + flag;
  248 + proxy.$http.get(url, {},function (res){
  249 + kpiUnit.value = res.data.kpiUnit == null ? "" : res.data.kpiUnit;
  250 + if (res.data && res.data.names.length == 0) {
  251 + rateData.value = {
  252 + names: ['00:00', '01:00', '02:00', '03:00', '04:00', '05:00', '06:00', '07:00', '08:00', '09:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00', '18:00', '19:00', '20:00', '21:00', '22:00', '23:00'],
  253 + series: [{
  254 + "data": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  255 + "name": kpiName.value
  256 + }],
  257 + kpiUnit: kpiUnit.value
  258 + }
  259 + } else {
  260 + rateData.value = res.data;
  261 + }
  262 + setSeries();
  263 + },function (error){
  264 + rateData.value = {
  265 + names: ['00:00', '01:00', '02:00', '03:00', '04:00', '05:00', '06:00', '07:00', '08:00', '09:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00', '18:00', '19:00', '20:00', '21:00', '22:00', '23:00'],
  266 + series: [{
  267 + "data": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  268 + "name": kpiName.value
  269 + }],
  270 + kpiUnit: kpiUnit.value
  271 + }
  272 + setSeries();
  273 + })
  274 +
  275 + }
  276 + const setSeries=()=>{
  277 + series.value=[];
  278 + $.each(rateData.value.series,function (i,v) {
  279 + series.value.push({
  280 + name: v.name,
  281 + type: 'line',
  282 + data: v.data,
  283 + symbolSize: 12,
  284 + symbol: 'circle',
  285 + itemStyle: {
  286 + normal: {
  287 + color: colorsArr.value[i].start //图标颜色
  288 + }
  289 + },
  290 + lineStyle: {
  291 + normal: {
  292 + width: 3, //连线粗细
  293 + color: colorsArr.value[i].end //连线颜色
  294 + }
  295 + }
  296 + })
  297 + });
  298 + optionDataInit();
  299 + }
  300 + const optionDataInit=()=>{
  301 +
  302 + optionData.value = {
  303 + tooltip: {
  304 + trigger: 'axis',
  305 + formatter:function (param) {
  306 + var tips = kpiName.value+" "+param[0].name +"<br/>";
  307 + $.each(param,function (i,v) {
  308 + tips += v.marker+" "+v.seriesName + ":"+v.value +kpiUnit.value+"</br>"
  309 + });
  310 + return tips;
  311 + }
  312 + },
  313 + legend: {
  314 + show: true
  315 + },
  316 + grid: {
  317 + top: '10%',
  318 + left: '3%',
  319 + right: '4%',
  320 + bottom: '15%',
  321 + containLabel: true
  322 + },
  323 + toolbox: {
  324 + feature: {
  325 + saveAsImage: {
  326 + show: false
  327 + }
  328 + }
  329 + },
  330 + xAxis: {
  331 + type: 'category',
  332 + data: rateData.value.names,
  333 + axisLine: {
  334 + lineStyle: {
  335 + color: '#c9c9c9'
  336 + }
  337 + },
  338 + axisLabel: {
  339 + color: '#232425',
  340 + showMaxLabel: true
  341 + },
  342 + splitArea: {
  343 + show: true,
  344 + areaStyle: {
  345 + color: ['rgba(200,200,200,0.1)', 'transparent'
  346 + ]
  347 + }
  348 + }
  349 + },
  350 + yAxis: {
  351 + type: 'value',
  352 + scale: true,
  353 + boundaryGap: ['10%', '10%'],
  354 + axisLine: {
  355 + lineStyle: {
  356 + color: '#232425'
  357 + },
  358 + show: false
  359 + },
  360 + axisTick: {
  361 + show: false
  362 + },
  363 + splitLine: {
  364 + lineStyle: {
  365 + color: ['#ccc']
  366 + }
  367 + }
  368 + },
  369 + // x轴拖动
  370 + dataZoom: [
  371 + {
  372 + type: "slider",
  373 + realtime: true, //拖动滚动条时是否动态的更新图表数据
  374 + height: 25, //滚动条高度
  375 + start: 40, //滚动条开始位置(共100等份)
  376 + end: 65 //结束位置(共100等份)
  377 + }
  378 + ],
  379 + series:series.value
  380 + };
  381 + }
  382 + //时间范围组件回调函数--时间范围
  383 + const callbacktime=(val)=>{
  384 +
  385 + }
  386 + //时间范围组件回调函数--聚合频率
  387 + const callbackrate=(val)=>{
  388 +
  389 + }
  390 + // 挂载完
  391 + Vue.onMounted(() => {
  392 + getLineChart();
  393 + })
  394 + return {
  395 + interval,
  396 + optionData,
  397 + names,
  398 + series,
  399 + rateData,
  400 + kpiUnit,
  401 + kpiName,
  402 + keys,
  403 + optionDataInit,
  404 + getOptionData,
  405 + getInfluxOption,
  406 + getLineChart,
  407 + changeInterval
  408 + }
  409 + }
  410 +}