/** * Point.js * 点位管理界面 * emial: yaoqiang@chinausky.com * create: 2018-12-08 */ Ext.Loader.setConfig({ enabled: true }); Ext.Loader.setPath('Ext.ux', '../../res/extjs/examples/ux'); Ext.require([ 'Ext.grid.*', 'Ext.data.*', 'Ext.ux.RowExpander', 'Ext.selection.CheckboxModel' ]); var sm = Ext.create('Ext.selection.CheckboxModel'); Ext.define('Point',{ extend: 'Ext.data.Model', fields: [ //{name:'I_POINTVER_ID', type:'int'}, {name:'UQ_POINT_ID', type:'string'}, {name:'I_ORDER_IDX', type:'int'}, {name:'V_POINT_ADDRESS', type:'string'}, {name:'I_FLOOR', type:'int'}, {name:'F_HEIGHT', type:'string'}, //{name:'V_COMMENT', type:'string'}, //{name:'UQ_ADMIN_ID', type:'string'}, {name:'I_VERSION', type:'int'}, {name:'D_STORETIME', type:'string'}, ] }); Ext.onReady(function(){ var baseUrl = document.getElementById('basePath').value; var theme = document.getElementById('theme').value; var chkIcon = '' var unchkIcon = '' var countPerPage = 20; var maxHeight = 10000; var chkBoolean = function(flag) { if(flag) return chkIcon; return unchkIcon; } var states1 = Ext.create('Ext.data.Store', { fields: ['status', 'name'], data : [ // {"status":-1, "name":"全选"}, {"status":"待开通", "name":"待开通"}, {"status":"已开通", "name":"已开通"}, {"status":"已锁定", "name":"已锁定"}, {"status":"注销", "name":"注销"}, ] }); var clear_append_form = function (){ Ext.getCmp('fa_V_POINT_ADDRESS').setValue(""); Ext.getCmp('fa_I_FLOOR').setValue(""); Ext.getCmp('fa_F_HEIGHT').setValue(""); Ext.getCmp('fa_UQ_ADMIN_ID').setValue(""); Ext.getCmp('fa_V_COMMENT').setValue(""); Ext.getCmp('PointListPanel').getStore().reload(); } var myStore = Ext.create('Ext.data.Store', { model: 'Point', pageSize: countPerPage, proxy: { type: 'ajax', url: baseUrl+'iot/point/getList', reader: { type: 'json', root: 'RESULT', totalProperty: 'totalCount' } }, remoteSort: true }); var AppendForm = Ext.create('Ext.form.Panel', { id: 'pointAppendForm', labelWidth: 55, url: baseUrl+'iot/point/append', defaultType: 'textfield', bodyPadding: 15, items: [{ fieldLabel:'点位地址', id: 'fa_V_POINT_ADDRESS', name:'V_POINT_ADDRESS', maxLength:20, maxLengthText:'长度不得超出{0}', anchor:'75%' },{ fieldLabel:'楼层', id: 'fa_I_FLOOR', name: 'I_FLOOR', maxLength: 250, maxLengthText:'长度不得超出{0}', anchor:'95%' },{ fieldLabel:'点位部署垂直高度', id: 'fa_F_HEIGHT', name: 'F_HEIGHT', maxLength: 250, maxLengthText:'长度不得超出{0}', anchor:'95%' },{ fieldLabel:'信息录入人ID', id: 'fa_UQ_ADMIN_ID', name:'UQ_ADMIN_ID', maxLength: 30, maxLengthText:'长度不得超出{0}', anchor:'95%' },{ fieldLabel:'新增说明', id: 'fa_V_COMMENT', name:'V_COMMENT', xtype: 'textareafield', maxLength: 250, maxLengthText:'长度不得超出{0}', anchor:'100%' },{ id:'fa_queryJson', name:'queryJson', hidden:true }], buttons: [{ text: '提交', iconCls:'ok_btn', handler: function() { var form = this.up('form').getForm(); if (form.isValid()) { var query = new Object(); query.V_POINT_ADDRESS = Ext.getCmp('fa_V_POINT_ADDRESS').getValue(); query.I_FLOOR = Ext.getCmp('fa_I_FLOOR').getValue(); query.F_HEIGHT = Ext.getCmp('fa_F_HEIGHT').getValue(); query.UQ_ADMIN_ID = Ext.getCmp('fa_UQ_ADMIN_ID').getValue(); query.V_COMMENT = Ext.getCmp('fa_V_COMMENT').getValue(); var jsonstr = Ext.JSON.encode(query); Ext.getCmp('fa_queryJson').setValue(jsonstr); form.submit({ method:'post', success: function(form, action) { Ext.Msg.alert('操作成功', '新增点位地址已保存', function(btn,txt){ clear_append_form(); }); }, failure: function(form, action) { Ext.Msg.alert('操作失败', action.Msg , function(btn,txt){ clear_append_form(); }); } }); } } },{ text: '关闭', iconCls: 'cancel_btn', handler: function() { this.up('window').hide(); } }] }); var appendwin = function(){ Ext.create('Ext.window.Window', { title: '新增', height: 350, width: 400, layout: 'fit', items: AppendForm, closeAction: 'hide' }).show(); } //筛选 var states2 = Ext.create('Ext.data.Store', { fields: ['status', 'name'], data : [ {"status":10, "name":"全选"}, {"status":0, "name":"待开通"}, {"status":1, "name":"已开通"}, {"status":2, "name":"已锁定"}, {"status":3, "name":"注销"}, ] }); var clear_filter_form = function(){ Ext.getCmp('ff_V_POINT_ADDRESS').setValue(""); Ext.getCmp('ff_I_FLOOR').setValue(""); Ext.getCmp('ff_F_HEIGHT').setValue(""); Ext.getCmp('ff_UQ_ADMIN_ID').setValue(""); Ext.getCmp('ff_V_COMMENT').setValue(""); } var states = Ext.create('Ext.data.Store', { fields: ['status', 'name'], data : [ {"status":-1, "name":"全选"}, {"status":0, "name":"无效"}, {"status":1, "name":"有效"} ] }); var FilterWin = Ext.create('Ext.form.Panel', { id: 'PointFilterForm', labelWidth: 55, defaultType: 'textfield', bodyPadding: 15, items: [{ fieldLabel:'点位地址', id: 'ff_V_POINT_ADDRESS', name:'V_POINT_ADDRESS', maxLength:20, maxLengthText:'长度不得超出{0}', value : document.getElementById('vPointAddress').value, anchor:'75%' },{ fieldLabel:'楼层', id:'ff_I_FLOOR', name:'I_FLOOR', maxLength: 250, maxLengthText:'长度不得超出{0}', value : document.getElementById('iFloor').value, editable : false }, // { // fieldLabel:'点位部署垂直高度', // id: 'ff_F_HEIGHT', // name: 'F_HEIGHT', // maxLength: 250, // maxLengthText:'长度不得超出{0}', // value : document.getElementById('fHelght').value, // anchor:'95%' // }, { id:'ff_queryJson', name:'queryJson', hidden:true }], buttons: [{ text: '提交', iconCls:'ok_btn', handler: function() { var form = this.up('form').getForm(); if (form.isValid()) { var query = new Object(); if(Ext.getCmp('ff_V_POINT_ADDRESS').getValue().length>0) query.V_POINT_ADDRESS = Ext.getCmp('ff_V_POINT_ADDRESS').getValue(); if(Ext.getCmp('ff_I_FLOOR').getValue().length>0) query.I_FLOOR = Ext.getCmp('ff_I_FLOOR').getValue(); // if(Ext.getCmp('ff_F_HEIGHT').getValue().length>0) // query.F_HEIGHT = Ext.getCmp('ff_F_HEIGHT').getValue(); var jsonstr = Ext.JSON.encode(query); myStore.getProxy().extraParams = { queryJson : jsonstr }; Ext.getCmp('PointListPageToolbar').moveFirst(); Ext.getCmp('vPointAddress').setValue(query.V_POINT_ADDRESS); Ext.getCmp('iFloor').setValue(query.I_FLOOR); //Ext.getCmp('fHelght').setValue(query.F_HEIGHT); // myStore.reload(); clear_filter_form(); this.up('window').hide(); } } },{ text: '关闭', iconCls: 'cancel_btn', handler: function() { this.up('window').hide(); } }] }); var filterwin = function() { Ext.create('Ext.window.Window',{ title: '筛选', height: 300, width: 350, layout: 'fit', items: FilterWin, closeAction: 'hide' }).show(); } var clear_modify_form = function (){ Ext.getCmp('fm_V_POINT_ADDRESS').setValue(""); Ext.getCmp('fm_I_FLOOR').setValue(""); Ext.getCmp('fm_F_HEIGHT').setValue(""); Ext.getCmp('fm_UQ_ADMIN_ID').setValue(""); Ext.getCmp('fm_V_COMMENT').setValue(""); Ext.getCmp('PointListPanel').getStore().reload(); } var ModifyForm = Ext.create('Ext.form.Panel', { id: 'PointEditForm', labelWidth: 55, url: baseUrl+'iot/point/update', defaultType: 'textfield', bodyPadding: 15, items: [{ fieldLabel:'点位地址', id: 'fm_V_POINT_ADDRESS', name:'V_POINT_ADDRESS', maxLength:20, maxLengthText:'长度不得超出{0}', anchor:'75%' },{ fieldLabel:'楼层', id: 'fm_I_FLOOR', name: 'I_FLOOR', maxLength: 250, maxLengthText:'长度不得超出{0}', anchor:'95%' },{ fieldLabel:'点位部署垂直高度', id: 'fm_F_HEIGHT', name: 'F_HEIGHT', maxLength: 250, maxLengthText:'长度不得超出{0}', anchor:'95%' },{ fieldLabel:'信息录入人ID', id: 'fm_UQ_ADMIN_ID', name:'UQ_ADMIN_ID', maxLength: 30, value:"0000-0000-0000", maxLengthText:'长度不得超出{0}', anchor:'95%' },{ fieldLabel:'修改说明', id: 'fm_V_COMMENT', name:'V_COMMENT', xtype: 'textareafield', maxLength: 250, maxLengthText:'长度不得超出{0}', anchor:'100%' },{ id: 'fm_UQ_POINT_ID', name:'UQ_POINT_ID', hidden:true },{ id:'fm_queryJson', name:'queryJson', hidden:true }], buttons: [{ text: '修改', iconCls:'ok_btn', handler: function() { var form = this.up('form').getForm(); if (form.isValid()) { var query = new Object(); query.UQ_POINT_ID = Ext.getCmp('fm_UQ_POINT_ID').getValue(); query.V_POINT_ADDRESS = Ext.getCmp('fm_V_POINT_ADDRESS').getValue(); query.I_FLOOR = Ext.getCmp('fm_I_FLOOR').getValue(); query.F_HEIGHT = Ext.getCmp('fm_F_HEIGHT').getValue(); query.UQ_ADMIN_ID = Ext.getCmp('fm_UQ_ADMIN_ID').getValue(); query.V_COMMENT = Ext.getCmp('fm_V_COMMENT').getValue(); var jsonstr = Ext.JSON.encode(query); Ext.getCmp('fm_queryJson').setValue(jsonstr); form.submit({ method:'post', success: function(form, action) { Ext.Msg.alert('操作成功', '已修改', function(btn,txt){ clear_modify_form(); }); }, failure: function(form, action) { Ext.Msg.alert('操作失败', action.Msg , function(btn,txt){ clear_modify_form(); }); } }); this.up('window').hide(); } } },{ text: '关闭', iconCls: 'cancel_btn', handler: function() { this.up('window').hide(); } }] }); var modifywin = function(){ Ext.create('Ext.window.Window', { title: '修改', height: 350, width: 400, layout: 'fit', items: ModifyForm, closeAction: 'hide' }).show(); } var chk_sm = function() { if(sm.getCount()==1){ modifywin(); var selected = sm.getSelection( ); Ext.getCmp('fm_UQ_POINT_ID').setValue(selected[0].raw.UQ_POINT_ID); Ext.getCmp('fm_V_POINT_ADDRESS').setValue(selected[0].raw.V_POINT_ADDRESS); Ext.getCmp('fm_I_FLOOR').setValue(selected[0].raw.I_FLOOR); Ext.getCmp('fm_F_HEIGHT').setValue(selected[0].raw.F_HEIGHT); }else{ Ext.Msg.alert('请先选择','请先选择一条记录,再点击修改'); } } // // var deletewin = function() { // window.alert("无此功能"); // // } Ext.create('Ext.grid.Panel', { title: '点位地址管理', id: 'PointListPanel', store: myStore, selModel: sm, columns: [ //{ header: 'ID', dataIndex: 'UQ_POINT_ID',hidden:true, menuDisabled:true }, { header: '序号', dataIndex: 'I_ORDER_IDX', width:40, menuDisabled:true }, { header: '点位地址', dataIndex: 'V_POINT_ADDRESS', width:120,align:'center', menuDisabled:true }, { header: '楼层', dataIndex: 'I_FLOOR', width:160,align:'center', menuDisabled:true }, { header: '点位部署垂直高度', dataIndex: 'F_HEIGHT', width:120,align:'center', menuDisabled:true }, { header: '保存时间', dataIndex: 'D_STORETIME',width:160, align:'center', menuDisabled:true }, { header: '记录版本', dataIndex: 'I_VERSION', width:120, align:'center', menuDisabled:true }, { xtype : 'actioncolumn', width:20, sortable:false, //这里 align:'center', menuDisabled:true, items:[{ icon: '../../res/img/common/forum.gif', tooltip: '版本记录', handler: function(grid, rowIndex, colIndex) { var rec = grid.getStore().getAt(rowIndex); window.location = 'version.jsp?theme='+theme+'&pointId='+rec.get('UQ_POINT_ID'); } }] } ], columnLines: true, tbar: [ { xtype: 'button', iconCls:'filter_btn', text: '筛选', listeners: { click: filterwin } },'-', {xtype: 'tbfill'},'-', { xtype: 'button', iconCls:'append_btn', text: '新增', listeners: { click: appendwin } }, { xtype: 'button', iconCls:'modify_btn', text: '修改', listeners: { click: chk_sm } }, // { // xtype: 'button', // iconCls:'delete_btn', // text: '注销', // listeners: { // click: deletewin // } // } // ,{ // xtype: 'button', // iconCls:'delete_btn', // text: '导出', // listeners: { // click: export_sj // } // } ], height: maxHeight, width: '100%', bbar: new Ext.PagingToolbar({ store: myStore, id:'PointListPageToolbar', displayInfo: true, pageSize: countPerPage, prependButtons: true, displayMsg : '显示第 {0}条到 {1}条记录,总共 {2}条', emptyMsg : "没有记录", firstText: '第一页', prevText: '前一页', nextText: '后一页', lastText: '最后一页', refreshText: '刷新', // doRefresh:function(start){ // alert(start); // relushDataFunction(start); // 调用函数刷新数据 // this.cursor = start; // 更新页签 // } }), frame: true, border:false, iconCls: 'icon-grid', renderTo: Ext.getBody() }); myStore.reload(); maxHeight = document.documentElement.clientHeight; Ext.getCmp('PointListPanel').setHeight(maxHeight); });