diff --git a/projects/IoTNode/Startup.cs b/projects/IoTNode/Startup.cs index 3f7aa808..21c05464 100644 --- a/projects/IoTNode/Startup.cs +++ b/projects/IoTNode/Startup.cs @@ -44,9 +44,9 @@ namespace IoTNode services.AddTransient(); if (Env.IsDevelopment()) { - //services.AddHostedService(o => o.GetService()); - //services.AddHostedService(o => o.GetService()); - //services.AddHostedService(o => o.GetService()); + services.AddHostedService(o => o.GetService()); + services.AddHostedService(o => o.GetService()); + services.AddHostedService(o => o.GetService()); services.AddHostedService(o => o.GetService()); } else diff --git a/projects/Platform/Views/Home/Index.cshtml b/projects/Platform/Views/Home/Index.cshtml index cb2759f5..698b7c8d 100644 --- a/projects/Platform/Views/Home/Index.cshtml +++ b/projects/Platform/Views/Home/Index.cshtml @@ -1,11 +1,4 @@ -@inject IHostEnvironment env -@if (!Context.Request.Path.ToString().StartsWith("/Home")) -{ - Layout = null; - @Html.Raw(System.IO.File.ReadAllText(System.IO.Path.Combine(env.ContentRootPath, "wwwroot", "index.html"))) -} -else -{ +@{ HideBread = true; @section scripts{ diff --git a/projects/Platform/Views/Shared/_Layout.cshtml b/projects/Platform/Views/Shared/_Layout.cshtml index b644f9e0..ff739afc 100644 --- a/projects/Platform/Views/Shared/_Layout.cshtml +++ b/projects/Platform/Views/Shared/_Layout.cshtml @@ -93,7 +93,7 @@
- + @Html.DropDownList("UserCurrentOrganNumber", list, new { @class = "organ submit", style = "height:30px;width:160px;font-size:15px;background-color:#343a40;color: rgba(255,255,255,.8);font-size:14px;" })
diff --git a/projects/Platform/wwwroot/js/site.js b/projects/Platform/wwwroot/js/site.js index 578f2929..f74a0485 100644 --- a/projects/Platform/wwwroot/js/site.js +++ b/projects/Platform/wwwroot/js/site.js @@ -1,4 +1,10 @@ -function urlContent2(baseUrl,path) { +if (!String.prototype.endsWith) { + String.prototype.endsWith = function (endStr) { + var d = this.length - endStr.length; + return (d >= 0 && this.lastIndexOf(endStr) == d); + }; +} +function urlContent2(baseUrl, path) { if (!path.startsWith("/dfs/")) { return baseUrl + path; } @@ -96,34 +102,39 @@ $(function () { } }); }); -//delete confrim +//query $(function () { - $("th button.delete,td button.delete").click(function () { + $("button.action.query").click(function () { var form = $(this).parents("form"); - layer.confirm("确认删除?", { - title: '警告', - icon: 3, - btn: ['确认', '取消'], - btnAlign: 'c' - }, function () { - form.submit(); - }, function () { - }); - return false; + form.attr('action', $(this).attr('data-action')); + form.attr('method', 'get'); + form[0].submit(); }); - $("button.confirm").click(function () { +}); +//delete confrim +$(function () { + $("button.action.confirm").click(function () { var form = $(this).parents("form"); + var list = form.find('tbody input:checked[name]'); form.attr('action', $(this).attr('data-action')); - var msg = "确认" + $(this).text() + "?"; - layer.confirm(msg, { - title: '警告', - icon: 3, - btn: ['确认', '取消'], - btnAlign: 'c' - }, function () { - form.submit(); - }, function () { - }); + form.attr('method', 'post'); + var msg = "确认" + $(this).text() + "?"; + + if (!list.length) { + Swal.fire('没有选中任何记录!'); + } + else { + Swal.fire({ + text: msg, + confirmButtonText: '确定', + cancelButtonText: '取消', + showCancelButton: true + }).then(function (value) { + if (value.isConfirmed) { + form[0].submit(); + } + }); + } return false; }); }); @@ -138,13 +149,57 @@ function InitControls() { $.datetimepicker.setLocale('zh'); $('.edit-date').datetimepicker({ timepicker: false, format: 'Y-m-d' }); $('.edit-datetime').datetimepicker({ format: 'Y-m-d H:i' }); + $('.edit-time').datetimepicker({ datepicker: false, format: 'H:i' }); } // - $(".edit-multiSelect").treeMultiselect({ enableSelectAll: true, searchable: true, selectAllText: "全选", unselectAllText: "反选" }); + $(".edit-multiSelect").each(function () { + $(this).treeMultiselect({ enableSelectAll: true, searchable: true, selectAllText: "全选", unselectAllText: "反选" }); + }); // - $('select.search').select2({ - theme: "bootstrap4", - language: "zh-CN" + $('select.select2bs4').each(function () { + var allow = $(this).attr('data-allow-input') === 'true'; + $(this).select2({ + tags: allow, + theme: "bootstrap4", + language: "zh-CN", + placeholder: '请选择', + allowClear: true + }).change(function () { + $(this).valid(); + });; + }); + $('select.select2bs4.search').each(function () { + var url = $(this).attr('data-search-url'); + $(this).select2({ + theme: "bootstrap4", + language: "zh-CN", + placeholder: '请选择', + allowClear: true, + minimumInputLength: 2, + ajax: { + url: url, + data: function (params) { + var query = { + search: params.term, + type: 'public' + } + return query; + }, + dataType: 'json', + processResults: function (data) { + return { + results: Enumerable.from(data).select(function (o) { return { id: o.value, text: o.text }; }).toArray() + }; + } + } + }); + }); + // + $('select[data-remote-target]').each(function () { + var sourceId = $(this).attr('data-remote-source'); + var targetId = $(this).attr('data-remote-target'); + var url = $(this).attr('data-remote-url'); + change(sourceId, targetId, url); }); // $('input.cron').each(function () { @@ -192,7 +247,7 @@ function InitEditor(K) { var emtpyImage = $(this).attr('data-emptyImage'); var baseUrl = $(this).attr('data-baseUrl'); var isRequired = $(this).attr('data-val-required') !== undefined; - var editor = K.editor({ + var editor = KindEditor.editor({ allowImageUpload: true, formatUploadUrl: false, uploadJson: uploadUrl @@ -200,13 +255,13 @@ function InitEditor(K) { KindEditor(btn_id).click(function () { editor.loadPlugin('insertfile', function () { editor.plugin.fileDialog({ - fileUrl: K('#' + id).val(), + fileUrl: $('#' + id).val(), clickFn: function (url, title) { $('#' + id).attr('value', url); if (isRequired) { $('#' + id).parents('form').validate().element('#' + id); } - $(image_id).attr('src', urlContent2(baseUrl,url)); + $(image_id).attr('src', urlContent2(baseUrl, url)); $(image_id).parent('a').attr('href', urlContent2(baseUrl, url)); editor.hideDialog(); } @@ -228,7 +283,7 @@ function InitEditor(K) { var uploadUrl = $(this).attr('data-uploadUrl'); var baseUrl = $(this).attr('data-baseUrl'); var isRequired = $(this).attr('data-val-required') !== undefined; - var editor = K.editor({ + var editor = KindEditor.editor({ allowImageUpload: true, formatUploadUrl: false, uploadJson: uploadUrl @@ -236,7 +291,7 @@ function InitEditor(K) { KindEditor(btn_id).click(function () { editor.loadPlugin('insertfile', function () { editor.plugin.fileDialog({ - fileUrl: K('#' + id).val(), + fileUrl: $('#' + id).val(), clickFn: function (url, title) { $('#' + id).attr('value', url); if (isRequired) { @@ -257,7 +312,7 @@ function InitEditor(K) { var id = '#file_' + $(this).attr('id'); var btn_id = '#' + $(this).attr('id'); var uploadUrl = $(this).attr('data-action'); - var editor = K.editor({ + var editor = KindEditor.editor({ allowFileManager: false, allowImageUpload: true, formatUploadUrl: false, @@ -267,9 +322,9 @@ function InitEditor(K) { editor.loadPlugin('image', function () { editor.plugin.imageDialog({ showRemote: false, - imageUrl: K(id).val(), + imageUrl: $(id).val(), clickFn: function (url, title, width, height, border, align) { - K('id').val(url); + $('id').val(url); editor.hideDialog(); location.reload(); } @@ -277,12 +332,11 @@ function InitEditor(K) { }); }); }); - } KindEditor.ready(function (K) { InitEditor(K); }); -$(function(){ +$(function () { $("button.list-export").click(function () { var form = $(this).parents("form"); form.attr('target', '_blank'); @@ -296,6 +350,11 @@ $(function(){ $(function () { InitControls(); }); + +$('body').on('change', 'select.submit', function () { + $(this).parents('form').submit(); +}); + $('body').on('click', '.cmd', function () { $.getJSON($(this).attr('href'), function (response) { console.log(response); @@ -305,15 +364,34 @@ $('body').on('click', '.cmd', function () { }); return false; }); - +function change(sourceId, targetId, url) { + if (document.getElementById(targetId)) { + $('#' + sourceId).change(function () { + var id = $(this).find(':selected').val(); + update(url, id, '#' + targetId); + }); + } + if (document.getElementById('Query_' + targetId)) { + $('#Query_' + sourceId).change(function () { + var id = $(this).find(':selected').val(); + update(url, id, '#Query_' + targetId); + }); + } +} function update(url, parent, targetId) { - $(targetId).find('option').not('[value=""]').remove(); + if (!document.querySelector(targetId)) { + return; + } + $(targetId).find('option').not('[value=""]').remove().change(); if (url !== null) { - url += '?parentId=' + encodeURI(parent); + url = URI(url).addSearch("parentId", parent); + $('#loadingToast:hidden ').show(); $.getJSON(url, function (data) { $.each(data, function (i, v) { $(targetId).append(''); }); + }).always(function () { + $('#loadingToast:visible').hide(); }); } } @@ -321,7 +399,4 @@ function reset() { $('form').removeData('validator'); $('form').removeData('unobtrusiveValidation'); $.validator.unobtrusive.parse('form'); -} -$('body').on('change', 'select.submit', function () { - $(this).parents('form').submit(); -}); \ No newline at end of file +} \ No newline at end of file