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.

235 lines
9.1 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

define(function (require, exports, module) {
//引入业务类基类
let BaseBiz = require('apps/rht/base/rhtBiz');
let rhtComm = require('apps/rht/comm/rhtComm');
//引入业务服务
let Service = require('./stk180301service');
/**
* 定义业务类对象
* @param vm 界面相关ViewModule
*/
function Biz(vm) {
//继承第一步,构造继承
BaseBiz.call(this, vm);
}
//继承第二步,方法继承
inherits(Biz, BaseBiz);
//控制是否允许删除明细 0-否 1-是(允许)
//let Isdel = "0";
//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;
let sdate = rhtComm.GetServerDate(3);
let OrgType = rhtComm.GetOrgType(Store.logOn.orgCode);
if ((OrgType !="1001") && (OrgType !="1002") && (OrgType !="9999")){
newRow.setColumnText('ShOrgCode', Store.logOn.orgCode);
}
newRow.setColumnValue('InOrgCode', InOrgCode);
newRow.setColumnValue('DbDate', sdate);
}
this.super('afterNewRow', dataSrc, newRow);
};
//保存前校验 计算主表合计数量等字段
Biz.prototype.beforeSave = function () {
let curRow = this.dsMaster.currentRow;
if(curRow){
let DbCount = 0.0;
for(let i=0;i<this.dsDetail.rows.length;i++){
let row = this.dsDetail.rows[i];
DbCount = DbCount + TypeUtil.toFloat(row['DbCount']);
}
curRow.setColumnValue('DbCount',DbCount);
}
return this.super('beforeSave');
};
//明细行单行提交触发的校验
Biz.prototype.dataRowValidate = function (dataSrc, dr) {
if (dataSrc.uiObjCode === this.dsDetail.uiObjCode) {
let PluCode = TypeUtil.toString(dr['PluCode']);
let DbCount = TypeUtil.toFloat(dr['DbCount']);
if (PluCode.length <= 0) {
return "商品编码不能为空!";
}
if (DbCount <= 0) {
return "调拨数量应该大于0";
}
}
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 'ShOrgCode':
this.fieldChangedShOrgCode(dataSrc, dr, dc);
break;
case 'ChOrgCode':
this.fieldChangedChOrgCode(dataSrc, dr, dc);
break;
case 'DbDate':
this.fieldChangedDbDate(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');
};
//ShOrgCode 字段变化执行事件
Biz.prototype.fieldChangedShOrgCode = function (dataSrc, dr, dc) {
let self = this;
let currentRow = self.dsMaster.currentRow;
let ShOrgCode = currentRow['ShOrgCode'];
let ChOrgCode = currentRow ? TypeUtil.toString(currentRow['ChOrgCode']) : '';
if (ChOrgCode.length > 0) {
if(ShOrgCode == ChOrgCode){
dr.setColumnError('ShOrgCode', "调入组织和调出组织不能重复!");
return false;
}
}
return true;
};
//ChOrgCode 字段变化执行事件
Biz.prototype.fieldChangedChOrgCode = function (dataSrc, dr, dc) {
let self = this;
let currentRow = self.dsMaster.currentRow;
let ChOrgCode = currentRow['ChOrgCode'];
let ShOrgCode = currentRow ? TypeUtil.toString(currentRow['ShOrgCode']) : '';
if (ShOrgCode.length > 0) {
if(ShOrgCode == ChOrgCode){
dr.setColumnError('ChOrgCode', "调入组织和调出组织不能重复!");
return false;
}
}
return true;
};
//DbDate 字段变化执行事件
Biz.prototype.fieldChangedDbDate = function (dataSrc, dr, dc) {
let self = this;
let currentRow = self.dsMaster.currentRow;
let sdate = rhtComm.GetServerDate(0);
let DbDate = currentRow ? TypeUtil.toString(currentRow['DbDate']) : '';
if (DbDate > sdate) {
dr.setColumnError('DbDate', "调拨到货日期不能早于当前日期!");
return false;
}
return true;
};
//PluCode 字段变化执行事件
Biz.prototype.fieldChangedPluCode = function (dataSrc, dr, dc) {
let PluCode = dr['PluCode'];
if (PluCode.length > 0){
let JSONObject={psPluCode:PluCode,psYwType:"1803"};
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('DbCount', "0");
}
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']);
dr.setColumnValue("DbCount", (PackCount * PackQty) + SglCount);
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']);
dr.setColumnValue("DbCount", (PackCount * PackQty) + SglCount);
return true;
};
//控制主界面按钮状态
Biz.prototype.getOpEnabled = function (opCode) {
let isOk = this.super('getOpEnabled', opCode);
if (!isOk) return false;
let curRow = this.dsMaster.currentRow;
if (opCode == 'pause') {
let JzDate = curRow ? TypeUtil.toString(curRow['JzDate']) : '';
let EndDate = curRow ? TypeUtil.toString(curRow['EndDate']) : '';
if (!curRow)
return false;
if (JzDate == '')
return false;
if (EndDate != '')
return false;
}
return true;
};
//按钮事件控制
Biz.prototype.doOp = function (opCode) {
let self = this;
if (opCode == 'pause') {
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']) : '';
let ChOrgCode = dsrow ? TypeUtil.toString(dsrow['ChOrgCode']) : '';
let Remark = dsrow ? TypeUtil.toString(dsrow['Remark']) : '';
let TimeMark = dsrow ? TypeUtil.toString(dsrow['TimeMark']) : '';
if (BillNo.length > 0){
if (!Store.confirm("您确定要终止当前的调拨通知单吗?")) {
return false;
}
let ret= Service.getSlideMenuData("actExecute","onpause",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;
});