/**
* 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');
Ext.define('PatrolPlan',{
extend: 'Ext.data.Model',
fields: [
{name:'id', type:'string'},
{name:'personnel', type:'string'},
{name:'route', type:'string'},
{name:'planned_date', type:'string'},
{name:'start_time', type:'string'},
{name:'end_time', type:'string'},
{name:'completion_status', type:'string'},
]
});
Ext.onReady(function(){
var baseUrl = document.getElementById('basePath').value;
var theme = document.getElementById('theme').value;
company_code = document.getElementById('company_code').value;
V_LOGINNAME = $("#V_LOGINNAME").val();
V_PASSWORD = $("#V_PASSWORD").val();
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_personnel').setValue("");
Ext.getCmp('fa_route').setValue("");
// Ext.getCmp('fa_planned_date').setValue("");
Ext.getCmp('fa_start_data').setValue("");
Ext.getCmp('fa_end_data').setValue("");
Ext.getCmp('fa_start_time').setValue("");
Ext.getCmp('fa_end_time').setValue("");
Ext.getCmp('fa_completion_status').setValue("");
Ext.getCmp('PatrolPlanListPanel').getStore().reload();
}
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: 'PatrolPlan',
pageSize: countPerPage,
proxy: {
type: 'ajax',
url: baseUrl+'iot/patrolplan/getList',
reader: {
type: 'json',
root: 'RESULT',
totalProperty: 'totalCount'
},
extraParams:{
queryJson:Ext.JSON.encode(queryJson)
}
},
remoteSort: true
});
Ext.define('CompanyComboStore',{
extend:'Ext.data.Model',
fields: [
{name:'name', type:'string'},
{name:'id',type:'int'}
]
});
Ext.define('RouteComboStore',{
extend:'Ext.data.Model',
fields: [
{name:'route_name', type:'string'},
{name:'id',type:'int'}
]
});
var queryJson = new Object();
var InspectorsStory = Ext.create('Ext.data.Store',{
model: 'CompanyComboStore',
proxy: {
type: 'ajax',
actionMethods: {
create : 'POST',
read : 'POST', // by default GET
update : 'POST',
destroy: 'POST'
},
url: baseUrl+'iot/inspectors/getList',
reader: {
type: 'json',
root: 'RESULT',
totalProperty: 'totalCount'
},
extraParams:{
queryJson:Ext.JSON.encode(queryJson)
}
}
});
var RouteStory = Ext.create('Ext.data.Store',{
model: 'RouteComboStore',
proxy: {
type: 'ajax',
actionMethods: {
create : 'POST',
read : 'POST', // by default GET
update : 'POST',
destroy: 'POST'
},
url: baseUrl+'iot/route/getList',
reader: {
type: 'json',
root: 'RESULT',
totalProperty: 'totalCount'
},
extraParams:{
queryJson:Ext.JSON.encode(queryJson)
}
}
});
var data =Ext.Date.format(new Date(), 'm/d/Y');
var AppendForm = Ext.create('Ext.form.Panel', {
id: 'PatrolPlanAppendForm',
labelWidth: 55,
url: baseUrl+'iot/patrolplan/append',
defaultType: 'textfield',
bodyPadding: 15,
items: [{
xtype:'combo',
fieldLabel:'巡检人名称',
id: 'fa_personnel',
name:'xj_name',
displayField : 'name',
valueField : 'id',
editable : false,
width:283,
store:InspectorsStory
},{
// fieldLabel:'巡检路线',
// id: 'fa_route',
// name: 'route',
// maxLength: 250,
// maxLengthText:'长度不得超出{0}',
// anchor:'80%'
xtype:'combo',
fieldLabel:'巡检路线',
id: 'fa_route',
name:'route',
displayField : 'route_name',
valueField : 'id',
editable : false,
width:283,
store:RouteStory
},{
xtype:'timefield',
fieldLabel:'开始时间',
id: 'fa_start_time',
name:"start_time",
minValue:'9:00',
maxValue:'18:00',
minText:'时间要大于{0}',
maxText:'时间要小于{0}',
format:'G:i',//时间格式G(24小时进制)、i、s(时分秒,g是12小时进制)
increment:30,//跨度,默认是15分钟
invalidText:'时间格式错误',
anchor:'80%'
},{
xtype:'timefield',
fieldLabel:'结束时间',
id: 'fa_end_time',
name:"end_time",
minValue:'9:00',
maxValue:'18:00',
minText:'时间要大于{0}',
maxText:'时间要小于{0}',
format:'G:i',//时间格式G(24小时进制)、i、s(时分秒,g是12小时进制)
increment:30,//跨度,默认是15分钟
invalidText:'时间格式错误',
anchor:'80%'
},{
xtype: 'checkboxgroup',
fieldLabel: '巡检时间',
id:"Inspectiontime",
columns: 3,
items: [
{boxLabel: '周一', name: 'monday',inputValue:"星期一"},
{boxLabel: '周二', name: 'tuesday',inputValue:"星期二"},
{boxLabel: '周三', name: 'wednesday',inputValue:"星期三"},
{boxLabel: '周四', name: 'thursday',inputValue:"星期四"},
{boxLabel: '周五', name: 'friday',inputValue:"星期五"},
{boxLabel: '周六', name: 'saturday',inputValue:"星期六"},
{boxLabel: '周日', name: 'sunday',inputValue:"星期日"}
]},{
xtype:'datefield',
fieldLabel:"开始日期",
minValue:data,
// '07/07/2017',
minText:"当前日期选择应大于当天日期",
format:"Y-m-d",
columnWidth:0.5,
id: 'fa_start_data',
name:"start_data",
editable:false,//只读约束
anchor:'80%'
},{
xtype:'datefield',
fieldLabel:"结束日期",
minValue:data,
// '07/07/2017',
minText:"当前日期选择应大于当天日期",
format:"Y-m-d",
columnWidth:0.5,
id: 'fa_end_data',
name:"end_data",
editable:false,//只读约束
anchor:'80%'
},{
id: 'fa_completion_status',
name:'completion_status',
hidden:true
},{
id:'fa_queryJson',
name:'queryJson',
hidden:true
}],
buttons: [{
text: '提交',
iconCls:'ok_btn',
handler: function() {
var form = this.up('form').getForm();
if (form.isValid()) {
var InspectiontimeValue = Ext.getCmp('Inspectiontime').getChecked();
var Inspectiontime='';
Ext.Array.each(InspectiontimeValue, function(item){
Inspectiontime +=item.inputValue+'|';
});
// var start_data = Ext.util.Format.date(Ext.getCmp('fa_start_data').getValue(), 'Y-m-d');
// var end_data = Ext.util.Format.date(Ext.getCmp('fa_end_data').getValue(), 'Y-m-d');
var V_LOGINNAME = $("#V_LOGINNAME").val();
var V_PASSWORD = $("#V_PASSWORD").val();
var start_time = Ext.getCmp('fa_start_time').getValue();
var start_time1=((start_time.getHours()<10)?('0'+start_time.getHours()):start_time.getHours()) + ':' + ((start_time.getMinutes()<10)?('0'+start_time.getMinutes()):start_time.getMinutes());
var end_time = Ext.getCmp('fa_end_time').getValue();
var end_time1=((end_time.getHours()<10)?('0'+end_time.getHours()):end_time.getHours()) + ':' + ((end_time.getMinutes()<10)?('0'+end_time.getMinutes()):end_time.getMinutes());
// Ext.MessageBox.alert('提示', '您的兴趣是' + V_LOGINNAME);
var query = new Object();
query.start_data = Ext.util.Format.date(Ext.getCmp('fa_start_data').getValue(), 'Y-m-d');
query.end_data = Ext.util.Format.date(Ext.getCmp('fa_end_data').getValue(), 'Y-m-d');
query.Inspectiontime = Inspectiontime;
query.personnel = Ext.getCmp('fa_personnel').getValue();
query.route = Ext.getCmp('fa_route').getValue();
// query.planned_date = Ext.getCmp('fa_planned_date').getValue();
query.V_LOGINNAME = V_LOGINNAME;
query.V_PASSWORD = V_PASSWORD;
query.start_time = start_time1;
query.end_time = end_time1;
query.completion_status = Ext.getCmp('fa_completion_status').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 clear_filter_form = function(){
Ext.getCmp('ff_personnel').setValue("");
Ext.getCmp('ff_route').setValue("");
Ext.getCmp('ff_planned_date').setValue("");
Ext.getCmp('ff_start_time').setValue("");
Ext.getCmp('ff_end_time').setValue("");
Ext.getCmp('ff_completion_status').setValue("");
}
var FilterWin = Ext.create('Ext.form.Panel', {
id: 'PatrolPlanFilterForm',
labelWidth: 55,
defaultType: 'textfield',
bodyPadding: 15,
items: [{
fieldLabel:'巡检人',
id: 'ff_personnel',
name:'personnel',
maxLength:20,
maxLengthText:'长度不得超出{0}',
value : document.getElementById('personnel').value,
anchor:'75%'
},{
fieldLabel:'巡检路线',
id:'ff_route',
name:'route',
maxLength: 250,
maxLengthText:'长度不得超出{0}',
value : document.getElementById('route').value,
editable : false
},{
fieldLabel:'巡检日期',
id: 'ff_planned_date',
name: 'planned_date',
maxLength: 250,
maxLengthText:'长度不得超出{0}',
value : document.getElementById('planned_date').value,
anchor:'95%'
},{
fieldLabel:'开始时间',
id: 'ff_start_time',
name: 'start_time',
maxLength: 250,
maxLengthText:'长度不得超出{0}',
value : document.getElementById('start_time').value,
anchor:'95%'
},{
fieldLabel:'结束时间',
id: 'ff_end_time',
name: 'end_time',
maxLength: 250,
maxLengthText:'长度不得超出{0}',
value : document.getElementById('end_time').value,
anchor:'95%'
},{
fieldLabel:'完成情况(%)',
id: 'ff_completion_status',
name: 'completion_status',
maxLength: 250,
maxLengthText:'长度不得超出{0}',
value : document.getElementById('completion_status').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_personnel').getValue().length>0)
query.personnel = Ext.getCmp('ff_personnel').getValue();
if(Ext.getCmp('ff_route').getValue().length>0)
query.route = Ext.getCmp('ff_route').getValue();
if(Ext.getCmp('ff_planned_date').getValue().length>0)
query.planned_date = Ext.getCmp('ff_planned_date').getValue();
if(Ext.getCmp('ff_start_time').getValue().length>0)
query.start_time = Ext.getCmp('ff_start_time').getValue();
if(Ext.getCmp('ff_end_time').getValue().length>0)
query.end_time = Ext.getCmp('ff_end_time').getValue();
if(Ext.getCmp('ff_completion_status').getValue().length>0)
query.completion_status = Ext.getCmp('ff_completion_status').getValue();
var jsonstr = Ext.JSON.encode(query);
myStore.getProxy().extraParams = {
queryJson : jsonstr
};
Ext.getCmp('PatrolPlanListPageToolbar').moveFirst();
Ext.getCmp('personnel').setValue(query.personnel);
Ext.getCmp('route').setValue(query.route);
Ext.getCmp('planned_date').setValue(query.planned_date);
Ext.getCmp('start_time').setValue(query.start_time);
Ext.getCmp('end_time').setValue(query.end_time);
Ext.getCmp('completion_status').setValue(query.completion_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_id').setValue("");
Ext.getCmp('fm_route').setValue("");
Ext.getCmp('fm_planned_date').setValue("");
Ext.getCmp('fm_start_time').setValue("");
Ext.getCmp('fm_end_time').setValue("");
Ext.getCmp('fm_personnel').setValue("");
Ext.getCmp('fm_completion_status').setValue("");
Ext.getCmp('PatrolPlanListPanel').getStore().reload();
}
var ModifyForm = Ext.create('Ext.form.Panel', {
id: 'PatrolPlanEditForm',
labelWidth: 55,
url: baseUrl+'iot/patrolplan/update',
defaultType: 'textfield',
bodyPadding: 15,
items: [{
fieldLabel:'巡检人',
id: 'fm_personnel',
name:'personnel',
maxLength:20,
maxLengthText:'长度不得超出{0}',
anchor:'75%'
},{
fieldLabel:'巡检路线',
id: 'fm_route',
name: 'route',
maxLength: 250,
maxLengthText:'长度不得超出{0}',
anchor:'95%'
},{
fieldLabel:'巡检日期',
id: 'fm_planned_date',
name: 'planned_date',
maxLength: 250,
maxLengthText:'长度不得超出{0}',
anchor:'95%'
},{
fieldLabel:'开始时间',
id: 'fm_start_time',
name:'start_time',
maxLength: 30,
maxLengthText:'长度不得超出{0}',
anchor:'95%'
},{
fieldLabel:'结束时间',
id: 'fm_end_time',
name:'end_time',
maxLength: 30,
maxLengthText:'长度不得超出{0}',
anchor:'95%'
},{
id: 'fm_completion_status',
name:'completion_status',
hidden:true
},{
id: 'fm_id',
name:'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.id = Ext.getCmp('fm_id').getValue();
query.completion_status = Ext.getCmp('fm_completion_status').getValue();
query.personnel = Ext.getCmp('fm_personnel').getValue();
query.route = Ext.getCmp('fm_route').getValue();
query.planned_date = Ext.getCmp('fm_planned_date').getValue();
query.start_time = Ext.getCmp('fm_start_time').getValue();
query.end_time = Ext.getCmp('fm_end_time').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_id').setValue(selected[0].raw.id);
Ext.getCmp('fm_personnel').setValue(selected[0].raw.personnel);
Ext.getCmp('fm_route').setValue(selected[0].raw.route);
Ext.getCmp('fm_planned_date').setValue(selected[0].raw.planned_date);
Ext.getCmp('fm_start_time').setValue(selected[0].raw.start_time);
Ext.getCmp('fm_end_time').setValue(selected[0].raw.end_time);
Ext.getCmp('fm_completion_status').setValue(selected[0].raw.completion_status);
}else{
Ext.Msg.alert('请先选择','请先选择一条记录,再点击修改');
}
}
//
// var deletewin = function() {
// window.alert("无此功能");
//
// }
Ext.create('Ext.grid.Panel', {
title: '巡检计划管理',
id: 'PatrolPlanListPanel',
store: myStore,
selModel: sm,
columns: [
//{ header: 'ID', dataIndex: 'UQ_POINT_ID',hidden:true, menuDisabled:true },
{ header: 'ID', dataIndex: 'id', width:40, menuDisabled:true },
{ header: '巡检人', dataIndex: 'personnel', width:120,align:'center', menuDisabled:true },
{ header: '巡检路线', dataIndex: 'route', width:160,align:'center', menuDisabled:true },
{ header: '巡检日期', dataIndex: 'planned_date', width:120,align:'center', menuDisabled:true },
{ header: '开始时间', dataIndex: 'start_time',width:160, align:'center', menuDisabled:true },
{ header: '结束时间', dataIndex: 'end_time', width:120, align:'center', menuDisabled:true },
{ header: '完成情况(%)', dataIndex: 'completion_status', 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:'PatrolPlanListPageToolbar',
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('PatrolPlanListPanel').setHeight(maxHeight);
});