From 7e053e0d0097de249cc03dd39f2c68619f1edd79 Mon Sep 17 00:00:00 2001 From: wzyyy <1175160654@qq.com> Date: Sat, 4 Mar 2023 11:51:42 +0800 Subject: [PATCH 1/6] =?UTF-8?q?fix:=20=E7=89=A9=E8=81=94=E5=8D=A1=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E6=9B=BF=E6=8D=A2=E5=8F=8A=E9=83=A8=E5=88=86=E5=9C=BA?= =?UTF-8?q?=E6=99=AF=E8=81=94=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/utils/comm.ts | 2 +- .../device/Instance/Detail/Parsing/index.vue | 2 +- .../Product/Detail/DataAnalysis/index.vue | 2 +- .../iot-card/CardManagement/BindDevice.vue | 60 ++-- src/views/iot-card/CardManagement/Export.vue | 16 +- src/views/iot-card/CardManagement/Import.vue | 8 +- src/views/iot-card/CardManagement/Save.vue | 4 +- src/views/iot-card/CardManagement/index.vue | 64 ++--- src/views/iot-card/Platform/Detail/index.vue | 2 +- src/views/iot-card/Platform/index.vue | 82 ++---- src/views/iot-card/Recharge/Save.vue | 5 +- .../Scene/Save/action/Device/Product.vue | 261 ++++++++++++++++++ .../Scene/Save/action/Device/device/index.vue | 14 + .../Scene/Save/action/Device/index.vue | 110 +++++++- .../Scene/Save/action/Device/typings.d.ts | 28 ++ yarn.lock | 43 ++- 17 files changed, 531 insertions(+), 174 deletions(-) create mode 100644 src/views/rule-engine/Scene/Save/action/Device/Product.vue create mode 100644 src/views/rule-engine/Scene/Save/action/Device/device/index.vue create mode 100644 src/views/rule-engine/Scene/Save/action/Device/typings.d.ts diff --git a/package.json b/package.json index 387d6753..c3cc14ad 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "event-source-polyfill": "^1.0.31", "global": "^4.4.0", "jetlinks-store": "^0.0.3", - "jetlinks-ui-components": "^1.0.1", + "jetlinks-ui-components": "^1.0.3", "js-cookie": "^3.0.1", "less": "^4.1.3", "less-loader": "^11.1.0", diff --git a/src/utils/comm.ts b/src/utils/comm.ts index 25e54bab..85f9273f 100644 --- a/src/utils/comm.ts +++ b/src/utils/comm.ts @@ -1,6 +1,6 @@ import type { Slots } from 'vue' import { TOKEN_KEY } from '@/utils/variable' -import { message } from 'ant-design-vue' +import { message } from 'jetlinks-ui-components'; /** * 静态图片资源处理 diff --git a/src/views/device/Instance/Detail/Parsing/index.vue b/src/views/device/Instance/Detail/Parsing/index.vue index dd31b0bd..11324960 100644 --- a/src/views/device/Instance/Detail/Parsing/index.vue +++ b/src/views/device/Instance/Detail/Parsing/index.vue @@ -103,7 +103,7 @@ import { saveDeviceCode, delDeviceCode } from '@/api/device/instance' -import { message } from 'ant-design-vue'; +import { message } from 'jetlinks-ui-components'; import { isBoolean } from 'lodash'; const defaultValue = diff --git a/src/views/device/Product/Detail/DataAnalysis/index.vue b/src/views/device/Product/Detail/DataAnalysis/index.vue index 0db2b63a..7b4045fc 100644 --- a/src/views/device/Product/Detail/DataAnalysis/index.vue +++ b/src/views/device/Product/Detail/DataAnalysis/index.vue @@ -72,7 +72,7 @@ import { testCode, saveProductCode, } from '@/api/device/instance' -import { message } from 'ant-design-vue'; +import { message } from 'jetlinks-ui-components'; import { isBoolean } from 'lodash'; const defaultValue = diff --git a/src/views/iot-card/CardManagement/BindDevice.vue b/src/views/iot-card/CardManagement/BindDevice.vue index cc2b100a..51321fb2 100644 --- a/src/views/iot-card/CardManagement/BindDevice.vue +++ b/src/views/iot-card/CardManagement/BindDevice.vue @@ -1,53 +1,27 @@ \ 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 @@