|
|
Ext.namespace('Shipping');
|
|
|
|
|
|
String.prototype.trim = function () { return this.replace(/(^\s*)|(\s*$)/g, ""); }
|
|
|
|
|
|
Shipping.MsCompanysDeptIndex = function (config) {
|
|
|
Ext.applyIf(this, config);
|
|
|
this.initUIComponents();
|
|
|
window.Shipping.MsCompanysDeptIndex.superclass.constructor.call(this);
|
|
|
};
|
|
|
|
|
|
Ext.extend(Shipping.MsCompanysDeptIndex, Ext.Panel, {
|
|
|
editRecord: null, //仅当弹出界面时使用
|
|
|
SelectedRecord: null,
|
|
|
parentWin: null,
|
|
|
|
|
|
initUIComponents: function () {
|
|
|
this.formname = "formMsCompanysDeptIndex"; //页面名称
|
|
|
|
|
|
//#region 定义数据集
|
|
|
this.storeList = Ext.create('Ext.data.Store', {
|
|
|
model: 'MsCompanysDeptModel',
|
|
|
remoteSort: true,
|
|
|
proxy: {
|
|
|
type: 'ajax',
|
|
|
url: '/MvcShipping/MsCompanysDept/GetDataList',
|
|
|
reader: {
|
|
|
id: 'GID',
|
|
|
root: 'data',
|
|
|
totalProperty: 'totalCount'
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
//#endregion
|
|
|
|
|
|
//#region 列定义
|
|
|
this.girdcolums = [{
|
|
|
sortable: true,
|
|
|
dataIndex: 'GID',
|
|
|
header: '唯一编码',
|
|
|
width: 0
|
|
|
}, {
|
|
|
dataIndex: 'DEPTNO',
|
|
|
header: '代码',
|
|
|
width: 50,
|
|
|
editor: {
|
|
|
xtype: 'textfield',
|
|
|
selectOnFocus: true
|
|
|
}
|
|
|
}, {
|
|
|
dataIndex: 'DEPTNAME',
|
|
|
header: '名称',
|
|
|
width: 100,
|
|
|
editor: {
|
|
|
xtype: 'textfield',
|
|
|
selectOnFocus: true
|
|
|
}
|
|
|
}, {
|
|
|
dataIndex: 'FINANCESOFTCODE',
|
|
|
header: '财务代码',
|
|
|
width: 80,
|
|
|
editor: {
|
|
|
xtype: 'textfield',
|
|
|
selectOnFocus: true
|
|
|
}
|
|
|
}, {
|
|
|
dataIndex: 'MANAGE1',
|
|
|
header: '经理',
|
|
|
width: 80,
|
|
|
editor: {
|
|
|
xtype: 'textfield',
|
|
|
selectOnFocus: true
|
|
|
}
|
|
|
}, {
|
|
|
dataIndex: 'MANAGE2',
|
|
|
header: '副经理',
|
|
|
width: 80,
|
|
|
editor: {
|
|
|
xtype: 'textfield',
|
|
|
selectOnFocus: true
|
|
|
}
|
|
|
}, {
|
|
|
dataIndex: 'REMARK',
|
|
|
header: '备注',
|
|
|
width: 100,
|
|
|
editor: {
|
|
|
xtype: 'textfield',
|
|
|
selectOnFocus: true
|
|
|
}
|
|
|
}];
|
|
|
//#endregion
|
|
|
|
|
|
//#region gridList列表显示信息
|
|
|
this.gridListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
|
|
|
clicksToEdit: 1 //1单击,2双击
|
|
|
});
|
|
|
|
|
|
this.gridList = new Ext.grid.GridPanel({
|
|
|
region: 'center',
|
|
|
store: this.storeList,
|
|
|
enableHdMenu: false, //是否显示表格列的菜单
|
|
|
hideHeaders: false, //是否隐藏表头
|
|
|
rowLines: true,
|
|
|
columnLines: true,
|
|
|
loadMask: { msg: "数据加载中,请稍等..." },
|
|
|
plugins: [this.gridListCellEditing],
|
|
|
selType: 'cellmodel',
|
|
|
columns: this.girdcolums
|
|
|
});
|
|
|
//#endregion
|
|
|
|
|
|
//#region 按钮工具条/页面布局
|
|
|
this.panelBtn = new Ext.Panel({
|
|
|
region: "north",
|
|
|
tbar: [{
|
|
|
text: '添加',
|
|
|
tooltip: '添加',
|
|
|
id: "btnadd",
|
|
|
iconCls: "btnadd",
|
|
|
handler: function (button, event) {
|
|
|
this.onAddClick(button, event);
|
|
|
},
|
|
|
scope: this
|
|
|
}, '-', {
|
|
|
id: 'btnESave',
|
|
|
text: "保存",
|
|
|
iconCls: "btnsave",
|
|
|
handler: function (button, event) {
|
|
|
this.Save('0');
|
|
|
},
|
|
|
scope: this
|
|
|
}, '-', {
|
|
|
text: '删除',
|
|
|
tooltip: '删除',
|
|
|
id: "btndel",
|
|
|
iconCls: "btndelete",
|
|
|
handler: function (button, event) {
|
|
|
this.onDelClick(button, event);
|
|
|
},
|
|
|
scope: this
|
|
|
}]
|
|
|
}); //end 按钮Toolbar
|
|
|
|
|
|
Ext.apply(this, {
|
|
|
items: [this.panelBtn, this.gridList]
|
|
|
});
|
|
|
//#endregion
|
|
|
this.storeList.on('beforeload', function (store) {
|
|
|
var condition = " LINKID='" + this.editRecord.get('GID') + "'";
|
|
|
Ext.apply(store.proxy.extraParams, { condition: condition });
|
|
|
}, this);
|
|
|
//var mainform = window.parent._this; // Ext.getCmp('OpOtherEdit');
|
|
|
this.parentWin = window.parent.panelEdit;
|
|
|
this.InitData();
|
|
|
}, //end initUIComponents
|
|
|
|
|
|
//#region 按钮函数
|
|
|
InitData: function () {
|
|
|
if (this.parentWin!=null) {
|
|
|
this.editRecord = this.parentWin.editRecord;
|
|
|
var sGID = this.editRecord.get('GID');
|
|
|
}
|
|
|
if(sGID!="")
|
|
|
{
|
|
|
var condition = " LINKID='" + this.editRecord.get('GID') + "'";
|
|
|
this.storeList.load({ params: { condition: condition }, waitMsg: "正在查询数据...", scope: this });
|
|
|
}
|
|
|
}, //end InitData
|
|
|
|
|
|
Save: function () {
|
|
|
var j = 0;
|
|
|
var bodydatas = [];
|
|
|
for (var i = 0; i < this.storeList.getCount(); i += 1) {
|
|
|
var member = this.storeList.getAt(i);
|
|
|
bodydatas.push(member);
|
|
|
}
|
|
|
if (bodydatas.length > 0) {
|
|
|
var jsonBody = ConvertRecordsToJsonAll(bodydatas);
|
|
|
Ext.Msg.wait('正在保存数据, 请稍侯..');
|
|
|
Ext.Ajax.request({
|
|
|
waitMsg: '正在保存数据...',
|
|
|
url: '/MvcShipping/MsCompanysDept/Save',
|
|
|
scope: this,
|
|
|
params: {
|
|
|
LINKID:this.editRecord.get('GID'),
|
|
|
body: jsonBody
|
|
|
},
|
|
|
callback: function (options, success, response) {
|
|
|
if (success) {
|
|
|
Ext.MessageBox.hide();
|
|
|
var jsonresult = Ext.JSON.decode(response.responseText);
|
|
|
if (jsonresult.Success) {
|
|
|
//var returnData = jsonresult.Data;
|
|
|
var condition = " LINKID='" + this.editRecord.get('GID') + "'";
|
|
|
this.storeList.load({ params: { condition: condition }, waitMsg: "正在刷新数据...", scope: this });
|
|
|
} else {
|
|
|
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
|
|
|
}
|
|
|
} else {
|
|
|
Ext.Msg.show({ title: '请重试',
|
|
|
msg: '服务器响应出错',
|
|
|
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
}, //end save
|
|
|
|
|
|
onAddClick: function () {
|
|
|
var record = Ext.create('MsCompanysDeptModel', {
|
|
|
GID: '*',
|
|
|
DEPTNO: '',
|
|
|
DEPTNAME: '',
|
|
|
FINANCESOFTCODE: '',
|
|
|
MANAGE1: '',
|
|
|
MANAGE2: '',
|
|
|
REMARK: ''
|
|
|
});
|
|
|
this.storeList.add(record);
|
|
|
var n = this.storeList.getCount();
|
|
|
this.gridListCellEditing.startEditByPosition({ row: n - 1, column: 0 });
|
|
|
},
|
|
|
|
|
|
onDelClick: function () {
|
|
|
var selectedRecords = this.gridList.selModel.getSelection();
|
|
|
var rec = selectedRecords[0];
|
|
|
Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) {
|
|
|
if (btn == 'yes') {
|
|
|
Ext.Msg.wait('正在删除数据...');
|
|
|
Ext.Ajax.request({
|
|
|
waitMsg: '正在删除数据...',
|
|
|
url: '/MvcShipping/MsCompanysDept/Delete',
|
|
|
params: {
|
|
|
data: Ext.JSON.encode(rec.data),
|
|
|
LINKID:this.editRecord.get('GID')
|
|
|
},
|
|
|
callback: function (options, success, response) {
|
|
|
if (success) {
|
|
|
var jsonresult = Ext.JSON.decode(response.responseText);
|
|
|
if (jsonresult.Success) {
|
|
|
this.storeList.remove(rec);
|
|
|
Ext.Msg.show({ title: '提示', msg: jsonresult.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
|
|
|
}
|
|
|
else {
|
|
|
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
failure: function (response, options) {
|
|
|
Ext.Msg.show({ title: '警告', msg: '服务器响应出错,请重试', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
|
|
|
},
|
|
|
scope: this
|
|
|
}); //end Ext.Ajax.request
|
|
|
}
|
|
|
}, this);
|
|
|
}
|
|
|
//#endregion
|
|
|
});
|
|
|
|
|
|
|