From e3bcf526414064531c05d4af6df9a328d4c773a6 Mon Sep 17 00:00:00 2001 From: 100011797 <2642441182@qq.com> Date: Tue, 28 Mar 2023 17:59:40 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E8=BE=B9=E7=BC=98?= =?UTF-8?q?=E7=BD=91=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/NormalUpload/index.vue | 2 +- src/components/Upload/index.vue | 4 +- src/views/device/Instance/Save/index.vue | 2 +- src/views/edge/Device/Save/index.vue | 2 +- src/views/edge/Resource/Issue/index.vue | 45 ++++++++++++++----- src/views/edge/Resource/index.vue | 45 ++++++++++--------- .../Save/action/Notify/NotifyTemplate.vue | 4 +- .../action/Notify/VariableDefinitions.vue | 20 ++++++--- .../Scene/Save/action/Notify/index.vue | 17 ++++++- 9 files changed, 96 insertions(+), 45 deletions(-) diff --git a/src/components/NormalUpload/index.vue b/src/components/NormalUpload/index.vue index 296164f1..e1e21a63 100644 --- a/src/components/NormalUpload/index.vue +++ b/src/components/NormalUpload/index.vue @@ -7,10 +7,10 @@ :headers="{ 'X-Access-Token': LocalStore.get(TOKEN_KEY), }" - accept=".xlsx,.csv" :maxCount="1" :showUploadList="false" @change="uploadChange" + :accept="props?.file?.fileType ? `.${props?.file?.fileType}` : '.xlsx'" > diff --git a/src/components/Upload/index.vue b/src/components/Upload/index.vue index a4267169..336a255f 100644 --- a/src/components/Upload/index.vue +++ b/src/components/Upload/index.vue @@ -90,8 +90,8 @@ const props: JUploadProps = defineProps({ default: '', }, accept:{ - type:Array, - default:()=>[], + type: String, + default: undefined } }); diff --git a/src/views/device/Instance/Save/index.vue b/src/views/device/Instance/Save/index.vue index 17ac2138..a0267b67 100644 --- a/src/views/device/Instance/Save/index.vue +++ b/src/views/device/Instance/Save/index.vue @@ -13,7 +13,7 @@ - + diff --git a/src/views/edge/Device/Save/index.vue b/src/views/edge/Device/Save/index.vue index 58108a27..be2b47d3 100644 --- a/src/views/edge/Device/Save/index.vue +++ b/src/views/edge/Device/Save/index.vue @@ -13,7 +13,7 @@ - + diff --git a/src/views/edge/Resource/Issue/index.vue b/src/views/edge/Resource/Issue/index.vue index b12f7554..0cac4972 100644 --- a/src/views/edge/Resource/Issue/index.vue +++ b/src/views/edge/Resource/Issue/index.vue @@ -6,7 +6,7 @@ @ok="onSave" @cancel="onCancel" > -
+
- + @@ -56,9 +65,11 @@ import { onlyMessage } from '@/utils/comm'; import { queryDeviceList } from '@/api/edge/resource'; import dayjs from 'dayjs'; import Result from './Result.vue'; +import { queryNoPagingPost } from '@/api/device/product'; const defaultParams = { - sorts: [{ name: 'createTime', order: 'desc' }], + pageSize: 10, + sorts: [{ name: 'registerTime', order: 'desc' }], terms: [ { terms: [ @@ -111,6 +122,18 @@ const columns = [ ellipsis: true, search: { type: 'select', + rename: 'productId', + options: () => + new Promise((resolve) => { + queryNoPagingPost({ paging: false }).then((resp: any) => { + resolve( + resp.result.map((item: any) => ({ + label: item.name, + value: item.id, + })), + ); + }); + }), }, }, { @@ -155,10 +178,10 @@ const handleSearch = (v: any) => { }; const onSave = () => { - if(_data.value.length){ - visible.value = true + if (_data.value.length) { + visible.value = true; } else { - onlyMessage('请选择设备', 'error') + onlyMessage('请选择设备', 'error'); } }; @@ -167,12 +190,12 @@ const onCancel = () => { }; - \ No newline at end of file + + + 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 a02934b0..74607c6c 100644 --- a/src/views/rule-engine/Scene/Save/action/Notify/NotifyTemplate.vue +++ b/src/views/rule-engine/Scene/Save/action/Notify/NotifyTemplate.vue @@ -84,7 +84,7 @@ const props = defineProps({ }, }); -const emit = defineEmits(['update:value', 'change']); +const emit = defineEmits(['update:value', 'change', 'update:detail']); const getLogo = (type: string, provider: string) => { return MSG_TYPE[type].find((f: any) => f.value === provider)?.logo; @@ -133,10 +133,12 @@ const handleClick = (dt: any) => { _selectedRowKeys.value = []; emit('update:value', undefined); emit('change', { templateName: undefined }); + emit('update:detail', undefined); } else { _selectedRowKeys.value = [dt.id]; emit('update:value', dt.id); emit('change', { templateName: dt?.name }); + emit('update:detail', dt); } }; 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 975bbae1..5dadba7c 100644 --- a/src/views/rule-engine/Scene/Save/action/Notify/VariableDefinitions.vue +++ b/src/views/rule-engine/Scene/Save/action/Notify/VariableDefinitions.vue @@ -75,6 +75,10 @@ const props = defineProps({ type: Object, default: () => {}, }, + template: { + type: Object, + default: () => {}, + }, }); const emit = defineEmits(['update:value', 'change']); @@ -87,6 +91,12 @@ watchEffect(() => { Object.assign(modelRef, props?.value); }); +watchEffect(() => { + if(props?.template?.template?.sendTo && props?.template?.template?.sendTo?.length){ + emit('change', { sendTo: props?.template?.template?.sendTo.join(' ') }); + } +}); + const getType = (item: any) => { return item.expands?.businessType || item.type; }; @@ -180,16 +190,16 @@ const onChange = (val: any, type: any) => { emit('change', { tagName: val }); } else if (type === 'user') { emit('change', { sendTo: val }); - } else if (type === 'build-in') { - // emit('change', { sendTo: val }); } }; const onSave = () => - new Promise((resolve) => { - formRef.value?.validate().then(async (_data: any) => { + new Promise((resolve, reject) => { + formRef.value?.validate().then((_data: any) => { resolve(_data); - }); + }).catch(() => { + reject(false) + }) }); defineExpose({ onSave }); 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 9e00c129..4c900aed 100644 --- a/src/views/rule-engine/Scene/Save/action/Notify/index.vue +++ b/src/views/rule-engine/Scene/Save/action/Notify/index.vue @@ -47,6 +47,7 @@ @@ -58,6 +59,7 @@ :variableDefinitions="variable" :value="formModel.variables" :notify="formModel" + :template="template" @change="(val) => onValChange(val, 'variables')" ref="variableRef" /> @@ -119,11 +121,19 @@ const formModel = reactive({ const variable = ref([]); const variableRef = ref(); +const template = ref(); watch( () => props.value, (newVal) => { Object.assign(formModel, newVal); + if(newVal?.templateId){ + Template.detail(newVal?.templateId).then((resp: any) => { + if(resp.status === 200){ + template.value = resp.result + } + }) + } }, { deep: true, immediate: true }, ); @@ -193,8 +203,11 @@ const onCancel = () => { emit('cancel'); }; const onOk = async () => { - const _data = await variableRef.value.onSave(); - formModel.variables = _data; + let _data = undefined + if(variable.value.length){ + _data = await variableRef.value.onSave() + } + formModel.variables = _data || []; const { options, ...extra } = formModel; emit('save', { ...extra }, { ...options }); };