/** * Building.js * 建筑物界面 * emial: hanzhengyi@chinausky.com * create: 2018-12-27 */ 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('Building',{ extend: 'Ext.data.Model', fields: [ { name:'I_ORDER_IDX', type:'int' }, { name:'UQ_BUILDING_ID', type:'string' }, { name:'V_BUILDING_NAME', type:'string' }, { name:'UQ_POINT_ID', type:'string' }, { name:'UQ_COMPANY_ID', type:'string' }, { name:'V_AREA_ID', type:'string' }, { name:'V_ADDR_0', type:'string' }, { name:'V_ADDR_1', type:'string' }, { name:'V_ADDR_2', type:'string' }, { name:'I_MIN_FLOOR', type:'int' }, { name:'I_MAX_FLOOR', type:'int' }, { name:'F_FLOOR_SPACE', type:'string' }, { name:'F_TOTAL_SPACE', type:'string' }, { name:'F_BUILDING_HEIGHT', 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 clear_append_form = function (){ Ext.getCmp('fa_V_BUILDING_NAME').setValue(""); Ext.getCmp('fa_UQ_POINT_ID').setValue(""); Ext.getCmp('fa_UQ_COMPANY_ID').setValue(""); Ext.getCmp('fa_V_AREA_ID').setValue(""); Ext.getCmp('fa_V_ADDR_0').setValue(""); Ext.getCmp('fa_I_MIN_FLOOR').setValue(""); //Ext.getCmp('fa_I_MAX_FLOOR').setValue(""); Ext.getCmp('fa_I_MAX_FLOOR').setValue(""); Ext.getCmp('fa_V_COMMENT').setValue("新增建筑物"); Ext.getCmp('BuildingListPanel').getStore().reload(); } var states2 = Ext.create('Ext.data.Store', { fields: ['status', 'name'], data : [ {"status": "国家", "name":"国家"}, {"status": "省、直辖市、自治区、特别行政区", "name":"省、直辖市、自治区、特别行政区"}, {"status": "地区、市、自治州、盟", "name":"地区、市、自治州、盟"}, {"status": "县、市辖区、县级市、旗", "name":"县、市辖区、县级市、旗"}, ] }); var myStore = Ext.create('Ext.data.Store', { model: 'Building', pageSize: countPerPage, proxy: { type: 'ajax', url: baseUrl+'iot/building/getList', reader: { type: 'json', root: 'RESULT', totalProperty: 'totalCount' } }, remoteSort: true }); // var combocitystoreA = new Ext.data.Store({ // //设定读取的地址 // proxy: new Ext.data.HttpProxy({ url: baseUrl+'iot/area/getProvince' }), // //设定读取的格式 // reader: new Ext.data.JsonReader({ // root: 'RESULT', // fields :[ 'V_AREA_ID', 'V_AREA_NAME' ] // }) // }); Ext.define('Province',{ extend:'Ext.data.Model', fields: [ {name:'V_AREA_NAME', type:'string'}, {name:'V_AREA_ID',type:'string'} ] }); Ext.define('City',{ extend:'Ext.data.Model', fields: [ {name:'V_AREA_NAME', type:'string'}, {name:'V_AREA_ID',type:'string'} ] }); Ext.define('Qu',{ extend:'Ext.data.Model', fields: [ {name:'V_AREA_NAME', type:'string'}, {name:'V_AREA_ID',type:'string'} ] }); var queryJson = new Object(); var combocitystoreA = Ext.create('Ext.data.Store',{ model: 'Province', proxy: { type: 'ajax', actionMethods: { create : 'POST', read : 'POST', // by default GET update : 'POST', destroy: 'POST' }, url: baseUrl+'iot/area/getProvince', reader: { type: 'json', root: 'RESULT', totalProperty: 'totalCount' } // extraParams:{ // queryJson:Ext.JSON.encode(queryJson) // } } }); // combocitystoreA.reload(); var CityStore = Ext.create('Ext.data.Store',{ model: 'City', proxy: { type: 'ajax', actionMethods: { create : 'POST', read : 'POST', // by default GET update : 'POST', destroy: 'POST' }, url: baseUrl+'iot/area/getCity', reader: { type: 'json', root: 'RESULT', totalProperty: 'totalCount' } } }); var QuStore = Ext.create('Ext.data.Store',{ model: 'Qu', proxy: { type: 'ajax', actionMethods: { create : 'POST', read : 'POST', // by default GET update : 'POST', destroy: 'POST' }, url: baseUrl+'iot/area/getQu', reader: { type: 'json', root: 'RESULT', totalProperty: 'totalCount' } } }); Ext.define('State', { extend: 'Ext.data.Model', fields: [ {name:'V_AREA_NAME', type:'string'}, {name:'V_AREA_ID',type:'string'} ] }); //加载省数据源 var store = Ext.create('Ext.data.Store', { model: 'State', proxy: { type: 'ajax', url: baseUrl+'iot/area/getProvince' }, // autoLoad: true, remoteSort:true, reader: { type: 'json', root: 'RESULT', totalProperty: 'totalCount' } }); //加载市数据源 var store1 = Ext.create('Ext.data.Store', { model: 'State', proxy: { type: 'ajax', url: 'city.asp?act=shi&n='+new Date().getTime()+'' }, autoLoad: false, remoteSort:true }); //加载区数据源 var store2 = Ext.create('Ext.data.Store', { model: 'State', proxy: { type: 'ajax', url: 'city.asp?act=qu&n='+new Date().getTime()+'' }, autoLoad: false, remoteSort:true }); var AppendForm = Ext.create('Ext.form.Panel', { id: 'BuildingAppendForm', labelWidth: 55, url: baseUrl+'iot/building/append', defaultType: 'textfield', bodyPadding: 15, items: [{ fieldLabel:'建筑物名称', id: 'fa_V_BUILDING_NAME', name:'V_BUILDING_NAME', maxLength:20, maxLengthText:'长度不得超出{0}', anchor:'75%' },{ fieldLabel:'坐标点位ID', id: 'fa_UQ_POINT_ID', name: 'UQ_POINT_ID', maxLength: 7, maxLengthText:'长度不得超出{0}', anchor:'50%' },{ fieldLabel:'物业管理公司ID', id: 'fa_UQ_COMPANY_ID', name:'UQ_COMPANY_ID', maxLength: 12, maxLengthText:'长度不得超出{0}', anchor:'75%' }, { xtype:"combo", name:'sheng', id : 'sheng', fieldLabel:'选择省', displayField:'V_AREA_NAME', valueField:'V_AREA_ID', store:combocitystoreA, triggerAction:'all', queryMode: 'remote', selectOnFocus:true, forceSelection: true, allowBlank:false, editable: false, emptyText:'请选择省', blankText : '请选择省', listeners:{ select:function(combo, record,index){ try{ //userAdd = record.data.name; var parent=Ext.getCmp('shi'); var parent1 = Ext.getCmp("fa_V_AREA_ID"); parent.clearValue(); parent1.clearValue(); parent.store.load({params:{queryJson:this.value}}); } catch(ex){ Ext.MessageBox.alert("错误","数据加载失败。"); } } } },{ xtype:"combo", name:'shi', id : 'shi', fieldLabel:'选择市', displayField:'V_AREA_NAME', valueField:'V_AREA_ID', store:CityStore, triggerAction:'all', queryMode: 'local', selectOnFocus:true, forceSelection: true, allowBlank:false, editable: false, emptyText:'请选择市', blankText : '请选择市', listeners:{ select:function(combo, record,index){ try{ //userAdd = record.data.name; var parent = Ext.getCmp("fa_V_AREA_ID"); parent.clearValue(); parent.store.load({params:{queryJson:this.value}}); } catch(ex){ Ext.MessageBox.alert("错误","数据加载失败。"); } } } }, { xtype:"combo", name:'V_AREA_ID', id : 'fa_V_AREA_ID', fieldLabel:'选择区', displayField:'V_AREA_NAME', valueField:'V_AREA_ID', store:QuStore, triggerAction:'all', queryMode: 'local', selectOnFocus:true, forceSelection: true, allowBlank:false, editable: false, emptyText:'请选择区', blankText : '请选择区', }, { fieldLabel:'详细地址1', id: 'fa_V_ADDR_0', name:'V_ADDR_0', maxLength: 30, maxLengthText:'长度不得超出{0}', anchor:'75%' },{ fieldLabel:'最低楼层', id: 'fa_I_MIN_FLOOR', name:'I_MIN_FLOOR', maxLength: 30, maxLengthText:'长度不得超出{0}', anchor:'75%' },{ fieldLabel:'最高楼层', id: 'fa_I_MAX_FLOOR', name:'I_MAX_FLOOR', maxLength: 30, maxLengthText:'长度不得超出{0}', anchor:'75%' },{ fieldLabel:'新增建筑物说明', id: 'fa_V_COMMENT', name:'V_COMMENT', xtype: 'textareafield', maxLength: 250, maxLengthText:'长度不得超出{0}', anchor:'100%', value:'新增建筑物' },{ 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_BUILDING_NAME = Ext.getCmp('fa_V_BUILDING_NAME').getValue(); query.UQ_POINT_ID = Ext.getCmp('fa_UQ_POINT_ID').getValue(); query.UQ_COMPANY_ID = Ext.getCmp('fa_UQ_COMPANY_ID').getValue(); query.V_AREA_ID = Ext.getCmp('fa_V_AREA_ID').getValue(); query.V_ADDR_0 = Ext.getCmp('fa_V_ADDR_0').getValue(); query.I_MIN_FLOOR = Ext.getCmp('fa_I_MIN_FLOOR').getValue(); query.I_MAX_FLOOR = Ext.getCmp('fa_I_MAX_FLOOR').getValue(); // if(Ext.getCmp('fa_I_MAX_FLOOR').getValue()=='国家'){ // query.I_MAX_FLOOR=0; // } // if(Ext.getCmp('fa_I_MAX_FLOOR').getValue()=='省、直辖市、自治区、特别行政区'){ // query.I_MAX_FLOOR=1; // } // if(Ext.getCmp('fa_I_MAX_FLOOR').getValue()=='地区、市、自治州、盟'){ // query.I_MAX_FLOOR=2; // } // if(Ext.getCmp('fa_I_MAX_FLOOR').getValue()=='县、市辖区、县级市、旗'){ // query.I_MAX_FLOOR=3; // } query.V_COMMENT = Ext.getCmp('fa_V_COMMENT').getValue(); query.UQ_ADMIN_ID = '00000000-000000-000000-000000'; 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: 400, width: 400, layout: 'fit', items: AppendForm, closeAction: 'hide' }).show(); // combocitystoreA.reload(); } var clear_filter_form = function(){ Ext.getCmp('ff_V_BUILDING_NAME').setValue(""); Ext.getCmp('ff_UQ_COMPANY_ID').setValue(""); Ext.getCmp('ff_V_AREA_ID').setValue(""); Ext.getCmp('ff_V_ADDR_0').setValue(""); // Ext.getCmp('ff_I_MAX_FLOOR').setValue(0); } var FilterForm = Ext.create('Ext.form.Panel', { id: 'BuildingFilterForm', labelWidth: 55, defaultType: 'textfield', bodyPadding: 15, items: [{ fieldLabel:'建筑物名称', id: 'ff_V_BUILDING_NAME', name:'V_BUILDING_NAME', maxLength:20, maxLengthText:'长度不得超出{0}', anchor:'75%', value:document.getElementById('myAct').value },{ fieldLabel:'物业管理公司ID', id: 'ff_UQ_COMPANY_ID', name: 'UQ_COMPANY_ID', maxLength: 7, maxLengthText:'长度不得超出{0}', anchor:'75%', value:document.getElementById('loginName').value },{ fieldLabel:'行政区域ID', id: 'ff_V_AREA_ID', name: 'V_AREA_ID', maxLength: 30, maxLengthText:'长度不得超出{0}', anchor:'75%', value:document.getElementById('zipCode').value },{ fieldLabel:'详细地址', id: 'ff_V_ADDR_0', name: 'V_ADDR_0', maxLength: 30, maxLengthText:'长度不得超出{0}', anchor:'75%', value:document.getElementById('mergerName').value },{ 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_BUILDING_NAME').getValue().length>0) query.V_BUILDING_NAME = Ext.getCmp('ff_V_BUILDING_NAME').getValue(); if(Ext.getCmp('ff_UQ_COMPANY_ID').getValue().length>0) query.UQ_COMPANY_ID = Ext.getCmp('ff_UQ_COMPANY_ID').getValue(); if(Ext.getCmp('ff_V_AREA_ID').getValue().length>0) query.V_AREA_ID = Ext.getCmp('ff_V_AREA_ID').getValue(); if(Ext.getCmp('ff_V_ADDR_0').getValue().length>0) query.V_ADDR_0 = Ext.getCmp('ff_V_ADDR_0').getValue(); // if(Ext.getCmp('ff_I_MAX_FLOOR').getValue().length>0) // if(Ext.getCmp('ff_I_MAX_FLOOR').getValue()=='国家'){ // query.I_MAX_FLOOR=0; // } // if(Ext.getCmp('ff_I_MAX_FLOOR').getValue()=='省、直辖市、自治区、特别行政区'){ // query.I_MAX_FLOOR=1; // } // if(Ext.getCmp('ff_I_MAX_FLOOR').getValue()=='地区、市、自治州、盟'){ // query.I_MAX_FLOOR=2; // } // if(Ext.getCmp('ff_I_MAX_FLOOR').getValue()=='县、市辖区、县级市、旗'){ // query.I_MAX_FLOOR=3; // } var jsonstr = Ext.JSON.encode(query); myStore.getProxy().extraParams = { queryJson : jsonstr }; Ext.getCmp('BuildingListPageToolbar').moveFirst(); Ext.getCmp('myAct').setValue(query.V_BUILDING_NAME); Ext.getCmp('loginName').setValue(query.UQ_COMPANY_ID); Ext.getCmp('zipCode').setValue(query.V_AREA_ID); Ext.getCmp('mergerName').setValue(query.V_ADDR_0); // Ext.getCmp('level').setValue(query.I_MAX_FLOOR); 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',{ id: 'BuildingFilterWin', title: '建筑物筛选', height: 300, width: 400, layout: 'fit', items: FilterForm, closeAction: 'hide' }).show(); } var clear_modify_form = function (){ Ext.getCmp('fm_V_BUILDING_NAME').setValue(""); Ext.getCmp('fm_UQ_COMPANY_ID').setValue(""); Ext.getCmp('fm_V_AREA_ID').setValue(""); Ext.getCmp('fm_V_ADDR_0').setValue(""); Ext.getCmp('fm_I_MIN_FLOOR').setValue(""); Ext.getCmp('fm_I_MAX_FLOOR').setValue(0); Ext.getCmp('fm_V_COMMENT').setValue("修改建筑物"); Ext.getCmp('BuildingListPanel').getStore().reload(); } var ModifyForm = Ext.create('Ext.form.Panel', { id: 'BuildingEditForm', labelWidth: 55, url: baseUrl+'iot/building/update', defaultType: 'textfield', bodyPadding: 15, items: [{ fieldLabel:'建筑物名称', id: 'fm_V_BUILDING_NAME', name:'V_BUILDING_NAME', maxLength:20, maxLengthText:'长度不得超出{0}', anchor:'75%' },{ fieldLabel:'物业管理公司ID', id: 'fm_UQ_COMPANY_ID', name:'UQ_COMPANY_ID', maxLength: 12, maxLengthText:'长度不得超出{0}', anchor:'75%' },{ fieldLabel:'行政区域ID', id: 'fm_V_AREA_ID', name:'V_AREA_ID', maxLength: 30, maxLengthText:'长度不得超出{0}', anchor:'75%' },{ fieldLabel:'详细地址', id: 'fm_V_ADDR_0', name:'V_ADDR_0', maxLength: 30, maxLengthText:'长度不得超出{0}', anchor:'75%' },{ fieldLabel:'最低楼层', id: 'fm_I_MIN_FLOOR', name:'I_MIN_FLOOR', maxLength: 30, maxLengthText:'长度不得超出{0}', anchor:'75%' },{ fieldLabel:'最高楼层', id: 'fm_I_MAX_FLOOR', name: 'I_MAX_FLOOR', maxLength: 7, maxLengthText:'长度不得超出{0}', anchor:'50%' },{ fieldLabel:'修改建筑物说明', id: 'fm_V_COMMENT', name:'V_COMMENT', xtype: 'textareafield', maxLength: 250, maxLengthText:'长度不得超出{0}', anchor:'100%', value:'修改建筑物' },{ id: 'fm_UQ_BUILDING_ID', name:'UQ_BUILDING_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_BUILDING_ID = Ext.getCmp('fm_UQ_BUILDING_ID').getValue(); query.V_BUILDING_NAME = Ext.getCmp('fm_V_BUILDING_NAME').getValue(); query.I_MAX_FLOOR = Ext.getCmp('fm_I_MAX_FLOOR').getValue(); query.UQ_COMPANY_ID = Ext.getCmp('fm_UQ_COMPANY_ID').getValue(); query.V_AREA_ID = Ext.getCmp('fm_V_AREA_ID').getValue(); query.V_ADDR_0 = Ext.getCmp('fm_V_ADDR_0').getValue(); query.I_MIN_FLOOR = Ext.getCmp('fm_I_MIN_FLOOR').getValue(); // if(Ext.getCmp('fm_I_MAX_FLOOR').getValue()=='国家'){ // query.I_MAX_FLOOR=0; // } // if(Ext.getCmp('fm_I_MAX_FLOOR').getValue()=='省、直辖市、自治区、特别行政区'){ // query.I_MAX_FLOOR=1; // } // if(Ext.getCmp('fm_I_MAX_FLOOR').getValue()=='地区、市、自治州、盟'){ // query.I_MAX_FLOOR=2; // } // if(Ext.getCmp('fm_I_MAX_FLOOR').getValue()=='县、市辖区、县级市、旗'){ // query.I_MAX_FLOOR=3; // } query.V_COMMENT = Ext.getCmp('fm_V_COMMENT').getValue(); query.UQ_ADMIN_ID = '00000000-000000-000000-000000'; 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: 400, width: 400, layout: 'fit', items: ModifyForm, closeAction: 'hide' }).show(); } // var del_sm = function() { // if(sm.getCount()==1){ // var selected = sm.getSelection( ); // var query = new Object(); // var list = new Array(); // var o = new Object(); // o.UQ_BUILDING_ID = selected[0].raw.UQ_BUILDING_ID; // list.push(o); // query.Building_LIST = list; // var jsonstr= Ext.JSON.encode(query); // Ext.MessageBox.confirm('注销建筑物','是否注销 '+selected[0].raw.V_BUILDING_NAME+' 建筑物?',function(btn){ // if(btn=='yes'){ // // Ext.Ajax.request( { // timeout : 3000000, // url: baseUrl+'iot/building/delete', // params : 'queryJson='+ jsonstr, // success: function(resp,opts){ // myStore.reload(); // } // }); // // } // },this); // }else{ // if(sm.getCount()>1){ // var query = new Object(); // var list = new Array(); // for(var i=0;i