/** * 复制权限按钮弹框文件 * @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/cls/cls130101/ClsDivide.tpl'); let service = require('./cls130101service'); /** * [复制权限弹框] * @param {[type]} dsData 角色表数据源,用于对角色ComBox进行赋值 */ function ClsDivide(dsData, newClsCodeLen, preClsCode) { 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: 'ClsDivide' + (new Date()).getTime(), data: null, onBeforeClose: function(){ dsData.unmount(self) } } this.dsData = dsData; this.newClsCodeLen = newClsCodeLen; this.preClsCode = preClsCode; this.dsData.on('onFieldChanged', function(sendor, eventArgs){ let adapter = self.vm['ep_dsMaster']; switch(eventArgs.col.fieldName) { case 'IsLast' : // 把默认不可编辑的禁掉 adapter.setEditorEditable('ClsCode', true); adapter.setEditorEditable('ClsName', true); adapter.setEditorEditable('IsLast', false); adapter.setEditorEditable('PluCount', true); break; } }, self); Window.call(this, this.options); } inherits(ClsDivide, Window); ClsDivide.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_dsMaster'; if (self.vm[gridName].actions.onActiveFirstCell) { self.vm[gridName].actions.onActiveFirstCell(); } } } }; self.register('editpanel', 'ep_dsMaster', args); } ClsDivide.prototype.open = function() { Window.prototype.open.call(this); this.dsData.setEditable(true); //this.dsData.getColumn('IsLast').set('isEditable',false); // let adapter = self.vm['ep_dsMaster']; // adapter.setEditorEditable('IsLast', false); let newRow = this.dsData.addRow(); newRow.setColumnText('IsLast', '1'); } //执行windows窗体上自定义按钮事件 ClsDivide.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 currentRow = self.dsData.currentRow; let clsCode = TypeUtil.toString(currentRow['ClsCode']); let clsName = TypeUtil.toString(currentRow['ClsName']); let clsType = TypeUtil.toString(currentRow['ClsType']); let isExPluCode = TypeUtil.toString(currentRow['IsExPluCode']); let exPluType = TypeUtil.toString(currentRow['ExPluType']); let isBz = TypeUtil.toString(currentRow['IsBz']); let isCurrDay = TypeUtil.toString(currentRow['IsCurrDay']); let isSeason = TypeUtil.toString(currentRow['IsSeason']); let cxPrecision = TypeUtil.toString(currentRow['CxPrecision']); let cxCalcuType = TypeUtil.toString(currentRow['CxCalcuType']); let remark = TypeUtil.toString(currentRow['Remark']); let pluCount = TypeUtil.toString(currentRow['PluCount']); let minMlRate = TypeUtil.toFloat(currentRow['MinMlRate']); let maxMlRate = TypeUtil.toFloat(currentRow['MaxMlRate']); let saleSeason = TypeUtil.toString(currentRow['SaleSeason']); if(clsCode == '') { Store.messager.err('品类编号不能为空!'); return false; } if(clsName == '') { Store.messager.err('品类名称不能为空!'); return false; } // 品类编号需要满足特殊选项设置的长度,前缀为父级品类的编号 let pattern=eval('/^' + self.preClsCode + '[0-9a-zA-Z]{' + (self.newClsCodeLen-self.preClsCode.length) + '}$/'); if (!pattern.test(clsCode)) { Store.messager.err('品类编号必须为数字或英文字母的组合,长度为' + self.newClsCodeLen + (self.preClsCode == '' ? '' : ',前缀为' + self.preClsCode)); return false; } let pattern = /[+ -''*|=,{};]/; if(pattern.test(clsName)) { Store.messager.err('品类编号不能包含+ -\'\'*|=,{};等非法字符!'); return false; } if(minMlRate < 0 || minMlRate > 100) { Store.messager.err('最小毛利率应在0到100之间!'); return false; } if(maxMlRate < 0 || maxMlRate > 100) { Store.messager.err('最大毛利率应在0到100之间!'); return false; } if(minMlRate > maxMlRate) { Store.messager.err('最大毛利率应大于等于最小毛利率!'); return false; } let ret = service.ClsExists(clsCode, ''); if (ret.result != 1) { Store.messager.err(ret.message); return false; } if (ret.data == 1) { Store.messager.err('品类编号已存在!'); return false; } ret = service.ClsExists('', clsName); if (ret.result != 1) { Store.messager.err(ret.message); return false; } if (ret.data == 1) { if (!Store.confirm("品类名称已存在,要继续吗?")) { return false; } } let clsData = clsCode + '#' + clsName; let clsInfo = (clsType=='' ? '01' : clsType) + '#' + isExPluCode + '#' + (exPluType=='' ? '00' : exPluType) + '#' + isBz + '#' + isCurrDay + '#' + isSeason + '#' + (cxPrecision=='' ? '0' : cxPrecision) + '#' + (cxCalcuType=='' ? '0' : cxCalcuType) + '#' + remark + '#' + (pluCount=='' ? '0' : pluCount) + '#' + minMlRate + '#' + maxMlRate + '#' + (saleSeason=='' ? '1111' : saleSeason); self.dsData.deleteRow(self.dsData.currentRow); self.dsData.setEditable(false); if (self.callback) { self.callback(clsData, clsInfo); } self.close(); }); //取消按钮事件 this.getElement('.btnCancel').on('click', function(event) { self.dsData.setEditable(false); self.dsData.deleteRow(self.dsData.currentRow); self.close(); }); } return ClsDivide; })