|
|
define(function (require, exports, module) {
|
|
|
let BaseBiz = require('apps/rht/base/rhtBiz');
|
|
|
let Service = require('./dst200105service');
|
|
|
let rhtComm = require('../../comm/rhtComm');
|
|
|
/**
|
|
|
* 控制按钮的可用
|
|
|
* @param opCode 按钮编码
|
|
|
* @return [description]
|
|
|
*/
|
|
|
|
|
|
function Biz(vm) {
|
|
|
//继承第一步,构造继承
|
|
|
BaseBiz.call(this, vm);
|
|
|
vm.remark =''
|
|
|
}
|
|
|
|
|
|
//继承第二步,方法继承
|
|
|
inherits(Biz, BaseBiz);
|
|
|
|
|
|
let IsMdKwMng = rhtComm.getRhtOptionValue('*','STK','IsMdKwMng','1');
|
|
|
|
|
|
//增加后
|
|
|
Biz.prototype.afterAdd = function () {
|
|
|
let masterRow = this.dsMaster.currentRow;
|
|
|
let sInOrgCode = rhtComm.GetInOrgCode(Store.logOn.orgCode).message;
|
|
|
masterRow.setColumnText('InOrgCode', sInOrgCode);
|
|
|
masterRow.setColumnText('PlnThDate', rhtComm.GetServerDate(1));
|
|
|
this.dsMaster.getColumn('DepCode').set('isEditable',true);
|
|
|
this.dsMaster.getColumn('ThOrgCode').set('isEditable',true);
|
|
|
this.dsMaster.getColumn('HtCode').set('isEditable',true);
|
|
|
this.dsMaster.getColumn('Remark').set('isEditable',true);
|
|
|
return true;
|
|
|
};
|
|
|
//编辑后
|
|
|
Biz.prototype.afterEdit = function () {
|
|
|
let masterRow = this.dsMaster.currentRow;
|
|
|
let sGenType = TypeUtil.toString(masterRow['GenType']);
|
|
|
let fOriThCount = TypeUtil.toFloat(masterRow['OriThCount']);
|
|
|
if (sGenType == "1"){
|
|
|
this.dsMaster.getColumn('DepCode').set('isEditable',false);
|
|
|
this.dsMaster.getColumn('ThOrgCode').set('isEditable',false);
|
|
|
this.dsMaster.getColumn('HtCode').set('isEditable',false);
|
|
|
this.dsMaster.getColumn('Remark').set('isEditable',false);
|
|
|
this.dsDetail.allowDel = false;
|
|
|
this.dsDetail.allowEdit = false;
|
|
|
this.dsDetail.allowInsert = false;
|
|
|
}
|
|
|
else{
|
|
|
this.dsMaster.getColumn('DepCode').set('isEditable',true);
|
|
|
this.dsMaster.getColumn('ThOrgCode').set('isEditable',true);
|
|
|
this.dsMaster.getColumn('HtCode').set('isEditable',true);
|
|
|
this.dsMaster.getColumn('Remark').set('isEditable',true);
|
|
|
this.dsDetail.allowDel = true;
|
|
|
this.dsDetail.allowEdit = true;
|
|
|
this.dsDetail.allowInsert = true;
|
|
|
}
|
|
|
if (fOriThCount != 0){
|
|
|
this.dsMaster.getColumn('ThReason').set('isEditable',false);
|
|
|
this.dsDetail.getColumn('ThReason').set('isEditable',false);
|
|
|
}
|
|
|
else{
|
|
|
this.dsMaster.getColumn('ThReason').set('isEditable',true);
|
|
|
this.dsDetail.getColumn('ThReason').set('isEditable',true);
|
|
|
}
|
|
|
return this.super('afterEdit');
|
|
|
};
|
|
|
//保存前校验
|
|
|
Biz.prototype.beforeSave = function () {
|
|
|
let masterRow = this.dsMaster.currentRow;
|
|
|
if(masterRow){
|
|
|
let sOrgCode = masterRow ? TypeUtil.toString(masterRow['OrgCode']) : '';
|
|
|
let sThOrgCode = masterRow ? TypeUtil.toString(masterRow['ThOrgCode']) : '';
|
|
|
let sCurrCode = masterRow ? TypeUtil.toString(masterRow['CurrCode']) : '';
|
|
|
let iErrCount = 0;
|
|
|
for (let i=0;i<this.dsDetail.rows.length;i++){
|
|
|
let row = this.dsDetail.rows[i];
|
|
|
let fThPrice = TypeUtil.toFloat(row['ThPrice']);
|
|
|
if (fThPrice == 0) {
|
|
|
iErrCount = iErrCount + 1;
|
|
|
}
|
|
|
}
|
|
|
if (iErrCount > 0){
|
|
|
if (!Store.confirm("当前单据存在商品退货价为0的数据,是否继续?")) {
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
let retYsYe = Service.getSlideMenuData("BeforeSave","GetPreYsYeTotal",sOrgCode,sThOrgCode,sCurrCode,"","");
|
|
|
if (retYsYe.result === 1) {
|
|
|
masterRow.setColumnValue('PreYsYeTotal', retYsYe.message);
|
|
|
}
|
|
|
}
|
|
|
return this.super('beforeSave');
|
|
|
};
|
|
|
//新增行后处理,默认值已经处理
|
|
|
Biz.prototype.afterNewRow = function (dataSrc, newRow) {
|
|
|
if (dataSrc.uiObjCode === this.dsDetail.uiObjCode) {
|
|
|
let masterRow = this.dsMaster.currentRow;
|
|
|
let sThReason = masterRow ? TypeUtil.toString(masterRow['ThReason']) : '';
|
|
|
if (sThReason.length > 0){
|
|
|
newRow.setColumnText('ThReason', sThReason);
|
|
|
}
|
|
|
}
|
|
|
this.super('afterNewRow', dataSrc, newRow);
|
|
|
};
|
|
|
//明细行单行提交触发的校验
|
|
|
Biz.prototype.dataRowValidate = function (dataSrc, dr) {
|
|
|
if (dataSrc.uiObjCode === this.dsDetail.uiObjCode) {
|
|
|
let sPluCode = TypeUtil.toString(dr['PluCode']);
|
|
|
let fThCount = TypeUtil.toFloat(dr['ThCount']);
|
|
|
|
|
|
if (sPluCode.length > 0) {
|
|
|
if (fThCount < 0){
|
|
|
return '退货数量不能小于零!';
|
|
|
}
|
|
|
let PackUnit = TypeUtil.toString(dr['PackUnit']);
|
|
|
if (PackUnit == ""){
|
|
|
dr.setColumnValue('PackCount', "0");
|
|
|
}
|
|
|
}
|
|
|
else{
|
|
|
return '商品编码不能为空!';
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
|
};
|
|
|
// 列校验,列赋值时调用,发生异常表示校验失败
|
|
|
Biz.prototype.dataColumnValidate = function (dataSrc, dr, dc, value) {
|
|
|
let self = this;
|
|
|
if (dataSrc.uiObjCode === this.dsDetail.uiObjCode) {
|
|
|
if (this.dsDetail.rows.length == 0){
|
|
|
let masterRow = self.dsMaster.currentRow;
|
|
|
let sOrgCode = masterRow ? TypeUtil.toString(masterRow['OrgCode']) : '';
|
|
|
let sThOrgCode = masterRow ? TypeUtil.toString(masterRow['ThOrgCode']) : '';
|
|
|
let sHtCode = masterRow ? TypeUtil.toString(masterRow['HtCode']) : '';
|
|
|
let sCkCode = masterRow ? TypeUtil.toString(masterRow['CkCode']) : '';
|
|
|
if (sThOrgCode.length <= 0){
|
|
|
return "请输入退货组织编码!";
|
|
|
}
|
|
|
if (sCkCode.length <= 0){
|
|
|
return "请输入表头的仓库!";
|
|
|
}
|
|
|
if (rhtComm.GetOrgCode(sThOrgCode) == "1"){
|
|
|
let JSONObject={OrgCode:sOrgCode,EtpCode:sThOrgCode};
|
|
|
let ret= Service.getSlideMenuData("pubsysBaseBL","UOrgIsDlHs",JSONObject,"","","","");
|
|
|
if (ret.result === 1) {
|
|
|
if (sHtCode.length <= 0) {
|
|
|
return "当前组织和退货组织不是同一核算组织,必须输入合同信息!";
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return this.super('dataColumnValidate');
|
|
|
};
|
|
|
//校验小数精度
|
|
|
Biz.prototype.getPrecision = function (dataSrc, dr, dc, defaultPrecision) {
|
|
|
if (dataSrc.uiObjCode == this.dsDetail.uiObjCode) {
|
|
|
//把这里改成需要控制的字段
|
|
|
if ((dc.fieldName == 'PackCount') || (dc.fieldName == 'SglCount')) {
|
|
|
return TypeUtil.toInt(dr['R_DotDecimal']);
|
|
|
}
|
|
|
}
|
|
|
return this.super('getPrecision', dataSrc, dr, dc, defaultPrecision);
|
|
|
};
|
|
|
//字段变化触发事件
|
|
|
Biz.prototype.fieldChanged = function (dataSrc, dr, dc) {
|
|
|
if (dataSrc.uiObjCode === this.dsMaster.uiObjCode) {
|
|
|
switch (dc.fieldName) {
|
|
|
case 'ThOrgCode':
|
|
|
this.fieldChangedThOrgCode(dataSrc, dr, dc);
|
|
|
break;
|
|
|
case 'HtCode':
|
|
|
this.fieldChangedHtCode(dataSrc, dr, dc);
|
|
|
break;
|
|
|
case 'CkCode':
|
|
|
this.fieldChangedCkCode(dataSrc, dr, dc);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if (dataSrc.uiObjCode === this.dsDetail.uiObjCode) {
|
|
|
switch (dc.fieldName) {
|
|
|
case 'PluCode':
|
|
|
this.fieldChangedPluCode(dataSrc, dr, dc);
|
|
|
break;
|
|
|
case 'PackCount':
|
|
|
this.fieldChangedPackCount(dataSrc, dr, dc);
|
|
|
break;
|
|
|
case 'PackUnit':
|
|
|
this.fieldChangedPackUnit(dataSrc, dr, dc);
|
|
|
break;
|
|
|
case 'SglCount':
|
|
|
this.fieldChangedSglCount(dataSrc, dr, dc);
|
|
|
break;
|
|
|
case 'ThPrice':
|
|
|
this.fieldChangedThPrice(dataSrc, dr, dc);
|
|
|
break;
|
|
|
case 'StlCurrThPrice':
|
|
|
this.fieldChangedStlCurrThPrice(dataSrc, dr, dc);
|
|
|
break;
|
|
|
case 'DepCode':
|
|
|
this.fieldChangedDepCode(dataSrc, dr, dc);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
this.super('fieldChanged');
|
|
|
};
|
|
|
//ThOrgCode 字段变化执行事件
|
|
|
Biz.prototype.fieldChangedThOrgCode = function (dataSrc, dr, dc) {
|
|
|
let sThOrgCode = dr ? TypeUtil.toString(dr['ThOrgCode']) : '';
|
|
|
if (sThOrgCode === '') return false;
|
|
|
let sInOrgCode = rhtComm.GetInOrgCode(sThOrgCode).message;
|
|
|
if (sInOrgCode != "*"){
|
|
|
dr.setColumnValue('InThOrgCode', sInOrgCode);
|
|
|
}
|
|
|
dr.setColumnValue('HtCode', "");
|
|
|
dr.setColumnValue('HtName', "");
|
|
|
dr.setColumnValue('CntID', "");
|
|
|
dr.setColumnValue('JyMode', "");
|
|
|
dr.setColumnValue('JsCode', "");
|
|
|
dr.setColumnValue('YwIOType', dc.getRefValue('etpdsttype'));
|
|
|
dr.setColumnText('OrgType', dc.getRefValue('etpdsttype'));
|
|
|
|
|
|
let ret= Service.getSlideMenuData("DoOnMasterCalcRule","ThOrgCode", dr.getData(),"","","","");
|
|
|
if (ret.result !== 1) {
|
|
|
dr.setColumnError(dc.fieldName, ret.message);
|
|
|
return false;
|
|
|
}
|
|
|
if (ret.data != null) {
|
|
|
dr.setColumnValue('CurrCode', ret.data.currcode);
|
|
|
dr.setColumnValue('ExchangeRate', ret.data.exchangerate);
|
|
|
dr.setColumnValue('IsStdCurr', ret.data.isstdcurr);
|
|
|
}
|
|
|
return true;
|
|
|
};
|
|
|
//HtCode 字段变化执行事件
|
|
|
Biz.prototype.fieldChangedHtCode = function (dataSrc, dr, dc) {
|
|
|
let sHtCode = dr ? TypeUtil.toString(dr['HtCode']) : '';
|
|
|
if (sHtCode.length == 0){
|
|
|
dr.setColumnValue('HtName', "");
|
|
|
dr.setColumnValue('CntID', "0");
|
|
|
dr.setColumnValue('JyMode', "0");
|
|
|
dr.setColumnValue('JsCode', "0");
|
|
|
}
|
|
|
else{
|
|
|
dr.setColumnValue('JyMode', dc.getRefValue('jymode'));
|
|
|
dr.setColumnValue('JsCode', dc.getRefValue('jscode'));
|
|
|
}
|
|
|
return true;
|
|
|
};
|
|
|
//CkCode 字段变化执行事件
|
|
|
Biz.prototype.fieldChangedCkCode = function (dataSrc, dr, dc) {
|
|
|
let sCkCode = dr ? TypeUtil.toString(dr['CkCode']) : '';
|
|
|
if (sCkCode === '') return false;
|
|
|
if ((IsMdKwMng == "1") && (this.dsDetail.rows.length > 0)){
|
|
|
let ret= Service.getSlideMenuData("DoOnMasterCalcRule","CkCode", dr.getData(),"","","","");
|
|
|
if (ret.result !== 1) {
|
|
|
dr.setColumnError(dc.fieldName, ret.message);
|
|
|
return false;
|
|
|
}
|
|
|
if (ret.data != null){
|
|
|
if (ret.data.CkType == "1"){
|
|
|
let masterRow = this.dsMaster.currentRow;
|
|
|
sCkCode = TypeUtil.toString(masterRow['CkCode']);
|
|
|
let sInOrgCode = rhtComm.GetInOrgCode(Store.logOn.orgCode).message;
|
|
|
for (let i=0;i<this.dsDetail.rows.length;i++){
|
|
|
let row = this.dsDetail.rows[i];
|
|
|
let sPluID = TypeUtil.toFloat(row['PluID']);
|
|
|
let JSONObject={CurInOrgCode:sInOrgCode,CkCode:sCkCode,PluID:sPluID};
|
|
|
let retKwCode = Service.getSlideMenuData("pubsysBaseBL","GetPluKw",JSONObject,"","","","");
|
|
|
if (retKwCode.result === 1) {
|
|
|
if (retKwCode.data != null) {
|
|
|
dr.setColumnValue('KwCode', retKwCode.data.KwCode);
|
|
|
}
|
|
|
}
|
|
|
else{
|
|
|
dr.setColumnError('BillNo', retKwCode.message);
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else{
|
|
|
dr.setColumnValue('KwCode', "");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
|
};
|
|
|
//PluCode 字段变化执行事件
|
|
|
Biz.prototype.fieldChangedPluCode = function (dataSrc, dr, dc) {
|
|
|
let masterRow = this.dsMaster.currentRow;
|
|
|
let sThOrgCode = TypeUtil.toString(masterRow['ThOrgCode']);
|
|
|
let sPluCode = dr ? TypeUtil.toString(dr['PluCode']) : '';
|
|
|
let sPluID = dr ? TypeUtil.toString(dr['PluID']) : '';
|
|
|
let sInOrgCode = rhtComm.GetInOrgCode(Store.logOn.orgCode).message;
|
|
|
if (sPluCode === '') return false;
|
|
|
|
|
|
let ret= Service.getSlideMenuData("DoOnDetailCalcRule","PluCode", masterRow.getData(), dr.getData(), "","","");
|
|
|
if (ret.result !== 1) {
|
|
|
dr.setColumnError(dc.fieldName, ret.message);
|
|
|
return false;
|
|
|
}
|
|
|
if (ret.data != null) {
|
|
|
let fPrice = TypeUtil.toFloat(ret.data[0].price);
|
|
|
let fXTaxRate = TypeUtil.toFloat(ret.data[0].xtaxrate);
|
|
|
dr.setColumnValue('ThPrice', ret.data[0].price);
|
|
|
dr.setColumnValue('StlCurrThPrice', ret.data[0].stlcurrprice);
|
|
|
dr.setColumnText('DepCode', ret.data[0].depcode);
|
|
|
dr.setColumnValue('WThPrice', (fPrice/(1+fXTaxRate/100)).round(4));
|
|
|
dr.setColumnValue('XTaxRate', fXTaxRate);
|
|
|
|
|
|
//获取包装信息
|
|
|
JSONObject={psPluCode:sPluCode,psYwType:"2004"};
|
|
|
let retPacket= Service.getSlideMenuData("pubsysBaseBL","GetDefaultPluPackUnitByYwType",JSONObject,sPluCode,"","","");
|
|
|
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");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
let retDep= Service.getSlideMenuData("DoOnDetailCalcRule","PluGetDep", masterRow.getData(), dr.getData(),"","","");
|
|
|
if (retDep.result === 1) {
|
|
|
if (retDep.data != null) {
|
|
|
dr.setColumnValue('DepID', retDep.data.depid);
|
|
|
dr.setColumnValue('DepCode', retDep.data.depcode);
|
|
|
dr.setColumnValue('DepName', retDep.data.depname);
|
|
|
}
|
|
|
}
|
|
|
let JSONObject={OrgCode:sThOrgCode,PluCode:sPluCode,PluID:sPluID,FieldNameGrp:"Price",FieldCount:1};
|
|
|
let retEx = Service.getSlideMenuData("pubsysBaseBL","USkuGetPluExPropInfo",JSONObject,"","","","");
|
|
|
if (retEx.result === 1) {
|
|
|
if (retEx.data != null) {
|
|
|
dr.setColumnValue('Price', retEx.data.Price);
|
|
|
}
|
|
|
else{
|
|
|
JSONObject={OrgCode:sInOrgCode,PluCode:sPluCode,PluID:sPluID,FieldNameGrp:"Price",FieldCount:1};
|
|
|
let retExB = Service.getSlideMenuData("pubsysBaseBL","USkuGetPluExPropInfo",JSONObject,"","","","");
|
|
|
if (retExB.result === 1) {
|
|
|
if (retExB.data != null) {
|
|
|
dr.setColumnValue('Price', retExB.data.Price);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else{
|
|
|
dr.setColumnError('BillNo', retEx.message);
|
|
|
return false;
|
|
|
}
|
|
|
if (IsMdKwMng == "1"){
|
|
|
let sCkCode = TypeUtil.toString(masterRow['CkCode']);
|
|
|
JSONObject={CurInOrgCode:sInOrgCode,CkCode:sCkCode,PluID:sPluID};
|
|
|
let retKwCode = Service.getSlideMenuData("pubsysBaseBL","GetPluKw",JSONObject,"","","","");
|
|
|
if (retKwCode.result === 1) {
|
|
|
if (retKwCode.data != null) {
|
|
|
dr.setColumnValue('KwCode', retKwCode.data.KwCode);
|
|
|
}
|
|
|
}
|
|
|
else{
|
|
|
dr.setColumnError('BillNo', retKwCode.message);
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
dr.setColumnValue('ThSpDate', rhtComm.GetServerDateTime(0));
|
|
|
dr.setColumnValue('ThSprID', Store.logOn.userId);
|
|
|
dr.setColumnValue('ThSprCode', Store.logOn.userCode);
|
|
|
dr.setColumnValue('ThSprName', Store.logOn.userName);
|
|
|
return true;
|
|
|
};
|
|
|
//PackUnit 字段变化执行事件
|
|
|
Biz.prototype.fieldChangedPackUnit = function (dataSrc, dr, dc) {
|
|
|
let PackUnit = TypeUtil.toString(dr['PackUnit']);
|
|
|
if (PackUnit == "")
|
|
|
{
|
|
|
dr.setColumnValue('PackQty', "0");
|
|
|
}
|
|
|
dr.setColumnText('PackCount', "0");
|
|
|
return true;
|
|
|
};
|
|
|
//PackCount 字段变化执行事件
|
|
|
Biz.prototype.fieldChangedPackCount = function (dataSrc, dr, dc) {
|
|
|
let masterRow = this.dsMaster.currentRow;
|
|
|
let fExchangeRate = TypeUtil.toFloat(masterRow['ExchangeRate']);
|
|
|
let sIsStdCurr = masterRow ? TypeUtil.toString(masterRow['IsStdCurr']) : '0';
|
|
|
let fPackCount = TypeUtil.toFloat(dr['PackCount']);
|
|
|
let fPackQty = TypeUtil.toFloat(dr['PackQty']);
|
|
|
let fSglCount = TypeUtil.toFloat(dr['SglCount']);
|
|
|
let sPluCode = dr ? TypeUtil.toString(dr['PluCode']) : '';
|
|
|
let fStlCurrThPrice = TypeUtil.toFloat(dr['StlCurrThPrice']);
|
|
|
let fXTaxRate = TypeUtil.toFloat(dr['XTaxRate']);
|
|
|
let fPrice = TypeUtil.toFloat(dr['Price']);
|
|
|
let fThCount = fPackCount*fPackQty+fSglCount;
|
|
|
if (sPluCode === '') return false;
|
|
|
|
|
|
//明细相关字段赋值
|
|
|
let ret= Service.getSlideMenuData("DoOnDetailCalcRule","USkuGetPluPieceCount", sPluCode,fThCount,"","","");
|
|
|
if (ret.result !== 1) {
|
|
|
dr.setColumnError(dc.fieldName, ret.message);
|
|
|
return false;
|
|
|
}
|
|
|
else{
|
|
|
dr.setColumnValue('PieceCount', ret.message);
|
|
|
}
|
|
|
|
|
|
let fStlCurrThTotal = (fStlCurrThPrice*fThCount).round(2);
|
|
|
let fThTotal = (fStlCurrThTotal*fExchangeRate).round(2);
|
|
|
let fWThTotal = (fThTotal/(1+fXTaxRate/100)).round(2);
|
|
|
let fThPrice = 0.0;
|
|
|
if (sIsStdCurr == "1"){
|
|
|
fThPrice = fStlCurrThPrice;
|
|
|
}
|
|
|
else{
|
|
|
if (fThTotal == 0){
|
|
|
fThPrice = (fStlCurrThPrice*fExchangeRate).round(4);
|
|
|
}
|
|
|
else{
|
|
|
if (fThCount == 0){
|
|
|
fThPrice = 0;
|
|
|
}
|
|
|
else{
|
|
|
fThPrice = (fThTotal/fThCount).round(4);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
let fWThPrice = 0.0;
|
|
|
if (fXTaxRate == 0){
|
|
|
fWThPrice = 0;
|
|
|
}
|
|
|
else{
|
|
|
if (fWThTotal == 0){
|
|
|
fWThPrice = (fThPrice/(1+fXTaxRate/100)).round(4);
|
|
|
}
|
|
|
else{
|
|
|
if (fThCount == 0){
|
|
|
fWThPrice = 0;
|
|
|
}
|
|
|
else{
|
|
|
fWThPrice = (fWThTotal/fThCount).round(4);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
let fXTaxTotal = fThTotal - fWThTotal;
|
|
|
let fSTotal = (fThCount*fPrice).round(2);
|
|
|
dr.setColumnValue('ThCount', fThCount);
|
|
|
dr.setColumnValue('StlCurrThTotal', fStlCurrThTotal);
|
|
|
dr.setColumnValue('ThTotal', fThTotal);
|
|
|
dr.setColumnValue('WThTotal', fWThTotal);
|
|
|
dr.setColumnValue('ThPrice', fThPrice);
|
|
|
dr.setColumnValue('WThPrice', fWThPrice);
|
|
|
dr.setColumnValue('XTaxTotal', fXTaxTotal);
|
|
|
dr.setColumnValue('STotal', fSTotal);
|
|
|
return true;
|
|
|
};
|
|
|
//SglCount 字段变化执行事件
|
|
|
Biz.prototype.fieldChangedSglCount = function (dataSrc, dr, dc) {
|
|
|
let masterRow = this.dsMaster.currentRow;
|
|
|
let fExchangeRate = TypeUtil.toFloat(masterRow['ExchangeRate']);
|
|
|
let sIsStdCurr = masterRow ? TypeUtil.toString(masterRow['IsStdCurr']) : '0';
|
|
|
let fPackCount = TypeUtil.toFloat(dr['PackCount']);
|
|
|
let fPackQty = TypeUtil.toFloat(dr['PackQty']);
|
|
|
let fSglCount = TypeUtil.toFloat(dr['SglCount']);
|
|
|
let sPluCode = dr ? TypeUtil.toString(dr['PluCode']) : '';
|
|
|
let fStlCurrThPrice = TypeUtil.toFloat(dr['StlCurrThPrice']);
|
|
|
let fXTaxRate = TypeUtil.toFloat(dr['XTaxRate']);
|
|
|
let fPrice = TypeUtil.toFloat(dr['Price']);
|
|
|
let fThCount = fPackCount*fPackQty+fSglCount;
|
|
|
if (sPluCode === '') return false;
|
|
|
|
|
|
//明细相关字段赋值
|
|
|
let ret= Service.getSlideMenuData("DoOnDetailCalcRule","USkuGetPluPieceCount", sPluCode,fThCount,"","","");
|
|
|
if (ret.result !== 1) {
|
|
|
dr.setColumnError(dc.fieldName, ret.message);
|
|
|
return false;
|
|
|
}
|
|
|
else{
|
|
|
dr.setColumnValue('PieceCount', ret.message);
|
|
|
}
|
|
|
let fStlCurrThTotal = (fStlCurrThPrice*fThCount).round(2);
|
|
|
let fThTotal = (fStlCurrThTotal*fExchangeRate).round(2);
|
|
|
let fWThTotal = (fThTotal/(1+fXTaxRate/100)).round(2);
|
|
|
let fThPrice = 0.0;
|
|
|
if (sIsStdCurr == "1"){
|
|
|
fThPrice = fStlCurrThPrice;
|
|
|
}
|
|
|
else{
|
|
|
if (fThTotal == 0){
|
|
|
fThPrice = (fStlCurrThPrice*fExchangeRate).round(4);
|
|
|
}
|
|
|
else{
|
|
|
if (fThCount == 0){
|
|
|
fThPrice = 0;
|
|
|
}
|
|
|
else{
|
|
|
fThPrice = (fThTotal/fThCount).round(4);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
let fWThPrice = 0.0;
|
|
|
if (fXTaxRate == 0){
|
|
|
fWThPrice = 0;
|
|
|
}
|
|
|
else{
|
|
|
if (fWThTotal == 0){
|
|
|
fWThPrice = (fThPrice/(1+fXTaxRate/100)).round(4);
|
|
|
}
|
|
|
else{
|
|
|
if (fThCount == 0){
|
|
|
fWThPrice = 0;
|
|
|
}
|
|
|
else{
|
|
|
fWThPrice = (fWThTotal/fThCount).round(4);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
let fXTaxTotal = fThTotal - fWThTotal;
|
|
|
let fSTotal = (fThCount*fPrice).round(2);
|
|
|
dr.setColumnValue('ThCount', fThCount);
|
|
|
dr.setColumnValue('StlCurrThTotal', fStlCurrThTotal);
|
|
|
dr.setColumnValue('ThTotal', fThTotal);
|
|
|
dr.setColumnValue('WThTotal', fWThTotal);
|
|
|
dr.setColumnValue('ThPrice', fThPrice);
|
|
|
dr.setColumnValue('WThPrice', fWThPrice);
|
|
|
dr.setColumnValue('XTaxTotal', fXTaxTotal);
|
|
|
dr.setColumnValue('STotal', fSTotal);
|
|
|
return true;
|
|
|
};
|
|
|
//ThPrice 字段变化执行事件
|
|
|
Biz.prototype.fieldChangedThPrice = function (dataSrc, dr, dc) {
|
|
|
let masterRow = this.dsMaster.currentRow;
|
|
|
let sThOrgCode = TypeUtil.toString(masterRow['ThOrgCode']);
|
|
|
let sPluCode = dr ? TypeUtil.toString(dr['PluCode']) : '';
|
|
|
let fThPrice = TypeUtil.toFloat(dr['ThPrice']);
|
|
|
if (sPluCode === '') return false;
|
|
|
|
|
|
let isOrg = rhtComm.GetOrgCode(sThOrgCode);
|
|
|
if (isOrg !== "1"){
|
|
|
if (fThPrice == 0){
|
|
|
if (!Store.confirm("当前商品退货价为0,是否继续?")) {
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
|
};
|
|
|
//StlCurrThPrice 字段变化执行事件
|
|
|
Biz.prototype.fieldChangedStlCurrThPrice = function (dataSrc, dr, dc) {
|
|
|
let masterRow = this.dsMaster.currentRow;
|
|
|
let fExchangeRate = TypeUtil.toFloat(masterRow['ExchangeRate']);
|
|
|
let sIsStdCurr = masterRow ? TypeUtil.toString(masterRow['IsStdCurr']) : '0';
|
|
|
let fPackCount = TypeUtil.toFloat(dr['PackCount']);
|
|
|
let fPackQty = TypeUtil.toFloat(dr['PackQty']);
|
|
|
let fSglCount = TypeUtil.toFloat(dr['SglCount']);
|
|
|
let sPluCode = dr ? TypeUtil.toString(dr['PluCode']) : '';
|
|
|
let fStlCurrThPrice = TypeUtil.toFloat(dr['StlCurrThPrice']);
|
|
|
let fXTaxRate = TypeUtil.toFloat(dr['XTaxRate']);
|
|
|
let fPrice = TypeUtil.toFloat(dr['Price']);
|
|
|
let fThCount = fPackCount*fPackQty+fSglCount;
|
|
|
if (sPluCode === '') return false;
|
|
|
|
|
|
let fStlCurrThTotal = (fStlCurrThPrice*fThCount).round(2);
|
|
|
let fThTotal = (fStlCurrThTotal*fExchangeRate).round(2);
|
|
|
let fWThTotal = (fThTotal/(1+fXTaxRate/100)).round(2);
|
|
|
let fThPrice = 0.0;
|
|
|
if (sIsStdCurr == "1"){
|
|
|
fThPrice = fStlCurrThPrice;
|
|
|
}
|
|
|
else{
|
|
|
if (fThTotal == 0){
|
|
|
fThPrice = (fStlCurrThPrice*fExchangeRate).round(4);
|
|
|
}
|
|
|
else{
|
|
|
if (fThCount == 0){
|
|
|
fThPrice = 0;
|
|
|
}
|
|
|
else{
|
|
|
fThPrice = (fThTotal/fThCount).round(4);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
let fWThPrice = 0.0;
|
|
|
if (fXTaxRate == 0){
|
|
|
fWThPrice = 0;
|
|
|
}
|
|
|
else{
|
|
|
if (fWThTotal == 0){
|
|
|
fWThPrice = (fThPrice/(1+fXTaxRate/100)).round(4);
|
|
|
}
|
|
|
else{
|
|
|
if (fThCount == 0){
|
|
|
fWThPrice = 0;
|
|
|
}
|
|
|
else{
|
|
|
fWThPrice = (fWThTotal/fThCount).round(4);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
let fXTaxTotal = fThTotal - fWThTotal;
|
|
|
let fSTotal = (fThCount*fPrice).round(2);
|
|
|
dr.setColumnValue('ThCount', fThCount);
|
|
|
dr.setColumnValue('StlCurrThTotal', fStlCurrThTotal);
|
|
|
dr.setColumnValue('ThTotal', fThTotal);
|
|
|
dr.setColumnValue('WThTotal', fWThTotal);
|
|
|
dr.setColumnValue('ThPrice', fThPrice);
|
|
|
dr.setColumnValue('WThPrice', fWThPrice);
|
|
|
dr.setColumnValue('XTaxTotal', fXTaxTotal);
|
|
|
dr.setColumnValue('STotal', fSTotal);
|
|
|
return true;
|
|
|
};
|
|
|
//DepCode 字段变化执行事件
|
|
|
Biz.prototype.fieldChangedDepCode = function (dataSrc, dr, dc) {
|
|
|
dr.setColumnValue('PackUnit', "");
|
|
|
return true;
|
|
|
};
|
|
|
return Biz;
|
|
|
}); |