/** * OutcryPackage.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('OutcryPackage',{ extend: 'Ext.data.Model', fields: [ {name:'UQ_SETMREAL_ZB_ID', type:'string'}, {name:'UQ_SETMREAL_ID', type:'string'}, {name:'I_ORDER_IDX', type:'int'}, {name:'UQ_CATEGORY', type:'string'}, {name:'UQ_CATEGORY1', type:'string'}, {name:'I_NUMBER_OF_BARS', type:'string'}, {name:'V_COMPANY_NAME', type:'string'}, {name:'I_CYCLE', type:'string'}, {name:'I_CYCLE1', type:'string'}, {name:'UQ_COMPANY_ID', type:'string'}, {name:'D_START_STORETIME', type:'string'}, {name:'D_END_STORETIME', type:'string'}, {name:'V_PHONE', type:'string'}, {name:'E_STATUS', type:'string'}, ] }); Ext.define('CompanyComboStore',{ extend:'Ext.data.Model', fields: [ {name:'owner_name', type:'string'}, {name:'owner_id',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 states = Ext.create('Ext.data.Store', { fields: ['status', 'name'], data : [ {"status":1, "name":"火系统报警"}, {"status":2, "name":"水系统报警"}, {"status":3, "name":"烟感报警"}, {"status":4, "name":"消防栓报警"}, {"status":5, "name":"液位报警"}, {"status":6, "name":"RTU报警"}, {"status":7, "name":"电气火灾报警"}, {"status":8, "name":"离线报警"}, ] }); var states1 = Ext.create('Ext.data.Store', { fields: ['status', 'name'], data : [ {"status":0, "name":"天"}, {"status":1, "name":"月"}, {"status":2, "name":"年"}, ] }); var clear_append_form = function (){ Ext.getCmp('fa_UQ_COMPANY_ID').setValue(""); Ext.getCmp('fa_UQ_CATEGORY').setValue(""); Ext.getCmp('fa_I_NUMBER_OF_BARS').setValue(""); Ext.getCmp('fa_I_CYCLE').setValue(""); Ext.getCmp('fa_D_START_STORETIME').setValue(""); Ext.getCmp('fa_D_END_STORETIME').setValue(""); Ext.getCmp('fa_V_PHONE').setValue(""); Ext.getCmp('OutcryPackageListPanel').getStore().reload(); } var myStore = Ext.create('Ext.data.Store', { model: 'OutcryPackage', pageSize: countPerPage, proxy: { type: 'ajax', url: baseUrl+'iot/outcrypackage/getList', reader: { type: 'json', root: 'RESULT', totalProperty: 'totalCount' } }, remoteSort: true }); var CompanyStory = Ext.create('Ext.data.Store', { model: 'CompanyComboStore', pageSize: countPerPage, proxy: { type: 'ajax', url: baseUrl+'iot/company/view/getNameList', reader: { type: 'json', root: 'RESULT', totalProperty: 'totalCount' } }, remoteSort: true }); var data =Ext.Date.format(new Date(), 'm/d/Y'); var AppendForm = Ext.create('Ext.form.Panel', { id: 'OutcryPackageAppendForm', labelWidth: 55, url: baseUrl+'iot/outcrypackage/append', defaultType: 'textfield', bodyPadding: 15, items: [{ xtype:'combo', fieldLabel:'单位名称', id: 'fa_UQ_COMPANY_ID', name:'UQ_COMPANY_ID', displayField : 'owner_name', valueField : 'owner_id', editable : false, width:330, store:CompanyStory },{ fieldLabel:'类别', id:'fa_UQ_CATEGORY', name:'UQ_CATEGORY', xtype:'combo', store:states, displayField : 'name', valueField : 'status', width:330, editable : false },{ fieldLabel:'规格', id:'fa_I_CYCLE', name:'I_CYCLE', xtype:'combo', store:states1, displayField : 'name', valueField : 'status', width:330, editable : false },{ fieldLabel:'数量', id: 'fa_I_NUMBER_OF_BARS', name: 'I_NUMBER_OF_BARS', maxLength: 300, maxLengthText:'长度不得超出{0}', anchor:'90%' },{ fieldLabel:'手机号 ', id: 'fa_V_PHONE', name: 'V_PHONE', maxLength: 11, maxLengthText:'长度不得超出{0}', anchor:'90%' },{ xtype:'datefield', fieldLabel:"开始日期", minValue:data, // '07/07/2017', minText:"当前日期选择应大于当天日期", format:"Y-m-d", columnWidth:0.5, id: 'fa_D_START_STORETIME', name:"D_END_STORETIME", editable:false,//只读约束 anchor:'80%' // fieldLabel:'开始日期', // id: 'fa_D_START_STORETIME', // name: 'D_START_STORETIME', // maxLength: 250, // maxLengthText:'长度不得超出{0}', // anchor:'95%' },{ xtype:'datefield', fieldLabel:"结束日期", minValue:data, // '07/07/2017', minText:"当前日期选择应大于当天日期", format:"Y-m-d", columnWidth:0.5, id: 'fa_D_END_STORETIME', name:"D_END_STORETIME", editable:false,//只读约束 anchor:'80%' // fieldLabel:'结束日期', // id: 'fa_D_END_STORETIME', // name:'D_END_STORETIME', // maxLength: 30, // maxLengthText:'长度不得超出{0}', // anchor:'95%' },{ 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.UQ_COMPANY_ID = Ext.getCmp('fa_UQ_COMPANY_ID').getValue(); query.UQ_CATEGORY = Ext.getCmp('fa_UQ_CATEGORY').getValue(); query.I_NUMBER_OF_BARS = Ext.getCmp('fa_I_NUMBER_OF_BARS').getValue(); query.I_CYCLE = Ext.getCmp('fa_I_CYCLE').getValue(); query.D_START_STORETIME = Ext.getCmp('fa_D_START_STORETIME').getValue(); query.D_END_STORETIME = Ext.getCmp('fa_D_END_STORETIME').getValue(); query.V_PHONE = Ext.getCmp('fa_V_PHONE').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 clear_filter_form = function(){ Ext.getCmp('ff_UQ_COMPANY_ID').setValue(""); Ext.getCmp('ff_D_START_STORETIME').setValue(""); Ext.getCmp('ff_D_END_STORETIME').setValue(""); Ext.getCmp('ff_UQ_CATEGORY').setValue(""); Ext.getCmp('ff_I_NUMBER_OF_BARS').setValue(""); Ext.getCmp('ff_I_CYCLE').setValue(""); } var FilterWin = Ext.create('Ext.form.Panel', { id: 'OutcryPackageFilterForm', labelWidth: 55, defaultType: 'textfield', bodyPadding: 15, items: [{ // xtype:'combo', // fieldLabel:'单位名称', // id: 'ff_UQ_COMPANY_ID', // name:'UQ_COMPANY_ID', // displayField : 'owner_name', // valueField : 'owner_id', // value : document.getElementById('companyId').value, // editable : false, // width:330, // store:CompanyStory fieldLabel:'单位编号', id: 'ff_UQ_COMPANY_ID', name:'UQ_COMPANY_ID', maxLength:20, maxLengthText:'长度不得超出{0}', value : document.getElementById('companyId').value, anchor:'95%' },{ // fieldLabel:'类别', // id:'ff_UQ_CATEGORY', // name:'UQ_CATEGORY', // xtype:'combo', // store:states, // displayField : 'name', // valueField : 'status', //// value : -1, // width:330, // editable : false fieldLabel:'类别', id: 'ff_UQ_CATEGORY', name:'UQ_CATEGORY', maxLength: 30, maxLengthText:'长度不得超出{0}', value : document.getElementById('uqCategory').value, anchor:'95%' },{ // fieldLabel:'规格', // id:'ff_I_CYCLE', // name:'I_CYCLE', // xtype:'combo', // store:states1, // displayField : 'name', // valueField : 'status', // width:330, // editable : false fieldLabel:'规格', id: 'ff_I_CYCLE', name:'I_CYCLE', maxLength: 30, maxLengthText:'长度不得超出{0}', value : document.getElementById('iCycle').value, anchor:'95%' },{ fieldLabel:'数量', id: 'ff_I_NUMBER_OF_BARS', name:'I_NUMBER_OF_BARS', maxLength: 30, maxLengthText:'长度不得超出{0}', value : document.getElementById('iNumberOfBars').value, anchor:'95%' },{ fieldLabel:'手机号 ', id: 'ff_V_PHONE', name: 'V_PHONE', maxLength: 11, maxLengthText:'长度不得超出{0}', value : document.getElementById('vPhone').value, anchor:'95%' },{ fieldLabel:'开始日期', id: 'ff_D_START_STORETIME', name: 'D_START_STORETIME', maxLength: 250, maxLengthText:'长度不得超出{0}', value : document.getElementById('dStartStoretime').value, anchor:'95%' },{ fieldLabel:'结束日期', id: 'ff_D_END_STORETIME', name:'D_END_STORETIME', maxLength: 30, maxLengthText:'长度不得超出{0}', value : document.getElementById('dEndStoretime').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_UQ_COMPANY_ID').getValue().length>0) query.UQ_COMPANY_ID = Ext.getCmp('ff_UQ_COMPANY_ID').getValue(); if(Ext.getCmp('ff_V_PHONE').getValue().length>0) query.V_PHONE = Ext.getCmp('ff_V_PHONE').getValue(); if(Ext.getCmp('ff_D_START_STORETIME').getValue().length>0) query.D_START_STORETIME = Ext.getCmp('ff_D_START_STORETIME').getValue(); if(Ext.getCmp('ff_D_END_STORETIME').getValue().length>0) query.D_END_STORETIME = Ext.getCmp('ff_D_END_STORETIME').getValue(); if(Ext.getCmp('ff_UQ_CATEGORY').getValue().length>0){ var a = Ext.getCmp('ff_UQ_CATEGORY').getValue(); if(a=="火系统报警") { query.UQ_CATEGORY = 1; }else if(a=="水系统报警") { query.UQ_CATEGORY = 2; }else if(a=="烟感报警") { query.UQ_CATEGORY = 3; }else if(a=="消防栓报警") { query.UQ_CATEGORY = 4; }else if(a=="液位报警") { query.UQ_CATEGORY = 5; }else if(a=="RTU报警") { query.UQ_CATEGORY = 6; }else if(a=="电气火灾报警") { query.UQ_CATEGORY = 7; }else if(a=="离线报警") { query.UQ_CATEGORY = 8; }else{ query.UQ_CATEGORY = Ext.getCmp('ff_UQ_CATEGORY').getValue(); } } if(Ext.getCmp('ff_I_NUMBER_OF_BARS').getValue().length>0) query.I_NUMBER_OF_BARS = Ext.getCmp('ff_I_NUMBER_OF_BARS').getValue(); if(Ext.getCmp('ff_I_CYCLE').getValue().length>0){ var b = Ext.getCmp('ff_I_CYCLE').getValue(); if(b=="天") { query.I_CYCLE =0; }else if(b=="月") { query.I_CYCLE =1; }else if(b=="年") { query.I_CYCLE =2; }else{ query.I_CYCLE = Ext.getCmp('ff_I_CYCLE').getValue(); } } var jsonstr = Ext.JSON.encode(query); myStore.getProxy().extraParams = { queryJson : jsonstr }; Ext.getCmp('OutcryPackageListPageToolbar').moveFirst(); Ext.getCmp('companyId').setValue(query.UQ_COMPANY_ID); Ext.getCmp('dStartStoretime').setValue(query.D_START_STORETIME); Ext.getCmp('uqCategory').setValue(query.UQ_CATEGORY); Ext.getCmp('dEndStoretime').setValue(query.D_END_STORETIME); Ext.getCmp('iNumberOfBars').setValue(query.I_NUMBER_OF_BARS); Ext.getCmp('iCycle').setValue(query.I_CYCLE); Ext.getCmp('vPhone').setValue(query.V_PHONE); // 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: 320, width: 380, layout: 'fit', items: FilterWin, closeAction: 'hide' }).show(); } var states4 = Ext.create('Ext.data.Store', { fields: ['status', 'name'], data : [ // {"status":-1, "name":"全选"}, {"status":"待开通", "name":"待开通"}, {"status":"已开通", "name":"已开通"}, {"status":"已锁定", "name":"已锁定"}, {"status":"注销", "name":"注销"}, ] }); var clear_modify_form = function (){ Ext.getCmp('fm_UQ_COMPANY_ID').setValue(""); Ext.getCmp('fm_E_STATUS').setValue(""); Ext.getCmp('fm_D_START_STORETIME').setValue(""); Ext.getCmp('fm_D_END_STORETIME').setValue(""); Ext.getCmp('fm_UQ_CATEGORY').setValue(""); Ext.getCmp('fm_I_NUMBER_OF_BARS').setValue(""); Ext.getCmp('fm_I_CYCLE').setValue(""); Ext.getCmp('fm_UQ_SETMREAL_ZB_ID').setValue(""); Ext.getCmp('fm_UQ_SETMREAL_ID').setValue(""); Ext.getCmp('fm_V_PHONE').setValue(""); Ext.getCmp('OutcryPackageListPanel').getStore().reload(); } var ModifyForm = Ext.create('Ext.form.Panel', { id: 'OutcryPackageEditForm', labelWidth: 55, url: baseUrl+'iot/outcrypackage/update', defaultType: 'textfield', bodyPadding: 15, items: [{ xtype:'combo', fieldLabel:'单位名称', id: 'fm_UQ_COMPANY_ID', name:'UQ_COMPANY_ID', displayField : 'owner_name', valueField : 'owner_name', editable : false, width:330, store:CompanyStory },{ fieldLabel:'类别', id:'fm_UQ_CATEGORY', name:'UQ_CATEGORY', xtype:'combo', store:states, displayField : 'name', valueField : 'status', // value : -1, width:330, editable : false },{ fieldLabel:'规格', id:'fm_I_CYCLE', name:'I_CYCLE', xtype:'combo', store:states1, displayField : 'name', valueField : 'status', width:330, editable : false, },{ fieldLabel:'数量', id: 'fm_I_NUMBER_OF_BARS', name: 'I_NUMBER_OF_BARS', maxLength: 250, maxLengthText:'长度不得超出{0}', anchor:'90%' },{ fieldLabel:'当前状态', id:'fm_E_STATUS', name:'E_STATUS', xtype:'combo', store:states4, displayField : 'name', valueField : 'status', value : -1, editable : false },{ fieldLabel:'手机号 ', id: 'fm_V_PHONE', name: 'V_PHONE', maxLength: 11, maxLengthText:'长度不得超出{0}', anchor:'90%' },{ fieldLabel:'开始日期', id: 'fm_D_START_STORETIME', name: 'D_START_STORETIME', maxLength: 250, maxLengthText:'长度不得超出{0}', anchor:'90%' },{ fieldLabel:'结束日期', id: 'fm_D_END_STORETIME', name: 'D_END_STORETIME', maxLength: 250, maxLengthText:'长度不得超出{0}', anchor:'90%' },{ id: 'fm_UQ_SETMREAL_ZB_ID', name:'UQ_SETMREAL_ZB_ID', hidden:true },{ id: 'fm_UQ_SETMREAL_ID', name:'UQ_SETMREAL_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(); var a = Ext.getCmp('fm_UQ_CATEGORY').getValue(); if(a=="火系统报警") { query.UQ_CATEGORY = 1; }else if(a=="水系统报警") { query.UQ_CATEGORY = 2; }else if(a=="烟感报警") { query.UQ_CATEGORY = 3; }else if(a=="消防栓报警") { query.UQ_CATEGORY = 4; }else if(a=="液位报警") { query.UQ_CATEGORY = 5; }else if(a=="RTU报警") { query.UQ_CATEGORY = 6; }else if(a=="电气火灾报警") { query.UQ_CATEGORY = 7; }else if(a=="离线报警") { query.UQ_CATEGORY = 8; }else{ query.UQ_CATEGORY = Ext.getCmp('fm_UQ_CATEGORY').getValue(); } var b = Ext.getCmp('fm_I_CYCLE').getValue(); if(b=="天") { query.I_CYCLE =0; }else if(b=="月") { query.I_CYCLE =1; }else if(b=="年") { query.I_CYCLE =2; }else{ query.I_CYCLE = Ext.getCmp('fm_I_CYCLE').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; } query.UQ_COMPANY_ID = Ext.getCmp('fm_UQ_COMPANY_ID').getValue(); query.V_PHONE = Ext.getCmp('fm_V_PHONE').getValue(); query.D_START_STORETIME = Ext.getCmp('fm_D_START_STORETIME').getValue(); query.UQ_SETMREAL_ZB_ID = Ext.getCmp('fm_UQ_SETMREAL_ZB_ID').getValue(); query.UQ_SETMREAL_ID = Ext.getCmp('fm_UQ_SETMREAL_ID').getValue(); // query.I_CYCLE = Ext.getCmp('fm_I_CYCLE').getValue(); query.I_NUMBER_OF_BARS = Ext.getCmp('fm_I_NUMBER_OF_BARS').getValue(); query.D_END_STORETIME = Ext.getCmp('fm_D_END_STORETIME').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( ); // var estatus = parseInt(selected[0].raw.E_STATUS); Ext.getCmp('fm_UQ_COMPANY_ID').setValue(selected[0].raw.V_COMPANY_NAME); Ext.getCmp('fm_V_PHONE').setValue(selected[0].raw.V_PHONE); Ext.getCmp('fm_D_START_STORETIME').setValue(selected[0].raw.D_START_STORETIME); Ext.getCmp('fm_D_END_STORETIME').setValue(selected[0].raw.D_END_STORETIME); Ext.getCmp('fm_UQ_CATEGORY').setValue(selected[0].raw.UQ_CATEGORY); Ext.getCmp('fm_I_NUMBER_OF_BARS').setValue(selected[0].raw.I_NUMBER_OF_BARS); Ext.getCmp('fm_I_CYCLE').setValue(selected[0].raw.I_CYCLE); Ext.getCmp('fm_UQ_SETMREAL_ID').setValue(selected[0].raw.UQ_SETMREAL_ID); Ext.getCmp('fm_UQ_SETMREAL_ZB_ID').setValue(selected[0].raw.UQ_SETMREAL_ZB_ID); Ext.getCmp('fm_E_STATUS').setValue(selected[0].raw.E_STATUS); }else{ Ext.Msg.alert('请先选择','请先选择一条记录,再点击修改'); } } var clear_filter_form1 = function(){ // Ext.getCmp('fc_UQ_SETMREAL_ID').setValue(""); Ext.getCmp('fc_UQ_SETMREAL_ZB_ID').setValue(""); // Ext.getCmp('fc_E_STATUS').setValue(-1); // Ext.getCmp('PermissionListPanel').getStore().reload(); } 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