fix: 优化物模型-功能定义-输出

This commit is contained in:
XieYongHong 2023-07-07 11:09:28 +08:00
parent d76aa3f65c
commit 90df330400
8 changed files with 31 additions and 19 deletions

View File

@ -162,6 +162,7 @@
style="padding: 0" style="padding: 0"
danger danger
:pop-confirm="{ :pop-confirm="{
placement: 'topRight',
title: dataSource.length === 1 ? '这是最后一条数据了,确认删除?' : '确认删除?', title: dataSource.length === 1 ? '这是最后一条数据了,确认删除?' : '确认删除?',
onConfirm: async () => { onConfirm: async () => {
await removeItem(data.index, dataSource.length === 1); await removeItem(data.index, dataSource.length === 1);

View File

@ -90,7 +90,7 @@ export const useColumns = (type?: MetadataType, target?: 'device' | 'product', d
const hasId = oldValue.some((item) => item.id === value) const hasId = oldValue.some((item) => item.id === value)
if (value) { if (value) {
if (hasId) { if (hasId) {
return Promise.reject('标识重复') return Promise.reject('该标识存在')
} }
return Promise.resolve() return Promise.resolve()
} }

View File

@ -7,11 +7,13 @@
v-if="type === 'array'" v-if="type === 'array'"
v-model:value="_valueType.elementType" v-model:value="_valueType.elementType"
:unitOptions="options" :unitOptions="options"
placement="topRight"
@confirm="valueChange" @confirm="valueChange"
/> />
<DataTableObject <DataTableObject
v-else-if="type === 'object'" v-else-if="type === 'object'"
v-model:value="_valueType.properties" v-model:value="_valueType.properties"
placement="topRight"
:columns="[ :columns="[
{ title: '参数标识', dataIndex: 'id', type: 'text', width: 100 }, { title: '参数标识', dataIndex: 'id', type: 'text', width: 100 },
{ title: '参数名称', dataIndex: 'name', type: 'text', width: 100 }, { title: '参数名称', dataIndex: 'name', type: 'text', width: 100 },
@ -48,25 +50,28 @@
<OtherConfigInfo :value="data.record.valueType"></OtherConfigInfo> <OtherConfigInfo :value="data.record.valueType"></OtherConfigInfo>
</template> </template>
</DataTableObject> </DataTableObject>
<DataTableEnum v-else-if="type === 'enum'" v-model:value="_valueType" @confirm="valueChange"/> <DataTableEnum v-else-if="type === 'enum'" v-model:value="_valueType" placement="topRight" @confirm="valueChange"/>
<DataTableBoolean v-else-if="type === 'boolean'" v-model:value="_valueType" @confirm="valueChange"/> <DataTableBoolean v-else-if="type === 'boolean'" v-model:value="_valueType" placement="topRight" @confirm="valueChange"/>
<DataTableDouble <DataTableDouble
v-else-if="['float', 'double'].includes(type)" v-else-if="['float', 'double'].includes(type)"
:options="options" :options="options"
v-model:value="_valueType" v-model:value="_valueType"
placement="topRight"
@confirm="valueChange" @confirm="valueChange"
/> />
<DataTableInteger <DataTableInteger
v-else-if="['int', 'long'].includes(type)" v-else-if="['int', 'long'].includes(type)"
:options="options" :options="options"
v-model:value="_valueType.unit" v-model:value="_valueType.unit"
placement="topRight"
@confirm="valueChange" @confirm="valueChange"
/> />
<DataTableFile v-else-if="type === 'file'" v-model:value="_valueType.fileType" @confirm="valueChange"/> <DataTableFile v-else-if="type === 'file'" v-model:value="_valueType.fileType" placement="topRight" @confirm="valueChange"/>
<DataTableDate v-else-if="type === 'date'" v-model:value="_valueType.format" @confirm="valueChange"/> <DataTableDate v-else-if="type === 'date'" v-model:value="_valueType.format" placement="topRight" @confirm="valueChange"/>
<DataTableString <DataTableString
v-else-if="['string', 'password'].includes(type)" v-else-if="['string', 'password'].includes(type)"
v-model:value="_valueType.maxLength" v-model:value="_valueType.maxLength"
placement="topRight"
/> />
</div> </div>
</template> </template>

View File

@ -93,7 +93,7 @@ watch(() => JSON.stringify(dataSource.value), () => {
const hasId = oldValue.some((item) => item.id === value) const hasId = oldValue.some((item) => item.id === value)
if (value) { if (value) {
if (hasId) { if (hasId) {
return Promise.reject('标识重复') return Promise.reject('该标识存在')
} }
return Promise.resolve() return Promise.resolve()
} }
@ -127,10 +127,6 @@ watch(() => JSON.stringify(dataSource.value), () => {
{ {
title: '其他配置', title: '其他配置',
dataIndex: 'config', dataIndex: 'config',
type: 'components',
components: {
name: DataTypeObjectChild
}
}, },
{ {
title: '操作', title: '操作',

View File

@ -11,7 +11,7 @@
{{ data.record.range === 'true' ? '范围值' : '固定值'}} {{ data.record.range === 'true' ? '范围值' : '固定值'}}
</template> </template>
<template #value="{data}"> <template #value="{data}">
{{ data.record.range === 'true' ? data.record.value.toString() : data.record.value }} {{ data.record.range === 'true' ? data.record.value?.toString() : data.record.value }}
</template> </template>
<template #action="{data}"> <template #action="{data}">
<j-button <j-button

View File

@ -71,7 +71,7 @@ const showText = computed(() => {
if (props.value.range === 'false') { if (props.value.range === 'false') {
return props.value.value || '' return props.value.value || ''
} else { } else {
return props.value.value[0] ? props.value.value.join('-') : '' return props.value.value?.[0] ? props.value.value.join('-') : ''
} }
}) })

View File

@ -7,7 +7,7 @@
@visibleChange="visibleChange" @visibleChange="visibleChange"
> >
<template #content> <template #content>
<j-scrollbar height="350"> <j-scrollbar height="350" v-if="showMetrics || config.length > 0">
<j-collapse v-model:activeKey="activeKey"> <j-collapse v-model:activeKey="activeKey">
<j-collapse-panel v-for="(item, index) in config" :key="'store_'+index" :header="item.name"> <j-collapse-panel v-for="(item, index) in config" :key="'store_'+index" :header="item.name">
<j-table <j-table
@ -40,7 +40,14 @@
<Metrics ref="metricsRef" :value="myValue.expands?.metrics" :type="props.value?.valueType?.type"/> <Metrics ref="metricsRef" :value="myValue.expands?.metrics" :type="props.value?.valueType?.type"/>
</j-collapse-panel> </j-collapse-panel>
</j-collapse> </j-collapse>
</j-scrollbar> </j-scrollbar>
<div v-else style="padding-top: 24px">
<j-empty
description="没有动态配置项"
/>
</div>
</template> </template>
<j-button> <j-button>
<AIcon type="SettingOutlined" /> <AIcon type="SettingOutlined" />
@ -123,8 +130,13 @@ const getConfig = async () => {
if (resp.status === 200) { if (resp.status === 200) {
config.value = resp.result config.value = resp.result
if (resp.result.length && !configValue.value) { if (resp.result.length) {
activeKey.value = ['store_0'] activeKey.value = ['store_0']
} else if (showMetrics.value) {
activeKey.value = ['metrics']
}
if (resp.result.length && !configValue.value) {
resp.result.forEach(a => { resp.result.forEach(a => {
if (a.properties) { if (a.properties) {
a.properties.forEach(b => { a.properties.forEach(b => {
@ -132,8 +144,6 @@ const getConfig = async () => {
}) })
} }
}) })
} else if (showMetrics.value) {
activeKey.value = ['metrics']
} }
} }
} }

View File

@ -3825,8 +3825,8 @@ jetlinks-store@^0.0.3:
jetlinks-ui-components@^1.0.23, jetlinks-ui-components@^1.0.24: jetlinks-ui-components@^1.0.23, jetlinks-ui-components@^1.0.24:
version "1.0.24" version "1.0.24"
resolved "http://registry.jetlinks.cn/jetlinks-ui-components/-/jetlinks-ui-components-1.0.24.tgz#6633322daa90f3acd9a48aeab61c5eaf23c06e10" resolved "http://registry.jetlinks.cn/jetlinks-ui-components/-/jetlinks-ui-components-1.0.24.tgz#4fed08d639873b642911b808d94ef64856c62cd1"
integrity sha512-5KxeoLb9tnA4TGoX5Q1e43jNobPmGfHk+lxZsxEs50LTaOYVj0E6DSqCfaHbLHrXMdCcL45eKRCauRusVIXQTA== integrity sha512-bFdN1VdrOR8bmHlE81h5MoTSSwpXPS/qjW0ppDZU55qm8GtNszZfGBi8VeWD2Kvn1oTM43ldyVcGVqipl2DtMQ==
dependencies: dependencies:
"@vueuse/core" "^9.12.0" "@vueuse/core" "^9.12.0"
"@vueuse/router" "^9.13.0" "@vueuse/router" "^9.13.0"