sysGoodsApplicationEdit.jsp 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. <%--
  2. time:2017-06-05 16:33:55
  3. desc:edit the 物品申请
  4. --%>
  5. <%@page language="java" pageEncoding="UTF-8"%>
  6. <%@include file="/commons/include/html_doctype.html"%>
  7. <html>
  8. <head>
  9. <title>编辑 物品申请</title>
  10. <%@include file="/commons/include/form.jsp" %>
  11. <script type="text/javascript" src="${ctx}/js/hotent/CustomValid.js"></script>
  12. <script type="text/javascript" src="${ctx}/js/hotent/formdata.js"></script>
  13. <script type="text/javascript" src="${ctx}/js/hotent/subform.js"></script>
  14. <script type="text/javascript">
  15. var productids;
  16. $(function() {
  17. $("a.add").click(function() {
  18. var flag = '${sysGoodsApplication.flag}';
  19. if(flag == 2){
  20. $('#sysGoodsApplicationRelaTable a').css('display','');
  21. $('#sysGoodsApplicationRelaTable input:text').not('input[name="quantity"]').prop('readonly',true);
  22. }
  23. });
  24. });
  25. $(function() {
  26. $("a.save").click(function() {
  27. var productcode = $("input[name='productcode']").val();
  28. if(!productcode) {
  29. $.ligerDialog.warn("请添加至少一件物品","消息提示");
  30. return;
  31. }
  32. $("#sysGoodsApplicationForm").attr("action","save.ht");
  33. $("#saveData").val(1);
  34. submitForm();
  35. });
  36. });
  37. //提交表单
  38. function submitForm(){
  39. var options={};
  40. if(showResponse){
  41. options.success=showResponse;
  42. }
  43. var frm=$('#sysGoodsApplicationForm').form();
  44. frm.ajaxForm(options);
  45. if(frm.valid()){
  46. frm.sortList();
  47. frm.submit();
  48. }
  49. }
  50. function showResponse(responseText) {
  51. var obj = new com.hotent.form.ResultMessage(responseText);
  52. if(!obj.isSuccess()){
  53. $.ligerDialog.err("提示信息"," 物品申请保存失败!",obj.getMessage());
  54. return;
  55. }
  56. $.ligerDialog.confirm(obj.getMessage()+",是否继续操作","提示信息", function(rtn) {
  57. if(rtn){
  58. window.location.href = window.location.href;
  59. }else{
  60. window.location.href = "${ctx}/platform/system/sysGoodsApplication/list.ht?flag=${sysGoodsApplication.flag}";
  61. }
  62. });
  63. }
  64. /*选择物品*/
  65. function selectGoods(flag){goodsDialog(flag,{callback:function (data){
  66. var temddata = data[0].value.split("#");
  67. $("#sysGoodsApplicationRelaForm tr,th,td").find('input[name="productid"]').val(temddata[0]);
  68. $("#sysGoodsApplicationRelaForm tr,th,td").find('input[name="productcode"]').val(temddata[1]);
  69. $("#sysGoodsApplicationRelaForm tr,th,td").find('input[name="productname"]').val(temddata[2]);
  70. $("#sysGoodsApplicationRelaForm tr,th,td").find('input[name="brand"]').val(temddata[3]);
  71. $("#sysGoodsApplicationRelaForm tr,th,td").find('input[name="specification"]').val(temddata[4]);
  72. $("#sysGoodsApplicationRelaForm tr,th,td").find('input[name="price"]').val(temddata[5]);
  73. }});
  74. }
  75. /*物品对话框*/
  76. function goodsDialog(flag,conf){
  77. $("input[name='productid']").each(function(){
  78. var pro = $(this),
  79. tr = pro.parents("tr"),
  80. productid = $("input[name='productid']",tr).val();
  81. if(productid && productids.indexOf(productid) == -1) {
  82. productids = productid + "," + productids;
  83. }
  84. });
  85. if(!productids) productids = "";
  86. if(!conf) conf={};
  87. var url=__ctx + "/platform/system/sysGoodsApplication/selector.ht?flag=" + flag + "&productids=" + productids;
  88. var dialog = null;
  89. dialog = DialogUtil.open({
  90. passConf : {dialog:dialog},
  91. url:url,
  92. title : "物品列表",
  93. width : 600,
  94. height : 400,
  95. modal : true,
  96. resizable : true,
  97. buttons:[{
  98. text:'确定',
  99. onclick:function(){
  100. var arrysysgoods = dialog.jiframe.contents().find("input[name='sysgoodsdata'][checked]");
  101. if(conf.callback){
  102. conf.callback(arrysysgoods);
  103. dialog.close();
  104. }else{
  105. dialog.close();
  106. }
  107. }
  108. },{
  109. text:'取消',
  110. onclick: function (item,dialog) { dialog.close(); }
  111. }]
  112. });
  113. }
  114. function calculateP(obj) {
  115. if($("#sysGoodsApplicationRelaForm tr,th,td").find('input[name="quantity"]').val() != 0) {
  116. $("#sysGoodsApplicationRelaForm tr,th,td").find('input[name="totalprice"]').val(($("#sysGoodsApplicationRelaForm tr,th,td").find('input[name="quantity"]').val()*(obj.val()*100).toFixed(2))/100);
  117. }
  118. }
  119. function calculateQ(obj) {
  120. if($("#sysGoodsApplicationRelaForm tr,th,td").find('input[name="price"]').val() != 0) {
  121. $("#sysGoodsApplicationRelaForm tr,th,td").find('input[name="totalprice"]').val((($("#sysGoodsApplicationRelaForm tr,th,td").find('input[name="price"]').val()*100).toFixed(2)*obj.val())/100);
  122. }
  123. }
  124. function validateP(obj){
  125. var reg = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/;
  126. if(!reg.test(obj.val())){
  127. $.ligerDialog.error("请输入正确数字类型","提示信息");
  128. obj.val("");
  129. $("#sysGoodsApplicationRelaForm tr,th,td").find('input[name="totalprice"]').val("");
  130. return;
  131. }
  132. }
  133. function validateQ(obj){
  134. var quantity = obj.val();
  135. var reg = /^[0-9]*$/;
  136. if(!reg.test(quantity)){
  137. $.ligerDialog.error("请输入正确数字类型","提示信息");
  138. obj.val("");
  139. $("#sysGoodsApplicationRelaForm tr,th,td").find('input[name="totalprice"]').val("");
  140. return;
  141. }
  142. var productid = $("#sysGoodsApplicationRelaForm tr,th,td").find('input[name="productid"]').val();
  143. var url = __ctx + "/platform/system/sysGoodsApplication/validate.ht";
  144. if(quantity.length > 0) {
  145. var rtn = {
  146. status : 0,
  147. msg : ""
  148. };
  149. $.ajax({
  150. url:url,
  151. data:{
  152. productid : productid,
  153. quantity : quantity
  154. },
  155. async:false
  156. }).done(function(data){
  157. if(data.status){
  158. rtn.status = -1;
  159. rtn.msg = data.msg;
  160. }
  161. }).fail(function(){
  162. rtn.status = -1;
  163. rtn.msg='后台出错!';
  164. });
  165. if(rtn.status){
  166. if(rtn.msg){
  167. $.ligerDialog.warn(rtn.msg,"消息提示");
  168. }
  169. obj.val("");
  170. $("#sysGoodsApplicationRelaForm tr,th,td").find('input[name="totalprice"]').val("");
  171. return;
  172. }
  173. }
  174. }
  175. </script>
  176. </head>
  177. <body>
  178. <div class="panel">
  179. <div class="panel-top">
  180. <div class="tbar-title">
  181. <c:choose>
  182. <c:when test="${sysGoodsApplication.id !=null}">
  183. <span class="tbar-label"><span></span>编辑物品申请</span>
  184. </c:when>
  185. <c:otherwise>
  186. <span class="tbar-label"><span></span>添加物品申请</span>
  187. </c:otherwise>
  188. </c:choose>
  189. </div>
  190. <div class="panel-toolbar">
  191. <div class="toolBar">
  192. <div class="group"><a class="link save" id="dataFormSave" href="#"><span></span>申请</a></div>
  193. <div class="l-bar-separator"></div>
  194. <div class="group"><a class="link back" href="list.ht?flag=${sysGoodsApplication.flag}"><span></span>返回</a></div>
  195. </div>
  196. </div>
  197. </div>
  198. <div class="panel-body">
  199. <form id="sysGoodsApplicationForm" method="post" action="save.ht">
  200. <table class="table-detail" cellpadding="0" cellspacing="0" border="0" type="main">
  201. <tr>
  202. <th width="20%">申请科室: </th>
  203. <td><input type="text" id="department" name="department" value="${sysGoodsApplication.department}" class="inputText" validate="{required:false,maxlength:32}" readonly /></td>
  204. </tr>
  205. <tr>
  206. <th width="20%">人员: </th>
  207. <td><input type="text" id="personnel" name="personnel" value="${sysGoodsApplication.personnel}" class="inputText" validate="{required:false,maxlength:32}" readonly /></td>
  208. </tr>
  209. <tr>
  210. <th width="20%">申请时间: </th>
  211. <td><input type="text" id="applicationdate" name="applicationdate" value="<fmt:formatDate value='${sysGoodsApplication.applicationdate}' pattern='yyyy-MM-dd HH:mm:ss'/>" class="inputText" style="width:150px" validate="{date:true}" readonly /></td>
  212. </tr>
  213. <tr>
  214. <th width="20%">申请原因: </th>
  215. <td><textarea rows="6" style="width:500px" id="reason" name="reason" validate={required:false}></textarea></td>
  216. </tr>
  217. </table>
  218. <table class="table-grid table-list" cellpadding="1" cellspacing="1" id="sysGoodsApplicationRela" formtype="form" type="subtable">
  219. <tr>
  220. <td colspan="8">
  221. <div class="group" align="left">
  222. <a id="btnAdd" class="link add">添加</a>
  223. </div>
  224. <div align="center">
  225. 申请物品
  226. </div>
  227. </td>
  228. </tr>
  229. <tr>
  230. <th>物品编号</th>
  231. <th>物品名称</th>
  232. <th>品牌</th>
  233. <th>规格</th>
  234. <th id="price">价格</th>
  235. <th>数量</th>
  236. <th id="totalprice">总价</th>
  237. </tr>
  238. <c:forEach items="${sysGoodsApplicationRelaList}" var="sysGoodsApplicationRelaItem" varStatus="status">
  239. <tr type="subdata">
  240. <td style="text-align: center" name="productcode">${sysGoodsApplicationRelaItem.productcode}</td>
  241. <td style="text-align: center" name="productname">${sysGoodsApplicationRelaItem.productname}</td>
  242. <td style="text-align: center" name="brand">${sysGoodsApplicationRelaItem.brand}</td>
  243. <td style="text-align: center" name="specification">${sysGoodsApplicationRelaItem.specification}</td>
  244. <td style="text-align: center" id="price" name="price">${sysGoodsApplicationRelaItem.price}</td>
  245. <td style="text-align: center" name="quantity">${sysGoodsApplicationRelaItem.quantity}</td>
  246. <td style="text-align: center" id="totalprice" name="totalprice">${sysGoodsApplicationRelaItem.totalprice}</td>
  247. <input type="hidden" name="productid" value="${sysGoodsApplicationRelaItem.productid}"/>
  248. <input type="hidden" name="productcode" value="${sysGoodsApplicationRelaItem.productcode}"/>
  249. <input type="hidden" name="productname" value="${sysGoodsApplicationRelaItem.productname}"/>
  250. <input type="hidden" name="brand" value="${sysGoodsApplicationRelaItem.brand}"/>
  251. <input type="hidden" name="specification" value="${sysGoodsApplicationRelaItem.specification}"/>
  252. <input type="hidden" id="price" name="price" value="${sysGoodsApplicationRelaItem.price}"/>
  253. <input type="hidden" name="quantity" value="${sysGoodsApplicationRelaItem.quantity}"/>
  254. <input type="hidden" id="totalprice" name="totalprice" value="${sysGoodsApplicationRelaItem.totalprice}"/>
  255. </tr>
  256. </c:forEach>
  257. <tr type="append">
  258. <td style="text-align: center" name="productcode"></td>
  259. <td style="text-align: center" name="productname"></td>
  260. <td style="text-align: center" name="brand"></td>
  261. <td style="text-align: center" name="specification"></td>
  262. <td style="text-align: center" id="price" name="price"></td>
  263. <td style="text-align: center" name="quantity"></td>
  264. <td style="text-align: center" id="totalprice" name="totalprice"></td>
  265. <input type="hidden" name="productid" value=""/>
  266. <input type="hidden" name="productcode" value=""/>
  267. <input type="hidden" name="productname" value=""/>
  268. <input type="hidden" name="brand" value=""/>
  269. <input type="hidden" name="specification" value=""/>
  270. <input type="hidden" id="price" name="price" value=""/>
  271. <input type="hidden" name="quantity" value=""/>
  272. <input type="hidden" id="totalprice" name="totalprice" value=""/>
  273. </tr>
  274. </table>
  275. <input type="hidden" name="id" value="${sysGoodsApplication.id}" />
  276. <input type="hidden" name="flag" value="${sysGoodsApplication.flag}" />
  277. <input type="hidden" name="saveData" id="saveData" />
  278. <input type="hidden" name="executeType" value="start" />
  279. </form>
  280. </div>
  281. <form id="sysGoodsApplicationRelaForm" style="display:none" title="申请物品">
  282. <table class="table-detail" id="sysGoodsApplicationRelaTable" cellpadding="0" cellspacing="0" border="0">
  283. <tr>
  284. <th width="20%">物品编号: <span class="required red">*</span></th>
  285. <td>
  286. <input type="text" name="productcode" value="" class="inputText" validate="{required:true,number:true }"/>
  287. <a class="button" style="display:none" onclick="selectGoods('${sysGoodsApplication.flag}');"><span>选择</span></a>
  288. </td>
  289. </tr>
  290. <tr>
  291. <th width="20%">物品名称: <span class="required red">*</span></th>
  292. <td><input type="text" name="productname" value="" class="inputText" validate="{required:true,maxlength:128}"/></td>
  293. </tr>
  294. <tr>
  295. <th width="20%">品牌: <span class="required red">*</span></th>
  296. <td><input type="text" name="brand" value="" class="inputText" validate="{required:true,maxlength:32}"/></td>
  297. </tr>
  298. <tr>
  299. <th width="20%">规格: <span class="required red">*</span></th>
  300. <td><input type="text" name="specification" value="" class="inputText" validate="{required:true}"/></td>
  301. </tr>
  302. <tr id="price">
  303. <th width="20%">价格: <span class="required red">*</span></th>
  304. <td><input type="text" name="price" value="" class="inputText" onBlur="validateP($(this))" onchange="calculateP($(this))" validate="{required:true,number:true,maxDecimalLen:2,maxIntLen:18 }"/></td>
  305. </tr>
  306. <tr>
  307. <th width="20%">数量: <span class="required red">*</span></th>
  308. <td><input type="text" name="quantity" value="" class="inputText" onBlur="validateQ($(this))" onchange="calculateQ($(this))" validate="{required:true,number:true }"/></td>
  309. </tr>
  310. <tr id="totalprice">
  311. <th width="20%">总价: <span class="required red">*</span></th>
  312. <td><input type="text" name="totalprice" value="" class="inputText" validate="{required:true,number:true,maxDecimalLen:2,maxIntLen:18 }" readonly /></td>
  313. </tr>
  314. </table>
  315. <input type="hidden" name="productid" value=""/>
  316. </form>
  317. </div>
  318. </body>
  319. </html>