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/Account/Viewsjs/Chfee_cheque/ChChequeBookEdit.js

743 lines
24 KiB
JavaScript

Ext.namespace('Shipping');
Shipping.MsChChequeBookEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsChChequeBookEdit.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsChChequeBookEdit, Ext.Panel, {
ParentWin: null,
OpStatus: 'add',
StoreList: null,
EditRecord: null,
initUIComponents: function () {
this.serialNo = 0;
this.workSerialNo = 0;
this.bodyDel = [];
this.StoreBANK = Ext.create('DsExt.ux.RefTableStore', {
model: 'BANK',
proxy: { url: '/MvcShipping/MsBaseInfo/GetBANKList' }
});
this.StoreBANK.load({ params: { condition: ""} });
this.comboxBANK = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '开户银行',
store: this.StoreBANK,
forceSelection: true,
name: 'BANKID',
valueField: 'GID',
displayField: 'ACCBANKNAME'
});
//#region 编辑form
//枚举参照相关(编辑form)
this.storeInvCategory = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsExtEnumModel',
proxy: { url: '/CommMng/PubSys/GetEnumValueList' }
});
this.storeInvCategory.load({ params: { enumTypeId: 97021} });
this.comboxInvCategory = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '支票类型',
store: this.storeInvCategory,
forceSelection: true,
name: 'TYPE',
valueField: 'EnumValueName',
displayField: 'EnumValueName'
});
this.StoreCurr = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsFeeCurr',
proxy: { url: '/MvcShipping/MsChFee/GetFeeCurrList' }
});
this.StoreCurr.load({ params: { condition: ""} });
this.comboxCurr = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '币别',
store: this.StoreCurr,
forceSelection: true,
allowBlank: false,
name: 'CURRENCY',
valueField: 'CURR',
displayField: 'CURR',
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (records.length > 0) {
}
}
}
});
//表参照相关(编辑form)
_this = this;
//编辑form
this.formEdit = Ext.widget('form', {
region: 'center',
frame: true,
bodyPadding: 5,
autoScroll: true,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 90,
msgTarget: 'qtip'
},
items: [
{//fieldset 1
xtype: 'fieldset',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: 'GID',
name: 'GID', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: 'CREATEUSER',
name: 'CREATEUSER', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: 'COMPANYID',
name: 'COMPANYID', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: '票册名称',
name: 'NAME'
}, {
fieldLabel: '票册描述',
name: 'DESCRIPTION'
}, this.comboxCurr, this.comboxInvCategory
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxBANK,{
fieldLabel: '支票代码',
name: 'CHEQUECODE'
}, {
fieldLabel: '票册开始号',
name: 'CHEQUENUMSTART'
}, {
fieldLabel: '票册结束号',
name: 'CHEQUENUMEND',
listeners: {
change: function () {
var basicForm = _this.formEdit.getForm();
var STARTDATE = parseInt(basicForm.findField('CHEQUENUMSTART').getValue());
var newValue = parseInt(basicForm.findField('CHEQUENUMEND').getValue());
var chenum = newValue - STARTDATE + 1;
basicForm.findField('CHEQUETOTAL').setValue(chenum);
}
}
}, {
fieldLabel: '支票总数',
hidden: true,
name: 'CHEQUETOTAL'
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '创建人',
readOnly: true,
name: 'CREATEUSERREF'
}, {
fieldLabel: '创建时间',
readOnly: true,
name: 'CREATETIME'
}, {
fieldLabel: '是否锁定',
readOnly: true,
name: 'ISLOCK'
}, {
fieldLabel: '是否作废',
readOnly: true,
name: 'ISDELETE'
}]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
}); //end this.formEdit
//#endregion
//#region 按钮Toolbar
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
text: "保存",
id: 'btnsave',
iconCls: "btnsave",
handler: function (button, event) {
this.Save('0');
},
scope: this
},
{
text: "保存并关闭",
id: 'btnsaveandclose',
handler: function (button, event) {
this.Save('1');
},
scope: this
},
'-',
{
text: "保存并新建",
id: 'btnsaveandnew',
handler: function (button, event) {
this.Save('2');
},
scope: this
}, '-',
{
text: "生成",
id: 'btncreateitems',
handler: function (button, event) {
this.CreateItems();
},
scope: this
}
]
}); //end 按钮Toolbar
//#endregion
//#region 明细表
//明细表表格相关
//明细表-数据集
this.storeBodyList = Ext.create('Ext.data.Store', {
model: 'ChChequeBookdetail',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/Account/Chfee_cheque/GetBookitemsDataList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//明细表表格
this.gridListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.GridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
this.gridList = new Ext.grid.GridPanel({
store: this.storeBodyList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.gridListCellEditing],
selModel: this.GridCheckBoxModel,
selType: 'cellmodel',
tbar: [
//
// {
// text: '增加明细',
// tooltip: '增加明细',
// iconCls: "btnadddetail",
// handler: function (button, event) {
// this.onAddDetailClick(button, event, 1);
// },
// scope: this
// }, '-',
{
text: '锁定',
tooltip: '锁定',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onLockDetailClick(button, event);
},
scope: this
}, {
text: '取消锁定',
tooltip: '取消锁定',
iconCls: "btnreset",
handler: function (button, event) {
this.CancelLockDetail();
},
scope: this
}],
columns: [{
sortable: true,
dataIndex: 'GID',
header: 'GID',
hidden: true,
width: 100
}, {
sortable: true,
dataIndex: 'BOOKID',
header: 'BOOKID',
hidden: true,
width: 100
}, {
sortable: true,
dataIndex: 'CHEQUENUM',
header: '支票号',
width: 160
}, {
sortable: true,
dataIndex: 'ISMAKEOUT',
header: '是否开出',
width: 160
}, {
sortable: true,
dataIndex: 'ISLOCK',
header: '是否锁定',
width: 160
}, {
sortable: true,
dataIndex: 'ISDELETE',
header: '是否作废',
width: 160
}
]
});
this.panelService = new Ext.Panel({
title: '支票号明细',
layout: "border",
region: 'center',
margin: '5 10',
items: [this.gridList]
});
//#endregion 明细表
//#region 布局
//控件布局
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 140,
items: [this.panelBtn, this.formEdit]
});
Ext.apply(this, {
items: [this.panelTop, this.panelService]
});
//#endregion
//绑定查询窗体
this.ParentWin = window.parent.opener;
//初始化数据
this.InitData();
//绑定事件
this.gridList.on('edit', function (editor, e, eOpts) {
this.gridAfterEdit(editor, e, eOpts);
}, this);
}, //end initUIComponents
InitData: function () {
this.opStatus = 'add';
var condition = '';
if (this.ParentWin) {
var ret = this.ParentWin.OprationSwap();
this.opStatus = ret[0];
this.StoreList = ret[1];
this.editRecord = ret[2];
}
if (this.opStatus == 'edit')
condition = " GID='" + this.editRecord.get('GID') + "'";
this.LoadData(this.opStatus, condition);
}, //end InitData
LoadData: function (opstatus, condition) {
this.serialNo = 0;
this.workSerialNo = 0;
this.bodyDel = [];
_this = this;
this.opStatus = opstatus;
Ext.Ajax.request({
waitMsg: '正在查询明细数据...',
url: '/Account/Chfee_cheque/GetBookData',
params: {
handle: opstatus,
condition: condition
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (!result.Success) {
Ext.Msg.show({
title: '提示',
msg: result.Message,
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
return;
}
var data = result.data;
this.formEdit.getForm().reset();
this.formEdit.getForm().setValues(data);
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
var billno = '*';
var cargoid = 0;
if (this.opStatus == 'edit') {
cargoid = this.editRecord.get('GID');
}
var canedit = true;
this.storeBodyList.load({ params: { condition: " BOOKID='" + cargoid + "'" },
callback: function (r, options, success) {
if (success) {
if (r.length != 0) {
canedit = false;
} else { canedit = true; }
_this.setSaveBtnStatus(canedit);
}
}
});
}, // end LoadDate
Save: function (type) {
var basicForm = this.formEdit.getForm();
if (!basicForm.isValid()) {
return;
}
//判断表格数据是否合法
if (!validateEditorGridPanel(this.gridList)) {
return;
}
basicForm.findField('GID').setDisabled(false);
var data = basicForm.getValues();
basicForm.findField('GID').setDisabled(true);
if (this.opStatus == 'add') {
data.GID = '*';
}
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Account/Chfee_cheque/SaveBook',
scope: this,
params: {
opstatus: this.opStatus,
data: Ext.JSON.encode(data)
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var returnData = jsonresult.Data;
this.formEdit.getForm().setValues(returnData);
if (this.opStatus == 'add') {
var arrNewRecords = this.StoreList.add(returnData);
this.editRecord = arrNewRecords[0];
}
else if (this.opStatus == 'edit') {
var editp = Ext.create('MsChChequeBook', returnData);
this.editRecord.fields.each(function (field) {
if (field.persist) {
name = field.name;
if (name != 'id')
this.editRecord.set(name, editp.get(name));
}
}, this);
this.editRecord.commit();
}
if (type == '0') {
this.opStatus = 'edit';
basicForm.findField('GID').setDisabled(true);
} else if (type == '1') {
window.close();
} else {
this.LoadData('add', '');
basicForm.findField('GID').setDisabled(false);
}
} 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
CreateItems: function () {
var basicForm = this.formEdit.getForm();
if (!basicForm.isValid()) {
return;
}
basicForm.findField('GID').setDisabled(false);
var data = basicForm.getValues();
basicForm.findField('GID').setDisabled(true);
var GID = basicForm.findField('GID').getValue();
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Account/Chfee_cheque/CreateBookitems',
scope: this,
params: {
data: Ext.JSON.encode(data)
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.storeBodyList.load({ params: { condition: " BOOKID='" + GID + "'"} });
} 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
onAddDetailClick: function (button, event, type) {
this.addDetail(type);
}, //end onAddDetailClick
onLockDetailClick: function (button, event) {
this.LockDetail();
}, //onDelDetailClick
gridAfterEdit: function (editor, e, eOpts) {
//需要自己实现里面的事件
},
addDetail: function (type) {
var newSerialno = 0;
if (type == 2) {
store = this.storeWorkList;
newSerialno = DsGetNewSerialNo(store, this.workSerialNo);
this.workSerialNo = newSerialno;
} else if (type == 1) {
store = this.storeBodyList;
newSerialno = DsGetNewSerialNo(store, this.serialNo);
this.serialNo = newSerialno;
}
var record = Ext.create('MsCodeOpServiceDetail', {
OS_ID: '',
SerialNo: newSerialno,
NAME: "",
WORKLOAD: 0,
REMARK: ""
});
store.add(record);
var n = store.getCount();
if (type == 2) {
this.gridworkListCellEditing.startEditByPosition({ row: n - 1, column: 1 });
} else if (type == 1) {
this.gridListCellEditing.startEditByPosition({ row: n - 1, column: 1 });
}
},
LockDetail: 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;
};
var bodyAddDatas = [];
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.data.ISMAKEOUT != '是' && rec.data.ISDELETE != '是') {
bodyAddDatas.push(rec);
}
}
_this = this;
var jsonbodyAddDatas = ConvertRecordsToJsonAll(bodyAddDatas);
Ext.MessageBox.confirm('提示', '确定要锁定该记录吗?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在锁定数据...');
Ext.Ajax.request({
waitMsg: '正在锁定数据...',
url: '/Account/Chfee_cheque/LockBookitems',
params: {
data: jsonbodyAddDatas
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var cargoid = this.editRecord.get('GID');
this.storeBodyList.load({ params: { condition: " BOOKID='" + cargoid + "'"} });
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);
},
CancelLockDetail: 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;
};
var bodyAddDatas = [];
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.data.ISLOCK == '是') {
bodyAddDatas.push(rec);
}
}
_this = this;
var jsonbodyAddDatas = ConvertRecordsToJsonAll(bodyAddDatas);
Ext.MessageBox.confirm('提示', '确定要取消锁定该记录吗?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在取消锁定数据...');
Ext.Ajax.request({
waitMsg: '正在取消锁定数据...',
url: '/Account/Chfee_cheque/CancelLockBookitems',
params: {
data: jsonbodyAddDatas
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var cargoid = this.editRecord.get('GID');
this.storeBodyList.load({ params: { condition: " BOOKID='" + cargoid + "'"} });
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);
},
setSaveBtnStatus: function (enable) {
var btnESave = Ext.getCmp('btnsave');
var btnESaveAndClose = Ext.getCmp('btnsaveandclose');
var btnESaveAndNew = Ext.getCmp('btnsaveandnew');
var btncreateitems = Ext.getCmp('btncreateitems');
if (enable) {
btnESave.enable();
btnESaveAndClose.enable();
btnESaveAndNew.enable();
btncreateitems.enable();
} else {
btnESave.disable();
btnESaveAndClose.disable();
btnESaveAndNew.disable();
btncreateitems.disable();
}
}
});