fix: 物模型导入类型bug

This commit is contained in:
XieYongHong 2023-12-21 09:49:30 +08:00
parent 7a226b7af3
commit 97363057f0
6 changed files with 48 additions and 25 deletions

BIN
public/images/marker.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -20,11 +20,9 @@
},
}"
:icon="{
image: 'https://a.amap.com/jsapi_demos/static/images/poi-marker.png',
image: '/images/marker.png',
anchor: 'bottom-center',
size: [25, 34],
clipOrigin: [459, 92],
clipSize: [50, 68],
}"
></el-amap-label-marker
>
@ -35,6 +33,7 @@
<script lang="ts" setup>
import AmapComponent from '@/components/AMapComponent/index.vue';
import { getGo } from '@/api/device/dashboard';
import { getImage } from '@/utils/comm';
let point = ref();
const getMapData = async () => {
const res = await getGo({

View File

@ -70,12 +70,13 @@
v-if="type === 'device' || formModel.type === 'import'"
>
<j-select v-model:value="formModel.metadata">
<j-select-option value="jetlinks"
<!-- <j-select-option value="jetlinks"
>Jetlinks物模型</j-select-option
>
<j-select-option value="alink"
>阿里云物模型TSL</j-select-option
>
> -->
<j-select-option v-for="i in codecs" :value="i.id">{{ i.name }}</j-select-option>
</j-select>
</j-form-item>
<j-form-item
@ -177,6 +178,7 @@
</j-modal>
</template>
<script setup lang="ts" name="Import">
import { getCodecs } from '@/api/device/product';
import { saveMetadata } from '@/api/device/instance';
import {
queryNoPagingPost,
@ -214,7 +216,7 @@ interface Emits {
const props = defineProps<Props>();
const emits = defineEmits<Emits>();
const loading = ref(false);
const codecs = ref<any>([])
const _visible = computed({
get: () => {
return props.visible;
@ -300,7 +302,7 @@ const requiredCheck = (data:any) =>{
check = true
return
}else{
check = testType(item,index)
check = testType(item.valueType,index)
}
if(!item?.expands?.source){
onlyMessage(`属性定义第${index + 1}个数组中缺失expands.source属性`,'error');
@ -414,7 +416,7 @@ const requiredCheck = (data:any) =>{
check = true
return
}else{
testType(item?.valueType?.type,index)
testType(item?.valueType,index)
}
if(!item?.expands?.type){
onlyMessage(`标签定义第${index + 1}个数组中缺失expands.type属性`,'error');
@ -595,6 +597,12 @@ const metadataStore = useMetadataStore();
const handleImport = async () => {
formRef.value.validate().then(async (data: any) => {
let check
if((props.type === 'device' || formModel.type === 'import') &&
formModel.metadataType === 'script'){
check = formModel.metadata === 'jetlinks' ? requiredCheck(JSON.parse(formModel.import)) : aliCheck(JSON.parse(formModel.import))
}
if(!check){
const { id } = route.params || {};
if (data.metadata === 'alink') {
try {
@ -723,9 +731,16 @@ const handleImport = async () => {
);
}
}
}
});
};
onMounted(async()=>{
const res = await getCodecs()
if (res.status === 200) {
codecs.value = [{ id: 'jetlinks', name: '标准物模型' }].concat(res.result)
}
})
// const showProduct = computed(() => formModel.type === 'copy')
</script>
<style scoped lang="less">

View File

@ -4,15 +4,16 @@ export const testProperties = (data:any) =>{
}
export const testType = (data:any,index:number,isArray?:boolean,isObject?:boolean)=>{
if(data.valueType.type === 'boolean'){
if(!data?.valueType?.trueText || !data?.valueType?.trueValue || !data?.valueType?.falseText || !data?.valueType?.falseValue){
console.log(data,index)
if(data.type === 'boolean'){
if(!data?.trueText || !data?.trueValue || !data?.falseText || !data?.falseValue){
onlyMessage(`方法定义inputs第${index+1}个数组ValueType中缺失必填属性`,'error')
return true
}
}
if(data.valueType.type === 'enum' && !isObject){
if(data.valueType?.elements?.length > 0){
data.valueType.elements.forEach((a:any,b:number)=>{
if(data.type === 'enum' && !isObject){
if(data?.elements?.length > 0){
data.elements.forEach((a:any,b:number)=>{
if(!a.value || !a.text){
onlyMessage(`方法定义inputs第${index+1}个数组ValueType中elements缺失必填属性`,'error')
return true
@ -23,23 +24,23 @@ export const testType = (data:any,index:number,isArray?:boolean,isObject?:boolea
return true
}
}
if(data.valueType.type === 'array' && !isArray && !isObject){
if(data.valueType?.elementType){
testType(data.valueType.elementType,index,true)
if(data.type === 'array' && !isArray && !isObject){
if(data?.elementType){
testType(data.elementType,index,true)
}else{
onlyMessage(`方法定义inputs第${index+1}个数组ValueType中缺失elementType属性`,'error')
return true
}
}
if(data.valueType.type === 'file' && !isArray && !isObject){
if(!data.valueType?.fileType){
if(data.type === 'file' && !isArray && !isObject){
if(!data?.fileType){
onlyMessage(`方法定义inputs第${index+1}个数组ValueType中缺失fileType属性`,'error')
return true
}
}
if(data.valueType.type === 'object' && !isArray && !isObject){
if(data.type === 'object' && !isArray && !isObject){
if(data?.valueType?.properties?.length > 0){
return testObject(data.valueType.properties,index)
return testObject(data.properties,index)
}else{
onlyMessage(`方法定义inputs第${index+1}个数组ValueType中缺失properties属性`,'error')
return true

View File

@ -7,7 +7,7 @@
style="margin-right: 12px"
/>
<template v-if="shakeLimit.enabled">
<j-input-number :min="1" :max="100" :precision="0" size="small" v-model:value="shakeLimit.time" style="width: 38px" />
<j-input-number :min="1" :precision="0" size="small" v-model:value="shakeLimit.time" style="width: 38px" />
<span>秒内发送</span>
<j-input-number :min="1" :max="100" :precision="0" size="small" v-model:value="shakeLimit.threshold" style="width: 38px" />
<span>次及以上时处理</span>

View File

@ -36,6 +36,7 @@
v-model:value='paramsValue.termType'
@select='termsTypeSelect'
/>
<div v-if="!['notnull','isnull'].includes(paramsValue.termType)">
<DoubleParamsDropdown
v-if='showDouble'
icon='icon-canshu'
@ -59,6 +60,7 @@
v-model:source='paramsValue.value.source'
@select='valueSelect'
/>
</div>
<j-popconfirm title='确认删除?' @confirm='onDelete' :overlayStyle='{minWidth: "180px"}'>
<div v-show='showDelete' class='button-delete'> <AIcon type='CloseOutlined' /></div>
</j-popconfirm>
@ -82,12 +84,12 @@ import { ContextKey, arrayParamsKey, timeTypeKeys } from './util'
import { useSceneStore } from 'store/scene'
import { storeToRefs } from 'pinia';
import { Form } from 'jetlinks-ui-components'
import {indexOf, isArray, isObject, isString, pick , cloneDeep } from 'lodash-es'
import {indexOf, isArray, isObject, isString, pick} from 'lodash-es'
import {cloneDeep} from "lodash";
const sceneStore = useSceneStore()
const { data: formModel } = storeToRefs(sceneStore)
const formItemContext = Form.useInjectFormItemContext();
type Emit = {
(e: 'update:value', data: TermsType): void
}
@ -328,6 +330,11 @@ const termsTypeSelect = (e: { key: string, name: string }) => {
newValue.value = undefined
}
}
if(
['isnull','notull'].includes(e.key)
){
newValue.value.value = 1
}
paramsValue.value = newValue
emit('update:value', { ...paramsValue })
@ -337,6 +344,7 @@ const termsTypeSelect = (e: { key: string, name: string }) => {
}
const valueSelect = (v: any, label: string, labelObj: Record<number, any>, option: any) => {
console.log(labelObj,option,paramsValue.value,'____123')
if (paramsValue.value?.source === 'metric') {
paramsValue.value.metric = option?.id
}