123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355 |
- 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:'<div align="center">设置权限('+(limittype_=='detail'?'按明细数据':'按条件')+')</div>'
- }).show();
- }
- }
- },
- 'button[itemId=createSql]':{
- click:function(btn){
- var w=btn.ownerCt.ownerCt,g=w.down('#querygrid'),_c=g.getCondition();
- if(_c){
- Ext.getCmp('condition_').setValue(_c);
- w.close();
- }else {
- showError('未设置任何条件');
- }
-
- }
- },
- 'button[itemId=query]':{
- click:function(btn){
- var w=btn.ownerCt.ownerCt,g=w.down('#querygrid'),dg=w.down('#datagrid'),con=g.getCondition();
- if(con!=""){
- dg.getStore().load({
- params:{
- condition:con
- }
- });
- }
- }
- },
- 'button[itemId=selectdata]':{
- click:function(btn){
- var w=btn.ownerCt.ownerCt,g=w.down('#datagrid'),selects=g.getSelectionModel().getSelection();
- var limitdetail=Ext.getCmp('limitdetail');
- if(selects.length>0){
- limitdetail.insertRecords(selects);
- }else showError('请选择需要分配的数据!');
- w.close();
- }
- },
- 'button[itemId=save]':{
- click:function(btn){
- var form=btn.ownerCt.ownerCt,grid=Ext.getCmp('limitdetail'),params=new Object();
- var r=form.getValues();
- delete r['emcode_'];
- delete r['emname_'];
- params.formData=unescape(escape(Ext.JSON.encode(r)));
- var changes=grid.getChange();
- if(changes.added.length>0){
- params.inserts=unescape(changes.added.toString());
- }
- if(changes.updated.length>0){
- params.updates=unescape(changes.updated.toString());
- }
- me.FormUtil.setLoading(true);
- Ext.Ajax.request({
- url:basePath+'ma/datalimit/InstanceDataLimit.action',
- method:'post',
- params:params,
- 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_:res.id ||-1
- }
- })
- });
- }
- }
- });
- }
- }
- });
- },
- getDataLimitInstance:function(limitid_,emid){
- var me=this;
- me.FormUtil.setLoading(true);
- Ext.Ajax.request({
- url:basePath+'ma/datalimit/getDataLimitInstance.action',
- method:'get',
- params:{
- empid_:emid,
- limitid_:limitid_
- },
- callback : function(options, success, response){
- me.FormUtil.setLoading(false);
- var res={nolimit_:1};
- if (response.responseText) res = new Ext.decode(response.responseText);
- me.refreshLimits(res);
- }
- });
- },
- refreshLimits:function(data){
- var me=this,nolimit_=Ext.getCmp('nolimit_'),instanceid_=Ext.getCmp('instanceid_'),noaddlimit_=Ext.getCmp('noaddlimit_'),usereport_=Ext.getCmp('usereport_'),condition_=Ext.getCmp('condition_'),limittype_=Ext.getCmp('limittype_');
- nolimit_.setDisabled(false);
- if(data){
- instanceid_.setValue(data['instanceid_']);
- noaddlimit_.setValue(data['noaddlimit_']);
- usereport_.setValue(data['usereport_']);
- condition_.setValue(data['condition_']);
- limittype_.setValue({limittype_:data['limittype_']});
- me.flag=false;
- nolimit_.setValue(data['nolimit_']);
- Ext.getCmp('limitdetail').getStore().load({
- params:{
- InstanceId_:data['instanceid_'] ||-1
- }
- })
- }
- },
- CopyPower:function(){
- var win=Ext.getCmp('emp_select');
- if(!win){
- win=new Ext.window.Window({
- id:'emp_select',
- width:'90%',
- height:'95%',
- title:'复制权限',
- closeAction:'hide',
- layout:'anchor',
- items:[{
- anchor:'100% 20%',
- xtype:'erpBatchDealFormPanel',
- caller:'EmployeeCopyPower'
- },{
- anchor:'100% 80%',
- xtype:'erpBatchDealGridPanel',
- caller:'EmployeeCopyPower'
- }]
- });
- }
- win.show();
- },
- vastDeal: function(url,instanceId){
- var me = this, grid = Ext.getCmp('batchDealGridPanel');
- var items = grid.selModel.getSelection();
- 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){
- item.index = this.data[grid.keyField];
- grid.multiselected.push(item);
- }
- });
- var form = Ext.getCmp('dealform'),params=new Object();
- var records = Ext.Array.unique(grid.multiselected);
- if(records.length > 0){
- var data=new Array();
- Ext.each(records,function (item){
- data.push({
- em_id:item.data[grid.keyField],
- InstanceId_:instanceId
- })
- });
- if(!me.dealing){
- params.data = unescape(Ext.JSON.encode(data).replace(/\\/g,"%"));
- me.dealing = true;
- var main = parent.Ext.getCmp("content-panel");
- main.getActiveTab().setLoading(true);//loading...
- Ext.Ajax.request({
- url : basePath + url,
- params: params,
- method : 'post',
- timeout: 6000000,
- callback : function(options,success,response){
- main.getActiveTab().setLoading(false);
- me.dealing = false;
- var localJson = new Ext.decode(response.responseText);
- if(localJson.exceptionInfo){
- var str = localJson.exceptionInfo;
- if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){
- str = str.replace('AFTERSUCCESS', '');
- grid.multiselected = new Array();
- }
- showError(str);return;
- }
- if(localJson.success){
- if(localJson.log){
- showMessage("提示", localJson.log);
- }
- grid.multiselected = new Array();
- grid.ownerCt.close();
- }
- }
- });
- } else {
- showError("没有需要处理的数据!");
- }
- } else {
- showError("请勾选需要的明细!");
- }
- }
- });
|