/**
* patrolplan.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');
//var sm1 = Ext.create('Ext.selection.CheckboxModel');
var menuidx = '';
var mouseon;
var mouseoff;
var menu_click;
var AllSelectedRecords = [];
var sm1;
var initflag = false;
Ext.define('companyxx',{
extend: 'Ext.data.Model',
fields: [
{name:'id', type:'string'},
{name:'xh1', type:'int'},
{name:'xh', type:'string'},
{name:'AccessKeyId', type:'string'},
{name:'AccessKeySecret', type:'string'},
{name:'tjsj', type:'string'},
]
});
var body_resize = function(){
maxHeight = document.documentElement.clientHeight;
maxWidth = document.documentElement.clientWidth;
Ext.getCmp('PatrolPlanPiebar').setHeight(maxHeight);
Ext.getCmp('PatrolPlanPiebar').setWidth(maxWidth);
}
Ext.onReady(function(){
var baseUrl = document.getElementById('basePath').value;
var theme = document.getElementById('theme').value;
company_code = document.getElementById('company_code').value;
$("#V_LOGINNAME").val(sessionStorage.getItem('V_LOGINNAME'));
$("#V_PASSWORD").val(sessionStorage.getItem('V_PASSWORD'));
var V_LOGINNAME = $("#V_LOGINNAME").val();
var V_PASSWORD = $("#V_PASSWORD").val();
var chkIcon = '
'
var unchkIcon = '
'
var countPerPage = 15;
var maxHeight = 10000;
var chkBoolean = function(flag) {
if(flag)
return chkIcon;
return unchkIcon;
}
var deselect_fun = function(record){
var index = AllSelectedRecords.indexOf(record.get("id"));
if (index > -1) {
AllSelectedRecords.splice(index, 1);
return AllSelectedRecords;
}
}
sm1 = Ext.create('Ext.selection.CheckboxModel',{
mode: "MULTI",
listeners: {
deselect: function (me, record, index, opts) {
if(initflag){
// alert("初始化");
}else{
deselect_fun(record);
}
},
select: function (me, record, index, opts) {
var index = AllSelectedRecords.indexOf(record.get("id"));
if (index > -1) {
return AllSelectedRecords;
}else{
AllSelectedRecords.push(record.get("id"));
return AllSelectedRecords;
}
}
}
});
var queryJson = new Object();
// queryJson.V_LOGINNAME = V_LOGINNAME;
// queryJson.V_PASSWORD = V_PASSWORD;
queryJson.COMMSTATUS = 'NO';
if((company_code!=null)&&(company_code!='null')&&(company_code.length>0))
queryJson.company_code = company_code;
var myStore = Ext.create('Ext.data.Store', {
model: 'companyxx',
pageSize: countPerPage,
proxy: {
type: 'ajax',
url: baseUrl+'iot/pzb/getXhList',
reader: {
type: 'json',
root: 'RESULT',
totalProperty: 'totalCount'
},
extraParams:{
queryJson:Ext.JSON.encode(queryJson)
}
},
remoteSort: true
});
var clear_append_form = function (){
Ext.getCmp('fa_xh').setValue("");
Ext.getCmp('fa_AccessKeyId').setValue("");
Ext.getCmp('fa_AccessKeySecret').setValue("");
Ext.getCmp('PatrolPlanListPageToolbar').getStore().reload();
}
var AppendForm = Ext.create('Ext.form.Panel', {
id: 'xhForm1',
labelWidth: 55,
url: baseUrl+'iot/pzb/appendXh',
defaultType: 'textfield',
bodyPadding: 15,
items: [{
fieldLabel:'显号',
id: 'fa_xh',
name:'xh',
maxLength:11,
labelWidth: 120,
maxLengthText:'长度不得超出{0}',
anchor:'90%'
},{
fieldLabel:'AccessKeyId',
id: 'fa_AccessKeyId',
name:'AccessKeyId',
maxLength:50,
labelWidth: 120,
maxLengthText:'长度不得超出{0}',
anchor:'90%'
},{
fieldLabel:'AccessKeySecret',
id: 'fa_AccessKeySecret',
name:'AccessKeySecret',
maxLength:50,
labelWidth: 120,
maxLengthText:'长度不得超出{0}',
anchor:'90%'
},{
id:'fa_Inspectors_queryJson1',
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_LOGINNAME = $("#V_LOGINNAME").val();
query.xh = Ext.getCmp('fa_xh').getValue();
query.AccessKeyId = Ext.getCmp('fa_AccessKeyId').getValue();
query.AccessKeySecret = Ext.getCmp('fa_AccessKeySecret').getValue();
var jsonstr = Ext.JSON.encode(query);
Ext.getCmp('fa_Inspectors_queryJson1').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.result.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,
modal: true,
layout: 'fit',
items: AppendForm,
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.id = selected[0].raw.id;
list.push(o);
query.ID_LIST = list;
var jsonstr= Ext.JSON.encode(query);
Ext.MessageBox.confirm('注销显号信息','是否注销该显号信息?',function(btn){
if(btn=='yes'){
$.ajax({
type:'POST',
url: baseUrl+"iot/pzb/deleteXh",
data: {
queryJson : jsonstr
},
success: function(result){
var json = eval('(' + result + ')');
if(json.action=='deleteXh'){
if(json.success==true){
Ext.Msg.alert('操作成功', json.MSG , function(btn,txt){
// Ext.getCmp('PatrolPlanListPageToolbar').getStore().reload();
Ext.getCmp('PatrolPlanListPageToolbar').getStore().reload();
});
}else{
Ext.Msg.alert('操作失败', json.MSG , function(btn,txt){
Ext.getCmp('PatrolPlanListPageToolbar').getStore().reload();
});
}
}
}
});
}
},this);
}else{
if(sm.getCount()>1){
var query = new Object();
var list = new Array();
for(var i=0;i0){
query.AccessKeyId = AccessKeyId;
$("#AccessKeyId").val(AccessKeyId);
}
if(xh.length>0){
query.xh = xh;
$("#xh").val(xh);
}
// query.V_LOGINNAME = V_LOGINNAME;
// query.V_PASSWORD = V_PASSWORD;
var jsonstr = Ext.JSON.encode(query);
myStore.getProxy().extraParams = {
queryJson : jsonstr
};
Ext.getCmp('PatrolPlanListPageToolbar').moveFirst();
}
var reset1 = function(){
document.getElementById('xh_title2_input').value = '';
document.getElementById('xh_title3_input1').value = '';
$("#AccessKeyId").val('');
$("#xh").val('');
show_page();
}
mouseon = function(obj){
var id = obj.id;
$("#"+id).removeClass(id);
$("#"+id).addClass(id+'_on');
}
mouseoff = function(obj){
var mid = "companyxx_";
for(var i=1;i<6;i++){
var id = "companyxx_title"+i+"_div";
$("#"+id).removeClass(id+'_on');
$("#"+id).addClass(id);
}
if(menuidx=='m1'){
mid += 'title1_div';
$("#"+mid).removeClass(mid);
$("#"+mid).addClass(mid+'_on');
}
else if(menuidx=='m2'){
mid += 'title2_div';
$("#"+mid).removeClass(mid);
$("#"+mid).addClass(mid+'_on');
}
else if(menuidx=='m3'){
mid += 'title3_div';
$("#"+mid).removeClass(mid);
$("#"+mid).addClass(mid+'_on');
}
else if(menuidx=='m4'){
mid += 'title4_div';
$("#"+mid).removeClass(mid);
$("#"+mid).addClass(mid+'_on');
}
else if(menuidx=='m5'){
mid += 'title5_div';
$("#"+mid).removeClass(mid);
$("#"+mid).addClass(mid+'_on');
}
}
menu_click = function(obj){
var id = obj.id;
if(id=='companyxx_title1_div'){
menuidx = 'm1';
show_page();
}
else if(id=='companyxx_title2_div'){
menuidx = 'm2';
reset1();
}
else if(id=='companyxx_title3_div'){
menuidx = 'm3';
del_sm();
}
else if(id=='companyxx_title4_div'){
menuidx = 'm4';
appendwin();
}
else if(id=='companyxx_title5_div'){
menuidx = 'm5';
chk_sm();
}
}
var piedarHtml = function() {
var maintenancePlanHtml = document.getElementById('patrolPlanHtml');
var divhiddle = document.createElement('div');
divhiddle.id='pzd_div_1';
divhiddle.setAttribute('class','xhHandleHtml3DivHiddle');
maintenancePlanHtml.appendChild(divhiddle);
var title = document.createElement('div');
title.setAttribute('class','xh_Title');
title.innerHTML='显号信息';
maintenancePlanHtml.appendChild(title);
var title2 = document.createElement('div');
title2.setAttribute('class','xh_title2_div');
title2.innerHTML='AccessKeyId';
maintenancePlanHtml.appendChild(title2);
var input = document.createElement('input');
input.setAttribute('class','xh_input_class');
input.setAttribute('id','xh_title2_input');
input.setAttribute('type','text');
input.setAttribute('value','');
maintenancePlanHtml.appendChild(input);
var title3 = document.createElement('div');
title3.setAttribute('class','xh_title3_div');
title3.innerHTML='显号';
maintenancePlanHtml.appendChild(title3);
var input66 = document.createElement('input');
input66.setAttribute('class','xh_input1_class');
input66.setAttribute('id','xh_title3_input1');
input66.setAttribute('type','text');
input66.setAttribute('value','');
maintenancePlanHtml.appendChild(input66);
var title4 = document.createElement('div');
title4.setAttribute('class','companyxx_title1_div');
title4.setAttribute('id','companyxx_title1_div');
title4.setAttribute('onmouseover',"mouseon(this)");
title4.setAttribute('onmouseout',"mouseoff(this)");
title4.setAttribute('onclick',"menu_click(this)");
maintenancePlanHtml.appendChild(title4);
var title5 = document.createElement('div');
title5.setAttribute('class','companyxx_title2_div');
title5.setAttribute('id','companyxx_title2_div');
title5.setAttribute('onmouseover',"mouseon(this)");
title5.setAttribute('onmouseout',"mouseoff(this)");
title5.setAttribute('onclick',"menu_click(this)");
maintenancePlanHtml.appendChild(title5);
var title7 = document.createElement('div');
title7.setAttribute('class','companyxx_title3_div');
title7.setAttribute('id','companyxx_title3_div');
title7.setAttribute('onmouseover',"mouseon(this)");
title7.setAttribute('onmouseout',"mouseoff(this)");
title7.setAttribute('onclick',"menu_click(this)");
maintenancePlanHtml.appendChild(title7);
var title8 = document.createElement('div');
title8.setAttribute('class','companyxx_title4_div');
title8.setAttribute('id','companyxx_title4_div');
title8.setAttribute('onmouseover',"mouseon(this)");
title8.setAttribute('onmouseout',"mouseoff(this)");
title8.setAttribute('onclick',"menu_click(this)");
maintenancePlanHtml.appendChild(title8);
var title9 = document.createElement('div');
title9.setAttribute('class','companyxx_title5_div');
title9.setAttribute('id','companyxx_title5_div');
title9.setAttribute('onmouseover',"mouseon(this)");
title9.setAttribute('onmouseout',"mouseoff(this)");
title9.setAttribute('onclick',"menu_click(this)");
maintenancePlanHtml.appendChild(title9);
}
var clear_modify_form = function (){
Ext.getCmp('fm_id').setValue("");
Ext.getCmp('fm_xh').setValue("");
Ext.getCmp('fm_AccessKeyId').setValue("");
Ext.getCmp('fm_AccessKeySecret').setValue("");
Ext.getCmp('PatrolPlanListPageToolbar').getStore().reload();
}
var ModifyForm = Ext.create('Ext.form.Panel', {
id: 'InspectorsEditForm',
labelWidth: 55,
url: baseUrl+'iot/pzb/updateXh',
defaultType: 'textfield',
bodyPadding: 15,
items: [{
fieldLabel:'显号',
id: 'fm_xh',
name:'xh',
labelWidth:120,
maxLength:11,
maxLengthText:'长度不得超出{0}',
anchor:'90%'
},{
fieldLabel:'AccessKeyId',
id: 'fm_AccessKeyId',
name:'AccessKeyId',
labelWidth:120,
maxLength:50,
maxLengthText:'长度不得超出{0}',
anchor:'90%'
},{
fieldLabel:'AccessKeySecret',
id: 'fm_AccessKeySecret',
name:'AccessKeySecret',
labelWidth:120,
maxLength:50,
maxLengthText:'长度不得超出{0}',
anchor:'90%'
},{
id: 'fm_id',
name:'id',
hidden:true
},{
id:'fm_inspectors_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.id = Ext.getCmp('fm_id').getValue();
query.xh = Ext.getCmp('fm_xh').getValue();
query.AccessKeyId = Ext.getCmp('fm_AccessKeyId').getValue();
query.AccessKeySecret = Ext.getCmp('fm_AccessKeySecret').getValue();
var jsonstr = Ext.JSON.encode(query);
Ext.getCmp('fm_inspectors_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();
clear_modify_form();
}
}]
});
var modifywin = function(){
Ext.create('Ext.window.Window', {
title: '修改',
height: 350,
width: 400,
modal: true,
layout: 'fit',
items: ModifyForm,
closeAction: 'hide'
}).show();
}
var chk_sm = function() {
if(sm.getCount()==1){
modifywin();;
var selected = sm.getSelection( );
Ext.getCmp('fm_id').setValue(selected[0].raw.id);
Ext.getCmp('fm_xh').setValue(selected[0].raw.xh);
Ext.getCmp('fm_AccessKeyId').setValue(selected[0].raw.AccessKeyId);
Ext.getCmp('fm_AccessKeySecret').setValue(selected[0].raw.AccessKeySecret);
}else{
Ext.Msg.alert('请先选择','请先选择一条记录,再点击修改');
}
}
var maintenancedevice = function(){
var maintenance_look_device = document.getElementById('patrolplan_look_device');
var img = document.createElement('img');
img.width=400;
img.height=400;
img.src = baseUrl+ConfirmStore[0].picture_route;
img.setAttribute('class','maintenance_look_device_img');
maintenance_look_device.appendChild(img);
var div4 = document.createElement('div');
div4.style.textAlign='center';
div4.innerHTML=ConfirmStore[0].remarks;
maintenance_look_device.appendChild(div4);
}
var editMaintenance = function(spot_id){
var spot_id = spot_id;
Ext.create('Ext.window.Window', {
id:'patrolplan_data_win1',
height: 500,
width: 400,
layout: 'fit',
modal:true,
buttons:[
{
text:'关闭',
handler : function() {
Ext.getCmp('patrolplan_data_win1').destroy();
}
}
],
closeAction:'destroy',
html:''
}).show();
var query = new Object();
query.V_LOGINNAME = $("#V_LOGINNAME").val();
// query.V_PASSWORD = $("#V_PASSWORD").val();
query.id = spot_id;
$.ajax({
type:'POST',
url: baseUrl+"iot/inspectionpoints/getList",
data: {
queryJson : Ext.JSON.encode(query)
},
success: function(result){
var json = eval('(' + result + ')');
if(json.action=='getInspectionPointsList'){
ConfirmStore = json.RESULT;
maintenancedevice(ConfirmStore);
}
}
});
}
var MaintenancePlanPanel =Ext.create('Ext.grid.Panel', {
header :{
height:0,
border:'0px solid #000000'
},
id: 'PatrolPlanListPanel',
store: myStore,
selModel: sm,
columns: [
{ header: 'ID', dataIndex: 'id',hidden:true, menuDisabled:true },
{ header: '序号', dataIndex: 'xh1', width:77, menuDisabled:true },
{ header: '显号', dataIndex: 'xh', width:320,align:'center', menuDisabled:true },
{ header: '阿里云AccessKeyId', dataIndex: 'AccessKeyId', width:360,align:'center', menuDisabled:true },
{ header: '阿里云AccessKeySecret', dataIndex: 'AccessKeySecret', width:380,align:'center', menuDisabled:true },
{ header: '添加时间', dataIndex: 'tjsj',width:300, align:'tjsj',align:'center', menuDisabled:true },
],
columnLines: true,
height: maxHeight,
width: '100%',
bbar: new Ext.PagingToolbar({
store: myStore,
id:'PatrolPlanListPageToolbar',
displayInfo: true,
pageSize: countPerPage,
prependButtons: true,
displayMsg : '显示第 {0}条到 {1}条记录,总共 {2}条',
emptyMsg : "没有记录",
firstText: '第一页',
prevText: '前一页',
nextText: '后一页',
lastText: '最后一页',
refreshText: '刷新',
}),
// frame: true,
border:false,
iconCls: 'icon-grid'
// renderTo: Ext.getBody()
});
var piebar = Ext.create('Ext.panel.Panel',{
id:'patrolPlanHtml',
width:'100%',
height:188,
region:'north',
layout:'form',
defaults:{
border:false
}
// items: [childPanel1]
});
new Ext.create('Ext.panel.Panel',{
width:'100%',
id: 'PatrolPlanPiebar',
layout:'border',
items:[
piebar,MaintenancePlanPanel
],
renderTo: Ext.getBody()
});
// piedarHtml();
myStore.reload();
myStore.addListener('load',function(store,record,opts){
if(document.getElementById('pzd_div_1')==undefined)
piedarHtml();
});
$(window).resize(function(){
body_resize();
});
body_resize();
});