index.html 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>TODO supply a title</title>
  5. {include file="../application/manage/view/commons/headers.html" }
  6. <script>
  7. // 编辑窗口
  8. var $editWin;
  9. var winHeight = $(window).height();
  10. var frameHeight = winHeight * 0.9;
  11. $(function() {
  12. $editWin = $('#edit-window').window({
  13. title: '关键词编辑',
  14. width: 800,
  15. height: frameHeight,
  16. top: ($(document).height() - frameHeight) / 2,
  17. left: ($(document).width() - 820) / 2,
  18. shadow: true,
  19. modal: true,
  20. iconCls: 'icon-edit',
  21. closed: true,
  22. minimizable: false,
  23. maximizable: false,
  24. collapsible: false
  25. });
  26. })
  27. function commandsFormatter(id, row) {
  28. var cmdEdit = "<a href='#' onclick=\"javascript:showEditWin('" + row.id + "');\" >编辑</a>&nbsp;";
  29. cmdEdit += "<a href='#' onclick=\"javascript:deleteRow('" + row.id + "');\" >删除</a>";
  30. return cmdEdit;
  31. }
  32. $(function() {
  33. var height = $(document).height();
  34. $("#gd").height(height);
  35. getDatas();
  36. });
  37. //获取数据
  38. function getDatas() {
  39. var institution = $("#institution").val();
  40. $('#gd').datagrid({
  41. url: '/manage/device/getAll?institution=' + institution,
  42. idField: 'id', method: 'get', rownumbers: true,singleSelect:true,selectOnCheck:false,
  43. showFooter: true, toolbar: '#tb',
  44. columns: [
  45. [{
  46. field: 'id',
  47. title: 'ID',
  48. hidden: true
  49. }, {
  50. field: 'name',
  51. title: '名称',
  52. align: 'center'
  53. }, {
  54. field: 'ecName',
  55. title: '检查类别名称',
  56. align: 'center'
  57. }, {
  58. field: 'institutionName',
  59. title: '机构名称',
  60. align: 'center'
  61. }, {
  62. field: 'grid_commands',
  63. title: '操作',
  64. align: 'center',
  65. width: 100,
  66. formatter: commandsFormatter
  67. }, ]
  68. ],
  69. onDblClickRow: function(rowIndex, rowData) {
  70. showEditWin(rowData.id);
  71. },
  72. });
  73. }
  74. // 显示编辑窗口
  75. function showEditWin(id) {
  76. if ("undefined" == typeof id) {
  77. $editWin.window('open');
  78. $('#editFrame').attr('src', '/manage/device/goEdit');
  79. } else {
  80. $editWin.window('open');
  81. $('#editFrame').attr('src', '/manage/device/goEdit?id=' + id);
  82. }
  83. }
  84. function deleteRow(id) {
  85. $.messager.confirm('Confirm', '确定要删除这条记录吗?', function(r) {
  86. if (r) {
  87. $.ajax({
  88. url: "/manage/device/del",
  89. data: "id=" + id + "&t=" + new Date(),
  90. success: function(rs) {
  91. if (rs == "delete_ok") {
  92. alert("操作已成功!");
  93. document.location.reload();
  94. } else {
  95. alert("操作失败!");
  96. }
  97. }
  98. });
  99. }
  100. });
  101. }
  102. // 关闭编辑窗口
  103. function closeEditWin(isReload) {
  104. $editWin.window('close');
  105. if (isReload == "reload") {
  106. document.location.reload();
  107. }
  108. }
  109. </script>
  110. </head>
  111. <body>
  112. <div id="gd" class="easyui-datagrid" style="width:100%;height:auto;"></div>
  113. <div id="tb" class="editform" style="display: none; padding-top: 1px;">
  114. &nbsp; 机构:
  115. <select id="institution" style="width: 180px; ">
  116. <option value="">全部</option>
  117. {volist name="institutions" id="it"}
  118. <option value="{$it.id}">{$it.name}</option>
  119. {/volist}
  120. </select>
  121. <a id="submit" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" style="width: 80px" onclick="javascript:getDatas()">查询</a>
  122. <a id="add" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-add'" onclick="javascript:showEditWin()" style="width: 80px">添加</a>
  123. </div>
  124. <div id="edit-window" class="easyui-window" style="overflow: hidden"><iframe src="about:blank" id="editFrame" width="100%" height="100%" frameborder="0" scrolling="yes"></iframe></div>
  125. </body>
  126. </html>