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/Account/Viewsjs/Chfee_invoice/ChInvoiceEdit.js

3758 lines
139 KiB
JavaScript

3 years ago
Ext.namespace('Shipping');
Shipping.MsChInvoiceEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsChInvoiceEdit.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsChInvoiceEdit, 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: "modInvLock"} });
this.StoreUnLockOp = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsFeeOP',
proxy: { url: '/MvcShipping/MsBaseInfo/GetOpIDRang' }
});
this.StoreUnLockOp.load({ params: { optype: "modInvUnLock"} });
//#region 编辑form
//枚举参照相关(编辑form)
//表参照相关(编辑form)
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 recs = DsStoreQueryBy(this.storeCustCode, 'CustName', records[0].data.CustName);
var INVOICECUSTNAME = this.formEdit.getForm().findField('INVOICECUSTNAME');
var CUSTRATENO = this.formEdit.getForm().findField('CUSTRATENO');
var CUSTADDRTEL = this.formEdit.getForm().findField('CUSTADDRTEL');
var CUSTBANK = this.formEdit.getForm().findField('CUSTBANK');
var CURR = this.formEdit.getForm().findField('CURRENCY').getValue();
if (recs.getCount() > 0) {
var data = recs.getAt(0).data;
INVOICECUSTNAME.setValue(data.BillRises1);
CUSTRATENO.setValue(data.TaxNo);
CUSTADDRTEL.setValue(data.Addr + ' ' + data.Tel);
if (CURR == 'RMB') {
CUSTBANK.setValue(data.RMBBank + ' ' + data.RMBAccount);
} else if (CURR == 'USD') {
CUSTBANK.setValue(data.USDBank + ' ' + data.USDAccount);
}
} else {
INVOICECUSTNAME.setValue('');
CUSTRATENO.setValue('');
CUSTADDRTEL.setValue('');
CUSTBANK.setValue('');
}
var CUSTOMERNAME = this.formEdit.getForm().findField('CUSTOMERNAME').getValue();
if (CUSTOMERNAME == '') return;
var CUSTNAME = this.formSearch.getForm().findField('CUSTNAME');
var tmpcust = CUSTNAME.getValue();
if (tmpcust == '' || tmpcust == null || tmpcust == undefined) {
CUSTNAME.setValue(CUSTOMERNAME);
}
}
}
}
});
this.storeInvCustCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomInvRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomInvRefList' }
});
this.storeInvCustCode.load({ params: { condition: ""} });
this.comboxInvCustCode = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '代开客户',
store: this.storeInvCustCode,
forceSelection: true,
name: 'ACTUALCUSTOMERNAME',
valueField: 'CustName',
displayField: 'CodeAndName',
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (records.length > 0) {
var recs = DsStoreQueryBy(this.storeInvCustCode, 'CustName', records[0].data.CustName);
var INVOICECUSTNAME = this.formEdit.getForm().findField('INVOICECUSTNAME');
var CUSTRATENO = this.formEdit.getForm().findField('CUSTRATENO');
var CUSTADDRTEL = this.formEdit.getForm().findField('CUSTADDRTEL');
var CUSTBANK = this.formEdit.getForm().findField('CUSTBANK');
var CURRFIELD = this.formEdit.getForm().findField('CURRENCY');
var CURR = CURRFIELD.getValue();
if (recs.getCount() > 0) {
var data = recs.getAt(0).data;
INVOICECUSTNAME.setValue(data.BillRises1);
CUSTRATENO.setValue(data.TaxNo);
CUSTADDRTEL.setValue(data.Addr + ' ' + data.Tel);
if (CURR == 'RMB') {
CUSTBANK.setValue(data.RMBBank + ' ' + data.RMBAccount);
} else if (CURR == 'USD') {
CUSTBANK.setValue(data.USDBank + ' ' + data.USDAccount);
}
} else {
INVOICECUSTNAME.setValue('');
CUSTRATENO.setValue('');
CUSTADDRTEL.setValue('');
CUSTBANK.setValue('');
}
}
}
}
});
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,
labelWidth: 60,
name: 'CURRENCY',
valueField: 'CURR',
displayField: 'CURR',
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (records.length > 0) {
var CUSTOMERNAME = this.formEdit.getForm().findField('ACTUALCUSTOMERNAME').getValue();
if (CUSTOMERNAME == '') {
CUSTOMERNAME = this.formEdit.getForm().findField('CUSTOMERNAME').getValue();
}
if (CUSTOMERNAME == '') return;
var CURR = records[0].data.CURR;
var CUSTBANK = this.formEdit.getForm().findField('CUSTBANK');
var recs = DsStoreQueryBy(this.storeInvCustCode, 'CustName', CUSTOMERNAME);
if (recs.getCount() > 0) {
var data = recs.getAt(0).data;
if (CURR == 'RMB') {
CUSTBANK.setValue(data.RMBBank + ' ' + data.RMBAccount);
} else if (CURR == 'USD') {
CUSTBANK.setValue(data.USDBank + ' ' + data.USDAccount);
}
} else {
CUSTBANK.setValue('');
}
}
}
}
});
this.storeInvCategory = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsExtEnumModel',
proxy: { url: '/CommMng/PubSys/GetEnumValueList' }
});
this.storeInvCategory.load({ params: { enumTypeId: 97008} });
this.comboxInvCategory = Ext.create('DsExt.ux.RefTableCombox', {
2 years ago
fieldLabel: '发票类型',//'类型'
3 years ago
store: this.storeInvCategory,
forceSelection: true,
name: 'INVOICECATEGORY',
valueField: 'EnumValueId',
displayField: 'EnumValueName'
});
this.StoreInvNo = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsChInvoiceNo',
proxy: { url: '/Account/Chfee_invoice/GetInvoiceNo' }
});
this.StoreInvNo.load({ params: { condition: ""} });
this.comboxInvNo = Ext.create('DsExt.ux.RefTableCombox', {
store: this.StoreInvNo,
fieldLabel: '发票号',
flex: 2,
name: 'INVOICENO',
valueField: 'INVNO',
displayField: 'INVNO'
});
//编辑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: 'VOUCHERNO',
name: 'VOUCHERNO', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: 'VOUNO',
name: 'VOUNO', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: 'APPLICANT',
name: 'APPLICANT', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: 'OPERATOR',
name: 'OPERATOR', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: 'COMPANYID',
name: 'COMPANYID', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: 'INVOICETYPE',
value: '1',
name: 'INVOICETYPE', flex: 0, hidden: true, margins: '0'
},
{
fieldLabel: '编号',
readOnly: true,
hidden: true,
flex: 2,
name: 'BILLNO'
},
{
fieldLabel: '发票类别',
readOnly: true,
flex: 2,
name: 'INVOICETYPEREF'
}, this.comboxInvNo, {
fieldLabel: '开票日期',
flex: 2,
readOnly: true,
name: 'INVOICEMAKETIME'
},
{
fieldLabel: '开票人',
flex: 2,
readOnly: true,
name: 'OPERATORNAME'
},
{
fieldLabel: '是否锁定',
flex: 1,
readOnly: true,
name: 'BILLSTATUSREF'
},
{
fieldLabel: '是否打印',
flex: 1,
readOnly: true,
name: 'ISNEEDPRINT'
},
{
fieldLabel: '是否结算',
flex: 1,
readOnly: true,
name: 'ISNEEDFEE'
},
{
fieldLabel: '是否作废',
flex: 1,
readOnly: true,
name: 'ISDELETE'
}
]
}
]//end items(fieldset 1)
}, //end fieldset 1
{
xtype: 'fieldset',
defaultType: 'textfield',
layout: 'hbox',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'anchor',
flex: 3,
defaultType: 'textfield',
items: [
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '发票抬头',
name: 'INVOICECUSTNAME'
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '纳税人识别号',
name: 'CUSTRATENO'
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '地址、电话',
name: 'CUSTADDRTEL'
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '开户行及账号',
name: 'CUSTBANK'
}]
}
]
}, {
xtype: 'fieldset',
defaultType: 'textfield',
flex: 5,
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
flex: 1,
defaultType: 'textfield',
items: [this.comboxCurr, this.comboxInvCategory, this.comboxCustCode, this.comboxInvCustCode]
}, {
xtype: 'container',
layout: 'hbox',
flex: 1,
defaultType: 'textfield',
items: [{
fieldLabel: '实际金额',
labelWidth: 60,
name: 'AMOUNT',
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;
}
}, {
fieldLabel: '开票金额',
name: 'INVAMOUNT',
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;
}
}, {
fieldLabel: '开票税率',
name: 'EXCHANGERATE'
}, {
fieldLabel: '外币金额',
name: 'OTCURRAMOUNT',
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;
}
}]
}
, {
xtype: 'container',
layout: 'hbox',
flex: 2,
defaultType: 'textfield',
items: [{
xtype: 'textareafield',
grow: true,
labelWidth: 60,
name: 'REMARK',
fieldLabel: '备注',
anchor: '100%'
}]
}
]
}
]//end items(fieldset 2)
}
]//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
}
]
}); //end 按钮Toolbar
//#endregion
//#region发票明细
this.GridDetailCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
//明细表-数据集
this.storeDetailList = Ext.create('Ext.data.Store', {
model: 'MsChInvoiceDetail',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/Account/Chfee_invoice/GetDetailList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//明细表表格
this.gridDetailCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.gridDetailList = new Ext.grid.GridPanel({
store: this.storeDetailList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
// columnLines: true,
selModel: this.GridDetailCheckBoxModel,
plugins: [this.gridDetailCellEditing],
features: [{
ftype: 'summary'//Ext.grid.feature.Summary表格汇总特性
}],
tbar: [{
text: '添加发票明细',
tooltip: '添加发票明细',
id: 'btnAddInvdetail',
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddInvDetailClick();
},
scope: this
}, {
text: '删除发票明细',
tooltip: '删除发票明细',
id: 'btndelInvdetail',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelInvDetailClick();
},
scope: this
}],
columns: [{
sortable: true,
dataIndex: 'GID',
header: 'GID',
hidden: true,
width: 100
}, {
sortable: true,
dataIndex: 'PID',
header: 'PID',
hidden: true,
width: 100
}, {
sortable: true,
dataIndex: 'SERIALNO',
header: 'SERIALNO',
hidden: true,
width: 100
}, {
sortable: false,
dataIndex: 'GOODSNAME',
header: '货物或应税劳务名称',
editor: {
xtype: 'textfield',
allowBlank: false,
selectOnFocus: true
},
summaryType: 'count',
width: 120
}, {
sortable: false,
dataIndex: 'SPEC',
header: '规格型号',
editor: {
xtype: 'textfield',
allowBlank: false,
selectOnFocus: true
},
width: 120
}, {
sortable: false,
dataIndex: 'UNIT',
header: '单位',
editor: {
xtype: 'textfield',
allowBlank: false,
selectOnFocus: true
},
width: 100
}, {
sortable: false,
dataIndex: 'PKGS',
header: '数量',
editor: {
xtype: 'numberfield',
allowBlank: false,
selectOnFocus: true
},
width: 80
}, {
sortable: false,
dataIndex: 'TAXPRICE',
header: '含税单价',
editor: {
xtype: 'numberfield',
allowBlank: false,
selectOnFocus: true
},
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;
},
width: 80
}, {
sortable: false,
dataIndex: 'PRICE',
header: '单价',
editor: {
xtype: 'numberfield',
allowBlank: false,
selectOnFocus: true
},
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;
},
width: 80
}, {
sortable: false,
dataIndex: 'AMOUNT',
editor: {
xtype: 'numberfield',
allowBlank: false,
selectOnFocus: true
},
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;
},
summaryType: 'sum',
header: '金额',
width: 80
}, {
sortable: false,
dataIndex: 'TAXRATE',
editor: {
xtype: 'numberfield',
allowBlank: false,
selectOnFocus: true
},
header: '税率',
width: 80
}, {
sortable: false,
dataIndex: 'TAX',
header: '税额',
editor: {
xtype: 'numberfield',
allowBlank: false,
selectOnFocus: true
},
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;
},
summaryType: 'sum',
width: 80
}
]
});
this.gridDetailList.on('edit', function (editor, e, eOpts) {
this.gridListDetailAfterEdit(editor, e, eOpts);
}, this);
//#endregion
this.formAMT = Ext.widget('form', {
region: 'south',
frame: false,
bodyPadding: 0,
height: 35,
trackResetOnLoad: true,
fieldDefaults: {
margins: '2 2 0 0',
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: '金额合计(大写)',
readOnly: true,
name: 'AMOUNTCAPITAL'
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
}]
}); //end this.formEdit
//#region 明细表
//明细表表格相关
this.GridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
//明细表-数据集
this.storeBodyList = Ext.create('Ext.data.Store', {
model: 'Chfee_do_detail',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/Account/Chfee_invoice/GetBillList',
reader: {
id: 'BSNO,FEEDOID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//明细表表格
this.gridListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.gridList = new Ext.grid.GridPanel({
store: this.storeBodyList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
selModel: this.GridCheckBoxModel,
tbar: [{
text: '删除明细',
tooltip: '删除明细',
id: 'btndeldetail',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDeleteClick(button, event, 1);
},
scope: this
}],
columns: [{
sortable: true,
dataIndex: 'BILLNO',
header: 'BILL',
hidden: true,
width: 100
}, {
sortable: true,
dataIndex: 'BSNO',
header: 'BSNO',
hidden: true,
width: 100
}, {
sortable: true,
dataIndex: 'FEEDOID',
header: 'FEEDOID',
hidden: true,
width: 100
}, {
sortable: true,
dataIndex: 'CUSTNO',
header: '委托编号',
width: 120
}, {
sortable: true,
dataIndex: 'MBLNO',
header: '主提单号',
width: 120
}, {
sortable: true,
dataIndex: 'CUSTOMERNAME',
header: '委托单位',
width: 100
}, {
sortable: true,
dataIndex: 'ETD',
header: '开船日期',
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
width: 100
}, {
sortable: true,
dataIndex: 'BSSOURCE',
header: '业务来源',
width: 80
}, {
sortable: true,
dataIndex: 'FEENAME',
header: '费用名称',
width: 80
}, {
sortable: true,
dataIndex: 'FEETYPEREF',
header: '收付',
width: 40
}, {
sortable: true,
dataIndex: 'AMOUNT',
header: '申请金额',
width: 80,
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;
}
}, {
sortable: true,
dataIndex: 'ORIGCURRENCY',
header: '原始币别',
width: 80
}, {
sortable: true,
dataIndex: 'ORIGAMOUNT',
header: '原始金额',
width: 80,
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;
}
}, {
sortable: true,
dataIndex: 'SALE',
header: '揽货人',
width: 80
}
]
});
this.storeBodySum = Ext.create('Ext.data.Store', {
model: 'Chfee_do_sum',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/Account/Chfee_invoice/GetBillSum',
reader: {
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.gridSum = new Ext.grid.GridPanel({
store: this.storeBodySum,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
tbar: [{
xtype: 'label',
width: 120,
height: 22,
text: '开票金额合计'
}],
columns: [{
sortable: true,
dataIndex: 'FEETYPEREF',
header: '收付',
width: 40
}, {
sortable: true,
dataIndex: 'CURRENCY',
header: '币 别',
width: 80
}, {
sortable: true,
dataIndex: 'AMOUNT',
header: '金额',
width: 80,
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;
}
}
]
});
this.storeAddFeeList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'MsChFeeAddBillFee',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/Account/Chfee_invoice/GetFeeDataList',
reader: {
id: 'BSNO',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.AddFeeGridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
this.cellEditingFee = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1,
listeners: {
'edit': function (editor, e) {
}
}
});
_this = this;
this.FeeGroup = new Ext.form.RadioGroup({
id: 'FeeGroup',
xtype: 'radiogroup',
fieldLabel: '发票明细',
labelWidth: 90,
columns: 2,
items: [
{ boxLabel: '费用合计', name: 'Curr', inputValue: 'false', checked: true },
{ boxLabel: '费用列表', name: 'Curr', inputValue: 'true' }
]
});
this.gridAddFeeList = new Ext.grid.GridPanel({
store: this.storeAddFeeList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.cellEditingFee],
selModel: this.AddFeeGridCheckBoxModel,
tbar: [{
text: '添加发票费用明细',
tooltip: '添加发票费用明细',
iconCls: "btnadddetail",
id: "btnadddetail",
handler: function (button, event) {
this.onAddDetailClick(button, event);
},
scope: this
}, '-', this.FeeGroup],
columns: [{
sortable: true,
dataIndex: 'CH_ID',
header: 'CH_ID',
hidden: true,
width: 100
}, {
sortable: true,
dataIndex: 'BSNO',
header: 'BSNO',
hidden: true,
width: 100
}, {
sortable: true,
dataIndex: 'FeeObjName',
header: '客户名称',
width: 90
}, {
sortable: true,
dataIndex: 'FeeType_Ref',
header: '收付',
width: 40
}, {
sortable: true,
dataIndex: 'FeeName',
header: '费用名称',
width: 90
}, {
sortable: true,
dataIndex: 'Amount',
header: '金额',
width: 70,
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;
}
}, {
sortable: true,
dataIndex: 'Currency',
header: '币别',
width: 40
}, {
sortable: true,
dataIndex: 'BalAmount',
header: '未申金额',
width: 70,
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;
}
}, {
sortable: true,
dataIndex: 'StlAmount',
header: '本次申请金额',
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
allowDecimals: true,
decimalPrecision: 2,
selectOnFocus: true,
mouseWheelEnabled: false,
enableKeyEvents: true,
listeners: {
keydown: function (textfield, e) {
if (e.getKey() == 40) {
_this.onNextKeyClick(9)
} else if (e.getKey() == 38) {
_this.onUpKeyClick(9)
}
}
}
},
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;
},
width: 70
}, {
sortable: true,
dataIndex: 'AccTaxRate',
header: '进项税率',
width: 60
}, {
sortable: true,
dataIndex: 'ExChangerate',
header: '原始汇率',
width: 60
}, {
sortable: true,
dataIndex: 'OPLBNAME',
header: '业务类别',
width: 80
}, {
sortable: true,
dataIndex: 'CUSTNO',
header: '委托编号',
width: 108
}, {
sortable: true,
dataIndex: 'MBLNO',
header: '主提单号',
width: 108
}, {
sortable: true,
dataIndex: 'CUSTOMERNAME',
header: '委托单位',
width: 100
}, {
sortable: true,
dataIndex: 'CUSTOMNO',
header: '报关单号',
width: 108
}, {
sortable: true,
dataIndex: 'ETD',
header: '开船日期',
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
width: 100
}, {
sortable: true,
dataIndex: 'SALE',
header: '揽货人',
width: 80
}, {
sortable: true,
dataIndex: 'ACCDATE',
header: '会计期间',
width: 80
}, {
sortable: true,
dataIndex: 'OP',
header: '操作',
width: 80
}, {
sortable: true,
dataIndex: 'INPUTBY',
header: '录入人',
width: 80
}, {
sortable: true,
dataIndex: 'PORTLOAD',
header: '起运港',
width: 120
}, {
sortable: true,
dataIndex: 'PORTDISCHARGE',
header: '目的港',
width: 120
}, {
sortable: true,
dataIndex: 'VESSEL',
header: '船名',
width: 150
}, {
sortable: true,
dataIndex: 'VOYNO',
header: '航次',
width: 60
}
],
// paging bar on the bottom
bbar: Ext.create('Ext.PagingToolbar', {
store: this.storeAddFeeList,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
})
});
this.gridAddFeeList.addListener('itemdblclick', function (dataview, record, item, index, e, b) {
this.SelectedRecord = record;
var openSet = "height=700, width=1024, toolbar=no, menubar=no,scrollbars=1, resizable=1,location=no, status=no,Top= " + (screen.height - 750) / 2 + ",Left= " + (screen.width - 1100) / 2
var openType = "_blank";
var openUrl = "";
openUrl = "../../MvcShipping/MsOpBill/MsOpFeeView?handle=check&bsno=" + record.data.BSNO;
window.open(openUrl, openType, openSet);
// DsOpenEditWin("/TruckMng/MsWlPc/Edit");
}, this);
this.gridAddFeeList.on('edit', function (editor, e, eOpts) {
this.gridAddFeeListAfterEdit(editor, e, eOpts);
}, this);
_this = this;
this.gridAddFeeList.on({
selectionchange: function (sm, selections) {
_this.storeSelectSum.removeAll();
for (var i = 0; i < selections.length; i++) {
var rec = selections[i];
var isfind = false;
for (var j = 0; j < _this.storeSelectSum.getCount(); j += 1) {
var memberyf = _this.storeSelectSum.getAt(j);
if ((memberyf.data.FEETYPEREF == rec.data.FeeType_Ref) && (memberyf.data.CURRENCY == rec.data.Currency)) {
isfind = true;
var amount = memberyf.data.AMOUNT;
amount = (parseFloat(amount).add(parseFloat(rec.data.StlAmount))).toFixed(2);
memberyf.set("AMOUNT", amount);
memberyf.commit();
}
}
if (!isfind)
_this.storeSelectSum.add({ "FEETYPEREF": rec.data.FeeType_Ref, "CURRENCY": rec.data.Currency, "AMOUNT": rec.data.StlAmount });
}
}
});
this.storeAddBodySum = Ext.create('Ext.data.Store', {
model: 'Chfee_do_sum',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/Account/Chfee_invoice/GetAddSum',
reader: {
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.gridAddSum = new Ext.grid.GridPanel({
store: this.storeAddBodySum,
enableHdMenu: false,
anchor: '100% 50%',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
tbar: [{
xtype: 'label',
width: 120,
height: 22,
text: '未开票金额合计'
}],
columns: [{
sortable: true,
dataIndex: 'FEETYPEREF',
header: '收付',
width: 40
}, {
sortable: true,
dataIndex: 'CURRENCY',
header: '币 别',
width: 80
}, {
sortable: true,
dataIndex: 'AMOUNT',
header: '金额',
width: 80,
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;
}
}
]
});
this.storeSelectSum = Ext.create('Ext.data.Store', {
model: 'Chfee_do_sum'
});
this.gridSelectSum = new Ext.grid.GridPanel({
store: this.storeSelectSum,
enableHdMenu: false,
anchor: '100% 50%',
// region: 'south',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
tbar: [{
xtype: 'label',
width: 120,
height: 22,
text: '所选费用合计'
}],
columns: [{
sortable: true,
dataIndex: 'FEETYPEREF',
header: '收付',
width: 40
}, {
sortable: true,
dataIndex: 'CURRENCY',
header: '币 别',
width: 80
}, {
sortable: true,
dataIndex: 'AMOUNT',
header: '金额',
width: 80,
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;
}
}
]
});
this.storeCustCodefee = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomInvRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomInvRefList' }
});
this.storeCustCodefee.load({ params: { condition: ""} });
this.comboxAddCustCode = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '费用对象',
store: this.storeCustCodefee,
forceSelection: true,
name: 'CUSTNAME',
valueField: 'CustName',
displayField: 'CodeAndName'
});
this.StoreOpLb = Ext.create('Ext.data.Store', {
fields: ['OPLBNAME']
});
this.StoreOpLb.add({ "OPLBNAME": "海运出口" });
this.StoreOpLb.add({ "OPLBNAME": "海运进口" });
this.StoreOpLb.add({ "OPLBNAME": "报关业务" });
this.StoreOpLb.add({ "OPLBNAME": "进口贸易" });
this.StoreOpLb.add({ "OPLBNAME": "大宗散货" });
this.StoreOpLb.add({ "OPLBNAME": "综合业务" });
this.comboxOpLb = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '业务类别',
store: this.StoreOpLb,
valueField: 'OPLBNAME',
displayField: 'OPLBNAME',
forceSelection: true,
name: 'OPLBNAME'
});
this.storeAddDCType = Ext.create('Ext.data.Store', {
fields: ['DC', 'NAME']
});
this.storeAddDCType.add({ "DC": "", "NAME": "全部" });
this.storeAddDCType.add({ "DC": "1", "NAME": "应收" });
this.storeAddDCType.add({ "DC": "2", "NAME": "应付" });
this.comboxaddDCType = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '收/付',
store: this.storeAddDCType,
valueField: 'DC',
displayField: 'NAME',
readOnly: true,
forceSelection: true,
name: 'DC',
value: '1'
});
this.comboxCurr2 = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '币别',
store: this.StoreCurr,
forceSelection: true,
name: 'Currency',
valueField: 'CURR',
displayField: 'CURR'
});
this.storeFeeNameRef = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.FeeTypeRefModel',
proxy: { url: '/MvcShipping/MsChFee/GetFeeTypeRefList' }
});
this.comboxFeeNameRef = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '费用名称',
store: this.storeFeeNameRef,
forceSelection: true,
name: 'FeeName',
valueField: 'Name',
displayField: 'CodeAndName'
});
this.storeFeeNameRef.load({ params: { condition: ""} });
this.storeCurrExrate = Ext.create('Ext.data.Store', {
fields: ['CURR', 'EXRATE']
});
this.formSearch = Ext.widget('form', {
frame: true,
region: 'north',
bodyPadding: 5,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 90,
msgTarget: 'qtip'
},
items: [
{//fieldset 1
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxAddCustCode, this.comboxOpLb, {
fieldLabel: '编号检索',
name: 'CustomNo'
}, {
fieldLabel: '从业务日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'ExpDateBgn'
}, {
fieldLabel: '到业务日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'ExpDateEnd'
}, {
xtype: 'button',
width: 90,
text: "重置条件",
iconCls: "btnreset",
handler: function (button, event) {
this.onClearSql(button, event);
},
scope: this
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxaddDCType, this.comboxCurr2, this.comboxFeeNameRef, {
fieldLabel: '会计期间',
xtype: 'monthfield',
name: 'ACCDATEFR'
}, {
fieldLabel: '会计期间',
xtype: 'monthfield',
name: 'ACCDATETO'
}, {
xtype: 'button',
width: 90,
text: "执行查询",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onRefreshClick(button, event);
},
scope: this
}
]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
});
this.panelInvDetail = new Ext.Panel({
layout: "border",
// height: 220,
region: "center",
margin: '2 2',
items: [this.gridDetailList, this.formAMT]
});
this.panelService = new Ext.Panel({
layout: "border",
region: 'center',
margin: '2 2',
items: [this.gridList]
});
this.panelSum = new Ext.Panel({
layout: "border",
region: 'east',
width: 260,
split: true,
margin: '2 2',
items: [this.gridSum]
});
this.panelAddSum = new Ext.Panel({
layout: "anchor",
region: 'east',
width: 260,
split: true,
margin: '2 2',
items: [this.gridAddSum, this.gridSelectSum]
});
this.paneldetail = new Ext.Panel({
title: '申请明细',
layout: "border",
height: 220,
region: "north",
items: [
this.panelService, this.panelSum
]
});
this.panelAddService = new Ext.Panel({
layout: "border",
region: 'center',
margin: '2 2',
items: [this.gridAddFeeList, this.panelAddSum]
});
this.paneladd = new Ext.Panel({
title: '添加发票申请明细',
layout: "border",
// region: 'south',
region: "center",
// height: 420,
items: [
this.formSearch, this.panelAddService
]
});
//#endregion 明细表
//#region 布局
//控件布局
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 200,
items: [this.panelBtn, this.formEdit]
});
this.panelBody = new Ext.Panel({
title: "费用明细",
layout: "border",
region: "center",
items: [this.paneldetail]
});
this.panelInv = new Ext.Panel({
title: "发票明细",
layout: "border",
region: "center",
// height: 220,
items: [this.panelInvDetail]
});
this.tabpanel = new Ext.TabPanel
({
activeTab: 0,
autoWidth: true,
border: false,
frame: false,
height: 220,
region: 'north',
id: "TabPanelID",
enableTabScroll: true,
split: true,
items:
[
this.panelInv,
this.panelBody
]
});
Ext.apply(this, {
items: [this.panelTop, this.tabpanel, this.paneladd]
});
//#endregion
//绑定查询窗体
this.ParentWin = window.parent.opener;
//初始化数据
this.InitData();
//绑定事件
var billno = '*';
if (this.opStatus == 'edit') {
billno = this.editRecord.get('BILLNO');
};
this.storeBodyList.on('beforeload', function (store) {
var sql = " BILLNO='" + billno + "'";
Ext.apply(store.proxy.extraParams, { condition: sql });
}, this);
this.storeBodyList.on('load', function (store, records) {
if (store.getCount() > 0) {
this.gridList.getSelectionModel().select(0);
}
}, this);
this.storeAddFeeList.on('beforeload', function (store) {
var sql = this.getCondition();
Ext.apply(store.proxy.extraParams, { condition: this.BillSql });
}, this);
// this.storeBodyAddList.on('load', function (store, records) {
// if (store.getCount() > 0) {
// this.gridAddList.getSelectionModel().select(0);
// }
// }, this);
// this.gridAddList.getSelectionModel().on('select', function (model, record, index) {
// var bsno = record.data.BSNO;
// var sql = "";
// sql = " BSNO='" + bsno + "'";
// sql = sql + getAndConSql(sql, this.FeeSqlStr, this.FeeSqlStr);
// this.storeAddFeeList.load({ params: { condition: sql} });
// }, 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 = " BILLNO='" + this.editRecord.get('BILLNO') + "'";
this.LoadData(this.opStatus, condition);
}, //end InitData
LoadData: function (opstatus, condition) {
this.serialNo = 0;
this.workSerialNo = 0;
this.bodyDel = [];
this.opStatus = opstatus;
_this = this;
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/Account/Chfee_invoice/GetData',
params: {
handle: opstatus,
condition: condition,
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().findField('BILLSTATUS').setDisabled(false);
_this.formEdit.getForm().reset();
_this.formAMT.getForm().reset();
_this.formEdit.getForm().setValues(data);
_this.formAMT.getForm().setValues(data);
// _this.formEdit.getForm().findField('BILLSTATUS').setDisabled(true);
_this.GetEditStatus();
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
var billno = '*';
var GID = '*';
if (this.opStatus == 'edit') {
billno = this.editRecord.get('BILLNO');
GID = this.editRecord.get('GID');
};
this.storeBodyList.load({ params: { condition: " BILLNO='" + billno + "'" },
callback: function (r, options, success) {
if (success) {
if (this.storeBodyList.getCount() > 0) {
this.comboxCurr.setReadOnly(true);
this.comboxCustCode.setReadOnly(true);
}
else {
this.comboxCurr.setReadOnly(false);
this.comboxCustCode.setReadOnly(false);
}
}
},
scope: this
});
this.storeBodySum.load({ params: { condition: " BILLNO='" + billno + "'"} });
this.storeDetailList.load({ params: { condition: " PID='" + GID + "'"} });
}, // 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);
var bodydatas = [];
for (var i = 0; i < this.storeDetailList.getCount(); i += 1) {
var member = this.storeDetailList.getAt(i);
bodydatas.push(member);
}
var jsonBody = ConvertRecordsToJsonAll(bodydatas);
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Account/Chfee_invoice/Save',
scope: this,
params: {
opstatus: this.opStatus,
data: Ext.JSON.encode(data),
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;
this.formEdit.getForm().setValues(returnData);
this.formAMT.getForm().setValues(data);
if (this.opStatus == 'add') {
var arrNewRecords = this.StoreList.add(returnData);
this.editRecord = arrNewRecords[0];
}
else if (this.opStatus == 'edit') {
var editp = Ext.create('MsChInvoice', 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';
this.storeDetailList.load({ params: { condition: " PID='" + GID + "'"} });
} 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
onAddDetailClick: function (button, event) {
this.addstore = true;
this.addDetail();
}, //end onAddDetailClick
onDelDetailClick: function (button, event, type) {
this.deleteDetail();
}, //onDelDetailClick
onAddClick: function (button, event) {
this.addstore = true;
this.addBill();
}, //end onAddDetailClick
onDeleteClick: function (button, event) {
this.deleteBill();
}, //end onAddDetailClick
onDelInvClick: function (button, event) {
this.DeleteInv();
},
gridListDetailAfterEdit: function (editor, e, eOpts) {
if (e.value == e.originalValue) return;
if (e.field == 'PKGS' || e.field == 'PRICE') {
var unitPrice = e.record.data['PRICE'];
var quantity = e.record.data['PKGS'];
var taxrate = e.record.data['TAXRATE'];
if (taxrate != null) {
var taxrateb = parseFloat(1 + parseFloat(taxrate / 100));
var TaxUnitPrice = (unitPrice.mul(taxrateb)).toFixed(2);
e.record.set('TAXPRICE', TaxUnitPrice);
}
var amount = (unitPrice.mul(quantity)).toFixed(2);
e.record.set('AMOUNT', amount);
taxrate = parseFloat(taxrate) / 100;
var tax = parseFloat(amount).mul(taxrate);
e.record.set('TAX', tax);
this.calcDetailTotal();
} else if (e.field == 'TAXPRICE') {
var TaxUnitPrice = e.record.data['TAXPRICE'];
if (e.value != 0) {
var quantity = e.record.data['PKGS'];
var taxrate = e.record.data['TAXRATE'];
var taxrateb = parseFloat(1 + parseFloat(taxrate / 100));
var unitPrice = (parseFloat(TaxUnitPrice).div(parseFloat(taxrateb))).toFixed(2);
e.record.set('PRICE', unitPrice);
if (quantity != null) {
var amount = (parseFloat(unitPrice).mul(quantity)).toFixed(2);
e.record.set('AMOUNT', amount);
taxrate = parseFloat(taxrate) / 100;
var tax = parseFloat(amount).mul(taxrate);
e.record.set('TAX', tax);
}
this.calcDetailTotal();
}
} else if (e.field == 'TAXRATE') {
var taxrate = e.record.data['TAXRATE'];
var unitPrice = e.record.data['PRICE'];
var quantity = e.record.data['PKGS'];
if (unitPrice != null) {
var taxrateb = parseFloat(1 + parseFloat(taxrate / 100));
var TaxUnitPrice = (parseFloat(unitPrice).mul(taxrateb)).toFixed(2);
e.record.set('TAXPRICE', TaxUnitPrice);
}
var notaxamount = e.record.data['AMOUNT'];
taxrate = parseFloat(taxrate) / 100;
var tax = parseFloat(notaxamount).mul(taxrate);
e.record.set('TAX', tax);
this.calcDetailTotal();
} else if (e.field == 'AMOUNT' || e.field == 'TAX') {
this.calcDetailTotal();
}
},
calcDetailTotal: function () {
var ttlamt = 0;
for (var i = 0; i < this.storeDetailList.getCount(); i += 1) {
var member = this.storeDetailList.getAt(i);
var value = member.get('AMOUNT');
var tax = member.get('TAX');
ttlamt = ttlamt.add(parseFloat(value));
ttlamt = ttlamt.add(parseFloat(tax));
}
this.setHeadFieldValue('INVAMOUNT', Ext.util.Format.number(parseFloat(ttlamt), '00.00'));
var amtc = this.numtoc(parseFloat(ttlamt).toFixed(2));
var field = this.formAMT.getForm().findField('AMOUNTCAPITAL');
field.setValue(amtc);
},
setHeadFieldValue: function (fieldName, value) {
var field = this.formEdit.getForm().findField(fieldName);
field.setValue(value);
},
gridAddFeeListAfterEdit: function (editor, e, eOpts) {
//需要自己实现里面的事件
if (e.value == e.originalValue) return;
if (e.field == 'StlAmount') {
var BalAmount = e.record.data['BalAmount'];
var StlAmount = e.record.data['StlAmount'];
if (BalAmount >= 0) {
if (StlAmount > BalAmount) {
e.record.set('StlAmount', BalAmount);
Ext.Msg.show({ title: '提示', msg: '申请金额不能大于未申金额!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
}
} else {
if (StlAmount < BalAmount) {
e.record.set('StlAmount', BalAmount);
Ext.Msg.show({ title: '提示', msg: '申请金额不能大于未申金额!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
}
}
}
},
onNextKeyClick: function (col) {
var rows = this.gridAddFeeList.getSelectionModel().getSelection();
var row = rows[rows.length - 1];
var s = this.gridAddFeeList.getStore();
var number = s.indexOf(row) + 1;
this.cellEditingFee.startEditByPosition({ row: number, column: col });
},
onUpKeyClick: function (col) {
var rows = this.gridAddFeeList.getSelectionModel().getSelection();
var row = rows[rows.length - 1];
var s = this.gridAddFeeList.getStore();
var number = s.indexOf(row) - 1;
if (number < 0) number = 0;
this.cellEditingFee.startEditByPosition({ row: number, column: col });
},
onAddInvDetailClick: function () {
var BILLNO = this.formEdit.getForm().findField('BILLNO').getValue();
this.formEdit.getForm().findField('GID').setDisabled(false);
var GID = this.formEdit.getForm().findField('GID').getValue();
this.formEdit.getForm().findField('GID').setDisabled(true);
var billtaxrate = this.formEdit.getForm().findField('EXCHANGERATE').getValue();
if (BILLNO == '*') {
Ext.Msg.show({ title: '注意', msg: '请先保存业务信息再添加发票明细!', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var newSerialno = DsGetNewSerialNo(this.storeDetailList, 0);
var record = Ext.create('MsChInvoiceDetail', {
GID: '',
PID: '*',
SERIALNO: newSerialno,
GOODSNAME: '',
SPEC: '',
UNIT: '',
PKGS: 1,
TAXPRICE: 0,
PRICE: 0,
TAXRATE: billtaxrate,
AMOUNT: 0,
TAX: 0,
REMARK: ''
});
this.storeDetailList.add(record);
var n = this.storeDetailList.getCount();
this.gridDetailCellEditing.startEditByPosition({ row: n - 1, column: 1 });
},
onDelInvDetailClick: function () {
var selectedRecords = this.GridDetailCheckBoxModel.selected.items;
var GID = this.formEdit.getForm().findField('GID').getValue();
var BILLNO = this.formEdit.getForm().findField('BILLNO').getValue();
Ext.MessageBox.confirm('提示', '确定要删除选中的明细吗?', function (btn) {
if (btn == 'yes') {
var bodyDatas = [];
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.GID == "" || rec.PID == "*") //如果是新增但没有保存的数据,没有必要提交到后台
{
this.storeDetailList.remove(selectedRecords[i]);
} else {
bodyDatas.push(rec);
}
}
var jsonBody = ConvertRecordsToJsonAll(bodyDatas);
_this = this;
Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/Account/Chfee_invoice/DelInvDetail',
params: {
billno: BILLNO,
body: jsonBody,
GID:GID
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
for (var i = 0; i < selectedRecords.length; i++) {
this.storeDetailList.remove(selectedRecords[i]);
}
// this.gridList.getView().refresh();
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 });
},
success: function (response, options) {
},
scope: this
}); //end Ext.Ajax.request
}
}, this);
},
addDetail: function () {
var basicForm = this.formEdit.getForm();
var Duino = this.formEdit.getForm().findField('BILLNO').getValue();
_this = this;
if ((Duino == '*') || basicForm.isDirty()) {
var CUSTOMERNAME = this.formEdit.getForm().findField('CUSTOMERNAME').getValue();
var CURR = this.formEdit.getForm().findField('CURRENCY').getValue();
if ((CUSTOMERNAME == '') || (CUSTOMERNAME == null) || (CURR == '') || (CURR == null)) {
var selectedRecords = this.gridAddFeeList.selModel.getSelection();
if (selectedRecords.length > 0) {
var rec = selectedRecords[0];
var cust = rec.data.FeeObjName;
var curr = rec.data.Currency;
if ((CUSTOMERNAME == '') || (CUSTOMERNAME == null))
this.formEdit.getForm().findField('CUSTOMERNAME').setValue(cust);
if ((CURR == '') || (CURR == null)) {
Ext.Msg.show({ title: '提示', msg: '币别不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
}
}
if (!basicForm.isValid()) {
return;
}
var type = 0;
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);
var bodydatas = [];
for (var i = 0; i < this.storeDetailList.getCount(); i += 1) {
var member = this.storeDetailList.getAt(i);
bodydatas.push(member);
}
var jsonBody = ConvertRecordsToJsonAll(bodydatas);
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Account/Chfee_invoice/Save',
scope: this,
params: {
opstatus: this.opStatus,
data: Ext.JSON.encode(data),
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;
this.formEdit.getForm().setValues(returnData);
this.formAMT.getForm().setValues(data);
if (this.opStatus == 'add') {
var arrNewRecords = this.StoreList.add(returnData);
this.editRecord = arrNewRecords[0];
}
else if (this.opStatus == 'edit') {
var editp = Ext.create('MsChInvoice', 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();
}
this.opStatus = 'edit';
this.storeDetailList.load({ params: { condition: " PID='" + GID + "'"} });
_this.addDetailfn();
} 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
});
}
}
});
} else {
this.addDetailfn();
}
}, //end save
addDetailfn: function () {
if (this.addstore) {
this.storeCurrExrate.removeAll();
this.addstore = false;
}
var Duino = this.formEdit.getForm().findField('BILLNO').getValue();
var GID = this.formEdit.getForm().findField('GID').getValue();
var jobValue = this.FeeGroup.getValue();
var ISDELETE = this.formEdit.getForm().findField('ISDELETE').getValue();
var ISNEEDPRINT = this.formEdit.getForm().findField('ISNEEDPRINT').getValue();
var ISNEEDFEE = this.formEdit.getForm().findField('ISNEEDFEE').getValue();
var VOUCHERNO = this.formEdit.getForm().findField('VOUCHERNO').getValue();
var VOUNO = this.formEdit.getForm().findField('VOUNO').getValue();
if (ISNEEDPRINT == 'true') {
Ext.Msg.show({ title: '提示', msg: '已打印无法修改此发票,只能作废!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
if (VOUCHERNO != '' && VOUCHERNO !=null) {
Ext.Msg.show({ title: '提示', msg: '已生成接口凭证无法修改此发票,只能作废!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
if (VOUNO != '' && VOUNO != null) {
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 basicForm = this.formEdit.getForm();
var billcust = this.editRecord.data.CUSTOMERNAME;
var billno = this.editRecord.data.BILLNO;
var billcurr = this.editRecord.data.CURRENCY;
var billtaxrate = this.editRecord.data.EXCHANGERATE;
var invoiceno = this.editRecord.data.INVOICENO;
var selectedRecords = this.gridAddFeeList.selModel.getSelection();
var bodyAddDatas = [];
_this = this;
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
var cust = rec.data.FeeObjName;
var bsno = rec.data.BSNO;
var curr = rec.data.Currency;
var acctaxrate = rec.data.AccTaxRate;
if (cust == billcust) {
if (billtaxrate == acctaxrate) {
if (billcurr == curr) {
rec.data.DoAmount = rec.data.StlAmount;
} else {
var recs = DsStoreQueryBy(_this.storeCurrExrate, 'CURR', curr);
if (recs.getCount() > 0) {
var data = recs.getAt(0).data;
var EXRATE = data.EXRATE;
rec.data.DoAmount = parseFloat(rec.data.StlAmount).mul(parseFloat(EXRATE));
} else {
_this.ExrateConversion(curr, billcurr, 'detail');
return;
}
}
bodyAddDatas.push(rec);
} else {
Ext.Msg.show({ title: '提示', msg: '费用进项税率与发票申请税率不一致,不能添加此费用明细!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
}
} else {
Ext.Msg.show({ title: '提示', msg: '费用对象与开票客户不一致,不能添加此费用明细!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
}
}
if (bodyAddDatas.length == 0) {
Ext.Msg.show({ title: '提示', msg: '没有要添加的费用明细!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
};
var jsonbodyAddDatas = ConvertRecordsToJsonAll(bodyAddDatas);
Ext.Ajax.request({
waitMsg: '正在添加数据...',
url: '/Account/Chfee_invoice/AddDetail',
params: {
bill: billno,
data: jsonbodyAddDatas,
curr: billcurr,
islist: jobValue,
GID: GID,
invoiceno: invoiceno
},
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 {
var sql = this.BillSql;
this.storeAddFeeList.load({ params: { start: 0, limit: _this.PageSize, sort: '', condition: sql} });
this.storeAddBodySum.load({ params: { condition: sql} });
_this.storeBodyList.load({ params: { condition: " BILLNO='" + billno + "'" },
callback: function (r, options, success) {
if (success) {
if (_this.storeBodyList.getCount() > 0) {
_this.comboxCurr.setReadOnly(true);
_this.comboxCustCode.setReadOnly(true);
}
else {
_this.comboxCurr.setReadOnly(false);
_this.comboxCustCode.setReadOnly(false);
}
}
},
scope: this
});
this.storeBodySum.load({ params: { condition: " BILLNO='" + billno + "'"} });
this.storeDetailList.load({ params: { condition: " PID='" + GID + "'"} });
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/Account/Chfee_invoice/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);
this.formAMT.getForm().setValues(data);
var editp = Ext.create('MsChInvoice', 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
});
},
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 ISNEEDPRINT = this.formEdit.getForm().findField('ISNEEDPRINT').getValue();
var ISNEEDFEE = this.formEdit.getForm().findField('ISNEEDFEE').getValue();
var VOUCHERNO = this.formEdit.getForm().findField('VOUCHERNO').getValue();
var VOUNO = this.formEdit.getForm().findField('VOUNO').getValue();
if (ISNEEDPRINT == 'true') {
Ext.Msg.show({ title: '提示', msg: '已打印无法修改此发票,只能作废!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
if (VOUCHERNO != '') {
Ext.Msg.show({ title: '提示', msg: '已生成接口凭证无法修改此发票,只能作废!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
if (VOUNO != '') {
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 bodyAddDatas = [];
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
bodyAddDatas.push(rec);
}
var jsonbodyAddDatas = ConvertRecordsToJsonAll(bodyAddDatas);
var sql = this.BillSql;
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/Account/Chfee_invoice/DelBill',
params: {
data: jsonbodyAddDatas,
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 {
var sql = this.BillSql;
this.storeAddFeeList.load({ params: { start: 0, limit: _this.PageSize, sort: '', condition: sql} });
this.storeAddBodySum.load({ params: { condition: sql} });
_this.storeBodyList.load({ params: { condition: " BILLNO='" + billno + "'" },
callback: function (r, options, success) {
if (success) {
if (_this.storeBodyList.getCount() > 0) {
_this.comboxCurr.setReadOnly(true);
_this.comboxCustCode.setReadOnly(true);
}
else {
_this.comboxCurr.setReadOnly(false);
_this.comboxCustCode.setReadOnly(false);
}
}
},
scope: this
});
this.storeBodySum.load({ params: { condition: " BILLNO='" + billno + "'"} });
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/Account/Chfee_invoice/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);
this.formAMT.getForm().setValues(data);
var editp = Ext.create('MsChInvoice', 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 ISNEEDPRINT = this.formEdit.getForm().findField('ISNEEDPRINT').getValue();
var ISNEEDFEE = this.formEdit.getForm().findField('ISNEEDFEE').getValue();
var VOUCHERNO = this.formEdit.getForm().findField('VOUCHERNO').getValue();
var VOUNO = this.formEdit.getForm().findField('VOUNO').getValue();
if (VOUCHERNO != '') {
Ext.Msg.show({ title: '提示', msg: '已生成接口凭证无法删除此发票!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
if (VOUNO != '') {
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_invoice/DeleteInv',
params: {
billno: billno,
isprint: ISNEEDPRINT
},
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 {
var sql = this.BillSql;
this.storeAddFeeList.load({ params: { start: 0, limit: _this.PageSize, sort: '', condition: sql} });
this.storeAddBodySum.load({ params: { condition: sql} });
_this.storeBodyList.load({ params: { condition: " BILLNO='" + billno + "'" },
callback: function (r, options, success) {
if (success) {
if (_this.storeBodyList.getCount() > 0) {
_this.comboxCurr.setReadOnly(true);
_this.comboxCustCode.setReadOnly(true);
}
else {
_this.comboxCurr.setReadOnly(false);
_this.comboxCustCode.setReadOnly(false);
}
}
},
scope: this
});
this.storeBodySum.load({ params: { condition: " BILLNO='" + billno + "'"} });
if (ISNEEDPRINT == "true") {
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/Account/Chfee_invoice/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);
this.formAMT.getForm().setValues(data);
var editp = Ext.create('MsChInvoice', 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_invoice/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 {
var sql = this.BillSql;
this.storeAddFeeList.load({ params: { start: 0, limit: _this.PageSize, sort: '', condition: sql} });
this.storeAddBodySum.load({ params: { condition: sql} });
_this.storeBodyList.load({ params: { condition: " BILLNO='" + billno + "'" },
callback: function (r, options, success) {
if (success) {
if (_this.storeBodyList.getCount() > 0) {
_this.comboxCurr.setReadOnly(true);
_this.comboxCustCode.setReadOnly(true);
}
else {
_this.comboxCurr.setReadOnly(false);
_this.comboxCustCode.setReadOnly(false);
}
}
},
scope: this
});
this.storeBodySum.load({ params: { condition: " BILLNO='" + billno + "'"} });
this.storeDetailList.load({ params: { condition: " PID='" + GID + "'"} });
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/Account/Chfee_invoice/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);
this.formAMT.getForm().setValues(data);
var editp = Ext.create('MsChInvoice', 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();
var VOUCHERNO = this.formEdit.getForm().findField('VOUCHERNO').getValue();
var VOUNO = this.formEdit.getForm().findField('VOUNO').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;
}
if (VOUCHERNO != '' && VOUCHERNO != null) {
Ext.Msg.show({ title: '提示', msg: '已生成接口凭证无法撤销锁定!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
if (VOUNO != '' && VOUNO != null) {
Ext.Msg.show({ title: '提示', msg: '已生成总账凭证无法撤销锁定!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
_this = this;
Ext.Ajax.request({
waitMsg: '正在添加数据...',
url: '/Account/Chfee_invoice/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 {
var sql = this.BillSql;
this.storeAddFeeList.load({ params: { start: 0, limit: _this.PageSize, sort: '', condition: sql} });
this.storeAddBodySum.load({ params: { condition: sql} });
_this.storeBodyList.load({ params: { condition: " BILLNO='" + billno + "'" },
callback: function (r, options, success) {
if (success) {
if (_this.storeBodyList.getCount() > 0) {
_this.comboxCurr.setReadOnly(true);
_this.comboxCustCode.setReadOnly(true);
}
else {
_this.comboxCurr.setReadOnly(false);
_this.comboxCustCode.setReadOnly(false);
}
}
},
scope: this
});
this.storeBodySum.load({ params: { condition: " BILLNO='" + billno + "'"} });
this.storeDetailList.load({ params: { condition: " PID='" + GID + "'"} });
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/Account/Chfee_invoice/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);
this.formAMT.getForm().setValues(data);
var editp = Ext.create('MsChInvoice', 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
});
},
onRefreshClick: function (button, event) {
var sql = this.getCondition();
this.storeAddFeeList.load({ params: { start: 0, limit: this.PageSize, sort: '', condition: sql} });
this.storeAddBodySum.load({ params: { condition: sql} });
},
onClearSql: function () {
var form = this.formSearch.getForm();
form.reset();
},
getCondition: function () {
var form = this.formSearch.getForm();
if (!form.isValid()) {
Ext.Msg.alert('提示', '查询条件赋值错误,请检查。');
return '';
}
var sql = '';
var customNo = form.findField('CustomNo').getValue();
sql = sql + getAndConSql(sql, customNo, " (b.CUSTNO like '%" + customNo + "%' or b.MBLNO like '%" + customNo + "%' or b.HBLNO like '%" + customNo + "%' or b.CUSTOMNO like '%" + customNo + "%' or b.ORDERNO like '%" + customNo + "%')");
var OPLBNAME = form.findField('OPLBNAME').getValue();
sql = sql + getAndConSql(sql, OPLBNAME, "b.OPLBNAME='" + OPLBNAME + "'");
var expDateBgn = form.findField('ExpDateBgn').getRawValue();
sql = sql + getAndConSql(sql, expDateBgn, "b.ETD >='" + expDateBgn + "'");
var expDateEnd = form.findField('ExpDateEnd').getRawValue();
sql = sql + getAndConSql(sql, expDateEnd, "b.ETD <='" + expDateEnd + "'");
var ACCDATE = form.findField('ACCDATEFR').getRawValue();
sql = sql + getAndConSql(sql, ACCDATE, "b.ACCDATE>='" + ACCDATE + "'");
var ACCDATETO = form.findField('ACCDATETO').getRawValue();
sql = sql + getAndConSql(sql, ACCDATETO, "b.ACCDATE<='" + ACCDATETO + "'");
var feesql = 'f.FEESTATUS IN (0,8,9) and (f.AMOUNT<>(ISNULL(f.INVOICE,0)+ISNULL(f.ORDERINVOICE,0)-ISNULL(f.ORDERINVSETTLEMENT,0))) ';
this.FeeSqlStr = this.getFeeCondition();
feesql = feesql + getAndConSql(feesql, this.FeeSqlStr, this.FeeSqlStr);
sql = sql + getAndConSql(sql, feesql, feesql);
this.BillSql = sql;
return sql;
},
getFeeCondition: function () {
var form = this.formSearch.getForm();
var feesql = '';
var CUSTNAME = form.findField('CUSTNAME').getValue();
feesql = feesql + getAndConSql(feesql, CUSTNAME, "f.CUSTOMERNAME='" + CUSTNAME + "'");
var DC = form.findField('DC').getValue();
feesql = feesql + getAndConSql(feesql, DC, "f.FEETYPE=" + DC);
var Currency = form.findField('Currency').getValue();
feesql = feesql + getAndConSql(feesql, Currency, "f.Currency='" + Currency + "'");
var FeeName = form.findField('FeeName').getValue();
feesql = feesql + getAndConSql(feesql, FeeName, "f.FeeName='" + FeeName + "'");
return feesql;
},
ExrateConversion: function (bfcurr, afcurr, fntype) {
var EXRATE = 0;
var achange = true;
var bchange = true;
formExrateConversion = Ext.widget('form', {
frame: true,
region: 'center',
bodyPadding: 5,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 90,
msgTarget: 'qtip'
},
items: [
{//fieldset 1
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '1' + bfcurr + '=',
xtype: 'numberfield',
name: 'bfcurr',
decimalPrecision: 4,
value: 0,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
try {
var lsValue = usMoney(value, 4, '', 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 () {
if (bchange) {
var bfcurr = formExrateConversion.getForm().findField('bfcurr').getValue();
var field = formExrateConversion.getForm().findField('afcurr');
if (bfcurr == 0) { field.setValue(0); } else {
var taxrate = (parseFloat(1).div(parseFloat(bfcurr))).toFixed(4);
achange = false;
field.setValue(taxrate);
}
}
achange = true;
}
}
}, {
xtype: 'label',
width: 120,
text: afcurr,
name: 'bfcurr2'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '1' + afcurr + '=',
xtype: 'numberfield',
name: 'afcurr',
decimalPrecision: 4,
value: 0,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
try {
var lsValue = usMoney(value, 4, '', 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 () {
if (achange) {
var afcurr = formExrateConversion.getForm().findField('afcurr').getValue();
var field = formExrateConversion.getForm().findField('bfcurr');
if (afcurr == 0) { field.setValue(0); } else {
var taxrate = (parseFloat(1).div(parseFloat(afcurr))).toFixed(4);
bchange = false;
field.setValue(taxrate);
}
}
bchange = true;
}
}
}, {
xtype: 'label',
width: 120,
text: bfcurr,
name: 'afcurr2'
}
]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
});
me = this;
winExrateShow = Ext.create('Ext.window.Window', {
title: "币别汇率折算",
width: 450,
//height : 120,
//plain : true,
iconCls: "addicon",
resizable: false,
// 是否可以拖动
// draggable:false,
collapsible: true, // 允许缩放条
closeAction: 'close',
closable: true,
modal: 'true',
buttonAlign: "center",
bodyStyle: "padding:0 0 0 0",
items: [formExrateConversion],
buttons: [{
text: "确定",
minWidth: 70,
handler: function () {
var form = formExrateConversion.getForm();
var UsdExrate = form.findField('bfcurr').getValue();
if (UsdExrate == '' || UsdExrate == null || UsdExrate == undefined) {
Ext.Msg.show({ title: '提示', msg: '必须填折算汇率!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
};
var recs = DsStoreQueryBy(me.storeCurrExrate, 'CURR', bfcurr);
if (recs.getCount() > 0) {
// var dfdata = DFrecords.getAt(0).data;
// dfdata.EXRATE = UsdExrate;
for (var i = 0; i < me.storeCurrExrate.getCount(); i += 1) {
var member = me.storeCurrExrate.getAt(i);
if (member.data.CURR == bfcurr) {
// member.EXRATE = UsdExrate;
member.set('EXRATE', UsdExrate);
member.commit();
}
}
} else {
me.storeCurrExrate.add({ "CURR": bfcurr, "EXRATE": UsdExrate })
}
winExrateShow.close();
if (fntype == 'detail') {
me.addDetail();
}
if (fntype == 'bill') {
me.addBill();
}
return;
}
}, {
text: "关闭",
minWidth: 70,
handler: function () {
winExrateShow.close();
return;
}
}]
});
if (bfcurr == 'RMB') {
var DFrecords = DsStoreQueryBy(this.StoreCurr, 'CURR', afcurr);
if (DFrecords.getCount() > 0) {
var dfdata = DFrecords.getAt(0).data;
var DEFRATE = dfdata.DEFRATE;
} else {
var DEFRATE = 0;
}
var field = formExrateConversion.getForm().findField('afcurr');
achange = true;
field.setValue(DEFRATE);
} else {
var DFrecords = DsStoreQueryBy(this.StoreCurr, 'CURR', bfcurr);
if (DFrecords.getCount() > 0) {
var dfdata = DFrecords.getAt(0).data;
var DEFRATE = dfdata.DEFRATE;
} else {
var DEFRATE = 0;
}
var field = formExrateConversion.getForm().findField('bfcurr');
bchange = true;
field.setValue(DEFRATE);
}
winExrateShow.show();
// S=setInterval(function () {
// if (EXRATE != 0) {
// alert(EXRATE);
// clearInterval(S);
// }
// }, 500)
},
numtoc: function (numberValue) {
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;
},
// #region 根据权限和状态判断是否允许修改
GetIsEdit: function () {
var ISDELETE = this.formEdit.getForm().findField('ISDELETE').getValue();
var ISNEEDPRINT = this.formEdit.getForm().findField('ISNEEDPRINT').getValue();
var ISNEEDFEE = this.formEdit.getForm().findField('ISNEEDFEE').getValue();
var VOUCHERNO = this.formEdit.getForm().findField('VOUCHERNO').getValue();
var VOUNO = this.formEdit.getForm().findField('VOUNO').getValue();
var BILLSTATUS = this.formEdit.getForm().findField('BILLSTATUS').getValue();
if ((ISDELETE == 'true') || (ISNEEDPRINT == 'true') || (VOUCHERNO != '') || (VOUNO != '') || (BILLSTATUS != 0)) return false;
else return true;
},
GetEditStatus: function () {
var canedit = false;
var op = this.formEdit.getForm().findField('OPERATORNAME').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: "modInvoiceManagement" },
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('OPERATOR').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');
var btnEAddDetail = Ext.getCmp('btnadddetail');
var btnEDeleteDetail = Ext.getCmp('btndeldetail');
var btnEAddInvDetail = Ext.getCmp('btnAddInvdetail');
var btnEDeleteInvDetail = Ext.getCmp('btndelInvdetail');
if (enable) {
btnESave.enable();
btnESaveAndClose.enable();
btnESaveAndNew.enable();
btnEAddDetail.enable();
btnEDeleteDetail.enable();
btnEAddInvDetail.enable();
btnEDeleteInvDetail.enable();
} else {
btnESave.disable();
btnESaveAndClose.disable();
btnESaveAndNew.disable();
btnEAddDetail.disable();
btnEDeleteDetail.disable();
btnEAddInvDetail.disable();
btnEDeleteInvDetail.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() || (this.storeDetailList.getUpdatedRecords() > 0)) {
Ext.Msg.show({ title: '错误', msg: '单据还没有保存,请保存后再打印', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var printType = 'MSCHFEEINVOICE';
var sql1 = "SELECT * FROM ch_fee_invoice WHERE GID='" + Gid + "'";
var sql2 = "SELECT c.GID,c.BSNO,c.FEEID,c.FEENAME,c.CURRENCY,c.AMOUNT,c.DOAMOUNT,c.ORIGCURRENCY,c.ORIGAMOUNT,c.EXCHANGERATE ";
sql2 = sql2 + ",b.CUSTOMERNAME,b.VESSEL,b.VOYNO,b.ETD,b.PORTLOAD";
sql2 = sql2 + " ,b.PORTDISCHARGE,b.INPUTBY,b.OP,b.CUSTSERVICE,b.DOC,b.SALE";
sql2 = sql2 + " FROM ch_fee_do c left join v_op_bill b on (b.bsno=c.bsno)";
sql2 = sql2 + " WHERE C.BILLNO='" + billNo + "'";
var sql3 = "SELECT * FROM CH_FEE_INVOICEDETAIL WHERE PID='" + Gid + "'";
var sql4 = "";
var sql5 = "";
var sql6 = "";
PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6);
Ext.Ajax.request({
waitMsg: '正在查询数据...',
url: '/Account/Chfee_invoice/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_invoice/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);
this.formAMT.getForm().setValues(data);
var editp = Ext.create('MsChInvoice', 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
});
}
});