| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261 |
- Ext.QuickTips.init();
- Ext.define('erp.controller.common.SubsFormula', {
- extend: 'Ext.app.Controller',
- requires: ['erp.util.FormUtil', 'erp.util.GridUtil', 'erp.util.BaseUtil'],
- views:[
- 'core.form.Panel','common.subs.SubsFormula','core.grid.Panel2','core.toolbar.Toolbar','core.trigger.MultiDbfindTrigger','core.trigger.HrOrgTreeDbfindTrigger',
- 'core.button.Save','core.button.Add','core.button.Submit','core.button.Print','core.button.Upload','core.button.ResAudit',
- 'core.button.Audit','core.button.Close','core.button.Delete','core.button.Update','core.button.DeleteDetail','core.button.ResSubmit',
- 'core.button.Banned','core.button.ResBanned','core.form.MultiField','core.button.Confirm','core.button.Sync',
- 'core.trigger.DbfindTrigger','core.trigger.TextAreaTrigger','core.form.YnField', 'core.grid.YnColumn','core.trigger.AddDbfindTrigger',
- 'core.form.FileField','core.form.SplitTextField','core.button.End','core.button.ResEnd',
- 'core.form.MonthDateField','core.form.SpecialContainField','core.button.Test'
- ],
- init:function(){
- var me = this;
- me.FormUtil = Ext.create('erp.util.FormUtil');
- me.GridUtil = Ext.create('erp.util.GridUtil');
- me.BaseUtil = Ext.create('erp.util.BaseUtil');
- this.control({
- 'erpGridPanel2': {
- itemclick: this.onGridItemClick,
- },
- 'erpSaveButton': {
- click: function(btn){
- var form = me.getForm(btn);
- if (Ext.getCmp(form.codeField).value == null
- || Ext.getCmp(form.codeField).value == '') {
- me.BaseUtil.getRandomNumber();// 自动添加编号
- }
- this.FormUtil.beforeSave(this);
- }
- },
- 'erpDeleteButton' : {
- click: function(btn){
- me.FormUtil.onDelete(Ext.getCmp('id_').value);
- }
- },
- 'erpUpdateButton': {
- click: function(btn){
- this.FormUtil.onUpdate(this);
- }
- },
- 'erpAddButton': {
- click: function(){
- me.FormUtil.onAdd('addSubsFormula', '新增订阅项', 'jsps/common/subsformula.jsp');
- }
- },
- 'erpCloseButton': {
- click: function(btn){
- me.FormUtil.beforeClose(me);
- }
- },
- 'erpAuditButton' : {
- afterrender : function(btn) {
- var status = Ext.getCmp('statuscode_');
- if (status && status.value != 'COMMITED') {
- btn.hide();
- }
- },
- click : function(btn) {
- this.FormUtil.onAudit(Ext.getCmp('id_').value);
- }
- },
- 'erpResAuditButton' : {
- afterrender : function(btn) {
- var status = Ext.getCmp('statuscode_');
- if (status && status.value != 'AUDITED') {
- btn.hide();
- }
- },
- click : function(btn) {
- this.FormUtil.onResAudit(Ext.getCmp('id_').value);
- }
- },
- 'erpSubmitButton' : {
- afterrender : function(btn) {
- var status = Ext.getCmp('statuscode_');
- if (status && status.value != 'ENTERING') {
- btn.hide();
- }
- },
- click : function(btn) {
- this.FormUtil.onSubmit(Ext.getCmp('id_').value);
- }
- },
- 'erpResSubmitButton' : {
- afterrender : function(btn) {
- var status = Ext.getCmp('statuscode_');
- if (status && status.value != 'COMMITED') {
- btn.hide();
- }
- },
- click : function(btn) {
- this.FormUtil.onResSubmit(Ext.getCmp('id_').value);
- }
- },
- 'erpTestButton': {
- afterrender : function(btn) {
- var status = Ext.getCmp('statuscode_');
- if (status && status.value != 'AUDITED') {
- btn.hide();
- }
- },
- click: function(btn){
- Ext.Ajax.request({
- url: basePath + 'common/charts/testSubsFormula.action',
- params: {
- id: Ext.getCmp('id_').value,
- caller:caller
- },
- method: 'post',
- callback: function(options, success, response){
- var res = new Ext.decode(response.responseText);
- if(res.exceptionInfo) {
- showError(res.exceptionInfo);
- } else {
- Ext.MessageBox.confirm('提示', '测试通过,是否需要预览数据?', del);
- function del(btn) {
- if(btn == 'yes'){
- // 弹出win预览数据
- var win = new Ext.window.Window({
- title: '预 览',
- height: "100%",
- width: "80%",
- maximizable : true,
- resizable:true,
- buttonAlign : 'center',
- layout : 'anchor',
- bodyStyle: 'background:#f1f1f1;',
- items:[{
- xtype: 'form',
- id:'paramsForm',
- anchor: '100% 20%',
- autoScroll:true,
- bodyStyle: 'background:#f1f1f1;',
- layout: 'column',
- items:[ {
- margin: '5 0 0 5',
- xtype: 'textfield',
- fieldLabel: '员工ID',
- name: 'EMID',
- value: EMID,
- id: 'EMID'
- },{
- margin: '5 0 0 5',
- xtype: 'textfield',
- fieldLabel: '编号',
- name: 'EMCODE',
- value: EMCODE,
- id: 'EMCODE'
- },{
- margin: '5 0 0 5',
- xtype: 'textfield',
- fieldLabel: '姓名',
- name: 'EMNAME',
- value: EMNAME,
- id: 'EMNAME'
- },{
- margin: '5 0 0 5',
- xtype: 'textfield',
- fieldLabel: '组织',
- name: 'EMDEFAULTORNAME',
- value: EMDEFAULTORNAME,
- id: 'EMDEFAULTORNAME'
- },{
- margin: '5 0 0 5',
- xtype: 'textfield',
- fieldLabel: '部门',
- name: 'EMDEPART',
- value: EMDEPART,
- id: 'EMDEPART'
- },{
- margin: '5 0 0 5',
- xtype: 'numberfield',
- fieldLabel: '预览行数',
- minValue: 0,
- allowDecimals:false,
- name: 'RN',
- value: 10,
- id: 'RN'
- }]},{
- xtype: 'grid',
- anchor: '100% 80%',
- id : 'configGrid',
- name : 'configGrid',
- columns : [],
- emptyText : "暂无数据",
- store:[],
- items : []
- }],
- buttons:[{
- text : '预览',
- flag : 'confirm',
- height : 26,
- handler : function(b) {
- var params=Ext.getCmp('paramsForm').getValues();
- var keys = Ext.Object.getKeys(params);
- var reg = /[!@#$%^&*()'":,\/?]/;
- Ext.each(keys, function(k){
- params[k] = params[k].trim().toUpperCase().replace(reg, '');
- });
- Ext.Ajax.request({
- url: basePath + 'common/charts/getPreviewDatas.action',
- params: {
- id: Ext.getCmp('id_').value,
- caller:caller,
- params:Ext.JSON.encode(params)
- },
- method: 'post',
- callback: function(options, success, response){
- var res = new Ext.decode(response.responseText);
- if(res.exceptionInfo) {
- showError(res.exceptionInfo);
- } else {
- var datas = res.datas; //获得后台传递json
- var fieldsNames=[];
- var columModle=[];
- if (datas.length>0){
- for(var item in datas[0]){
- fieldsNames.push({"name":item});
- columModle.push({"header":item,"dataIndex":item,"flex":1,"draggable":false});
- }
- }
- var store = Ext.create('Ext.data.Store', {
- fields :fieldsNames,
- data : datas
- });
- Ext.getCmp("configGrid").reconfigure(store, columModle); //定义grid的store和column
- Ext.getCmp("configGrid").render();
- }
-
- }});
- }
- },{
- text : '关 闭',
- flag : 'cancel',
- height : 26,
- handler : function(b) {
- b.ownerCt.ownerCt.close();
- }
- }]
- });
- win.show();
-
- }else window.location.reload();
- }
- }
- }
- });
- }
- }
- });
- },
- onGridItemClick: function(selModel, record){// grid行选择
- this.GridUtil.onGridItemClick(selModel, record);
- },
- getForm: function(btn){
- return btn.ownerCt.ownerCt;
- }
- });
|