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.

273 lines
11 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('./stk180308service');
/**
* 定义业务类对象
* @param vm 界面相关ViewModule
*/
function Biz(vm) {
//继承第一步,构造继承
BaseBiz.call(this, vm);
}
//继承第二步,方法继承
inherits(Biz, BaseBiz);
//新增行后处理,默认值已经处理
Biz.prototype.afterNewRow = function (dataSrc, newRow) {
if (dataSrc.uiObjCode === this.dsMaster.uiObjCode) {
let InOrgCode = rhtComm.GetInOrgCode(Store.logOn.orgCode).message;
newRow.setColumnValue('InOrgCode', InOrgCode);
}
this.super('afterNewRow', dataSrc, newRow);
};
//明细行单行提交触发的校验
Biz.prototype.dataRowValidate = function (dataSrc, dr) {
if (dataSrc.uiObjCode === this.dsDetail.uiObjCode) {
let self = this;
let curMaster = self.dsMaster.currentRow;
let BillNo = TypeUtil.toString(curMaster['BillNo']);
let InOrgCode = TypeUtil.toString(curMaster['InOrgCode']);
let CkCode = TypeUtil.toString(curMaster['CkCode']);
let TzCount = TypeUtil.toFloat(dr['TzCount']);
let InPcNo = TypeUtil.toString(dr['InPcNo']);
let OutPcNo = TypeUtil.toString(dr['OutPcNo']);
let DepID = TypeUtil.toString(dr['DepID']);
if (TzCount <= 0) {
return "调整数量应该大于0";
}
if (InPcNo.length <= 0) {
return "调入批次不能为空!";
}
if (OutPcNo.length <= 0) {
return "调出批次不能为空!";
}
if (DepID.length <= 0) {
return "请录入正确的部门信息!";
}
//判断商品库存是否充足
let Params = BillNo+";"+"1814;*;"+InOrgCode+";"+DepID+";"+CkCode+";"+OutPcNo;
let JSONObject={DataType:"1",Params:Params};
let retKyCount = Service.getSlideMenuData("pubsysBaseBL","MSysGetLsKcKyCount",JSONObject,"","","","");
if (retKyCount.result === 1) {
if (TzCount > TypeUtil.toFloat(retKyCount.message)){
let errmsg = "商品调整数量大于当前可用数量"+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.dsDetail.uiObjCode) {
switch (dc.fieldName) {
case 'InPcNo':
this.fieldChangedInPcNo(dataSrc, dr, dc);
break;
case 'OutPcNo':
this.fieldChangedOutPcNo(dataSrc, dr, dc);
break;
case 'SglCount':
this.fieldChangedSglCount(dataSrc, dr, dc);
break;
case 'PackCount':
this.fieldChangedPackCount(dataSrc, dr, dc);
break;
case 'PluCode':
/**使TextOutPcNoInPcNo
*此问题背景输入商品和调入调出批次号后再修改商品时调入调出批次号没有清空
*直接保存记账可能会因为商品与批次不一致造成库存混乱.
**/
dr.setColumnText('OutPcNo', TypeUtil.toString(dataSrc['OutPcNo']));
dr.setColumnText('InPcNo', TypeUtil.toString(dataSrc['InPcNo']));
break;
}
}
this.super('fieldChanged');
};
//InPcNo 字段变化执行事件
Biz.prototype.fieldChangedInPcNo = function (dataSrc, dr, dc) {
let self = this;
let currentRow = self.dsDetail.currentRow;
let InPcNo = currentRow['InPcNo'];
let OutPcNo = currentRow ? TypeUtil.toString(currentRow['OutPcNo']) : '';
if (OutPcNo.length > 0) {
if(InPcNo == OutPcNo){
dr.setColumnError('ShOrgCode', "调入调出批次号不能相同!");
return false;
}
}
let SglCount = TypeUtil.toFloat(dr['SglCount']);
let PackCount = TypeUtil.toFloat(dr['PackCount']);
let PackQty = TypeUtil.toFloat(dr['PackQty']);
let OutHJPrice = TypeUtil.toFloat(dr['OutHJPrice']);
let OutWJPrice = TypeUtil.toFloat(dr['OutWJPrice']);
let InHJPrice = TypeUtil.toFloat(dr['InHJPrice']);
let InWJPrice = TypeUtil.toFloat(dr['InWJPrice']);
let TzCount = (PackCount * PackQty) + SglCount;
let OutHCost = OutHJPrice * TzCount;
let OutWCost = OutWJPrice * TzCount;
let InHCost = InHJPrice * TzCount;
let InWCost = InWJPrice * TzCount;
dr.setColumnValue("TzCount", TzCount);
dr.setColumnValue("OutHCost", OutHCost);
dr.setColumnValue("OutWCost", OutWCost);
dr.setColumnValue("InHCost", InHCost);
dr.setColumnValue("InWCost", InWCost);
dr.setColumnValue("TzHTotal", InHCost - OutHCost);
dr.setColumnValue("TzWTotal", InWCost - OutWCost);
return true;
};
//OutPcNo 字段变化执行事件
Biz.prototype.fieldChangedOutPcNo = function (dataSrc, dr, dc) {
let self = this;
let currentRow = self.dsDetail.currentRow;
let OutPcNo = currentRow['OutPcNo'];
let InPcNo = currentRow ? TypeUtil.toString(currentRow['InPcNo']) : '';
if (InPcNo.length > 0) {
if(InPcNo == OutPcNo){
dr.setColumnError('ShOrgCode', "调入调出批次号不能相同!");
return false;
}
}
let SglCount = TypeUtil.toFloat(dr['SglCount']);
let PackCount = TypeUtil.toFloat(dr['PackCount']);
let PackQty = TypeUtil.toFloat(dr['PackQty']);
let OutHJPrice = TypeUtil.toFloat(dr['OutHJPrice']);
let OutWJPrice = TypeUtil.toFloat(dr['OutWJPrice']);
let InHJPrice = TypeUtil.toFloat(dr['InHJPrice']);
let InWJPrice = TypeUtil.toFloat(dr['InWJPrice']);
let TzCount = (PackCount * PackQty) + SglCount;
let OutHCost = OutHJPrice * TzCount;
let OutWCost = OutWJPrice * TzCount;
let InHCost = InHJPrice * TzCount;
let InWCost = InWJPrice * TzCount;
dr.setColumnValue("TzCount", TzCount);
dr.setColumnValue("OutHCost", OutHCost);
dr.setColumnValue("OutWCost", OutWCost);
dr.setColumnValue("InHCost", InHCost);
dr.setColumnValue("InWCost", InWCost);
dr.setColumnValue("TzHTotal", InHCost - OutHCost);
dr.setColumnValue("TzWTotal", InWCost - OutWCost);
return true;
};
//SglCount 字段变化执行事件
Biz.prototype.fieldChangedSglCount = function (dataSrc, dr, dc) {
let SglCount = TypeUtil.toFloat(dr['SglCount']);
let PackCount = TypeUtil.toFloat(dr['PackCount']);
let PackQty = TypeUtil.toFloat(dr['PackQty']);
let OutHJPrice = TypeUtil.toFloat(dr['OutHJPrice']);
let OutWJPrice = TypeUtil.toFloat(dr['OutWJPrice']);
let InHJPrice = TypeUtil.toFloat(dr['InHJPrice']);
let InWJPrice = TypeUtil.toFloat(dr['InWJPrice']);
let TzCount = (PackCount * PackQty) + SglCount;
let OutHCost = OutHJPrice * TzCount;
let OutWCost = OutWJPrice * TzCount;
let InHCost = InHJPrice * TzCount;
let InWCost = InWJPrice * TzCount;
dr.setColumnValue("TzCount", TzCount);
dr.setColumnValue("OutHCost", OutHCost);
dr.setColumnValue("OutWCost", OutWCost);
dr.setColumnValue("InHCost", InHCost);
dr.setColumnValue("InWCost", InWCost);
dr.setColumnValue("TzHTotal", InHCost - OutHCost);
dr.setColumnValue("TzWTotal", InWCost - OutWCost);
};
//PackCount 字段变化执行事件
Biz.prototype.fieldChangedPackCount = function (dataSrc, dr, dc) {
let SglCount = TypeUtil.toFloat(dr['SglCount']);
let PackCount = TypeUtil.toFloat(dr['PackCount']);
let PackQty = TypeUtil.toFloat(dr['PackQty']);
let TzCount = (PackCount * PackQty) + SglCount;
dr.setColumnValue("TzCount", TzCount);
};
/*
//控制主界面按钮状态
Biz.prototype.getOpEnabled = function (opCode) {
let isOk = this.super('getOpEnabled', opCode);
if (!isOk) return false;
let curRow = this.dsMaster.currentRow;
if (opCode == 'edit') {
let OrgCode = curRow ? TypeUtil.toString(curRow['OrgCode']) : '';
if (!curRow)
return false;
if (OrgCode != Store.logOn.orgCode)
return false;
}
if (opCode == 'delete') {
let OrgCode = curRow ? TypeUtil.toString(curRow['OrgCode']) : '';
if (!curRow)
return false;
if (OrgCode != Store.logOn.orgCode)
return false;
}
if (opCode == 'acc') {
let OrgCode = curRow ? TypeUtil.toString(curRow['OrgCode']) : '';
if (!curRow)
return false;
if (OrgCode != Store.logOn.orgCode)
return false;
}
return true;
};
//按钮事件控制
Biz.prototype.doOp = function (opCode) {
let self = this;
if (opCode == 'acc') {
let ds = self.dsMaster;
this.onpause(self, ds);
}
};
//按钮事件
Biz.prototype.onpause = function (biz, ds) {
let dsrow=ds.currentRow;
let BillNo = dsrow ? TypeUtil.toString(dsrow['BillNo']) : '';
if (BillNo.length > 0){
if (!Store.confirm("您确定要记账当前批次调整单吗?")) {
return false;
}
let ret= Service.getSlideMenuData("doAccount","acc",BillNo,ChOrgCode,Remark,Store.logOn.userCode,Store.logOn.userName,TimeMark);
if (ret.result !== 1) {
dsrow.setColumnError('BillNo', '终止失败:'+ret.message);
return false;
}
else{
Store.messager.tip('调拨通知单已终止!');
//刷新当前行
biz.dsMaster.updateRow();
}
}
return true;
};*/
return Biz;
});