You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/Areas/MvcShipping/Viewsjs/MsCtExplan/MsCtExplanIndex.js

458 lines
18 KiB
JavaScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

Ext.namespace('Shipping');
String.prototype.trim = function () { return this.replace(/(^\s*)|(\s*$)/g, ""); }
Shipping.MsCtExplanIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsCtExplanIndex.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsCtExplanIndex, Ext.Panel, {
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
isKeyAdd: 0,
initUIComponents: function () {
this.formname = "formMsCtExplanIndex"; //页面名称
//#region gridList列表
this.storeList = Ext.create('Ext.data.Store', {
model: 'MsCtExplanModel',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsCtExplan/GetDataList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.girdcolums = [{
dataIndex: 'GID',
text: '唯一编码',
width: 0,
hidden: true
}, {
text: '摘要类别',
dataIndex: 'EXPLANTYPE',
width: 188,
//align: 'center',
editor: {
xtype: 'textfield',
selectOnFocus: true,
enableKeyEvents: true, //激活键盘事件
listeners: {
scope: this,
'keyup': {
fn: function (_field, e) {
if (e.getKey() == 40) {
this.storeListDetail.removeAll();
this.isKeyAdd = 1;
this.onAddClick();
}
},
scope: this
}
}
}
}, {
text: '模块类别',
dataIndex: 'MODULETYPE',
//align: 'center',
width: 0,
hidden: true
}];
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,
listeners: {
scope: this,
'cellclick': function (_thisTable, td, cellIndex, record, tr, rowIndex, e, eOpts) {
if (record.data.EXPLANTYPE == "(所有类别)") {
return false;
}
this.storeListDetail.load({ params: { condition: "LINKGID='" + record.data.GID + "'" }, waitMsg: "正在刷新数据...", scope: this });
parentWin = window.parent.opener;
if (parentWin) {
return false;
}
},
'edit': function (editor, e, eOpts) {
if (e.value == e.originalValue) { return; }
if (e.value == "(所有类别)") { return; }
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsCtExplan/Save',
params: {
data: Ext.JSON.encode(e.record.data)
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.storeList.load({
params: { condition: "MODULETYPE='出纳'" },
waitMsg: "正在刷新数据...",
callback: function (options, success, response) {
if (this.isKeyAdd == 1) {
this.isKeyAdd = 0;
this.onAddClick();
}
},
async: false,
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
});
}
},
//async: false,
scope: this
});
}
}
});
this.storeList.load({ params: { condition: "MODULETYPE='出纳'" }, waitMsg: "正在查询数据...", scope: this });
//#endregion
//#region gridListDetail列表
this.storeListDetail = Ext.create('Ext.data.Store', {
model: 'MsCtExplanDetailModel',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsCtExplan/GetDataListDetail',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.girdcolumsDetail = [{
dataIndex: 'GID',
text: '唯一编码',
width: 0,
hidden: true
}, {
text: '摘要',
dataIndex: 'EXPLAN',
width: 400,
//align: 'center',
editor: {
xtype: 'textfield',
selectOnFocus: true,
enableKeyEvents: true, //激活键盘事件
listeners: {
scope: this,
'keyup': {
fn: function (_field, e) {
if (e.getKey() == 40) {
this.isKeyAdd = 1;
this.onAddDetailClick();
}
},
scope: this
}
}
}
}];
this.gridListCellEditingDetail = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1 //1单击2双击
});
this.gridListDetail = new Ext.grid.GridPanel({
region: 'center',
store: this.storeListDetail,
enableHdMenu: false, //是否显示表格列的菜单
hideHeaders: false, //是否隐藏表头
rowLines: true,
columnLines: true,
loadMask: { msg: "数据加载中,请稍等..." },
plugins: [this.gridListCellEditingDetail],
selType: 'cellmodel',
columns: this.girdcolumsDetail,
listeners: {
scope: this,
'cellclick': function (_thisTable, td, cellIndex, record, tr, rowIndex, e, eOpts) {
parentWin = window.parent.opener;
if (parentWin) {
return false;
}
},
'edit': function (editor, e, eOpts) {
if (e.value == e.originalValue) { return; }
var selections = this.gridList.getSelectionModel().getSelection(); //获得选中的项
if (selections.length == 0) {
Ext.Msg.show({ title: '错误', msg: "请先选择摘要类别!", icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var sLINKGID = selections[0].data.GID;
//
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsCtExplan/SaveDetail',
params: {
data: Ext.JSON.encode(e.record.data),
sLINKGID: sLINKGID
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.storeListDetail.load({
params: { condition: "LINKGID='" + sLINKGID + "'" },
waitMsg: "正在刷新数据...",
callback: function (options, success, response) {
if (this.isKeyAdd == 1) {
this.isKeyAdd = 0;
this.onAddDetailClick();
}
},
async: false,
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
});
}
},
//async: false,
scope: this
});
}
}
});
this.gridListDetail.addListener('itemdblclick', function (dataview, record, item, index, e, b) {
_this = this;
parentWin = window.parent.opener;
if (parentWin) {
this.onF7DbClick(parentWin, record);
}
}, this);
//#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
}, '-', {
text: '删除',
tooltip: '删除',
id: "btndel",
iconCls: "btndelete",
handler: function (button, event) {
this.onDelClick(button, event);
},
scope: this
}]
}); //end 按钮Toolbar
this.panelBtnDetail = new Ext.Panel({
region: "north",
tbar: [{
text: '添加明细',
tooltip: '添加明细',
id: "btnaddDetail",
iconCls: "btnadd",
handler: function (button, event) {
this.onAddDetailClick(button, event);
},
scope: this
}, '-', {
text: '删除明细',
tooltip: '删除明细',
id: "btndelDetail",
iconCls: "btndelete",
handler: function (button, event) {
this.onDelDetailClick(button, event);
},
scope: this
}]
}); //end 按钮Toolbar
this.panelWest = new Ext.Panel({
layout: "border",
region: "west",
//region: "center",
width: 200,
frame: true,
items: [this.panelBtn, this.gridList]
});
this.panelCenter = new Ext.Panel({
layout: "border",
region: "center",
//height: 100,
frame: true,
items: [this.panelBtnDetail, this.gridListDetail]
});
Ext.apply(this, {
items: [this.panelWest, this.panelCenter]
});
//#endregion
}, //end initUIComponents
//#region 按钮函数
onAddClick: function () {
var record = Ext.create('MsCtExplanModel', {
GID: '*',
EXPLANTYPE: '',
MODULETYPE: '出纳'
});
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();
if (selectedRecords.length <= 0) {
//Ext.Msg.show({ title: '警告', msg: '请选中要操作的数据!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return false;
}
var rec = selectedRecords[0];
Ext.MessageBox.confirm('提示', '确定删除该记录(包含明细)吗?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/MvcShipping/MsCtExplan/Delete',
params: {
data: Ext.JSON.encode(rec.data)
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.storeList.load({ params: { condition: "MODULETYPE='出纳'" }, waitMsg: "正在查询数据...", scope: this });
this.storeListDetail.removeAll();
//Ext.Msg.show({ title: '提示', msg: jsonresult.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
Ext.Msg.hide();
}
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);
},
onAddDetailClick: function () {
var record = Ext.create('MsCtExplanDetailModel', {
GID: '*',
EXPLAN: ''
});
this.storeListDetail.add(record);
var n = this.storeListDetail.getCount();
this.gridListCellEditingDetail.startEditByPosition({ row: n - 1, column: 0 });
},
onDelDetailClick: function () {
var selectedRecords = this.gridListDetail.selModel.getSelection();
if (selectedRecords.length <= 0) {
//Ext.Msg.show({ title: '警告', msg: '请选中要操作的数据!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return false;
}
var rec = selectedRecords[0];
Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在删除明细数据...');
Ext.Ajax.request({
waitMsg: '正在删除明细数据...',
url: '/MvcShipping/MsCtExplan/DeleteDetail',
params: {
data: Ext.JSON.encode(rec.data)
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var selections = this.gridList.getSelectionModel().getSelection(); //获得选中的项
var sLINKGID = selections[0].data.GID;
this.storeListDetail.load({ params: { condition: "LINKGID='" + sLINKGID + "'" }, waitMsg: "正在刷新数据...", scope: this });
//Ext.Msg.show({ title: '提示', msg: jsonresult.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
Ext.Msg.hide();
}
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
//#region F7返回双击事件
onF7DbClick: function (parentWin, record) {
if (record.data.EXPLAN.toString() == '') {
Ext.Msg.show({ title: '警告', msg: '不允许选择为空数据!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK });
return;
}
var ret = parentWin.OprationSwap2();
var selections = ret[0];
selections.setValue(record.data.EXPLAN.toString());
window.close();
}
//#endregion
});