BatchRegistr.cshtml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. GetGrid110();
  20. //表格居中显示
  21. $(".ui-th-column").css("text-align", "center");
  22. });
  23. //重设(表格)宽高
  24. function initialPage() {
  25. //resize重设(表格、树形)宽高
  26. $(window).resize(function (e) {
  27. window.setTimeout(function () {
  28. $('#gridTable').setGridWidth(($('.gridPanel').width()));
  29. $("#gridTable").setGridHeight($(window).height() - 108.5);
  30. }, 200);
  31. e.stopPropagation();
  32. });
  33. }
  34. //加载表格
  35. function GetGrid110(tabledata) {
  36. jQuery("#gridTable").jqGrid(
  37. {
  38. datatype: "local",
  39. height: $(window).height() - 108.5,
  40. colModel: [
  41. { label: 'ID', name: 'ID', hidden: true },
  42. { label: "IMEI", name: "IMEI", width: 300, align: "left", sortable: false },
  43. { label: "SIM(ICCID)", name: "SIM", width: 300, align: "left", sortable: false },
  44. { label: "地址", name: "METERADDR", width: 300, align: "left", sortable: false },
  45. { label: "注册状态", name: "registerState", width: 300, align: "left", sortable: false, },
  46. ],
  47. rownumbers: true,
  48. });
  49. if (tabledata != null) {
  50. var mydata = JSON.parse(tabledata);
  51. for (var i = 0; i <= mydata.length; i++) {
  52. jQuery("#gridTable").jqGrid('addRowData', i + 1, mydata[i]);
  53. }
  54. }
  55. }
  56. function enteredKbFmatter(cellvalue, options, rowObject) {
  57. if (cellvalue == 1) {
  58. return "已注册";
  59. } else {
  60. return "未注册";
  61. }
  62. }
  63. function btn_confirm() {
  64. Loading(true);
  65. $("#gridTable").jqGrid("clearGridData");
  66. var file = document.getElementById("file");
  67. console.log(file.files.length);
  68. var formData = new FormData($('#uploadForm')[0]);
  69. if (!file.files.length) {
  70. Loading(false);
  71. dialogMsg("请选择文件", 0);
  72. return;
  73. }
  74. $.ajax({
  75. type: 'post',
  76. url: '/NBManage/NBEquipmentDebug/ImportExcel',
  77. data: formData,
  78. cache: false,
  79. processData: false,
  80. contentType: false,
  81. success: function (data) {
  82. GetGrid110(data);
  83. Loading(false);
  84. },
  85. })
  86. }
  87. </script>
  88. <div style="background: #fff; padding-left:15px;">
  89. <form id="uploadForm" enctype="multipart/form-data" style="display: inline">
  90. 文件 :
  91. <input id="file" type="file" name="file" style="display: inline" />
  92. </form>
  93. <button id="upload" onclick="btn_confirm()" class="button" style="display: inline">上传文件</button>
  94. <br />
  95. </div>
  96. <div class="gridPanel" style="width:100%;">
  97. <table id="gridTable"></table>
  98. <div id="gridPager"></div>
  99. </div>