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.
263 lines
11 KiB
263 lines
11 KiB
define(function (require, exports, module) {
|
|
let BaseBiz = require('apps/rht/base/rhtBiz');
|
|
let Service = require('./cou190115service');
|
|
let rhtComm = require('../../comm/rhtComm');
|
|
/**
|
|
* 控制按钮的可用
|
|
* @param opCode 按钮编码
|
|
* @return [description]
|
|
*/
|
|
|
|
function Biz(vm) {
|
|
//继承第一步,构造继承
|
|
BaseBiz.call(this, vm);
|
|
vm.remark =''
|
|
}
|
|
|
|
//继承第二步,方法继承
|
|
inherits(Biz, BaseBiz);
|
|
|
|
//取部门核算级别
|
|
let accLength = rhtComm.getOptionOrgAccLevel();
|
|
|
|
//功能初始化完毕调用该方法
|
|
Biz.prototype.initCompleted = function() {
|
|
let sOrgType = rhtComm.GetOrgType(Store.logOn.orgCode);
|
|
if ((sOrgType != "1001") && (sOrgType != "1002")){
|
|
this.dsMaster.getColumn('OrgCode').set('isEditable',false);
|
|
}
|
|
return this.super('initCompleted');
|
|
};
|
|
//给字段赋默认值
|
|
Biz.prototype.getDefaultValue = function (dataSrc, dr, dc, defaultValue) {
|
|
if (dataSrc.uiObjCode === this.dsDetail.uiObjCode) {
|
|
if (dc.fieldName == 'DepCode'){
|
|
let self = this;
|
|
let masterRow = self.dsMaster.currentRow;
|
|
let DepCodeHead = masterRow ? TypeUtil.toString(masterRow['DepCode']) : '';
|
|
if (DepCodeHead.length > 0){
|
|
return DepCodeHead;
|
|
}
|
|
}
|
|
}
|
|
return this.super("getDefaultValue", dataSrc, dr, dc, defaultValue);
|
|
};
|
|
//明细行单行提交触发的校验
|
|
Biz.prototype.dataRowValidate = function (dataSrc, dr) {
|
|
if (dataSrc.uiObjCode === this.dsDetail.uiObjCode) {
|
|
let PluCode = TypeUtil.toString(dr['PluCode']);
|
|
let fKcCount = TypeUtil.toFloat(dr['KcCount']);
|
|
let fZmCount = TypeUtil.toFloat(dr['ZmCount']);
|
|
if (PluCode.length > 0) {
|
|
dr.setColumnValue('HzDate', rhtComm.GetServerDate(0));
|
|
if (fZmCount < 0 ) {
|
|
return "报损数量不能为负值!";
|
|
}
|
|
if (fZmCount > fKcCount ) {
|
|
return "报损数量不能大于库存数量!";
|
|
}
|
|
dr.setColumnValue('YkRate', "100");
|
|
}
|
|
}
|
|
return true;
|
|
};
|
|
// 列校验,列赋值时调用,发生异常表示校验失败
|
|
Biz.prototype.dataColumnValidate = function (dataSrc, dr, dc, value) {
|
|
let self = this;
|
|
if (dataSrc.uiObjCode === this.dsDetail.uiObjCode) {
|
|
let masterRow = self.dsMaster.currentRow;
|
|
let DepCodeHead = masterRow ? TypeUtil.toString(masterRow['DepCode']) : '';
|
|
if ((accLength > 0) && (DepCodeHead.length == 0)){
|
|
return "核算到部门,必须录入主表部门!";
|
|
}
|
|
}
|
|
return this.super('dataColumnValidate');
|
|
};
|
|
//校验小数精度
|
|
Biz.prototype.getPrecision = function (dataSrc, dr, dc, defaultPrecision) {
|
|
if (dataSrc.uiObjCode == this.dsDetail.uiObjCode) {
|
|
//把这里改成需要控制的字段
|
|
if (dc.fieldName == 'ZmCount') {
|
|
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) {
|
|
if (dc.fieldName == 'OrgCode') {
|
|
this.fieldChangedOrgCode(dataSrc, dr, dc);
|
|
}
|
|
}
|
|
if (dataSrc.uiObjCode === this.dsDetail.uiObjCode) {
|
|
switch (dc.fieldName) {
|
|
case 'ZmCount':
|
|
this.fieldChangedZmCount(dataSrc, dr, dc);
|
|
break;
|
|
case 'PluCode':
|
|
this.fieldChangedPluCode(dataSrc, dr, dc);
|
|
break;
|
|
case 'DepCode':
|
|
this.fieldChangedDepCode(dataSrc, dr, dc);
|
|
break;
|
|
case 'YkCount':
|
|
this.fieldChangedYkCount(dataSrc, dr, dc);
|
|
break;
|
|
}
|
|
}
|
|
this.super('fieldChanged');
|
|
};
|
|
//OrgCode 字段变化执行事件
|
|
Biz.prototype.fieldChangedOrgCode = function (dataSrc, dr, dc) {
|
|
let sOrgCode = TypeUtil.toString(dr['OrgCode']);
|
|
let sOldOrgCode = TypeUtil.toString(dr.transData['OrgCode']);
|
|
|
|
if (sOldOrgCode != sOrgCode){
|
|
dr.setColumnValue('CkCode', "");
|
|
dr.setColumnValue('DepCode', "");
|
|
}
|
|
return true;
|
|
};
|
|
//ZmCount 字段变化执行事件
|
|
Biz.prototype.fieldChangedZmCount = function (dataSrc, dr, dc) {
|
|
let sPluCode = TypeUtil.toString(dr['PluCode']);
|
|
let fZmCount = TypeUtil.toFloat(dr['ZmCount']);
|
|
let fHJPrice = TypeUtil.toFloat(dr['HJPrice']);
|
|
let fWJPrice = TypeUtil.toFloat(dr['WJPrice']);
|
|
let fPrice = TypeUtil.toFloat(dr['Price']);
|
|
if (sPluCode.length > 0)
|
|
{
|
|
let fZmHCost = (fHJPrice*fZmCount).round(2);
|
|
let fZmWCost = (fWJPrice*fZmCount).round(2);
|
|
let fZmSCost = (fPrice*fZmCount).round(2);
|
|
dr.setColumnValue('ZmHCost', fZmHCost);
|
|
dr.setColumnValue('ZmWCost', fZmWCost);
|
|
dr.setColumnValue('ZmSCost', fZmSCost);
|
|
dr.setColumnValue('SjCount', "0");
|
|
dr.setColumnValue('SjHCost', "0");
|
|
dr.setColumnValue('SjWCost', "0");
|
|
dr.setColumnValue('SjSCost', "0");
|
|
dr.setColumnValue('YkCount', (-1*fZmCount));
|
|
dr.setColumnValue('YkHCost', (-1*fZmHCost));
|
|
dr.setColumnValue('YkWCost', (-1*fZmWCost));
|
|
dr.setColumnValue('YkSCost', (-1*fZmSCost));
|
|
/*
|
|
let DotDecimal = TypeUtil.toFloat(dr['R_DotDecimal']);
|
|
if (fZmCount.toString().indexOf(".") == -1) {
|
|
let sdl= 0;
|
|
}
|
|
else {
|
|
let sdl= fZmCount.toString().split(".")[1].length || 0;
|
|
}
|
|
if (DotDecimal < sdl){
|
|
dr.setColumnError(dc.fieldName, "此商品的小数精度是" + dr['R_DotDecimal'] );
|
|
return false;
|
|
}
|
|
*/
|
|
}
|
|
return true;
|
|
};
|
|
//PluCode 字段变化执行事件
|
|
Biz.prototype.fieldChangedPluCode = function (dataSrc, dr, dc) {
|
|
let masterRow = this.dsMaster.currentRow;
|
|
let sInOrgCode = TypeUtil.toString(masterRow['InOrgCode']);
|
|
let sHeadDepCode = masterRow ? TypeUtil.toString(masterRow['DepCode']) : '';
|
|
let sCkCode = masterRow ? TypeUtil.toString(masterRow['CkCode']) : '';
|
|
let sPluCode = dr ? TypeUtil.toString(dr['PluCode']) : '';
|
|
let sDepCode = dr ? TypeUtil.toString(dr['DepCode']) : '';
|
|
if (sPluCode === '') return false;
|
|
dr.setColumnValue('ZmCount', "0");
|
|
dr.setColumnText('YkCount', "0");
|
|
let ret= Service.getSlideMenuData("DoOnDetailCalcRule","PluCode", sInOrgCode,sHeadDepCode,sCkCode,sPluCode,"");
|
|
if (ret.result !== 1) {
|
|
dr.setColumnError(dc.fieldName, ret.message);
|
|
return false;
|
|
}
|
|
if (ret.data != null) {
|
|
dr.setColumnValue('Price', ret.data.price);
|
|
if (sDepCode.length <= 0){
|
|
dr.setColumnValue('DepID', ret.data.depid);
|
|
dr.setColumnValue('DepCode', ret.data.depcode);
|
|
dr.setColumnValue('DepName', ret.data.depname);
|
|
dr.setColumnValue('ExPluCode', ret.data.explucode);
|
|
dr.setColumnValue('ExPluName', ret.data.expluname);
|
|
}
|
|
}
|
|
if (dr['DepID'].length > 0){
|
|
let MRow = masterRow.getData();
|
|
let DRow = dr.getData();
|
|
let retGetPluKc= Service.getSlideMenuData("DoOnDetailCalcRule","GetPluKc", MRow,DRow,"","","");
|
|
if (retGetPluKc.result !== 1) {
|
|
dr.setColumnError(dc.fieldName, retGetPluKc.message);
|
|
return false;
|
|
}
|
|
if (retGetPluKc.data != null) {
|
|
let fZmCount = TypeUtil.toFloat(retGetPluKc.data.kccount);
|
|
let fHJPrice = TypeUtil.toFloat(retGetPluKc.data.hjprice);
|
|
let fWJPrice = TypeUtil.toFloat(retGetPluKc.data.wjprice);
|
|
dr.setColumnValue('ZmCount', retGetPluKc.data.kccount);
|
|
dr.setColumnValue('KcCount', retGetPluKc.data.kccount);
|
|
dr.setColumnValue('HJPrice', fHJPrice);
|
|
dr.setColumnValue('WJPrice', fWJPrice);
|
|
dr.setColumnValue('ZmHCost', (fZmCount*fHJPrice).round(2));
|
|
dr.setColumnValue('ZmWCost', (fZmCount*fWJPrice).round(2));
|
|
dr.setColumnValue('ZmSCost', (fZmCount*TypeUtil.toFloat(dr['Price'])).round(2));
|
|
}
|
|
}
|
|
return true;
|
|
};
|
|
//DepCode 字段变化执行事件
|
|
Biz.prototype.fieldChangedDepCode = function (dataSrc, dr, dc) {
|
|
let sPluCode = dr ? TypeUtil.toString(dr['PluCode']) : '';
|
|
if (sPluCode === '') return false;
|
|
dr.setColumnValue('ZmCount', "0");
|
|
dr.setColumnText('YkCount', "0");
|
|
let masterRow = this.dsMaster.currentRow;
|
|
let MRow = masterRow.getData();
|
|
let DRow = dr.getData();
|
|
let retGetPluKc= Service.getSlideMenuData("DoOnDetailCalcRule","GetPluKc", MRow,DRow,"","","");
|
|
if (retGetPluKc.result !== 1) {
|
|
dr.setColumnError(dc.fieldName, retGetPluKc.message);
|
|
return false;
|
|
}
|
|
if (retGetPluKc.data != null) {
|
|
let fZmCount = TypeUtil.toFloat(retGetPluKc.data.kccount);
|
|
let fHJPrice = TypeUtil.toFloat(retGetPluKc.data.hjprice);
|
|
let fWJPrice = TypeUtil.toFloat(retGetPluKc.data.wjprice);
|
|
dr.setColumnValue('ZmCount', retGetPluKc.data.kccount);
|
|
dr.setColumnValue('KcCount', retGetPluKc.data.kccount);
|
|
dr.setColumnValue('HJPrice', fHJPrice);
|
|
dr.setColumnValue('WJPrice', fWJPrice);
|
|
dr.setColumnValue('ZmHCost', (fZmCount*fHJPrice).round(2));
|
|
dr.setColumnValue('ZmWCost', (fZmCount*fWJPrice).round(2));
|
|
dr.setColumnValue('ZmSCost', (fZmCount*TypeUtil.toFloat(dr['Price'])).round(2));
|
|
}
|
|
return true;
|
|
};
|
|
//YkCount 字段变化执行事件
|
|
Biz.prototype.fieldChangedYkCount = function (dataSrc, dr, dc) {
|
|
let fYkCount = TypeUtil.toFloat(dr['YkCount']);
|
|
let fZmCount = TypeUtil.toFloat(dr['ZmCount']);
|
|
let PluCode = TypeUtil.toString(dr['PluCode']);
|
|
if (PluCode.length > 0)
|
|
{
|
|
let fKyTmp= Math.abs((100*fYkCount)/fZmCount);
|
|
let fYkRate = 0.0;
|
|
if ((fZmCount == 0) || ((fZmCount != 0) && (fKyTmp > 100))){
|
|
if (fYkCount > 0){
|
|
fYkRate = 1;
|
|
}
|
|
else{
|
|
fYkRate = -1;
|
|
}
|
|
}
|
|
else{
|
|
fYkRate = fYkCount/fZmCount;
|
|
}
|
|
dr.setColumnValue('YkRate', (fYkRate*100).round(2));
|
|
}
|
|
return true;
|
|
};
|
|
return Biz;
|
|
}); |