SyncData.cshtml 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. @{
  2. ViewBag.Title = "同步数据";
  3. Layout = "~/Views/Shared/_Index.cshtml";
  4. }
  5. <style>
  6. .button {
  7. width: auto;
  8. padding: 9px 15px;
  9. background: #617798;
  10. border: 0;
  11. font-size: 14px;
  12. color: #FFFFFF;
  13. }
  14. </style>
  15. <script>
  16. $(document).ready(function () {
  17. initialPage();
  18. GetGrid();
  19. //表格表头居中显示
  20. $(".ui-th-column").css("text-align", "center");
  21. });
  22. //重设(表格)宽高
  23. function initialPage() {
  24. //resize重设(表格、树形)宽高
  25. $(window).resize(function (e) {
  26. window.setTimeout(function () {
  27. $('#gridTable').setGridWidth(($('.gridPanel').width()));
  28. $("#gridTable").setGridHeight($(window).height() - 108.5);
  29. }, 200);
  30. e.stopPropagation();
  31. });
  32. }
  33. //加载表格
  34. function GetGrid(tabledata) {
  35. jQuery("#gridTable").jqGrid({
  36. datatype: "local",
  37. height: $(window).height() - 108.5,
  38. colModel: [
  39. { label: "小区", name: "小区", width: 130, align: "left", sortable: false, fixed: true },
  40. { label: "楼宇", name: "楼宇", width: 130, align: "left", sortable: false, fixed: true },
  41. { label: "单元", name: "单元", width: 130, align: "left", sortable: false, fixed: true },
  42. { label: "户号", name: "户号", width: 130, align: "left", sortable: false, fixed: true },
  43. { label: "表地址", name: "表地址", width: 150, align: "right", sortable: false, fixed: true },
  44. { label: "IMEI", name: "IMEI", width: 200, align: "left", sortable: false, fixed: true },
  45. { label: "ICCID", name: "ICCID", width: 250, align: "right", sortable: false, fixed: true },
  46. { label: "DeviceID", name: "DeviceID", width: 300, align: "left", sortable: false, fixed: true },
  47. { label: "同步状态", name: "syncState", width: 300, align: "left", sortable: false, fixed: true }
  48. ]
  49. });
  50. if (tabledata != null) {
  51. var mydata = JSON.parse(tabledata);
  52. for (var i = 0; i <= mydata.length; i++) {
  53. jQuery("#gridTable").jqGrid('addRowData', i + 1, mydata[i]);
  54. }
  55. }
  56. }
  57. //上传文件
  58. function btn_confirm() {
  59. Loading(true);
  60. $("#gridTable").jqGrid("clearGridData");
  61. var formData = new FormData($('#uploadForm')[0]);
  62. $.ajax({
  63. type: 'post',
  64. url: '/NBManage/NBEquipmentDebug/ImportExcelForSync',
  65. data: formData,
  66. cache: false,
  67. processData: false,
  68. contentType: false,
  69. success: function (data) {
  70. GetGrid(data);
  71. Loading(false);
  72. }
  73. })
  74. }
  75. </script>
  76. <div style="background: #fff;padding-left:15px;">
  77. <form id="uploadForm" enctype="multipart/form-data" style="display: inline">
  78. 文件 :
  79. <input id="file" type="file" name="file" style="display: inline" />
  80. </form>
  81. <button id="upload" onclick="btn_confirm()" class="button" style="display: inline">上传文件</button>
  82. <br />
  83. </div>
  84. <div class="gridPanel">
  85. <table id="gridTable"></table>
  86. <div id="gridPager"></div>
  87. </div>