define(function (require, exports, module) { let BaseBiz = require('apps/rht/base/rhtBiz'); let Service = require('./cou190122service'); /** * 控制按钮的可用 * @param opCode 按钮编码 * @return [description] */ function Biz(vm) { //继承第一步,构造继承 BaseBiz.call(this, vm); vm.remark ='' } //继承第二步,方法继承 inherits(Biz, BaseBiz); //给字段赋默认值 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.fieldChanged = function (dataSrc, dr, dc) { if (dataSrc.uiObjCode === this.dsDetail.uiObjCode) { switch (dc.fieldName) { case 'ZmCount': this.fieldChangedBodyZmCount(dataSrc, dr, dc); break; case 'PluCode': this.fieldChangedPluCode(dataSrc, dr, dc); break; } } this.super('fieldChanged'); }; //ZmCount 字段变化执行事件 Biz.prototype.fieldChangedBodyZmCount = function (dataSrc, dr, dc) { let fZmCount = TypeUtil.toString(dr['ZmCount']); let PluCode = TypeUtil.toString(dr['PluCode']); if (PluCode.length > 0) { let DotDecimal = TypeUtil.toFloat(dr['R_DotDecimal']); let sdl= 0; if (fZmCount.toString().indexOf(".") !== -1) { 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; //明细相关字段赋值 if (sDepCode.length <= 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('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); } } return true; }; //按钮事件控制 Biz.prototype.doOp = function (opCode) { if (opCode == 'apply') { this.onacc("1"); } if (opCode == 'pass') { this.onacc("2"); } if (opCode == 'nopass') { this.onacc("3"); } if (opCode == 'myedit') { this.opRouter('edit'); } if (opCode == 'mydelete') { this.opRouter('delete'); } }; //控制主界面按钮状态 Biz.prototype.getOpEnabled = function (opCode) { let isOk = this.super('getOpEnabled', opCode); if (!isOk) { return false; } let curRow = this.dsMaster.currentRow; let sCouStatus = curRow ? TypeUtil.toString(curRow['CouStatus']) : ''; if (opCode == 'apply'){ if (!curRow) return false; if (this.isEdit()) return false; if ((sCouStatus == "1") || (sCouStatus == "2")) return false; } if ((opCode == 'pass') || (opCode == 'nopass')) { if (!curRow) return false; if (sCouStatus != "1") return false; if (this.isEdit()) return false; } if ((opCode == 'myedit') || (opCode == 'mydelete')) { if (!curRow) return false; if (sCouStatus != "0") return false; if (this.isEdit()) return false; } return true; }; //退货公共事件处理 Biz.prototype.onacc = function (sType) { let curHRow = this.dsMaster.currentRow; let sBillNo = curHRow ? TypeUtil.toString(curHRow['BillNo']) : ''; let ret= Service.getSlideMenuData("actExecute","onacc", sBillNo,sType,"","",""); if (ret.result !== 1) { Store.messager.err(ret.message); return false; } this.dsMaster.updateRow(); Store.messager.tip("处理成功!"); return true; }; return Biz; });