From 049bf99395596e90a5c3de7c223efe924d391c84 Mon Sep 17 00:00:00 2001 From: jackhoo_98 Date: Mon, 27 Mar 2023 15:25:53 +0800 Subject: [PATCH 01/13] =?UTF-8?q?fix:=20=E8=8F=9C=E5=8D=95=E7=AE=A1?= =?UTF-8?q?=E7=90=86=20=E5=AE=8C=E6=88=90=E8=8F=9C=E5=8D=95=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/system/Menu/Setting/index copy.vue | 388 ------------------- src/views/system/Menu/Setting/index.vue | 157 ++++---- src/views/system/Menu/Setting/utils.ts | 51 ++- 3 files changed, 129 insertions(+), 467 deletions(-) delete mode 100644 src/views/system/Menu/Setting/index copy.vue diff --git a/src/views/system/Menu/Setting/index copy.vue b/src/views/system/Menu/Setting/index copy.vue deleted file mode 100644 index b0444c57..00000000 --- a/src/views/system/Menu/Setting/index copy.vue +++ /dev/null @@ -1,388 +0,0 @@ - - - - - diff --git a/src/views/system/Menu/Setting/index.vue b/src/views/system/Menu/Setting/index.vue index 9634b5b5..bf7bcea4 100644 --- a/src/views/system/Menu/Setting/index.vue +++ b/src/views/system/Menu/Setting/index.vue @@ -3,84 +3,84 @@
- 基于系统源代码中的菜单数据,配置系统菜单。 + 单击可切换菜单未选中/选中状态;操作父级菜单时,对应子菜单状态将默认与其同步,可以单独操作调整;支持拖拽菜单调整展示顺序。 +
-
- 系统菜单 - - +
+ - - -
-
- - - + +
+
+ 保存 + + 保存后当前系统菜单数据将被覆盖,确认操作? + \ No newline at end of file diff --git a/src/components/index.ts b/src/components/index.ts index 9af226d5..71e6d881 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -9,8 +9,8 @@ import NormalUpload from './NormalUpload/index.vue' import FileFormat from './FileFormat/index.vue' import JProUpload from './Upload/index.vue' import { BasicLayoutPage, BlankLayoutPage } from './Layout' -import { PageContainer, AIcon } from 'jetlinks-ui-components' -import Ellipsis from './Ellipsis/index.vue' +import { PageContainer, AIcon, Ellipsis } from 'jetlinks-ui-components' +// import Ellipsis from './Ellipsis/index.vue' import JEmpty from './Empty/index.vue' import AMapComponent from './AMapComponent/index.vue' import PathSimplifier from './AMapComponent/PathSimplifier.vue' From a887be421e68c2850fcc1f3509d177ced86970c1 Mon Sep 17 00:00:00 2001 From: xieyonghong <18010623010@163.com> Date: Mon, 27 Mar 2023 15:58:03 +0800 Subject: [PATCH 08/13] =?UTF-8?q?update:=20=E6=9B=B4=E6=96=B0=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yarn.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/yarn.lock b/yarn.lock index cd047e8c..e886d399 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3700,8 +3700,8 @@ jetlinks-store@^0.0.3: jetlinks-ui-components@^1.0.5: version "1.0.5" - resolved "http://47.108.170.157:9013/jetlinks-ui-components/-/jetlinks-ui-components-1.0.5.tgz#6a3cc76cd6d98319e070da597bfcf146fa12d375" - integrity sha512-ASPqiWprK2v4/zQIYxOytjkVFgx+AkBaD5Klg2ik88y9uDAW/Ylvqa91v149znihU1y8Q2Nm2PXvUSJFD7HPpw== + resolved "http://47.108.170.157:9013/jetlinks-ui-components/-/jetlinks-ui-components-1.0.5.tgz#27312836506c4833dcaaef075e1d3c694d75ae4d" + integrity sha512-oum7zipoDUVkm/tPd7yu+mw9mR5NmfBcvBf49ebf55s+nz4zyArFOITzldQJ3Wx6BwaUUH/BiDwskHH+KgBVyg== dependencies: "@vueuse/core" "^9.12.0" ant-design-vue "^3.2.15" From dbd14ce4d63f9a6fe1d9d26e8fe9c7c3946ca4c6 Mon Sep 17 00:00:00 2001 From: JiangQiming <291854119@qq.com> Date: Mon, 27 Mar 2023 16:11:06 +0800 Subject: [PATCH 09/13] =?UTF-8?q?fix:=20bug#10924=E3=80=8111001?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/validate.ts | 10 +++++- .../system/Apply/Save/components/EditForm.vue | 31 +++++++++++++++++-- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/src/utils/validate.ts b/src/utils/validate.ts index 8ac2aef3..85542cb4 100644 --- a/src/utils/validate.ts +++ b/src/utils/validate.ts @@ -16,4 +16,12 @@ export const phoneRegEx = (value: string) => { export const passwordRegEx = (value: string) => { const password = new RegExp(/^\S*(?=\S{8,})(?=\S*\d)(?=\S*[A-Z])(?=\S*[a-z])\S*$/) return password.test(value) -} \ No newline at end of file +} +/** + * 判断是否为正确的IP地址 + */ +export const testIP = (value: string) => { + const ip = + /^([0-9]|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.([0-9]|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.([0-9]|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.([0-9]|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])$/; + return ip.test(value); +}; \ No newline at end of file diff --git a/src/views/system/Apply/Save/components/EditForm.vue b/src/views/system/Apply/Save/components/EditForm.vue index 17c572e1..595f957a 100644 --- a/src/views/system/Apply/Save/components/EditForm.vue +++ b/src/views/system/Apply/Save/components/EditForm.vue @@ -824,7 +824,15 @@ placeholder="请输入redirectUrl" /> - + import { BASE_API_PATH, TOKEN_KEY } from '@/utils/variable'; import { LocalStore, filterSelectNode } from '@/utils/comm'; +import { testIP } from '@/utils/validate'; import { getDepartmentList_api, @@ -1454,6 +1463,7 @@ import { import { randomString } from '@/utils/utils'; import { cloneDeep, difference } from 'lodash'; import { useMenuStore } from '@/store/menu'; +import { Rule } from 'ant-design-vue/lib/form'; const emit = defineEmits(['changeApplyType']); const routeQuery = useRoute().query; @@ -1836,7 +1846,7 @@ function getErrorNum( } } -const imageTypes = ref(['image/jpg', 'image/png']); +const imageTypes = ref(['image/jpg', 'image/png', 'image/jpeg']); const beforeLogoUpload = (file: any) => { const isType: any = imageTypes.value.includes(file.type); if (!isType) { @@ -1871,6 +1881,23 @@ function clearNullProp(obj: object) { } } } + +/** + * 验证IP合法性 + * @param _rule + * @param value + */ +const validateIP = (_rule: Rule, value: string) => { + const ipList = value?.split(/[\n,]/g).filter((i: string) => i && i.trim()); + const errorIPList = ipList.filter( + (f: string) => !testIP(f.replace(/\s*/g, '')), + ); + return new Promise((resolve, reject) => { + !errorIPList.length + ? resolve('') + : reject(`[${errorIPList}]不是正确的IP地址`); + }); +}; \ No newline at end of file diff --git a/src/views/device/Instance/Detail/Running/Property/Indicators.vue b/src/views/device/Instance/Detail/Running/Property/Indicators.vue index 95b6f9e7..3709ff01 100644 --- a/src/views/device/Instance/Detail/Running/Property/Indicators.vue +++ b/src/views/device/Instance/Detail/Running/Property/Indicators.vue @@ -33,8 +33,10 @@ }指标值`, }" :name="['metrics', index, 'value', 0]" - :label="item?.name || '指标值'" > + ({ metrics: [], }); @@ -132,8 +135,8 @@ watch( ) { const list = resp?.result.map((item: any) => { const val = Array.isArray(item?.value) - ? [item?.value] - : item?.value?.split(','); + ? item?.value + : (isNumber(item?.value) ? [item.value] : item?.value?.split(',')) return { ...item, value: val, @@ -172,7 +175,7 @@ watch( const handleSave = () => { formRef.value .validate() - .then(async () => { + .then(async (_data: any) => { loading.value = true; const list = (toRaw(modelRef)?.metrics || []).map((item: any) => { return { diff --git a/src/views/rule-engine/Scene/Save/action/Device/actions/FunctionItem.vue b/src/views/rule-engine/Scene/Save/action/Device/actions/FunctionItem.vue index 4ac0e416..d07b6a39 100644 --- a/src/views/rule-engine/Scene/Save/action/Device/actions/FunctionItem.vue +++ b/src/views/rule-engine/Scene/Save/action/Device/actions/FunctionItem.vue @@ -9,7 +9,7 @@ @select="onChange" > diff --git a/src/views/rule-engine/Scene/Save/action/Device/actions/WriteProperty.vue b/src/views/rule-engine/Scene/Save/action/Device/actions/WriteProperty.vue index d6533ba7..066e9287 100644 --- a/src/views/rule-engine/Scene/Save/action/Device/actions/WriteProperty.vue +++ b/src/views/rule-engine/Scene/Save/action/Device/actions/WriteProperty.vue @@ -41,7 +41,7 @@ @select="onValueChange" > @@ -112,7 +112,6 @@ const filterParamsData = (type?: string, data?: any[]): any[] => { item.children = _children; return _children.length ? true : false; } else if (item.type === type) { - // optionMap.current.set(item.id, item); return true; } return false; @@ -132,12 +131,12 @@ const handleOptions = computed(() => { if (_type === 'boolean') { return [ { - label: _item.trueText, - value: _item.trueValue, + label: _item.trueText || true, + value: _item.trueValue || true, }, { - label: _item.falseText, - value: _item.falseValue, + label: _item.falseText || false, + value: _item.falseValue || false, }, ]; } diff --git a/src/views/rule-engine/Scene/Save/action/Device/actions/index.vue b/src/views/rule-engine/Scene/Save/action/Device/actions/index.vue index e6004fd6..2e4c3bcb 100644 --- a/src/views/rule-engine/Scene/Save/action/Device/actions/index.vue +++ b/src/views/rule-engine/Scene/Save/action/Device/actions/index.vue @@ -22,12 +22,13 @@ showSearch placeholder="请选择功能" v-model:value="modelRef.message.functionId" - @select="functionSelect" + @change="functionSelect" > {{ item?.name }} @@ -54,6 +55,7 @@ showSearch placeholder="请选择属性" v-model:value="modelRef.message.properties[0]" + @change="propertySelect" > {{ item?.name }} @@ -130,8 +133,14 @@ const props = defineProps({ type: Number, default: 0, }, + productDetail: { + type: Object, + default: () => {}, + }, }); +const emit = defineEmits(['change']); + const formRef = ref(); const modelRef = reactive({ @@ -146,8 +155,19 @@ const modelRef = reactive({ const writeFormRef = ref(); -const functionSelect = () => { +const functionSelect = (val: any, options?: any) => { modelRef.message.inputs = []; + emit('change', { + propertiesName: options?.label, + propertiesValue: modelRef.propertiesValue, + }); +}; + +const propertySelect = (val: any, options?: any) => { + emit('change', { + propertiesName: options?.label, + propertiesValue: modelRef.propertiesValue, + }); }; const functionRules = [ @@ -239,11 +259,11 @@ const onMessageTypeChange = (val: string) => { }; watch( - () => props.values, + () => props.productDetail, (newVal) => { - if (newVal?.productDetail?.id) { - if (newVal?.selector === 'fixed') { - const id = newVal?.selectorValues?.[0]?.value; + if (newVal?.id) { + if (props.values?.selector === 'fixed') { + const id = props.values?.selectorValues?.[0]?.value; if (id) { detail(id).then((resp) => { if (resp.status === 200) { @@ -254,9 +274,7 @@ watch( }); } } else { - metadata.value = JSON.parse( - newVal?.productDetail?.metadata || '{}', - ); + metadata.value = JSON.parse(newVal?.metadata || '{}'); } } }, @@ -282,6 +300,13 @@ watch( const onWriteChange = (val: string) => { modelRef.propertiesValue = val; + emit('change', { + propertiesName: + deviceMessageType.value === 'INVOKE_FUNCTION' + ? _function.value?.name + : _property.value?.name, + propertiesValue: modelRef.propertiesValue, + }); }; const onFormSave = () => { @@ -295,19 +320,19 @@ const onFormSave = () => { reject(false); } } - // 处理三种情况的值的格式 - const obj = { + resolve({ message: { ...modelRef.message, ..._data.message, - propertiesName: - deviceMessageType.value === 'INVOKE_FUNCTION' - ? _function.value?.name - : _property.value?.name, - propertiesValue: modelRef.propertiesValue, }, - }; - resolve(obj); + }); + emit('change', { + propertiesName: + deviceMessageType.value === 'INVOKE_FUNCTION' + ? _function.value?.name + : _property.value?.name, + propertiesValue: modelRef.propertiesValue, + }); }) .catch((err: any) => { reject(err); diff --git a/src/views/rule-engine/Scene/Save/action/Device/device/Tag.vue b/src/views/rule-engine/Scene/Save/action/Device/device/Tag.vue index 8f8b701e..e1d4f346 100644 --- a/src/views/rule-engine/Scene/Save/action/Device/device/Tag.vue +++ b/src/views/rule-engine/Scene/Save/action/Device/device/Tag.vue @@ -177,15 +177,8 @@ const onValueChange = () => { value: item.value, }; }); - const arr = _data.map((item: any) => { - return { - column: item.name, - type: item.type, - value: item.value, - }; - }); emits('update:value', [{ value: newValue, name: '标签' }]); - emits('change', [{ value: newValue, name: '标签' }], arr); + emits('change', [{ value: newValue, name: '标签' }], _data); }; diff --git a/src/views/rule-engine/Scene/Save/action/Device/device/index.vue b/src/views/rule-engine/Scene/Save/action/Device/device/index.vue index 6963427d..13bf7a9e 100644 --- a/src/views/rule-engine/Scene/Save/action/Device/device/index.vue +++ b/src/views/rule-engine/Scene/Save/action/Device/device/index.vue @@ -13,18 +13,12 @@ @change="onSelectorChange" /> - - {}, + }, }); // save保存deviceDetail @@ -122,9 +120,7 @@ const modelRef = reactive({ selectorValues: undefined, deviceId: '', source: '', - relationName: '', upperKey: '', - message: undefined, }); const list = ref([]); @@ -166,10 +162,11 @@ const filterTree = (nodes: any[]) => { if ( it.children.find( (item: any) => - item.id.indexOf('deviceId' || 'device_id' || 'device_Id') > - -1, + item?.id?.indexOf( + 'deviceId' || 'device_id' || 'device_Id', + ) > -1, ) && - !it.children.find((item: any) => item.id.indexOf('boolean') > -1) + !it.children.find((item: any) => item?.id.indexOf('boolean') > -1) ) { return true; } @@ -197,7 +194,7 @@ const sourceChangeEvent = async () => { const productId = data.value?.branches?.[props.branchesName].then?.[props.thenName] ?.actions?.[props.name > 0 ? props.name - 1 : 0]?.device?.productId; - if (productId === props.values?.productDetail?.id) { + if (productId === props?.productDetail?.id) { const _data = await getParams(_params, unref(data)); builtInList.value = handleParamsData(filterTree(_data), 'id'); } else { @@ -205,7 +202,7 @@ const sourceChangeEvent = async () => { } }; -const filterType = async () => { +const filterType = async (newVal: any) => { const _list = TypeList.filter((item) => item.value === 'fixed'); if (unref(data)?.trigger?.type === 'device') { //关系 @@ -221,10 +218,9 @@ const filterType = async () => { _list.push(...array); } //标签 - const tag = JSON.parse( - props.values.productDetail?.metadata || '{}', - )?.tags; + const tag = JSON.parse(newVal?.metadata || '{}')?.tags; if (tag && tag.length !== 0) { + tagList.value = tag || []; const array = TypeList.filter((item) => item.value === 'tag'); _list.push(...array); } @@ -251,23 +247,23 @@ const filterType = async () => { } }; -const onSelectorChange = () => { +const onSelectorChange = (val: string) => { modelRef.selectorValues = undefined; + modelRef.selector = val; }; const onDeviceChange = (_detail: any) => { if (_detail) { if (_detail.id) { - modelRef.deviceId = _detail.id; + modelRef.deviceId = _detail?.id; modelRef.selectorValues = [ { value: _detail.id, name: _detail.name }, ] as any; - modelRef.message = {} as any; } else { modelRef.deviceId = ''; modelRef.selectorValues = [] as any; } - emits('save', unref(modelRef), _detail); + emits('save', unref(modelRef), { name: _detail.name }); } }; @@ -276,8 +272,7 @@ const onRelationChange = (val: any, options: any) => { modelRef.source = 'upper'; modelRef.selectorValues = val; modelRef.upperKey = 'scene.deviceId'; - modelRef.relationName = options.label; - emits('save', unref(modelRef), {}); + emits('save', unref(modelRef), { relationName: options.label }); }; const onTagChange = (val: any[], arr: any[]) => { @@ -285,27 +280,61 @@ const onTagChange = (val: any[], arr: any[]) => { modelRef.deviceId = 'deviceId'; modelRef.source = 'fixed'; } - emits('save', unref(modelRef), {}, arr ? { tagList: arr } : {}); + const tagName = arr.map((i, _index) => { + return `${_index !== 0 && _index !== (arr || []).length && i.type}${ + i.name + }为${i.value}`; + }); + emits( + 'save', + unref(modelRef), + {}, + arr ? { tagName: tagName.join('') } : {}, + ); }; const onVariableChange = (val: any, node: any) => { modelRef.deviceId = val; modelRef.selectorValues = [{ value: val, name: node.description }] as any; - emits('save', unref(modelRef), node); + emits('save', unref(modelRef), { name: node.description }); }; -watchEffect(() => { - Object.assign(modelRef, props.values); -}); +watch( + () => props.values, + (newVal) => { + Object.assign(modelRef, newVal); + }, + { + immediate: true, + deep: true, + }, +); watch( - () => props.values.productDetail, + () => props.productDetail, async (newVal) => { await sourceChangeEvent(); if (newVal) { - const metadata = JSON.parse(newVal?.metadata || '{}'); - tagList.value = metadata?.tags || []; - filterType(); + filterType(newVal); + } + }, + { + immediate: true, + deep: true, + }, +); + +watch( + () => [props.values, builtInList.value], + ([newVal1, newVal2]) => { + if (newVal2 && newVal2.length) { + const param = newVal1?.selectorValues?.[0]?.value; + const isVariable = (newVal2 || [])?.find((item: any) => { + return item.children.find((i: any) => i.id === param); + }); + if (isVariable) { + modelRef.selector = 'variable'; + } } }, { @@ -319,14 +348,14 @@ const onFormSave = () => { formRef.value .validate() .then(async (_data: any) => { - if(modelRef.selector === 'fixed'){ - if(!modelRef?.selectorValues?.[0]?.value){ - onlyMessage('请选择设备', 'error') + if (modelRef.selector === 'fixed') { + if (!modelRef?.selectorValues?.[0]?.value) { + onlyMessage('请选择设备', 'error'); reject(false); } else { resolve({ ..._data, - selectorValues: modelRef.selectorValues + selectorValues: modelRef.selectorValues, }); } } else { diff --git a/src/views/rule-engine/Scene/Save/action/Device/index.vue b/src/views/rule-engine/Scene/Save/action/Device/index.vue index de9c3580..7abb6074 100644 --- a/src/views/rule-engine/Scene/Save/action/Device/index.vue +++ b/src/views/rule-engine/Scene/Save/action/Device/index.vue @@ -23,7 +23,7 @@
diff --git a/yarn.lock b/yarn.lock index 35ef0063..cd047e8c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3700,8 +3700,8 @@ jetlinks-store@^0.0.3: jetlinks-ui-components@^1.0.5: version "1.0.5" - resolved "http://47.108.170.157:9013/jetlinks-ui-components/-/jetlinks-ui-components-1.0.5.tgz#593185f6313895485b59e9a79bc920c63374d84d" - integrity sha512-dkSOmatSPLHlV91YdTcHWO2wfwriUIZKEuLd5bJF2GsO9SvDMyJ2YJ4n/3fkklOoL5albhY37iX2Ot3A+7QYwA== + resolved "http://47.108.170.157:9013/jetlinks-ui-components/-/jetlinks-ui-components-1.0.5.tgz#6a3cc76cd6d98319e070da597bfcf146fa12d375" + integrity sha512-ASPqiWprK2v4/zQIYxOytjkVFgx+AkBaD5Klg2ik88y9uDAW/Ylvqa91v149znihU1y8Q2Nm2PXvUSJFD7HPpw== dependencies: "@vueuse/core" "^9.12.0" ant-design-vue "^3.2.15" From 3fc1e30027ccfc3292ab6aa39284736cbf4af956 Mon Sep 17 00:00:00 2001 From: wangshuaiswim Date: Mon, 27 Mar 2023 17:14:18 +0800 Subject: [PATCH 11/13] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E7=89=A9?= =?UTF-8?q?=E6=A8=A1=E5=9E=8B=E5=B1=9E=E6=80=A7=E6=8F=90=E4=BA=A4=E6=97=B6?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0type=E9=BB=98=E8=AE=A4=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Metadata/VirtualRuleParam/index.vue | 13 +++++++++---- .../components/Metadata/Base/Edit/ExpandsForm.vue | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/components/Metadata/VirtualRuleParam/index.vue b/src/components/Metadata/VirtualRuleParam/index.vue index 5452a0e5..751a1033 100644 --- a/src/components/Metadata/VirtualRuleParam/index.vue +++ b/src/components/Metadata/VirtualRuleParam/index.vue @@ -1,4 +1,7 @@