function edit() { eval("var data ="+ grid.colsToJson("rowId","C1==1")); var datas = data.join(",").split(","); //var factIncomeId = grid.getSelectedId(); if(datas==null||datas==""){ skysz.msg.info("请选择要编辑的收款清单的数据。"); return false; } var statuses = grid.colsToArray("6","C1==1",true); for ( var i = 0; i < statuses.length; i++) { var status = statuses[i]; if (status!='未提交') { skysz.msg.info("已提交或已拆分的收款清单不能编辑,请重新选择."); return false; } } var gridData = grid.colsToArray("rowId","(C1==1)"); var ids="["; ids+=gridData; ids+="]" audit.book.receiptDetail.window = skysz.window.modalWindow("收款清单登记 》编辑", 800, 450, '../app/audit/book/receiptDetailEdit.jsp?id='+ids ); } var delIds=""; function del() { eval("var data ="+ grid.colsToJson("rowId","C1==1")); var datas = data.join(",").split(","); //var factIncomeId = grid.getSelectedId(); if(datas==null||datas==""){ skysz.msg.info("请选择要删除的收款清单的数据。"); return false; } var statuses = grid.colsToArray("6","C1==1",true); for ( var i = 0; i < statuses.length; i++) { var status = statuses[i]; if (status!='未提交') { skysz.msg.info("已提交或已拆分的收款清单不能删除,请重新选择."); return false; } } var gridData = grid.colsToArray("rowId","(C1==1)"); var ids="["; ids+=gridData; ids+="]"; delIds=ids; skysz.msg.confirm('你确定要删除所选中信息?', detail_delete_do); } function detail_delete_do(flag) { var url = "${delete}"; if (skysz.msg.isConfirmBack(flag)) { skysz.ajax.post(url, "id=" + delIds, delete_callBack); } } var delete_actionResponse ={}; function delete_callBack(actionResponse){ //success if(skysz.msg.isReturnBack(delete_actionResponse,actionResponse)){ grid.refreash(); //销毁返回对象。 skysz.ajax.destroyActionResponse(delete_actionResponse); } } function submit() { eval("var data ="+ grid.colsToJson("rowId","C1==1")); var datas = data.join(",").split(","); //var factIncomeId = grid.getSelectedId(); if(datas==null||datas==""){ skysz.msg.info("请选择要提交的收款清单的数据。"); return false; } var statuses = grid.colsToArray("6","C1==1",true); for ( var i = 0; i < statuses.length; i++) { var status = statuses[i]; if (status!='未提交') { skysz.msg.info("已提交或已拆分的收款清单不能提交,请重新选择."); return false; } } var payTypes = grid.colsToArray("2","C1==1",true); for ( var i = 0; i < payTypes.length; i++) { var payType = payTypes[i]; if (payType!=payTypes[0]) { skysz.msg.info("缴款类型不一致,请重新选择."); return false; } } var gridData = grid.colsToArray("rowId","(C1==1)"); var ids="["; ids+=gridData; ids+="]" audit.book.receiptDetail.window = skysz.window.modalWindow("收款清单登记 》提交", 600, 200, '../app/audit/book/receiptDetailSubmit.jsp?id='+ids ); } function saveFactPay() { //将grid中的数据转换成JSON. var gridJson = grid.colsToJson("0,1,2,3,4,5"); //调用后台的保存方法. form.submit("${save}", 'grid=' + gridJson, addSaveCallBack); } //操作grid. factPay_add_operateGrid = { checkValue : function() { //得到所有行. var rows = grid.getRowsNum(); if (rows == 0) return true; var items = grid.getAllItemIds().split(","); for ( var i = 0; i < items.length; i++) { var rowId = grid.getRowId(i); //得到行Id if (!grid.validateRow("C1!=''", rowId)) { skysz.msg.info("收款日期为必填项目,请填写完整."); return false; } if (!grid.validateRow("C3!=''", rowId)) { skysz.msg.info("营业厅名称为必填项目,请填写完整."); return false; } //缴款金额不能为0的判断. if (grid.validateRow("C4==0", rowId)) { skysz.msg.info("金额不能为0,请重新填写."); return false; } } return true; } }
/** * 新增 * * @return */ public ActionResponse save() { ActionResponse ar = new ActionResponse(ResponseType.FAILURE); String payType = this.getParameter("payType"); List<String[]> grid = super.getGrid("grid"); List<ReceiptDetail> rdList = new ArrayList<ReceiptDetail>(); if (CollectionUtils.isNotEmpty(grid)) { for (String[] str : grid) { ReceiptDetail rd = new ReceiptDetail(); rd.setPayType(payType); rd.setAmount(Double.parseDouble(str[4])); rd.setHall(new Hall(Long.parseLong(str[3]))); rd.setRemark(str[5]); rd.setStatus("1"); rd.setBusinessDate(DateUtils.toDate(str[1])); rd.setEnable(true); this.setWho(rd); rdList.add(rd); } } receiptDetailService.insertAll(rdList); ar.setResponseType(ResponseType.SUCCESS_SAVE); return ar; } /** * 编辑 * * @return */ public ActionResponse update() { ActionResponse ar = new ActionResponse(ResponseType.FAILURE); String payType = this.getParameter("payType"); List<String[]> grid = super.getGrid("grid"); List<ReceiptDetail> insertList = new ArrayList<ReceiptDetail>(); List<ReceiptDetail> updateList = new ArrayList<ReceiptDetail>(); if (CollectionUtils.isNotEmpty(grid)) { for (String[] str : grid) { ReceiptDetail rd = null; if (str[0].indexOf("K") != -1) { rd = new ReceiptDetail(); } else { rd = this.receiptDetailService.get(Long.parseLong(str[0])); } rd.setPayType(payType); rd.setAmount(Double.parseDouble(str[5])); rd.setHall(new Hall(Long.parseLong(str[4]))); rd.setRemark(str[6]); rd.setStatus("1"); rd.setBusinessDate(DateUtils.toDate(str[2])); rd.setEnable(true); this.setWho(rd); if (str[0].indexOf("K") != -1) { insertList.add(rd); } else { updateList.add(rd); } } } if (CollectionUtils.isNotEmpty(insertList)) { receiptDetailService.insertAll(insertList); } if (CollectionUtils.isNotEmpty(updateList)) { receiptDetailService.updateAll(updateList); } ar.setResponseType(ResponseType.SUCCESS_SAVE); return ar; }