fix: 物模型导入类型bug
This commit is contained in:
parent
7a226b7af3
commit
97363057f0
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
|
@ -20,11 +20,9 @@
|
||||||
},
|
},
|
||||||
}"
|
}"
|
||||||
:icon="{
|
:icon="{
|
||||||
image: 'https://a.amap.com/jsapi_demos/static/images/poi-marker.png',
|
image: '/images/marker.png',
|
||||||
anchor: 'bottom-center',
|
anchor: 'bottom-center',
|
||||||
size: [25, 34],
|
size: [25, 34],
|
||||||
clipOrigin: [459, 92],
|
|
||||||
clipSize: [50, 68],
|
|
||||||
}"
|
}"
|
||||||
></el-amap-label-marker
|
></el-amap-label-marker
|
||||||
>
|
>
|
||||||
|
@ -35,6 +33,7 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import AmapComponent from '@/components/AMapComponent/index.vue';
|
import AmapComponent from '@/components/AMapComponent/index.vue';
|
||||||
import { getGo } from '@/api/device/dashboard';
|
import { getGo } from '@/api/device/dashboard';
|
||||||
|
import { getImage } from '@/utils/comm';
|
||||||
let point = ref();
|
let point = ref();
|
||||||
const getMapData = async () => {
|
const getMapData = async () => {
|
||||||
const res = await getGo({
|
const res = await getGo({
|
||||||
|
@ -47,4 +46,4 @@ const getMapData = async () => {
|
||||||
getMapData();
|
getMapData();
|
||||||
</script>
|
</script>
|
||||||
<style scoped>
|
<style scoped>
|
||||||
</style>
|
</style>
|
|
@ -70,12 +70,13 @@
|
||||||
v-if="type === 'device' || formModel.type === 'import'"
|
v-if="type === 'device' || formModel.type === 'import'"
|
||||||
>
|
>
|
||||||
<j-select v-model:value="formModel.metadata">
|
<j-select v-model:value="formModel.metadata">
|
||||||
<j-select-option value="jetlinks"
|
<!-- <j-select-option value="jetlinks"
|
||||||
>Jetlinks物模型</j-select-option
|
>Jetlinks物模型</j-select-option
|
||||||
>
|
>
|
||||||
<j-select-option value="alink"
|
<j-select-option value="alink"
|
||||||
>阿里云物模型TSL</j-select-option
|
>阿里云物模型TSL</j-select-option
|
||||||
>
|
> -->
|
||||||
|
<j-select-option v-for="i in codecs" :value="i.id">{{ i.name }}</j-select-option>
|
||||||
</j-select>
|
</j-select>
|
||||||
</j-form-item>
|
</j-form-item>
|
||||||
<j-form-item
|
<j-form-item
|
||||||
|
@ -177,6 +178,7 @@
|
||||||
</j-modal>
|
</j-modal>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts" name="Import">
|
<script setup lang="ts" name="Import">
|
||||||
|
import { getCodecs } from '@/api/device/product';
|
||||||
import { saveMetadata } from '@/api/device/instance';
|
import { saveMetadata } from '@/api/device/instance';
|
||||||
import {
|
import {
|
||||||
queryNoPagingPost,
|
queryNoPagingPost,
|
||||||
|
@ -214,7 +216,7 @@ interface Emits {
|
||||||
const props = defineProps<Props>();
|
const props = defineProps<Props>();
|
||||||
const emits = defineEmits<Emits>();
|
const emits = defineEmits<Emits>();
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
|
const codecs = ref<any>([])
|
||||||
const _visible = computed({
|
const _visible = computed({
|
||||||
get: () => {
|
get: () => {
|
||||||
return props.visible;
|
return props.visible;
|
||||||
|
@ -300,7 +302,7 @@ const requiredCheck = (data:any) =>{
|
||||||
check = true
|
check = true
|
||||||
return
|
return
|
||||||
}else{
|
}else{
|
||||||
check = testType(item,index)
|
check = testType(item.valueType,index)
|
||||||
}
|
}
|
||||||
if(!item?.expands?.source){
|
if(!item?.expands?.source){
|
||||||
onlyMessage(`属性定义第${index + 1}个数组中缺失expands.source属性`,'error');
|
onlyMessage(`属性定义第${index + 1}个数组中缺失expands.source属性`,'error');
|
||||||
|
@ -414,7 +416,7 @@ const requiredCheck = (data:any) =>{
|
||||||
check = true
|
check = true
|
||||||
return
|
return
|
||||||
}else{
|
}else{
|
||||||
testType(item?.valueType?.type,index)
|
testType(item?.valueType,index)
|
||||||
}
|
}
|
||||||
if(!item?.expands?.type){
|
if(!item?.expands?.type){
|
||||||
onlyMessage(`标签定义第${index + 1}个数组中缺失expands.type属性`,'error');
|
onlyMessage(`标签定义第${index + 1}个数组中缺失expands.type属性`,'error');
|
||||||
|
@ -595,6 +597,12 @@ const metadataStore = useMetadataStore();
|
||||||
|
|
||||||
const handleImport = async () => {
|
const handleImport = async () => {
|
||||||
formRef.value.validate().then(async (data: any) => {
|
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 || {};
|
const { id } = route.params || {};
|
||||||
if (data.metadata === 'alink') {
|
if (data.metadata === 'alink') {
|
||||||
try {
|
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')
|
// const showProduct = computed(() => formModel.type === 'copy')
|
||||||
</script>
|
</script>
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
|
|
|
@ -4,15 +4,16 @@ export const testProperties = (data:any) =>{
|
||||||
}
|
}
|
||||||
|
|
||||||
export const testType = (data:any,index:number,isArray?:boolean,isObject?:boolean)=>{
|
export const testType = (data:any,index:number,isArray?:boolean,isObject?:boolean)=>{
|
||||||
if(data.valueType.type === 'boolean'){
|
console.log(data,index)
|
||||||
if(!data?.valueType?.trueText || !data?.valueType?.trueValue || !data?.valueType?.falseText || !data?.valueType?.falseValue){
|
if(data.type === 'boolean'){
|
||||||
|
if(!data?.trueText || !data?.trueValue || !data?.falseText || !data?.falseValue){
|
||||||
onlyMessage(`方法定义inputs第${index+1}个数组ValueType中缺失必填属性`,'error')
|
onlyMessage(`方法定义inputs第${index+1}个数组ValueType中缺失必填属性`,'error')
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(data.valueType.type === 'enum' && !isObject){
|
if(data.type === 'enum' && !isObject){
|
||||||
if(data.valueType?.elements?.length > 0){
|
if(data?.elements?.length > 0){
|
||||||
data.valueType.elements.forEach((a:any,b:number)=>{
|
data.elements.forEach((a:any,b:number)=>{
|
||||||
if(!a.value || !a.text){
|
if(!a.value || !a.text){
|
||||||
onlyMessage(`方法定义inputs第${index+1}个数组ValueType中elements缺失必填属性`,'error')
|
onlyMessage(`方法定义inputs第${index+1}个数组ValueType中elements缺失必填属性`,'error')
|
||||||
return true
|
return true
|
||||||
|
@ -23,23 +24,23 @@ export const testType = (data:any,index:number,isArray?:boolean,isObject?:boolea
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(data.valueType.type === 'array' && !isArray && !isObject){
|
if(data.type === 'array' && !isArray && !isObject){
|
||||||
if(data.valueType?.elementType){
|
if(data?.elementType){
|
||||||
testType(data.valueType.elementType,index,true)
|
testType(data.elementType,index,true)
|
||||||
}else{
|
}else{
|
||||||
onlyMessage(`方法定义inputs第${index+1}个数组ValueType中缺失elementType属性`,'error')
|
onlyMessage(`方法定义inputs第${index+1}个数组ValueType中缺失elementType属性`,'error')
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(data.valueType.type === 'file' && !isArray && !isObject){
|
if(data.type === 'file' && !isArray && !isObject){
|
||||||
if(!data.valueType?.fileType){
|
if(!data?.fileType){
|
||||||
onlyMessage(`方法定义inputs第${index+1}个数组ValueType中缺失fileType属性`,'error')
|
onlyMessage(`方法定义inputs第${index+1}个数组ValueType中缺失fileType属性`,'error')
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(data.valueType.type === 'object' && !isArray && !isObject){
|
if(data.type === 'object' && !isArray && !isObject){
|
||||||
if(data?.valueType?.properties?.length > 0){
|
if(data?.valueType?.properties?.length > 0){
|
||||||
return testObject(data.valueType.properties,index)
|
return testObject(data.properties,index)
|
||||||
}else{
|
}else{
|
||||||
onlyMessage(`方法定义inputs第${index+1}个数组ValueType中缺失properties属性`,'error')
|
onlyMessage(`方法定义inputs第${index+1}个数组ValueType中缺失properties属性`,'error')
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
style="margin-right: 12px"
|
style="margin-right: 12px"
|
||||||
/>
|
/>
|
||||||
<template v-if="shakeLimit.enabled">
|
<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>
|
<span>秒内发送</span>
|
||||||
<j-input-number :min="1" :max="100" :precision="0" size="small" v-model:value="shakeLimit.threshold" style="width: 38px" />
|
<j-input-number :min="1" :max="100" :precision="0" size="small" v-model:value="shakeLimit.threshold" style="width: 38px" />
|
||||||
<span>次及以上时,处理</span>
|
<span>次及以上时,处理</span>
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
v-model:value='paramsValue.termType'
|
v-model:value='paramsValue.termType'
|
||||||
@select='termsTypeSelect'
|
@select='termsTypeSelect'
|
||||||
/>
|
/>
|
||||||
|
<div v-if="!['notnull','isnull'].includes(paramsValue.termType)">
|
||||||
<DoubleParamsDropdown
|
<DoubleParamsDropdown
|
||||||
v-if='showDouble'
|
v-if='showDouble'
|
||||||
icon='icon-canshu'
|
icon='icon-canshu'
|
||||||
|
@ -59,6 +60,7 @@
|
||||||
v-model:source='paramsValue.value.source'
|
v-model:source='paramsValue.value.source'
|
||||||
@select='valueSelect'
|
@select='valueSelect'
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
<j-popconfirm title='确认删除?' @confirm='onDelete' :overlayStyle='{minWidth: "180px"}'>
|
<j-popconfirm title='确认删除?' @confirm='onDelete' :overlayStyle='{minWidth: "180px"}'>
|
||||||
<div v-show='showDelete' class='button-delete'> <AIcon type='CloseOutlined' /></div>
|
<div v-show='showDelete' class='button-delete'> <AIcon type='CloseOutlined' /></div>
|
||||||
</j-popconfirm>
|
</j-popconfirm>
|
||||||
|
@ -82,12 +84,12 @@ import { ContextKey, arrayParamsKey, timeTypeKeys } from './util'
|
||||||
import { useSceneStore } from 'store/scene'
|
import { useSceneStore } from 'store/scene'
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
import { Form } from 'jetlinks-ui-components'
|
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 sceneStore = useSceneStore()
|
||||||
const { data: formModel } = storeToRefs(sceneStore)
|
const { data: formModel } = storeToRefs(sceneStore)
|
||||||
const formItemContext = Form.useInjectFormItemContext();
|
const formItemContext = Form.useInjectFormItemContext();
|
||||||
|
|
||||||
type Emit = {
|
type Emit = {
|
||||||
(e: 'update:value', data: TermsType): void
|
(e: 'update:value', data: TermsType): void
|
||||||
}
|
}
|
||||||
|
@ -328,15 +330,21 @@ const termsTypeSelect = (e: { key: string, name: string }) => {
|
||||||
newValue.value = undefined
|
newValue.value = undefined
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(
|
||||||
|
['isnull','notull'].includes(e.key)
|
||||||
|
){
|
||||||
|
newValue.value.value = 1
|
||||||
|
}
|
||||||
paramsValue.value = newValue
|
paramsValue.value = newValue
|
||||||
|
|
||||||
emit('update:value', { ...paramsValue })
|
emit('update:value', { ...paramsValue })
|
||||||
formItemContext.onFieldChange()
|
formItemContext.onFieldChange()
|
||||||
formModel.value.options!.when[props.branchName].terms[props.whenName].terms[props.termsName][1] = e.name
|
formModel.value.options!.when[props.branchName].terms[props.whenName].terms[props.termsName][1] = e.name
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const valueSelect = (v: any, label: string, labelObj: Record<number, any>, option: any) => {
|
const valueSelect = (v: any, label: string, labelObj: Record<number, any>, option: any) => {
|
||||||
|
console.log(labelObj,option,paramsValue.value,'____123')
|
||||||
if (paramsValue.value?.source === 'metric') {
|
if (paramsValue.value?.source === 'metric') {
|
||||||
paramsValue.value.metric = option?.id
|
paramsValue.value.metric = option?.id
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue