//<%@ page language="java" contentType="text/html; charset=utf-8"%>
Ext.Ajax.timeout = 15*60*1000;
Ext.QuickTips.init();
Ext.form.Field.prototype.msgTarget = "side";
Ext.BLANK_IMAGE_URL = "../ext-3.4.0/resources/images/default/s.gif";
var areaCodeStore = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url:"../tcascommon/userDeptAction_queryUserAuthorizedAreaDept.action"}),
reader: new Ext.data.JsonReader(
{root: "authorizedDeptList"},
[{name: "deptCode"}, {name: "deptName"}]
),
listeners:{
load: function(s, r, o){
if(r.length==1)
{
var ar = Ext.getCmp("areaCodeCombox");
ar.setValue((r[0]).get("deptCode"));
}
//store.loadEx({params:{start:0, limit:gridPanel.getTopToolbar().pageSize}});
}
}
});
var areaPriceTypeStore = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url:"queryPriceTypeByArea.action"}),
reader: new Ext.data.JsonReader(
{root: "root"},
[{name: "priceTypeCode"}, {name: "priceTypeName"}]
),
listeners: {
beforeLoad: function(){
if(Ext.isEmpty(Ext.getCmp("areaCodeCombox").getValue(), false))
{
Ext.Msg.alert("提示", "请选择地区代码!");
return false;
}
this.baseParams['areaCode'] = Ext.getCmp("areaCodeCombox").getValue();
},
load: function(s, r, o){
var data ={priceTypeCode: "", priceTypeName: "无方案类型"};
var emptyOption = [new Ext.data.Record(data)];
s.insert(0, emptyOption);
var selectionModel = gridPanel.getSelectionModel();
if(selectionModel.getSelections().length==1)
{
var rec = selectionModel.getSelected();
addPriceTypeWin.getForm().setValues({
"depotPrice.priceTypeCode": rec.get("priceTypeCode")
});
}
else
{
addPriceTypeWin.getForm().setValues({
"depotPrice.priceTypeCode": ""
});
}
addPriceTypeWin.show();
addPriceTypeWin.getForm().clearInvalid();
}
}
});
var toolButtons = [
{
id: "queryButton",
xtype: "button",
text: "查询",
icon: "../images/search.gif",
handler: function(){
if(Ext.isEmpty(Ext.getCmp("areaCodeCombox").getValue(), false))
{
Ext.Msg.alert("提示", "请选择地区代码!");
return false;
}
if(!(queryFormPanel.getForm().isValid()))
{
return false;
}
store.loadEx({params:{start:0, limit:gridPanel.getTopToolbar().pageSize}});
}
}
<app:isPermission code="/depotcfg/updateDepotPrice.action">
,
'-',
{
xtype: "button",
text: "网点单价配置",
icon: "../images/edit.gif",
handler: function(){
var selectionModel = gridPanel.getSelectionModel();
if( !(selectionModel.hasSelection()) )
{
Ext.Msg.alert("提示", "请选择要配置单价的记录!");
return false;
}
var selectedRecs = selectionModel.getSelections();
//var firstAreaCode = selectedRecs[0].get("areaCode");
var deptCodes = selectedRecs[0].get("deptCode");
for(var i=1; i<selectedRecs.length; i++)
{
/*
var otherAreaCode = selectedRecs[i].get("areaCode");
if(firstAreaCode !== otherAreaCode)
{
Ext.MessageBox.show({
title : "提示",
msg : "请选择地区代码相同的记录进行批量修改!",
buttons : Ext.MessageBox.OK
});
return false;
}*/
deptCodes += "_" + selectedRecs[i].get("deptCode");
}
addPriceTypeWin.getForm().setValues({
"depotPrice.deptCodes": deptCodes
});
addPriceTypeWin.setTitle("网点单价配置");
areaPriceTypeStore.loadEx();
}
}
</app:isPermission>
<app:isPermission code="/depotcfg/exportDepotPrice.action">
,
'-',
{
xtype: "button",
text: "导出",
icon: "../images/export.gif",
handler: function(){
if(Ext.isEmpty(Ext.getCmp("areaCodeCombox").getValue(), false))
{
Ext.Msg.alert("提示", "请选择地区代码!");
return false;
}
queryFormPanel.getForm().submitEx({
url : "exportDepotPrice.action",
waitTitle : '正在导出',
waitMsg : '正在导出,请稍等...',
method : "post",
success : function(form, action){
if(!(Ext.isEmpty(action.result.error, false)))
{
Ext.Msg.alert("提示", action.result.error);
return false;
}
window.location = "../tcascommon/downloadExcel_downloadReport.action?key=" + encodeURI(encodeURI(action.result.importMsgFileName)) + "&downloadFileName=" + encodeURI(encodeURI("分点部单价配置导出"));
}
});
}
}
</app:isPermission>
<app:isPermission code="/depotcfg/importDepotPrice.action">
,
'-',
{
xtype: "button",
text: "导入",
icon: "../images/copy.png",
handler: function(){
importPriceWin.show();
}
}
</app:isPermission>
];
var queryFormPanel = new Ext.form.FormPanel({
region: "center",
labelAlign: "right",
title: "",
labelWidth: 50,
height: 100,
frame: true,
items:[
{
xtype: "fieldset",
title: "查询条件",
layout: "column",
labelWidth: 90,
items:[
{
layout: "form",
columnWidth: .33,
items:[{
xtype: "combo",
id: "areaCodeCombox",
fieldLabel: "地区代码",
emptyText: "请选择",
mode: "local",
hiddenName: "areaCode",
triggerAction: "all",
valueField: "deptCode",
displayField: "deptName",
forceSelection: true,
editable: true,
resizable: true,
allowBlank: false,
width: 150,
doQuery : comboxQueryAreaCode,
minChars: 1,
store: areaCodeStore
}]
},
{
layout: "form",
columnWidth: .33,
items:[{
xtype: "textfield",
fieldLabel: "网点代码",
name: "deptCode",
maxLength: 30,
width: 150
}]
},
{
layout: "form",
columnWidth: .33,
items:[{
xtype: "combo",
width: 100,
fieldLabel: "方案类型",
emptyText: "请选择",
mode: "local",
hiddenName: "priceTypeCode",
allowBlank: true,
triggerAction: "all",
valueField: "TYPE_CODE",
displayField: "TYPE_NAME",
editable: false,
store: new Ext.data.SimpleStore({
fields: ["TYPE_CODE", "TYPE_NAME"],
data: [["", "全部"],["0", "未配置方案"],["A", "A"],["B", "B"],["C", "C"],["D", "D"],["E", "E"],["F", "F"],
["G", "G"],["H", "H"],["I", "I"],["J", "J"],["K", "K"],["L", "L"],
["M", "M"],["N", "N"],["O", "O"],["P", "P"],["Q", "Q"],["R", "R"],
["S", "S"],["T", "T"],["U", "U"],["V", "V"],["W", "W"],["X", "X"],
["Y", "Y"],["Z", "Z"]]
})
}]
}
]
}
,{xtype: "panel", layout: "fit", border:false, height:20, items:[{xtype:"label", id:"deptCountLabel", text:""}]}
]
});
var sm = new Ext.grid.CheckboxSelectionModel({singleSelect:false});
var cm = new Ext.grid.ColumnModel(
[sm,
{header:"地区代码", dataIndex:"areaCode", width:120},
{header:"网点代码", dataIndex:"deptCode", width:120},
{header:"网点名称", dataIndex:"deptName", width:160},
{header:"方案类型", dataIndex:"priceTypeCode", width:110},
{header:"<div style='text-align:left'>票数单价</div>", dataIndex:"priceBallotQty", width:140, renderer:Ext.util.Format.numberRenderer("0.0000"), align:"right"},
{header:"<div style='text-align:left'>重量单价</div>", dataIndex:"priceWeightQty", width:140, renderer:Ext.util.Format.numberRenderer("0.0000"), align:"right"},
{header:"<div style='text-align:left'>修改人工号</div>", dataIndex:"modifiedEmpCode", width:160, align:"center"},
{header:"修改时间", dataIndex:"modifiedTm", width:160}
]);
var MyJsonReader = Ext.extend(Ext.data.JsonReader, {
read: function(response){
var json = response.responseText;
var o = Ext.decode(json);
if(!o)
{
throw {message: 'JsonReader.read: Json object not found'};
}
this.responseJsonObject = o;
return this.readRecords(o);
}
});
var myReader = new MyJsonReader(
{totalProperty: "totalCount", root: "root"},
[
{name: "priceId"},
{name: "areaCode"},
{name: "deptCode"},
{name: "deptName"},
{name: "priceTypeCode"},
{name: "priceBallotQty"},
{name: "priceWeightQty"},
{name: "createdEmpCode"},
{name: "createdTm"},
{name: "modifiedEmpCode"},
{name: "modifiedTm"}
]
);
var store = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url:"queryPriceByPage.action"}),
reader: myReader,
listeners: {
beforeLoad: function(){
if(Ext.isEmpty(Ext.getCmp("areaCodeCombox").getValue(), false))
{
Ext.Msg.alert("提示", "请选择地区代码!");
return false;
}
this.baseParams = queryFormPanel.getForm().getValues();
this.baseParams['limit'] = gridPanel.getTopToolbar().pageSize;
},
load: function(){
Ext.getCmp("deptCountLabel").setText(" 网点总数:"
+ myReader.responseJsonObject.allDeptCount
+ " 已配置数:"
+ myReader.responseJsonObject.configDeptCount
+ " 未配置数:"
+ "<font style='font-weight:bold;color:red'>" + myReader.responseJsonObject.notConfigDeptCount, false) + "</font>";
}
}
});
var gridPanel = new Ext.grid.GridPanel({
region: "center",
store: store,
sm: sm,
cm: cm,
frame: true,
loadMask: true,
viewConfig: {
//forceFit: true,
getRowClass: function(record, rowIndex, rowParams, store){
if(Ext.isEmpty(record.data.priceBallotQty, false)
|| Ext.isEmpty(record.data.priceWeightQty, false))
{
return "redFontForGrid";
}
}
},
tbar: new Ext.PagingToolbar({
pageSize: 50,
store: store,
displayInfo: true
})
});
var addPriceTypeWin = null;
function createPriceTypeDialog(){
addPriceTypeWin = new Ext.Window({
width: 550,
height: 200,
modal: true,
border: false,
bodyBorder: false,
closable: false,
resizable: false,
layout: "fit",
closeAction: "hide",
title: "",
tools: [{id:'close', handler:function(){addPriceTypeWin.hide(); addPriceTypeWin.getForm().reset();}}],
getForm: function(){
return Ext.getCmp("addPriceTypeForm").getForm();
}
});
addPriceTypeWin.add({
id: "addPriceTypeForm",
xtype: 'form',
bodyBorder: false,
tbar:[
{text: "保存",
icon: "../images/save.gif",
minWidth: 40,
handler:function(){
var form = Ext.getCmp("addPriceTypeForm").getForm();
if(!(form.isValid()))
{
Ext.Msg.alert("提示", "请正确填写表单信息!");
return false;
}
form.submitEx({
url: 'updateDepotPrice.action',
clientValidation: true,
waitTitle: "提示",
waitMsg: "正在保存...",
method: "post",
success:function(form, action){
if(!(Ext.isEmpty(action.result.error, false)))
{
Ext.Msg.alert("提示", action.result.error);
return false;
}
Ext.Msg.alert("提示", "保存成功!");
store.loadEx({params:{start:0, limit:gridPanel.getTopToolbar().pageSize}});
gridPanel.getSelectionModel().clearSelections();
addPriceTypeWin.hide();
addPriceTypeWin.getForm().reset();
}
});
}},
'-'],
items:{
xtype:'panel',
height: 180,
layout:"column",
frame:true,
items:[
{
xtype:'hidden',
name:'depotPrice.deptCodes',
allowBlank:true
},
{
xtype:'panel',
labelWidth:130,
layout:"form",
columnWidth:0.9,
labelAlign:'right',
items:[
{
xtype: "combo",
width:300,
fieldLabel: "方案类型",
emptyText: "请选择",
mode: "remote",
hiddenName: "depotPrice.priceTypeCode",
allowBlank: true,
triggerAction: "all",
valueField: "priceTypeCode",
displayField: "priceTypeName",
editable: false,
store: areaPriceTypeStore
}]
}]
}
});
};
var templateFileUrl = '<div><a href="../tcascommon/downloadExcel_downloadExcel.action?key={0}&downloadFileName={1}&metadataDirectory={2}" style="font-weight:bold;">分点部单价配置导入.xls</a></div>';
var importPriceWin = null;
function createImportDialog(){
importPriceWin = new Ext.Window({
width: 650,
height: 200,
modal: true,
border: false,
bodyBorder: false,
closable: false,
resizable: false,
layout: "fit",
closeAction: "hide",
title: "导入",
tools: [{id:'close', handler:function(){importPriceWin.hide(); importPriceWin.getForm().reset();}}],
getForm: function(){
return Ext.getCmp("importPriceForm").getForm();
}
});
importPriceWin.add({
id: "importPriceForm",
xtype: 'form',
fileUpload: true,
bodyBorder: false,
tbar:[
{text: "保存",
icon: "../images/save.gif",
minWidth:40,
handler:function(){
var form = Ext.getCmp("importPriceForm").getForm();
var fileName = form.findField("importFile").getValue();
if(Ext.isEmpty(fileName, false))
{
Ext.Msg.alert("提示", "请选择要导入的Excel文件!");
return false;
}
var xlsReg = /.*\S+.*\.xlsx?$/g;
if(!(xlsReg.test(fileName)))
{
Ext.Msg.alert("提示", "请选择类型为 Excel 的文件!");
return false;
}
form.submitEx({
url: "importDepotPrice.action",
clientValidation: true,
waitTitle: "提示",
waitMsg: "正在保存...",
method: "post",
success:function(form, action){
if(!(Ext.isEmpty(action.result.error, false)))
{
Ext.Msg.alert("提示", action.result.error);
return false;
}
Ext.Msg.alert("提示", action.result.importMsg,
function(e){
if(action.result.hasError=="Y")
{
window.location = "../tcascommon/downloadExcel_downloadReport.action?key="
+ encodeURI(action.result.importMsgFileName)
+ "&downloadFileName=" + encodeURI(encodeURI("分点部单价配置导入结果"));
}
else
{
gridPanel.getSelectionModel().clearSelections();
importPriceWin.hide();
importPriceWin.getForm().reset();
//Ext.getCmp("queryButton").fireEvent("click");
store.loadEx({params:{start:0, limit:gridPanel.getTopToolbar().pageSize}});
}
});
}
});
}}],
items:{
xtype: 'panel',
height: 200,
layout: "column",
frame:true,
items:[
{
xtype: 'panel',
labelWidth: 120,
layout: "form",
columnWidth: 1,
labelAlign: 'right',
items:[
{
xtype: 'fileuploadfield',
//inputType: "file",
height: 40,
name: 'importFile',
emptyText: '请选择文件',
fieldLabel: '选择文件',
buttonText: '浏览...',
width: 300,
buttonCfg: {
width: 80
}
},
{ xtype: 'label',
html: String.format(templateFileUrl, 'DeptPriceTemplate_import', encodeURI(encodeURI("分点部单价配置导入")), "com/sf/module/depotcfg/META-INF"),
fieldLabel: '模板下载'
}]
}]
}
});
};
Ext.onReady(
function(){
new Ext.Viewport({
layout: "border",
items: [{xtype: "panel", layout: "fit", region:"north", frame:true, height:145, tbar:toolButtons, items:[queryFormPanel]},
gridPanel]
});
createPriceTypeDialog();
areaCodeStore.loadEx();
createImportDialog();
}
);
ExtJS示例
最新推荐文章于 2016-05-12 11:17:00 发布