2021-11-30 16:39:21 +08:00
< template >
2021-12-02 18:33:28 +08:00
< div class = "chart-config" >
< el-form
ref = "chartForm"
: model = "chartConfig"
: rules = "rules"
label - position = "top"
label - width = "120px"
>
2021-12-29 14:29:37 +08:00
2022-03-25 15:40:05 +08:00
< div v-my-loading = "loading" v-for="(item, index) in chartConfig.param.datasource " :key="index" class="chart-system-top-box" >
2021-12-29 14:29:37 +08:00
< div class = "chart-title chart-title-config" >
< span class = "chart-title-content el-form-item" : class = " {
2021-12-17 11:18:49 +08:00
'is-error' : systemNameShow [ 0 ] . error ,
'hide-input' : systemNameShow [ 0 ] . hideInput
} " >
< i class = "nz-icon nz-icon-arrow-down" :class = "systemNameShow[0].show?'':'is-active'" @click.stop ="showSystemNameShow(0)" > < / i >
< el-input
@ mousedown . stop
v - model = "chartConfig.param.datasource[0].name"
size = "small"
@ input = "(val)=>{systemNameInput(val,0)}"
@ change = "systemNameChange(0)" style = "width: 120px"
@ focus . stop = "showsystemInput(0,false)"
@ blur = "showsystemInput(0,true)"
/ >
< div v-if = "systemNameShow[0].error" class="el-form-item__error" style="top: 10px;left: 164px" > {{ systemNameShow [ 0 ] .error }} < / div >
< / span >
2021-12-02 18:33:28 +08:00
< / div >
2021-12-29 14:29:37 +08:00
< transition name = "el-zoom-in-top" >
< div v-show = "systemNameShow[0].show" >
< div class = "system-chart-config" >
< div class = "system-chart-config-left" >
< ul >
< li
v - for = "(system,index1) in systemData"
: key = "index1"
class = "system-chart-item"
: class = "system.name == chartConfig.param.datasource[index].type ? 'is-select' : ''"
@ click = "changeSystem(system, index)"
2022-02-25 15:39:44 +08:00
> { { system . name } } < i class = "nz-icon nz-icon-check" / > < / li >
2021-12-29 14:29:37 +08:00
< / ul >
< / div >
< div class = "system-chart-config-right" >
< div class = "form-items--half-width-group" >
< el-form-item
: label = "$t('dashboard.panel.chartForm.dimension')"
class = "form-item--half-width"
prop = "param.systemGroup"
>
< el-select size = "small" v-model = "item.systemGroup" multiple collapse-tags :placeholder="$t('el.select.placeholder')" @change="systemGroupChange(index)" popper-class="right-box-select-top prevent-clickoutside" >
< el-option v-for = "group in groupList" :value="group.name" :key="group.name" :label="group.name" />
< / el-select >
< / el-form-item >
< el-form-item
v - if = "selectList.length"
: label = "$t('dashboard.panel.chartForm.select')"
class = "form-item--half-width"
prop = "param.systemSelect"
>
< el-select size = "small" v-model = "item.systemSelect" :placeholder="$t('el.select.placeholder')" @change="systemSelectChange(index)" popper-class="right-box-select-top prevent-clickoutside" >
< el-option v-for = "selectItem in selectList" :value="selectItem.name" :key="selectItem.name" :label="selectItem.name" />
< / el-select >
< / el-form-item >
< / div >
< div class = "form-items--half-width-group" >
< el-form-item
: label = "$t('dashboard.panel.chartForm.sort')"
class = "form-item--half-width"
prop = "param.sort"
>
< el-select
id = "chart-box-height"
v - model = "item.sort"
placeholder = ""
popper - class = "right-box-select-top prevent-clickoutside"
size = "small"
value - key = "chartSpan"
@ change = "change"
>
< el-option :value = "'desc'" :label = "$t('dashboard.explore.descending')" >
< / el-option >
< el-option :value = "'asc'" :label = "$t('dashboard.explore.ascending')" >
< / el-option >
< / el-select >
< / el-form-item >
< el-form-item
: label = "$t('dashboard.panel.chartForm.limit')"
class = "form-item--half-width"
prop = "param.limit"
>
< el-input-number :controls = "false" v -model .number = " item.limit " :placeholder = "$t('placeholder.system.limit')" size = "small" @change ="change" />
< / el-form-item >
< / div >
2022-02-21 10:40:12 +08:00
< div class = "form-items--half-width-group" >
< el-form-item
: label = "$t('dashboard.panel.chartForm.filter')"
class = "form-item"
style = "width: 100%"
prop = "param.filter"
>
< filterSearch
2022-02-22 18:27:28 +08:00
ref = "filterSearch"
2022-02-21 17:16:33 +08:00
: valueList . sync = "item.filter"
@ change = "change"
2022-02-21 10:40:12 +08:00
: keyList = "keyList"
/ >
< / el-form-item >
< / div >
2021-12-29 14:29:37 +08:00
< / div >
< / div >
< el-row style = "display: flex" >
< el-col class = "legend-title" >
< span class = "legend-title__span" > { { $t ( 'dashboard.panel.chartForm.legend' ) } } & nbsp ; < / span >
< el-popover placement = "top" trigger = "hover" width = "211" popper -class = " prevent -clickoutside " >
< div :style = "{'word-break':language!=='cn'?'keep-all':'break-all'}" > { { $t ( 'dashboard.panel.chartForm.legendTip' ) } } < / div >
< i @mouseover ="rz" class = "nz-icon nz-icon-info-normal" slot = "reference" style = "font-size: 14px; -webkit-transform:scale(0.75);display:inline-block;" > < / i >
< / el-popover >
< / el-col >
< el-col style = "flex: 1" >
< el-form-item style = "margin: 0 0 10px 0" >
< el-input size = "small" v-model = "item.legend" @change="change" style="line-height: 32px" > < / el -input >
< / el-form-item >
< / el-col >
< / el-row >
2021-12-02 18:33:28 +08:00
< / div >
2021-12-29 14:29:37 +08:00
< / transition >
2021-12-02 18:33:28 +08:00
< / div >
<!-- title -- >
< div class = "form__sub-title" >
< span > { { $t ( 'dashboard.panel.chartForm.displayConfig' ) } } < / span >
< / div >
< div class = "form-items--half-width-group" >
<!-- type -- >
< el-form-item
: label = "$t('dashboard.panel.chartForm.type')"
class = "form-item--half-width"
prop = "type"
2021-12-02 15:36:01 +08:00
>
2021-12-02 18:33:28 +08:00
< el-select
id = "chart-box-type"
v - model = "chartConfig.type"
: disabled = "chartConfig.type==='group'&&chartConfig.children&&chartConfig.children.length"
placeholder = ""
popper - class = "right-box-select-top prevent-clickoutside"
size = "small"
value - key = "chartType"
@ change = "chartTypeChange" >
< el-option
v - for = "item in chartTypeList"
: key = "item.id"
: disabled = "item.id==='group' && chartConfig.isGroup"
: label = "item.name"
: value = "item.id" >
< span class = "panel-dropdown-label-txt" > { { item . name } } < / span >
< / el-option >
< / el-select >
< / el-form-item >
<!-- refer -- >
< el-form-item
: label = "$t('dashboard.panel.chartForm.refer')"
class = "form-item--half-width"
prop = "param.stack"
2021-12-07 14:19:16 +08:00
style = "display: none"
2021-12-02 15:36:01 +08:00
>
2021-12-02 18:33:28 +08:00
< el-select
id = "chart-box-height"
v - model = "chartConfig.param.refer"
placeholder = ""
popper - class = "right-box-select-top prevent-clickoutside"
size = "small"
value - key = "chartSpan"
@ change = "change"
>
< el-option :value = "1" label = "true" >
< / el-option >
< el-option :value = "0" label = "false" >
< / el-option >
< / el-select >
< / el-form-item >
2021-12-15 17:55:56 +08:00
<!-- index -- >
< el-form-item
v - show = "isTable(chartConfig.type)"
: label = "$t('dashboard.panel.chartForm.tableIndex')"
class = "form-item--half-width"
prop = "param.index"
>
< vue-tags-input
v - model = "tag"
: maxlength = "32"
: placeholder = "$t('overall.addParameter')"
: tags = "chartConfig.param.tags"
@ tags - changed = "(newTags)=>{tagsChange(newTags)}"
/ >
< / el-form-item >
2021-12-22 15:11:23 +08:00
<!-- unit -- >
< el-form-item
v - show = "!isTable(chartConfig.type)&&!isLog(chartConfig.type)"
: label = "$t('dashboard.panel.chartForm.unit')"
class = "form-item--half-width"
prop = "unit"
>
< el-cascader id = "chart-box-unit"
v - model = "chartConfig.unit"
: options = "unitOptions"
: props = "{ expandTrigger: 'hover',emitPath:false }"
: show - all - levels = "false" filterable
placeholder = ""
popper - class = "dc-dropdown right-box-select-top right-public-box-dropdown-top prevent-clickoutside chart-box-unit"
size = "small"
style = "width: 100%"
@ change = "unitSelected"
>
< / el-cascader >
< / el-form-item >
< / div >
2021-12-02 18:33:28 +08:00
< div class = "form-items--half-width-group" >
<!-- width -- >
< el-form-item
: label = "$t('dashboard.panel.chartForm.width')"
class = "form-item--half-width"
prop = "span" >
< el-select
id = "chart-box-span"
v - model = "chartConfig.span"
: disabled = "chartConfig.type === 'group'"
placeholder = ""
popper - class = "right-box-select-top prevent-clickoutside"
size = "small"
value - key = "chartSpan"
@ change = "change"
>
< el-option
v - for = "item in spanList"
: key = "item"
: label = "'span-' + item"
: value = "item" >
< span class = "panel-dropdown-label-txt" > span - { { item } } < / span >
< / el-option >
< / el-select >
< / el-form-item >
2021-12-02 15:36:01 +08:00
2021-12-02 18:33:28 +08:00
<!-- height -- >
< el-form-item
: label = "$t('dashboard.panel.chartForm.high')"
class = "form-item--half-width"
prop = "height" >
<!-- 由px改为span -- >
< el-select
id = "chart-box-height"
v - model = "chartConfig.height"
: disabled = "chartConfig.type === 'group'"
placeholder = ""
popper - class = "right-box-select-top prevent-clickoutside"
size = "small"
value - key = "chartSpan"
@ change = "change"
2021-12-02 15:36:01 +08:00
>
2021-12-02 18:33:28 +08:00
< el-option
v - for = "item in spanList"
: key = "item"
: label = "'span-' + item"
: value = "item"
>
< span class = "panel-dropdown-label-txt" > span - { { item } } < / span >
< / el-option >
< / el-select >
< / el-form-item >
< / div >
2021-12-24 15:32:16 +08:00
< div class = "form-items--half-width-group" v-if = "isGauge(chartConfig.type)" >
<!-- min -- >
< el-form-item :label = "$t('dashboard.panel.chartForm.min')" class = "form-item--half-width" >
< el-input-number
size = "small"
style = "margin-top: 2px"
: controls = "false"
@ change = "change"
show - word - limit v - model = "chartConfig.param.min" / >
< / el-form-item >
<!-- max -- >
< el-form-item :label = "$t('dashboard.panel.chartForm.max')" class = "form-item--half-width" >
< el-input-number
size = "small"
style = "margin-top: 2px"
: controls = "false"
@ change = "change"
show - word - limit v - model = "chartConfig.param.max" / >
< / el-form-item >
< / div >
2021-12-23 16:07:57 +08:00
< div class = "form-items--half-width-group" >
<!-- text -- >
< el-form-item
: label = "$t('dashboard.panel.chartForm.display')"
class = "form-item--half-width"
prop = "param.nullType"
v - if = "isShowText(chartConfig.type)"
>
< el-select
id = "chart-box-text"
v - model = "chartConfig.param.text"
placeholder = ""
popper - class = "right-box-select-top prevent-clickoutside"
size = "small"
@ change = "change"
>
< el-option
v - for = "item in textList"
: key = "item.value"
: label = "$t(item.label)"
: value = "item.value"
> < / el-option >
< / el-select >
< / el-form-item >
2022-03-15 14:08:55 +08:00
<!-- decimals -- >
2022-03-18 09:19:43 +08:00
< el-form-item v-if = "isShowDecimals(chartConfig.type)" :label="$t('config.assetLabel.decimals')" class="form-item--half-width" >
2022-03-15 14:08:55 +08:00
< el-input-number
size = "small"
style = "margin-top: 2px"
: controls = "false"
@ change = "change"
: placeholder = "'Default 2'"
show - word - limit v - model = "chartConfig.param.decimals" / >
< / el-form-item >
2021-12-23 16:07:57 +08:00
< / div >
2021-12-28 10:53:34 +08:00
<!-- legend -- >
< div v-if = "isShowLegend(chartConfig.type)" >
<!-- legendConfig -- >
< div class = "form__sub-title" >
< span > { { $t ( 'dashboard.panel.chartForm.legendConfig' ) } } < / span >
< el-switch v-model = "chartConfig.param.enable.legend" size="small" @change="change" > < / el -switch >
< / div >
< transition name = "el-zoom-in-top" >
< div
v - if = "chartConfig.param.enable.legend"
class = "form-items--half-width-group"
>
< el-form-item
: label = "$t('dashboard.panel.chartForm.legendPosition')"
class = "form-item--half-width"
prop = "param.legend.placement"
>
< el-select
id = "chart-box-legend-show"
v - model = "chartConfig.param.legend.placement"
placeholder = ""
popper - class = "right-box-select-top prevent-clickoutside"
size = "small"
@ change = "change"
>
< el-option
v - for = "item in legendPositionList"
: key = "item.value"
: label = "$t(item.label)"
: value = "item.value"
> < / el-option >
< / el-select >
< / el-form-item >
< el-form-item
: label = "$t('dashboard.panel.chartForm.legendValues')"
class = "form-item--half-width"
prop = "param.legend.values"
v - if = "isShowLegendVlaues(chartConfig.type)"
>
< el-select
id = "chart-box-legend-value"
v - model = "chartConfig.param.legend.values"
multiple
collapse - tags
: placeholder = "$t('el.select.placeholder')"
popper - class = "right-box-select-top prevent-clickoutside"
size = "small"
@ change = "change"
>
< el-option
v - for = "item in statisticsList"
: key = "item.value"
: label = "$t(item.label)"
: value = "item.value"
>
< / el-option >
< / el-select >
< / el-form-item >
< / div >
< / transition >
2022-03-24 15:59:05 +08:00
<!-- thresholdConfig -- >
2022-04-02 17:30:49 +08:00
< div class = "form__sub-title" v-if = "isThresholdConfig(chartConfig.type)" >
2022-03-24 15:59:05 +08:00
< span > { { $t ( 'dashboard.panel.chartForm.threshold' ) } } < / span >
< el-switch
v - model = "chartConfig.param.enable.thresholds"
size = "small"
@ change = "thresholdShowChange"
> < / el-switch >
< / div >
< transition name = "el-zoom-in-top" >
2022-04-02 17:30:49 +08:00
< el-row v-if = "chartConfig.param.enable.thresholds && isThresholdConfig(chartConfig.type)" >
2022-03-24 15:59:05 +08:00
< el-form-item
v - for = "(item,index) in chartConfig.param.thresholds"
: key = "index"
class = "thresholds-item"
: prop = "'param.thresholds.' + index + '.value'"
: rules = "{ required: true, message: $t('validate.required'), trigger: 'blur'}"
>
< nezhaColor
: value - arr = "[{name:'thresholds',value:item.color}]"
: show - text = "false"
: color - val = "item.color"
@ colorChange = "(color,key)=>{colorChange(color,key,index)}"
/ >
< el-input-number
size = "small"
style = "margin-top: 2px"
: placeholder = "$t('placeholder.chart.threshold')"
v - model . number = "item.value"
: controls = "false"
@ blur = "sortThresholds"
@ change = "change"
/ >
< span
@ click = "delThresholds(index)"
class = "del-thresholds-icon"
>
< i class = "nz-icon nz-icon-delete" / >
< / span >
< / el-form-item >
< div @click ="addThresholds" class = "thresholds-add" >
{ { $t ( 'overall.addThresholds' ) } }
< / div >
< / el-row >
< / transition >
2021-12-28 10:53:34 +08:00
< / div >
2022-03-24 15:59:05 +08:00
2021-12-16 10:10:27 +08:00
<!-- table column -- >
< div v-if = "isTable(chartConfig.type)" >
< div class = "form__sub-title" >
< span > { { $t ( 'dashboard.panel.chartForm.columns' ) } } < / span >
< / div >
2022-03-15 11:14:42 +08:00
< div v-for = "(item,index) in chartConfig.param.columns" :key="index" :class="item.error? 'is-item-box-error' : ''" >
2021-12-16 10:10:27 +08:00
< div class = "chart-title chart-title-config" >
< span class = "chart-title-content" >
< i class = "nz-icon nz-icon-arrow-down" :class = "item.show?'':'is-active'" @click ="showColumns(index)" > < / i >
< span v-show = "!item.show" class="title-content-left" >
< span >
{ { item . value } }
< / span >
< / span >
< / span >
< span >
< span @click ="addColumns('')" >
< i class = "nz-icon nz-icon-create-square" style = "font-weight: normal; font-size: 17px; cursor: pointer;" > < / i >
< / span >
2022-03-29 11:13:01 +08:00
< span style = "margin-right: 5px" >
2021-12-16 10:10:27 +08:00
< i @click ="copyColumns(index)" class = "nz-icon nz-icon-override" > < / i >
< / span >
< span class = "nz-icon-minus-medium" >
< i @click ="removeColumns(index)" class = "nz-icon nz-icon-minus" > < / i >
< / span >
< / span >
< / div >
< transition-group appear tag = "div" name = "el-zoom-in-top" >
< el-row class = "thresholds-item" v-show = "item.show" :key="1" >
< div >
2022-03-24 15:59:05 +08:00
< div class = 'mapping-display' > { { $t ( 'project.topology.title' ) } } < / div >
2021-12-16 10:10:27 +08:00
< / div >
< el-form-item : prop = "'param.columns.' + index + '.title'" : rules = "{ required: true, message: $t('validate.required'), trigger: 'blur'}" class = "thresholds-from-item" style = "flex: 1" >
2022-03-15 11:14:42 +08:00
< el-input size = "small" v-model = "item.title" @change="change('columns',index)" > < / el -input >
2021-12-16 10:10:27 +08:00
< / el-form-item >
< div >
2022-03-24 15:59:05 +08:00
< div class = 'mapping-display' > { { $t ( 'dashboard.panel.chartForm.unit' ) } } < / div >
2021-12-16 10:10:27 +08:00
< / div >
< el-cascader : id = "'columns-unit' + index" v-model = "item.unit" :options="unitOptions" :props="{ expandTrigger: 'hover',emitPath:false }" :show-all-levels="false" filterable
placeholder = ""
popper - class = "dc-dropdown right-box-select-top right-public-box-dropdown-top prevent-clickoutside chart-box-unit"
size = "small"
style = "flex: 1"
@ change = "unitSelected"
>
< / el-cascader >
< / el-row >
< el-row class = "thresholds-item" v-show = "item.show" :key="2" >
< div >
2022-03-24 15:59:05 +08:00
< div class = 'mapping-display' > { { $t ( 'dashboard.panel.chartForm.display' ) } } < / div >
2021-12-16 10:10:27 +08:00
< / div >
< el-form-item : prop = "'param.columns.' + index + '.display'" : rules = "{ required: true, message: $t('validate.required'), trigger: 'blur'}" class = "thresholds-from-item" >
2022-03-15 11:14:42 +08:00
< el-input v-model = "item.display" style="margin-right: 10px" size="small" @change="change('columns',index)" />
2021-12-16 10:10:27 +08:00
< / el-form-item >
< / el-row >
< / transition-group >
< / div >
< div @click ="addColumns" class = "thresholds-add" >
2022-03-24 15:59:05 +08:00
{ { $t ( 'overall.addColumns' ) } }
2021-12-16 10:10:27 +08:00
< / div >
< / div >
2021-12-03 10:08:34 +08:00
<!-- valueMapping -- >
2021-12-16 10:10:27 +08:00
< div v-if = "isShowValueMapping(chartConfig.type) || isTable(chartConfig.type)" >
2021-12-03 10:08:34 +08:00
< div class = "form__sub-title" >
< span > { { $t ( 'dashboard.panel.chartForm.valueMapping' ) } } < / span >
< el-switch
2021-12-16 18:13:47 +08:00
v - model = "chartConfig.param.enable.valueMapping"
2021-12-03 10:08:34 +08:00
size = "small"
@ change = "change"
> < / el-switch >
< / div >
< transition name = "el-zoom-in-top" >
2021-12-16 18:13:47 +08:00
< el-row v-if = "chartConfig.param.enable.valueMapping" >
2021-12-03 10:08:34 +08:00
< div
2021-12-16 18:13:47 +08:00
v - for = "(item,index) in chartConfig.param.valueMapping"
2021-12-03 10:08:34 +08:00
: key = "index"
2022-03-15 11:14:42 +08:00
: class = "item.error? 'is-item-box-error' : ''"
2021-12-03 10:08:34 +08:00
>
< div class = "chart-title chart-title-config" >
2021-12-16 10:10:27 +08:00
< span class = "chart-title-content" >
2021-12-03 10:08:34 +08:00
< i class = "nz-icon nz-icon-arrow-down" :class = "item.show?'':'is-active'" @click ="showMapping(index)" > < / i >
< span v-show = "!item.show" class="title-content-left" >
< span v-if = "item.type === 'value'" >
{ { item . value } }
< / span >
< span v-if = "item.type === 'range'" >
2021-12-24 18:39:31 +08:00
[ { { item . from } } , { { item . to } } )
2021-12-03 10:08:34 +08:00
< / span >
< span v-if = "item.type === 'regx'" >
{ { item . regx } }
< / span >
2022-05-09 15:57:03 +08:00
< div class = "prev-mapping-icon" >
< i :class = "item.icon" : style = "{ color: item.color.icon }" > < / i >
< / div >
< div :style = "{background:item.color.bac}" class = "prev-mapping-box" >
< span :style = "{color:item.color.text}" >
{ { item . display || "T" } }
< / span >
< / div >
2021-12-03 10:08:34 +08:00
< / span >
< / span >
< span >
2021-12-16 10:10:27 +08:00
< span @click ="addMapping('')" style = "margin-right: 5px" >
< i class = "nz-icon nz-icon-create-square" > < / i >
2021-12-03 10:08:34 +08:00
< / span >
2021-12-16 10:10:27 +08:00
< span @click ="copyMapping(index)" style = "margin-right: 5px" >
< i class = "nz-icon nz-icon-override" > < / i >
2021-12-03 10:08:34 +08:00
< / span >
2021-12-16 10:10:27 +08:00
< span @click ="removeMapping(index)" style = "margin-right: 5px" >
< i class = "nz-icon nz-icon-minus" > < / i >
2021-12-03 10:08:34 +08:00
< / span >
< / span >
< / div >
< transition-group appear tag = "div" name = "el-zoom-in-top" >
< el-row
v - show = "item.show"
: key = "1"
class = "thresholds-item"
>
< div >
< el-select
v - model = "item.type"
size = "small"
style = "width: 100px"
@ change = "(val)=>{mappingItemChange(index,val)}"
>
< el-option
v - for = "item in mappingTypeList"
: value = "item.value"
2022-03-24 15:59:05 +08:00
: label = "$t(item.label)"
2021-12-03 10:08:34 +08:00
: key = "item.value" / >
< / el-select >
< / div >
< el-form-item
v - if = "item.type === 'value'"
2021-12-16 18:13:47 +08:00
: prop = "'param.valueMapping.' + index + '.value'"
2021-12-09 10:34:11 +08:00
: rules = "{ required: true, message: $t('validate.required'), trigger: 'blur'}"
2021-12-03 10:08:34 +08:00
class = "thresholds-from-item"
>
2021-12-09 10:34:11 +08:00
< el-input-number
2021-12-03 10:08:34 +08:00
: controls = "false"
size = "small"
2021-12-03 16:58:25 +08:00
v - model . number = "item.value"
2021-12-03 10:08:34 +08:00
placeholder = "value"
2022-03-15 11:14:42 +08:00
@ change = "change('valueMapping', index)"
2021-12-09 10:34:11 +08:00
> < / el-input-number >
2021-12-03 10:08:34 +08:00
< / el-form-item >
< el-form-item
v - if = "item.type === 'range'"
2021-12-16 18:13:47 +08:00
: prop = "'param.valueMapping.' + index + '.from'"
2021-12-09 10:34:11 +08:00
: rules = "{ required: true, message: $t('validate.required'), trigger: 'blur'}"
2021-12-03 10:08:34 +08:00
class = "thresholds-from-item"
>
2021-12-09 10:34:11 +08:00
< el-input-number
2021-12-03 10:08:34 +08:00
: controls = "false"
size = "small"
2021-12-03 16:58:25 +08:00
v - model . number = "item.from"
2021-12-03 10:08:34 +08:00
placeholder = "from"
2022-03-15 11:14:42 +08:00
@ change = "change('valueMapping', index)"
2021-12-09 10:34:11 +08:00
> < / el-input-number >
2021-12-03 10:08:34 +08:00
< / el-form-item >
< el-form-item
v - if = "item.type === 'range'"
2021-12-16 18:13:47 +08:00
: prop = "'param.valueMapping.' + index + '.to'"
2021-12-09 10:34:11 +08:00
: rules = "{ required: true, message: $t('validate.required'), trigger: 'blur'}"
2021-12-03 10:08:34 +08:00
class = "thresholds-from-item"
>
2021-12-09 10:34:11 +08:00
< el-input-number
2021-12-03 10:08:34 +08:00
: controls = "false"
size = "small"
2021-12-03 16:58:25 +08:00
v - model . number = "item.to"
2022-03-15 11:14:42 +08:00
@ change = "change('valueMapping', index)"
2021-12-16 10:10:27 +08:00
placeholder = "to"
2021-12-09 10:34:11 +08:00
> < / el-input-number >
2021-12-03 10:08:34 +08:00
< / el-form-item >
< el-form-item
v - if = "item.type === 'regx'"
2021-12-16 18:13:47 +08:00
: prop = "'param.valueMapping.' + index + '.regx'"
2021-12-09 10:34:11 +08:00
: rules = "{ required: true, message: $t('validate.required'), trigger: 'blur'}"
2021-12-03 10:08:34 +08:00
class = "thresholds-from-item"
>
< el-input
size = "small"
v - model = "item.regx"
placeholder = "regx"
2022-03-15 11:14:42 +08:00
@ change = "change('valueMapping', index)"
2021-12-03 10:08:34 +08:00
> < / el-input >
< / el-form-item >
< / el-row >
< el-row v-show = "item.show" :key="2" class="thresholds-item" >
2021-12-16 10:10:27 +08:00
< div v-if = "isTable(chartConfig.type)" >
2022-03-24 15:59:05 +08:00
< div class = 'mapping-display' > { { $t ( 'dashboard.panel.chartForm.columns' ) } } < / div >
2021-12-16 10:10:27 +08:00
< / div >
2021-12-16 18:13:47 +08:00
< el-form-item v-if = "isTable(chartConfig.type)" :prop="'param.valueMapping.' + index + '.column'" :rules="{ required: true, message: $t('validate.required'), trigger: 'blur'}" class="thresholds-from-item" >
2022-03-15 11:14:42 +08:00
< el-input v-model = "item.column" style="margin-right: 10px" :placeholder="$t('placeholder.chart.column')" size="small" @change="change('valueMapping', index)" />
2021-12-16 10:10:27 +08:00
< / el-form-item >
2021-12-03 10:08:34 +08:00
< div >
2022-03-24 15:59:05 +08:00
< div class = 'mapping-display' > { { $t ( 'dashboard.panel.chartForm.display' ) } } < / div >
2021-12-03 10:08:34 +08:00
< / div >
2022-05-13 14:33:41 +08:00
< el-popover
placement = "top-start"
trigger = "manual"
popper - class = "mapping-iconPop no-style-class"
v - clickoutside = "()=>{closeChoose(index)}"
v - model = "isChoose[index]"
2022-05-09 15:57:03 +08:00
>
2022-05-13 14:33:41 +08:00
< ul class = "mapping-iconList" >
< li class = "mapping-iconItem" :class = "{active:item.icon===subItem.value}" v-for = "subItem in mappingIconList" @click="iconActive(item,subItem,index)" :key="subItem.value" >
< i :class = "subItem.value" > < / i >
< / li >
< / ul >
< div class = "mapping-iconSelect" slot = "reference" @click ="chooseIcon(isChoose[index],index)" >
< i v-if = "item.icon" class="mapping-icon" :class="item.icon" :style="{ color: item.color.icon }" > < / i >
< span v-else > {{ $ t ( ' el.select.placeholder ' ) }} < / span >
< i class = "el-icon-arrow-down" :class = "{'is-active':isChoose[index]}" > < / i >
< / div >
< / el-popover >
2021-12-16 18:13:47 +08:00
< el-form-item : prop = "'param.valueMapping.' + index + '.display'" : rules = "{ required: true, message: $t('validate.required'), trigger: 'blur'}" class = "thresholds-from-item" >
2022-03-15 11:14:42 +08:00
< el-input v-model = "item.display" style="margin-right: 10px" :placeholder="$t('placeholder.chart.display')" size="small" @change="change('valueMapping', index)" />
2021-12-03 10:08:34 +08:00
< / el-form-item >
2022-05-09 15:57:03 +08:00
< nezhaColor
: color - val = "item.color"
: single = "false"
: value - arr = "[{name:'icon',value:item.color.icon,key:'icon'},{name:'bac',value:item.color.bac,key:'bac'},{name:'text',value:item.color.text,key:'text'}]"
@ colorChange = "(val,key)=>{colorChange(val, key, index)}"
/ >
2021-12-03 10:08:34 +08:00
< / el-row >
< / transition-group >
< / div >
< div @click ="addMapping" class = "thresholds-add" >
2022-03-24 15:59:05 +08:00
{ { $t ( 'overall.addMapping' ) } }
2021-12-03 10:08:34 +08:00
< / div >
< / el-row >
< / transition >
< / div >
2021-12-02 18:33:28 +08:00
< / el-form >
< / div >
2021-11-30 16:39:21 +08:00
< / template >
< script >
2021-12-02 15:36:01 +08:00
import publicConfig from '@/components/common/rightBox/chart/publicConfig'
import chartTypeShow from '@/components/common/rightBox/chart/chartTypeShow'
2021-12-03 10:08:34 +08:00
import nezhaColor from '@/components/common/nezhaColor'
2022-02-23 09:12:50 +08:00
import filterSearch from '@/components/common/filterSearch/filterSearch.vue'
2021-12-16 10:10:27 +08:00
import VueTagsInput from '@johmun/vue-tags-input'
2021-12-24 15:32:16 +08:00
import { isGauge } from '@/components/chart/chart/tools'
2021-11-30 16:39:21 +08:00
export default {
2021-12-02 15:36:01 +08:00
name : 'systemChartConfig' ,
mixins : [ publicConfig , chartTypeShow ] ,
2021-12-03 10:08:34 +08:00
components : {
2021-12-16 10:10:27 +08:00
nezhaColor ,
2022-02-21 10:40:12 +08:00
filterSearch ,
2021-12-16 10:10:27 +08:00
VueTagsInput
2021-12-03 10:08:34 +08:00
} ,
2021-12-02 15:36:01 +08:00
data ( ) {
return {
2021-12-02 18:52:32 +08:00
systemData : [ ] ,
loading : false ,
2021-12-02 18:33:28 +08:00
rules : { } ,
2021-12-17 11:18:49 +08:00
systemNameShow : [ {
error : false ,
hideInput : true ,
show : true ,
oldName : ''
} ] ,
2021-12-03 10:08:34 +08:00
groupList : [ ] ,
selectList : [ ] ,
2021-12-07 14:19:16 +08:00
oldType : '' ,
2021-12-15 17:55:56 +08:00
tag : '' ,
2021-12-02 15:36:01 +08:00
chartTypeList : [
{
2021-12-06 11:40:06 +08:00
id : 'stat' ,
2021-12-02 18:33:28 +08:00
name : this . $t ( 'dashboard.panel.chartForm.typeVal.singleStat.label' )
2021-12-02 15:36:01 +08:00
} ,
2021-12-28 18:09:44 +08:00
{
id : 'hexagon' ,
name : this . $t ( 'dashboard.panel.chartForm.typeVal.hexagonFigure.label' )
} ,
2021-12-02 15:36:01 +08:00
{
2021-12-02 18:33:28 +08:00
id : 'bar' ,
name : this . $t ( 'dashboard.panel.chartForm.typeVal.bar.label' )
2021-12-02 15:36:01 +08:00
} ,
{
2021-12-02 18:33:28 +08:00
id : 'pie' ,
name : this . $t ( 'dashboard.panel.chartForm.typeVal.pie.label' )
2021-12-03 10:08:34 +08:00
} ,
{
2022-03-07 18:06:41 +08:00
id : 'gauge' ,
name : this . $t ( 'dashboard.panel.chartForm.typeVal.gauge.label' )
2021-12-03 10:08:34 +08:00
} ,
{
id : 'treemap' ,
name : this . $t ( 'dashboard.panel.chartForm.typeVal.treemap.label' )
} ,
{
id : 'table' ,
name : this . $t ( 'dashboard.panel.chartForm.typeVal.table.label' )
2021-12-02 18:52:32 +08:00
}
2022-02-21 10:40:12 +08:00
] ,
keyList : [ ] ,
compareList : [ ]
2021-12-02 15:36:01 +08:00
}
} ,
2021-12-03 17:59:27 +08:00
watch : {
selectList ( n ) {
2021-12-23 16:27:05 +08:00
if ( ! this . chartConfig . param . datasource [ 0 ] . systemSelect ) {
2021-12-16 18:13:47 +08:00
this . chartConfig . param . datasource [ 0 ] . systemSelect = this . selectList [ 0 ] . name
this . systemSelectChange ( 0 )
2021-12-03 17:59:27 +08:00
}
}
} ,
2021-12-02 15:36:01 +08:00
methods : {
2021-12-24 15:32:16 +08:00
isGauge ,
2021-12-02 15:36:01 +08:00
init ( ) {
this . chartConfig = JSON . parse ( JSON . stringify ( this . params ) )
2022-02-21 17:16:33 +08:00
if ( ! this . chartConfig . param . datasource [ 0 ] . filter ) {
this . chartConfig . param . datasource [ 0 ] . filter = [ ]
}
2021-12-07 14:19:16 +08:00
this . oldType = this . chartConfig . type
2021-12-02 15:36:01 +08:00
} ,
2021-12-02 18:52:32 +08:00
getSystemData ( ) {
this . loading = true
2021-12-06 15:25:09 +08:00
this . $get ( '/sys/config/key/stat_query_json' ) . then ( res => {
2021-12-02 18:52:32 +08:00
this . loading = false
if ( res . code === 200 ) {
2021-12-06 15:25:09 +08:00
this . systemData = JSON . parse ( res . data . paramValue )
if ( this . systemData . length ) {
2021-12-23 16:27:05 +08:00
if ( ! this . chartConfig . param . datasource [ 0 ] . type ) {
2021-12-16 18:13:47 +08:00
this . chartConfig . param . datasource [ 0 ] . type = this . systemData [ 0 ] . name
2021-12-06 15:25:09 +08:00
this . groupList = this . systemData [ 0 ] . group
this . selectList = this . systemData [ 0 ] . select
2022-02-21 17:16:33 +08:00
this . keyList = this . systemData [ 0 ] . filter
2021-12-29 14:29:37 +08:00
} else {
2021-12-16 18:13:47 +08:00
const system = this . systemData . find ( item => item . name === this . chartConfig . param . datasource [ 0 ] . type )
2021-12-06 15:25:09 +08:00
this . chartConfig . param . system = system . name
this . groupList = system . group
this . selectList = system . select
2022-02-21 17:16:33 +08:00
this . keyList = system . filter
2021-12-06 15:25:09 +08:00
}
2021-12-08 16:20:03 +08:00
this . $refs . chartForm && this . $refs . chartForm . clearValidate ( )
2021-12-02 18:52:32 +08:00
}
} else {
this . $message . error ( res . msg )
}
} )
} ,
2021-12-02 15:36:01 +08:00
chartTypeChange ( type ) {
switch ( type ) {
2021-12-06 11:40:06 +08:00
case 'stat' :
2021-12-28 18:09:44 +08:00
case 'hexagon' :
2022-03-07 18:06:41 +08:00
case 'gauge' :
if ( this . oldType === 'stat' || this . oldType === 'gauge' || this . oldType === 'hexagon' ) {
2021-12-07 14:19:16 +08:00
break
}
2021-12-15 17:55:56 +08:00
this . chartConfig . param = {
2021-12-28 10:53:34 +08:00
nullType : this . chartConfig . param . nullType ,
2021-12-24 16:06:17 +08:00
link : this . chartConfig . param . link ,
2021-12-15 17:55:56 +08:00
statistics : 'last' ,
2021-12-28 10:53:34 +08:00
text : 'value' ,
2021-12-16 18:13:47 +08:00
valueMapping : [ ] ,
2021-12-28 10:53:34 +08:00
min : 0 ,
max : 100 ,
enable : {
legend : true ,
valueMapping : false ,
thresholds : false
2021-12-28 18:09:44 +08:00
} ,
datasource : [ ... this . chartConfig . param . datasource ]
2021-12-28 10:53:34 +08:00
}
break
case 'bar' :
case 'treemap' :
case 'pie' :
if ( this . oldType === 'bar' || this . oldType === 'treemap' || this . oldType === 'pie' ) {
break
}
this . chartConfig . param = {
nullType : this . chartConfig . param . nullType ,
link : this . chartConfig . param . link ,
statistics : 'last' ,
2021-12-22 15:11:23 +08:00
text : 'value' ,
2021-12-28 10:53:34 +08:00
valueMapping : [ ] ,
legend : { placement : 'bottom' , values : [ ] , show : true } ,
2021-12-24 15:32:16 +08:00
min : 0 ,
max : 100 ,
2021-12-16 18:13:47 +08:00
enable : {
legend : true ,
2021-12-17 11:18:49 +08:00
valueMapping : false ,
thresholds : false
2021-12-28 18:09:44 +08:00
} ,
datasource : [ ... this . chartConfig . param . datasource ]
2021-12-02 15:36:01 +08:00
}
break
2021-12-03 10:08:34 +08:00
case 'table' :
2021-12-15 17:55:56 +08:00
this . chartConfig . param = {
2021-12-24 16:06:17 +08:00
link : this . chartConfig . param . link ,
2021-12-15 17:55:56 +08:00
refer : 1 ,
system : '' ,
indexs : '' ,
2021-12-16 10:10:27 +08:00
tags : [ ] ,
2021-12-15 17:55:56 +08:00
nullType : 'null' ,
statistics : 'last' ,
2021-12-16 10:10:27 +08:00
columns : [ ] ,
2021-12-16 18:13:47 +08:00
valueMapping : [ ] ,
enable : {
legend : true ,
2021-12-17 11:18:49 +08:00
valueMapping : false ,
thresholds : false
2021-12-16 18:13:47 +08:00
} ,
2021-12-28 18:09:44 +08:00
datasource : [ ... this . chartConfig . param . datasource ]
2021-12-15 17:55:56 +08:00
}
2021-12-02 15:36:01 +08:00
break
}
2021-12-07 14:19:16 +08:00
this . oldType = type
2021-12-02 15:36:01 +08:00
this . change ( )
} ,
2021-12-02 18:52:32 +08:00
changeSystem ( item ) {
2021-12-16 18:13:47 +08:00
this . chartConfig . param . datasource [ 0 ] . type = item . name
this . chartConfig . param . datasource [ 0 ] . systemGroup = ''
this . chartConfig . param . datasource [ 0 ] . systemSelect = ''
this . chartConfig . param . datasource [ 0 ] . group = ''
this . chartConfig . param . datasource [ 0 ] . select = ''
2022-02-21 17:16:33 +08:00
this . chartConfig . param . datasource [ 0 ] . filter = [ ]
2022-02-22 18:27:28 +08:00
this . $refs . filterSearch [ 0 ] . metaList = [ ]
2021-12-03 10:08:34 +08:00
this . groupList = item . group
2021-12-03 17:59:27 +08:00
this . selectList = JSON . parse ( JSON . stringify ( item . select ) )
2022-02-21 17:16:33 +08:00
this . keyList = JSON . parse ( JSON . stringify ( item . filter ) )
2021-12-16 10:10:27 +08:00
} ,
2021-12-16 18:13:47 +08:00
systemGroupChange ( index ) {
this . chartConfig . param . datasource [ index ] . group = this . chartConfig . param . datasource [ index ] . systemGroup . map ( item => {
2021-12-16 10:10:27 +08:00
const obj = this . groupList . find ( group => group . name === item )
return obj
} )
this . change ( )
} ,
2021-12-16 18:13:47 +08:00
systemSelectChange ( index ) {
this . chartConfig . param . datasource [ index ] . select = this . selectList . find ( item => item . name === this . chartConfig . param . datasource [ index ] . systemSelect )
2021-12-16 10:10:27 +08:00
this . change ( )
2021-12-17 11:18:49 +08:00
} ,
showSystemNameShow ( index ) {
this . systemNameShow [ index ] . show = ! this . systemNameShow [ index ] . show
this . $set ( this . systemNameShow , index , this . systemNameShow [ index ] )
} ,
systemNameInput ( val , index ) {
const findIndex = this . systemNameShow . indexOf ( val )
const lastIndex = this . systemNameShow . lastIndexOf ( val )
if ( findIndex !== - 1 && lastIndex != - 1 && lastIndex !== findIndex ) {
this . systemNameShow [ index ] . error = this . $t ( 'error.nameDuplicate' )
} else if ( ! val ) {
this . systemNameShow [ index ] . error = this . $t ( 'validate.required' )
} else {
this . systemNameShow [ index ] . error = ''
}
} ,
systemNameChange ( index ) {
if ( this . systemNameShow [ index ] . error ) {
2022-03-11 11:05:30 +08:00
this . chartConfig . param . datasource [ index ] . name = this . systemNameShow [ index ] . oldName
2021-12-17 11:18:49 +08:00
this . systemNameShow [ index ] . error = ''
2022-03-11 11:05:30 +08:00
} else if ( ! this . chartConfig . param . datasource [ index ] . name ) {
this . chartConfig . param . datasource [ index ] . name = this . systemNameShow [ index ] . oldName
2021-12-17 11:18:49 +08:00
} else {
2022-03-11 11:05:30 +08:00
this . systemNameShow [ index ] . oldName = this . chartConfig . param . datasource [ index ] . name
2021-12-17 11:18:49 +08:00
}
this . change ( )
} ,
showsystemInput ( index , flag ) {
this . systemNameShow [ index ] . hideInput = flag
2021-12-02 18:52:32 +08:00
}
2021-12-02 18:33:28 +08:00
} ,
created ( ) {
this . init ( )
2021-12-02 18:52:32 +08:00
} ,
mounted ( ) {
2021-12-17 11:18:49 +08:00
this . systemNameShow = [ {
error : false ,
hideInput : true ,
show : true ,
oldName : this . chartConfig . param . datasource [ 0 ] . name
} ]
2021-12-02 18:52:32 +08:00
this . getSystemData ( )
2021-12-02 15:36:01 +08:00
}
2021-11-30 16:39:21 +08:00
}
< / script >
< style scoped >
< / style >