问题描述
一段时间后,我为我的项目创建了这个角度模式:
{
"schema": {
"type": "object","properties": {
"name": {
"title": "Name","type": "string","required": true,"default": "customname"
},"buses": {
"type": "array","items": {
"title": "Overwrite","type": "object","properties": {
"bus_name": {
"title": "Bus Name","description": "Optional name for your bus"
},"bus_IP": {
"title": "Bus IP","placeholder": "10.0.0.1","description": "Bus IP address in your local network"
},"bus_port": {
"title": "Bus Port","type": "integer","default": 6000,"required": true
},"bus_cdn": {
"title": "Bus Control Device","placeholder": "1.50","description": "Give an arbitrary number for a virtual device on your bus that will send and receive all commands and states for plugin. Must be in format 'subnet.device' and not coincide with existing device numbers."
},"devices": {
"description": "Add all devices you need on this bus","type": "array","items": {
"type": "object","properties": {
"device_name": {
"title": "Device Name","description": "Your custom name for device. Will be used as a default name in homekit.","required": true
},"device_address": {
"title": "Device address","description": "Device address on the bus,must be in form 'subnet.device',e. g. 1.1","device_type": {
"title": "Device type","description": "Select an appropriate device type to see more options","oneOf": [{
"title": "Dry Contact","enum": ["drycontact"]
},{
"title": "Relay Lightbulb","enum": ["relaylightbulb"]
},{
"title": "Relay Dimmable Lightbulb","enum": ["relaydimmablelightbulb"]
},{
"title": "Sensor 8in1","enum": ["sensor8in1"]
},{
"title": "Relay Lock","enum": ["relaylock"]
}
],"nc": {
"title": "Dry contact type","type": "boolean","description": "Allows to flip logic for which state of contact is active","default": true
},"channel": {
"title": "Channel","description": "The channel of relay on which your device is located"
},"area": {
"title": "Area","default": 1,"description": "Change it in case your relay supports areas"
},"drycontact_type": {
"title": "Dry contact purpose","description": "Select dry contact purpose","oneOf": [{
"title": "Leak Sensor","enum": ["leaksensor"]
},{
"title": "Motion Sensor","enum": ["motionsensor"]
}
]
}
}
}
}
}
}
}
}
},"layout": [{
"type": "array","title": "Buses","expandable": true,"expanded": true,"items": [{
"type": "flex","title": "Bus","items": [
"buses[].bus_name",{
"key": "buses[].bus_IP","type": "ipv4"
},"buses[].bus_port","buses[].bus_cdn",{
"type": "fieldset","title": "Devices","expanded": false,"items": [{
"type": "array","items": [{
"key": "buses[].devices[].device_name"
},{
"key": "buses[].devices[].device_address"
},{
"key": "buses[].devices[].device_type"
},{
"key": "buses[].devices[].area","condition": {
"functionBody": "return (['drycontact'].includes(model.buses[arrayIndices[0]].devices[arrayIndices[1]].device_type))"
}
},{
"key": "buses[].devices[].channel","condition": {
"functionBody": "return (['relaylightbulb','relaydimmablelightbulb','drycontact','relaylock'].includes(model.buses[arrayIndices[0]].devices[arrayIndices[1]].device_type))"
}
},{
"key": "buses[].devices[].drycontact_type",{
"key": "buses[].devices[].nc","type": "radios-inline","titleMap": [{
"name": "normally closed","value": true
},{
"name": "normally open","value": false
}
],"condition": {
"functionBody": "return (['relaylock','drycontact'].includes(model.buses[arrayIndices[0]].devices[arrayIndices[1]].device_type))"
}
}
]
}
]
}
]
}
]
}
]
}
它的行为就像我想要的 - 将元素添加到数组和条件显示条目选项 - 除了一个奇怪的细节:在我将“设备”添加到我的数组并保存此配置后,下次我只打开它的第一个将显示一个,其余的将在我为我添加到架构的每个设备再次按下“添加”按钮后出现(并编辑已经在破坏输出架构结构的设备)。我完全不明白为什么会发生这种行为,而我所有改变形式的尝试都以某种方式破坏了它。我做错了什么?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)