|
87 | 87 | </div> |
88 | 88 | <div |
89 | 89 | class="field-value" |
90 | | - style="flex: 0 0 50px;" /> |
| 90 | + :style="`flex: 0 0 ${addList.length > 0 ? 80 : 50}px;`" /> |
91 | 91 | </div> |
92 | 92 | </div> |
93 | 93 | <vuedraggable |
|
247 | 247 | </bk-form-item> |
248 | 248 | </div> |
249 | 249 | <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> |
256 | 283 | </div> |
257 | 284 | </div> |
258 | 285 | </div> |
|
372 | 399 | }); |
373 | 400 | const list = ref<any[]>([]); |
374 | 401 | const addList = ref<any[]>([]); |
| 402 | + const addPopoverRefs = ref<Record<number, any>>({}); |
375 | 403 | const showFieldDict = ref(false); |
376 | 404 | const showFieldReference = ref(false); |
377 | 405 |
|
|
561 | 589 | addList.value = addList.value.filter((addItem: any) => addItem.json_path !== item.json_path); |
562 | 590 | }; |
563 | 591 |
|
| 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 | +
|
564 | 604 | // 在树形结构中查找节点的函数 |
565 | 605 | const findNode = (treeData: any[], targetJsonPath: string): any => { |
566 | 606 | if (!treeData || !Array.isArray(treeData)) return null; |
|
920 | 960 | } |
921 | 961 |
|
922 | 962 | .field-icon { |
923 | | - margin-left: 20px; |
| 963 | + margin-left: 16px; |
| 964 | + font-size: 14px; |
924 | 965 | color: #c4c6cc; |
925 | 966 | cursor: pointer; |
| 967 | +} |
926 | 968 |
|
| 969 | +.add-fill { |
| 970 | + &:hover { |
| 971 | + /* 新增 icon hover 加深一个色号 */ |
| 972 | + color: #979ba5; |
| 973 | + } |
| 974 | +} |
| 975 | +
|
| 976 | +.reduce-fill { |
927 | 977 | &:hover { |
928 | 978 | /* 删除 icon hover 变红色 */ |
929 | 979 | color: #ea3636; |
930 | 980 | } |
931 | 981 | } |
932 | 982 |
|
| 983 | +
|
933 | 984 | .add-field { |
934 | 985 | margin-top: 10px; |
935 | 986 | } |
|
0 commit comments