Skip to content

Commit 2df03b5

Browse files
zhaoyiming111zzlliang
authored andcommitted
feat: api工具--编辑工具结果表格字段动态添加新增按钮 --story=132030106
1 parent 4bb87dd commit 2df03b5

File tree

1 file changed

+59
-8
lines changed
  • src/frontend/src/views/tools/tools-square/add/components/api/result

1 file changed

+59
-8
lines changed

src/frontend/src/views/tools/tools-square/add/components/api/result/list-table.vue

Lines changed: 59 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
</div>
8888
<div
8989
class="field-value"
90-
style="flex: 0 0 50px;" />
90+
:style="`flex: 0 0 ${addList.length > 0 ? 80 : 50}px;`" />
9191
</div>
9292
</div>
9393
<vuedraggable
@@ -247,12 +247,39 @@
247247
</bk-form-item>
248248
</div>
249249
<div
250-
class="field-value"
251-
style="flex: 0 0 50px;border-right: none !important;">
252-
<audit-icon
253-
class="reduce-fill field-icon"
254-
type="reduce-fill"
255-
@click="handleDelect(element.json_path)" />
250+
class="field-value operation-cell"
251+
:style="`flex: 0 0 ${addList.length > 0 ? 80 : 50}px;border-right: none !important;`">
252+
<bk-form-item
253+
error-display-type="tooltips"
254+
label=""
255+
label-width="0">
256+
<bk-popover
257+
v-if="addList.length > 0"
258+
:ref="(el: any) => addPopoverRefs[index] = el"
259+
ext-cls="field-required-pop"
260+
placement="bottom"
261+
theme="light"
262+
trigger="click">
263+
<audit-icon
264+
class="add-fill field-icon"
265+
type="add-fill" />
266+
<template #content>
267+
<div class="field-required-pop-hideen">
268+
<div
269+
v-for="(addItem, addIndex) in addList"
270+
:key="addIndex"
271+
class="field-required-item"
272+
@click="handleInsertAfter(index, addItem)">
273+
{{ addItem.name }}
274+
</div>
275+
</div>
276+
</template>
277+
</bk-popover>
278+
<audit-icon
279+
class="reduce-fill field-icon"
280+
type="reduce-fill"
281+
@click="handleDelect(element.json_path)" />
282+
</bk-form-item>
256283
</div>
257284
</div>
258285
</div>
@@ -372,6 +399,7 @@
372399
});
373400
const list = ref<any[]>([]);
374401
const addList = ref<any[]>([]);
402+
const addPopoverRefs = ref<Record<number, any>>({});
375403
const showFieldDict = ref(false);
376404
const showFieldReference = ref(false);
377405
@@ -561,6 +589,18 @@
561589
addList.value = addList.value.filter((addItem: any) => addItem.json_path !== item.json_path);
562590
};
563591
592+
// 在指定行下方插入字段
593+
const handleInsertAfter = (index: number, item: any) => {
594+
// 关闭 popover
595+
if (addPopoverRefs.value[index]) {
596+
addPopoverRefs.value[index].hide();
597+
}
598+
// 从 addList 中移除已插入的项目
599+
addList.value = addList.value.filter((addItem: any) => addItem.json_path !== item.json_path);
600+
// 在当前行下方插入
601+
list.value.splice(index + 1, 0, item);
602+
};
603+
564604
// 在树形结构中查找节点的函数
565605
const findNode = (treeData: any[], targetJsonPath: string): any => {
566606
if (!treeData || !Array.isArray(treeData)) return null;
@@ -920,16 +960,27 @@
920960
}
921961
922962
.field-icon {
923-
margin-left: 20px;
963+
margin-left: 16px;
964+
font-size: 14px;
924965
color: #c4c6cc;
925966
cursor: pointer;
967+
}
926968
969+
.add-fill {
970+
&:hover {
971+
/* 新增 icon hover 加深一个色号 */
972+
color: #979ba5;
973+
}
974+
}
975+
976+
.reduce-fill {
927977
&:hover {
928978
/* 删除 icon hover 变红色 */
929979
color: #ea3636;
930980
}
931981
}
932982
983+
933984
.add-field {
934985
margin-top: 10px;
935986
}

0 commit comments

Comments
 (0)