Ext.QuickTips.init(); Ext.define('erp.controller.ma.DataLimit', { extend : 'Ext.app.Controller', stores: ['ma.DataLimitStore'], views : [ 'ma.datalimit.DataLimit', 'ma.datalimit.LimitDetail', 'ma.datalimit.LimitForm','core.form.MultiField','core.trigger.DbfindTrigger','ma.datalimit.SourceWindow', 'core.form.FtField','core.form.FtDateField','core.form.FtFindField','core.form.FtNumberField', 'core.form.MonthDateField','common.batchDeal.Form','common.batchDeal.GridPanel', 'core.trigger.AddDbfindTrigger', 'core.trigger.DbfindTrigger','core.form.FtField','core.form.FtFindField','core.form.ConDateField','core.button.TurnMeetingButton', 'core.trigger.TextAreaTrigger','core.form.YnField', 'core.form.MonthDateField','core.form.ConMonthDateField','core.trigger.SchedulerTrigger', 'core.grid.YnColumn','core.form.DateHourMinuteField','core.form.SeparNumber'], FormUtil: Ext.create('erp.util.FormUtil'), BaseUtil: Ext.create('erp.util.BaseUtil'), GridUtil: Ext.create('erp.util.GridUtil'), flag:true, init : function() { var me = this; this.control({ 'button[itemId=copy]': { click: function(btn) { var instanceid_=Ext.getCmp('instanceid_'); if(instanceid_.value) me.CopyPower(); else showError('请选择有效的人员和数据类型复制权限!'); } }, 'button[itemId=delete]':{//清除权限 click:function(btn){ var me = this, grid = Ext.getCmp('limitdetail'),instanceid_=Ext.getCmp('instanceid_'); var items = grid.selModel.getSelection(),dItems=new Array(),rItems=new Array(); if(items.length<1) showError("没有需要处理的数据!"); Ext.each(items, function(item, index){ if(this.data[grid.keyField] != null && this.data[grid.keyField] != '' && this.data[grid.keyField] != '0' && this.data[grid.keyField] != 0){ dItems.push({ id_:item.data.id_ }); }else rItems.push(item); }); grid.getStore().remove(rItems); if(dItems.length>0){ me.FormUtil.setLoading(true); Ext.Ajax.request({ url:basePath+'ma/datalimit/deleteLimitPower.action', method:'POST', params:{ data:unescape(Ext.JSON.encode(dItems)) }, callback:function(options, success, response){ me.FormUtil.setLoading(false); var res = new Ext.decode(response.responseText); if(res.success){ Ext.Msg.alert('提示','删除成功!',function(){ Ext.getCmp('limitdetail').getStore().load({ params:{ InstanceId_:instanceid_ } }) }); } } }); } } }, 'erpVastDealButton': { click: function(btn){ var url=btn.ownerCt.ownerCt.dealUrl,instanceid_=Ext.getCmp('instanceid_'); warnMsg("复制权限将选中人员对应数据类型权限全部覆盖?", function(btn){ if(btn == 'yes'){ me.vastDeal(url, instanceid_.value); } else { return; } }); } }, 'combo[name=limit_id_]':{ change:function(field,newvalue,oldvalue){ var empid_=Ext.getCmp('empid_'); if(empid_.value){ me.getDataLimitInstance(newvalue,empid_.value); } } }, 'hidden[name=empid_]':{ change:function(field,newvalue,oldvalue){ var limitid_=Ext.getCmp('limit_id_'); if(limitid_.value){ me.getDataLimitInstance(limitid_.value,newvalue); } } }, 'checkbox[name=nolimit_]':{ change:function(field,newvalue,oldvalue){ var querys=Ext.ComponentQuery.query('button[itemId=select]'),noaddlimit_=Ext.getCmp('noaddlimit_'), usereport_=Ext.getCmp('usereport_'); if(querys.length>0) { querys[0].setDisabled(newvalue==1); } noaddlimit_.setDisabled(newvalue==1); usereport_.setDisabled(newvalue==1); if(newvalue==1){ noaddlimit_.setValue(0); usereport_.setValue(0); } if(me.flag){ if(newvalue){ warnMsg('是否将分配全部权限信息?', function(btn){ if(btn != 'yes' && btn != 'ok'){ me.flag=false; field.setValue(0); }else { var noaddlimit_=Ext.getCmp('noaddlimit_'),usereport_=Ext.getCmp('usereport_'); noaddlimit_.setDisabled(true); usereport_.setDisabled(true); var querys=Ext.ComponentQuery.query('button[itemId=select]'); if(querys.length>0) querys[0].setDisabled(true); } }); }else{ warnMsg('是否将已有全部权限信息清除?', function(btn){ if(btn != 'yes' && btn != 'ok'){ me.flag=false; field.setValue(1); }else { var noaddlimit_=Ext.getCmp('noaddlimit_'),usereport_=Ext.getCmp('usereport_'); noaddlimit_.setDisabled(false); usereport_.setDisabled(false); var querys=Ext.ComponentQuery.query('button[itemId=select]'); if(querys.length>0) querys[0].setDisabled(false); } }); } }else me.flag=true; } }, 'radiogroup':{ change:function(field,newvalue,oldvalue){ var c=Ext.getCmp('condition_'); if(c.hidden && newvalue.limittype_=='condition'){ c.show(); }else if(!c.hidden)c.hide(); } }, 'button[itemId=select]':{ click:function(btn){ var limitid_=Ext.getCmp('limit_id_'),empid_=Ext.getCmp('empid_'),record=limitid_.findRecordByValue(limitid_.value),limittype_=Ext.getCmp('limittype_').getValue().limittype_; if(!limitid_.value) showError('未选择相应的数据类型!'); else if(!empid_.value) showError('未选择相应的人员!'); else { Ext.widget('sourcewindow',{ limitId_:limitid_.value, table:record.get('table_'), LimitType:limittype_, modal:true, title:'