MyTest.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. 
  2. var CurrQueryID = 47;
  3. var CurrQueryDs = null;
  4. var CurrDs = null;
  5. $(function () {
  6. CurrQueryDs = GetQueryCol(CurrQueryID);
  7. GetGrid();
  8. })
  9. $(window).resize(function () {
  10. $(window).unbind("onresize");
  11. //$("#gridTable").setGridHeight($(window).height() - 190);
  12. doResize();
  13. $(window).bind("onresize", this);
  14. });
  15. function doResize() {
  16. var ss = getPageSize();
  17. $("#gridTable").jqGrid('setGridWidth', ss.WinW - 10).jqGrid('setGridHeight', ss.WinH - 100);
  18. }
  19. function getPageSize() {
  20. //http://www.blabla.cn/js_kb/javascript_pagesize_windowsize_scrollbar.html
  21. var winW, winH;
  22. if (window.innerHeight) {// all except IE
  23. winW = window.innerWidth;
  24. winH = window.innerHeight;
  25. } else if (document.documentElement && document.documentElement.clientHeight) {// IE 6 Strict Mode
  26. winW = document.documentElement.clientWidth;
  27. winH = document.documentElement.clientHeight;
  28. } else if (document.body) { // other
  29. winW = document.body.clientWidth;
  30. winH = document.body.clientHeight;
  31. } // for small pages with total size less then the viewport
  32. return { WinW: winW, WinH: winH };
  33. }
  34. //加载表格
  35. function GetGrid() {
  36. var condition = GetCondition();
  37. CurrDs = RDForQueryIndexONameArgsForDb(CurrQueryID, condition, $("#currdbname").val());
  38. if (CurrDs.hasOwnProperty("resultcode")) {
  39. alert("调用发生错误,错误信息为:" + CurrDs["errorinfo"]);
  40. return;
  41. }
  42. $("#gridTable").jqGrid({
  43. datatype: "local",
  44. data: CurrDs,
  45. height: $(window).height() - 149,
  46. autowidth: true,
  47. colModel:
  48. GetTableColStr(CurrQueryDs),
  49. pager: "#gridPager",
  50. sortname: '',
  51. sortorder: 'desc',
  52. rownumbers: true,
  53. shrinkToFit: false,
  54. gridview: true,
  55. });
  56. }
  57. //获取用户设置的查询条件
  58. function GetCondition() {
  59. //var condition = "";
  60. //var tempstr = $("#FCode").val();
  61. //if (tempstr != "") {
  62. // condition += " and a.FCode='" + tempstr + "'";
  63. //}
  64. //tempstr = $("#FDateS").val();
  65. //var tempstre = $("#FDateE").val();
  66. //if (tempstr != "" && tempstre != "") {
  67. // condition += " and a.fdate between to_date('" + tempstr + " 00:00:00','YYYY-MM-DD HH24:MI:SS') and to_date('" + tempstre + " 23:59:59','YYYY-MM-DD HH24:MI:SS')";
  68. //}
  69. //var tt = "@(LeaRun.Utilities.ManageProvider.Provider.Current().Code)";
  70. //condition += " and a.pmc01='" + tt + "'";
  71. //return condition;
  72. return "";
  73. }
  74. //根据条件查询
  75. function btn_Search() {
  76. $("#gridTable").clearGridData();
  77. var condition = GetCondition();
  78. CurrDs = RDForQueryIndexONameArgsForDb(CurrQueryID, condition, $("#currdbname").val());
  79. if (CurrDs.hasOwnProperty("resultcode")) {
  80. alert("调用发生错误,错误信息为:" + CurrDs["errorinfo"]);
  81. return;
  82. }
  83. $("#gridTable").jqGrid('setGridParam', { datatype: "local", data: CurrDs }).trigger('reloadGrid');
  84. }
  85. //编辑
  86. function btn_edit() {
  87. //var KeyValue = GetJqGridRowValue("#gridTable", "ID");
  88. //if (IsChecked(KeyValue)) {
  89. // ShowSgoodsMstBase(KeyValue);
  90. //}
  91. doResize();
  92. }
  93. //新增
  94. function btn_add() {
  95. ShowSgoodsMstBase(0);
  96. }
  97. function ShowSgoodsMstBase(id) {
  98. var url = "/OilModule/SGoodsMst/SGoodsMstBaseNew?KeyValue=" + id;
  99. AddTabMenu("SGoodsMstBase111", url, "送货单维护", "application_side_expand.png", true, true, true);
  100. }
  101. function btn_delete() {
  102. confirmDialog("提示", "您确定要删除您选择的数据吗?", function (r) {
  103. if (r) {
  104. var detailKeyValue = GetJqGridRowValue("#gridTable", "ID");
  105. var Nurl = '/OilModule/SGoodsMst/DelSGoodsMst';
  106. var PostDdata = '{ "ID": "' + detailKeyValue + '}';
  107. var parm = { json: PostDdata };
  108. AjaxJson(Nurl, parm, DetailDelete);
  109. }
  110. });
  111. }
  112. function DetailDelete(json) {
  113. json = JSON.parse(json);
  114. if (json.hasOwnProperty("state")) {
  115. alert("调用发生错误,错误信息为:" + json.message);
  116. return;
  117. }
  118. var result = json[0].ID;
  119. if (result > 0) {
  120. alert("删除成功!");
  121. btn_Search();
  122. }
  123. }