/** * .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('Unitmodel',{ extend: 'Ext.data.Model', fields: [ {name:'UQ_UNIT_MODEL_ID', type:'string'}, {name:'I_ORDER_IDX', type:'int'}, {name:'V_UNIT_MODEL', type:'string'}, {name:'UQ_PROTOCOL_ID', type:'string'}, {name:'UQ_COMPANY_ID', type:'string'}, {name:'V_COMPANY_NAME', type:'string'}, {name:'D_STORETIME', type:'string'}, {name:'E_STATUS', type:'string'}, {name:'V_COMMENT', type:'string'}, {name:'UQ_ADMIN_ID', type:'string'}, {name:'I_VERSION', type:'int'}, ] }); 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 getManufacturerId = Ext.create("Ext.data.Store", { fields: ["V_COMPANY_NAME", "UQ_COMPANY_ID_1"], autoLoad: true, proxy: { type: "ajax", actionMethods: { read: "POST" }, url: baseUrl+'iot/company/getList', reader: { type: "json", root: "RESULT" } } }); 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_UNIT_MODEL').setValue(""); Ext.getCmp('fa_UQ_PROTOCOL_ID').setValue(""); Ext.getCmp('fa_UQ_COMPANY_ID').setValue(""); Ext.getCmp('fa_UQ_ADMIN_ID').setValue(""); Ext.getCmp('fa_V_COMMENT').setValue(""); Ext.getCmp('UnitmodelListPanel').getStore().reload(); } var myStore = Ext.create('Ext.data.Store', { model: 'Unitmodel', pageSize: countPerPage, proxy: { type: 'ajax', url: baseUrl+'iot/unitmodel/getList', reader: { type: 'json', root: 'RESULT', totalProperty: 'totalCount' } }, remoteSort: true }); var AppendForm = Ext.create('Ext.form.Panel', { id: 'unitmodelAppendForm', labelWidth: 55, url: baseUrl+'iot/unitmodel/append', defaultType: 'textfield', bodyPadding: 15, items: [{ fieldLabel:'监控终端型号', id: 'fa_V_UNIT_MODEL', name:'V_UNIT_MODEL', maxLength:20, maxLengthText:'长度不得超出{0}', anchor:'75%' },{ fieldLabel:'通信协议ID', id: 'fa_UQ_PROTOCOL_ID', name: 'UQ_PROTOCOL_ID', maxLength: 250, maxLengthText:'长度不得超出{0}', anchor:'95%' },{ fieldLabel:'请选择制造商', id:'fa_UQ_COMPANY_ID', name:'UQ_COMPANY_ID', xtype:'combo', store:getManufacturerId, displayField : 'V_COMPANY_NAME', valueField : 'UQ_COMPANY_ID_1', value : document.getElementById('companyId1').value, editable : false }, // ,{ // fieldLabel:'制造商ID', // id: 'fa_UQ_COMPANY_ID', // name: 'UQ_COMPANY_ID', // 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_UNIT_MODEL = Ext.getCmp('fa_V_UNIT_MODEL').getValue(); query.UQ_PROTOCOL_ID = Ext.getCmp('fa_UQ_PROTOCOL_ID').getValue(); query.UQ_COMPANY_ID = Ext.getCmp('fa_UQ_COMPANY_ID').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: 450, 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_UNIT_MODEL').setValue(""); Ext.getCmp('ff_UQ_PROTOCOL_ID').setValue(""); Ext.getCmp('ff_UQ_COMPANY_ID').setValue(""); Ext.getCmp('ff_E_STATUS').setValue("10"); } 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: 'UnitmodelFilterForm', labelWidth: 55, defaultType: 'textfield', bodyPadding: 15, items: [{ fieldLabel:'监控终端型号', id: 'ff_V_UNIT_MODEL', name:'V_UNIT_MODEL', maxLength:20, maxLengthText:'长度不得超出{0}', value : document.getElementById('unitModel').value, anchor:'75%' },{ fieldLabel:'当前状态', id:'ff_E_STATUS', name:'E_STATUS', xtype:'combo', store:states2, displayField : 'name', valueField : 'status', value : document.getElementById('estatus').value, editable : false },{ fieldLabel:'通信协议ID', id: 'ff_UQ_PROTOCOL_ID', name: 'UQ_PROTOCOL_ID', maxLength: 250, maxLengthText:'长度不得超出{0}', value : document.getElementById('unitProtocolId').value, anchor:'95%' },{ fieldLabel:'制造商ID', id: 'ff_UQ_COMPANY_ID', name:'UQ_COMPANY_ID', maxLength: 30, maxLengthText:'长度不得超出{0}', value : document.getElementById('companyId').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_UNIT_MODEL').getValue().length>0) query.V_UNIT_MODEL = Ext.getCmp('ff_V_UNIT_MODEL').getValue(); if(Ext.getCmp('ff_UQ_PROTOCOL_ID').getValue().length>0) query.UQ_PROTOCOL_ID = Ext.getCmp('ff_UQ_PROTOCOL_ID').getValue(); query.E_STATUS = Ext.getCmp('ff_E_STATUS').getValue(); if(Ext.getCmp('ff_UQ_COMPANY_ID').getValue().length>0) query.UQ_COMPANY_ID = Ext.getCmp('ff_UQ_COMPANY_ID').getValue(); var jsonstr = Ext.JSON.encode(query); myStore.getProxy().extraParams = { queryJson : jsonstr }; Ext.getCmp('UnitmodelListPageToolbar').moveFirst(); Ext.getCmp('unitModel').setValue(query.V_UNIT_MODEL); Ext.getCmp('unitProtocolId').setValue(query.UQ_PROTOCOL_ID); Ext.getCmp('companyId').setValue(query.UQ_COMPANY_ID); Ext.getCmp('estatus').setValue(query.E_STATUS); // 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_UQ_UNIT_MODEL_ID').setValue(""); Ext.getCmp('fm_V_UNIT_MODEL').setValue(""); Ext.getCmp('fm_UQ_PROTOCOL_ID').setValue(""); Ext.getCmp('fm_UQ_COMPANY_ID').setValue(""); Ext.getCmp('fm_UQ_ADMIN_ID').setValue("0000-0000-0000"); Ext.getCmp('fm_E_STATUS').setValue(10); Ext.getCmp('fm_V_COMMENT').setValue(""); Ext.getCmp('UnitmodelListPanel').getStore().reload(); } var ModifyForm = Ext.create('Ext.form.Panel', { id: 'UnitmodelEditForm', labelWidth: 55, url: baseUrl+'iot/unitmodel/update', defaultType: 'textfield', bodyPadding: 15, items: [{ fieldLabel:'监控终端型号', id: 'fm_V_UNIT_MODEL', name:'V_UNIT_MODEL', maxLength:20, maxLengthText:'长度不得超出{0}', anchor:'75%' },{ fieldLabel:'通信协议ID', id: 'fm_UQ_PROTOCOL_ID', name: 'UQ_PROTOCOL_ID', maxLength: 250, maxLengthText:'长度不得超出{0}', anchor:'95%' }, { fieldLabel:'制造商ID', id: 'fm_UQ_COMPANY_ID', name: 'UQ_COMPANY_ID', maxLength: 250, maxLengthText:'长度不得超出{0}', anchor:'95%' },{ fieldLabel:'录入人ID', id: 'fm_UQ_ADMIN_ID', name:'UQ_ADMIN_ID', maxLength: 250, value : "0000-0000-0000", maxLengthText:'长度不得超出{0}', anchor:'95%' },{ fieldLabel:'当前状态', id:'fm_E_STATUS', name:'E_STATUS', xtype:'combo', store:states1, displayField : 'name', valueField : 'status', value : 0, editable : false },{ fieldLabel:'修改说明', id: 'fm_V_COMMENT', name:'V_COMMENT', xtype: 'textareafield', maxLength: 250, maxLengthText:'长度不得超出{0}', anchor:'100%' },{ id: 'fm_UQ_UNIT_MODEL_ID', name:'UQ_UNIT_MODEL_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_UNIT_MODEL_ID = Ext.getCmp('fm_UQ_UNIT_MODEL_ID').getValue(); query.V_UNIT_MODEL = Ext.getCmp('fm_V_UNIT_MODEL').getValue(); query.UQ_COMPANY_ID = Ext.getCmp('fm_UQ_COMPANY_ID').getValue(); query.UQ_PROTOCOL_ID = Ext.getCmp('fm_UQ_PROTOCOL_ID').getValue(); query.UQ_ADMIN_ID = Ext.getCmp('fm_UQ_ADMIN_ID').getValue(); query.V_COMMENT = Ext.getCmp('fm_V_COMMENT').getValue(); if(Ext.getCmp('fm_E_STATUS').getValue()=="待开通"){ query.E_STATUS=0; } if(Ext.getCmp('fm_E_STATUS').getValue()=="已开通"){ query.E_STATUS=1; } if(Ext.getCmp('fm_E_STATUS').getValue()=="已锁定"){ query.E_STATUS=2; } if(Ext.getCmp('fm_E_STATUS').getValue()=="注销"){ query.E_STATUS=3; } 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: 500, width: 400, layout: 'fit', items: ModifyForm, closeAction: 'hide' }).show(); } var chk_sm = function() { if(sm.getCount()==1){ modifywin(); var selected = sm.getSelection( ); // var estatus = parseInt(selected[0].raw.E_STATUS); Ext.getCmp('fm_V_UNIT_MODEL').setValue(selected[0].raw.V_UNIT_MODEL); Ext.getCmp('fm_UQ_PROTOCOL_ID').setValue(selected[0].raw.UQ_PROTOCOL_ID); Ext.getCmp('fm_UQ_COMPANY_ID').setValue(selected[0].raw.UQ_COMPANY_ID); Ext.getCmp('fm_E_STATUS').setValue(selected[0].raw.E_STATUS); Ext.getCmp('fm_UQ_UNIT_MODEL_ID').setValue(selected[0].raw.UQ_UNIT_MODEL_ID); //Ext.getCmp('fm_V_COMMENT').setValue(selected[0].raw.V_COMMENT); //Ext.getCmp('fm_UQ_ADMIN_ID').setValue(selected[0].raw.UQ_ADMIN_ID); }else{ Ext.Msg.alert('请先选择','请先选择一条记录,再点击修改'); } } var deletewin = function() { if(sm.getCount()>=1){ // var companyname = selected[0].raw.V_COMPANY_NAME; // window.alert(selected[0].raw); var query = new Object(); var list = new Array(); for (var i=0;i