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 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