/** * 复制权限按钮弹框文件 * @description [description] * @version 1.0 * @author yangjinhua */ define(function(require, exports, module) { let Window = require('system/views/pages/window'); let tpl = require('text!apps/rht/cnt/cnt070210/OutLayDetail.tpl'); let rhtComm = require('../../comm/rhtComm'); /** * [复制权限弹框] * @param {[type]} dsData 角色表数据源,用于对角色ComBox进行赋值 */ function OutLayDetail(dsData, operType) { let self = this this.options = { title: "合同扣款变更", content: tpl, width: 800, height: 600, modal: true, closed: true, closable: false, draggable: true, maximizable: false, resizable: false, id: 'OutLayDetail' + (new Date()).getTime(), data: null, onBeforeClose: function(){ dsData.unmount(self) } } this.dsData = dsData; this.operType = operType; this.dsData.on('onFieldChanged', function(sendor, eventArgs){ let adapter = self.vm['ep_dsDetailKx']; switch(eventArgs.col.fieldName) { case 'BillNo' : // 把默认不可编辑的禁掉 adapter.setEditorEditable('CalBgnDate', false); adapter.setEditorEditable('CalEndDate', false); adapter.setEditorEditable('ZfCode', false); adapter.setEditorEditable('PluCode', false); adapter.setEditorEditable('KxRate', false); adapter.setEditorEditable('IsCjKx', false); adapter.setEditorEditable('ClsCode', false); adapter.setEditorEditable('BrandCode', false); adapter.setEditorEditable('KxFormula', false); adapter.setEditorEditable('CalcType', false); break; case 'JsBase' : let jsBase = eventArgs.row.JsBase; if(jsBase == '00') { adapter.setEditorEditable('TkTotal', true); adapter.setEditorEditable('KxRate', false); adapter.setEditorEditable('CalMode', false); adapter.setEditorEditable('CalBgnDate', false); adapter.setEditorEditable('CalEndDate', false); adapter.setEditorEditable('ZfCode', false); adapter.setEditorEditable('PluCode', false); }else { adapter.setEditorEditable('TkTotal', false); adapter.setEditorEditable('KxRate', true); adapter.setEditorEditable('CalMode', true); if(jsBase == '24') { adapter.setEditorEditable('ZfCode', true); }else { adapter.setEditorEditable('ZfCode', false); } // 当计算基数选择商品相关的四个基数之一时,商品编码可编辑 if(jsBase == '12' || jsBase == '25' || jsBase == '26') { adapter.setEditorEditable('PluCode', true); }else { adapter.setEditorEditable('PluCode', false); } } if(jsBase == '00' || jsBase == '25' || jsBase == '26' || jsBase == '60') { adapter.setEditorEditable('IsCjKx', false); adapter.setEditorEditable('CalcType', false); }else { adapter.setEditorEditable('IsCjKx', true); eventArgs.row.setColumnValue('IsCjKx', 1); adapter.setEditorEditable('CalcType', eventArgs.row.IsCjKx == '1'); } if(jsBase == '60') { adapter.setEditorEditable('KxRate', false); }else { adapter.setEditorEditable('KxRate', true); } if(jsBase == '71' || jsBase == '72') { adapter.setEditorEditable('ClsCode', true); adapter.setEditorEditable('BrandCode', true); }else { adapter.setEditorEditable('ClsCode', false); adapter.setEditorEditable('BrandCode', false); } if(jsBase == '74') { adapter.setEditorEditable('KxFormula', true); }else { adapter.setEditorEditable('KxFormula', false); } if(jsBase == '00') { eventArgs.row.setColumnValue('CalMode', 0); eventArgs.row.setColumnValue('KxRate', 0); eventArgs.row.setColumnValue('PluCode', ''); }else { eventArgs.row.setColumnValue('TkTotal', 0); if(jsBase != '12' && jsBase != '25' && jsBase != '26') { eventArgs.row.setColumnValue('PluCode', ''); } } if(jsBase == '16' || jsBase == '17' || jsBase == '18') { adapter.setEditorEditable('ClType', false); eventArgs.row.setColumnValue('ClType', 1); }else { adapter.setEditorEditable('ClType', true); } if(jsBase == '60') { adapter.setEditorEditable('KxRate', false); eventArgs.row.setColumnValue('KxRate', 0); }else { adapter.setEditorEditable('KxRate', true); } if(jsBase == '71' || jsBase == '72') { adapter.setEditorEditable('ClsCode', false); adapter.setEditorEditable('BrandCode', false); }else { adapter.setEditorEditable('ClsCode', true); adapter.setEditorEditable('BrandCode', true); } if(jsBase == '74') { adapter.setEditorEditable('KxFormula', true); }else { adapter.setEditorEditable('KxFormula', false); } break; case 'CalMode' : let calMode = eventArgs.row.CalMode; if(calMode == '0') { adapter.setEditorEditable('CalBgnDate', false); adapter.setEditorEditable('CalEndDate', false); }else { adapter.setEditorEditable('CalBgnDate', true); adapter.setEditorEditable('CalEndDate', true); } break; case 'IsCjKx' : let isCjKx = eventArgs.row.IsCjKx; if(isCjKx == '1') { adapter.setEditorEditable('CalcType', true); eventArgs.row.setColumnValue('KxRate', 0); }else { adapter.setEditorEditable('CalcType', false); } break; } }, self); Window.call(this, this.options); } inherits(OutLayDetail, Window); OutLayDetail.prototype.init = function() { let self = this; let args = { data: this.dsData, opts: { showSettingBtn: '0', editable: true }, //TODO 添加last panel enter action actions: { onLastPanelEneterd: function () { let gridName = 'grid_dsDetailKx'; if (self.vm[gridName].actions.onActiveFirstCell) { self.vm[gridName].actions.onActiveFirstCell(); } } } }; self.register('editpanel', 'ep_dsDetailKx', args); } OutLayDetail.prototype.open = function() { Window.prototype.open.call(this); this.dsData.setEditable(true); if(this.operType == '0') { this.dsData.addRow(); } } //执行windows窗体上自定义按钮事件 OutLayDetail.prototype.customerize = function() { let self = this; let rows = null; if (Store.logOn.userType === '0') rows = this.dsData.rows; else rows = _.where(self.dsData.rows, { 'RightCtrlOrgCode': Store.logOn.rightCtrlOrgCode }); //确定按钮事件 this.getElement('.btnOK').on('click', function(event) { let row = self.dsData.currentRow; let bgnDate = TypeUtil.toString(row.BgnDate); let endDate = TypeUtil.toString(row.EndDate); if(bgnDate > endDate) { Store.messager.err('合同扣款结束日期必须大于等于开始日期!'); return false; } let orgCode = TypeUtil.toString(row.OrgCode); if(orgCode == '') { Store.messager.err('合同扣款组织不能为空!'); return false; } let itemNo = TypeUtil.toString(row.ItemNo); if(itemNo == '') { Store.messager.err('条款号不能为空!'); return false; } let jsBase = TypeUtil.toString(row.JsBase); if(jsBase != '00') { let calMode = TypeUtil.toString(row.CalMode); if(calMode == '1') { let calBgnDate = TypeUtil.toString(row.CalBgnDate); let calEndDate = TypeUtil.toString(row.CalEndDate); if(calBgnDate == '' || calEndDate == '') { Store.messager.err('计算区间开始和结束日期不能为空!'); return false; } if(calBgnDate > calEndDate) { Store.messager.err('计算区间结束日期必须大于等于计算区间开始日期!'); return false; } } if(jsBase == '12' || jsBase == '25' || jsBase == '26') { let pluCode = TypeUtil.toString(row.PluCode); if(pluCode == '') { Store.messager.err('商品编码不能为空!'); return false; } }else if(jsBase == '74') { let formulaId = TypeUtil.toString(row.FormulaId); if(formulaId == '') { Store.messager.err('计算公式不能为空!'); return false; } }else { let kxRate = TypeUtil.toFloat(row.KxRate); if(kxRate < 0 || kxRate > 100) { Store.messager.err('合同扣项比率应在0至100之间!'); return false; } } } if(jsBase == '24') { let zfCode = TypeUtil.toString(row.ZfCode); if(zfCode == '') { Store.messager.err('支付方式不能为空!'); return false; } } if(jsBase == '14' || jsBase == '15') { let isMultiCheck = rhtComm.getRhtOptionValue("*",'ORD','Ord_IsMultiCheck','1'); if(isMultiCheck != '0') { Store.messager.err('合同扣款条款需要系统控制不允许多次验收,允许多次验收不能设置扣项!'); return false; } } if(jsBase == '60') { let orgCode = TypeUtil.toString(row.OrgCode); if(orgCode == '*') { Store.messager.err('计算基数为“60-供应商新增经营商品”,其对应的组织不能为*!'); return false; } } if(jsBase == '71' || jsBase == '72') { let isMultiCheck = rhtComm.getRhtOptionValue("*",'ORD','Ord_IsMultiCheck','1'); if(isMultiCheck != '0') { Store.messager.err('合同扣款条款需要系统控制不允许多次验收,允许多次验收不能设置扣项!'); return false; } } self.dsData.setEditable(false); if (self.callback) { self.callback(); } self.close(); }); //取消按钮事件 this.getElement('.btnCancel').on('click', function(event) { self.dsData.setEditable(false); if(self.operType == '0') { self.dsData.deleteRow(self.dsData.currentRow); } self.close(); }); } return OutLayDetail; })