From bcc0c517fe26b9de09588ba38e69fc2f4949a6df Mon Sep 17 00:00:00 2001 From: wanggang <76527413@qq.com> Date: Fri, 17 Jul 2020 17:00:25 +0800 Subject: [PATCH] update Former-commit-id: 643fffeb10dd7cbdcd0b9cfeca381f740c0b136d Former-commit-id: 1ad3c694544086d64d8ed670f489cb09b56e5455 --- .../Models/EditSceneCommandModel.cs | 2 +- .../Models/EditSceneTiggerModel.cs | 2 +- .../Models/EditGlobalSceneCommandModel.cs | 2 +- .../Models/EditGlobalSceneTiggerModel.cs | 2 +- projects/WebMVC/wwwroot/js/iot.js | 61 ++++++++++++------- .../wwwroot/router/admin/setting/index.html | 11 ++++ .../WebMVC/wwwroot/router/shared/edit.html | 2 +- .../router/shared/edit/selectlist.html | 8 +-- .../WebMVC/wwwroot/router/shared/list.html | 2 +- 9 files changed, 58 insertions(+), 34 deletions(-) create mode 100644 projects/WebMVC/wwwroot/router/admin/setting/index.html diff --git a/projects/IoT.Shared/Application/Models/EditSceneCommandModel.cs b/projects/IoT.Shared/Application/Models/EditSceneCommandModel.cs index 680c7bc2..68c148db 100644 --- a/projects/IoT.Shared/Application/Models/EditSceneCommandModel.cs +++ b/projects/IoT.Shared/Application/Models/EditSceneCommandModel.cs @@ -7,7 +7,7 @@ namespace Application.Models [Display(Name = "场景命令")] public class EditSceneCommandModel : EditModel { - [Display(Name = "场景节点")] + [Display(Name = "节点")] [DataType("SelectList")] [Required(ErrorMessage = nameof(RequiredAttribute))] public Guid? NodeId { get; set; } diff --git a/projects/IoT.Shared/Application/Models/EditSceneTiggerModel.cs b/projects/IoT.Shared/Application/Models/EditSceneTiggerModel.cs index 95a31ae0..2576d407 100644 --- a/projects/IoT.Shared/Application/Models/EditSceneTiggerModel.cs +++ b/projects/IoT.Shared/Application/Models/EditSceneTiggerModel.cs @@ -10,7 +10,7 @@ namespace Application.Models public class EditSceneTiggerModel : EditModel { [DataType("SelectList")] - [Display(Name = "触发器节点")] + [Display(Name = "节点")] [Required(ErrorMessage = nameof(RequiredAttribute))] public Guid? NodeId { get; set; } diff --git a/projects/IoTCenter/Application/Models/EditGlobalSceneCommandModel.cs b/projects/IoTCenter/Application/Models/EditGlobalSceneCommandModel.cs index 9b557183..54a84460 100644 --- a/projects/IoTCenter/Application/Models/EditGlobalSceneCommandModel.cs +++ b/projects/IoTCenter/Application/Models/EditGlobalSceneCommandModel.cs @@ -12,7 +12,7 @@ namespace IoTCenter.Application.Models [Required(ErrorMessage = nameof(RequiredAttribute))] public Guid? SceneId { get; set; } - [Display(Name = "命令节点")] + [Display(Name = "节点")] [DataType("SelectList")] [Required(ErrorMessage = nameof(RequiredAttribute))] public Guid? NodeId { get; set; } diff --git a/projects/IoTCenter/Application/Models/EditGlobalSceneTiggerModel.cs b/projects/IoTCenter/Application/Models/EditGlobalSceneTiggerModel.cs index 67170ec1..2c6ad711 100644 --- a/projects/IoTCenter/Application/Models/EditGlobalSceneTiggerModel.cs +++ b/projects/IoTCenter/Application/Models/EditGlobalSceneTiggerModel.cs @@ -19,7 +19,7 @@ namespace IoTCenter.Application.Models public string Name { get; set; } [DataType("SelectList")] - [Display(Name = "设备节点")] + [Display(Name = "节点")] [Required(ErrorMessage = nameof(RequiredAttribute))] public Guid? DeviceNodeId { get; set; } diff --git a/projects/WebMVC/wwwroot/js/iot.js b/projects/WebMVC/wwwroot/js/iot.js index 2d854854..64eb6a3d 100644 --- a/projects/WebMVC/wwwroot/js/iot.js +++ b/projects/WebMVC/wwwroot/js/iot.js @@ -95,25 +95,42 @@ deviceInfo['摄像头'] = 'iot-camera'; deviceInfo['摄像头'] = 'gateway'; deviceInfo['串口控制器'] = 'iot-serial-port'; /// -//function updateSelect(action, id, value) { -// var select = $('select#' + id); -// if (select.length) { -// select.remove("option[value!='']"); -// if (value) { -// var url = config.baseUrl + '/IoTCenter/Admin/Ajax/' + action + '?parentId='+ value; -// $.getJSON(url, function (data) { -// $.each(data, function (i, v) { -// select.append(''); -// }); -// }); -// } -// select.change(); -// } -//} -//$(document).on('change', 'select#productId', function (e) { -// var value = $(this).val(); -// updateSelect('getProductApiJson', 'apiId',value); -//}); -$(document).on('change', 'select', function (e) { - $(this).parents('form').find("button[type='submit']").click(); -}); \ No newline at end of file +function updateSelect(action, id, value) { + var select = $('select#' + id); + if (select.length) { + select.find("option[value!=null]").remove(); + if (value) { + var url = config.baseUrl + '/IoTCenter/Admin/Ajax/' + action + '?parentId='+ value; + $.getJSON(url, function (data) { + $.each(data, function (i, v) { + select.append(''); + }); + }); + } + select.change(); + } +} +$(document).on('change', 'select#productId', function (e) { + var value = $(this).val(); + updateSelect('getProductApiJson', 'apiId',value); +}); +$(document).on('change', 'select#nodeId', function (e) { + var value = $(this).val(); + updateSelect('getDeviceJson', 'deviceId', value); + updateSelect('getCommandJson', 'commandId', value); + if ($(this).parents('form.GlobalSceneCommand').length===0) { + updateSelect('getSceneJson', 'sceneId', value); + } +}); +$(document).on('change', 'select#deviceNodeId', function (e) { + var value = $(this).val(); + updateSelect('getDeviceJson', 'deviceId', value); +}); +$(document).on('change', 'select#deviceId', function (e) { + var value = $(this).val(); + updateSelect('getApiJson', 'apiId', value); + updateSelect('getDataJson', 'dataId', value); +}); +//$(document).on('change', 'select', function (e) { +// $(this).parents('form').find("button[type='submit']").click(); +//}); \ No newline at end of file diff --git a/projects/WebMVC/wwwroot/router/admin/setting/index.html b/projects/WebMVC/wwwroot/router/admin/setting/index.html new file mode 100644 index 00000000..86a74ebc --- /dev/null +++ b/projects/WebMVC/wwwroot/router/admin/setting/index.html @@ -0,0 +1,11 @@ + + \ No newline at end of file diff --git a/projects/WebMVC/wwwroot/router/shared/edit.html b/projects/WebMVC/wwwroot/router/shared/edit.html index dbe92f65..7a31fa94 100644 --- a/projects/WebMVC/wwwroot/router/shared/edit.html +++ b/projects/WebMVC/wwwroot/router/shared/edit.html @@ -3,7 +3,7 @@

{{title}}

-
+