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

View File

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

View File

@ -164,7 +164,16 @@ import { isBoolean } from 'lodash';
import { onlyMessage } from '@/utils/comm'; import { onlyMessage } from '@/utils/comm';
const defaultValue = 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 el = ref<HTMLElement | null>(null);
const { toggle } = useFullscreen(el); const { toggle } = useFullscreen(el);

View File

@ -123,7 +123,16 @@ import { isBoolean } from 'lodash';
import { onlyMessage } from '@/utils/comm'; import { onlyMessage } from '@/utils/comm';
const defaultValue = 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 el = ref<HTMLElement | null>(null);
const { toggle } = useFullscreen(el); 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 fieldIndex = Number(field[1])
const values = dataSource.find((item, index) => index === fieldIndex) const values = dataSource.find((item, index) => index === fieldIndex)
return validatorConfig(values.output) return validatorConfig(values.output)
} }
}] }]

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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