Initial commit (code only without large binaries)
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
Vue.component("node-schedule-conds-viewer", {
|
||||
props: ["value", "v-params", "v-operators"],
|
||||
mounted: function () {
|
||||
this.formatConds(this.condsConfig.conds)
|
||||
this.$forceUpdate()
|
||||
},
|
||||
data: function () {
|
||||
let paramMap = {}
|
||||
this.vParams.forEach(function (param) {
|
||||
paramMap[param.code] = param
|
||||
})
|
||||
|
||||
let operatorMap = {}
|
||||
this.vOperators.forEach(function (operator) {
|
||||
operatorMap[operator.code] = operator.name
|
||||
})
|
||||
|
||||
return {
|
||||
condsConfig: this.value,
|
||||
paramMap: paramMap,
|
||||
operatorMap: operatorMap
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
formatConds: function (conds) {
|
||||
let that = this
|
||||
conds.forEach(function (cond) {
|
||||
switch (that.paramMap[cond.param].valueType) {
|
||||
case "bandwidth":
|
||||
cond.valueFormat = cond.value.count + cond.value.unit[0].toUpperCase() + cond.value.unit.substring(1) + "ps"
|
||||
return
|
||||
case "traffic":
|
||||
cond.valueFormat = cond.value.count + cond.value.unit.toUpperCase()
|
||||
return
|
||||
case "cpu":
|
||||
cond.valueFormat = cond.value + "%"
|
||||
return
|
||||
case "memory":
|
||||
cond.valueFormat = cond.value + "%"
|
||||
return
|
||||
case "load":
|
||||
cond.valueFormat = cond.value
|
||||
return
|
||||
case "rate":
|
||||
cond.valueFormat = cond.value + "/秒"
|
||||
return
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
template: `<div>
|
||||
<span v-for="(cond, index) in condsConfig.conds">
|
||||
<span class="ui label basic small">
|
||||
<span>{{paramMap[cond.param].name}}
|
||||
<span v-if="paramMap[cond.param].operators != null && paramMap[cond.param].operators.length > 0"><span class="grey">{{operatorMap[cond.operator]}}</span> {{cond.valueFormat}}</span>
|
||||
</span>
|
||||
</span>
|
||||
<span v-if="index < condsConfig.conds.length - 1"> <span v-if="condsConfig.connector == 'and'">且</span><span v-else>或</span> </span>
|
||||
</span>
|
||||
</div>`
|
||||
})
|
||||
Reference in New Issue
Block a user