123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219 |
- /**
- * ERP项目gridpanel通用样式1
- */
- Ext.define('erp.view.scm.product.MSDProduct.MsdInfoGrid',{
- extend: 'Ext.grid.Panel',
- alias: 'widget.msdInfoGridGrid',
- region: 'south',
- layout : 'fit',
- id: 'grid',
- emptyText : $I18N.common.grid.emptyText,
- columnLines : true,
- autoScroll : true,
- store: [],
- columns: [],
- tbar:[{
- xtype:'erpSaveButton'
- },{
- xtype:'erpDeleteButton'
- },{
- text: '操作日志',
- extend: 'Ext.Button',
- alias: 'widget.erpSaveButton',
- param: [],
- iconCls: 'x-button-icon-query',
- cls:'x-btn-gray',
- style: {
- marginLeft: '10px'
- },
- listeners:{
- click: function(btn){
- var grid = Ext.getCmp('grid');
- grid.getLogs();
- }
- }
- },'->',{
- xtype:'erpCloseButton'
- }],
- GridUtil: Ext.create('erp.util.GridUtil'),
- BaseUtil: Ext.create('erp.util.BaseUtil'),
- FormUtil: Ext.create('erp.util.FormUtil'),
- plugins: Ext.create('Ext.grid.plugin.CellEditing', {
- clicksToEdit: 1
- }),
- initComponent : function(){
- var gridCondition = this.BaseUtil.getUrlParam('gridCondition');
- gridCondition = (gridCondition == null || gridCondition == "null") ? "1=1" : gridCondition;
- var gridParam = {caller: caller, condition: gridCondition};
- this.GridUtil.getGridColumnsAndStore(this, 'common/singleGridPanel.action', gridParam, "");
- this.callParent(arguments);
- //给页面加上ctrl+alt+s键盘事件,自动跳转form配置界面
- this.addKeyBoardEvents();//监听Ctrl+Alt+S事件
- },
- getGridStore: function(){
- var grid = this;
- var jsonGridData = new Array();
- var s = grid.getStore().data.items;//获取store里面的数据
- for(var i=0;i<s.length;i++){//将grid里面各行的数据获取并拼成jsonGridData
- var data = s[i].data;
- if(s[i].dirty){
- var bool = true;
- Ext.each(grid.necessaryField, function(f){
- if(data[f] == null){
- bool = false;
- showError("有必填项未填写!代号:" + f);return;
- }
- });
- if(bool){
- Ext.each(grid.columns, function(c){
- if(c.xtype == 'numbercolumn'){//赋个默认值0吧,不然不好保存
- if(data[c.dataIndex] == null || data[c.dataIndex] == ''){
- data[c.dataIndex] = '0';//也可以从data里面去掉这些字段
- }
- }
- });
- jsonGridData.push(Ext.JSON.encode(data));
- }
- }
- }
- return jsonGridData;
- }, /**
- * 监听一些事件,
- * 如Ctrl+Alt+S
- */
- addKeyBoardEvents: function(){
- var me = this;
- if(Ext.isIE && !Ext.isIE11){
- document.body.attachEvent('onkeydown', function(){//ie的事件名称不同,也不支持addEventListener
- if(window.event.altKey && window.event.ctrlKey && window.event.keyCode == 83){
- if(Ext.ComponentQuery.query('gridpanel').length > 0){//有grid
- me.FormUtil.onAdd('form' + caller, 'Form配置维护(' + caller + ')', "jsps/ma/multiform.jsp?formCondition=fo_idIS" + me.fo_id +
- "&gridCondition=fd_foidIS" + me.fo_id + "&whoami=" + caller);
- }else if(Ext.ComponentQuery.query('formpanel').length == 0){
- me.FormUtil.onAdd('form' + caller, 'Form配置维护(' + caller + ')', "jsps/ma/multiform.jsp?formCondition=fo_idIS" + me.fo_id +
- "&gridCondition=fd_foidIS" + me.fo_id + "&whoami=" + caller);
- } else {
- me.FormUtil.onAdd('form' + caller, 'Form配置维护(' + caller + ')', "jsps/ma/form.jsp?formCondition=fo_idIS" + me.fo_id +
- "&gridCondition=fd_foidIS" + me.fo_id);
- }
- }
- });
- document.body.attachEvent("onmouseover", function(){
- if(window.event.ctrlKey){
- var e = window.event;
- me.Contextvalue = e.target.textContent == "" ? e.target.value : e.target.textContent;
- textarea_text = parent.document.getElementById("textarea_text");
- textarea_text.value = me.Contextvalue;
- textarea_text.focus();
- textarea_text.select();
- }
- });
- } else {
- document.body.addEventListener("keydown", function(e){
- if(Ext.isFF5){//firefox不支持window.event
- e = e || window.event;
- }
- if(e.altKey && e.ctrlKey && e.keyCode == 83){
- if(Ext.ComponentQuery.query('gridpanel').length > 0&&Ext.ComponentQuery.query('formpanel').length > 0){//有grid
- me.FormUtil.onAdd('form' + caller, 'Form配置维护(' + caller + ')', "jsps/ma/multiform.jsp?formCondition=fo_idIS" + me.fo_id +
- "&gridCondition=fd_foidIS" + me.fo_id + "&whoami=" + caller);
- }else if(Ext.ComponentQuery.query('formpanel').length == 0&&Ext.ComponentQuery.query('gridpanel').length > 0){//只有form
- me.FormUtil.onAdd('form' + caller, 'Form配置维护(' + caller + ')', "jsps/ma/multigrid.jsp?formCondition=fo_idIS" + me.fo_id +
- "&gridCondition=fd_foidIS" + me.fo_id + "&whoami=" + caller);
- } else {
- me.FormUtil.onAdd('form' + caller, 'Form配置维护(' + caller + ')', "jsps/ma/form.jsp?formCondition=fo_idIS" + me.fo_id +
- "&gridCondition=fd_foidIS" + me.fo_id);
- }
- }
- });
- document.body.addEventListener("mouseover", function(e){
- if(Ext.isFF5){
- e = e || window.event;
- }
- if(e.ctrlKey){
- me.Contextvalue = e.target.textContent == "" ? e.target.value : e.target.textContent;
- textarea_text = parent.document.getElementById("textarea_text");
- textarea_text.value = me.Contextvalue;
- textarea_text.focus();
- textarea_text.select();
- }
- });
- }
- },
- /**
- * 查询操作日志
- */
- getLogs: function() {
- if(Ext.getCmp('win' + caller)){
- Ext.getCmp('win' + caller).show();
- } else {
- Ext.Ajax.request({//拿到grid的columns
- url : basePath + 'common/getMessageLogs.action',
- async: false,
- params: {
- caller: caller,
- id: 0
- },
- method : 'post',
- callback : function(options,success,response){
- var res = new Ext.decode(response.responseText);
- if(res.exception || res.exceptionInfo){
- showError(res.exceptionInfo);
- return;
- }
- var logs = res.logs;
- logs = logs.length == 0 ? [{ml_date: $I18N.common.grid.emptyText, ml_man: $I18N.common.grid.emptyText,
- ml_content: $I18N.common.grid.emptyText, ml_result: $I18N.common.grid.emptyText}] : logs;
- Ext.create('Ext.window.Window', {
- id : 'win' + caller,
- title: '<span style="color:#CD6839;">操作日志</span>',
- iconCls: 'x-button-icon-set',
- closeAction: 'hide',
- height: "90%",
- width: "90%",
- maximizable : true,
- buttonAlign : 'center',
- layout : 'anchor',
- items: [{
- anchor: '100% 100%',
- xtype: 'gridpanel',
- ignore: true,
- bodyStyle: 'background:#f1f1f1;',
- autoScroll: true,
- store: Ext.create('Ext.data.Store', {
- fields: ['ml_date', 'ml_man', 'ml_content', 'ml_result'],
- data: logs
- }),
- columnLines: true,
- columns: [
- { header: '时间', dataIndex: 'ml_date', flex: 1.5 , renderer: function(val){
- if(val != '无数据'){
- return Ext.Date.format(new Date(val), 'Y-m-d H:i:s');
- }
- }},
- { header: '操作人员', dataIndex: 'ml_man', flex: 1 ,renderer: function(val){
- if(val == em_name){
- return '<font color=red>' + val + '</font>';
- } else {
- return val;
- }
- }},
- { header: '操作', dataIndex: 'ml_content', flex: 1.5},
- { header: '结果', dataIndex: 'ml_result', flex: 3}
- ]
- }],
- buttons : [{
- text : '关 闭',
- iconCls: 'x-button-icon-close',
- cls: 'x-btn-gray',
- handler : function(){
- Ext.getCmp('win' + caller).close();
- }
- }]
- }).show();
- }
- });
- }
- }
- });
|