| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- Ext.define('saas.view.sys.power.FormPanelController', {
- extend: 'Ext.app.ViewController',
- alias: 'controller.sys-power-formpanel',
- init: function (form) {
- var me = this;
- this.control({
- 'button[name=savepower]':{
- click:function(b){
- me.onSave(b);
- }
- }
- });
- },
- onSave: function(b) {
- var me = this,
- form = me.getView(),
- viewModel = me.getViewModel(),
- updateRecs = viewModel.data.powergrid.getUpdatedRecords();
- if(updateRecs.length>0){
- var params = {};
- var roleId = b.ownerCt.ownerCt.initId;//角色ID
- params.roleId = roleId;
- var datas = [];
- Ext.Array.each(updateRecs,function(rec){
- var modified = rec.modified;
- if(modified){
- var modifyDatas = me.getBaseField(modified,rec.get('groupId'),rec.data);
- datas = datas.concat(modifyDatas);
- }
- //收集other
- var other = rec.get('other');
- if(other&&other!=null){
- Ext.Array.each(other,function(o){
- datas.push({
- classify:'other',
- checked:o.checked,
- resourceId:o.resourceId
- });
- });
- }
- })
- params.powerSetList = datas;
- saas.util.BaseUtil.request({
- url: form.saveUrl,
- params: JSON.stringify(params),
- method: 'POST',
- })
- .then(function(localJson) {
- if(localJson.success){
- saas.util.BaseUtil.showSuccessToast('保存成功');
- viewModel.data.powergrid.load();
- }
- })
- .catch(function(e) {
- saas.util.BaseUtil.showErrorToast('保存失败: ' + e.message);
- });
- }else{
- saas.util.BaseUtil.showErrorToast('没有修改数据,请修改后保存');
- }
- },
- getBaseField:function(modified,groupId,data){
- var powerSetList = [];
- if((typeof modified.add) == 'boolean'){
- powerSetList.push({
- groupId:groupId,
- classify:'add',
- checked:data['add']
- })
- }
- if((typeof modified.query) == 'boolean'){
- powerSetList.push({
- groupId:groupId,
- classify:'query',
- checked:data['query']
- })
- }
- if((typeof modified.delete) == 'boolean'){
- powerSetList.push({
- groupId:groupId,
- classify:'delete',
- checked:data['delete']
- })
- }
- if((typeof modified.audit) == 'boolean'){
- powerSetList.push({
- groupId:groupId,
- classify:'audit',
- checked:data['audit']
- })
- }
- if((typeof modified.update) == 'boolean'){
- powerSetList.push({
- groupId:groupId,
- classify:'update',
- checked:data['update']
- })
- }
- if((typeof modified.unAudit) == 'boolean'){
- powerSetList.push({
- groupId:groupId,
- classify:'unAudit',
- checked:data['unAudit']
- })
- }
- if((typeof modified.fileExport) == 'boolean'){
- powerSetList.push({
- groupId:groupId,
- classify:'export',
- checked:data['fileExport']
- })
- }
- if((typeof modified.fileImport) == 'boolean'){
- powerSetList.push({
- groupId:groupId,
- classify:'import',
- checked:data['fileImport']
- })
- }
- if((typeof modified.print) == 'boolean'){
- powerSetList.push({
- groupId:groupId,
- classify:'print',
- checked:data['print']
- })
- }
- return powerSetList;
- }
- });
|