You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

283 lines
12 KiB

4 years ago
define(function (require, exports, module) {
//引入业务类基类
let BaseBiz = require('apps/rht/base/rhtBiz');
let rhtComm = require('apps/rht/comm/rhtComm');
//引入业务服务
let Service = require('./stk180305service');
/**
* 定义业务类对象
* @param vm 界面相关ViewModule
*/
function Biz(vm) {
//继承第一步,构造继承
BaseBiz.call(this, vm);
}
//继承第二步,方法继承
inherits(Biz, BaseBiz);
let IsMdKwMng = rhtComm.getRhtOptionValue(Store.logOn.orgCode,'STK','IsMdKwMng','1');
//新增行后处理,默认值已经处理
Biz.prototype.afterNewRow = function (dataSrc, newRow) {
if (dataSrc.uiObjCode === this.dsMaster.uiObjCode) {
let InOrgCode = rhtComm.GetInOrgCode(Store.logOn.orgCode).message;
newRow.setColumnText('InOrgCode', InOrgCode);
}
this.super('afterNewRow', dataSrc, newRow);
};
//单据删除前处理
Biz.prototype.beforeDelete = function () {
let masterRow = this.dsMaster.currentRow;
let BillNo = masterRow ? TypeUtil.toString(masterRow['BillNo']) : '';
let ret= Service.getSlideMenuData("DoOnMasterRule","DoLsYkKcLock",BillNo,"1808","1","","");
if (ret.result !== 1) {
masterRow.setColumnError('BillNo', '删除锁定库存失败:'+ret.message);
return false;
}
return this.super('beforeDelete');
};
//保存前校验 计算主表合计数量等字段
Biz.prototype.beforeSave = function () {
let masterRow = this.dsMaster.currentRow;
if(masterRow){
let YkCount = 0.0;
for(let i=0;i<this.dsDetail.rows.length;i++){
let row = this.dsDetail.rows[i];
YkCount = YkCount + TypeUtil.toFloat(row['YkCount']);
}
masterRow.setColumnValue('YkCount',YkCount);
}
let BillNo = masterRow ? TypeUtil.toString(masterRow['BillNo']) : '';
let ret= Service.getSlideMenuData("DoOnMasterRule","DoLsYkKcLock",BillNo,"1808","0","","");
if (ret.result !== 1) {
masterRow.setColumnError('BillNo', '锁定库存失败:'+ret.message);
return false;
}
return this.super('beforeSave');
};
//明细行单行提交触发的校验
Biz.prototype.dataRowValidate = function (dataSrc, dr) {
if (dataSrc.uiObjCode === this.dsDetail.uiObjCode) {
let masterRow = this.dsMaster.currentRow;
let BillNo = masterRow ? TypeUtil.toString(masterRow['BillNo']) : '';
let InOrgCode = masterRow ? TypeUtil.toString(masterRow['InOrgCode']) : '';
let OldCkCode = masterRow ? TypeUtil.toString(masterRow['OldCkCode']) : '';
let NewCkCode = masterRow ? TypeUtil.toString(masterRow['NewCkCode']) : '';
let PluCode = dr ? TypeUtil.toString(dr['PluCode']) : '';
if (PluCode.length <= 0) {
return "商品编码不能为空!";
}
let PcNo = dr ? TypeUtil.toString(dr['PcNo']) : '';
let YkCount = TypeUtil.toFloat(dr['YkCount']);
if (YkCount <= 0) {
return "移库数量不能小于或等于零!";
}
if (PcNo != "*") {
retPc = Service.getSlideMenuData("DoOnDetailCalcRule","GetPcNo",PcNo,"","","","");
if (retPc.result === 1) {
if (retPc.data == null) {
return "此批次不存在。请重新选择。";
}
else{
dr.setColumnText('PluType', retPc.data.PluType);
}
}
}
let PluId = dr ? TypeUtil.toString(dr['PluId']) : '';
let PluType = TypeUtil.toString(dr['PluType']);
let ExPluCode = TypeUtil.toString(dr['ExPluCode']);
let fKyCount = 0.0;
let fLockCount = 0.0;
let retPc = Service.getSlideMenuData("DoOnDetailCalcRule","GetLockCount",InOrgCode,OldCkCode,PluId,PluType,BillNo,PcNo);
if (retPc.result === 1) {
if (retPc.data != null) {
fLockCount = retPc.data.LockCount;
}
}
let Params = BillNo+";"+"1808;*;"+InOrgCode+";"+OldCkCode+";"+NewCkCode+";"+PluId+";"+ExPluCode+";"+PluType+";"+PcNo;
let JSONObject={DataType:"9",Params:Params};
let retKyCount = Service.getSlideMenuData("pubsysBaseBL","MSysGetLsKcKyCount",JSONObject,"","","","");
if (retKyCount.result === 1) {
fKyCount = TypeUtil.toFloat(retKyCount.message);
if ((fKyCount + fLockCount) < YkCount){
let errmsg = "商品"+PluCode+"的移库数量大于当前可用数量:"+retKyCount.message;
return errmsg;
}
}
else{
return "查询商品库存失败:"+retKyCount.message;
}
}
return true;
};
/**
* @description 数据发生变化时调用
* @param dataSrc 数据集
* @param dr 数据行
* @param dc 数据列
*/
Biz.prototype.fieldChanged = function (dataSrc, dr, dc) {
let self = this;
let currentRow = self.dsMaster.currentRow;
if (currentRow === null) return false;
if (dataSrc.uiObjCode === this.dsMaster.uiObjCode) {
switch (dc.fieldName) {
case 'OldCkCode':
this.fieldChangedOldCkCode(dataSrc, dr, dc);
break;
case 'NewCkCode':
this.fieldChangedNewCkCode(dataSrc, dr, dc);
break;
case 'IsPcNo':
this.fieldChangedIsPcNo(dataSrc, dr, dc);
break;
}
}
if (dataSrc.uiObjCode === this.dsDetail.uiObjCode) {
switch (dc.fieldName) {
case 'PluCode':
this.fieldChangedPluCode(dataSrc, dr, dc);
break;
case 'SglCount':
this.fieldChangedSglCount(dataSrc, dr, dc);
break;
case 'PackCount':
this.fieldChangedPackCount(dataSrc, dr, dc);
break;
}
}
this.super('fieldChanged');
};
//OldCkCode 字段变化执行事件
Biz.prototype.fieldChangedOldCkCode = function (dataSrc, dr, dc) {
let OldCkCode = dr ? TypeUtil.toString(dr['OldCkCode']) : '';
let NewCkCode = dr ? TypeUtil.toString(dr['NewCkCode']) : '';
if (OldCkCode.length > 0){
if (NewCkCode == OldCkCode) {
dr.setColumnError(dc.fieldName, "移出仓库与移入仓库不能相同!");
return false;
}
}
return true;
};
//NewCkCode 字段变化执行事件
Biz.prototype.fieldChangedNewCkCode = function (dataSrc, dr, dc) {
let OldCkCode = dr ? TypeUtil.toString(dr['OldCkCode']) : '';
let NewCkCode = dr ? TypeUtil.toString(dr['NewCkCode']) : '';
if (NewCkCode.length > 0){
if (NewCkCode == OldCkCode) {
dr.setColumnError(dc.fieldName, "移入仓库与移出仓库不能相同!");
return false;
}
}
return true;
};
//IsPcNo 字段变化执行事件
Biz.prototype.fieldChangedIsPcNo = function (dataSrc, dr, dc) {
let IsPcNo = dr ? TypeUtil.toString(dr['IsPcNo']) : '';
if (IsPcNo == "1"){
dr.setColumnText("IsPluType", "0");
}
else{
dr.setColumnText("IsPluType", "1");
}
return true;
};
//PluCode 字段变化执行事件
Biz.prototype.fieldChangedPluCode = function (dataSrc, dr, dc) {
let PluCode = dr ? TypeUtil.toString(dr['PluCode']) : '';
if (PluCode.length > 0){
let self = this;
let currentRow = self.dsMaster.currentRow;
let InOrgCode = currentRow ? TypeUtil.toString(currentRow['InOrgCode']) : '';
let OldCkCode = currentRow ? TypeUtil.toString(currentRow['OldCkCode']) : '';
let NewCkCode = currentRow ? TypeUtil.toString(currentRow['NewCkCode']) : '';
let CurInOrgCode = rhtComm.GetInOrgCode(Store.logOn.orgCode).message;
let fPrice = 0.0;
let ret= Service.getSlideMenuData("DoOnDetailCalcRule","PluCode","",PluCode,CurInOrgCode,"","");
if (ret.result !== 1) {
dr.setColumnError(dc.fieldName, ret.message);
return false;
}
if (ret.data != null) {
fPrice = TypeUtil.toFloat(ret.data.Price);
}
if (IsMdKwMng == "1"){
let PluId = dr ? TypeUtil.toString(dr['PluId']) : '';
let retKw= Service.getSlideMenuData("DoOnMasterRule","GetPluKw",OldCkCode,InOrgCode,PluId,"","");
if (retKw.result === 1) {
if (retKw.data !== null) {
dr.setColumnValue('OutKwCode', retKw.data.KwCode);
}
}
retKw= Service.getSlideMenuData("DoOnMasterRule","GetPluKw",NewCkCode,InOrgCode,PluId,"","");
if (retKw.result === 1) {
if (retKw.data !== null) {
dr.setColumnValue('InKwCode', retKw.data.KwCode);
}
}
}
let JSONObject={psPluCode:PluCode,psYwType:"1808"};
let retPacket= Service.getSlideMenuData("pubsysBaseBL","GetDefaultPluPackUnitByYwType",JSONObject,PluCode,"","","");
if (retPacket.result === 1) {
if (retPacket.data != null) {
dr.setColumnValue('PackUnit', retPacket.data.Unit);
dr.setColumnValue('PackQty', retPacket.data.Qty);
}
}
dr.setColumnValue("PackCount", "0");
dr.setColumnText("SglCount", "0");
dr.setColumnValue("Price", fPrice);
}
return true;
};
//SglCount 字段变化执行事件
Biz.prototype.fieldChangedSglCount = function (dataSrc, dr, dc) {
let PackQty = TypeUtil.toFloat(dr['PackQty']);
let PackCount = TypeUtil.toFloat(dr['PackCount']);
let SglCount = TypeUtil.toFloat(dr['SglCount']);
let YkCount = (PackCount*PackQty)+SglCount;
let DotDecimal = TypeUtil.toFloat(dr['R_DotDecimal']);
dr.setColumnValue("YkCount", YkCount);
let sdl= 0;
if (SglCount.toString().indexOf(".") !== -1) {
sdl= SglCount.toString().split(".")[1].length || 0;
}
if (DotDecimal < sdl){
dr.setColumnError(dc.fieldName, "此商品的小数精度是" + dr['R_DotDecimal'] );
return false;
}
return true;
};
//PackCount 字段变化执行事件
Biz.prototype.fieldChangedPackCount = function (dataSrc, dr, dc) {
let PackQty = TypeUtil.toFloat(dr['PackQty']);
let PackCount = TypeUtil.toFloat(dr['PackCount']);
let SglCount = TypeUtil.toFloat(dr['SglCount']);
let YkCount = (PackCount*PackQty)+SglCount;
let DotDecimal = TypeUtil.toFloat(dr['R_DotDecimal']);
dr.setColumnValue("YkCount", YkCount);
let sdl= 0;
if (YkCount.toString().indexOf(".") !== -1) {
sdl= YkCount.toString().split(".")[1].length || 0;
}
if (DotDecimal < sdl){
dr.setColumnError(dc.fieldName, "此商品的小数精度是" + dr['R_DotDecimal'] );
return false;
}
return true;
};
return Biz;
});