SysLogs.cshtml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. @using System.Web.Optimization
  2. @using ShwasherSys.Authorization.Permissions
  3. @using ShwasherSys.Models.Layout
  4. @using ShwasherSys.Models.Modal
  5. @{
  6. /**/
  7. ViewBag.ActiveMenu = PermissionNames.PagesSystemSysLog; //The menu item will be active for this page.
  8. ViewBag.Title = "系统操作日志";
  9. string serviceNames = ViewBag.ServiceNames;
  10. //string methodNames = ViewBag.MethodNames;
  11. var searchItems = new SearchFormViewModal(new List<SearchItem>()
  12. {
  13. new SearchItem("methodName","操作名称"),
  14. new SearchItem("userName","用户名"),
  15. new SearchItem("clientName","客户端" ),
  16. new SearchItem("browserInfo","浏览器")
  17. });
  18. }
  19. @section css{
  20. @Styles.Render("~/Content/datetimepicker/css")
  21. <style>
  22. .search-unit.dateISO {
  23. float: left;
  24. }
  25. .search-unit {
  26. float: left;
  27. margin-left: 10px;
  28. }
  29. .search-unit input {
  30. border-radius: 0 !important;
  31. }
  32. .search-unit .select2-container--default .select2-selection--single {
  33. border-radius: 0;
  34. height: 26px;
  35. }
  36. .search-unit .KeyField + .select2-container--default .select2-selection--single {
  37. border-right: 0;
  38. }
  39. .search-unit .keyWords + .select2-container--default .select2-selection--multiple {
  40. border-radius: 0;
  41. height: 26px;
  42. }
  43. .search-unit .input-group .input-group-addon {
  44. border-radius: 0;
  45. /*border-color: #aaa;*/
  46. background-color: #eee;
  47. }
  48. .search-unit .input-group .input-group-addon {
  49. border-top-left-radius: 3px!important;
  50. border-bottom-left-radius: 3px!important;
  51. }
  52. .search-unit .input-group input:last-child {
  53. border-top-right-radius: 3px!important;
  54. border-bottom-right-radius: 3px!important;
  55. }
  56. </style>
  57. }
  58. <div class="table-box mr-4 iwb-bootstrap-table">
  59. @* @Html.Action("ToolMenu", "Layout", new { pageName = ViewBag.ActiveMenu })*@
  60. <div class="btn-toolbar row" id="tableTool" role="toolbar" aria-label="Toolbar with button groups">
  61. <div class="input-group input-group-sm hidden-sm hidden-xs hidden-sm" id="SearchBox" style="position: relative; width: 100%; max-width: 100%">
  62. <form id="SearchForm">
  63. @{
  64. <div class="search-unit" data-index="2" style="width: 40%">
  65. <div class="input-group input-group-sm text-non" style="position: relative; width: 100%;">
  66. <input class="form-control KeyField" id="KeyField-2" name="KeyField-2" style="display: none" disabled="disabled" value="ExecutionTime" />
  67. <input class="form-control KeyField" id="KeyField-3" name="KeyField-3" style="display: none" disabled="disabled" value="ExecutionTime" />
  68. <input class="form-control ExpType" id="FieldType-2" name="FieldType-2" style="display: none" value="5" />
  69. <input class="form-control ExpType" id="FieldType-3" name="FieldType-3" style="display: none" value="5" />
  70. <input class="form-control ExpType" id="ExpType-2" name="ExpType-2" style="display: none" value="4" />
  71. <input class="form-control ExpType" id="ExpType-3" name="ExpType-3" style="display: none" value="5" />
  72. <span class="input-group-addon" style="">执行时间</span>
  73. <input autocomplete="off" class="form-control dateISO KeyWords" id="KeyWords-2" name="KeyWords-2" placeholder="起始时间" value="" type="text">
  74. <span class="input-group-addon" style="border-radius: 0 !important;">至</span>
  75. <input autocomplete="off" class="form-control dateISO KeyWords" id="KeyWords-3" name="KeyWords-3" placeholder="终止时间" value="" type="text">
  76. </div>
  77. </div>
  78. <div class="search-unit" data-index="4" style="width: 28%">
  79. <div class="input-group input-group-sm text-non" style="position: relative; width: 100%;">
  80. <input class="form-control KeyField" id="KeyField-4" name="KeyField-4" style="display: none" disabled="disabled" value="ServiceName" />
  81. <input class="form-control ExpType" id="FieldType-4" name="FieldType-4" style="display: none" value="0" />
  82. <input class="form-control ExpType" id="ExpType-4" name="ExpType-4" style="display: none" value="0" />
  83. <span class="input-group-addon">日志名称</span>
  84. <select id="KeyWords-4" name="KeyWords-4" class="form-control KeyWords">
  85. <option value="">请选择...</option>
  86. @Html.Raw(serviceNames)
  87. </select>
  88. </div>
  89. </div>
  90. @*<div class="search-unit" data-index="5" style="width: 20%">
  91. <div class="input-group input-group-sm text-non" style="position: relative; width: 100%;">
  92. <input class="form-control KeyField" id="KeyField-5" name="KeyField-5" style="display: none" disabled="disabled" value="methodName"/>
  93. <input class="form-control ExpType" id="FieldType-5" name="FieldType-5" style="display: none" value="0"/>
  94. <input class="form-control ExpType" id="ExpType-5" name="ExpType-5" style="display: none" value="0"/>
  95. <span class="input-group-addon">操作名称</span>
  96. <select id="KeyWords-5" name="KeyWords-5" class="form-control KeyWords">
  97. @Html.Raw(methodNames)
  98. </select>
  99. </div>
  100. </div>*@
  101. var selectItemStr = "{";
  102. if (searchItems.SearchItems != null)
  103. {
  104. int i = 0;
  105. <div class="search-unit" data-index="1" style="width: 28%">
  106. <div class="input-group input-group-sm text-non" style="position: relative; width: 100%;">
  107. <select id="KeyField-1" name="KeyField-1" class="form-control KeyField" style="width: 100px !important">
  108. @foreach (var item in searchItems.SearchItems)
  109. {
  110. int isSelect = 0;
  111. if (!string.IsNullOrEmpty(item.SelectItemStr))
  112. {
  113. selectItemStr += (selectItemStr == "{" ? "" : ",") + item.SelectItemStr;
  114. isSelect = 1;
  115. }
  116. string selected = i == 0 ? "selected" : "";
  117. int fieldType = (int)item.FiledType;
  118. int expType = (int)item.ExpType;
  119. <option value="@item.Field" data-index="1" data-select="@isSelect" data-field="@item.Field" data-field-type="@fieldType" data-exp-type="@expType" @selected>@item.DisplayName</option>
  120. i++;
  121. }
  122. </select>
  123. <input id="FieldType-1" name="FieldType-1" class="FieldType" type="hidden" value="0" />
  124. <input id="ExpType-1" name="ExpType-1" class="ExpType" type="hidden" value="6" />
  125. <input id="KeyWords-1" name="KeyWords-1" class="form-control pull-right KeyWords" style="width: calc(100% - 100px) !important;border-top-right-radius: 3px!important;border-bottom-right-radius: 3px!important;" placeholder="请输入查询关键字..." autocomplete="off" />
  126. <span class="btn search-btn" data-type="_" onclick="BtnSearch(true)"><i class="iconfont icon-search "></i></span>
  127. </div>
  128. </div>
  129. }
  130. selectItemStr += "}";
  131. }
  132. </form>
  133. </div>
  134. </div>
  135. <table id="table"
  136. data-url="/api/services/app/AuditLogs/GetAll"
  137. data-striped="true" data-id-field="id" data-unique-id="id"
  138. data-method="post"
  139. data-side-pagination="server"
  140. data-content-type="application/x-www-form-urlencoded; charset=UTF-8"
  141. data-cache="false"
  142. data-pagination="true"
  143. data-page-size="30"
  144. data-page-number="1"
  145. data-page-list="[30,50,100,200]" data-pagination-detail-h-align="right" data-pagination-h-align="left"
  146. data-query-params="QueryParams"
  147. data-response-handler="ResponseHandler"
  148. data-click-to-select="true"
  149. data-single-select="true">
  150. <thead>
  151. <tr class="row" id="header">
  152. <th data-field="state" data-checkbox="true"></th>
  153. <th data-align="center" data-field="userName">用户名</th>
  154. <th data-align="center" data-field="serviceName">日志名称</th>
  155. <th data-align="center" data-field="methodName">操作名称</th>
  156. @*<th data-align="center" data-field="parameters"></th>*@
  157. <th data-align="center" data-field="executionTime">执行时间</th>
  158. <th data-align="center" data-field="clientIpAddress">IP地址</th>
  159. <th data-align="center" data-field="clientName">客户端</th>
  160. <th data-align="center" data-field="browserInfo">浏览器</th>
  161. </tr>
  162. </thead>
  163. </table>
  164. </div>
  165. @section modal{
  166. <!--Main Modal-->
  167. <section>
  168. <div class="modal fade" id="modal" role="dialog" tabindex="-1" aria-labelledby="ModalLabel" aria-hidden="true">
  169. <div class="modal-dialog modal-dialog-centered" role="document">
  170. <div class="modal-content">
  171. @Html.Partial("Modals/_ModalHeader", new ModalHeaderViewModel(""))
  172. @{
  173. var inputs = new List<InputViewModel>
  174. {
  175. new InputViewModel("id", hide: true),
  176. new InputViewModel(""),
  177. };
  178. //var specials = new List<SpecialInputModel>();
  179. }
  180. @Html.Partial("Modals/_ModalBody", new ModalBodyViewModel(inputs))
  181. @Html.Partial("Modals/_ModalFooter", "0")
  182. </div>
  183. </div>
  184. </div>
  185. </section>
  186. }
  187. @section scripts
  188. {
  189. @Scripts.Render("~/Bundles/datetimepicker/js")
  190. <script>
  191. $(function () {
  192. $("#KeyWords-2").datetimepicker({
  193. format: 'yyyy-mm-dd',
  194. minView: 'month',
  195. language: 'zh-CN',
  196. autoclose: true,
  197. startDate: "2008-01-01"
  198. }).on("click", function () {
  199. $("#KeyWords-2").datetimepicker("setEndDate", $("#KeyWords-3").val());
  200. });
  201. $("#KeyWords-3").datetimepicker({
  202. format: 'yyyy-mm-dd',
  203. minView: 'month',
  204. language: 'zh-CN',
  205. autoclose: true,
  206. startDate: new Date()
  207. }).on("click", function () {
  208. $("#KeyWords-3").datetimepicker("setStartDate", $("#KeyWords-2").val());
  209. });
  210. var now = new Date();
  211. $('#KeyWords-3').datetimepicker('setDate', new Date(now.getTime() + 24 * 60 * 60 * 1000));
  212. $('#KeyWords-2').datetimepicker('setDate', new Date(now.getTime() - 3 * 24 * 60 * 60 * 1000));
  213. $(".search-unit select").select2();
  214. $(".KeyField").off("change.keyfield").on("change.keyfield", function () {
  215. var $that = $(this).find("option:selected");
  216. var selectIndex = $that.data("index"),
  217. isSelect = $that.data("select"),
  218. field = $that.data("field"),
  219. expType = $that.data("exp-type"),
  220. fieldType = $that.data("field-type");
  221. changeKeyWord(selectIndex, isSelect,field, expType, fieldType);
  222. });
  223. LoadTable();
  224. var selectItem = @Html.Raw(selectItemStr);
  225. function changeKeyWord(index, isSelect,field,expType, fieldType) {
  226. var $index = $(".search-unit[data-index='" + index + "']");
  227. $index.find(".ExpType").val(expType);
  228. $index.find(".FieldType").val(fieldType);
  229. var str;
  230. var id = $index.find(".KeyWords").attr("id");
  231. console.log(fieldType, "-", isSelect);
  232. if (isSelect) {
  233. if (selectItem.length < 0) {
  234. return;
  235. }
  236. str = '<select id="' + id + '" name="' + id + '" class="form-control pull-right KeyWords" style="width: calc(100% - 120px) !important;" placeholder="请选择查询项..." autocomplete="off" data-placeholder="请选择查询项...">';
  237. str += selectItem[field];
  238. str += '</select>';
  239. $index.find(".KeyWords").next("span.select2").remove();
  240. $index.find(".KeyWords").remove();
  241. $index.find(".ExpType").after(str);
  242. $index.find(".KeyWords").select2();
  243. if ($index.find(".search-btn").length>0) {
  244. $index.find(".KeyWords").next().find(".select2-selection__arrow").css("right", "30px");
  245. }
  246. } else {
  247. if (fieldType === 1) {
  248. str = ' <input id="' + id + '" name="' + id + '" class="form-control number pull-right KeyWords" style="width: calc(100% - 100px) !important" placeholder="请输入需查询的数字..." autocomplete="off" />';
  249. } else if (fieldType === 5) {
  250. str = ' <input id="' + id + '" name="' + id + '" class="form-control dateISO pull-right KeyWords" style="width: calc(100% - 100px) !important" placeholder="请输入需查询的日期..." autocomplete="off" />';
  251. } else {
  252. str = '<input id="' + id + '" name="' + id + '" class="form-control pull-right KeyWords" style="width: calc(100% - 100px) !important" placeholder="请输入查询关键字..." autocomplete="off" />';
  253. }
  254. $index.find(".KeyWords").next("span.select2").remove();
  255. $index.find(".KeyWords").remove();
  256. $index.find(".ExpType").after(str);
  257. }
  258. AddSearchEvents();
  259. }
  260. });
  261. </script>
  262. }