主界面都是:
//1、变量定义
function XX_designer(){
}
//2、方法集合
XX_designer.prototype={
F1:function(){
}
F2:function(){
}
}
//3、控件 ,其实就是界面
XX_desinger.prototype.InitComponent=function(){
}
————————止--------
其实,InitComponent 这个方法,也可以写在方法集合里,方法集合里的方法均可以写在外面,
如:XX_designer.prototype.F1=function(){}
只要这个方法名调用在初始定义变量的时候调用就行
*****************************************************************
例子:
DZMCJCXXGLHANDLER = function (moduleName, moduleText, moduleIcon) {
if (moduleName == "" || moduleText == "" || moduleIcon == "") return;
var designer = new DZMCJCXXGL_Designer();
Yaxon.Common.ContexInfo.HideToolBar(true);
AddTab(moduleText, moduleName, designer.container, moduleIcon);
}
以上这段也可以换成:----这是AJAX请求后台后进行将数据进行解析成JSON格式
function WJ_ViewShopInfo(ShopId) {
Ext.QuickTips.init();
Ext.form.Field.prototype.msgTarget = 'qtip';// 'under';
Ext.Ajax.request({
url: 'DataService/WJ_ShopInfo/WJ_GetShopInfoByShopID.ashx',
method: "POST",
sync: true,
params: { ShopID: ShopId },//参数
success: function (response, options) {
var formData = Ext.util.JSON.decode(response.responseText);
var designer = new WJ_ViewShopInfo_Designer(formData);
designer.show();
}
});
}
PS:代码为大概框架,没有贴出具体的代码
下同**************************类的属性和成员变量*****
function DZMCJCXXGL_Designer() {
this.grid;
// this.currentpage = 1;
this.store;
this.treePanel;
this.container;
//this.checkType = { "全部": -1, "新增待审核": 4, "已审核": 0, "删除待审核": 2 };
this.checkType = { "全部": -1, "新增待审核": 4, "已审核": 0, "删除待审核": 2 ,"修改待审核":5};//2013.7.10修改,增加修改待审核
this.CheckFlag = -1;
//查询条件
this.pageSize = 500;
this.ShopIdsArray = [];
this.queryType = 2; // 1:按钮查询 2: 高级查询
this.groupId = -1; //分组ID
this.personId = -1; //人员ID
this.ManagerType = ""; //判断是否为KA经理和市场经理的标志
this.fields;
this.ordername;
this.orderindex=0;
//高级查询的字段名初始化为空
this.queryParams = {
BussCooperName: "",
ShopSystem: "",
CustomerName: "",
DZ_ShopType: "",
};
this.advQueryParams = new Object();
Ext.apply(this.advQueryParams, this.queryParams);
this.txt_ShopName;
this.InitComponent();
}
//*************类的方法*******************
DZMCJCXXGL_Designer.prototype = {
/**
* 树渲染: 扩展首节点
*/
treeRender: function () {
var root = this.treePanel.getRootNode();
if (root.firstChild != null) {
clearInterval(this.interval);
root.firstChild.select();
root.firstChild.expand();
this.treeClickHandler(root.firstChild);
}
},
/**
* 点击树节点
*/
treeClickHandler: function (node) {
if (!node.leaf) {
if (node.id.split("_")[1] == "group") {
this.queryType = 1;
this.groupId = node.id.split('_')[0];
this.personId = -1;
} else {
this.queryType = 1;
this.groupId = -1;
this.personId = node.id.split('_')[0];
this.ManagerType = node.attributes.person.DZ_ManagerType; //标志位取得postName的值(从node调试中看到的)
this.personName = node.text;
}
}
else {
this.queryType = 1;
this.groupId = -1;
this.personId = node.id.split('_')[0];
this.ManagerType = node.attributes.person.DZ_ManagerType; //标志位取得postName的值(从node调试中看到的)
this.personName = node.text;
}
},
/**
* 请求新的数据对象之前触发
*/
beforeloadStore: function (thiz, options) {
thiz.baseParams["QueryType"] = this.queryType;
thiz.baseParams["GroupId"] = this.groupId;
thiz.baseParams["PersonId"] = this.personId;
thiz.baseParams["CustomerName"] = this.queryParams.CustomerName; //增加-合作商名称
},
/**
* 采用当前参数加载Record缓存
*/
loadStore: function (inPageSize) {
this.pageSize = inPageSize == undefined ? this.pageSize : inPageSize;
this.store.load({
params: { start: 0, limit: this.pageSize,
QueryType: this.queryType,
CustomerName: this.queryParams.CustomerName
}
});
},
/**
* 采用上一次参数加载Record缓存
*/
reloadStore: function () {
this.store.reload();
},
/**
* 查询
*/
btn_Query_Click: function () {
this.ShopIdsArray = [];
this.queryType = 1;
this.store.removeAll();
this.queryParams.CustomerName = this.txt_ShopName.getValue();
this.queryParams.CheckFlag = this.CheckFlag; //新增的审核标志位
this.loadStore();
},
/**
* 高级查询回调
*/
advQueryCallBack: function (callParams) {
this.ShopIdsArray = [];
this.queryType = 2;
// //**2013.1.16修改,如果是审核标志位是-1,则进行的是高级查询
// this.queryParams.CustomerName = this.txt_ShopName.getValue();
// this.queryParams.CheckFlag = this.CheckFlag; //新增的审核标志位
// //**
this.advQueryParams = this.queryParams = callParams;
this.store.removeAll();
this.loadStore(); //这句话必须
},
/**
* 高级查询
*/
btn_AdvQuery_Click: function () {
AdvQueryMarketInfo(this.advQueryParams, this.advQueryCallBack.createDelegate(this), this.groupId);
},
//新增卖场
btn_Add_Click: function () {
//sShowWaitingHint();
setTimeout(this.tempAddCall.createDelegate(this), 1);
},
tempAddCall: function () {
//若点击树结点,则把相应的业务员的名字填入添加窗口的“人员”中
if (Ext.value(this.personId) != -1 && Ext.value(this.personId) != undefined) {
if (this.ManagerType != "市场经理") {
Ext.Msg.alert("提示", " 请选择市场经理进行添加");
return;
}
else {
AddMarketInfo(this.reloadStore.createDelegate(this), this.personName, this.personId, this.groupId);
}
}
else {
Ext.Msg.alert("提示", " 未选择业务员");
}
},
//** 批量审核
tempLotMarketInfoCheckCall: function (btn) {
var rows = this.grid.getSelectionModel().getSelections();
var checkflag = rows[0].data.CheckFlag;
if (btn == "yes") {
var ShopIDstr = new Array();
for (var i = 0; i < rows.length; i++) {
ShopIDstr.push(rows[i].data.ShopID);
}
Ext.Ajax.request({
url: "DataService/DZ_MarketInfo/CheckLotMarketInfo.ashx",
method: "POST",
params: {
ShopIdStr: ShopIDstr.join("|"),
Checkflag: checkflag
},
success: function (response, options) {
var result = Ext.util.JSON.decode(response.responseText);
if (result.success) {
this.reloadStore();
Ext.Msg.alert(resourceMsgTitle, result.Result);
}
else {
Ext.Msg.alert(resourceMsgTitle, resourceDelFail);
}
} .createDelegate(this),
failure: function () {
Ext.Msg.alert(resourceMsgTitle, resourceDelFail);
}
});
}
},
/**
* 审核状态
*/
renderCheckFlag: function (value, metadata, record, rowIndex, columnIndex, store) {
switch (value) {
case 0:
metadata.attr = "style=\"color:blue\"";
break;
case 4:
metadata.attr = "style=\"color:green\"";
break;
case 2:
metadata.attr = "style=\"color:red\"";
break;
case 5: //修改:2013.7.10增加 5:修改待审核
metadata.attr = "style=\"color:orange\"";
break;
}
for (var text in this.checkType) {
if (this.checkType[text] == value) {
return text;
}
}
},
// /** 导出当前和导出全部 **/
btn_Export_Current: function () {
var that = this;
//**beforechange的代码再执行一次
var rows = that.grid.getSelectionModel().getSelections();
if (rows.length != 0) {
var nary = [];
for (var i = 0; i < rows.length; i++) {
nary.push(rows[i].data.ShopID);
}
var cupage = that.pageBar.PagingToolBar.inputItem.value;
var n = parseInt(cupage) - 1;
if (that.ShopIdsArray.length < parseInt(cupage)) {
that.ShopIdsArray.push(nary);
} else {
that.ShopIdsArray[n] = nary;
}
//****
var shopIds = new Array();
if (that.ShopIdsArray.length > 0) {
for (var j = 0; j < that.ShopIdsArray.length; j++) {
var selary = that.ShopIdsArray[j];
for (var i = 0; i < selary.length; i++) {
shopIds.push(selary[i]);
}
}
}
ExportExcel("DataService/DZ_MarketInfo/MarketInfoReport.aspx", [["shopIds", shopIds.join("|")], ["exportType", 1]]);
} else {
Ext.Msg.alert(resourceMsgTitle, "请选择要导出的卖场信息");
}
},
btn_Export_All: function () {
window.open("DataService/DZ_MarketInfo/MarketInfoReport.aspx?personID=" + this.personId + "&GroupId=" + this.groupId + "&exportType=2" + "");
},
//***批量修改
//批量导出
btn_ExportLot: function () {
var that = this;
//**beforechange的代码再执行一次
var rows = that.grid.getSelectionModel().getSelections();
var nary = [];
for (var i = 0; i < rows.length; i++) {
nary.push(rows[i].data.ShopID);
}
var cupage = that.pageBar.PagingToolBar.inputItem.value;
var n = parseInt(cupage) - 1;
if (that.ShopIdsArray.length < parseInt(cupage)) {
that.ShopIdsArray.push(nary);
} else {
that.ShopIdsArray[n] = nary;
}
//****
var shopIds = new Array();
if (that.ShopIdsArray.length > 0) {
for (var j = 0; j < that.ShopIdsArray.length; j++) {
var selary = that.ShopIdsArray[j];
for (var i = 0; i < selary.length; i++) {
shopIds.push(selary[i]);
}
}
// var rows = this.grid.getSelectionModel().getSelections();
//修改2013.5.13 不针对人员导入,导入只有修改没有新增,不需要选中人员
DZ_LotImportMarket();
},
loadheaddes: function () { //
this.ShopIdsArray = [];
this.queryType = 1;
this.queryParams.CustomerName = this.txt_ShopName.getValue();
this.queryParams.CheckFlag = this.CheckFlag; //新增的审核标志位
this.loadStore();
},
headerclicks: function (grid, index, e) {
if (index > 0) {
if (this.ordername == this.fields[index - 1]) {
if (this.orderindex == 0) {
this.orderindex = 1;
}
else {
this.orderindex = 0;
}
}
else {
this.orderindex = 1;
}
this.ordername = this.fields[index - 1];
if (this.orderindex == 0) {
this.ordername = this.ordername + " DESC"
}
this.loadheaddes();
}
}
}
//*********************初始化控件(构造函数)******************
DZMCJCXXGL_Designer.prototype.InitComponent = function () {
this.treePanel = new DZ_SuperGroupPersonTreeCtrl(false).tree; //"JS/Public/Control/DZ_SuperGroupPersonTreeCtrl.js"
this.treePanel.on("click", this.treeClickHandler.createDelegate(this));
//查询时**
//1批状态
var checkStore = new Ext.data.SimpleStore({
fields: ['checkValue', 'checkValueText'],
data: [
[-1, '全部'],
[0, '已审核'],
[4, '新增待审核'],
[5, '修改待审核'], //增加修改待审核2013.7.10
[2, '删除待审核']
]
});
this.combo_Status = new Ext.form.ComboBox({
store: checkStore,
hiddenName: 'checkValue',
valueField: 'checkValue',
displayField: 'checkValueText',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
selectOnFocus: true,
editable: false,
width: 90,
value: -1,
listeners: { "select": function (combo, record, index) {
this.CheckFlag = record.get('checkValue'); this.btn_Query_Click();
} .createDelegate(this)
}
});
//2按卖场名查询
this.txt_ShopName = new Ext.form.TextField({
width: 150,
name: 'CustomerName',
emptyText: "请输入:卖场名称"
});
//字段参数
this.fields = [
"ShopID", //自动ID
"PersonID", //传递分配需要--就是树上的即市场经理的ID
"CustomerCode", //卖场编号
"ShopSystem", //所属系统(用户编码SystemCode)
"CustomerName" //卖场名称
];
this.store = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: "DataService/DZ_MarketInfo/GetMarketInfoList.ashx",
method: "POST"
}),
reader: new Ext.data.JsonReader({
fields: this.fields,
root: "data[0].table",
id: "ShopID",
totalProperty: "data[1].table[0].TotalCount"//存储过程中有这个totalCount
})
});
//高级查询的时候可以用
this.store.on("beforeload", this.beforeloadStore, this);
// this.store.on("load", this.afterloadStore.createDelegate(this), this);
var sm = new Ext.grid.CheckboxSelectionModel({ dataIndex: "ShopID" });
var cm = new Ext.grid.ColumnModel([
sm,
{
header: "门店ID",
dataIndex: "ShopID",
hidden: true
}
]);
//右键菜单(表的右键菜单,需求中可有可无)
var provinceRightClick = new Ext.menu.Menu({
items: [
{
text: resourceAdd,
iconCls: 'addicon',
hidden: !Yaxon.Common.CheckAuth('DZMCJCXXGL', 'DZMCJCXXGL_Add'),
handler: this.btn_Add_Click.createDelegate(this)
}]
});
this.pageBar = new PageBar(this.store, { defaultSize: this.pageSize, callBack: this.loadStore.createDelegate(this) });
//this.currentPage = pageBar.PagingToolBar.inputItem.value;
//**始***当前页选中,下一页后回到前一页还是可以看到选中的记录标记
var that = this;
this.pageBar.PagingToolBar.on('beforechange', function (thiz) {
var rows = that.grid.getSelectionModel().getSelections();
var nary = [];
for (var i = 0; i < rows.length; i++) {
nary.push(rows[i].data.ShopID);
}
var cupage = thiz.inputItem.value;
var n = parseInt(cupage) - 1;
if (that.ShopIdsArray.length < parseInt(cupage)) {
that.ShopIdsArray.push(nary);
} else {
that.ShopIdsArray[n] = nary;
}
});
this.pageBar.PagingToolBar.on('change', function (thiz) {
var cupage = this.pageBar.PagingToolBar.inputItem.value;
if (that.ShopIdsArray.length >= parseInt(cupage)) {
var selary = [];
var nary = that.ShopIdsArray[parseInt(cupage) - 1];
for (var i = 0; i < nary.length; i++) {
var Sindex = that.store.find("ShopID", nary[i]);
if (Sindex >= 0) {
selary.push(Sindex);
}
}
that.grid.getSelectionModel().selectRows(selary);
}
}, this);
//***止****
//grid表--现实
this.grid = new Ext.grid.GridPanel({
id: "ShopBaseInfoGrid",
region: 'center',
sm: sm,
cm: cm,
loadMask: true,
autoScroll: true,
border: false,
store: this.store,
bbar: this.pageBar.PagingToolBar,
tbar: [
{
text: resourceAdd,
iconCls: "addicon",
handler: this.btn_Add_Click.createDelegate(this)
},
"-",
"->",
'<b>状态:</b> ', this.combo_Status,
'-',
'<b>卖场名称:</b> ',
this.txt_ShopName,
'-',
{
text: resourceQuery,
pressed: true,
iconCls: 'serchrecord',
handler: this.btn_Query_Click.createDelegate(this)
},
'-',
{
text: resourceAdQuery,
pressed: true,
iconCls: 'adsearchicon',
handler: this.btn_AdvQuery_Click.createDelegate(this)
},
'-'
],
listeners: {
'contextmenu': function (e) { e.stopEvent(); },
'rowcontextmenu': function (grid, rowIndex, e) { e.stopEvent(); provinceRightClick.showAt(e.getXY()); },
"rowdblclick": this.btn_Edit_Click.createDelegate(this),
"rowdblclick": this.btn_Examine_DoubleClick.createDelegate(this), //双击查看详情
"headerclick": this.headerclicks.createDelegate(this)
}
});
//定义人员树容器
var leftContainer = new Ext.Panel({
region: 'west',
layout: "fit",
initialSize: 200,
minSize: 175,
maxSize: 400,
width: 200,
split: true,
autoScroll: true,
items: [this.treePanel]
});
this.container = new Ext.Panel({
layout: 'border',
margins: { top: 5 },
items: [leftContainer, this.grid]
});
this.interval = setInterval(this.treeRender.createDelegate(this), 1000);
};