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.

1503 lines
54 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');
Shipping.MsChChequeEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsChChequeEdit.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsChChequeEdit, Ext.Panel, {
ParentWin: null,
OpStatus: 'add',
StoreList: null,
EditRecord: null,
addstore: false,
PageSize: 30,
initUIComponents: function () {
this.serialNo = 0;
this.workSerialNo = 0;
this.bodyDel = [];
this.FeeSql = '';
this.BillSql = '';
this.DuiBillSql = '';
this.IsDebit = '0';
this.StoreLockOp = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsFeeOP',
proxy: { url: '/MvcShipping/MsBaseInfo/GetOpIDRang' }
});
this.StoreLockOp.load({ params: { optype: "modChequeLock"} });
this.StoreUnLockOp = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsFeeOP',
proxy: { url: '/MvcShipping/MsBaseInfo/GetOpIDRang' }
});
this.StoreUnLockOp.load({ params: { optype: "modChequeUnLock"} });
//#region 编辑form
//枚举参照相关(编辑form)
//表参照相关(编辑form)
this.storecustbank = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsInfoClientBankModel',
proxy: { url: '/MvcShipping/MsInfoClient/GetBankList' }
});
this.storeCustCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomInvRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomInvRefList' }
});
this.storeCustCode.load({ params: { condition: ""} });
this.comboxCustCode = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '开票单位',
store: this.storeCustCode,
allowBlank: false,
forceSelection: true,
name: 'CUSTOMERNAME',
valueField: 'CustName',
displayField: 'CodeAndName',
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (records.length > 0) {
var INVOICECUSTNAME = this.formEdit.getForm().findField('CHEQUECUSTNAME');
var PAYEEBANK = this.formEdit.getForm().findField('PAYEEBANK');
var PAYEEBANKACCOUNT = this.formEdit.getForm().findField('PAYEEBANKACCOUNT');
var PAYEEADR = this.formEdit.getForm().findField('PAYEEADR');
var CURR = this.formEdit.getForm().findField('CHEQUECURRENCY').getValue();
INVOICECUSTNAME.setValue(records[0].data.RMBBillRises);
PAYEEADR.setValue(records[0].data.Addr);
var s = " CURRENCY='" + CURR + "' and LINKID=(SELECT TOP 1 GID FROM INFO_CLIENT WHERE SHORTNAME='" + records[0].data.CustName + "')";
this.storecustbank.load({ params: { condition: s },
callback: function (r, options, success) {
if (success) {
if (this.storecustbank.getCount() > 0) {
var member = this.storecustbank.getAt(0);
PAYEEBANK.setValue(member.data.BANKNAME);
PAYEEBANKACCOUNT.setValue(member.data.ACCOUNT);
} else {
PAYEEBANK.setValue('');
PAYEEBANKACCOUNT.setValue('');
}
}
},
scope: this
});
}
}
}
});
this.StoreOpRange = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsOP',
proxy: { url: '/MvcShipping/MsBaseInfo/GetOpRang' }
});
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: 'CHEQUECURRENCY',
valueField: 'CURR',
displayField: 'CURR',
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (records.length > 0) {
var basicForm = _this.formEdit.getForm();
var newValue = basicForm.findField('CHEQUEAMOUNT').getValue();
var curr = records[0].data.CURR;
if (curr == 'USD')
basicForm.findField('CHEQUEAMOUNTUPPER').setValue('美元' + formatUSD(newValue));
else
basicForm.findField('CHEQUEAMOUNTUPPER').setValue(_this.numtoc(newValue));
}
}
}
});
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: 'CHEQUETYPE',
valueField: 'EnumValueName',
displayField: 'EnumValueName'
});
this.StoreInvNo = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsChInvoiceNo',
proxy: { url: '/Account/Chfee_cheque/GetChequeNo' }
});
this.StoreInvNo.load({ params: { condition: ""} });
this.comboxInvNo = Ext.create('DsExt.ux.RefTableCombox', {
store: this.StoreInvNo,
fieldLabel: '支票号',
name: 'CHEQUENO',
valueField: 'INVNO',
displayField: 'INVNO'
});
this.StoreBANK = Ext.create('DsExt.ux.RefTableStore', {
model: 'BANK',
proxy: { url: '/MvcShipping/MsBaseInfo/GetBANKList' }
});
this.StoreBANK.load({ params: { condition: ""} });
this.comboxBANKID = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '银行账户',
store: this.StoreBANK,
forceSelection: true,
allowBlank: false,
name: 'BANKID',
valueField: 'GID',
displayField: 'ACCBANKNAME',
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (records.length > 0) {
this.StoreInvNo.load({ params: { condition: " b.BANKID='" + records[0].data.GID + "'"} });
var PAYBANK = this.formEdit.getForm().findField('PAYBANK');
PAYBANK.setValue(records[0].data.BANKNAME);
var PAYBANKACCOUNT = this.formEdit.getForm().findField('PAYBANKACCOUNT');
PAYBANKACCOUNT.setValue(records[0].data.ACCOUNT);
this.formEdit.getForm().findField('CHEQUECURRENCY').setValue(records[0].data.CURRENCY);
}
}
}
});
this.comboxBANK = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '开户行',
store: this.StoreBANK,
forceSelection: true,
name: 'PAYBANK',
valueField: 'BANKNAME',
displayField: 'BANKNAME',
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (records.length > 0) {
var PAYBANKACCOUNT = this.formEdit.getForm().findField('PAYBANKACCOUNT');
PAYBANKACCOUNT.setValue(records[0].data.ACCOUNT);
}
}
}
});
//#region 编辑formHead 基本信息
this.comboxCustBank = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '收款单位银行',
store: this.storecustbank,
// forceSelection: true,
name: 'PAYEEBANK',
valueField: 'BANKNAME',
displayField: 'ACCOUNTNAMEREF',
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (records.length > 0) {
var CUSTACCOUNT = this.formEdit.getForm().findField('PAYEEBANKACCOUNT');
CUSTACCOUNT.setValue(records[0].data.ACCOUNT);
}
}
}
});
_this = this;
//编辑form
this.formEdit = Ext.widget('form', {
region: 'center',
frame: true,
bodyPadding: 3,
trackResetOnLoad: true,
// 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: 'BILLSTATUS',
name: 'BILLSTATUS', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: 'CREATEUSER',
name: 'CREATEUSER', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: 'PRINTUSER',
name: 'PRINTUSER', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: 'COMPANYID',
name: 'COMPANYID', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: 'YEAR',
name: 'YEAR', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: 'MONTH',
name: 'MONTH', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: 'DAY',
name: 'DAY', flex: 0, hidden: true, margins: '0'
},
{
fieldLabel: '编号',
readOnly: true,
flex: 1,
name: 'BILLNO'
}, {
fieldLabel: '状态',
flex: 1,
readOnly: true,
name: 'BILLSTATUSREF'
},
{
fieldLabel: '是否打印',
flex: 1,
readOnly: true,
name: 'ISPRINT'
},
{
fieldLabel: '是否作废',
flex: 1,
readOnly: true,
name: 'ISDELETE'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxBANKID, this.comboxInvNo, this.comboxCurr, {
fieldLabel: '开票金额',
name: 'CHEQUEAMOUNT',
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
try {
var lsValue = usMoney(value, 2, '', false);
if (lsValue != "NaN") {
value = lsValue; if (parseFloat(lsValue) < 0) {
return '<SPAN style="COLOR: red">' + lsValue + '</SPAN>';
}
}
else {
return value;
}
}
catch (e) {
return value;
}
return value;
},
listeners: {
change: function () {
var basicForm = _this.formEdit.getForm();
var newValue = basicForm.findField('CHEQUEAMOUNT').getValue();
var curr = basicForm.findField('CHEQUECURRENCY').getValue();
if (curr == 'USD')
basicForm.findField('CHEQUEAMOUNTUPPER').setValue('美元' + formatUSD(newValue));
else
basicForm.findField('CHEQUEAMOUNTUPPER').setValue(_this.numtoc(newValue));
},
scope: this
}
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxCustCode, {
fieldLabel: '开票日期',
xtype: 'datefield',
format: 'Y-m-d',
name: 'CHEQUEMAKETIME',
listeners: {
change: function () {
_this.datechange();
}
}
}, this.comboxInvCategory,
{
fieldLabel: '开票人',
readOnly: true,
name: 'CREATEUSERREF'
}
]
}
]//end items(fieldset 1)
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{//fieldset 1
xtype: 'fieldset',
defaultType: 'textfield',
flex: 1, layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaults: {
anchor: '100%'
},
defaultType: 'textfield',
items: [{
fieldLabel: '年',
flex: 1, labelAlign: 'right',
name: 'YEARUPPER'
}, {
fieldLabel: '月',
flex: 1, labelAlign: 'right',
name: 'MONTHUPPER'
}, {
fieldLabel: '日',
flex: 1, labelAlign: 'right',
name: 'DAYUPPER'
}]
}, {
fieldLabel: '收款单位',
flex: 3, name: 'CHEQUECUSTNAME'
}, {
fieldLabel: '金额大写',
flex: 3,
name: 'CHEQUEAMOUNTUPPER'
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '用途',
name: 'PURPOSE'
}, {
fieldLabel: '密码',
name: 'PASSWORD'
}]
}
]
}, {//fieldset 1
xtype: 'fieldset',
defaultType: 'textfield',
flex: 1,
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
flex: 1,
defaultType: 'textfield',
items: [this.comboxBANK]
}, {
xtype: 'container',
layout: 'hbox',
flex: 1,
defaultType: 'textfield',
items: [{
fieldLabel: '银行账号',
name: 'PAYBANKACCOUNT'
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxCustBank, {
fieldLabel: '收款账号',
name: 'PAYEEBANKACCOUNT'
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '收款单位地址',
flex: 2,
name: 'PAYEEADR'
}]
}
]
}]
}
]//end root items
}); //end this.formEdit
//#endregion
//#region 按钮Toolbar
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
id: 'btnESave',
text: "保存",
iconCls: "btnsave",
handler: function (button, event) {
this.Save('0');
},
scope: this
}, '-',
{
text: "打印",
handler: function (button, event) {
this.Print();
},
scope: this
},
'-',
{
id: 'btnESaveAndClose',
text: "保存并关闭",
handler: function (button, event) {
this.Save('1');
},
scope: this
},
'-',
{
id: 'btnESaveAndNew',
text: "保存并新建",
handler: function (button, event) {
this.Save('2');
this.GetEditStatus();
},
scope: this
},
'-',
{
id: 'btnENew',
text: "新建",
handler: function (button, event) {
this.LoadData('add', '*');
},
scope: this
}, '-', {
text: '锁定',
tooltip: '锁定',
id: 'btnSubmitAudit',
handler: function (button, event) {
this.onSubmitAuditClick();
},
scope: this
}, '-', {
text: '撤销锁定',
tooltip: '撤销锁定',
id: 'btnSubmitAuditBack',
handler: function (button, event) {
this.onSubmitAuditBackClick();
},
scope: this
}, '-', {
text: '复制新建',
tooltip: '复制新建',
id: 'btnCopyAndCreate',
handler: function (button, event) {
this.CopyAndCreate();
},
scope: this
}
]
}); //end 按钮Toolbar
//#endregion
//#endregion
//#region 布局
//控件布局
Ext.apply(this, {
items: [this.panelBtn, this.formEdit]
});
//#endregion
//绑定查询窗体
this.ParentWin = window.parent.opener;
//初始化数据
this.InitData();
//绑定事件
var billno = '*';
if (this.opStatus == 'edit') {
billno = this.editRecord.get('BILLNO');
};
}, //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 = " BILLNO='" + this.editRecord.get('BILLNO') + "'";
this.LoadData(this.opStatus, condition);
}, //end InitData
LoadData: function (opstatus, condition) {
var basicForm = this.formEdit.getForm();
var dataorg = basicForm.getValues();
this.serialNo = 0;
this.workSerialNo = 0;
this.bodyDel = [];
this.opStatus = opstatus;
_this = this;
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/Account/Chfee_cheque/GetData',
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().findField('BILLSTATUS').setDisabled(false);
_this.formEdit.getForm().reset();
_this.formEdit.getForm().setValues(data);
// _this.formEdit.getForm().findField('BILLSTATUS').setDisabled(true);
_this.GetEditStatus();
if (opstatus == "add") {
_this.datechange();
}
if (opstatus == "copy") {
this.formEdit.getForm().reset();
this.formEdit.getForm().setValues(dataorg);
this.formEdit.getForm().findField('BILLNO').setValue('*');
this.formEdit.getForm().findField('GID').setValue('');
this.formEdit.getForm().findField('ISPRINT').setValue('否');
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
}, // end LoadDate
Save: function (type) {
var basicForm = this.formEdit.getForm();
if (!basicForm.isValid()) {
return;
}
this.formEdit.getForm().findField('GID').setDisabled(false);
// this.formEdit.getForm().findField('BILLSTATUS').setDisabled(false);
this.formEdit.getForm().findField('COMPANYID').setDisabled(false);
var data = basicForm.getValues();
var GID = this.formEdit.getForm().findField('GID').getValue();
// this.formEdit.getForm().findField('BILLSTATUS').setDisabled(true);
this.formEdit.getForm().findField('COMPANYID').setDisabled(true);
this.formEdit.getForm().findField('GID').setDisabled(true);
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Account/Chfee_cheque/Save',
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('MsChCheque', 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';
} else if (type == '1') {
window.close();
} else {
this.LoadData('add', '');
}
} 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
datechange: function () {
var basicForm = _this.formEdit.getForm();
var STARTDATE = basicForm.findField('CHEQUEMAKETIME').getRawValue();
var year = STARTDATE.substr(0, 4);
var month = STARTDATE.substr(5, 2);
var date = STARTDATE.substr(8, 2);
var yearstr = _this.UppTime(year);
var monthstr = _this.UppTime(month, 1);
var datestr = _this.UppTime(date, 2);
basicForm.findField('YEARUPPER').setValue(yearstr);
basicForm.findField('MONTHUPPER').setValue(monthstr);
basicForm.findField('DAYUPPER').setValue(datestr);
basicForm.findField('YEAR').setValue(year);
basicForm.findField('MONTH').setValue(month);
basicForm.findField('DAY').setValue(date);
},
deleteBill: function (type) {
var billno = this.formEdit.getForm().findField('BILLNO').getValue();
var GID = this.formEdit.getForm().findField('GID').getValue();
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 ISDELETE = this.formEdit.getForm().findField('ISDELETE').getValue();
var ISPRINT = this.formEdit.getForm().findField('ISPRINT').getValue();
if (ISPRINT == 'true') {
Ext.Msg.show({ title: '提示', msg: '已打印无法修改此发票,只能作废!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
if (ISDELETE == 'true') {
Ext.Msg.show({ title: '提示', msg: '此发票已作废无法修改此发票!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var sql = this.BillSql;
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/Account/Chfee_cheque/DelBill',
params: {
billno: billno,
GID: GID
},
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;
} else {
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/Account/Chfee_cheque/GetData',
params: {
handle: 'edit',
condition: " BILLNO='" + billno + "'"
},
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);
var editp = Ext.create('MsChCheque', data);
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();
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
},
DeleteInv: function (type) {
var billno = this.formEdit.getForm().findField('BILLNO').getValue();
var GID = this.formEdit.getForm().findField('GID').getValue();
var ISDELETE = this.formEdit.getForm().findField('ISDELETE').getValue();
var ISPRINT = this.formEdit.getForm().findField('ISPRINT').getValue();
if (ISDELETE == 'true') {
Ext.Msg.show({ title: '提示', msg: '此发票已作废无法删除此支票!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var sql = this.BillSql;
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/Account/Chfee_cheque/DeleteUp',
params: {
billno: billno,
isprint: ISPRINT
},
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;
} else {
if (ISPRINT == "true") {
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/Account/Chfee_cheque/GetData',
params: {
handle: 'edit',
condition: " BILLNO='" + billno + "'"
},
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);
var editp = Ext.create('MsChCheque', data);
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();
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
}
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
},
onSubmitAuditClick: function () {
var billno = this.formEdit.getForm().findField('BILLNO').getValue();
var GID = this.formEdit.getForm().findField('GID').getValue();
var billstatus = this.formEdit.getForm().findField('BILLSTATUS').getValue();
var Duino = this.formEdit.getForm().findField('BILLNO').getValue();
if (Duino == '*') {
Ext.Msg.show({ title: '提示', msg: '请先保存发票,然后才能锁定!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
};
if ((billstatus != 0)) {
Ext.Msg.show({ title: '提示', msg: '当前状态无法锁定!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
_this = this;
Ext.Ajax.request({
waitMsg: '正在添加数据...',
url: '/Account/Chfee_cheque/Lock',
params: {
bill: Duino
},
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;
} else {
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/Account/Chfee_cheque/GetData',
params: {
handle: 'edit',
condition: " BILLNO='" + billno + "'",
isapp: false
},
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);
var editp = Ext.create('MsChCheque', data);
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();
this.GetEditStatus();
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
},
onSubmitAuditBackClick: function () {
var billno = this.formEdit.getForm().findField('BILLNO').getValue();
var GID = this.formEdit.getForm().findField('GID').getValue();
var Duino = this.formEdit.getForm().findField('BILLNO').getValue();
var billstatus = this.formEdit.getForm().findField('BILLSTATUS').getValue();
if (Duino == '*') {
Ext.Msg.show({ title: '提示', msg: '请先保存付费结算,然后才能撤销锁定!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
};
if (billstatus != 1) {
Ext.Msg.show({ title: '提示', msg: '当前状态无法撤销锁定!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
_this = this;
Ext.Ajax.request({
waitMsg: '正在添加数据...',
url: '/Account/Chfee_cheque/UnLock',
params: {
bill: Duino
},
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;
} else {
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/Account/Chfee_cheque/GetData',
params: {
handle: 'edit',
condition: " BILLNO='" + billno + "'"
},
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);
var editp = Ext.create('MsChCheque', data);
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();
this.GetEditStatus();
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
},
CopyAndCreate: function () {
this.LoadData('copy', '*');
},
numtoc: function (numberValue, curr) {
numberValue = parseFloat(numberValue).toFixed(2);
var numberValue = new String(Math.round(numberValue * 100)); // 数字金额
var chineseValue = ""; // 转换后的汉字金额
var String1 = "零壹贰叁肆伍陆柒捌玖"; // 汉字数字
var String2 = "万仟佰拾亿仟佰拾万仟佰拾元角分"; // 对应单位
var len = numberValue.length; // numberValue 的字符串长度
var Ch1; // 数字的汉语读法
var Ch2; // 数字位的汉字读法
var nZero = 0; // 用来计算连续的零值的个数
var String3; // 指定位置的数值
if (len > 15) {
alert("超出计算范围");
return "";
}
if (numberValue == 0) {
chineseValue = "零元整";
return chineseValue;
}
String2 = String2.substr(String2.length - len, len); // 取出对应位数的STRING2的值
for (var i = 0; i < len; i++) {
String3 = parseInt(numberValue.substr(i, 1), 10); // 取出需转换的某一位的值
if (i != (len - 3) && i != (len - 7) && i != (len - 11) && i != (len - 15)) {
if (String3 == 0) {
Ch1 = "";
Ch2 = "";
nZero = nZero + 1;
}
else if (String3 != 0 && nZero != 0) {
Ch1 = "零" + String1.substr(String3, 1);
Ch2 = String2.substr(i, 1);
nZero = 0;
}
else {
Ch1 = String1.substr(String3, 1);
Ch2 = String2.substr(i, 1);
nZero = 0;
}
}
else { // 该位是万亿,亿,万,元位等关键位
if (String3 != 0 && nZero != 0) {
Ch1 = "零" + String1.substr(String3, 1);
Ch2 = String2.substr(i, 1);
nZero = 0;
}
else if (String3 != 0 && nZero == 0) {
Ch1 = String1.substr(String3, 1);
Ch2 = String2.substr(i, 1);
nZero = 0;
}
else if (String3 == 0 && nZero >= 3) {
Ch1 = "";
Ch2 = "";
nZero = nZero + 1;
}
else {
Ch1 = "";
Ch2 = String2.substr(i, 1);
nZero = nZero + 1;
}
if (i == (len - 11) || i == (len - 3)) { // 如果该位是亿位或元位,则必须写上
Ch2 = String2.substr(i, 1);
}
}
chineseValue = chineseValue + Ch1 + Ch2;
}
if (String3 == 0) { // 最后一位为0时加上“整”
chineseValue = chineseValue + "整";
}
return chineseValue;
},
UppTime: function (iiv_, md_) { //票据出票日期中文大写
var arr13 = new Array('零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖', '', '拾', '佰', '仟', '万', '亿', '元', '角', '分', '整', '负');
var iNun_ = new String(iiv_).split(".")[0].split(""), iLen_ = iNun_.length, iNum_ = new Array(iLen_);
if (iiv_ > 999 && iiv_ < 9999) { for (ii_ = 0; ii_ < iLen_; ii_++) { iNum_[iLen_ - 1 - ii_] = arr13[iNun_[iLen_ - 1 - ii_]] } }
else if (iiv_ > 0 && iiv_ < 32) {
for (ii_ = 0; ii_ < iLen_; ii_++) {
iNum_[iLen_ - 1 - ii_] = (iNun_[iLen_ - 1 - ii_] == 0) ? (ii_ == 0 ?
(iLen_ > 1 ? "" : arr13[0]) : (iNun_[iLen_ - ii_] == 0 ? "" : arr13[0])) : (arr13[iNun_[iLen_ - 1 - ii_]] + arr13[10 + ii_])
}
} else { iNum_[0] = "" }
return (((iiv_ > 0 && iiv_ < (md_ == 1 ? 3 : 10)) || iiv_ == 10 || iiv_ == 20 || iiv_ == 30) ? arr13[0] : "") + iNum_.join("");
}
,
// #region 根据权限和状态判断是否允许修改
GetIsEdit: function () {
var ISDELETE = this.formEdit.getForm().findField('ISDELETE').getValue();
var ISPRINT = this.formEdit.getForm().findField('ISPRINT').getValue();
var BILLSTATUS = this.formEdit.getForm().findField('BILLSTATUS').getValue();
if ((ISDELETE == '是') || (ISPRINT == '是') || (BILLSTATUS != 2)) return false;
else return true;
},
GetEditStatus: function () {
var canedit = false;
var op = this.formEdit.getForm().findField('CREATEUSERREF').getValue();
var billstatus = this.formEdit.getForm().findField('BILLSTATUS').getValue();
_this = this;
var isEdit = this.GetIsEdit();
if (isEdit == false) {
canedit = false;
this.setSaveBtnStatus(canedit);
} else {
this.StoreOpRange.load({ params: { optype: "modCheque" },
callback: function (r, options, success) {
if (success) {
if (r.length != 0) {
var records = DsStoreQueryBy(_this.StoreOpRange, 'OPID', op);
if (records.getCount() > 0) {
canedit = true;
} else {
canedit = false;
}
_this.setSaveBtnStatus(canedit);
}
}
}
});
}
var opid = this.formEdit.getForm().findField('CREATEUSER').getValue();
var btnESubmitAudit = Ext.getCmp('btnSubmitAudit');
var btnESubmitAuditBack = Ext.getCmp('btnSubmitAuditBack');
var records = DsStoreQueryBy(this.StoreLockOp, 'OPID', opid);
if (records.getCount() > 0) {
if (billstatus == 1) {
btnESubmitAudit.disable();
} else {
btnESubmitAudit.enable();
}
} else {
btnESubmitAudit.disable();
}
var records = DsStoreQueryBy(this.StoreUnLockOp, 'OPID', opid);
if (records.getCount() > 0) {
if (billstatus == 1) {
btnESubmitAuditBack.enable();
} else {
btnESubmitAuditBack.disable();
}
} else {
btnESubmitAuditBack.disable();
}
},
setSaveBtnStatus: function (enable) {
var btnESave = Ext.getCmp('btnESave');
var btnESaveAndClose = Ext.getCmp('btnESaveAndClose');
var btnESaveAndNew = Ext.getCmp('btnESaveAndNew');
if (enable) {
btnESave.enable();
btnESaveAndClose.enable();
btnESaveAndNew.enable();
} else {
btnESave.disable();
btnESaveAndClose.disable();
btnESaveAndNew.disable();
}
},
// #endregion
Print: function () {
var basicForm = this.formEdit.getForm();
var billNo = basicForm.findField('BILLNO').value;
var Gid = basicForm.findField('GID').value;
if (billNo == '*' || billNo == '' || basicForm.isDirty()) {
Ext.Msg.show({ title: '错误', msg: '单据还没有保存,请保存后再打印', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var printType = 'MSCHFEECHEQUE';
var sql1 = "SELECT * FROM ch_fee_cheque WHERE GID='" + Gid + "'";
var sql2 = "";
var sql3 = "";
var sql4 = "";
var sql5 = "";
var sql6 = "";
PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6);
Ext.Ajax.request({
waitMsg: '正在查询数据...',
url: '/Account/Chfee_cheque/UpdatePrint',
async: false,
params: {
billno: billNo
},
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;
} else {
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/Account/Chfee_cheque/GetData',
params: {
handle: 'edit',
condition: " BILLNO='" + billno + "'",
isapp: false
},
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);
var editp = Ext.create('MsChCheque', data);
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();
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
}
});