fix widget index

This commit is contained in:
Qiuxia Fan 2022-03-27 22:42:09 +08:00
parent d733594804
commit 713c1d1459
2 changed files with 4 additions and 5 deletions

View File

@ -76,9 +76,10 @@ export const dashboardStore = defineStore({
this.currentDashboard = item; this.currentDashboard = item;
}, },
addControl(type: string) { addControl(type: string) {
const arr = this.layout.map((d: any) => Number(d.i));
const newItem: LayoutConfig = { const newItem: LayoutConfig = {
...NewControl, ...NewControl,
i: String(this.layout.length), i: String(Math.max(...arr) + 1),
type, type,
metricTypes: [""], metricTypes: [""],
metrics: [""], metrics: [""],
@ -146,9 +147,10 @@ export const dashboardStore = defineStore({
} }
const tabIndex = this.layout[idx].activedTabIndex || 0; const tabIndex = this.layout[idx].activedTabIndex || 0;
const { children } = this.layout[idx].children[tabIndex]; const { children } = this.layout[idx].children[tabIndex];
const arr = children.map((d: any) => Number(d.i));
const newItem: LayoutConfig = { const newItem: LayoutConfig = {
...NewControl, ...NewControl,
i: String(children.length), i: String(Math.max(...arr) + 1),
type, type,
metricTypes: [""], metricTypes: [""],
metrics: [""], metrics: [""],

View File

@ -19,9 +19,6 @@ limitations under the License. -->
<span> <span>
{{ data.widget?.title || "" }} {{ data.widget?.title || "" }}
</span> </span>
<span class="unit" v-show="data.standard?.unit">
({{ data.standard?.unit }})
</span>
</div> </div>
<div> <div>
<el-tooltip :content="data.widget?.tips"> <el-tooltip :content="data.widget?.tips">