feat(消息管理): 消息管理限制最少一个接收人

This commit is contained in:
baiqi 2023-10-19 10:15:00 +08:00 committed by 刘瑞斌
parent 7f3c0d60ba
commit 0247634c34
9 changed files with 36 additions and 7 deletions

View File

@ -283,6 +283,8 @@
}
.arco-textarea {
.ms-scroll-bar();
padding-right: 16px;
}
/** form-item **/

View File

@ -168,7 +168,7 @@
addText: string;
maxHeight?: string;
defaultVals?: any[]; //
isShowDrag: boolean; //
isShowDrag?: boolean; //
formWidth?: string; //
showEnable?: boolean; // switch
}>(),

View File

@ -27,6 +27,7 @@ export interface MsSearchSelectProps {
labelKey?: string; // 选项的 label 字段名,默认为 label
options: SelectOptionData[];
multiple?: boolean; // 是否多选
atLeastOne?: boolean; // 是否至少选择一个,多选模式下有效
remoteFieldsMap?: RemoteFieldsMap; // 远程模式下的结果 key 映射,例如 { value: 'id' },表示远程请求时,会将返回结果的 id 赋值到 value 字段
remoteExtraParams?: Record<string, any>; // 远程模式下的额外参数
notAutoInitSearch?: boolean; // 是否禁用 arco-select 的初始化自动搜索功能
@ -229,7 +230,22 @@ export default defineComponent(
default: () =>
filterOptions.value.map((item) => (
<a-tooltip content={item.tooltipContent} mouse-enter-delay={500}>
<a-option key={item.id} value={item}>
<a-option
key={item[props.valueKey || 'value']}
value={item}
tag-props={
props.multiple && props.atLeastOne
? { closable: Array.isArray(innerValue.value) && innerValue.value.length > 1 }
: {}
}
disabled={
props.multiple &&
props.atLeastOne &&
Array.isArray(innerValue.value) &&
innerValue.value.find((e) => e[props.valueKey || 'value'] === item[props.valueKey || 'value']) &&
innerValue.value.length === 1
}
>
<div class="one-line-text" style={getOptionComputedStyle.value}>
{optionItemLabelRender(item)}
</div>
@ -320,6 +336,7 @@ export default defineComponent(
onUpdate:model-value={(value: ModelType) => emit('update:modelValue', value)}
onSearch={handleSearch}
onPopupVisibleChange={(val: boolean) => emit('popupVisibleChange', val)}
onRemove={(val: string | number | boolean | Record<string, any> | undefined) => emit('remove', val)}
>
{{
prefix: props.prefix ? () => t(props.prefix || '') : null,
@ -364,7 +381,8 @@ export default defineComponent(
'loading',
'fallbackOption',
'labelKey',
'atLeastOne',
],
emits: ['update:modelValue', 'remoteSearch', 'popupVisibleChange', 'update:loading'],
emits: ['update:modelValue', 'remoteSearch', 'popupVisibleChange', 'update:loading', 'remove'],
}
);

View File

@ -63,7 +63,7 @@
:options="defaultReceivers"
:search-keys="['label']"
allow-search
allow-clear
:at-least-one="true"
value-key="id"
label-key="name"
:multiple="true"
@ -77,6 +77,7 @@
label: (val as Record<string, any>).name,
value: val,
})"
@remove="changeMessageReceivers(false, record, dataIndex as string)"
@popup-visible-change="changeMessageReceivers($event, record, dataIndex as string)"
/>
<span v-else></span>
@ -336,6 +337,10 @@
});
function editRobot(record: TableMessageChildrenItem, dataIndex: string) {
if (record.receivers?.length === 0) {
Message.warning(t('project.messageManagement.unsetReceiversTip'));
return;
}
router.push({
name: ProjectManagementRouteEnum.PROJECT_MANAGEMENT_MESSAGE_MANAGEMENT_EDIT,
query: {

View File

@ -146,6 +146,7 @@
import { useI18n } from '@/hooks/useI18n';
import useLocale from '@/locale/useLocale';
import useAppStore from '@/store/modules/app';
import useUserStore from '@/store/modules/user';
import { sleep } from '@/utils';
import type { Field, MessageTemplateDetail } from '@/models/projectManagement/message';
@ -153,6 +154,7 @@
const route = useRoute();
const router = useRouter();
const appStore = useAppStore();
const userStore = useUserStore();
const { t } = useI18n();
const { currentLocale } = useLocale();
@ -183,6 +185,7 @@
taskType: route.query.taskType as string,
event: route.query.event as string,
projectId: appStore.currentProjectId,
receiverIds: messageDetail.value?.receiverIds || [userStore.id || ''],
});
Message.success(t('project.messageManagement.saveSuccess'));
await sleep(300);

View File

@ -98,5 +98,6 @@ export default {
'project.messageManagement.saveReceiverSuccess': 'Recipient modified successfully',
'project.messageManagement.unsetReceiverTip': 'Please set up message recipients before enabling the robot',
'project.messageManagement.receiverNotNull': 'Please set at least one message recipient',
'project.messageManagement.unsetReceiversTip': 'Please set the message recipients before configuring the template.',
'project.messageManagement.noMatchField': 'No matching fields yet',
};

View File

@ -90,5 +90,6 @@ export default {
'project.messageManagement.saveReceiverSuccess': '接收人修改成功',
'project.messageManagement.unsetReceiverTip': '启用机器人前请先设置消息接收人',
'project.messageManagement.receiverNotNull': '请最少设置一位消息接收人',
'project.messageManagement.unsetReceiversTip': '配置模版前请先设置消息接收人',
'project.messageManagement.noMatchField': '暂无匹配字段',
};

View File

@ -108,12 +108,12 @@
{
title: 'system.resourcePool.tableColumnCreateTime',
dataIndex: 'createTime',
width: 170,
width: 180,
},
{
title: 'system.resourcePool.tableColumnUpdateTime',
dataIndex: 'updateTime',
width: 170,
width: 180,
},
{
title: 'system.resourcePool.tableColumnActions',

View File

@ -281,7 +281,6 @@
columns,
size: 'default',
selectable: true,
pageSimple: true,
showSetting: true,
},
(record) => ({