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.

200 lines
8.6 KiB

define(function (require, exports, module) {
let BaseBiz = require('apps/rht/base/rhtBiz');
let Service = require('./dst200106service');
let rhtComm = require('../../comm/rhtComm');
/**
* 控制按钮的可用
* @param opCode 按钮编码
* @return [description]
*/
function Biz(vm) {
//继承第一步,构造继承
BaseBiz.call(this, vm);
vm.remark =''
}
//继承第二步,方法继承
inherits(Biz, BaseBiz);
let dRefBodyData = null;
let sIsRef = "0";
//增加后
Biz.prototype.afterAdd = function () {
let masterRow = this.dsMaster.currentRow;
let sInOrgCode = rhtComm.GetInOrgCode(Store.logOn.orgCode).message;
masterRow.setColumnText('InOrgCode', sInOrgCode);
return true;
};
//明细行单行提交触发的校验
Biz.prototype.dataRowValidate = function (dataSrc, dr) {
if (dataSrc.uiObjCode === this.dsDetail.uiObjCode) {
let masterRow = this.dsMaster.currentRow;
let sTzType = TypeUtil.toString(masterRow['TzType']);
let sPluCode = TypeUtil.toString(dr['PluCode']);
let sTzCount = TypeUtil.toFloat(dr['TzCount']);
let fOldPsPrice = TypeUtil.toFloat(dr['OldPsPrice']);
let fNewPsPrice = TypeUtil.toFloat(dr['NewPsPrice']);
if (sIsRef == "1") {
return false;
}
if (sPluCode.length > 0) {
if (fNewPsPrice < 0){
return '新配送价不能小于零!';
}
if (fOldPsPrice == fNewPsPrice) {
return '新配送价不能与原配送价相同!';
}
if (sTzType == "2"){
if (sTzCount == 0) {
return '明细表中商品调整数量不符合要求!';
}
}
}
else{
return '商品编码不能为空!';
}
}
return true;
};
//字段变化触发事件
Biz.prototype.fieldChanged = function (dataSrc, dr, dc) {
if (dataSrc.uiObjCode === this.dsMaster.uiObjCode) {
switch (dc.fieldName) {
case 'RefBillNo':
this.fieldChangedRefBillNo(dataSrc, dr, dc);
break;
case 'OrgType':
this.fieldChangedOrgType(dataSrc, dr, dc);
break;
case 'EtpCode':
this.fieldChangedEtpCode(dataSrc, dr, dc);
break;
}
}
if (dataSrc.uiObjCode === this.dsDetail.uiObjCode) {
switch (dc.fieldName) {
case 'PluCode':
this.fieldChangedPluCode(dataSrc, dr, dc);
break;
case 'NewPsPrice':
this.fieldChangedNewPsPrice(dataSrc, dr, dc);
break;
case 'TzCount':
this.fieldChangedTzCount(dataSrc, dr, dc);
break;
}
}
this.super('fieldChanged');
};
//RefBillNo 字段变化执行事件
Biz.prototype.fieldChangedRefBillNo = function (dataSrc, dr, dc) {
let sRefBillNo = TypeUtil.toString(dr['RefBillNo']);
let sEtpCode = dr ? TypeUtil.toString(dr['EtpCode']) : '';
if (sEtpCode.length <= 0){
dr.setColumnError(dc.fieldName, '请输入客户编码!');
return false;
}
dr.setColumnText('JyMode', dc.getRefValue('jymode'));
dr.setColumnText('JsCode', dc.getRefValue('jscode'));
dr.setColumnText('RefBillType', dc.getRefValue('ywtype'));
let ret= Service.getSlideMenuData("DoOnMasterCalcRule","RefBillNo", sRefBillNo, "", "","","");
if (ret.result !== 1) {
dr.setColumnError(dc.fieldName, ret.message);
return false;
}
if (ret.data != null) {
dRefBodyData = ret.data;
}
return true;
};
//OrgType 字段变化执行事件
Biz.prototype.fieldChangedOrgType = function (dataSrc, dr, dc) {
let sOrgType = TypeUtil.toString(dr['OrgType']);
if (sOrgType.length > 0){
dr.setColumnText('YwIOType', sOrgType);
}
return true;
};
//EtpCode 字段变化执行事件
Biz.prototype.fieldChangedEtpCode = function (dataSrc, dr, dc) {
let sEtpCode = dr ? TypeUtil.toString(dr['EtpCode']) : '';
if (sEtpCode === '') return false;
dr.setColumnText('YwIOType', dc.getRefValue('etpdsttype'));
dr.setColumnText('TzType', "0");
return true;
};
//PluCode 字段变化执行事件
Biz.prototype.fieldChangedPluCode = function (dataSrc, dr, dc) {
let sPluCode = dr ? TypeUtil.toString(dr['PluCode']) : '';
if (sPluCode === '') return false;
//如果没有结果-->结束
if (dRefBodyData !== null){
sIsRef = "0";
for(let i = 0; i <= dRefBodyData.length - 1; i++){
if (sPluCode == dRefBodyData[i].plucode){
sIsRef = "1";
dr.setColumnValue('SerialNo', dRefBodyData[i].serialno);
dr.setColumnValue('DepID',dRefBodyData[i].depid);
dr.setColumnValue('DepCode',dRefBodyData[i].depcode);
dr.setColumnValue('DepName',dRefBodyData[i].depname);
dr.setColumnValue('PluID', dRefBodyData[i].pluid);
dr.setColumnValue('PluName', dRefBodyData[i].pluname);
dr.setColumnValue('BarCode',dRefBodyData[i].barcode);
dr.setColumnValue('ExPluCode',dRefBodyData[i].explucode);
dr.setColumnValue('ExPluName',dRefBodyData[i].expluname);
dr.setColumnValue('Spec',dRefBodyData[i].spec);
dr.setColumnValue('Unit',dRefBodyData[i].unit);
dr.setColumnValue('OldPsPrice',dRefBodyData[i].oldpsprice);
dr.setColumnValue('NewPsPrice',dRefBodyData[i].newpsprice);
dr.setColumnValue('PsCjPrice',dRefBodyData[i].pscjprice);
dr.setColumnValue('OldPsTotal',dRefBodyData[i].oldpstotal);
dr.setColumnValue('NewPsTotal',dRefBodyData[i].newpstotal);
dr.setColumnValue('PsCjTotal',dRefBodyData[i].pscjprice);
dr.setColumnValue('TzCount',dRefBodyData[i].tzcount);
dr.setColumnValue('Remark',dRefBodyData[i].remark);
sIsRef = "0";
}
else{
dr.setColumnError('BillNo',"所输入商品编码不在此笔单据中!");
return false;
}
}
}
return true;
};
//NewPsPrice 字段变化执行事件
Biz.prototype.fieldChangedNewPsPrice = function (dataSrc, dr, dc) {
let fOldPsPrice = TypeUtil.toFloat(dr['OldPsPrice']);
let fNewPsPrice = TypeUtil.toFloat(dr['NewPsPrice']);
let fTzCount = TypeUtil.toFloat(dr['TzCount']);
let fOldPsTotal = TypeUtil.toFloat(dr['OldPsTotal']);
let sPluCode = dr ? TypeUtil.toString(dr['PluCode']) : '';
if (sPluCode === '') return false;
let fPsCjPrice = fNewPsPrice - fOldPsPrice;
let fPsCjTotal = (fPsCjPrice*fTzCount).round(2);
let fNewPsTotal = fOldPsTotal+TypeUtil.toFloat((fPsCjPrice*fTzCount).round(2));
dr.setColumnValue('PsCjPrice', fPsCjPrice);
dr.setColumnValue('PsCjTotal', fPsCjTotal);
dr.setColumnValue('NewPsTotal', fNewPsTotal);
return true;
};
//TzCount 字段变化执行事件
Biz.prototype.fieldChangedTzCount = function (dataSrc, dr, dc) {
let fOldPsTotal = TypeUtil.toFloat(dr['OldPsTotal']);
let fTzCount = TypeUtil.toFloat(dr['TzCount']);
let fPsCjPrice = TypeUtil.toFloat(dr['PsCjPrice']);
let sPluCode = dr ? TypeUtil.toString(dr['PluCode']) : '';
if (sPluCode === '') return false;
let fPsCjTotal = (fPsCjPrice*fTzCount).round(2);
let fNewPsTotal = fOldPsTotal+TypeUtil.toFloat((fPsCjPrice*fTzCount).round(2));
dr.setColumnValue('PsCjTotal', fPsCjTotal);
dr.setColumnValue('NewPsTotal', fNewPsTotal);
return true;
};
return Biz;
});