fix: bug#16301

This commit is contained in:
XieYongHong 2023-07-13 20:18:12 +08:00
parent d9c6dc02a9
commit 4eb7d061e1
7 changed files with 43 additions and 17 deletions

View File

@ -448,6 +448,7 @@ const parentTabsChange = (next?: Function) => {
content: '页面改动数据未保存',
okText: '保存',
cancelText: '不保存',
zIndex: 1400,
onOk: () => {
handleSaveClick(next as Function)
},

View File

@ -37,6 +37,17 @@ const type = {
report: '上报',
};
export const validatorConfig = (value: any) => {
if (value.type === 'enum' && !value.elements?.length) {
return Promise.reject('请添加枚举项')
}
if (value.type === 'array' && !value.elementType?.type) {
return Promise.reject('请选择元素类型')
}
return Promise.resolve()
}
export const handleTypeValue = (type:string, value: any = {}) => {
let obj: any = {}
switch (type) {
@ -213,9 +224,18 @@ export const useColumns = (type?: MetadataType, target?: 'device' | 'product', n
form: {
required: true,
rules: [{
validator(_: any, value: any) {
callback(rule: any, value: any, dataSource: any[]) {
const field = rule.field.split('.')
const fieldIndex = Number(field[1])
const record = dataSource[fieldIndex]
console.log(record)
if (!record.valueType.properties.length) {
return Promise.reject('请添加配置参数')
}
return Promise.resolve()
// if (!value?.type) {
return Promise.reject('请选择数据类型')
// }
// return Promise.resolve()
}

View File

@ -20,7 +20,7 @@ import { ValueObject } from '../index'
import ConfigModal from '@/views/device/components/Metadata/Base/components/ConfigModal.vue'
import ModelButton from '@/views/device/components/Metadata/Base/components/ModelButton.vue'
import {omit} from "lodash-es";
import {TypeStringMap} from "../../columns";
import {TypeStringMap, validatorConfig} from "../../columns";
const columns = [
{
@ -93,10 +93,14 @@ const columns = [
form: {
required: true,
rules: [{
validator(_: any, value: any) {
console.log(value)
callback(rule: any, value: any, dataSource: any[]) {
const field = rule.field.split('.')
const fieldIndex = Number(field[1])
const record = dataSource[fieldIndex]
console.log(record)
return validatorConfig(record.valueType)
// if (!value?.type) {
return Promise.reject('请选择数据类型')
// return Promise.reject('')
// }
// return Promise.resolve()
}

View File

@ -14,7 +14,7 @@
<!-- </div>-->
<!-- </j-tooltip>-->
<!-- </div>-->
<j-tabs class="metadataNav" :activeKey="metadataStore.tabActiveKey" destroyInactiveTabPane type="card" @change="tabsChange">
<j-tabs class="metadataNav" :activeKey="tabActiveKey" destroyInactiveTabPane type="card" @change="tabsChange">
<template #rightExtra>
<j-space>
<PermissionButton v-if="type === 'device' && instanceStore.detail?.independentMetadata"
@ -68,6 +68,7 @@ const props = defineProps<Props>()
const permission = computed(() => props.type === 'device' ? 'device/Instance' : 'device/Product')
const visible = ref(false)
const cat = ref(false)
const tabActiveKey = ref('properties')
provide('_metadataType', props.type)
@ -89,7 +90,7 @@ const resetMetadata = async () => {
const tabsChange = (e: string) => {
EventEmitter.emit('MetadataTabs', () => {
metadataStore.tabActiveKey = e;
tabActiveKey.value = e;
})
}

View File

@ -107,7 +107,7 @@ const columns = [
terms: [
{
column: 'id',
termType: 'alarm-bind-rule$not',
termType: 'alarm-bind-rule',
value: props.data?.id,
},
{ column: 'triggerType', termType: 'eq', value: 'manual' }
@ -160,7 +160,7 @@ const terms = [
terms: [
{
column: 'id',
termType: 'alarm-bind-rule$not',
termType: 'alarm-bind-rule',
value: props.data?.id,
},
{

View File

@ -337,9 +337,9 @@ const orgCol = [
const otherCol = [
...columns,
{
title: '组织名称',
dataIndex: 'sourceId',
key: 'sourceId',
title: '场景名称',
dataIndex: 'targetId',
key: 'targetId',
search: {
type: 'select',
options: async () => {
@ -354,8 +354,8 @@ const otherCol = [
});
if (resp.status === 200) {
return resp.result.data.map((item: any) => ({
label: item.sourceName,
value: item.sourceId,
label: item.targetName,
value: item.targetId,
}));
}
return [];

View File

@ -3837,8 +3837,8 @@ jetlinks-ui-components@^1.0.23:
jetlinks-ui-components@^1.0.24:
version "1.0.24"
resolved "http://registry.jetlinks.cn/jetlinks-ui-components/-/jetlinks-ui-components-1.0.24.tgz#4163dab623d0b51e9280195f69b3eef8f039a637"
integrity sha512-hecgnwgrtPMwa08kYTQQuFrRajSGi6R0mJiFRpyPY0481C7AllhbHDdLscVSxsS7vuielznelUN6bWsonVuK9w==
resolved "http://registry.jetlinks.cn/jetlinks-ui-components/-/jetlinks-ui-components-1.0.24.tgz#920ba82872b918eb6f592813cdb08ddefc9a822c"
integrity sha512-x8J/jduzSeBJ7faxspaWgi/MbKiNl3aG1Mhw2TWIcr3y9qVuPS8CcQB0OHOikAFlHM+iUg7lJtfYFj11kdz4FA==
dependencies:
"@vueuse/core" "^9.12.0"
"@vueuse/router" "^9.13.0"