fix: 修改设备透传默认脚本

* fix: 优化物模型-全屏编辑

* fix: 优化物模型-枚举校验

* fix: 修改设备透传默认脚本
This commit is contained in:
XieYongHong 2023-07-27 09:52:39 +08:00 committed by GitHub
parent f2514fce8f
commit 9b9b316a5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 87 additions and 24 deletions

View File

@ -5,6 +5,7 @@
visible
width="70vw"
title="编辑规则"
:getContainer="(node) => fullRef || node"
@cancel="handleCancel"
:destroyOnClose="true"
>
@ -57,6 +58,7 @@
import Editor from './Editor/index.vue';
import Debug from './Debug/index.vue';
import Operator from './Operator/index.vue';
import { FULL_CODE } from 'jetlinks-ui-components/es/DataTable'
interface Emits {
(e: 'save', data: string | undefined): void;
@ -73,6 +75,7 @@ const props = defineProps({
const _value = ref<string | undefined>(props.value);
const _disabled = ref<boolean>(true);
const fullRef = inject(FULL_CODE);
const handleCancel = () => {
emit('close');

View File

@ -8,6 +8,7 @@
:options="options"
allowClear
style="width: 100%"
:getPopupContainer="getPopupContainer"
@change='selectChange'
/>
<j-time-picker
@ -16,6 +17,7 @@
allowClear
valueFormat="HH:mm:ss"
style="width: 100%"
:getPopupContainer="getPopupContainer"
@change='timeChange'
/>
<j-date-picker
@ -25,6 +27,7 @@
showTime
valueFormat="YYYY-MM-DD HH:mm:ss"
style="width: 100%"
:getPopupContainer="getPopupContainer"
@change='dateChange'
/>
<j-input-number
@ -93,6 +96,7 @@
cancel-text="取消"
v-model:visible="modalVis"
width="700px"
:getPopupContainer="getPopupContainer"
@cancel="modalVis = false"
@ok="handleItemModalSubmit"
:zIndex='1100'
@ -149,6 +153,10 @@ const props = defineProps({
placeholder: {
type: String,
default: () => '',
},
getPopupContainer: {
type: Function,
default: undefined
}
});
// type Props = {

View File

@ -164,7 +164,16 @@ import { isBoolean } from 'lodash';
import { onlyMessage } from '@/utils/comm';
const defaultValue =
'//解码函数\r\nfunction decode(context) {\r\n //原始报文\r\n var buffer = context.payload();\r\n // 转为json\r\n // var json = context.json();\r\n //mqtt 时通过此方法获取topic\r\n // var topic = context.topic();\r\n\r\n // 提取变量\r\n // var topicVars = context.pathVars("/{deviceId}/**",topic)\r\n //温度属性\r\n var temperature = buffer.getShort(3) * 10;\r\n //湿度属性\r\n var humidity = buffer.getShort(6) * 10;\r\n return {\r\n "temperature": temperature,\r\n "humidity": humidity\r\n };\r\n}\r\n';
`//注册设备下行数据监听器,当平台下发指令给设备时,回调将被调用,用于构造下发给设备的报文
codec.onDownstream(function(ctx){
});
//,,,.
codec.onUpstream(function(ctx){
});
`;
const el = ref<HTMLElement | null>(null);
const { toggle } = useFullscreen(el);

View File

@ -123,7 +123,16 @@ import { isBoolean } from 'lodash';
import { onlyMessage } from '@/utils/comm';
const defaultValue =
'//解码函数\r\nfunction decode(context) {\r\n //原始报文\r\n var buffer = context.payload();\r\n // 转为json\r\n // var json = context.json();\r\n //mqtt 时通过此方法获取topic\r\n // var topic = context.topic();\r\n\r\n // 提取变量\r\n // var topicVars = context.pathVars("/{deviceId}/**",topic)\r\n //温度属性\r\n var temperature = buffer.getShort(3) * 10;\r\n //湿度属性\r\n var humidity = buffer.getShort(6) * 10;\r\n return {\r\n "temperature": temperature,\r\n "humidity": humidity\r\n };\r\n}\r\n';
`//注册设备下行数据监听器,当平台下发指令给设备时,回调将被调用,用于构造下发给设备的报文
codec.onDownstream(function(ctx){
});
//,,,.
codec.onUpstream(function(ctx){
});
`;
const el = ref<HTMLElement | null>(null);
const { toggle } = useFullscreen(el);

View File

@ -341,7 +341,6 @@ export const useColumns = (type?: MetadataType, target?: 'device' | 'product', n
const fieldIndex = Number(field[1])
const values = dataSource.find((item, index) => index === fieldIndex)
return validatorConfig(values.output)
}
}]

View File

@ -12,6 +12,7 @@
<script setup name="ConstraintSelect">
import { set, get } from 'lodash-es'
import {FULL_CODE} from "jetlinks-ui-components/es/DataTable";
const props = defineProps({
value: {
@ -25,6 +26,7 @@ const props = defineProps({
})
const emit = defineEmits(['update:value'])
const fullRef = inject(FULL_CODE);
const myValue = ref()

View File

@ -3,6 +3,7 @@
v-model:value="value"
:options="options"
:placeholder="placeholder"
:getPopupContainer="(node) => fullRef || node"
@change="change"
/>
</template>
@ -10,7 +11,7 @@
<script setup lang="ts" name="SelectColumnn">
import type { PropType } from 'vue';
import { ref, watch } from 'vue';
import { FULL_CODE } from 'jetlinks-ui-components/es/DataTable'
type Emits = {
(e: 'update:value', data: Record<string, any>): void;
@ -18,6 +19,8 @@ type Emits = {
};
type SizeType = 'small' | 'middle' | 'large' | undefined;
const fullRef = inject(FULL_CODE);
const emit = defineEmits<Emits>();
const props = defineProps({
value: {

View File

@ -3,6 +3,7 @@
v-model:value="value"
:options="options"
:placeholder="placeholder"
:get-popup-container="(node) => fullRef || node"
@change="change"
/>
</template>
@ -10,7 +11,7 @@
<script setup lang="ts" name="SelectColumnn">
import type { PropType } from 'vue';
import { ref, watch } from 'vue';
import { FULL_CODE } from 'jetlinks-ui-components/es/DataTable'
type Emits = {
(e: 'update:value', data: Record<string, any>): void;
@ -36,7 +37,7 @@
});
const value = ref(props.value.async);
const fullRef = inject(FULL_CODE);
const change = (v: string) => {
emit('update:value', {...props.value, async: value.value});
emit('change', v);

View File

@ -5,11 +5,13 @@
{ label: '固定值', value: 'false' },
{ label: '范围值', value: 'true' },
]"
:get-popup-container="(node) => fullRef || node"
@select="select"
/>
</template>
<script name="BooleanSelect" setup>
import { FULL_CODE } from 'jetlinks-ui-components/es/DataTable'
const props = defineProps({
value: {
@ -17,8 +19,10 @@ const props = defineProps({
default: () => ({})
}
})
const emit = defineEmits(['update:value'])
const fullRef = inject(FULL_CODE);
const myValue = ref()
const select = (e) => {
emit('update:value', {

View File

@ -90,6 +90,14 @@ const columns: any = [
form: {
required: true,
rules: [
{
callback(rule:any,value: any) {
if (!value) {
return Promise.reject('请输入指标名称')
}
return Promise.resolve()
}
},
{ max: 64, message: '最多可输入64个字符' },
]
},
@ -107,11 +115,11 @@ const columns: any = [
required: true,
rules: [
{
validator(_: any, value: any) {
callback(rule:any,value: any) {
if (!value) {
return Promise.reject('请配置指标')
}
return validatorConfig(value, true)
return Promise.resolve()
}
},
]
@ -148,7 +156,7 @@ const addItem = () => {
const data = {
id: undefined,
name: undefined,
range: 'false',
range: false,
value: undefined,
}

View File

@ -6,6 +6,7 @@
<j-popconfirm-modal
:show-cancel="false"
body-style="width: 300px"
:get-popup-container="(node) => fullRef || node"
@confirm="confirm"
>
<template #content>
@ -39,6 +40,7 @@ import type { PropType } from 'vue';
import Item from './item.vue'
import {Form} from "jetlinks-ui-components";
import {cloneDeep} from "lodash";
import { FULL_CODE } from 'jetlinks-ui-components/es/DataTable'
type ValueType = number | Array<number | undefined> | undefined;
@ -55,7 +57,7 @@ const props = defineProps({
const emit = defineEmits<Emit>();
const formItemContext = Form.useInjectFormItemContext();
const fullRef = inject(FULL_CODE);
const formData = reactive<{
@ -89,6 +91,7 @@ const confirm = () => {
return new Promise((resolve, reject) => {
formRef.value.validate().then(() => {
const value = props.value.range === true ? formData.rangeValue : formData.value
console.log('confirm',value, props.value)
emit('update:value', {
...props.value,
value: value

View File

@ -23,17 +23,20 @@
{ label: '否', value: 'false'},
{ label: '是', value: 'true'},
]"
:get-popup-container="(node) => fullRef || node"
/>
<j-date-picker
v-else-if="type === 'date' "
v-model:value="myValue"
show-time
placeholder="请选择"
:get-popup-container="(node) => fullRef || node"
@change="change"
/>
</template>
<script setup name="MetricValueItem">
import { Form } from 'jetlinks-ui-components'
import {FULL_CODE} from "jetlinks-ui-components/es/DataTable";
const props = defineProps({
value: {
@ -47,6 +50,7 @@ const formItemContext = Form.useInjectFormItemContext();
const type = inject('metricsType')
const myValue = ref(props.value)
const fullRef = inject(FULL_CODE);
const change = () => {
// formItemContext.onFieldChange()

View File

@ -3,6 +3,7 @@
body-style="padding-top:4px;width:600px;"
placement="topRight"
:disabled="disabled"
:get-popup-container="(node) => fullRef || node"
@confirm="confirm"
@cancel="cancel"
@visibleChange="visibleChange"
@ -27,6 +28,7 @@
label: a.text,
value: a.value,
}))"
:get-popup-container="(node) => fullRef || node"
/>
</template>
</j-table>
@ -63,6 +65,7 @@ import {useInstanceStore} from "store/instance";
import {getMetadataConfig, getMetadataDeviceConfig} from "@/api/device/product";
import ModelButton from '@/views/device/components/Metadata/Base/components/ModelButton.vue'
import {omit} from "lodash-es";
import { FULL_CODE } from 'jetlinks-ui-components/es/DataTable'
const props = defineProps({
value: {
@ -83,6 +86,8 @@ const props = defineProps({
},
})
const fullRef = inject(FULL_CODE);
const type = inject('_metadataType')
const productStore = useProductStore()

View File

@ -16,6 +16,7 @@
label: a.text,
value: a.value,
}))"
:get-popup-container="(node) => fullRef || node"
/>
</template>
</j-table>
@ -29,6 +30,7 @@ import type { PropType } from "vue";
import { defineExpose } from 'vue'
import {getMetadataConfig, getMetadataDeviceConfig} from "@/api/device/product";
import { omit } from 'lodash-es'
import { FULL_CODE } from 'jetlinks-ui-components/es/DataTable'
const props = defineProps({
type: {
@ -47,7 +49,7 @@ const props = defineProps({
const productStore = useProductStore()
const deviceStore = useInstanceStore()
const fullRef = inject(FULL_CODE);
const config = ref<any>([])
const configValue = ref(props.record?.expands)

View File

@ -4,17 +4,20 @@
v-model:value="myValue"
:options="PropertySource"
placeholder="请选择来源"
@change="onChange"
:disabled="disabled"
:get-popup-container="(node) => fullRef || node"
@change="onChange"
>
</j-select>
<j-popconfirm-modal
v-if="myValue != 'manual'"
@confirm="confirm"
:bodyStyle="{
width: '450px',
height: myValue === 'rule' ? '300px' : '80px',
}"
:get-popup-container="(node) => fullRef || node"
placement="topLeft"
@confirm="confirm"
>
<template #content>
<j-scrollbar v-if="myValue">
@ -39,6 +42,7 @@
import { isNoCommunity } from '@/utils/utils';
import VirtualRule from './VirtualRule/index.vue';
import { Form } from 'jetlinks-ui-components';
import { FULL_CODE } from 'jetlinks-ui-components/es/DataTable'
const PropertySource: { label: string; value: string }[] = isNoCommunity
? [
@ -72,6 +76,8 @@ type Emit = {
(e: 'update:value', data: Record<string, any>): void;
};
const fullRef = inject(FULL_CODE);
const props = defineProps({
value: {
type: Object,

View File

@ -7,6 +7,7 @@
{ label: '写', value: 'write'},
{ label: '上报', value: 'report'},
]"
:get-popup-container="(node) => fullRef || node"
placeholder="请选择读写类型"
@change="onChange"
/>
@ -15,6 +16,7 @@
<script setup lang="ts">
import type {PropType} from "vue";
import { FULL_CODE } from 'jetlinks-ui-components/es/DataTable'
type Emit = {
(e: 'update:value', data: any): void
@ -28,7 +30,7 @@ const props = defineProps({
})
const emit = defineEmits<Emit>()
const fullRef = inject(FULL_CODE);
const myValue = ref<Array<string>>([])
const onChange = () =>{

View File

@ -7,6 +7,7 @@
<j-radio-group
button-style="solid"
v-model:value="data.type"
@change="() => { getNetworkEcharts(data) }"
>
<j-radio-button value="bytesRead">
上行
@ -105,6 +106,7 @@ const serverData = reactive({
const pickerTimeChange = (value: any) => {
data.value.time.type = undefined;
getNetworkEcharts(data.value);
};
const getNetworkEcharts = async (val: any) => {
@ -220,13 +222,6 @@ watch(
{ immediate: true, deep: true },
);
// watchEffect(() => {
// const time = data.value.time.time
// if (time && Array.isArray(time) && time.length === 2 && time[0] && props.serviceId) {
//
// }
// })
</script>
<style lang="less" scoped>

View File

@ -3755,8 +3755,8 @@ jetlinks-ui-components@^1.0.23:
jetlinks-ui-components@^1.0.27:
version "1.0.27"
resolved "http://registry.jetlinks.cn/jetlinks-ui-components/-/jetlinks-ui-components-1.0.27.tgz#c2e62ebf26d9465aed5489fdde37297738d57f2b"
integrity sha512-IVWCPfC5awTIIMQ5t6V5KTHLjfENj0owb6HsHxqRLrHebz7FaDng6oNfebvn17P+gHGVwwMemTCF7b8PpWFiwg==
resolved "http://registry.jetlinks.cn/jetlinks-ui-components/-/jetlinks-ui-components-1.0.27.tgz#03a2a9ba49d669c6d63e6c5d5b144f31a27253df"
integrity sha512-I9A05UXUtjRsSWU/jgRDfDNeCv2ZV21/PV4FEV3UG5bQOYa1/CvL7Lr7F7iB1m4Hjn9mnXTqAQ2pU11b6T2U8Q==
dependencies:
"@vueuse/core" "^9.12.0"
"@vueuse/router" "^9.13.0"