width="130" hiddenName="cfgType" triggerAction="all"
editable="false" mode="local" displayField="value" var="cfgType"
valueField="key" value="0" store="cfgTypeStore" allowBlank="false"/>
new Ext.form.DateField({allowBlank:false,width:130,name:"validDate",id:"validDate",
minValue:GetDateStr(),
format:"Y-m-d",itemId:"validDate",
fieldLabel:"${app:i18n('dateFlowCfg.validDate')}",editable:false,showToday:false})
new Ext.form.DateField({allowBlank:true,width:130,name:"expiryDate",id:"expiryDate",
minValue:GetMinDateStr(),
format:"Y-m-d",itemId:"expiryDate",
fieldLabel:"${app:i18n('dateFlowCfg.expiryDate')}",editable:false,showToday:false})
new Ext.form.DateField({allowBlank:true,width:130,name:"appStartDate",id:"appStartDate",
minValue:GetDateStr(),
format:"Y-m-d",itemId:"appStartDate",
fieldLabel:"${app:i18n('dateFlowCfg.appStartDate')}",editable:false,showToday:false})
new Ext.form.DateField({allowBlank:true,width:130,name:"appEndDate",id:"appEndDate",
minValue:GetMinDateStr(),
format:"Y-m-d",itemId:"appEndDate",
fieldLabel:"${app:i18n('dateFlowCfg.appEndDate')}",editable:false,showToday:false})
2.js
//产品类型
var produceTypeStore=new Ext.data.Store({
reader : new Ext.data.JsonReader({
idProperty : 'key',
fields : [ {
name : 'key',
type : 'String'
}, {
name : 'value',
type : 'String'
} ]
}),
data : [ {
key : 'all',
value : "${app:i18n('weightAreaCfg.all')}"
}, {
key : 'T1',
value : "${app:i18n('weightAreaCfg.produceMainLine')}"
},{
key : 'T8',
value : "${app:i18n('weightAreaCfg.produceRick')}"
},{
key : 'T4',
value : "${app:i18n('weightAreaCfg.produceNextDay')}"
},{
key : 'SP4',
value : "${app:i18n('weightAreaCfg.produceLand')}"
},{
key : 'T6',
value : "${app:i18n('weightAreaCfg.produceAlternateDay')}"
}]
});
//区域类型
var areaTypeStore = new Ext.data.Store({
reader : new Ext.data.JsonReader({
idProperty : 'key',
fields : [ {
name : 'key',
type : 'String'
}, {
name : 'value',
type : 'String'
} ]
}),
data : [ {
key : 'all',
value : "${app:i18n('weightAreaCfg.all')}"
}, {
key : 'sameCity',
value : "${app:i18n('weightAreaCfg.areaTc')}"
},{
key : 'sameProvince',
value : "${app:i18n('weightAreaCfg.areaSn')}"
},{
key : 'corssProvince',
value : "${app:i18n('weightAreaCfg.areaSw')}"
}]
});
//配置类型
var cfgTypeStore=new Ext.data.Store({
reader : new Ext.data.JsonReader({
idProperty : 'key',
fields : [ {
name : 'key',
type : 'String'
}, {
name : 'value',
type : 'String'
} ]
}),
data : [ {
key : 0,
value : "${app:i18n('dateFlowCfg.specialDate')}"
},{
key : 1,
value : "${app:i18n('dateFlowCfg.holiday')}"
} ]
});
/**
* 查询按钮事件
*/
function onSearch() {
Ext.Msg.wait('${app:i18n('waitingMessage')}');
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) {
} else {
Ext.Msg.alert('${app:i18n('prompt')}', '${app:i18n('searchFailure')}');
}
}
/**
* 新增
*/
function onAdd() {
addOrEditWindow.isEditing=false;
Ext.getCmp("edit_departBatchLevel").setReadOnly(false);
addOrEditWindow.dateflowCfg = null;
addOrEditWindow.setTitle("${app:i18n('add')}");
addOrEditWindow.show();
addOrEditForm.getForm().reset();
}
//点击修改按钮,设置表格可编辑修改
function onEdit() {
var recs=gridView.getSelectionModel().getSelections();
if (recs.length !=1) {
Ext.Msg.alert("${app:i18n('prompt')}","${app:i18n('selectOneRecord')}");
return;
}
addOrEditWindow.isEditing = true;
Ext.getCmp("edit_departBatchLevel").setReadOnly(true);
addOrEditWindow.dateflowCfg=recs[0];
addOrEditWindow.setTitle("${app:i18n('edit')}");
addOrEditWindow.show();
onRecordReset();
}
/**
* 删除事件
*/
function onDelete() {
var recs = gridView.getSelectionModel().getSelections();
if (recs == null || recs.length < 1) {
Ext.Msg.alert("${app:i18n('prompt')}", "${app:i18n('selectOneRecord')}");
return;
}
var ids = "";
for ( var i = 0; i < recs.length; ++i) {
var ue = recs[i];
if (ids.length > 0) {
ids += ',';
}
ids += ue.get('dateFlowId');
}
Ext.Msg.confirm("${app:i18n('prompt')}", "${app:i18n('confirmDeleteData')}", function(e) {
if (e == 'yes') {
var wb = Ext.Msg.wait("${app:i18n('waitingMessage')}");
Ext.Ajax.request({
url : 'deleteDateflowCfg.action',
params : {ids : ids},
callback : function(o, s, r) {
wb.hide();
if (s) {
var resp = Ext.util.JSON.decode(r.responseText);
if (resp.success) {
onSearch();
Ext.MessageBox.alert("${app:i18n('prompt')}", "${app:i18n('deleteSuccess')}");
} else {
Ext.MessageBox.alert("${app:i18n('prompt')}", resp.msg);
}
} else
Ext.MessageBox.alert("${app:i18n('prompt')}", "${app:i18n('deleteFailure')}");
}
});
}
});
}
/**
* 保存事件
*/
function onSave(){
if(!addOrEditForm.getForm().isValid()){
return;
}
// 异步校验网点有效性
var paramVal = {};
var vals = addOrEditForm.getForm().getValues();
for ( var keyTmp in vals) {
paramVal["dateflowCfg." + keyTmp] = vals[keyTmp].replace(/\s+/g,"");
}
saveOrUpdate(paramVal);
/*Ext.Ajax.request({
url: 'checkZoneAndCityCode.action',
params : paramVal,
async: false,
success: function (response) {
var result = Ext.util.JSON.decode(response.responseText);
if(result.success){
if(result.msg!='success'){
Ext.MessageBox.alert("${app:i18n('prompt')}", result.msg);
return;
}else{// 保存
saveOrUpdate(paramVal);
}
}else{
Ext.MessageBox.alert("${app:i18n('prompt')}", "${app:i18n('prompt.exception')}");
return;
}
},
failure:function (){
Ext.MessageBox.alert("${app:i18n('prompt')}", "${app:i18n('prompt.exception')}");
return;
}
});*/
}
/**
* 保存配置信息
*/
function saveOrUpdate(paramVal){
var url="addDateflowCfg.action";// 新增
if(addOrEditWindow.isEditing){
url="editDateflowCfg.action";// 修改
}
Ext.Ajax.request({
url : url,
params : paramVal,
success : function(response) {
var resp = Ext.util.JSON.decode(response.responseText);
if (resp.success) {
onSearch();
addOrEditWindow.hide();
Ext.MessageBox.alert("${app:i18n('prompt')}", "${app:i18n('saveSuccess')}");
}else{
if(resp.msg=='fail'){
Ext.MessageBox.alert("${app:i18n('prompt')}", "${app:i18n('validDateError')}");
}else{
Ext.MessageBox.alert("${app:i18n('prompt')}","${app:i18n('saveFailure')}");
}
}
},
failure:function(response){
if(Ext.util.JSON.encode(response.status) == 0) {
Ext.MessageBox.alert("${app:i18n('prompt')}", "${app:i18n('prompt.connection.exception')}");
}else{
Ext.MessageBox.alert("${app:i18n('prompt')}", "${app:i18n('prompt.exception')}");
}
}
});
}
/**
* 重置
*/
function onRecordReset(){
addOrEditForm.getForm().reset();
if (addOrEditWindow.isEditing && addOrEditWindow.dateflowCfg != null) {
addOrEditForm.getForm().loadRecord(addOrEditWindow.dateflowCfg);
}
}
//把输入框的值变成大写
function updateValue(textField) {
textField.setValue("");
}
//导入
function onImport() {
uploadForBatchView.setTitle("${app:i18n('dateFlowCfg.import')}");
uploadForBatchView.show();
setAllowedExtensions("xls");
resetUploadForBatchView();
setModelFileName("${app:i18n('dateFlowCfg.importModel')}");
}
//执行完上传后查询结果
uploadSuccessCall = doSearch;
function doSearch(){
gridStore.load({callback:function (r, options, success) {
if (!success) {
Ext.Msg.alert("${app:i18n('prompt')}", gridStore.reader.jsonData.msg);
}
}});
}
//下载模板
function getDownloadActionUrl() {
return "downloadDateflowCfgTpl.action";
}
//上传
function getUploadActionUrl() {
return "uploadDateflowCfgTpl.action";
}
//导出
function onExport(){
var timerID = null;
var wb = Ext.Msg.wait("${app:i18n('exporting')}", "${app:i18n('prompt')}");
// 3秒后关闭,以免重复点击
timerID = setTimeout(function () {
timerID = null;
wb.hide();
}, 5000);
var iframe = document.getElementById("download_DateflowCfg_frame");
var url = "exportDateflowCfgData.action?" + encodeURI(encodeURI(queryView.getForm().getValues(true)));
iframe.src = url;
}
//日期渲染器
function dateRenderer(v,m,r){
if (v == null)
return null;
var me = this;
return v.format(me.format);
}
//初始化生效日期
function GetDateStr(){
var date = new Date();
date.setUTCDate((date.getUTCDate()+1));
return date;
}
//失效日期
function GetMinDateStr(){
var date = new Date();
date.setUTCDate((date.getUTCDate()+2));
return date;
}
function dateFlowCfgStoreChanged(store){
var rec, len = store.getCount();
for ( var idx = 0; idx < len; idx++) {
rec = store.getAt(idx);
rec.data["validDate"] = Date.parseDate(rec.get("validDate"), "Y-m-dTH:i:s");
rec.data["expiryDate"] = Date.parseDate(rec.get("expiryDate"), "Y-m-dTH:i:s");
rec.data["appStartDate"] = Date.parseDate(rec.get("appStartDate"), "Y-m-dTH:i:s");
rec.data["appEndDate"] = Date.parseDate(rec.get("appEndDate"), "Y-m-dTH:i:s");
}
}
//日期渲染器
function dateRenderer(v,m,r){
if (v == null)
return null;
var me = this;
return v.format(me.format);
}
//产品
function convertproduceTypeStore(v){
if(v == null){
return "";
}
return levelRenderer(produceTypeStore,v);
}
//区域
function convertareaTypeStore(v){
if(v == null){
return "";
}
return levelRenderer(areaTypeStore,v);
}
//配置类型
function convertcfgTypeStore(v){
if(v == null){
return "";
}
return levelRenderer(cfgTypeStore,v);
}
//通过定义的数据源来取国际化的value的值
function levelRenderer(store,key) {
if (key == null || key == '') {
return '';
}
return store.getById(key)==null?"":store.getById(key).get('value');