search.jsp 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <%@ page language="java" contentType="text/html; charset=utf-8"
  2. pageEncoding="utf-8"%>
  3. <%
  4. String path = request.getContextPath();
  5. String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
  6. %>
  7. <!DOCTYPE html>
  8. <html>
  9. <head>
  10. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  11. <link rel="stylesheet" type="text/css" href="<%=basePath %>resource/ext/4.2/resources/ext-theme-gray/ext-theme-gray-all.css"/>
  12. <link rel="stylesheet" href="<%=basePath %>resource/css/search.css" type="text/css"></link>
  13. <script type="text/javascript" src="<%=basePath %>resource/ext/4.2/ext-all.js"></script>
  14. <script type="text/javascript" src="<%=basePath %>resource/i18n/i18n.js"></script>
  15. <script type="text/javascript">
  16. // ghost
  17. Ext.example = function() {
  18. var b;
  19. function a(t, c, d) {
  20. return '<div class="msg x-message-box-' + t + '"><h3>' + c + "</h3><p>" + d + "</p></div>"
  21. }
  22. return {
  23. msg: function(t, g, e, y) {
  24. if (!b) {
  25. b = Ext.DomHelper.insertFirst(document.body, {
  26. id: "msg-div"
  27. }, true);
  28. }
  29. var d = Ext.String.format.apply(String, Array.prototype.slice.call(arguments, 2));
  30. var c = Ext.DomHelper.append(b, a((t || 'info'), g, d), true);
  31. c.hide();
  32. c.slideIn("t").ghost("t", {
  33. delay: y || 1000,
  34. remove: true
  35. });
  36. },
  37. init: function() {
  38. if (!b) {
  39. b = Ext.DomHelper.insertFirst(document.body, {
  40. id: "msg-div"
  41. }, true);
  42. }
  43. }
  44. };
  45. } ();
  46. Ext.onReady(Ext.example.init, Ext.example);
  47. // override remote queryStr length
  48. Ext.override(Ext.form.field.ComboBox, {
  49. beforeQuery: function(queryPlan) {
  50. var me = this;
  51. // Allow beforequery event to veto by returning false
  52. if (me.fireEvent('beforequery', queryPlan) === false) {
  53. queryPlan.cancel = true;
  54. }
  55. // Allow beforequery event to veto by returning setting the cancel flag
  56. else if (!queryPlan.cancel) {
  57. // If the minChars threshold has not been met, and we're not forcing an "all" query, cancel the query
  58. if (me.getCharLength(queryPlan.query) < me.minChars && !queryPlan.forceAll) {
  59. queryPlan.cancel = true;
  60. }
  61. }
  62. return queryPlan;
  63. },
  64. getCharLength: function(str) {
  65. for (var len = str.length, c = 0, i = 0; i < len; i++)
  66. str.charCodeAt(i) < 27 || str.charCodeAt(i) > 126 ? c += 2 : c++;
  67. return c;
  68. }
  69. });
  70. // override fieldset, toggle others when checked
  71. Ext.override(Ext.form.FieldSet, {
  72. onCheckChange: function(cmp, checked) {
  73. this.setExpanded(checked);
  74. if (checked) {
  75. var id = this.id, cmps = this.ownerCt.query('fieldset[name=' + this.name + ']');
  76. Ext.Array.each(cmps, function(c){
  77. if (c.id !== id)
  78. c.setExpanded(false);
  79. });
  80. }
  81. }
  82. });
  83. // split by regexp without remove
  84. String.prototype._split = function(regexp) {
  85. if (regexp instanceof RegExp) {
  86. var arr = this.split(""), _arr = [], temp = '';
  87. for (var i in arr) {
  88. if (regexp.test(arr[i])) {
  89. if (temp.length > 0)
  90. _arr.push(temp);
  91. _arr.push(arr[i]);
  92. temp = '';
  93. } else
  94. temp += arr[i];
  95. }
  96. if (temp.length > 0)
  97. _arr.push(temp);
  98. return _arr;
  99. }
  100. return this.split(regexp);
  101. };
  102. // Math functions
  103. Math._abs = function() {
  104. if(arguments.length != 1)
  105. throw new Error('wrong number of arguments, expected 1, acctually ' + arguments.length);
  106. return Math.abs(arguments[0]);
  107. };
  108. Math._ceil = function() {
  109. if(arguments.length != 1)
  110. throw new Error('wrong number of arguments, expected 1, acctually ' + arguments.length);
  111. return Math.ceil(arguments[0]);
  112. };
  113. Math._floor = function() {
  114. if(arguments.length != 1)
  115. throw new Error('wrong number of arguments, expected 1, acctually ' + arguments.length);
  116. return Math.floor(arguments[0]);
  117. };
  118. Math._round = function() {
  119. if(arguments.length != 1 && arguments.length != 2)
  120. throw new Error('wrong number of arguments, expected 1 or 2, acctually ' + arguments.length);
  121. var a = arguments[0], b = arguments[1] || 0;
  122. return Math.round(a*Math.pow(10,b))/Math.pow(10,b);
  123. };
  124. // test formula with eval
  125. Ext.Test = {};
  126. Ext.Test.eval = function(code){
  127. code = 'var abs=' + Math._abs + ',ceil=' + Math._ceil + ',floor=' + Math._floor + ',round=' + Math._round + ';' + code;
  128. if (Ext.isIE){
  129. return execScript(code);
  130. } else {
  131. return window.eval(code);
  132. }
  133. };
  134. //is number(Ext.isNumber doesn't work)
  135. var isNumber = function(n) {
  136. return !isNaN(parseFloat(n)) && isFinite(n);
  137. };
  138. //
  139. Ext.Loader.setConfig({
  140. enabled: true
  141. });//开启动态加载
  142. Ext.application({
  143. name: 'erp',//为应用程序起一个名字,相当于命名空间
  144. appFolder: '<%=basePath %>'+'app',//app文件夹所在路径
  145. controllers: [//声明所用到的控制层
  146. 'common.Search'
  147. ],
  148. launch: function() {
  149. Ext.create('erp.view.common.search.Viewport');
  150. }
  151. });
  152. var caller = getUrlParam('whoami');
  153. </script>
  154. </head>
  155. <body >
  156. </body>
  157. </html>