From cfb7797996a14635adf542760fe5be7f2ad17805 Mon Sep 17 00:00:00 2001 From: 3octaves <873551943@qq.com> Date: Tue, 14 Jan 2025 15:19:51 +0800 Subject: [PATCH] =?UTF-8?q?feat(frontend):=20=E5=91=8A=E8=AD=A6=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E4=BC=98=E5=8C=96=20#8366?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../frontend/patch/user-selector/selector.vue | 4 ++-- .../components/NoticeMethodFormItem.vue | 18 ++++++++++++------ .../components/ReceiversSelector.vue | 8 ++++++++ 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/dbm-ui/frontend/patch/user-selector/selector.vue b/dbm-ui/frontend/patch/user-selector/selector.vue index 7f7dae0ead..5b0a325aa8 100644 --- a/dbm-ui/frontend/patch/user-selector/selector.vue +++ b/dbm-ui/frontend/patch/user-selector/selector.vue @@ -868,9 +868,9 @@ } try { loading.value = true; - const pasteStr = event.clipboardData.getData('text').replace(/\s/g, ''); + const pasteStr = event.clipboardData.getData('text').replace(/[^\S\r\n]/g, ''); const values = pasteStr - .split(/,|;/) + .split(/\s*[||,,;;、\t/\s]\s*/g) .map((value) => pasteFormatter.value(value)) .filter((value) => value.length); const uniqueValues = [...new Set(values)]; diff --git a/dbm-ui/frontend/src/views/monitor-alarm-db/alarm-group/components/NoticeMethodFormItem.vue b/dbm-ui/frontend/src/views/monitor-alarm-db/alarm-group/components/NoticeMethodFormItem.vue index ae435d5092..7f20b2fb00 100644 --- a/dbm-ui/frontend/src/views/monitor-alarm-db/alarm-group/components/NoticeMethodFormItem.vue +++ b/dbm-ui/frontend/src/views/monitor-alarm-db/alarm-group/components/NoticeMethodFormItem.vue @@ -221,6 +221,11 @@ ].join('\n'), }; + const InputMessageTypeMap: Record = { + 'wxwork-bot': MessageTypes.WECOM_ROBOT, + [MessageTypes.WECOM_ROBOT]: 'wxwork-bot', + }; + let head: TableHead[] = [ { label: t('告警级别'), @@ -472,14 +477,16 @@ const inputArr = _.cloneDeep(panelInitData.inputArr); configItem.notice_ways.forEach((wayItem) => { - if (InputMessageTypes.includes(wayItem.name)) { - const idx = inputArr.findIndex((inputItem) => inputItem.type === wayItem.name); + // 转为消息类型对应值 + const conversionType = InputMessageTypeMap[wayItem.name] || wayItem.name; + if (InputMessageTypes.includes(conversionType)) { + const idx = inputArr.findIndex((inputItem) => inputItem.type === conversionType); if (idx > -1) { inputArr[idx].value = (wayItem.receivers || []).join(','); } } else { - const idx = checkboxArr.findIndex((checkboxItem) => checkboxItem.type === wayItem.name); + const idx = checkboxArr.findIndex((checkboxItem) => checkboxItem.type === conversionType); if (idx > -1) { checkboxArr[idx].checked = true; @@ -625,7 +632,7 @@ (prev, current) => { if (current.value !== '') { prev.push({ - name: current.type, + name: InputMessageTypeMap[current.type] || current.type, // 转为映射值 receivers: current.value.split(','), }); } @@ -697,10 +704,9 @@ .table-row-item { display: flex; - min-width: 120px; + width: 110px; padding: 0 12px; border-bottom: 1px solid #dcdee5; - flex: 1; align-items: center; justify-content: center; flex-shrink: 0; diff --git a/dbm-ui/frontend/src/views/monitor-alarm-db/alarm-group/components/ReceiversSelector.vue b/dbm-ui/frontend/src/views/monitor-alarm-db/alarm-group/components/ReceiversSelector.vue index 04abae36d1..5f3ec2636b 100644 --- a/dbm-ui/frontend/src/views/monitor-alarm-db/alarm-group/components/ReceiversSelector.vue +++ b/dbm-ui/frontend/src/views/monitor-alarm-db/alarm-group/components/ReceiversSelector.vue @@ -21,6 +21,7 @@ :default-alternate="defaultAlternate" :disabled="disabled" :fuzzy-search-method="fuzzySearchMethod" + :paste-validator="pasteValidator" :render-list="renderList" :render-tag="renderTag" :search-from-default-alternate="false" @@ -227,6 +228,13 @@ userSelectorRef.value.search(); }; + const pasteValidator = (values: string[]) => + getUserList({ + exact_lookups: values.join(','), + offset: 0, + limit: -1, + }).then((userResult) => userResult.results.map((userItem) => userItem.username)); + defineExpose({ getSelectedReceivers() { return modelValue.value.map((modelValueItem) => ({