diff --git a/src/api/notice/config.ts b/src/api/notice/config.ts index 0dfa289e..d3e4854a 100644 --- a/src/api/notice/config.ts +++ b/src/api/notice/config.ts @@ -17,6 +17,8 @@ export default { getHistory: (data: any, id: string) => post(`/notify/history/config/${id}/_query`, data), // 获取所有平台用户 getPlatformUsers: (data: any) => post(`/user/_query/no-paging`, data), + // 获取所有关系 + getRelationUsers: (data: any) => post(`/relation/_query/no-paging`, data), // 钉钉部门 dingTalkDept: (id: string) => get(`/notifier/dingtalk/corp/${id}/departments/tree`), // 钉钉部门人员 @@ -38,5 +40,9 @@ export default { //通知类型 queryMessageType: () => get(`/notifier/config/types`), // 不分页-列表 - queryListNoPaging: (data: any) => post(`/notifier/config/_query/no-paging?paging=false`, data) + queryListNoPaging: (data: any) => post(`/notifier/config/_query/no-paging?paging=false`, data), + // + queryDingTalkUsers: (id: string) => get(`/notifier/dingtalk/corp/${id}/users?sorts[0].name='name'&sorts[0].order=asc`), + // + queryWechatUsers: (id: string) => get(`/notifier/wechat/corp/${id}/users?sorts[0].name='name'&sorts[0].order=asc`), } \ No newline at end of file diff --git a/src/api/rule-engine/scene.ts b/src/api/rule-engine/scene.ts index 4c00c1ba..1db1eb38 100644 --- a/src/api/rule-engine/scene.ts +++ b/src/api/rule-engine/scene.ts @@ -18,4 +18,7 @@ export const _action = (id: string, type: '_disable' | '_enable') => server.put( * @param id * @returns */ -export const _execute = (id: string) => server.post(`/scene/${id}/_execute`); \ No newline at end of file +export const _execute = (id: string) => server.post(`/scene/${id}/_execute`); + +// 内置参数 +export const queryBuiltInParams = (data: any, params?: any) => server.post(`/scene/parse-variables`, data, params); \ No newline at end of file diff --git a/src/views/rule-engine/Scene/Save/Timer/index.vue b/src/views/rule-engine/Scene/Save/Timer/index.vue index 60c78d36..e43a7f45 100644 --- a/src/views/rule-engine/Scene/Save/Timer/index.vue +++ b/src/views/rule-engine/Scene/Save/Timer/index.vue @@ -1,11 +1,16 @@ - \ No newline at end of file diff --git a/src/views/rule-engine/Scene/Save/action/ListItem/List.vue b/src/views/rule-engine/Scene/Save/action/ListItem/List.vue index d63761c3..d78fab0d 100644 --- a/src/views/rule-engine/Scene/Save/action/ListItem/List.vue +++ b/src/views/rule-engine/Scene/Save/action/ListItem/List.vue @@ -1,19 +1,43 @@ \ No newline at end of file diff --git a/src/views/rule-engine/Scene/Save/action/Modal/ActionTypeComponent.vue b/src/views/rule-engine/Scene/Save/action/Modal/ActionTypeComponent.vue new file mode 100644 index 00000000..545bcf04 --- /dev/null +++ b/src/views/rule-engine/Scene/Save/action/Modal/ActionTypeComponent.vue @@ -0,0 +1,64 @@ + + + \ No newline at end of file diff --git a/src/views/rule-engine/Scene/Save/action/Modal/index.vue b/src/views/rule-engine/Scene/Save/action/Modal/index.vue index 52e74e53..92aa275e 100644 --- a/src/views/rule-engine/Scene/Save/action/Modal/index.vue +++ b/src/views/rule-engine/Scene/Save/action/Modal/index.vue @@ -25,24 +25,51 @@ float="right" /> - - - + \ No newline at end of file diff --git a/src/views/rule-engine/Scene/Save/action/Notify/NotifyConfig.vue b/src/views/rule-engine/Scene/Save/action/Notify/NotifyConfig.vue index 267c0cd1..ce8e8d48 100644 --- a/src/views/rule-engine/Scene/Save/action/Notify/NotifyConfig.vue +++ b/src/views/rule-engine/Scene/Save/action/Notify/NotifyConfig.vue @@ -7,16 +7,12 @@ class="search" />
- ConfigApi.list({ + ...e, terms: [ + ...e?.terms, { terms: [ { @@ -27,11 +23,15 @@ ], }, ], - sorts: [{ name: 'createTime', order: 'desc' }], + sorts: [{ name: 'id', value: props.value }, { name: 'createTime', order: 'desc' }], + })" + model="CARD" + :bodyStyle="{ + paddingRight: 0, + paddingLeft: 0, }" :params="params" :gridColumn="2" - :gridColumns="[2, 2, 2]" :rowSelection="{ selectedRowKeys: _selectedRowKeys, }" @@ -82,7 +82,7 @@ - +
@@ -175,4 +175,9 @@ watch( padding-right: 0px; padding-left: 0px; } - \ No newline at end of file + +.logo{ + width: 88px; + height: 88px; +} + diff --git a/src/views/rule-engine/Scene/Save/action/Notify/NotifyTemplate.vue b/src/views/rule-engine/Scene/Save/action/Notify/NotifyTemplate.vue index f8486de6..c9ebf974 100644 --- a/src/views/rule-engine/Scene/Save/action/Notify/NotifyTemplate.vue +++ b/src/views/rule-engine/Scene/Save/action/Notify/NotifyTemplate.vue @@ -7,20 +7,16 @@ class="search" />
- - +
@@ -142,6 +138,27 @@ const handleClick = (dt: any) => { emit('update:value', dt.id); }; +const handleData = async (e: any) => { + const sorts = [ + { name: 'id', value: props.value }, + { name: 'createTime', order: 'desc' }, + ]; + const resp = await TemplateApi.getListByConfigId(props.notifierId, { + ...e, + sorts: sorts, + }); + return { + code: resp.message, + result: { + data: resp.result ? resp.result : [], + pageIndex: 0, + pageSize: resp.result.length, + total: resp.result.length, + }, + status: resp.status, + }; +}; + watch( () => props.value, (newValue) => { @@ -164,4 +181,9 @@ watch( padding-right: 0px; padding-left: 0px; } + +.logo { + width: 88px; + height: 88px; +} \ No newline at end of file diff --git a/src/views/rule-engine/Scene/Save/action/Notify/NotifyWay.vue b/src/views/rule-engine/Scene/Save/action/Notify/NotifyWay.vue index 9833c40c..23b7e31e 100644 --- a/src/views/rule-engine/Scene/Save/action/Notify/NotifyWay.vue +++ b/src/views/rule-engine/Scene/Save/action/Notify/NotifyWay.vue @@ -42,6 +42,7 @@ watch( ); onMounted(() => { + loading.value = true notice.queryMessageType().then((resp) => { if (resp.status === 200) { options.value = (resp.result as any[]).map((item) => { @@ -52,6 +53,7 @@ onMounted(() => { }; }); } + loading.value = false }); notifyType.value = props.value }); diff --git a/src/views/rule-engine/Scene/Save/action/Notify/VariableDefinitions.vue b/src/views/rule-engine/Scene/Save/action/Notify/VariableDefinitions.vue index 9da5902e..baf6439f 100644 --- a/src/views/rule-engine/Scene/Save/action/Notify/VariableDefinitions.vue +++ b/src/views/rule-engine/Scene/Save/action/Notify/VariableDefinitions.vue @@ -5,38 +5,44 @@ ref="formRef" :model="modelRef" > - + + + + + + + + @@ -46,25 +52,103 @@ import Org from './variableItem/Org.vue'; import Tag from './variableItem/Tag.vue'; import InputFile from './variableItem/InputFile.vue'; import User from './variableItem/User.vue'; +import { PropType } from 'vue'; const props = defineProps({ variableDefinitions: { - type: Array, + type: Array as PropType, default: () => [], }, value: { type: Object, default: () => {}, }, + notify: { + type: Object, + default: () => {}, + }, }); const formRef = ref(); const modelRef = reactive({}); -Object.assign(formRef, props.value); +watchEffect(() => { + Object.assign(modelRef, props.value); +}); const getType = (item: any) => { return item.expands?.businessType || item.type; }; + +const checkValue = (_rule: any, value: any, item: any) => { + const type = item.expands?.businessType || item?.type; + if (type === 'file') { + return Promise.resolve(); + } else if (type === 'link') { + if (!value) { + return Promise.reject(new Error('请输入' + item.name)); + } else if (value.length > 64) { + return Promise.reject(new Error('最多64个字符')); + } + } else if (type === 'tag' && !value) { + return Promise.reject(new Error('请选择' + item.name)); + } else if (['date', 'org'].includes(type)) { + if (!value) { + return Promise.reject(new Error('请选择' + item.name)); + } else { + if (value?.source === 'upper') { + if (!value.upperKey) { + return Promise.reject(new Error('请选择' + item.name)); + } else { + return Promise.resolve(); + } + } else { + if (!value.value) { + return Promise.reject(new Error('请选择' + item.name)); + } else { + return Promise.resolve(); + } + } + } + } else if (value.source === 'fixed' && !value.value) { + return Promise.reject(new Error('请输入' + item.name)); + } else if (value.source === 'relation' && !value.value && !value.relation) { + return Promise.reject(new Error('请选择' + item.name)); + } else if (value.source === 'upper' && !value.upperKey) { + return Promise.reject(new Error('请选择' + item.name)); + } else if (type === 'user') { + if (props.notify.notifyType === 'email') { + if (Array.isArray(value.value)) { + if (!value.value.length) { + return Promise.reject(new Error('请输入收件人')); + } + const reg = + /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/; + const flag = value.value.every((it: string) => { + return reg.test(it); + }); + if (!flag) { + return Promise.reject(new Error('请输入正确的邮箱地址')); + } else { + return Promise.resolve(); + } + } else { + return Promise.resolve(); + } + } + if ( + props.notify.notifyType && + ['sms', 'voice'].includes(props?.notify?.notifyType) + ) { + const reg = /^[1][3-9]\d{9}$/; + if (!reg.test(value.value)) { + return Promise.reject(new Error('请输入正确的手机号码')); + } else { + return Promise.resolve(); + } + } + } + return Promise.resolve(); +}; \ No newline at end of file diff --git a/src/views/rule-engine/Scene/Save/action/Notify/index.vue b/src/views/rule-engine/Scene/Save/action/Notify/index.vue index a5836cfe..baf3a186 100644 --- a/src/views/rule-engine/Scene/Save/action/Notify/index.vue +++ b/src/views/rule-engine/Scene/Save/action/Notify/index.vue @@ -33,12 +33,18 @@ @@ -55,8 +62,12 @@ 取消 上一步 - 下一步 - 确定 + 下一步 + 确定 @@ -69,6 +80,22 @@ import NotifyTemplate from './NotifyTemplate.vue'; import VariableDefinitions from './VariableDefinitions.vue'; import { onlyMessage } from '@/utils/comm'; import Template from '@/api/notice/template'; +import { PropType } from 'vue'; +import { NotifyProps } from '../../../typings'; + +const props = defineProps({ + value: { + type: Object as PropType>, + default: () => undefined, + }, + options: { + type: Object, + }, + name: { + type: Number, + default: 0, + }, +}); const emit = defineEmits(['cancel', 'save']); @@ -78,33 +105,42 @@ const formModel = reactive({ notifyType: '', notifierId: '', templateId: '', - variables: [], + variables: {}, }); const variable = ref([]); +watch( + () => props.value, + (newVal) => { + Object.assign(formModel, newVal); + }, + { deep: true, immediate: true }, +); + const jumpStep = async (val: number) => { if (val === 0) { current.value = val; } else if (val === 1) { + console.log(formModel) if (formModel.notifyType) { - current.value = val + current.value = val; } else { onlyMessage('请选择通知方式', 'error'); } } else if (val === 2) { if (formModel.notifierId) { - current.value = val + current.value = val; } else { onlyMessage('请选择通知配置', 'error'); } } else if (val === 3) { - formModel.templateId = '1628943618904956928' + formModel.templateId = '1628943618904956928'; if (formModel.templateId) { const resp = await Template.getTemplateDetail(formModel.templateId); if (resp.status === 200) { variable.value = resp.result?.variableDefinitions || []; - current.value = val + current.value = val; } } else { onlyMessage('请选择通知模板', 'error'); @@ -113,7 +149,7 @@ const jumpStep = async (val: number) => { }; const onChange = (cur: number) => { - jumpStep(cur) + jumpStep(cur); }; const prev = () => { @@ -121,7 +157,7 @@ const prev = () => { }; const next = async () => { - jumpStep(current.value + 1) + jumpStep(current.value + 1); }; const onCancel = () => { diff --git a/src/views/rule-engine/Scene/Save/action/Notify/variableItem/BuildIn.vue b/src/views/rule-engine/Scene/Save/action/Notify/variableItem/BuildIn.vue index 8f5ada65..2dc1cbb4 100644 --- a/src/views/rule-engine/Scene/Save/action/Notify/variableItem/BuildIn.vue +++ b/src/views/rule-engine/Scene/Save/action/Notify/variableItem/BuildIn.vue @@ -1,3 +1,163 @@ \ No newline at end of file + + + + + + + + + + \ No newline at end of file diff --git a/src/views/rule-engine/Scene/Save/action/Notify/variableItem/InputFile.vue b/src/views/rule-engine/Scene/Save/action/Notify/variableItem/InputFile.vue index ab803572..926f81f3 100644 --- a/src/views/rule-engine/Scene/Save/action/Notify/variableItem/InputFile.vue +++ b/src/views/rule-engine/Scene/Save/action/Notify/variableItem/InputFile.vue @@ -1,3 +1,77 @@ \ No newline at end of file + + + + + + \ No newline at end of file diff --git a/src/views/rule-engine/Scene/Save/action/Notify/variableItem/Org.vue b/src/views/rule-engine/Scene/Save/action/Notify/variableItem/Org.vue index 812f1dd2..012a694f 100644 --- a/src/views/rule-engine/Scene/Save/action/Notify/variableItem/Org.vue +++ b/src/views/rule-engine/Scene/Save/action/Notify/variableItem/Org.vue @@ -1,3 +1,75 @@ \ No newline at end of file + + + + + + \ No newline at end of file diff --git a/src/views/rule-engine/Scene/Save/action/Notify/variableItem/Tag.vue b/src/views/rule-engine/Scene/Save/action/Notify/variableItem/Tag.vue index 0e35727a..75b16cdf 100644 --- a/src/views/rule-engine/Scene/Save/action/Notify/variableItem/Tag.vue +++ b/src/views/rule-engine/Scene/Save/action/Notify/variableItem/Tag.vue @@ -1,3 +1,65 @@ \ No newline at end of file + + + + + + \ No newline at end of file diff --git a/src/views/rule-engine/Scene/Save/action/Notify/variableItem/User.vue b/src/views/rule-engine/Scene/Save/action/Notify/variableItem/User.vue index 91482aa7..48c416ef 100644 --- a/src/views/rule-engine/Scene/Save/action/Notify/variableItem/User.vue +++ b/src/views/rule-engine/Scene/Save/action/Notify/variableItem/User.vue @@ -1,3 +1,274 @@ \ No newline at end of file + + + + 平台用户 + + + 钉钉用户 + + + 微信用户 + + + 固定邮箱 + + + 固定号码 + + + + + {{ item.name }} + + + + + + + \ No newline at end of file diff --git a/src/views/rule-engine/Scene/Save/action/index.vue b/src/views/rule-engine/Scene/Save/action/index.vue index 14b1778d..7c3a9b68 100644 --- a/src/views/rule-engine/Scene/Save/action/index.vue +++ b/src/views/rule-engine/Scene/Save/action/index.vue @@ -42,6 +42,8 @@ :branchesName="props.name" :parallel="true" :actions="parallelArray.length ? parallelArray[0].actions : []" + @add="onAdd" + @delete="onDelete" /> @@ -53,8 +55,6 @@