Skip to content

Commit 39f54c8

Browse files
authored
fix: 主机新增关联失败 (#8412)
* fix: 主机新增关联失败 --story=123539990 * fix: 主机详情-修改所属拓扑后退出显示错误 --story=123600681 * fix: 实例列表拖拽排序表头,无法立即生效 --story=123576390 * fix: 实例名里面带逗号实例无法搜索 --story=123600999 * 代码优化 * fix: 业务节点信息切换后显示信息不正确 --bug=142670835 * 代码优化
1 parent c7a73f4 commit 39f54c8

File tree

15 files changed

+90
-116
lines changed

15 files changed

+90
-116
lines changed

src/ui/src/components/search/array.vue

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
v-model="localValue"
2020
v-bind="$attrs"
2121
:list="[]"
22+
:paste-fn="handlePasteFn"
2223
@removeAll="() => $emit('clear')"
2324
@click.native="handleToggle(true)"
2425
@blur="handleToggle(false, ...arguments)"
@@ -47,6 +48,10 @@
4748
fuzzy: {
4849
type: Boolean,
4950
default: undefined
51+
},
52+
isPasteSplit: {
53+
type: Boolean,
54+
default: false
5055
}
5156
},
5257
computed: {
@@ -66,36 +71,15 @@
6671
}
6772
}
6873
},
69-
watch: {
70-
multiple: {
71-
immediate: true,
72-
handler(multiple) {
73-
multiple ? this.addPasteEvent() : this.removePasteEvent()
74-
}
75-
}
76-
},
77-
beforeDestroy() {
78-
this.removePasteEvent()
79-
},
8074
methods: {
81-
async addPasteEvent() {
82-
await this.$nextTick()
83-
const { tagInput } = this.$refs
84-
if (!tagInput) return
85-
tagInput.$refs.input.addEventListener('paste', this.handlePaste)
86-
},
87-
async removePasteEvent() {
88-
await this.$nextTick()
89-
const { tagInput } = this.$refs
90-
if (!tagInput) return
91-
tagInput.$refs.input.removeEventListener('paste', this.handlePaste)
92-
},
93-
handlePaste(event) {
94-
const text = event.clipboardData.getData('text')
95-
const values = text.split(/,|;|\n/).map(value => value.trim())
96-
.filter(value => value.length)
97-
const value = [...new Set([...this.localValue, ...values])]
98-
this.localValue = value
75+
handlePasteFn(value) {
76+
if (!value) return
77+
let val = [value]
78+
if (this.isPasteSplit && this.multiple) {
79+
val = (value.split(/,|;|\n/)).map(value => value.trim())
80+
.filter(value => value.length)
81+
}
82+
this.localValue = [...new Set([...this.localValue, ...val])]
9983
},
10084
handleInputChange(value) {
10185
this.$emit('inputchange', value)

src/ui/src/components/search/longchar.vue

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
v-bind="$attrs"
2121
:list="[]"
2222
:has-delete-icon="true"
23+
:paste-fn="handlePasteFn"
2324
@removeAll="() => $emit('clear')"
2425
@click.native="handleToggle(true)"
2526
@blur="handleToggle(false, ...arguments)"
@@ -44,6 +45,10 @@
4445
value: {
4546
type: [String, Array],
4647
default: ''
48+
},
49+
isPasteSplit: {
50+
type: Boolean,
51+
default: false
4752
}
4853
},
4954
computed: {
@@ -60,36 +65,15 @@
6065
}
6166
}
6267
},
63-
watch: {
64-
multiple: {
65-
immediate: true,
66-
handler(multiple) {
67-
multiple ? this.addPasteEvent() : this.removePasteEvent()
68-
}
69-
}
70-
},
71-
beforeDestroy() {
72-
this.removePasteEvent()
73-
},
7468
methods: {
75-
async addPasteEvent() {
76-
await this.$nextTick()
77-
const { tagInput } = this.$refs
78-
if (!tagInput) return
79-
tagInput.$refs.input?.addEventListener('paste', this.handlePaste)
80-
},
81-
async removePasteEvent() {
82-
await this.$nextTick()
83-
const { tagInput } = this.$refs
84-
if (!tagInput) return
85-
tagInput.$refs.input?.removeEventListener('paste', this.handlePaste)
86-
},
87-
handlePaste(event) {
88-
const text = event.clipboardData.getData('text')
89-
const values = text.split(/,|;|\n/).map(value => value.trim())
90-
.filter(value => value.length)
91-
const value = [...new Set([...this.localValue, ...values])]
92-
this.localValue = value
69+
handlePasteFn(value) {
70+
if (!value) return
71+
let val = [value]
72+
if (this.isPasteSplit && this.multiple) {
73+
val = (value.split(/,|;|\n/)).map(value => value.trim())
74+
.filter(value => value.length)
75+
}
76+
this.localValue = [...new Set([...this.localValue, ...val])]
9377
},
9478
handleInputChange(value) {
9579
this.$emit('inputchange', value)

src/ui/src/components/search/singlechar.vue

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
v-bind="$attrs"
2121
:list="[]"
2222
:has-delete-icon="true"
23+
:paste-fn="handlePasteFn"
2324
@removeAll="() => $emit('clear')"
2425
@click.native="handleToggle(true)"
2526
@blur="handleToggle(false, ...arguments)"
@@ -51,6 +52,10 @@
5152
fuzzy: {
5253
type: Boolean,
5354
default: undefined
55+
},
56+
isPasteSplit: {
57+
type: Boolean,
58+
default: false
5459
}
5560
},
5661
computed: {
@@ -70,36 +75,15 @@
7075
}
7176
}
7277
},
73-
watch: {
74-
multiple: {
75-
immediate: true,
76-
handler(multiple) {
77-
multiple ? this.addPasteEvent() : this.removePasteEvent()
78-
}
79-
}
80-
},
81-
beforeDestroy() {
82-
this.removePasteEvent()
83-
},
8478
methods: {
85-
async addPasteEvent() {
86-
await this.$nextTick()
87-
const { tagInput } = this.$refs
88-
if (!tagInput) return
89-
tagInput.$refs.input?.addEventListener('paste', this.handlePaste)
90-
},
91-
async removePasteEvent() {
92-
await this.$nextTick()
93-
const { tagInput } = this.$refs
94-
if (!tagInput) return
95-
tagInput.$refs.input?.removeEventListener('paste', this.handlePaste)
96-
},
97-
handlePaste(event) {
98-
const text = event.clipboardData.getData('text')
99-
const values = text.split(/,|;|\n/).map(value => value.trim())
100-
.filter(value => value.length)
101-
const value = [...new Set([...this.localValue, ...values])]
102-
this.localValue = value
79+
handlePasteFn(value) {
80+
if (!value) return
81+
let val = [value]
82+
if (this.isPasteSplit && this.multiple) {
83+
val = (value.split(/,|;|\n/)).map(value => value.trim())
84+
.filter(value => value.length)
85+
}
86+
this.localValue = [...new Set([...this.localValue, ...val])]
10387
},
10488
handleInputChange(value) {
10589
this.$emit('inputchange', value)

src/ui/src/utils/util.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export const swapItem = (arr, fromIndex, toIndex) => {
121121
export const escapeRegexChar = (str) => {
122122
// eslint-disable-next-line no-useless-escape
123123
const escapeCharRE = /([\*\.\?\+\$\^\[\]\(\)\{\}\|\\\/])/g
124-
return String(str).replace(escapeCharRE, '\\$1')
124+
return str.replace(escapeCharRE, '\\$1')
125125
}
126126

127127
/**

src/ui/src/views/business-set/index.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@
159159
</template>
160160

161161
<script>
162-
import { computed, defineComponent, reactive, ref, watch, watchEffect } from 'vue'
162+
import { computed, defineComponent, reactive, ref, watch, watchEffect, nextTick } from 'vue'
163163
import { t } from '@/i18n'
164164
import { OPERATION } from '@/dictionary/iam-auth'
165165
import { $bkInfo, $success, $error } from '@/magicbox/index.js'
@@ -382,7 +382,11 @@
382382
)
383383
384384
const handleUpdateHeader = (header) => {
385-
table.header = header
385+
// 数组length在没有变化时候,需要先清空数组在赋值。否则表头无法实时更新
386+
table.header = []
387+
nextTick(() => {
388+
table.header = header
389+
})
386390
}
387391
388392
const handleSortChange = (sort) => {

src/ui/src/views/business-topology/children/service-node-info.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@
284284
},
285285
async getNodeDetails() {
286286
this.type = 'details'
287+
this.instance = {}
287288
await this.getInstance()
288289
289290
// 获取节点的模板属性配置

src/ui/src/views/business/index.vue

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -498,11 +498,15 @@
498498
})
499499
},
500500
updateTableHeader(properties) {
501-
this.table.header = properties.map(property => ({
502-
id: property.bk_property_id,
503-
name: this.$tools.getHeaderPropertyName(property),
504-
property
505-
}))
501+
// 数组length在没有变化时候,需要先清空数组在赋值。否则表头无法实时更新
502+
this.table.header = []
503+
this.$nextTick(() => {
504+
this.table.header = properties.map(property => ({
505+
id: property.bk_property_id,
506+
name: this.$tools.getHeaderPropertyName(property),
507+
property
508+
}))
509+
})
506510
},
507511
handleValueClick(row, column) {
508512
if (column.id !== 'bk_biz_id') {

src/ui/src/views/dynamic-group/children/search-select.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import { useHttp, jsonp } from '@/api'
1616
import { t } from '@/i18n'
1717
import { useStore } from '@/store'
18-
import { escapeRegexChar } from '@/utils/util'
1918
2019
const props = defineProps({
2120
defaultFilter: {
@@ -90,7 +89,7 @@
9089
const fetchDynamicGroup = async (val, menu) => {
9190
const params = {
9291
condition: {
93-
[menu.id]: escapeRegexChar(val)
92+
[menu.id]: val
9493
},
9594
page: {
9695
start: 0,

src/ui/src/views/dynamic-group/index.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@
111111
import RouterQuery from '@/router/query'
112112
import DynamicGroupForm from './form/form.js'
113113
import SearchSelect from './children/search-select.vue'
114-
import { escapeRegexChar } from '@/utils/util'
115114
116115
export default {
117116
components: {
@@ -149,7 +148,7 @@
149148
}
150149
}
151150
this.filter.forEach((item) => {
152-
const itemValue = item.value?.split(',').map(escapeRegexChar)
151+
const itemValue = item.value?.split(',')
153152
const value = itemValue?.length > 1 ? {
154153
$in: itemValue
155154
} : itemValue[0]

src/ui/src/views/field-template/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@
101101
}
102102
}
103103
filter.value.forEach((item) => {
104-
const itemValue = item.value?.split(',').map(escapeRegexChar)
104+
const itemValue = item.value?.split(',')
105105
const operator = queryBuilderOperator(itemValue?.length > 1 ? QUERY_OPERATOR.IN : QUERY_OPERATOR.LIKE)
106-
const value = itemValue?.length > 1 ? itemValue : itemValue[0]
106+
const value = itemValue?.length > 1 ? itemValue : escapeRegexChar(itemValue[0])
107107
if (item.id === 'templateName') {
108108
params.template_filter.rules.push({
109109
field: 'name',

0 commit comments

Comments
 (0)