define(function (require, exports, module) { //引入业务类基类 let BaseBiz = require('apps/rht/base/rhtBiz'); let rhtComm = require('apps/rht/comm/rhtComm'); //引入业务服务 let Service = require('./cnt070210service'); let OutLayDetail = require('./OutLayDetail'); /** * 定义业务类对象 * @param vm 界面相关ViewModule */ function Biz(vm) { //继承第一步,构造继承 BaseBiz.call(this, vm); } //继承第二步,方法继承 inherits(Biz, BaseBiz); Biz.prototype.initCompleted = function () { this.super('initCompleted'); this.orgType = rhtComm.GetOrgType(Store.logOn.orgCode); this.isForeignCheck = rhtComm.getRhtOptionValue(Store.logOn.orgCode,'SYS','Sys_IsForeignCheck','0'); this.ctrlCntOrgDepRight = rhtComm.getRhtOptionValue("",'CNT','CtrlCntOrgDepRight','0'); }; //控制主界面按钮状态 Biz.prototype.getOpEnabled = function (opCode) { let self = this; let isOk = this.super('getOpEnabled', opCode); if (!isOk) return false; let curRow = this.dsMaster.currentRow; let orgCode = curRow ? TypeUtil.toString(curRow['OrgCode']) : ''; let forChkStatus = curRow ? TypeUtil.toString(curRow['ForeignChkStatus']) : ''; let jzDate = curRow ? TypeUtil.toString(curRow['JzDate']) : ''; if (opCode == 'edit') { if (!curRow) return false; if (orgCode != Store.logOn.orgCode) return false; if(forChkStatus != '0' && forChkStatus != '3') return false; if(jzDate != '') return false; } if (opCode == 'delete') { if (!curRow) return false; if (orgCode != Store.logOn.orgCode) return false; if(forChkStatus != '0' && forChkStatus != '3') return false; if(jzDate != '') return false; } if (opCode == 'acc') { // 入账 if (!curRow) return false; if (orgCode != Store.logOn.orgCode) return false; if(this.isForeignCheck != '0') return false; if(jzDate != '') return false; } if (opCode == 'forchk') { // 外部审核 if (!curRow) return false; if (orgCode != Store.logOn.orgCode) return false; if(jzDate != '') return false; if(this.isForeignCheck != '1') return false; if(forChkStatus != '0' && forChkStatus != '3') return false; } if (opCode == 'additem') { if(self.getState() != 'edit' && self.getState() != 'add') return false; } if (opCode == 'edititem') { if(self.getState() != 'edit' && self.getState() != 'add') return false; } if (opCode == 'delitem') { if(self.getState() != 'edit' && self.getState() != 'add') return false; } if (opCode == 'nochg') { if(self.getState() != 'edit' && self.getState() != 'add') return false; } return true; }; /** * @description 数据发生变化时调用 * @param dataSrc 数据集 * @param dr 数据行 * @param dc 数据列 */ Biz.prototype.fieldChanged = function (dataSrc, dr, dc) { let self = this; if (dataSrc.uiObjCode === this.dsMaster.uiObjCode) { let currentRow = self.dsMaster.currentRow; if (currentRow === null) return false; switch (dc.fieldName) { case 'HtCode': this.fieldChangedHtCode(dataSrc, dr, dc); break; // case 'EtpCode': // this.fieldChangedEtpCode(dataSrc, dr, dc); // break; } }else if (dataSrc.uiObjCode === this.dsDetailCjKxRate.uiObjCode) { let currentRow = self.dsDetailCjKxRate.currentRow; if (currentRow === null) return false; switch (dc.fieldName) { case 'KxRate': this.fieldChangedKxRate(dataSrc, dr, dc); break; case 'MinTotal': this.fieldChangedMinTotal(dataSrc, dr, dc); break; case 'MaxTotal': this.fieldChangedMaxTotal(dataSrc, dr, dc); break; } } return this.super('fieldChanged'); }; Biz.prototype.fieldChangedHtCode = function (dataSrc, dr, dc) { let htCode = TypeUtil.toString(dr.HtCode); if(htCode == '') { return true; } let ret = Service.CntValid(htCode); if (ret.result != 1) { throw '校验合同失败!' + ret.message; //dr.setColumnError('HtCode','校验合同失败!' + ret.message); //return false; } ret = Service.GetCntEtp(htCode); if (ret.result != 1) { throw '加载合同信息失败!' + ret.message; // dr.setColumnError('HtCode','加载合同信息失败!' + ret.message); // return false; } dr.setColumnText('EtpCode', ret.data.etpcode); ret = Service.GetCntOutLay(htCode); if (ret.result != 1) { throw '加载合同信息失败!' + ret.message; // dr.setColumnError('HtCode','加载合同信息失败!' + ret.message); // return false; } let dsKx = this.dsDetailKx; dsKx.deleteAll(); for(let i = 0; i < ret.data.length; i++) { let newRow = dsKx.addRow(); newRow.setColumnValue('ChangeType', '0'); newRow.setColumnValue('ItemCode', ret.data[i].itemcode); newRow.setColumnValue('OrgCode', ret.data[i].orgcode); newRow.setColumnValue('OrgName', ret.data[i].orgname); newRow.setColumnValue('ItemNo', ret.data[i].itemno); newRow.setColumnValue('BgnDate', ret.data[i].bgndate); newRow.setColumnValue('EndDate', ret.data[i].enddate); newRow.setColumnValue('JsBase', ret.data[i].jsbase); newRow.setColumnValue('ZfCode', ret.data[i].zfcode); newRow.setColumnValue('KxRate', ret.data[i].kxrate); newRow.setColumnValue('TkTotal', ret.data[i].tktotal); newRow.setColumnValue('ClType', ret.data[i].cltype); newRow.setColumnValue('ClDate', ret.data[i].cldate); newRow.setColumnValue('ScClDate', ret.data[i].sccldate); newRow.setColumnValue('ZfType', ret.data[i].zftype); newRow.setColumnValue('IsCalMl', ret.data[i].iscalml); newRow.setColumnValue('CalMode', ret.data[i].calmode); newRow.setColumnValue('CalBgnDate', ret.data[i].calbgndate); newRow.setColumnValue('CalEndDate', ret.data[i].calenddate); newRow.setColumnValue('IsInvoice', ret.data[i].isinvoice); newRow.setColumnValue('SfRate', ret.data[i].sfrate); newRow.setColumnValue('TkType', ret.data[i].tktype); newRow.setColumnValue('Remark', ret.data[i].remark); newRow.setColumnValue('IsSr', ret.data[i].issr); newRow.setColumnValue('Months', ret.data[i].months); newRow.setColumnValue('PluID', ret.data[i].pluid); newRow.setColumnValue('PluCode', ret.data[i].plucode); newRow.setColumnValue('PluName', ret.data[i].pluname); newRow.setColumnValue('IsCjKx', ret.data[i].iscjkx); newRow.setColumnValue('CalcType', ret.data[i].calctype); newRow.setColumnValue('ClsID', ret.data[i].clsid); newRow.setColumnValue('ClsCode', ret.data[i].clscode); newRow.setColumnValue('ClsName', ret.data[i].clsname); newRow.setColumnValue('BrandCode', ret.data[i].brandcode); newRow.setColumnValue('BrandName', ret.data[i].brandname); newRow.setColumnValue('FormulaId', ret.data[i].formulaid); newRow.setColumnValue('FormulaName', ret.data[i].formulaname); newRow.setColumnValue('CgyId', ret.data[i].cgyid); newRow.setColumnValue('CgyCode', ret.data[i].cgycode); newRow.setColumnValue('CgyName', ret.data[i].cgyname); newRow.setColumnValue('GsOrgCode', ret.data[i].gsorgcode); newRow.setColumnValue('GsOrgName', ret.data[i].gsorgname); // 以下给记录扣项原值的字段赋值 newRow.setColumnValue('OldBgnDate', ret.data[i].bgndate); newRow.setColumnValue('OldEndDate', ret.data[i].enddate); newRow.setColumnValue('OldJsBase', ret.data[i].jsbase); newRow.setColumnValue('OldZfCode', ret.data[i].zfcode); newRow.setColumnValue('OldKxRate', ret.data[i].kxrate); newRow.setColumnValue('OldTkTotal', ret.data[i].tktotal); newRow.setColumnValue('OldClType', ret.data[i].cltype); newRow.setColumnValue('OldZfType', ret.data[i].zftype); newRow.setColumnValue('OldIsCalMl', ret.data[i].iscalml); newRow.setColumnValue('OldCalMode', ret.data[i].calmode); newRow.setColumnValue('OldCalBgnDate', ret.data[i].calbgndate); newRow.setColumnValue('OldCalEndDate', ret.data[i].calenddate); newRow.setColumnValue('OldIsInvoice', ret.data[i].isinvoice); newRow.setColumnValue('OldTkType', ret.data[i].tktype); newRow.setColumnValue('OldRemark', ret.data[i].remark); newRow.setColumnValue('OldIsSr', ret.data[i].issr); newRow.setColumnValue('OldPluID', ret.data[i].pluid); newRow.setColumnValue('OldPluCode', ret.data[i].plucode); newRow.setColumnValue('OldPluName', ret.data[i].pluname); newRow.setColumnValue('OldIsCjKx', ret.data[i].iscjkx); newRow.setColumnValue('OldCalcType', ret.data[i].calctype); newRow.setColumnValue('OldClsID', ret.data[i].clsid); newRow.setColumnValue('OldClsCode', ret.data[i].clscode); newRow.setColumnValue('OldClsName', ret.data[i].clsname); newRow.setColumnValue('OldBrandCode', ret.data[i].brandcode); newRow.setColumnValue('OldBrandName', ret.data[i].brandname); newRow.setColumnValue('OldFormulaId', ret.data[i].formulaid); newRow.setColumnValue('OldFormulaName', ret.data[i].formulaname); newRow.setColumnValue('OldCgyId', ret.data[i].cgyid); newRow.setColumnValue('OldCgyCode', ret.data[i].cgycode); newRow.setColumnValue('OldCgyName', ret.data[i].cgyname); newRow.setColumnValue('OldGsOrgCode', ret.data[i].gsorgcode); newRow.setColumnValue('OldGsOrgName', ret.data[i].gsorgname); } ret = Service.GetCntKxRate(htCode); if (ret.result != 1) { throw '加载合同信息失败!' + ret.message; // dr.setColumnError('HtCode','加载合同信息失败!' + ret.message); // return false; } let dsKxRate = this.dsDetailCjKxRate; dsKxRate.deleteAll(); for(let i = 0; i < ret.data.length; i++) { let newRow = dsKxRate.addRow(); newRow.setColumnValue('CntID', ret.data[i].cntid); newRow.setColumnValue('ItemCode', ret.data[i].itemcode); newRow.setColumnValue('ItemNo', ret.data[i].itemno); newRow.setColumnValue('Months', ret.data[i].months); newRow.setColumnValue('OrgCode', ret.data[i].orgcode); newRow.setColumnValue('MinTotal', ret.data[i].mintotal); newRow.setColumnValue('MaxTotal', ret.data[i].maxtotal); newRow.setColumnValue('KxRate', ret.data[i].kxrate); } return true; }; // Biz.prototype.fieldChangedEtpCode = function (dataSrc, dr, dc) { // dr.setColumnValue('HtCode', ''); // this.dsDetailKx.deleteAll(); // } Biz.prototype.fieldChangedKxRate = function (dataSrc, dr, dc) { let kxRate = TypeUtil.toFloat(dr.KxRate); if(kxRate < 0 || kxRate > 100) { dr.setColumnError('KxRate','合同扣项比率应在0至100之间!'); return false; } } Biz.prototype.fieldChangedMinTotal = function (dataSrc, dr, dc) { let minTotal = TypeUtil.toFloat(dr.MinTotal); let maxTotal = TypeUtil.toFloat(dr.MaxTotal); if(minTotal < 0 || minTotal > 99999999999999) { dr.setColumnError('MinTotal','输入金额必须在0-99999999999999之间!'); return false; } if(maxTotal != 0 && minTotal > maxTotal) { dr.setColumnError('MinTotal','金额下限应小于金额上限!'); return false; } } Biz.prototype.fieldChangedMaxTotal = function (dataSrc, dr, dc) { let minTotal = TypeUtil.toFloat(dr.MinTotal); let maxTotal = TypeUtil.toFloat(dr.MaxTotal); if(maxTotal < 0 || maxTotal > 99999999999999) { dr.setColumnError('MaxTotal','输入金额必须在0-99999999999999之间!'); return false; } if(maxTotal != 0 && minTotal > maxTotal) { dr.setColumnError('MaxTotal','金额上限应大于金额下限!'); return false; } } // 数据行变化 Biz.prototype.currentChanged = function (dataSrc, oldRow, newRow) { /*if (dataSrc.name == 'dsMaster') { }else if (dataSrc.name == 'dsDetailCjKxRate') { }*/ return this.super('currentChanged', dataSrc, oldRow, newRow); }; //新增行后处理,默认值已经处理 Biz.prototype.afterNewRow = function (dataSrc, newRow) { if (dataSrc.uiObjCode === this.dsDetailCjKxRate.uiObjCode) { if(this.dsDetailKx.currentRow.IsCjKx != '1') { Store.messager.err('扣项不是层进扣项,不能设置层进明细!'); this.dsDetailCjKxRate.deleteRow(newRow); return false; } } return this.super('afterNewRow', dataSrc, newRow); }; //按钮事件控制 Biz.prototype.doOp = function (opCode) { let self = this; // if (opCode == 'account') { // let ds = self.dsMaster; // this.onAcc(self, ds); // } if (opCode == 'forchk') { let ds = self.dsMaster; this.onForchk(self, ds); } if (opCode == 'additem') { let ds = self.dsMaster; this.onAddItem(self, ds); } if (opCode == 'edititem') { let ds = self.dsMaster; this.onEditItem(self, ds); } if (opCode == 'delitem') { let ds = self.dsMaster; this.onDeleteItem(self, ds); } if (opCode == 'nochg') { let ds = self.dsMaster; this.onNoChg(self, ds); } }; //按钮事件 // Biz.prototype.onAcc = function (biz, ds) { // let billNo = TypeUtil.toString(ds.currentRow['BillNo']); // let ret = Service.DoAccount(billNo, '0702'); // if (ret.result != 1) { // Store.messager.err('记账失败!' + ret.message); // return false; // } // Store.messager.tip('记账成功!'); // biz.dsMaster.updateRow(); // return true; // }; Biz.prototype.onForchk = function (biz, ds) { let billNo = TypeUtil.toString(ds.currentRow['BillNo']); let ret = Service.DoForchk(billNo); if (ret.result != 1) { Store.messager.err('提交外部审核失败!' + ret.message); return false; } Store.messager.tip('提交外部审核成功!'); biz.dsMaster.updateRow(); return true; }; Biz.prototype.onAddItem = function (biz, ds) { if(TypeUtil.toString(this.dsMaster.currentRow['HtCode']) == '') { Store.messager.err('请录入合同!'); return false; } let outLayDetail = new OutLayDetail(this.dsDetailKx, 0); outLayDetail.callback = function () { } outLayDetail.open(); return true; }; Biz.prototype.onEditItem = function (biz, ds) { if(TypeUtil.toString(this.dsMaster.currentRow['HtCode']) == '') { Store.messager.err('请录入合同!'); return false; } let kxRow = this.dsDetailKx.currentRow; if(!kxRow) { Store.messager.err('请选择合同扣项!'); return false; } let months = TypeUtil.toString(kxRow.Months); if(months != '*') { Store.messager.err('此合同扣款专为扣项单据使用,在此不允许修改!'); return false; } let clType = TypeUtil.toString(kxRow.ClType); let scClDate = TypeUtil.toString(kxRow.ScClDate); if(clType == '0' && scClDate != '') { Store.messager.err('当前一次性扣款已经使用,不再允许修改!'); return false; } let outLayDetail = new OutLayDetail(this.dsDetailKx, 1); outLayDetail.callback = function () { let changeType = TypeUtil.toString(kxRow.ChangeType); // 仅当当前扣项的变更类型不是“新增”时,才修改它的变更类型。 if(changeType != '1') { kxRow.setColumnValue('ChangeType', 2) } } outLayDetail.open(); return true; }; Biz.prototype.onDeleteItem = function (biz, ds) { if(TypeUtil.toString(this.dsMaster.currentRow['HtCode']) == '') { Store.messager.err('请录入合同!'); return false; } let kxRow = this.dsDetailKx.currentRow; if(!kxRow) { Store.messager.err('请选择合同扣项!'); return false; } let months = TypeUtil.toString(kxRow.Months); if(months != '*') { Store.messager.err('此合同扣款专为扣项单据使用,在此不允许删除!'); return false; } let scClDate = TypeUtil.toString(kxRow.ScClDate); if(scClDate != '') { Store.messager.err('当前一次性扣款已经使用,不允许删除!'); return false; } if (!Store.confirm("您确定要删除选中的扣项吗?")) { return false; } let changeType = TypeUtil.toString(kxRow.ChangeType); // 对于新增的扣项,直接将其删除,对于原有的扣项,将其变更类型修改为“删除” if(changeType == '1') { this.dsDetailKx.deleteRow(kxRow); }else { if(changeType == '2') { // 如果原来的变更类型为“修改”,则将扣项的各项值复原 this.RecoverDetailKx(kxRow); } kxRow.setColumnValue('ChangeType', 3) } return true; }; Biz.prototype.onNoChg = function (biz, ds) { if(TypeUtil.toString(this.dsMaster.currentRow['HtCode']) == '') { Store.messager.err('请录入合同!'); return false; } let kxRow = this.dsDetailKx.currentRow; if(!kxRow) { Store.messager.err('请选择合同扣项!'); return false; } if (!Store.confirm("确定要将当前选中扣项的变更类型设置为“无变更”吗?")) { return false; } let changeType = TypeUtil.toString(kxRow.ChangeType); // 对于新增的扣项,直接将其删除,对于原有的扣项,将其变更类型修改为“无变更” if(changeType == '1') { this.dsDetailKx.deleteRow(kxRow); }else { if(changeType == '2') { // 如果原来的变更类型为“修改”,则将扣项的各项值复原 this.RecoverDetailKx(kxRow); } kxRow.setColumnValue('ChangeType', 0) } return true; }; Biz.prototype.RecoverDetailKx = function (ksRow) { ksRow.setColumnValue('BgnDate',ksRow.OldBgnDate); ksRow.setColumnValue('EndDate',ksRow.OldEndDate); ksRow.setColumnValue('JsBase',ksRow.OldJsBase); ksRow.setColumnValue('ZfCode',ksRow.OldZfCode); ksRow.setColumnValue('KxRate',ksRow.OldKxRate); ksRow.setColumnValue('TkTotal',ksRow.OldTkTotal); ksRow.setColumnValue('ClType',ksRow.OldClType); ksRow.setColumnValue('ZfType',ksRow.OldZfType); ksRow.setColumnValue('IsCalMl',ksRow.OldIsCalMl); ksRow.setColumnValue('CalMode',ksRow.OldCalMode); ksRow.setColumnValue('TkType',ksRow.OldTkType); ksRow.setColumnValue('CalBgnDate',ksRow.OldCalBgnDate); ksRow.setColumnValue('CalEndDate',ksRow.OldCalEndDate); ksRow.setColumnValue('IsInvoice',ksRow.OldIsInvoice); ksRow.setColumnValue('Remark',ksRow.OldRemark); ksRow.setColumnValue('IsSr',ksRow.OldIsSr); ksRow.setColumnValue('PluID',ksRow.OldPluID); ksRow.setColumnValue('PluCode',ksRow.OldPluCode); ksRow.setColumnValue('PluName',ksRow.OldPluName); ksRow.setColumnValue('ClsID',ksRow.OldClsID); ksRow.setColumnValue('ClsCode',ksRow.OldClsCode); ksRow.setColumnValue('ClsName',ksRow.OldClsName); ksRow.setColumnValue('BrandCode',ksRow.OldBrandCode); ksRow.setColumnValue('BrandName',ksRow.OldBrandName); ksRow.setColumnValue('FormulaId',ksRow.OldFormulaId); ksRow.setColumnValue('FormulaName',ksRow.OldFormulaName); ksRow.setColumnValue('CgyId',ksRow.OldCgyId); ksRow.setColumnValue('CgyCode',ksRow.OldCgyCode); ksRow.setColumnValue('CgyName',ksRow.OldCgyName); ksRow.setColumnValue('GsOrgCode',ksRow.OldGsOrgCode); ksRow.setColumnValue('GsOrgName',ksRow.OldGsOrgName); return true; }; //保存前 Biz.prototype.beforeSave = function () { this.GenChangeData(); if(!this.CheckCjDetail()) { return false; } return this.super('beforeSave'); }; Biz.prototype.GenChangeData = function () { let kxRows = this.dsDetailKx.rows; let cjKxRateRows = this.dsDetailCjKxRate.rows; let kxXgRows = this.dsDetailXg.rows; for(let i = 0; i < kxRows.length; i++) { let currKxRow = kxRows[i]; if(currKxRow.ChangeType == '0' || currKxRow.ChangeType == '3') { let billNo = TypeUtil.toString(currKxRow.BillNo); let orgCode = TypeUtil.toString(currKxRow.OrgCode); let itemCode = TypeUtil.toString(currKxRow.ItemCode); let itemNo = TypeUtil.toString(currKxRow.ItemNo); let months = TypeUtil.toString(currKxRow.Months); for(let j = 0; j < cjKxRateRows.length; j++) { let currCjKxRateRow = cjKxRateRows[i]; if(currCjKxRateRow.BillNo == billNo && currCjKxRateRow.OrgCode == orgCode && currCjKxRateRow.ItemCode == itemCode && currCjKxRateRow.ItemNo == itemNo && currCjKxRateRow.Months == months) { this.dsDetailCjKxRate.deleteRow(currCjKxRateRow); } } for(let j = 0; j < kxXgRows.length; j++) { let currKxgRow = kxXgRows[i]; if(currKxgRow.BillNo == billNo && currKxgRow.OrgCode == orgCode && currKxgRow.ItemCode == itemCode && currKxgRow.ItemNo == itemNo && currKxgRow.Months == months) { this.dsDetailXg.deleteRow(currKxgRow); } } this.dsDetailKx.deleteRow(currKxRow); } // 以下逐个字段判断是否发生了变化,如果发生了变化,则生成变更数据 if(currKxRow.ChangeType == '2') { this.CheckKxFieldChanged(currKxRow, 'BgnDate', '开始日期'); this.CheckKxFieldChanged(currKxRow, 'EndDate', '结束日期'); this.CheckKxFieldChanged(currKxRow, 'JsBase', '计算基数'); this.CheckKxFieldChanged(currKxRow, 'ZfCode', '支付方式'); this.CheckKxFieldChanged(currKxRow, 'KxRate', '扣项比例'); this.CheckKxFieldChanged(currKxRow, 'TkTotal', '条款金额'); this.CheckKxFieldChanged(currKxRow, 'ClType', '处理类型'); this.CheckKxFieldChanged(currKxRow, 'ZfType', '支付类型'); this.CheckKxFieldChanged(currKxRow, 'IsCalMl', '计入毛利'); this.CheckKxFieldChanged(currKxRow, 'CalMode', '计算方式'); this.CheckKxFieldChanged(currKxRow, 'TkType', '条款类型'); this.CheckKxFieldChanged(currKxRow, 'CalBgnDate', '条款日期区间开始日期'); this.CheckKxFieldChanged(currKxRow, 'CalEndDate', '条款日期区间结束日期'); this.CheckKxFieldChanged(currKxRow, 'IsInvoice', '不计入货款发票'); this.CheckKxFieldChanged(currKxRow, 'Remark', '备注'); this.CheckKxFieldChanged(currKxRow, 'IsSr', '十位数四舍五入'); this.CheckKxFieldChanged(currKxRow, 'PluCode', '商品'); this.CheckKxFieldChanged(currKxRow, 'IsCjKx', '是否层进扣项'); this.CheckKxFieldChanged(currKxRow, 'CalcType', '层进扣项计算方式'); this.CheckKxFieldChanged(currKxRow, 'CgyId', '采购员ID'); this.CheckKxFieldChanged(currKxRow, 'CgyCode', '采购员编码'); this.CheckKxFieldChanged(currKxRow, 'CgyName', '采购员名称'); this.CheckKxFieldChanged(currKxRow, 'GsOrgCode', '扣项归属组织'); this.CheckKxFieldChanged(currKxRow, 'GsOrgName', '扣项归属组织名称'); this.CheckKxFieldChanged(currKxRow, 'ClsCode', '品类'); this.CheckKxFieldChanged(currKxRow, 'BrandCode', '品牌'); this.CheckKxFieldChanged(currKxRow, 'FormulaId', '计算公式') ; } } } Biz.prototype.CheckKxFieldChanged = function (kxRow, fieldName, fieldCNNane) { let oldValue = TypeUtil.toString(kxRow['Old' + fieldName]); let newValue = TypeUtil.toString(kxRow[fieldName]); let billNo = TypeUtil.toString(kxRow.BillNo); let orgCode = TypeUtil.toString(kxRow.OrgCode); let orgName = TypeUtil.toString(kxRow.OrgName); let itemCode = TypeUtil.toString(kxRow.ItemCode); let itemNo = TypeUtil.toString(kxRow.ItemNo); let months = TypeUtil.toString(kxRow.Months); let kxXgRows = this.dsDetailXg.rows; if(newValue != oldValue) { for(let i = 0; i < kxXgRows.length; i++) { let currKxXgRow = kxXgRows[i]; if(currKxXgRow.BillNo == billNo && currKxXgRow.OrgCode == orgCode && currKxXgRow.ItemCode == itemCode && currKxXgRow.ItemNo == itemNo && currKxXgRow.Months == months && currKxXgRow.FieldName == fieldName) { currKxXgRow.setColumnValue('OriValue', oldValue); currKxXgRow.setColumnValue('OriName', oldValue); currKxXgRow.setColumnValue('NowValue', newValue); currKxXgRow.setColumnValue('NowName', newValue); return true; } } let addKxXgRow = this.dsDetailXg.addRow(); addKxXgRow.setColumnValue('BillNo', billNo); addKxXgRow.setColumnValue('ItemCode', itemCode); addKxXgRow.setColumnValue('OrgCode', orgCode); addKxXgRow.setColumnValue('OrgName', orgName); addKxXgRow.setColumnValue('ItemNo', itemNo); addKxXgRow.setColumnValue('Months', months); addKxXgRow.setColumnValue('FieldName', fieldName); addKxXgRow.setColumnValue('FieldCName', fieldCNNane); addKxXgRow.setColumnValue('OriValue', oldValue); addKxXgRow.setColumnValue('OriName', oldValue); addKxXgRow.setColumnValue('NowValue', newValue); addKxXgRow.setColumnValue('NowName', newValue); return true; }else { for(let i = 0; i < kxXgRows.length; i++) { let currKxXgRow = kxXgRows[i]; if(currKxXgRow.BillNo == billNo && currKxXgRow.OrgCode == orgCode && currKxXgRow.ItemCode == itemCode && currKxXgRow.ItemNo == itemNo && currKxXgRow.Months == months && currKxXgRow.FieldName == fieldName) { kxXgRows.deleteRow(currKxXgRow); return true; } } } } Biz.prototype.CheckCjDetail = function() { if(this.dsDetailCjKxRate.rows.length < 1) { return true; } // 根据金额下限升序排序 this.dsDetailCjKxRate.rows.sort(this.SortLxTcRate); if(TypeUtil.toFloat(this.dsDetailCjKxRate.rows[0].MinTotal) != 0) { Store.messager.err('最低金额下限必须为0!'); return false; } let thisMaxTotal; let nextMinTotal; for(let i = 0; i < this.dsDetailCjKxRate.rows.length-1; i++) { thisMaxTotal = TypeUtil.toFloat(this.dsDetailCjKxRate.rows[i].MaxTotal); nextMinTotal = TypeUtil.toFloat(this.dsDetailCjKxRate.rows[i+1].MinTotal); if(thisMaxTotal > nextMinTotal) { Store.messager.err('金额区间重复!'); return false; } } for(let i = 0; i < this.dsDetailCjKxRate.rows.length-1; i++) { thisMaxTotal = TypeUtil.toFloat(this.dsDetailCjKxRate.rows[i].MaxTotal); nextMinTotal = TypeUtil.toFloat(this.dsDetailCjKxRate.rows[i+1].MinTotal); if(thisMaxTotal != nextMinTotal) { Store.messager.err('金额区间不连续!'); return false; } } if(TypeUtil.toFloat(this.dsDetailCjKxRate.rows[this.dsDetailCjKxRate.rows.length-1].MaxTotal) != 0) { Store.messager.err('最高金额上限必须设置为0,金额上限为0代表上限不做限制。'); return false; } return true; }; Biz.prototype.SortLxTcRate = function (a, b) { return a.MinTotal - b.MinTotal; }; return Biz; });