@@ -170,6 +177,7 @@
type_ids: form.type_ids,
attr_ids: form.attr_ids,
isShadow: isShadow,
+ ret: form.tableCategory === 2 ? 'cis' : '',
}"
:editable="false"
:ci_types="ci_types"
@@ -464,10 +472,12 @@ export default {
changeCIType(value) {
this.form.attr_ids = []
this.commonAttributes = []
- getCITypeAttributesByTypeIds({ type_ids: Array.isArray(value) ? value.join(',') : value }).then((res) => {
- this.attributes = res.attributes
- })
- if (!Array.isArray(value)) {
+ if ((Array.isArray(value) && value.length) || (!Array.isArray(value) && value)) {
+ getCITypeAttributesByTypeIds({ type_ids: Array.isArray(value) ? value.join(',') : value }).then((res) => {
+ this.attributes = res.attributes
+ })
+ }
+ if (!Array.isArray(value) && value) {
getRecursive_level2children(value).then((res) => {
this.level2children = res
})
@@ -523,6 +533,7 @@ export default {
delete params.attr_ids
delete params.tableCategory
await putCustomDashboard(this.item.id, params)
+ this.$emit('refresh', this.item.id)
} else {
const { xLast, yLast, wLast } = getLastLayout(this.layout())
const w = this.width
@@ -581,6 +592,9 @@ export default {
// }
// },
changeChartType(t) {
+ if (!(['bar', 'line', 'pie'].includes(this.chartType) && ['bar', 'line', 'pie'].includes(t.value))) {
+ this.resetForm()
+ }
this.chartType = t.value
this.isShowPreview = false
if (t.value === 'count') {
@@ -588,7 +602,6 @@ export default {
} else {
this.form.category = 1
}
- this.resetForm()
},
showPreview() {
this.$refs.chartForm.validate(async (valid) => {
@@ -673,6 +686,9 @@ export default {
}
this.form.level = level
},
+ filterOption(input, option) {
+ return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
+ },
},
}
@@ -702,6 +718,13 @@ export default {
border-radius: 8px;
}
}
+ .chart-left-preview-empty {
+ background: url('../../assets/dashboard_empty.png');
+ background-size: contain;
+ background-repeat: no-repeat;
+ background-position-x: center;
+ background-position-y: center;
+ }
}
.chart-right {
width: 50%;
diff --git a/cmdb-ui/src/modules/cmdb/views/custom_dashboard/chartOptions.js b/cmdb-ui/src/modules/cmdb/views/custom_dashboard/chartOptions.js
index bf5941b..a4a5a8c 100644
--- a/cmdb-ui/src/modules/cmdb/views/custom_dashboard/chartOptions.js
+++ b/cmdb-ui/src/modules/cmdb/views/custom_dashboard/chartOptions.js
@@ -23,6 +23,7 @@ export const category_1_bar_options = (data, options) => {
})
})
return {
+
color: options.chartColor.split(','),
grid: {
top: 15,
@@ -58,6 +59,7 @@ export const category_1_bar_options = (data, options) => {
data: xData
},
tooltip: {
+ appendToBody: true,
trigger: 'axis',
axisPointer: {
type: 'shadow'
@@ -65,7 +67,7 @@ export const category_1_bar_options = (data, options) => {
},
series: Object.keys(secondCategory).map(key => {
return {
- name: key,
+ name: options.attr_ids.length === 1 ? '' : key,
type: 'bar',
stack: options?.barStack ?? 'total',
barGap: 0,
@@ -90,6 +92,7 @@ export const category_1_line_options = (data, options) => {
containLabel: true,
},
tooltip: {
+ appendToBody: true,
trigger: 'axis'
},
xAxis: {
@@ -137,6 +140,7 @@ export const category_1_pie_options = (data, options) => {
containLabel: true,
},
tooltip: {
+ appendToBody: true,
trigger: 'item'
},
legend: {
@@ -186,6 +190,7 @@ export const category_2_bar_options = (data, options, chartType) => {
containLabel: true,
},
tooltip: {
+ appendToBody: true,
trigger: 'axis',
axisPointer: {
type: 'shadow'
@@ -257,7 +262,6 @@ export const category_2_bar_options = (data, options, chartType) => {
}
export const category_2_pie_options = (data, options) => {
- console.log(1111, options)
const _legend = []
Object.keys(data.detail).forEach(key => {
Object.keys(data.detail[key]).forEach(key2 => {
@@ -274,6 +278,7 @@ export const category_2_pie_options = (data, options) => {
containLabel: true,
},
tooltip: {
+ appendToBody: true,
trigger: 'item'
},
legend: {
diff --git a/cmdb-ui/src/modules/cmdb/views/custom_dashboard/customLayout.vue b/cmdb-ui/src/modules/cmdb/views/custom_dashboard/customLayout.vue
index 0744dd9..6a86dfd 100644
--- a/cmdb-ui/src/modules/cmdb/views/custom_dashboard/customLayout.vue
+++ b/cmdb-ui/src/modules/cmdb/views/custom_dashboard/customLayout.vue
@@ -11,13 +11,12 @@
{
+ this.$refs[`chart_${id}`][0].resizeChart()
+ }, 100)
+ } else {
+ this.getLayout()
+ }
},
deleteChart(item) {
const that = this
@@ -299,4 +304,7 @@ export default {
margin-right: 5px;
}
}
+.ops-button-primary:hover {
+ background-color: #2f54eb !important;
+}