<%@ taglib prefix="ext" uri="/ext-tags"%>
<%@ taglib prefix="app" uri="/app-tags"%>
//查询
function onSearch(){
var start=Ext.get("startDate").getValue();
var end=Ext.get("endDate").getValue();
if(start!=""&&end!=""){
if(start>end){
Ext.Msg.alert("${app:i18n('prompt')}","结束日期必须大于开始日期");
return;
}
}
var srcZonearea=Ext.get("srcZonearea").getValue();
if(srcZonearea.length>30){
Ext.Msg.alert("${app:i18n('prompt')}","不能超过30个字符");
return;
}
Ext.Msg.wait('正在查询,请稍等...');
gridView.getStore().baseParams = queryView.getForm().getValues();
pagingBar.pageSize = 20;
gridView.getStore().baseParams["limit"] = pagingBar.pageSize;
gridView.getStore().load({callback: searchCallback});
}
function searchCallback(r,options,success){
Ext.Msg.hide();
if (success == true) {
Ext.message.msg('${app:i18n('prompt')}', '${app:i18n('searchSuccess')}');
} else {
Ext.message.msg('${app:i18n('prompt')}', '${app:i18n('searchFailure')}');
}
}
function dateRenderer(value){
if(null!=value){
return Ext.util.Format.substr(value,0,10);
}
}
function timeRenderer(value){
if(null!=value){
var time=value.replace('T',' ');
return Ext.util.Format.substr(time,11,5);
}
}
function dtRenderer(value){
if(null!=value){
return value.replace('T',' ');
}
}
function TypeByNameRenderer(value){
if(value==4){
return "干支线";
}else if(value==2){
return "散航";
}else{
return "";
}
}
function loadRateRenderer(value){
if(null!=value){
return value+"%";
}
}
function showDataValue(value){
if(null!=value){
return "
"+value+"
";
}
return;
}
function TimelyRenderer(value, cellmeta, record, rowIndex, columnIndex, store){
var departDate=record.data["departTime"];
var updateDate=record.data["updateTime"];
if(null!=updateDate){
var departDateFmt=departDate.replace('T',' ');
var updateDateFmt=updateDate.replace('T',' ');
var begintime_ms = Date.parse(new Date(departDateFmt.replace(/-/g, "/")));
var endtime_ms = Date.parse(new Date(updateDateFmt.replace(/-/g, "/")));
var result = endtime_ms - begintime_ms;
var hours=Math.floor(result/(60*1000))
if(hours<=30){
return "是";
}else{
return "否";
}
}else{
return "";
}
}
//编辑前监听器
function beforeEdit(e){
var flag=true;
var row = e.row;
var column = e.column;
var record = e.record;
var columnModel = e.grid.getColumnModel();
var dataIndex = columnModel.getDataIndex(column);
var orgAuthFlg = record.data.orgAuthFlg;
var deleteFlg = record.data.deleteFlg;
var dataRe=gridStore.reader.jsonData.tempConveyanceInfos;
var conveyId=record.get("conveyId");
//判断有实际到车时间不允许录入
var actualArrivetime=record.get("actualArrivetime");
if(null!=actualArrivetime){
flag=false;
}else{
//判断昨天和今天的数据可以录入
var curDate=new Date();
var timeToday = curDate.format("Y") +"-" +curDate.format("m") + "-"+(curDate.format("d"));
var preDate = new Date(curDate.getTime() - 24*60*60*1000);
var timeYesterday = preDate.format("Y") +"-" +preDate.format("m") + "-"+(preDate.format("d"));
var departTimeStr=record.get("departTime");
var departDate=Ext.util.Format.substr(departTimeStr,0,10);
if((timeToday==departDate)||(timeYesterday==departDate)){
if(e.field=="planUnloadcode"||e.field=="transportLength"){
flag=true;
}
if(e.field=="vehiclePlateno"){
if(null==dataRe[row].vehiclePlateno){
flag=true;
}else{
if(null==record.get("vehiclePlatenoSys")){
flag=true;
}else{
flag=false;
}
}
}else if(e.field=="loadCapacity"){
if(null==dataRe[row].loadCapacity){
flag=true;
}else{
if(null==record.get("loadCapacitySys")){
flag=true;
}else{
flag=false;
}
}
}else if(e.field=="loadRate"){
if(null==dataRe[row].loadRate){
flag=true;
}else{
if(null==record.get("loadRateSys")){
flag=true;
}else{
flag=false;
}
}
}else if(e.field=="manageArea"){
if(null==dataRe[row].manageArea){
flag=true;
}else{
if(null==record.get("manageAreaSys")){
flag=true;
}else{
flag=false;
}
}
}
}else{
flag=false;
}
}
return flag;
}
//编辑后监听器
function afterEdit(e){
if(e.field == "planUnloadcode") {
var deptCode=e.value;
if(deptCode!=""){
Ext.Ajax.request({
url: 'findDepartmentByCode.action',
params: { deptCode: deptCode},
async: false,
success: function (response) {
var result = Ext.util.JSON.decode(response.responseText);
if(result.msg == 'fail'){
Ext.MessageBox.alert('${app:i18n('prompt')}', '您输入的网点不存在!');
//gridView.startEditing(e.row, e.column);
}
},
failure:function () {
Ext.Msg.alert("${app:i18n('prompt')}","获取失败");
}
});
}
}else if(e.field=="transportLength"){
var timeLength=e.value;
if(timeLength!=""){
var value=timeLength.split(":");
if(value.length<2){
Ext.MessageBox.alert('${app:i18n('prompt')}', '您输入的时长格式不对!');
}else{
if(/^[0-9]{1,}$/.test(value[0])== false){
Ext.MessageBox.alert('${app:i18n('prompt')}', '您输入的时长格式不对!');
}
if(/^[0-9]{1,}$/.test(value[1])== false){
Ext.MessageBox.alert('${app:i18n('prompt')}', '您输入的时长格式不对!');
}
if(!(value[1]>=0&&value[1]<=59)){
Ext.MessageBox.alert('${app:i18n('prompt')}', '您输入的时长格式不对!');
}
}
}
}
}
//保存
function onUpdate(){
gridView.startEditing(1,1);
if (gridView.getSelectionModel().getSelections().length < 1) {
Ext.MessageBox.alert("${app:i18n('prompt')}","请选择需要提交的数据!");
return;
}
var record=selectionModel.getSelections();
var modified = gridStore.modified;
var rowCount=record.length;
var json = [];
//Ext.each(modified, function(item){
// json.push(item.data);
//});
for(var i=0;i
var r=checkValidate(record[i]);
if(!r){
return;
}
}
if(json.length <=0){
Ext.Msg.alert('${app:i18n('prompt')}', "没有任何需要更新的数据!");
}else{
Ext.Msg.confirm("${app:i18n('prompt')}", "确定要保存吗?", function(button) {
if (button == "yes") {
Ext.Ajax.request({
url: "updateTempConveyanceInfo.action",
params: { data: Ext.util.JSON.encode(json) },
method: "POST",
success: function(response) {
var result = Ext.util.JSON.decode(response.responseText);
if(result.msg == 'success'){
Ext.Msg.alert('${app:i18n('prompt')}', "数据更新成功!", function() {
onSearch();
});
}else{
Ext.Msg.alert('${app:i18n('prompt')}', "数据更新失败,请重新再试!");
}
},
failure: function(response) {
Ext.Msg.alert('${app:i18n('prompt')}', "数据更新失败,请重新再试!");
}
});
}
});
}
}
//验证是否输入的数据是有效的
var checkValidate=function(record){
var result=true;
var loadCapacity=record.get("loadCapacity");
if(null!=loadCapacity&&loadCapacity!=""){
if(/^\d*(?:\.\d{0,3})?$/.test(loadCapacity)== false){
Ext.MessageBox.alert('${app:i18n('prompt')}',"您只能输入不超过3位小数的数字的载位,不能提交!");
result = false;
return result;
}
}
var loadRate=record.get("loadRate");
if(null!=loadRate&&loadRate!=""){
if(!(loadRate>0&&loadRate<=100)){
Ext.MessageBox.alert('${app:i18n('prompt')}',"您只能输入不大于100的装载率,不能提交!");
result = false;
return result;
}
}
var manageArea=record.get("manageArea");
if(null!=manageArea&&manageArea!=""){
Ext.Ajax.request({
url: 'findDepartmentByCode.action',
params: { deptCode:manageArea},
async: false,
success: function (response) {
var result = Ext.util.JSON.decode(response.responseText);
if(result.msg == 'fail'){
Ext.MessageBox.alert('${app:i18n('prompt')}', '您输入的车辆管理区不存在,不能提交!');
result = false;
return result;
}
},
failure:function () {
Ext.Msg.alert("${app:i18n('prompt')}","获取失败");
}
});
}
var planUnloadcode=record.get("planUnloadcode");
if(null!=planUnloadcode&&planUnloadcode!=""){
Ext.Ajax.request({
url: 'findDepartmentByCode.action',
params: { deptCode:planUnloadcode},
async: false,
success: function (response) {
var result = Ext.util.JSON.decode(response.responseText);
if(result.msg == 'fail'){
Ext.MessageBox.alert('${app:i18n('prompt')}', '您输入的计划卸车网点不存在,不能提交!');
result = false;
return result;
}
},
failure:function () {
Ext.Msg.alert("${app:i18n('prompt')}","获取失败");
}
});
}
var transportLength=record.get("transportLength");
if(null!=transportLength&&transportLength!=""){
var transport=transportLength.split(":");
if(transport.length<2){
Ext.MessageBox.alert('${app:i18n('prompt')}', '您输入的时长格式不对,不能提交!');
result = false;
return result;
}else{
if(/^[0-9]{1,}$/.test(transport[0])== false){
Ext.MessageBox.alert('${app:i18n('prompt')}', '您输入的时长格式不对,不能提交!');
result = false;
return result;
}
if(/^[0-9]{1,}$/.test(transport[1])== false){
Ext.MessageBox.alert('${app:i18n('prompt')}', '您输入的时长格式不对,不能提交!');
result = false;
return result;
}
if(!(transport[1]>=0&&transport[1]<=59)){
Ext.MessageBox.alert('${app:i18n('prompt')}', '您输入的时长格式不对,不能提交!');
result = false;
return result;
}
}
}
return result;
}
//导出
function onExport(){
Ext.MessageBox.wait("正在导出...");
var allParam = queryView.getForm().getValues();
Ext.Ajax.request({
params:allParam,
url: "createConveyanceInfoFile.action",
timeout: 10*60*1000,
method:'post',
success: successFn,
failure: failureFn,
callback: exportCallback,
urlExport: "ConveyanceInfoExport.action"
});
}
function successFn(response,options ){
dataSource = Ext.util.JSON.decode(response.responseText);
fileName=dataSource.fileName;
window.location = encodeURI(encodeURI(options.urlExport + "?fileName=" + fileName));
}
function failureFn(response){
Ext.message.msg('提示','导出失败!' );
}
function exportCallback(){
Ext.MessageBox.hide();
}
var globleVar = {};
function storeLoad(store,records,options){
for(var i=0;i
var conveyId = data['conveyId'];
if(globleVar[conveyId] == null){
var vehiclePlateno = data['vehiclePlateno'];
var loadCapacity = data['loadCapacity'];
var loadRate = data['loadRate'];
var manageArea = data['manageArea'];
var obj = {};
obj['vehiclePlateno'] = vehiclePlateno;
obj['loadCapacity'] = loadCapacity;
obj['loadRate'] = loadRate;
obj['manageArea'] = manageArea;
globleVar[conveyId] = obj;
}
}
}
listWidth="100">