Commit 225364ef by wancheng

数据统计单前端校验优化

parent 66d521f9
......@@ -7,6 +7,7 @@ import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.hp.constant.HPConstant;
import com.baosight.hpjx.hp.constant.HPSqlConstant;
import com.baosight.hpjx.hp.kc.domain.HPKC008;
import com.baosight.hpjx.hp.pz.domain.HPPZ002;
import com.baosight.hpjx.hp.pz.tools.HPPZTools;
import com.baosight.hpjx.util.CommonMethod;
import com.baosight.hpjx.util.EiInfoUtils;
......@@ -76,6 +77,69 @@ public class ServiceHPKC008 extends ServiceBase {
}
return inInfo;
}
/**
* 保存
*
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "数据统计单",operType = "保存",operDesc = "保存")
public EiInfo save(EiInfo inInfo) {
try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
// 写入数据
for (int i = 0; i < resultRows.size(); i++) {
HPKC008 fKc008 = new HPKC008();
fKc008.fromMap(resultRows.get(i));
if (fKc008.getId() == null || fKc008.getId() == 0) {
this.add(fKc008);
} else {
this.modify(fKc008);
}
}
inInfo = this.query(inInfo);
inInfo.setStatus(EiConstant.STATUS_DEFAULT);
inInfo.setMsg("操作成功!本次对[" + resultRows.size() + "]条数据保存成功!");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "保存失败");
}
return inInfo;
}
/**
* 新增操作
*
* @param fKc008
* @return
*/
public void add(HPKC008 fKc008) {
// 去除日期字符串中的-
fKc008.setDateMonth(StringUtil.removeHorizontalLine(fKc008.getDateMonth()));
// 存货名称
fKc008.setInventName(HPPZTools.HpPz004.getByCode(fKc008.getInventCode()).getInventName());
// 计算总金额
fKc008.setTotalPrice(fKc008.getAmount().multiply(fKc008.getPrice()));
// 生成单据号
fKc008.setStatNo(SequenceGenerator.getNextSequence(HPConstant.SequenceId.HPKC008_NUMBER));
DaoUtils.insert(HPKC008.INSERT, fKc008);
}
/**
* 修改操作
*
* @param fKc008
* @return
*/
public void modify(HPKC008 fKc008) {
// 去除日期字符串中的-
fKc008.setDateMonth(StringUtil.removeHorizontalLine(fKc008.getDateMonth()));
// 存货名称
fKc008.setInventName(HPPZTools.HpPz004.getByCode(fKc008.getInventCode()).getInventName());
// 计算总金额
fKc008.setTotalPrice(fKc008.getAmount().multiply(fKc008.getPrice()));
DaoUtils.update(HPKC008.UPDATE, fKc008);
}
/**
* 新增操作
......
......@@ -35,9 +35,13 @@ $(function() {
refreshSelect(container, inInfo);
}
}],
onSave: function (e) {
// 阻止后台保存请求,使用自定义保存
e.preventDefault();
save();
},
onSuccess: function (e) {
if(e.eiInfo.extAttr.methodName == 'update'
||e.eiInfo.extAttr.methodName == 'insert'
if(e.eiInfo.extAttr.methodName == 'save'
||e.eiInfo.extAttr.methodName == 'delete' ){
query();
}
......@@ -69,3 +73,42 @@ $(window).load(function () {
let query = function () {
resultGrid.dataSource.page(1);
}
/**
* 保存
*/
let save = function () {
let rows = resultGrid.getCheckedRows();
if (rows.length < 1) {
message("请选择数据");
return;
}
for (let i = 0; i < rows.length; i++) {
if (isBlank(rows[i]['dateMonth'])) {
message("勾选的第" + (i + 1) + "行\"月份\"不能为空");
return;
}
if (isBlank(rows[i]['inventCode'])) {
message("勾选的第" + (i + 1) + "行\"存货名称\"不能为空");
return;
}
if (isBlank(rows[i]['unit'])) {
message("勾选的第" + (i + 1) + "行\"单位\"不能为空");
return;
}
if (!isPositiveInteger(rows[i]['amount'])) {
message("勾选的第" + (i + 1) + "行\"数量\"必须是大于0的整数");
return;
}
if (isBlank(rows[i]['price'])) {
message("勾选的第" + (i + 1) + "行\"单价\"不能为空");
return;
}
}
JSUtils.confirm("确定对勾选中的[" + rows.length + "]条数据做\"保存\"操作? ", {
ok: function () {
JSUtils.submitGridsData("result", "HPKC008", "save", true);
}
});
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment