addOilAdd.jsp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  1. <%@ page language="java" contentType="text/html;charset=GBK" pageEncoding="GBK"%>
  2. <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  4. <html>
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html;charset=GBK">
  7. <title>新增加油登记</title>
  8. <script type="text/javascript" src="/shares/js/jquery-1.3.2.min.js"></script>
  9. <script type="text/javascript" src="/shares/js/file.js"></script>
  10. <link href="${pageContext.request.contextPath}/main.css" rel="stylesheet" type="text/css" />
  11. <link href="${pageContext.request.contextPath }/liger/lib/ligerUI/skins/${sessionScope.css}/css/ligerui-all.css" rel="stylesheet" type="text/css" />
  12. <script src="${pageContext.request.contextPath }/liger/lib/jquery/jquery-1.3.2.min.js" type="text/javascript"></script>
  13. <script src="${pageContext.request.contextPath }/liger/lib/ligerUI/js/core/base.js" type="text/javascript"></script>
  14. <script type="text/javascript" src="/shares/js/constant.js"></script>
  15. <script type="text/javascript" src="/shares/js/common.js"></script>
  16. <script src="/shares/xheditor/xheditor-1.1.14/xheditor-1.1.14-zh-cn.min.js" type="text/javascript"></script>
  17. <script src="${pageContext.request.contextPath}/liger/lib/json2.js" type="text/javascript"></script>
  18. <script src="${pageContext.request.contextPath}/liger/lib/ligerUI/js/plugins/ligerDialog.js" type="text/javascript"></script>
  19. <script src="${pageContext.request.contextPath}/liger/lib/ligerUI/js/plugins/ligerGrid.js" type="text/javascript"></script>
  20. <script src="${pageContext.request.contextPath}/liger/lib/ligerUI/js/plugins/ligerTextBox.js" type="text/javascript"></script>
  21. <script src="${pageContext.request.contextPath}/liger/lib/ligerUI/js/plugins/ligerCheckBox.js" type="text/javascript"></script>
  22. <script src="${pageContext.request.contextPath}/liger/lib/ligerUI/js/plugins/ligerComboBox.js" type="text/javascript"></script>
  23. <script src="${pageContext.request.contextPath}/liger/lib/ligerUI/js/plugins/ligerSpinner.js" type="text/javascript"></script>
  24. <script src="${pageContext.request.contextPath }/liger/lib/ligerUI/js/plugins/ligerDateEditor.js" type="text/javascript"></script>
  25. <script type="text/javascript" src="${pageContext.request.contextPath}/liger/lib/ligerUI/js/ligerui.all.js"></script>
  26. <script type="text/javascript">
  27. //焦点
  28. $(document).ready(function() {
  29. $("input[type='text']:first").focus();
  30. // $("#gas_station").ligerComboBox();
  31. $("#oilType").ligerComboBox();
  32. });
  33. function checkForm(){
  34. var rs = $.validate({
  35. name : "plate_number",
  36. model : [ {
  37. type : "require",
  38. msg : "车牌号不能为空!"
  39. }]
  40. });
  41. rs = $.validate({
  42. name : "gas_station",
  43. model : [ {
  44. type : "require",
  45. msg : "油库不能为空!"
  46. } ]
  47. }) && rs;
  48. rs = $.validate({
  49. name : "gas_volume",
  50. model : [ {
  51. type : "require",
  52. msg : "加油量不能为空!"
  53. } ]
  54. }) && rs;
  55. rs = $.validate({
  56. name : "gas_time",
  57. model : [ {
  58. type : "require",
  59. msg : "加油时间不能为空!"
  60. } ]
  61. }) && rs;
  62. /* rs = $.validate({
  63. name : "handle_per_name",
  64. model : [ {
  65. type : "require",
  66. msg : "经手人不能为空!"
  67. } ]
  68. }) && rs; */
  69. if (rs) {
  70. var a = $("#gas_time").val();
  71. $("#gas_times").val(a);
  72. var gas_station = $("#gas_station").val();
  73. if(gas_station != ""){
  74. var oilMass = "";
  75. $.ajax({
  76. url:'carOilDepotAction.do?task=numeration',
  77. async: false,
  78. type: 'post',
  79. data: {"oilIn.oil_depot_id":$("#gas_station").val(),"oilIn.oil_num_id":$("#oil_type_id").val()},
  80. cache: false,
  81. error: function(obj){},
  82. success: function(obj){
  83. if(obj!=""){
  84. oilMass = obj;
  85. }
  86. }
  87. });
  88. if(oilMass != ""){
  89. var oilMass1 = $("#gas_volume").val();
  90. if(parseInt(oilMass1) > parseInt(oilMass)){
  91. $.ligerDialog.alert('油库油量('+oilMass+')不足!', '提示', 'warn');
  92. return false;
  93. }
  94. }
  95. }
  96. return true;
  97. }else{
  98. return false;
  99. }
  100. }
  101. $(function() {
  102. loadTypeTree("assignedUserBtn", {
  103. type : "usersingle",
  104. backId : "handle_per",
  105. backName : "handle_per_name",
  106. tab : "1,2,3"
  107. });
  108. });
  109. $(function() {
  110. $("#gas_time").ligerDateEditor({showTime: true,width:160,labelAlign : 'left'});
  111. });
  112. function numeration () {
  113. var gas_station = $("#gas_station").val();
  114. if(gas_station != ""){
  115. var oilMass = "";
  116. $.ajax({
  117. url:'carOilDepotAction.do?task=numeration',
  118. async: false,
  119. type: 'post',
  120. data: {"oilIn.oil_depot_id":$("#gas_station").val(),"oilIn.oil_num_id":$("#oil_type_id").val()},
  121. cache: false,
  122. error: function(obj){},
  123. success: function(obj){
  124. if(obj!=""){
  125. oilMass = obj;
  126. }
  127. }
  128. });
  129. if(oilMass != ""){
  130. var oilMass1 = $("#gas_volume").val();
  131. if(parseInt(oilMass1) > parseInt(oilMass)){
  132. $.ligerDialog.alert('油库油量('+oilMass+')不足!', '提示', 'warn');
  133. return false;
  134. }
  135. }
  136. }
  137. }
  138. function refresh(obj){
  139. if(obj == "1"){
  140. parent.location.reload();
  141. }
  142. }
  143. function check(event) {
  144. var e = window.event || event;
  145. var target = e.srcElement || e.target;
  146. var k = e.keyCode;
  147. if(isFunKey(k)) {
  148. return true;
  149. }
  150. var c = getChar(k);
  151. if(target.value.length == '' && (c == '-' || c == '+')) {
  152. return true;
  153. }
  154. if(isNaN(target.value + getChar(k))) {
  155. return false;
  156. }
  157. return true;
  158. }
  159. function isFunKey(code) {
  160. // 8 --> Backspace
  161. // 35 --> End
  162. // 36 --> Home
  163. // 37 --> Left Arrow
  164. // 39 --> Right Arrow
  165. // 46 --> Delete
  166. // 112~123 --> F1~F12
  167. var funKeys = [8, 35, 36, 37, 39, 46];
  168. for(var i = 112; i <= 123; i++) {
  169. funKeys.push(i);
  170. }
  171. for(var i = 0; i < funKeys.length; i++) {
  172. if(funKeys[i] == code) {
  173. return true;
  174. }
  175. }
  176. return false;
  177. }
  178. function getChar(k) {
  179. if(k >= 48 && k <= 57) {
  180. return String.fromCharCode(k);
  181. }
  182. if(k >= 96 && k <= 105) {
  183. return String.fromCharCode(k - 48);
  184. }
  185. if(k == 110 || k == 190 || k== 188 ) {
  186. return ".";
  187. }
  188. if(k == 109 || k == 189) {
  189. return "-";
  190. }
  191. if(k == 107 || k == 187) {
  192. return "+";
  193. }
  194. return "#";
  195. }
  196. function submitItemName() {
  197. $("#oil_type").val("");
  198. var plate_numbers = "";
  199. var plate_number= document.getElementById("plate_number");
  200. //var plate_number2= document.getElementById("plate_number").value;
  201. if (plate_number.value != "" && typeof (plate_number.value) != "undefined") {
  202. plate_numbers = encodeURI(encodeURI(plate_number.value));
  203. }
  204. if (plate_number != "" && typeof (plate_number) != "undefined") {
  205. sendAsyncAjax({"plate_numbers" : "111"}, "carOilDepotAction.do?task=toFind&plate_number="+plate_numbers+"", "json", process2);
  206. }
  207. }
  208. function process2(data){
  209. //if(data.win_state == '2'){
  210. // $.ligerDialog.alert('该项目已经中标!', '提示', 'warn');
  211. // return;
  212. //}
  213. $("#oil_type").val(data.dictionary_name);
  214. $("#oil_type_id").val(data.oil_plants_number);
  215. $("#car_id").val(data.universalid);
  216. }
  217. /*
  218. * jquery.js
  219. *
  220. * function:类似GOOGLE搜索框提示功能
  221. */
  222. (function($) {
  223. $.fn.autopoint = function (options) {
  224. defaults = {
  225. url:options.url,
  226. keyLeft : 37,//向左方向键
  227. keyUp : 38,//向上方向键
  228. keyRight : 39,//向右方向键
  229. keyDown : 40,//向下方向键
  230. keyEnter : 13,//回车键
  231. listHoverCSS : 'jhover',//提示框列表鼠标悬浮的样式
  232. tpl : '<div onchange="submitItemName();" class="list"><div class="word">{word}</div><div class="view">约{view}条记录</div></div>',
  233. topoffset:options.topoffset||5
  234. };
  235. var options = $.extend(defaults, options);
  236. var dropDiv = $('<div></div>').addClass('dropDiv').appendTo('body');
  237. var isOver = false;
  238. dropDiv.hover(
  239. function(){
  240. isOver = true;
  241. },
  242. function(){
  243. isOver = false;
  244. });
  245. return this.each(function(){
  246. var pa = $(this);
  247. $(this).bind('keydown',
  248. function(event){
  249. if (dropDiv.css('display') != 'none') {
  250. //当提示层显示时才对键盘事件处理
  251. var currentList = dropDiv.find('.' + options.listHoverCSS);
  252. if (event.keyCode == options.keyDown) {
  253. //如果按的是向下方向键
  254. if (currentList.length == 0) {
  255. //如果提示列表没有一个被选中,则将列表第一个选中
  256. $(this).val(getPointWord(dropDiv.find('.list:first').mouseover()));
  257. //$("#plate_number_id").val(getPointView(dropDiv.find('.list:first').mouseover()));
  258. //$("#plate_number_id").val(getPointWord(dropDiv.find('.list:second').mouseover()));
  259. submitItemName();
  260. }else if (currentList.next().length == 0) {
  261. //如果是最后一个被选中,则取消选中,即可认为是输入框被选中
  262. unHoverAll();
  263. }else {
  264. unHoverAll();
  265. //将原先选中列的下一列选中
  266. if (currentList.next().length != 0)
  267. $(this).val(getPointWord(currentList.next().mouseover()));
  268. //$("#plate_number_id").val(getPointView(currentList.next().mouseover()));
  269. //$("#plate_number_id").val(getPointWord(dropDiv.find('.list:second').mouseover()));
  270. submitItemName();
  271. }
  272. return false;
  273. }else if (event.keyCode == options.keyUp) {//如果按的是向上方向键
  274. if (currentList.length == 0) {
  275. $(this).val(getPointWord(dropDiv.find('.list:last').mouseover()));
  276. //$("#plate_number_id").val(getPointView(dropDiv.find('.list:last').mouseover()));
  277. //$("#plate_number_id").val(getPointWord(dropDiv.find('.list:second').mouseover()));
  278. submitItemName();
  279. }else if (currentList.prev().length == 0) {
  280. unHoverAll();
  281. }else {
  282. unHoverAll();
  283. if (currentList.prev().length != 0)
  284. $(this).val(getPointWord(currentList.prev().mouseover()));
  285. //$(this).val(getPointView(currentList.prev().mouseover()));
  286. //$("#plate_number_id").val(getPointWord(dropDiv.find('.list:second').mouseover()));
  287. submitItemName();
  288. }
  289. return false;
  290. }else if(event.keyCode == options.keyEnter) dropDiv.empty().hide();
  291. }
  292. //当按下键之前记录输入框值,以方便查看键弹起时值有没有变
  293. $(this).attr('alt', $(this).val());
  294. //$("#plate_number_id").attr('alt', $("#plate_number_id").val());
  295. submitItemName();
  296. }).bind('keyup', function(event){
  297. //如果弹起的键是向上或向下方向键则返回
  298. if(event.keyCode == options.keyDown||event.keyCode == options.keyUp) return;
  299. if($(this).val() == ''){
  300. dropDiv.empty().hide();
  301. return;
  302. }
  303. //若输入框值没有改变或变为空则返回
  304. if ($(this).val() == $(this).attr('alt'))
  305. return;
  306. getData(pa, $(this).val());
  307. }).bind('blur', function(){
  308. if(isOver&&dropDiv.find('.' + options.listHoverCSS)!=0) return;
  309. //文本输入框失去焦点则清空并隐藏提示层
  310. dropDiv.empty().hide();
  311. });
  312. /**处理ajax返回成功的方法**/
  313. handleResponse = function(parent, json) {
  314. var isEmpty = true;
  315. for(var o in json){
  316. if(o == 'data') isEmpty = false;
  317. }
  318. if(isEmpty) {
  319. showError("返回数据格式错误,请检查请求URL是否正确!");
  320. return;
  321. }
  322. if(json['data'].length == 0) {
  323. //返回数据为空
  324. return;
  325. }
  326. refreshDropDiv(parent, json);
  327. dropDiv.show();
  328. }
  329. /**处理ajax失败的方法**/
  330. handleError = function(error) {
  331. //showError("由于url错误或超时请求失败!");
  332. }
  333. showError = function(error){
  334. alert(error);
  335. }
  336. /**通过ajax返回json格式数据生成用来创建dom的字符串**/
  337. render = function(parent, json) {
  338. var res = json['data'] || json;
  339. var appendStr = '';
  340. //用json对象中内容替换模版字符串中匹配/\{([a-z]+)\}/ig的内容,如{word},{view}
  341. for ( var i = 0; i < res.length; i+=1) {
  342. appendStr += options.tpl.replace(/\{([a-z]+)\}/ig, function(m, n) {
  343. return res[i][n];
  344. });
  345. }
  346. jebind(parent, appendStr);
  347. }
  348. /**将新建dom对象插入到提示框中,并重新绑定mouseover事件监听**/
  349. jebind = function(parent, a) {
  350. dropDiv.append(a);
  351. dropDiv.find('.list').each(function() {
  352. $(this).unbind('mouseover').mouseover(function() {
  353. unHoverAll();
  354. $(this).addClass(options.listHoverCSS);
  355. }).unbind('click').click(function(){
  356. parent.val(getPointWord($(this)));
  357. dropDiv.empty().hide();
  358. parent.focus();
  359. submitItemName();
  360. });
  361. });
  362. }
  363. /**将提示框中所有列的hover样式去掉**/
  364. unHoverAll = function() {
  365. dropDiv.find('.list').each(function() {
  366. $(this).removeClass(options.listHoverCSS);
  367. });
  368. }
  369. /**在提示框中取得当前选中的提示关键字**/
  370. getPointWord = function(p) {
  371. return p.find('div:first').text()
  372. }
  373. //getPointView = function(p) {
  374. // return p.find('div:second').text()
  375. //}
  376. /**刷新提示框,并设定样式**/
  377. refreshDropDiv = function(parent, json) {
  378. var left = parent.offset().left;
  379. var height = parent.height();
  380. var top = parent.offset().top + options.topoffset + height;
  381. var width = options.width || parent.width() + 'px';
  382. dropDiv.empty();
  383. dropDiv.css( {
  384. 'border' : '1px solid #000000',
  385. 'left' : left,
  386. 'top' : top,
  387. 'width' : width
  388. });
  389. render(parent, json);
  390. //防止ajax返回之前输入框失去焦点导致提示框不消失
  391. parent.focus();
  392. }
  393. /**通过ajax向服务器请求数据**/
  394. getData = function(parent, word) {
  395. $.ajax( {
  396. type : 'GET',
  397. data : "word="+ word,
  398. url : options.url,
  399. dataType : 'json',
  400. timeout : 1000,
  401. success : function(json){handleResponse(parent, json);},
  402. error : handleError
  403. });
  404. $("#oil_type").val("");
  405. }
  406. });
  407. }
  408. })(jQuery);
  409. $(function(){
  410.   $("#plate_number").autopoint({url:'carOilDepotAction.do?task=checkUp'});
  411. });
  412. </script>
  413. <style type="text/css">
  414. .dropDiv {
  415. position: absolute;
  416. z-index: 9999;
  417. display: block;
  418. cursor: hand;
  419. background-color: #FFFFFF;
  420. }
  421. .dropDiv .jhover {
  422. background-color: #D3D3D3;
  423. }
  424. .dropDiv .list {
  425. float:left;
  426. width:100%;
  427. height: 25px;
  428. }
  429. .dropDiv .word {
  430. float:left;
  431. }
  432. .dropDiv .view {
  433. float:right;
  434. color: gray;
  435. text-align: right;
  436. font-size: 10pt;
  437. display: none;
  438. }
  439. </style>
  440. </head>
  441. <!--
  442. <body>
  443. <h1>Google搜索</h1>
  444. <div style="margin-top: 20px; margin-left: 30px">
  445. 请输入搜索关键字:<input type="text" size="50" />
  446.    <input type="text" size="50" />
  447. </div>
  448. </body>
  449. <body>
  450. -->
  451. <%@ include file="/include/message.jsp"%>
  452. <form action="carOilDepotAction.do" method="post" onsubmit="return checkForm()">
  453. <div id="title" class="form-button">
  454. <input type="submit" class="l-button" value="提交" /> <input
  455. type="button" value="关闭" class="l-button" onclick="closeWindow();" />
  456. </div>
  457. <div class="container-layout">
  458. <div class="forum-container">
  459. <center>
  460. <table class="l-table-edit line">
  461. <tr>
  462. <th colspan="4">加油信息</th>
  463. </tr>
  464. <tr>
  465. <td class="l-table-edit-text" width="15%">车牌号<FONT COLOR="red">*</FONT>:</td>
  466. <td class="l-table-edit-td" width="85%" colspan="3">
  467. <input type="text" name="gas.plate_number" id="plate_number" autocomplete="off" style="width: 300px;">
  468. <input type="hidden" name="gas.car_id" id="car_id" style="width: 300px;">
  469. </td>
  470. </tr>
  471. <tr>
  472. <td class="l-table-edit-text" width="15%">油库<FONT COLOR="red">*</FONT>:</td>
  473. <td class="l-table-edit-td" colspan="3">
  474. <select name="gas.gas_station" id="gas_station" style="width: 130px;height: 28px;">
  475. <option value="">--选择--</option>
  476. <c:forEach items="${depots }" var="depots">
  477. <option value="${depots.universalid }">
  478. ${depots.oil_depot_name}
  479. </option>
  480. </c:forEach>
  481. </select></td>
  482. </tr>
  483. <tr>
  484. <td class="l-table-edit-text">油号:</td>
  485. <td class="l-table-edit-td" colspan="3">
  486. <input type="text" id="oil_type" name="oil_type" value="" disabled="disabled">
  487. <input type="hidden" id="oil_type_id" name="gas.oil_type" value="">
  488. </td>
  489. </tr>
  490. <tr>
  491. <td class="l-table-edit-text">加油量<FONT COLOR="red">*</FONT>:</td>
  492. <td class="l-table-edit-td" colspan="3">
  493. <select id="oilType" name="oilType">
  494. <option value="1">升</option>
  495. <option value="2">公斤</option>
  496. </select>
  497. <input type="text" onblur="numeration();" id="gas_volume" name="gas.gas_volume" value="" style="ime-mode: disabled;" onpaste="return false" onkeydown="return check(event)" onkeyup="if(isNaN(this.value)||this.value<0||this.value>100000000000) this.value='0'">
  498. </td>
  499. </tr>
  500. <tr>
  501. <td class="l-table-edit-text">加油时间:<FONT COLOR="red">*</FONT></td>
  502. <td class="l-table-edit-td" colspan="3">
  503. <input type="text" id="gas_time" name="gas_time" value="">
  504. <input type="hidden" id="gas_time" name="gas_time" value="">
  505. <input type="hidden" id="gas_times" name="gas_times" value="">
  506. </td>
  507. </tr>
  508. <tr>
  509. <td class="l-table-edit-text">经手人:</td>
  510. <td class="l-table-edit-td">
  511. <input type="hidden" name="gas.handle_per" id="handle_per" value="" />
  512. <input type="text" id="handle_per_name" name="handle_per_name" value="" readonly="readonly" />
  513. <input type="button" value="请选择" id="assignedUserBtn" class="l-button" />
  514. </td>
  515. </tr>
  516. <tr>
  517. <td class="l-table-edit-text">备注:</td>
  518. <td class="l-table-edit-td" colspan="3">
  519. <div style="float: left;">
  520. <textarea id="remark" name="gas.remark" rows="3" cols="61"></textarea>
  521. </div></td>
  522. </tr>
  523. </table>
  524. <input type="hidden" id="universalid" name="universalid" value="">
  525. <input type="hidden" id="task" name="task" value="doAddOilAdd">
  526. <input type="hidden" id="tabid" name="tabid" value="${requestScope.tabid}">
  527. </center>
  528. </div>
  529. </div>
  530. </form>
  531. </body>
  532. </html>