search.jsp 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  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() + "://"
  6. + request.getServerName() + ":" + request.getServerPort()
  7. + path + "/";
  8. %>
  9. <!DOCTYPE html>
  10. <html>
  11. <head>
  12. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  13. <link rel="stylesheet" type="text/css"
  14. href="<%=basePath%>resource/ext/4.2/resources/ext-theme-gray/ext-theme-gray-all.css" />
  15. <link rel="stylesheet" href="<%=basePath%>resource/css/search.css"
  16. type="text/css"></link>
  17. <script type="text/javascript"
  18. src="<%=basePath%>resource/ext/4.2/ext-all.js"></script>
  19. <script type="text/javascript" src="<%=basePath%>resource/i18n/i18n.js"></script>
  20. <script type="text/javascript">
  21. // ghost
  22. Ext.example = function() {
  23. var b;
  24. function a(t, c, d) {
  25. return '<div class="msg x-message-box-' + t + '"><h3>' + c + "</h3><p>" + d + "</p></div>"
  26. }
  27. return {
  28. msg : function(t, g, e, y) {
  29. if (!b) {
  30. b = Ext.DomHelper.insertFirst(document.body, {
  31. id : "msg-div"
  32. }, true);
  33. }
  34. var d = Ext.String.format.apply(String, Array.prototype.slice.call(arguments, 2));
  35. var c = Ext.DomHelper.append(b, a((t || 'info'), g, d), true);
  36. c.hide();
  37. c.slideIn("t").ghost("t", {
  38. delay : y || 1000,
  39. remove : true
  40. });
  41. },
  42. init : function() {
  43. if (!b) {
  44. b = Ext.DomHelper.insertFirst(document.body, {
  45. id : "msg-div"
  46. }, true);
  47. }
  48. }
  49. };
  50. }();
  51. Ext.onReady(Ext.example.init, Ext.example);
  52. // override remote queryStr length
  53. Ext.override(Ext.form.field.ComboBox, {
  54. beforeQuery : function(queryPlan) {
  55. var me = this;
  56. // Allow beforequery event to veto by returning false
  57. if (me.fireEvent('beforequery', queryPlan) === false) {
  58. queryPlan.cancel = true;
  59. }
  60. // Allow beforequery event to veto by returning setting the cancel flag
  61. else if (!queryPlan.cancel) {
  62. // If the minChars threshold has not been met, and we're not forcing an "all" query, cancel the query
  63. if (me.getCharLength(queryPlan.query) < me.minChars && !queryPlan.forceAll) {
  64. queryPlan.cancel = true;
  65. }
  66. }
  67. return queryPlan;
  68. },
  69. getCharLength : function(str) {
  70. for (var len = str.length, c = 0, i = 0; i < len; i++)
  71. str.charCodeAt(i) < 27 || str.charCodeAt(i) > 126 ? c += 2 : c++;
  72. return c;
  73. }
  74. });
  75. // override fieldset, toggle others when checked
  76. Ext.override(Ext.form.FieldSet, {
  77. onCheckChange : function(cmp, checked) {
  78. this.setExpanded(checked);
  79. if (checked) {
  80. var id = this.id, cmps = this.ownerCt.query('fieldset[name=' + this.name + ']');
  81. Ext.Array.each(cmps, function(c) {
  82. if (c.id !== id)
  83. c.setExpanded(false);
  84. });
  85. }
  86. }
  87. });
  88. // split by regexp without remove
  89. String.prototype._split = function(regexp) {
  90. if (regexp instanceof RegExp) {
  91. var arr = this.split(""), _arr = [], temp = '', isStr = false;
  92. for ( var i in arr) {
  93. // 字符串不拆
  94. if (arr[i] == "'") {
  95. if (temp.length > 0) {
  96. _arr.push("'" + temp + "'");
  97. isStr = false;
  98. } else
  99. isStr = true;
  100. temp = '';
  101. } else if (isStr){
  102. temp += arr[i];
  103. } else {
  104. if (regexp.test(arr[i])) {
  105. if (temp.length > 0)
  106. _arr.push(temp);
  107. _arr.push(arr[i]);
  108. temp = '';
  109. } else
  110. temp += arr[i];
  111. }
  112. }
  113. if (temp.length > 0)
  114. _arr.push(temp);
  115. return _arr;
  116. }
  117. return this.split(regexp);
  118. };
  119. // date format
  120. Date.prototype.format = function(format) {
  121. var value = this;
  122. var date = {
  123. "m+" : value.getMonth() + 1,
  124. "d+" : value.getDate(),
  125. "h+(24){0,1}" : value.getHours(),
  126. "(m){0,1}i+" : value.getMinutes(),
  127. "s+" : value.getSeconds(),
  128. "q+" : Math.floor((value.getMonth() + 3) / 3),
  129. "S+" : value.getMilliseconds()
  130. };
  131. if (/(y+)/i.test(format)) {
  132. format = format.replace(RegExp.$1, (value.getFullYear() + '').substr(4 - RegExp.$1.length));
  133. }
  134. for ( var k in date) {
  135. if (new RegExp("(" + k + ")").test(format)) {
  136. format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? date[k] : ("00" + date[k])
  137. .substr(("" + date[k]).length));
  138. }
  139. }
  140. return format;
  141. };
  142. // m-n的随机整数,不包括m
  143. Math.randomInt = function(m, n) {
  144. return Math.ceil(Math.random()*(n - m) + m);
  145. };
  146. // test formula with eval
  147. window.assertEquals = function(expected, actual) {
  148. var equal = false;
  149. if (expected instanceof Array) {
  150. for ( var i in expected) {
  151. if (expected[i] == actual)
  152. return;
  153. }
  154. } else {
  155. equal = expected == actual;
  156. }
  157. if (!equal)
  158. throw new Error('wrong number of arguments, expected '
  159. + (expected instanceof Array ? expected.join(' or ') : expected) + ', acctually ' + actual);
  160. };
  161. // 测试用函数集
  162. Ext.Test = {
  163. randomNum: function() {
  164. // 测试用number
  165. return Number(Math.random().toFixed(6));
  166. },
  167. randomDate: function() {
  168. // 测试用时间
  169. var y = Math.randomInt(1970, 2100), m = Math.randomInt(0, 12), d = Math.randomInt(0, 30),
  170. h = Math.randomInt(0, 24), i = Math.randomInt(0, 60), s = Math.randomInt(0, 60);
  171. return new Date(y, m, d, h, i, s);
  172. },
  173. randomStr: function() {
  174. // 测试用字符串
  175. var str = '', len = 8;
  176. var $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678';
  177. var maxPos = $chars.length;
  178. for (i = 0; i < len; i++) {
  179.   str += $chars.charAt(Math.floor(Math.random() * maxPos));
  180. }
  181. return str;
  182. },
  183. abs : function() {
  184. assertEquals(1, arguments.length);
  185. return Math.abs(arguments[0]);
  186. },
  187. ceil : function() {
  188. assertEquals(1, arguments.length);
  189. return Math.ceil(arguments[0]);
  190. },
  191. floor : function() {
  192. assertEquals(1, arguments.length);
  193. return Math.floor(arguments[0]);
  194. },
  195. round : function() {
  196. assertEquals([ 1, 2 ], arguments.length);
  197. var a = arguments[0], b = arguments[1] || 0;
  198. return Math.round(a * Math.pow(10, b)) / Math.pow(10, b);
  199. },
  200. nvl : function() {
  201. assertEquals(2, arguments.length);
  202. var a = arguments[0], b = arguments[1];
  203. return a == null ? b : a;
  204. },
  205. nvl2 : function() {
  206. assertEquals(3, arguments.length);
  207. var a = arguments[0], b = arguments[1], c = arguments[2];
  208. return a == null ? c : b;
  209. },
  210. lpad : function() {
  211. assertEquals(3, arguments.length);
  212. var a = arguments[0], b = Math.floor(arguments[1]), c = arguments[2];
  213. if (!!a) {
  214. a = String(a);
  215. c = String(c);
  216. var m = a.length, n = c.length, r = c.split("");
  217. if (m < b) {
  218. var i = 0, prefix = '';
  219. while (m < b) {
  220. prefix += r[i++ % n];
  221. m++;
  222. }
  223. a = prefix + a;
  224. } else if (m > b) {
  225. a = a.substr(0, b);
  226. }
  227. }
  228. return a;
  229. },
  230. rpad : function() {
  231. assertEquals(3, arguments.length);
  232. var a = arguments[0], b = Math.floor(arguments[1]), c = arguments[2];
  233. if (!!a) {
  234. a = String(a);
  235. c = String(c);
  236. var m = a.length, n = c.length, r = c.split("");
  237. if (m < b) {
  238. var i = 0;
  239. while (m < b) {
  240. a += r[i++ % n];
  241. m++;
  242. }
  243. } else if (m > b) {
  244. a = a.substr(0, b);
  245. }
  246. }
  247. return a;
  248. },
  249. trim : function() {
  250. assertEquals(1, arguments.length);
  251. var a = arguments[0];
  252. return !a ? a : String(a).trim();
  253. },
  254. to_char : function() {
  255. assertEquals([ 1, 2 ], arguments.length);
  256. var a = arguments[0], b = arguments[1];
  257. if(a instanceof Date) {
  258. return a.format(b);
  259. } else {
  260. return !a ? a : String(a);
  261. }
  262. },
  263. trunc : function() {
  264. assertEquals([ 1, 2 ], arguments.length);
  265. var a = arguments[0], b = arguments[1];
  266. if(a instanceof Date) {
  267. var y = a.getFullYear(), m = a.getMonth(), d = a.getDate();
  268. if (b) {
  269. b = b.toUpperCase();
  270. if(['Y', 'YEAR'].indexOf(b) > -1) {
  271. m = 0;
  272. d = 1;
  273. } else if(['M', 'MONTH'].indexOf(b) > -1) {
  274. d = 1;
  275. } else if(['D', 'DAY'].indexOf(b) > -1) {
  276. return new Date(new Date(y, m, d) - 86400000*a.getDay());
  277. }
  278. }
  279. return new Date(y, m, d);
  280. } else if (a instanceof Number) {
  281. return Math.ceil(a);
  282. } else {
  283. throw new Error('illegal argument type, trunc(' + a + ',' + b + ')');
  284. }
  285. return a;
  286. }
  287. };
  288. Ext.eval = function(code) {
  289. // Ext.Test作为预定义条件
  290. var def = '';
  291. for(var i in Ext.Test) {
  292. if (!def) {
  293. def = 'var ';
  294. } else {
  295. def += ',';
  296. }
  297. def += i + '=' + Ext.Test[i];
  298. }
  299. def += ';';
  300. code = def + code;
  301. if (Ext.isIE) {
  302. return execScript(code);
  303. } else {
  304. return window.eval(code);
  305. }
  306. };
  307. //is number(Ext.isNumber doesn't work)
  308. var isNumber = function(n) {
  309. return !isNaN(parseFloat(n)) && isFinite(n);
  310. };
  311. //
  312. Ext.Loader.setConfig({
  313. enabled : true
  314. });//开启动态加载
  315. Ext.application({
  316. name : 'erp',//为应用程序起一个名字,相当于命名空间
  317. appFolder : basePath + 'app',//app文件夹所在路径
  318. controllers : [//声明所用到的控制层
  319. 'common.Search' ],
  320. launch : function() {
  321. Ext.create('erp.view.common.search.Viewport');
  322. }
  323. });
  324. var caller = getUrlParam('whoami');
  325. </script>
  326. </head>
  327. <body>
  328. </body>
  329. </html>