Ext.namespace('Shipping');
Shipping.MsChPayapplicationBLEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsChPayapplicationBLEdit.superclass.constructor.call(this);
};
Date.prototype.format = function (format) {
var o = {
"M+": this.getMonth() + 1, //month
"d+": this.getDate(), //day
"h+": this.getHours(), //hour
"m+": this.getMinutes(), //minuet
"s+": this.getSeconds(), //second
"q+": Math.floor((this.getMonth() + 3) / 3), //quarter
"S": this.getMilliseconds() //millisecond
}
if (/(y+)/.test(format)) format = format.replace(RegExp.$1,
(this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o) if (new RegExp("(" + k + ")").test(format))
format = format.replace(RegExp.$1,
RegExp.$1.length == 1 ? o[k] :
("00" + o[k]).substr(("" + o[k]).length));
return format;
}
var xhr = new XMLHttpRequest();
var currdate = new Date();
if (!xhr) {
//...其他生成xmlhttprequest方法
}
xhr.open("HEAD", location.href, true);
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
var datestr = xhr.getResponseHeader("Date");
currdate = new Date(datestr);
// alert(currdate.format('yyyy-MM-dd'));
}
}
xhr.send(null);
Ext.extend(Shipping.MsChPayapplicationBLEdit, Ext.Panel, {
ParentWin: null,
opStatus: 'add',
HTH: "",
StoreList: null,
EditRecord: null,
addstore: false,
PageSize: 30,
VISIBLERANGE: 4,
OPERATERANGE: 4,
initUIComponents: function () {
this.serialNo = 0;
this.workSerialNo = 0;
this.bodyDel = [];
this.FeeSql = '';
this.BillSql = '';
this.DuiBillSql = '';
this.IsDebit = '0';
this.feeBodyDel = [];
this.ZDDetailDel = [];
if (SPTYPE == "跟单销售") {
this.formname = "formImportSalesEdit_detail"; //页面名称
this.formname_fee = "formImportSalesEdit_Fee"; //页面名称
this.formname_ZD = "formImport_SaleZD"; //页面名称
this.formname_ZDDetail = "formImport_SaleZDDetail"; //页面名称
this.formname_ZDFee = "formImportSalesEdit_Fee"; //页面名称
}
if (SPTYPE == "财务核销") {
this.formname = "formImportSalesEdit_detail_CWHX"; //页面名称
this.formname_fee = "formImportSalesEdit_Fee_CWHX"; //页面名称
this.formname_ZD = "formImport_SaleZD"; //页面名称
this.formname_ZDDetail = "formImport_SaleZDDetail"; //页面名称
this.formname_ZDFee = "formImportSalesEdit_Fee_CWHX"; //页面名称
}
//#region 编辑form
//枚举参照相关(编辑form)
//表参照相关(编辑form)
this.storeCustCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
});
this.storeCustCode.load({ params: { condition: "ISCONTROLLER='1'"} });
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 data = combo.value;
this.formEdit.getForm().findField('SALER').setValue(records[0].data.SALE);
}
}
}
});
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.StoreDateCurr = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsFeeCurr',
proxy: { url: '/MvcShipping/MsChFee/GetFeeCurrList' }
});
this.StoreDateCurr.load({ params: { condition: ""} });
this.comboxCurr = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '币别',
allowBlank: false,
store: this.StoreCurr,
forceSelection: true,
//emptyText: '原币申请',
name: 'CURRENCY',
valueField: 'CURR',
displayField: 'CURR',
value: 'RMB',
listeners: {
change: function (field, newValue, oldValue) {
this.setCURRENCY(field, newValue, oldValue);
},
scope: this
}
});
this.StoreDateCurr2 = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsFeeCurr',
proxy: { url: '/MvcShipping/MsChFee/GetFeeCurrList' }
});
this.StoreDateCurr2.load({ params: { condition: ""} });
this.comboxcurr_2 = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '币别',
allowBlank: false,
store: this.StoreDateCurr2,
forceSelection: true,
emptyText: '原币申请',
name: 'CURR',
valueField: 'CURR',
displayField: 'CURR'
});
//人员信息加载
this.storeOpCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.UserRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetUserLinkRefList' }
});
this.storeOpCode.load();
//采购
this.comboxOP = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '销售助理',
store: this.storeOpCode,
forceSelection: true,
name: 'OP',
valueField: 'UserName',
displayField: 'CodeAndName',
value: SHOWNAME
});
this.storeOpCode2 = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.UserRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetUserLinkRefList' }
});
this.storeOpCode2.load();
//采购
this.comboxSALER = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '销 售',
store: this.storeOpCode2,
forceSelection: true,
name: 'SALER',
valueField: 'UserName',
displayField: 'CodeAndName',
value: SHOWNAME
});
_this = this;
this.storeMainstate = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeMainstate.load({ params: { enumTypeId: 31} });
this.comboxMainstate = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: '销售类型', id: "MAINSTATUS",
forceSelection: true,
store: this.storeMainstate,
name: 'MAINSTATE',
listeners: {
change: function (field, newValue, oldValue) {
var SALESNO = _this.formEdit.getForm().findField('SALESNO').getValue();
var sql = " SALESNO='" + SALESNO + "'";
var __this = _this;
if (newValue == "2") {
Ext.Ajax.request({
waitMsg: '正在查询数据...',
url: '/CommMng/BasicDataRef/GetExist2',
scope: this,
async: false,
params: {
tablename: "SalesAdvancePay_state",
condition: sql,
tablename2: "ch_fee",
condition2: sql
},
waitMsg: "正在查询数据...",
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
var returnData = jsonresult.data;
//alert(returnData.Count);
this.ChfeeCount = parseInt(returnData);
if (this.ChfeeCount != "") {
alert("销售单<" + SALESNO + ">内包含未删除的费用或费用声明(认款),不能设置为取消");
Ext.getCmp("MAINSTATUS").setValue(oldValue);
return;
} else {
}
} else {
Ext.Msg.show({ title: '请重试',
msg: '服务器响应出错',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
return;
}
}
});
}
}
}
});
this.storeISINVOICE = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeISINVOICE.load({ params: { enumTypeId: 41} });
this.comboxISINVOICE = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: '是否开票', id: "ISINVOICE",
forceSelection: true,
store: this.storeISINVOICE,
name: 'ISINVOICE'
});
//编辑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: '时间戳',
name: 'TimeMark',
flex: 0,
hidden: true,
margins: '0'
}, {
fieldLabel: 'CORPID',
name: 'CORPID', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: 'DEPTGID',
name: 'DEPTGID', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: 'BSSTATUS',
name: 'BSSTATUS', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: 'FEESTATUS',
name: 'FEESTATUS', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: 'SALESTATUS', id: "SALESTATUS",
name: 'SALESTATUS', flex: 0, hidden: true, margins: '0'
},
{
fieldLabel: '销售单号',
readOnly: true,
name: 'SALESNO'
}, this.comboxCustCode
, this.comboxOP
, this.comboxSALER
, {
fieldLabel: '销售日期',
format: 'Y-m-d',
xtype: 'datefield',
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
name: 'SALESDATE'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '产品描述',
name: 'CARGONAME', flex: 2
}, {
fieldLabel: '备注',
name: 'REMARK', flex: 2
}, {
fieldLabel: '发货日期',
format: 'Y-m-d',
xtype: 'datefield',
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
name: 'DELIVERYDATE'
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'numberfield',
items: [
this.comboxCurr
,
{
fieldLabel: '金额',
name: 'AMOUNT', id: "AMOUNT"
},
{
fieldLabel: '汇率',
name: 'EXCHANGERATE',
allowDecimals: true,
//这里允许保留3位小数,所以你输入11.996就不会进位了
decimalPrecision: 5,
listeners: {
change: function (field, newValue, oldValue) {
this.setExchangeRate(field, newValue, oldValue);
},
scope: this
}
},
{
fieldLabel: 'RMB金额',
name: 'AMOUNTRMB', id: "AMOUNTRMB"
},
this.comboxMainstate]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
{
fieldLabel: '定金', readOnly: true,
name: 'PREPAYMENT', id: "PREPAYMENT"
}, {
fieldLabel: '已认款', readOnly: true,
name: 'Forecast_Amount', id: "Forecast_Amount"
}, {
xtype: 'checkbox', flex: 1,
fieldLabel: '是否盖章回传',
name: 'REPLY'
}, {
xtype: 'checkbox', flex: 1,
fieldLabel: '是否已做销售单',
name: 'ISMAKED'
}, {
xtype: 'hiddenfield', flex: 1
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
this.comboxISINVOICE
, {
xtype: 'hiddenfield', flex: 4
}
]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
}); //end this.formEdit
//#endregion
//#region 按钮Toolbar
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [{
id: 'btnEPrev',
text: "上一票",
// iconCls: "btnsave",
handler: function (button, event) {
this.PrevRecord();
},
scope: this
}, {
id: 'btnENext',
text: "下一票",
// iconCls: "btnsave",
handler: function (button, event) {
this.NextRecord();
},
scope: this
}, '-',
{
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', hidden: true,
text: "保存并新建",
handler: function (button, event) {
this.Save('2');
this.GetEditStatus();
},
scope: this
},
'-',
{
id: 'btnENew',
text: "新建",
handler: function (button, event) {
this.LoadData('add', '*');
},
scope: this
}, '-', {
id: 'btnSubmitAudit',
text: '提交出库', hidden: true,
tooltip: '您需要先在认款界面设置预收与销售单的关系。当财务人员审核通过后才能提交出库。',
handler: function (button, event) {
this.onSubmitAuditClick();
},
scope: this
}, {
id: 'btnSubmitAuditBack',
text: '撤销提交出库', hidden: true,
tooltip: '撤回提交,以便修改',
handler: function (button, event) {
this.onSubmitAuditBackClick();
},
scope: this
}, '-', {
id: 'btnEndSales',
text: '结束销售单',
tooltip: '当出库结束时,选择此项,令出库单中不再能查询到此业务的',
handler: function (button, event) {
this.EndSalesClick();
},
scope: this
}, {
id: 'btnUnEndSales',
text: '取消结束销售单',
tooltip: '撤回结束',
handler: function (button, event) {
this.UnEndSalesClick();
},
scope: this
}
]
}); //end 按钮Toolbar
//#endregion
//#region 明细表
this.storeDirectShop = Ext.create('Ext.data.Store', {
fields: ['NAME']
});
this.storeDirectShop.add({ "NAME": "" });
this.storeDirectShop.add({ "NAME": "北京直营店" });
this.storeDirectShop.add({ "NAME": "天津直营店" });
this.storeDirectShop.add({ "NAME": "上海直营店" });
this.storeDirectShop.add({ "NAME": "青岛直营店" });
this.storeDirectShop.add({ "NAME": "沈阳直营店" });
this.comboxDirectShop = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '直营店',
store: this.storeDirectShop,
name: 'DirectShop',
valueField: 'NAME',
displayField: 'NAME',
forceSelection: true
});
//明细表表格相关
this.GridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
//明细表-销售明细
this.storeBodyList = Ext.create('Ext.data.Store', {
model: 'ImportSaledetailmb',
remoteSort: false,
proxy: {
type: 'ajax',
url: '/Import/ImportSales/GetDetailList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//明细表表格 销售明细
this.gridListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.initgirdcolums = [
{
sortable: true, hidden: true,
dataIndex: 'GID',
header: 'GID',
width: 80
},
/*{
sortable: true, hidden: true,
dataIndex: 'SALESNO',
header: 'SALESNO',
width: 80
},*/
{
sortable: true, hidden: true,
dataIndex: 'CARGO_GID',
header: 'CARGO_GID',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'BSNO',
header: 'BSNO',
width: 80
},
{
sortable: true,
dataIndex: 'HTH',
header: '合同号',
width: 80
},
{
sortable: true,
dataIndex: 'SALESNO',
header: '销售单号',
width: 80
},
{
sortable: true,
dataIndex: 'CUSTOMERNAME',
header: '销售客户',
width: 80
},
{
sortable: true,
dataIndex: 'NAME',
header: '货物名称',
width: 80
},
{
sortable: true, align: 'right',
dataIndex: 'WEIGHT',
header: '销售重量(kg)',
width: 80,
editor: {
selectOnFocus: true, align: 'right',
xtype: 'numberfield'
}
},
{
sortable: true, align: 'right',
dataIndex: 'BOXCOUNT',
header: '销售件数',
width: 80,
editor: {
selectOnFocus: true, align: 'right',
xtype: 'numberfield'
}
},
{
sortable: true, align: 'right',
dataIndex: 'WEIGHT_ACT',
header: '采购入库重量(kg)',
width: 80
},
{
sortable: true, align: 'right',
dataIndex: 'WEIGHT_REMAIN',
header: '剩余可售重量(kg)',
width: 80
},
{
sortable: true, align: 'right',
dataIndex: 'BOXCOUNT_REMAIN',
header: '剩余可售件数',
width: 80
},
{
sortable: true, //hidden: true,
dataIndex: 'CURRENCY',
header: '币别',
width: 80,
editor: {
align: 'right',
xtype: 'textfield'
}
},
{
sortable: true,
dataIndex: 'PRICE',
header: '单价(币别/kg)',
width: 75,
editor: {
xtype: 'numberfield', align: 'right',
allowBlank: false,
selectOnFocus: true, //精确到小数点后2位(执行4舍5入)
allowDecimals: true, //允许输入小数
nanText: '请输入有效小数',
decimalPrecision: 6,
value: 0.000000
}, align: 'right'
},
{
sortable: true, align: 'right',
dataIndex: 'AMOUNT',
header: '金额',
editor: {
xtype: 'numberfield', align: 'right',
allowBlank: false,
selectOnFocus: true, //精确到小数点后2位(执行4舍5入)
allowDecimals: true, //允许输入小数
nanText: '请输入有效小数',
//minValue: 0,
//maxValue: 100000,
value: 0.00
},
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
},
{
sortable: true, hidden: true,
dataIndex: 'EXCHANGERATE',
header: '汇率',
width: 80,
editor: {
selectOnFocus: true,
xtype: 'numberfield'
}
},
{
sortable: true,
dataIndex: 'PRICERMB',
header: '单价(RMB/kg)',
width: 75,
editor: {
xtype: 'numberfield', align: 'right',
allowBlank: false,
selectOnFocus: true, //精确到小数点后2位(执行4舍5入)
allowDecimals: true, //允许输入小数
nanText: '请输入有效小数',
decimalPrecision: 6,
value: 0.000000
}, align: 'right'
},
{
sortable: true, align: 'right',
dataIndex: 'AMOUNTRMB',
header: 'RMB金额',
width: 80,
editor: {
xtype: 'numberfield', align: 'right',
allowBlank: false,
selectOnFocus: true, //精确到小数点后2位(执行4舍5入)
allowDecimals: true, //允许输入小数
nanText: '请输入有效小数',
//minValue: 0,
//maxValue: 100000,
value: 0.00
},
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
},
{
sortable: true, align: 'right',
dataIndex: 'PREPAYMENT',
header: '合同定金',
width: 80,
editor: {
xtype: 'numberfield', align: 'right',
allowBlank: false,
selectOnFocus: true, //精确到小数点后2位(执行4舍5入)
allowDecimals: true, //允许输入小数
nanText: '请输入有效小数',
value: 0.00
},
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
},
{
sortable: true, align: 'right',
dataIndex: 'PREPAYMENT_ACT',
header: '实际定金',
width: 80,
editor: {
xtype: 'numberfield', align: 'right',
allowBlank: false,
selectOnFocus: true, //精确到小数点后2位(执行4舍5入)
allowDecimals: true, //允许输入小数
nanText: '请输入有效小数',
value: 0.00
},
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
},
{
sortable: true, align: 'right',
dataIndex: 'COSTPRICE',
header: '预计成本(含税、代理费)',
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 '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; },
width: 130
},
{
sortable: true, align: 'right',
dataIndex: 'PRICEREMARK',
header: '价格备注',
width: 130,
editor: {
xtype: 'textfield'
}
},
{
sortable: true, align: 'right',
dataIndex: 'DirectShop',
header: '直营店',
width: 130,
editor: this.comboxDirectShop
},
{
sortable: true, align: 'right',
dataIndex: 'DirectPrice',
header: '直营店价格',
width: 80,
editor: {
xtype: 'numberfield'
},
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
},
{
sortable: true, align: 'right',
dataIndex: 'REMARK',
header: '备注',
width: 80,
editor: {
xtype: 'textfield'
}
}, {
sortable: true,
dataIndex: 'Exchangerate_Cust',
header: '收款汇率',
width: 80,
editor: {
xtype: 'numberfield',
decimalPrecision: 4
}
},
{
sortable: true,
dataIndex: 'AGENCRATE_Cust',
header: '收款代理费率',
width: 80,
editor: {
xtype: 'numberfield'
}
},
{
sortable: true,
dataIndex: 'FUNDRATE',
header: '资金利息利率',
width: 80,
editor: {
xtype: 'numberfield',
decimalPrecision: 4
}
},
{
sortable: true,
dataIndex: 'STOCKDATE_1',
header: '冷藏费开始日期',
width: 80,
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
editor: {
format: 'Y-m-d',
xtype: 'datefield',
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'STOCKDATE_2',
header: '冷藏费截止日期',
width: 80,
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
editor: {
format: 'Y-m-d',
xtype: 'datefield',
selectOnFocus: true
}
}
];
this.girdcolums = this.initgirdcolums;
_this = this;
this.gridList = new Ext.grid.GridPanel({
store: this.storeBodyList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
selModel: this.GridCheckBoxModel,
plugins: [this.gridListCellEditing],
tbar: [{
text: '删除销售明细',
tooltip: '删除销售明细',
id: 'btndeldetail',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDeleteClick(button, event, 1);
},
scope: this
}, '-', {
text: "保存列表样式",
id: "btnSaveTable",
handler: function (button, event) {
//this.column = DsTruck.SaveGridPanel(GID, this.formname, this.gridList.columns, this.column, 1, true);
var tempcolumns = this.gridList.columns;
DsTruck.SaveGridPanel(USERID, this.formname, tempcolumns, this.girdcolums, 0, true);
},
scope: this
}, '-', {
text: "生成账单项目", hidden: true,
id: "btnMakeOrder",
menu: [
{ text: "RMB尾款",
handler: function (button, event) {
_this.MakeOrderFee_RMB();
}
}, { text: "USD尾款",
handler: function (menu, event) {
_this.MakeOrderFee_USD();
}
}],
scope: this
}],
columns: this.girdcolums
});
/////////////以下部分为获取存储的gridpanel显示样式
this.girdcolums = DsTruck.GetGridPanel(USERID, this.formname, this.girdcolums, 1); //使用者id,表名,中间column数组,跳过一开始的几列
this.girdcolums.unshift(new Ext.grid.RowNumberer());
this.gridList.reconfigure(this.storeBodyList, this.girdcolums);
//this.gridList.columns[0] = new Ext.grid.RowNumberer();
////////////////////////////////////////////////
//#region 添加销售明细
this.storeBodyAddList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'ImportCargomb',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/Import/ImportSales/GetCargoList',
reader: {
id: '',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.storeCUSTOMERNAME = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
});
this.storeCUSTOMERNAME.load({ params: { condition: "ISCONTROLLER='1'"} });
this.comboxCUSTOMERNAME = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '客户名称',
store: this.storeCUSTOMERNAME,
//allowBlank: false,
forceSelection: true,
name: 'CUSTOMERNAME',
valueField: 'CustName',
displayField: 'CodeAndName'
});
this.AddGridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
this.gridAddList = new Ext.grid.GridPanel({
store: this.storeBodyAddList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
selModel: this.AddGridCheckBoxModel,
tbar: [{
text: '添加销售',
tooltip: '向销售单内添加货物',
id: 'btnaddbill',
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddClick(button, event);
},
scope: this
}],
columns: [{
sortable: true, hidden: true,
dataIndex: 'GID',
header: 'GID',
width: 80
},
{
sortable: true,
dataIndex: 'HTH',
header: '合同号',
width: 80
},
{
sortable: true,
dataIndex: 'BUYER',
header: '购货商',
width: 80
},
{
sortable: true,
dataIndex: 'NAME',
header: '货物名称',
width: 80
},
{
sortable: true,
dataIndex: 'FACTORYNO',
header: '厂号',
width: 80
},
{
sortable: true,
dataIndex: 'MAINSTATEREF',
header: '货物状态',
width: 80
},
{
sortable: true,
dataIndex: 'ARRIVALDATE',
header: '到港日',
width: 80
},
{
sortable: true,
dataIndex: 'WMSDATE',
header: '入库日期',
width: 80
},
{
sortable: true, align: 'right',
dataIndex: 'WEIGHT_ACT',
header: '实际重量(kg)',
width: 80
},
{
sortable: true, align: 'right',
dataIndex: 'WEIGHT',
header: '合同重量(kg)',
width: 80
},
{
sortable: true, align: 'right',
dataIndex: 'WEIGHT_REMAIN',
header: '剩余可售重量(kg)',
width: 80
},
{
sortable: true, align: 'right',
dataIndex: 'PRODUCTIONDATE_MIN',
header: '生产日期_起',
width: 80
},
{
sortable: true, align: 'right',
dataIndex: 'PRODUCTIONDATE_MAX',
header: '生产日期_止',
width: 80
},
{
sortable: true, align: 'right',
dataIndex: 'COSTPRICE',
header: '预计成本(RMB/kg)',
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 '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; },
width: 130
}
],
// paging bar on the bottom
bbar: Ext.create('Ext.PagingToolbar', {
store: this.storeBodyAddList,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
})
});
_this = this;
this.CurrGroup = new Ext.form.RadioGroup({
id: 'CurrGroup',
xtype: 'radiogroup',
fieldLabel: '折算币别',
columns: 2,
items: [
{ boxLabel: 'RMB', name: 'Curr', inputValue: 'RMB', checked: true },
{ boxLabel: 'USD', name: 'Curr', inputValue: 'USD' }
]
});
//#endregion
//#region 添加费用列表
this.storeAddFeeList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'Chfee_add_detail',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/Account/Chfee_ForeignPay/GetFeeDetailList',
reader: {
id: 'CH_ID',
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.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
}],
columns: [{
sortable: true,
dataIndex: 'CH_ID',
header: 'CH_ID',
hidden: true,
width: 100
}, {
sortable: true,
dataIndex: 'BSNO',
header: 'BSNO',
hidden: true,
width: 100
}, {
sortable: false,
dataIndex: 'CustomerName',
header: '客户名称',
width: 90
}, {
sortable: false,
dataIndex: 'FeeType_Ref',
header: '收付',
width: 40
}, {
sortable: false,
dataIndex: 'FeeName',
header: '费用名称',
width: 90
}, {
sortable: false,
dataIndex: 'Amount',
header: '金额',
width: 70
}, {
sortable: false,
dataIndex: 'Currency',
header: '币别',
width: 40
}, {
sortable: false,
dataIndex: 'BalAmount',
header: '未结金额',
width: 70
}, {
sortable: false,
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)
}
}
}
},
width: 70
}, {
sortable: false,
dataIndex: 'ExChangerate',
header: '原始汇率',
width: 60
}, {
sortable: false,
dataIndex: 'Invoice',
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.on('edit', function (editor, e, eOpts) {
this.gridAddFeeListAfterEdit(editor, e, eOpts);
}, this);
this.storeSelectSum = Ext.create('Ext.data.Store', {
model: 'Chfee_do_selectsum'
});
this.gridSelectSum = new Ext.grid.GridPanel({
store: this.storeSelectSum,
enableHdMenu: false,
// anchor: '100% 50%',
region: 'south',
height: 80,
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
tbar: [{
xtype: 'label',
width: 220,
id: 'SelectGrid',
height: 22,
text: '所选费用合计'
}],
columns: [{
sortable: true,
dataIndex: 'RMBDRAMOUNT',
header: 'RMB未收',
width: 80
}, {
sortable: true,
dataIndex: 'RMBCRAMOUNT',
header: 'RMB未付',
width: 80
}, {
sortable: true,
dataIndex: 'USDDRAMOUNT',
header: 'USD未收',
width: 80
}, {
sortable: true,
dataIndex: 'USDCRAMOUNT',
header: 'USD未付',
width: 80
}, {
sortable: true,
dataIndex: 'OTDRAMOUNT',
header: '其他未收',
width: 80
}, {
sortable: true,
dataIndex: 'OTCRAMOUNT',
header: '其他未付',
width: 80
}
]
});
//#endregion
_this = this;
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',
enableKeyEvents: true,
listeners: {
keyup: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
});
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',
enableKeyEvents: true,
listeners: {
keyup: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
});
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',
forceSelection: true,
name: 'DC',
value: '2',
enableKeyEvents: true,
listeners: {
keyup: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
});
this.comboxCurr2 = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '币别',
store: this.StoreCurr,
forceSelection: true,
name: 'Currency',
valueField: 'CURR',
displayField: 'CURR',
enableKeyEvents: true,
listeners: {
keyup: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
});
this.storeFeeCheck = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.FeeTypeRefModel',
proxy: { url: '/MvcShipping/MsChFee/GetFeeTypeRefList' }
});
this.storeFeeCheck.load({ params: { condition: " name in ( select name from code_fee where feegroup in(select feeName from code_PROFIT where FEEGROUP='冷藏')) "} });
this.storeCompany = Ext.create('DsExt.ux.RefTableStore', {
model: 'companymb', proxy: { url: '/CommMng/BasicDataRef/GetcompanyList' }
});
this.storeCompany.load({ params: { condition: ""} });
this.comboxCompany = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '分公司',
forceSelection: true,
store: this.storeCompany,
name: 'company',
valueField: 'gid',
displayField: 'name'
});
this.storeport = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeport.load({ params: { enumTypeId: 10} });
this.comboxport = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: '目的港',
forceSelection: true,
store: this.storeport,
name: 'port',
valueField: 'EnumValueName',
displayField: 'EnumValueName'
});
this.storeCountry = Ext.create('DsExt.ux.RefTableStore', {
model: 'ConutryRef',
proxy: { url: '/CommMng/BasicDataRef/GetCountryRefList' }
});
this.storeCountry.load({ params: { condition: ""} });
this.comboxCountry = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '进口国',
forceSelection: true,
store: this.storeCountry,
name: 'countryid',
valueField: 'countryid',
displayField: 'country_idandname'
});
this.storeMainstate = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeMainstate.load({ params: { enumTypeId: 28} });
this.comboxMainstate = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: '合同状态',
forceSelection: true,
store: this.storeMainstate,
name: 'Mainstate',
valueField: 'EnumValueName',
displayField: 'EnumValueName'
});
this.storeCurrExrate = Ext.create('Ext.data.Store', {
fields: ['CURR', 'EXRATE', 'DFEXRATE']
});
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,
{
xtype: 'button',
width: 90,
text: "执行查询",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onRefreshClick(button, event);
},
scope: this
},
{
fieldLabel: '合同号',
name: 'HTH',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
},
, this.comboxCUSTOMERNAME
, this.comboxCountry
, {
fieldLabel: '货物名称',
name: 'CARGONAME',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}
, this.comboxMainstate
]
},
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
xtype: 'button',
width: 90,
text: "重置条件",
iconCls: "btnreset",
handler: function (button, event) {
this.onClearSql(button, event);
},
scope: this
}, {
fieldLabel: '厂号',
name: 'FACTORYNO',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, {
fieldLabel: '从..到港日',
format: 'Y-m-d',
xtype: 'datefield',
name: 'ArrivalDate_min',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, {
fieldLabel: '到..到港日',
format: 'Y-m-d',
xtype: 'datefield',
name: 'ArrivalDate_max',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, {
xtype: 'hiddenfield', flex: 2
}
]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
});
//#endregion 明细表
//#region combox定义 明细参照
this.storeFeeTypeRef = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeFeeTypeRef.load({ params: { enumTypeId: 99020} });
this.comboxFeeTypeRef = Ext.create('DsExt.ux.RefEnumCombox', {
store: this.storeFeeTypeRef,
name: 'FeeType'
});
this.storeFeeNameRef = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.FeeTypeRefModel',
proxy: { url: '/MvcShipping/MsChFee/GetFeeTypeRefList' }
});
this.storeFeeNameRef.load({ params: { condition: ""} });
this.comboxFeeNameRef = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeFeeNameRef,
forceSelection: true,
name: 'FeeName',
valueField: 'Name',
displayField: 'CodeAndName'
});
this.comboxFeeNameRef2 = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeFeeNameRef,
//forceSelection: true,
name: 'FeeName',
valueField: 'Name',
displayField: 'CodeAndName'
});
this.storeCustomerNameRef = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsTruckMng.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
});
this.storeCustomerNameRef.load({ params: { condition: ""} });
this.comboxCustomerNameRef = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeCustomerNameRef,
forceSelection: true,
allowBlank: false,
name: 'CustomerName',
valueField: 'CustName',
displayField: 'CodeAndName'
});
//#endregion
//#region 费用列表
this.storeBodyChFee = Ext.create('Ext.data.Store', {
model: 'MsChFee_Sales',
remoteSort: false,
groupField: 'SETTLEBILLNO',
proxy: {
type: 'ajax',
url: '/Import/ImportSales/GetFeeList',
reader: {
id: 'GId',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.initFeecolums = [
{
sortable: true, hidden: true,
dataIndex: 'GId',
header: '惟一编号',
width: 160
}, {
sortable: true, hidden: true,
dataIndex: 'BsNo',
header: '业务编号',
width: 200
}, {
sortable: true,
dataIndex: 'FeeStatus',
header: '费用状态',
renderer: function (value, p, record) {
return record.data.FeeStatus_Ref;
},
width: 66
}, {
sortable: true,
dataIndex: 'FeeName',
header: '费用名称',
editor: this.comboxFeeNameRef,
width: 80
}, {
sortable: true,
dataIndex: 'FeeType',
header: '收付方式',
renderer: function (value, p, record) {
if (value == null || value == '')
return '';
else if (value == 1)
return '应收';
else if (value == 2)
return '应付';
},
editor: this.comboxFeeTypeRef,
width: 45
}, {
sortable: true,
dataIndex: 'FeeDescription',
header: '费用英文名称',
hidden: true,
width: 200
}, {
sortable: true,
dataIndex: 'CustomerType',
header: '客户类别',
hidden: true,
width: 200
}, {
sortable: true,
dataIndex: 'CustomerName',
header: '结算对象',
editor: this.comboxCustomerNameRef,
width: 120
}, {
sortable: true,
dataIndex: 'Unit',
header: '单位标准',
hidden: true,
width: 200
}, {
sortable: true, align: 'right',
dataIndex: 'UnitPrice',
header: '单价',
editor: {
xtype: 'textfield', //numberfield
selectOnFocus: true
},
width: 50
}, {
sortable: true, align: 'right',
dataIndex: 'Quantity',
header: '数量',
editor: {
xtype: 'textfield',
selectOnFocus: true
},
width: 70
}, {
sortable: true, align: 'right',
dataIndex: 'AMOUNTRMB',
header: 'RMB金额',
width: 95,
summaryType: 'sum',
summaryRenderer: Ext.util.Format.numberRenderer('0,000.00'),
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
}, {
sortable: true,
dataIndex: 'Currency',
header: '币别',
editor: this.comboxcurr_2,
width: 50
}, {
sortable: true, align: 'right',
dataIndex: 'Amount',
header: '金额',
width: 70,
summaryType: 'sum',
summaryRenderer: Ext.util.Format.numberRenderer('00.00'),
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
}, {
sortable: true, align: 'right',
dataIndex: 'ExChangerate',
header: '汇率',
//hidden: true,
editor: {
xtype: 'textfield',
selectOnFocus: true
},
width: 60
}, {
sortable: true,
dataIndex: 'EnterDate',
header: '时间',
width: 80,
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
editor: {
format: 'Y-m-d',
xtype: 'datefield',
selectOnFocus: true
}
}, {
sortable: true,
dataIndex: 'Remark',
header: '备注',
editor: {
xtype: 'textfield',
selectOnFocus: true
},
width: 250
}, {
sortable: true, hidden: true,
dataIndex: 'SALESNO',
header: 'SALESNO',
width: 100
}, {
sortable: true,
dataIndex: 'DELIVERYNO',
header: '出库单号',
width: 100
}, {
sortable: true,
dataIndex: 'SETTLEBILLNO',
header: '结算单号',
width: 100
}
];
this.FeeColumn = this.initFeecolums;
this.cellEditingChFee = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.feeGridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
this.gridListChFee = new Ext.grid.GridPanel({
store: this.storeBodyChFee,
title: '实际应收费用',
enableHdMenu: false,
layout: "border",
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.cellEditingChFee],
selModel: this.feeGridCheckBoxModel,
selType: 'cellmodel',
viewConfig: {
autoFill: true,
enableTextSelection: true,
getRowClass: function (record, rowIndex, rowParams, store) {
var feeStatus = record.get('FeeStatus');
return DsTruck.MsChFeeGetRowClass(feeStatus);
}
},
features: [{
id: 'group',
//ftype: 'grouping',
ftype: 'groupingsummary',
groupHeaderTpl: '{name}',
hideGroupedHeader: false,
enableGroupingMenu: true
}],
tbar: [{ xtype: 'label', id: 'label1', text: "应收应付费用" }, '-',
{
text: '增加明细', hidden: true,
tooltip: '增加明细', id: "addChfee",
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddFeeClick(button, event);
},
scope: this
}, {
text: '删除明细', hidden: true,
tooltip: '删除明细', id: "delChfee",
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelFeeClick(button, event);
},
scope: this
}, {
id: "btnSave", hidden: true,
text: '保存修改', id: "SaveChfee",
tooltip: '保存修改',
iconCls: "btnsave",
handler: function (button, event) {
this.SaveFee();
//alert(USERID);
},
scope: this
}, {
text: '提交审核', hidden: true,
tooltip: '提交审核',
iconCls: 'btnsubmitaudit',
handler: function (button, event) {
//this.onSubmitAuditClick(button, event);
},
scope: this
}, {
text: '撤回提交', hidden: true,
tooltip: '撤回提交', id: "AuditBackChfee",
iconCls: 'btncomm',
handler: function (button, event) {
this.onRetractClick(button, event, "1");
},
scope: this
}, {
text: '取消核销',
tooltip: '取消该出库单费用的核销,以便重新进行核销。只能选择一个核销单(该单内只选一条费用即可)。',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onUnSettlementClick(button, event);
},
scope: this
}, {
text: "保存列表样式",
id: "btnSaveTable2",
handler: function (button, event) {
var tempcolumns = this.gridListChFee.columns;
DsTruck.SaveGridPanel(USERID, this.formname_Fee, tempcolumns, this.FeeColumn, 0, true);
},
scope: this
}, { xtype: "label", id: "zongshu", text: "",
handler: function () { ; }
}],
columns: this.FeeColumn
});
/////////////以下部分为获取存储的gridpanel显示样式
this.FeeColumn = DsTruck.GetGridPanel(USERID, this.formname_Fee, this.FeeColumn, 1); //使用者id,表名,中间column数组,跳过一开始的几列
this.gridListChFee.reconfigure(this.storeBodyChFee, this.FeeColumn);
this.gridList.columns[0] = new Ext.grid.RowNumberer();
////////////////////////////////////////////////
//#endregion
//#region 选择load 重新加载
var _this = this;
this.gridListChFee.getSelectionModel().on('select', function (model, record, index) {
var billno = record.data.SETTLEBILLNO;
//this.storeBodyChFee.load({ params: { billno: ContractNo} });
_this.storeBodyListAcc.load({ params: { condition: " isnull(SETTLEBILLNO,'')<>'' and SETTLEBILLNO='" + billno + "'"} });
});
//#endregion
//#region 预收预付的取用
//待取用的预收明细
this.storeAccBodyList = Ext.create('Ext.data.Store', {
model: 'CWAdvancePaymentmb',
remoteSort: false,
proxy: {
type: 'ajax',
url: '/Account/Chfee_Foreignsettlement/GetAdvancePayment',
reader: {
id: 'BILLNO',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.APSearch = new Ext.form.Checkbox({
fieldLabel: '只显示认款预收',
labelwidth: 150, id: "APSearch",
width: 200,
//value:'1',
listeners: {
change: function (newValue, oldValue, eOpts)//change事件
{
var billno = _this.formEdit.getForm().findField('SALESNO').getValue();
var curr = "RMB";
var sql = "";
if (newValue.checked) {
sql = " Amount<>DoAmount and (ISFINISH=0 or ISFINISH IS NULL) AND FEETYPE=1 AND currency='" + curr + "' AND BILLNO<>'" + billno + "' AND BILLNO in(select AD_BILLNO from SalesAdvancePay_state where SALESNO like '%" + billno + "%') ";
} else {
sql = " Amount<>DoAmount and (ISFINISH=0 or ISFINISH IS NULL) AND FEETYPE=1 AND currency='" + curr + "' AND BILLNO<>'" + billno + "'";
}
_this.storeAccBodyList.load({ params: { start: 0, limit: _this.PageSize, sort: '', condition: sql} });
}
}
});
this.gridListAccCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.AccCB = Ext.create('Ext.selection.CheckboxModel', { checkOnly: true });
this.gridListAcc = new Ext.grid.GridPanel({
id: "gridListAcc",
store: this.storeAccBodyList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
selModel: this.AccCB,
plugins: [this.gridListAccCellEditing],
tbar: [{
text: '添加取用明细', hidden: true,
tooltip: '添加取用明细',
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddAPDetailClick(button, event);
},
scope: this
}, {
text: '执行查询', hidden: true,
tooltip: '查询可以用来核销的预收',
//iconCls: "btnadddetail",
id: "btnsearch",
handler: function (button, event) {
this.LoadAccBodyList(button, event);
},
scope: this
}, {
text: '自动核销',
tooltip: '依预收时间依次自动核销',
iconCls: "btnadddetail",
handler: function (button, event) {
this.AutoAPDetailClick(button, event);
},
scope: this
}, {
text: '手动核销',
tooltip: '查询可以用来核销的预收',
//iconCls: "btnadddetail",
//id: "btnsearch",
handler: function (button, event) {
this.onAddAPDetailClick(button, event);
},
scope: this
}, '-', this.APSearch, '-', { xtype: "label", id: "zongshu_YF", text: "",
handler: function () { ; }
}
],
columns: [{
sortable: true,
dataIndex: 'GID',
header: 'GID',
width: 80, hidden: true
},
{
sortable: true,
dataIndex: 'LINKGID',
header: 'LINKGID',
width: 80, hidden: true
},
{
sortable: true,
dataIndex: 'BILLNO',
header: '预收结算单号',
width: 130
},
{
sortable: true,
dataIndex: 'FEETYPEREF',
header: '收付',
width: 60
},
{
sortable: true,
dataIndex: 'CUSTOMERNAME',
header: '结算对象',
width: 100
},
{
sortable: true,
dataIndex: 'CURRENCY',
header: '币别',
width: 80
},
{
sortable: true,
dataIndex: 'AMOUNT',
header: '金额',
width: 80
},
{
sortable: true,
dataIndex: 'DOAMOUNT',
header: '已核销金额',
width: 80
},
{
sortable: true,
dataIndex: 'REMAIN',
header: '本次核销',
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
allowDecimals: true,
decimalPrecision: 2,
selectOnFocus: true,
mouseWheelEnabled: false,
enableKeyEvents: true
},
width: 80
},
{
sortable: true,
dataIndex: 'CREATEUSERREF',
header: '录入人',
width: 80
},
{
sortable: true,
dataIndex: 'CREATETIME',
header: '录入时间',
width: 80
},
{
sortable: true,
dataIndex: 'REMARK',
header: '备注',
width: 120
}
]
});
//预收预付的使用明细
this.storeBodyListAcc = Ext.create('Ext.data.Store', {
model: 'CWAdvancePaymentBodymb',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/Account/Chfee_Foreignsettlement/GetAPBodyList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.GridBodyAccCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
this.gridBodyListAcc = new Ext.grid.GridPanel({
store: this.storeBodyListAcc,
enableHdMenu: false,
region: 'center',
//height: 600,
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
selModel: this.GridBodyAccCheckBoxModel,
viewConfig: {
autoFill: true,
enableTextSelection: true
},
tbar: [{
text: '删除取用明细', hidden: true,
tooltip: '删除取用明细',
iconCls: "btnadddetail",
handler: function (button, event) {
this.onDeleteApClick(button, event);
},
scope: this
}, '-', {
text: '核销费用', hidden: true,
tooltip: '生成费用结算。注意:每个出库单所产生的费用只能同时核销!',
//iconCls: "btnadddetail",
handler: function (button, event) {
this.onSettlementClick(button, event);
},
scope: this
}],
columns: [
{
sortable: true,
dataIndex: 'GID',
header: 'GID', hidden: true,
width: 80
},
{
sortable: true,
dataIndex: 'LINKGID',
header: 'LINKGID', hidden: true,
width: 80
},
{
sortable: true,
dataIndex: 'BILLNO',
header: '预收结算单号',
width: 125
},
{
sortable: true,
dataIndex: 'SETTLELINKGID',
header: 'SETTLELINKGID', hidden: true,
width: 80
},
{
sortable: true,
dataIndex: 'SETTLEBILLNO',
header: '核销使用单号',
width: 125
},
{
sortable: true, hidden: true,
dataIndex: 'FEETYPE',
header: 'FEETYPE',
width: 80
},
{
sortable: true,
dataIndex: 'CUSTOMERNAME',
header: '结算对象', hidden: true,
width: 100
},
{
sortable: true,
dataIndex: 'CURRENCY',
header: '币别',
width: 50
},
{
sortable: true,
dataIndex: 'DOAMOUNT',
header: '核销金额',
width: 95
},
{
sortable: true,
dataIndex: 'SETTLEUSERREF',
header: '核销人',
width: 80
},
{
sortable: true,
dataIndex: 'SETTLETIME',
header: '核销时间',
width: 140
},
{
sortable: true,
dataIndex: 'REMARK',
header: '备注',
width: 80
},
{
sortable: true,
dataIndex: 'VOUCHERNO',
header: '凭证号',
width: 80
}
]
});
//#endregion
//#region 账单列表
this.ZD_CBM = Ext.create('Ext.selection.CheckboxModel');
this.storeZDList = Ext.create('Ext.data.Store', {
model: 'Import_SaleZDmb',
remoteSort: false,
proxy: {
type: 'ajax',
url: '/Import/ImportSales/GetZDList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//明细表表格 销售明细
this.ZD_CellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.ZD_colums = [
{
sortable: true, hidden: true,
dataIndex: 'GID',
header: 'GID',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'SALESNO',
header: 'SALESNO',
width: 80
}, {
dataIndex: 'ISUSE',
header: '是否采用',
width: 60,
renderer: function (value, cellmeta) {
if (value == '1' || value == 'True') {
return " ";
}
}
},
{
sortable: true,
dataIndex: 'REMARK',
header: '备注',
width: 200,
editor: {
align: 'right',
xtype: 'textfield'
}
},
{
sortable: true,
dataIndex: 'CREATEUSER',
header: '建立人',
width: 80
},
{
sortable: true,
dataIndex: 'CREATETIME',
header: '建立日期',
width: 80
},
{
sortable: true, //hidden: true,
dataIndex: 'OP',
header: '修改人',
width: 80
},
{
sortable: true,
dataIndex: 'OPDATE',
header: '修改日期',
width: 80
}
];
this.ZDcolums = this.ZD_colums;
_this = this;
this.ZDList = new Ext.grid.GridPanel({
store: this.storeZDList,
enableHdMenu: false,
region: 'center',
split: true,
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
selModel: this.ZD_CBM,
plugins: [this.ZD_CellEditing],
tbar: [{
text: '新建期货销售账单',
tooltip: '期货销售账单,从跟单信息取数',
//id: 'btndeldetail',
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddZD(1);
},
scope: this
}, {
text: '新建现货销售账单',
tooltip: '现货销售账单,从销售信息取数',
//id: 'btndeldetail',
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddZD(2);
},
scope: this
}, {
text: '删除销售账单',
tooltip: '删除销售账单',
//id: 'btndeldetail',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelZD(button, event, 1);
},
scope: this
}, '-', {
text: "采用/取消",
//id: "btnSaveTable_ZD",
handler: function (button, event) {
this.onMarkClick();
},
scope: this
}, '-', {
text: "保存列表样式",
id: "btnSaveTable_ZD",
handler: function (button, event) {
//this.column = DsTruck.SaveGridPanel(GID, this.formname, this.gridList.columns, this.column, 1, true);
var tempcolumns = this.ZDList.columns;
DsTruck.SaveGridPanel(USERID, this.formname_ZD, tempcolumns, this.ZDcolums, 0, true);
},
scope: this
}, '-', {
text: "生成账单项目",
id: "btnMakeOrder_ZDDetail",
menu: [
{ text: "RMB尾款(出入库)",
handler: function (button, event) {
_this.MakeOrderFee_RMB2("出入库");
}
}, { text: "USD尾款(出入库)",
handler: function (menu, event) {
_this.MakeOrderFee_USD2("出入库");
}
}, { text: "RMB尾款(倒柜)",
handler: function (button, event) {
_this.MakeOrderFee_RMB2("倒柜");
}
}, { text: "USD尾款(倒柜)",
handler: function (menu, event) {
_this.MakeOrderFee_USD2("倒柜");
}
}],
scope: this
},
{
text: "打印", //Print_importtrade_KHZD2
handler: function (menu, event) {
this.Print_KHDZ4();
},
scope: this
}],
columns: this.ZDcolums
});
/////////////以下部分为获取存储的gridpanel显示样式
this.ZDcolums = DsTruck.GetGridPanel(USERID, this.formname_ZD, this.ZDcolums, 0, true); //使用者id,表名,中间column数组,跳过一开始的几列
//this.girdcolums.unshift(new Ext.grid.RowNumberer());
this.ZDList.reconfigure(this.storeZDList, this.ZDcolums);
//this.gridList.columns[0] = new Ext.grid.RowNumberer();
////////////////////////////////////////////////
this.ZDList.getSelectionModel().on('select', function (model, record, index) {
var billno = record.data.GID;
_this.storeZDDetailList.load({ params: { condition: " ZD_GID='" + billno + "'"} });
_this.storeOrderChFee.load({ params: { billno: billno} });
});
//#endregion
//#region 账单明细
this.storeZDDetailList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'Import_SaleZDDetailmb',
remoteSort: false,
proxy: {
type: 'ajax',
url: '/Import/ImportSales/GetZDDetailList',
reader: {
id: '',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.ZDDetail_colums = [
{
sortable: true, hidden: true,
dataIndex: 'GID',
header: 'GID',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'SALESNO',
header: 'SALESNO',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'ZD_GID',
header: 'ZD_GID',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'SALEDETAIL_GID',
header: 'SALEDETAIL_GID',
width: 80
},
{
sortable: true,
dataIndex: 'NAME',
header: '品名',
width: 80
},
{
sortable: true,
dataIndex: 'WEIGHT',
header: '重量',
width: 80,
editor: {
xtype: 'numberfield', align: 'right',
allowBlank: false,
selectOnFocus: true, //精确到小数点后2位(执行4舍5入)
allowDecimals: true, //允许输入小数
//nanText: '请输入有效小数',
decimalPrecision: 2,
value: 0.00
}
},
{
sortable: true,
dataIndex: 'BOXCOUNT',
header: '件数',
width: 80,
editor: {
xtype: 'numberfield', align: 'right',
allowBlank: false,
selectOnFocus: true, //精确到小数点后2位(执行4舍5入)
allowDecimals: true, //允许输入小数
//nanText: '请输入有效小数',
decimalPrecision: 2,
value: 0.00
}
},
{
sortable: true,
dataIndex: 'CURRENCY',
header: '币别',
width: 80,
editor: {
xtype: 'textfield', align: 'right',
//allowBlank: false,
//selectOnFocus: true, //精确到小数点后2位(执行4舍5入)
//allowDecimals: true, //允许输入小数
//nanText: '请输入有效小数',
//decimalPrecision: 2,
value: ""
}
},
{
sortable: true,
dataIndex: 'PRICE',
header: '价格',
width: 80,
editor: {
xtype: 'numberfield', align: 'right',
allowBlank: false,
selectOnFocus: true, //精确到小数点后2位(执行4舍5入)
allowDecimals: true, //允许输入小数
//nanText: '请输入有效小数',
decimalPrecision: 6,
value: 0.000000
}
},
{
sortable: true,
dataIndex: 'AMOUNT',
header: '金额',
width: 80,
editor: {
xtype: 'numberfield', align: 'right',
allowBlank: false,
selectOnFocus: true, //精确到小数点后2位(执行4舍5入)
allowDecimals: true, //允许输入小数
//nanText: '请输入有效小数',
decimalPrecision: 2,
value: 0.00
}
},
{
sortable: true,
dataIndex: 'EXCHANGERATE_CUST',
header: '账单汇率',
width: 80,
editor: {
xtype: 'numberfield', align: 'right',
allowBlank: false,
selectOnFocus: true, //精确到小数点后2位(执行4舍5入)
allowDecimals: true, //允许输入小数
//nanText: '请输入有效小数',
decimalPrecision: 6,
value: 0.000000
}
},
{
sortable: true,
dataIndex: 'PREPAYMENT',
header: '实际定金',
width: 80,
editor: {
xtype: 'numberfield', align: 'right',
allowBlank: false,
selectOnFocus: true, //精确到小数点后2位(执行4舍5入)
allowDecimals: true, //允许输入小数
//nanText: '请输入有效小数',
decimalPrecision: 2,
value: 0.000000
}
},
{
sortable: true,
dataIndex: 'FUNDRATE',
header: '资金利率',
width: 80,
editor: {
xtype: 'numberfield', align: 'right',
allowBlank: false,
selectOnFocus: true, //精确到小数点后2位(执行4舍5入)
allowDecimals: true, //允许输入小数
//nanText: '请输入有效小数',
decimalPrecision: 2,
value: 0.00
}
},
{
sortable: true,
dataIndex: 'STOCKDATE_1',
header: '开始计费日期',
width: 80,
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
editor: {
xtype: 'datefield', align: 'right',
allowBlank: false,
selectOnFocus: true //精确到小数点后2位(执行4舍5入)
}
},
{
sortable: true,
dataIndex: 'STOCKDATE_2',
header: '结束计费日期',
width: 80,
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
editor: {
xtype: 'datefield', align: 'right',
allowBlank: false,
selectOnFocus: true //精确到小数点后2位(执行4舍5入)
}
},
{
sortable: true,
dataIndex: 'AGENCRATE_CUST',
header: '应收代理费率',
width: 80,
editor: {
xtype: 'numberfield', align: 'right',
allowBlank: false,
selectOnFocus: true, //精确到小数点后2位(执行4舍5入)
allowDecimals: true, //允许输入小数
//nanText: '请输入有效小数',
decimalPrecision: 2,
value: 0.00
}
},
{
sortable: true,
dataIndex: 'REMARK',
header: '备注',
width: 200,
editor: {
xtype: 'textfield', //align: 'right',
allowBlank: false,
selectOnFocus: true
}
}
];
this.ZDDetail_CellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.ZDDetail_CBM = Ext.create('Ext.selection.CheckboxModel');
this.ZDDetailList = new Ext.grid.GridPanel({
store: this.storeZDDetailList,
enableHdMenu: false,
region: 'south',
height: 300,
split: true,
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
selModel: this.ZDDetail_CBM,
plugins: [this.ZDDetail_CellEditing],
tbar: [{
text: '删除明细',
//tooltip: '向销售单内添加货物',
//id: 'btnaddbill',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelZDDetail(button, event);
},
scope: this
}, {
text: '保存账单明细',
//tooltip: '向销售单内添加货物',
//id: 'btnaddbill',
iconCls: "btnsave",
handler: function (button, event) {
this.onSaveZDDetail(button, event);
},
scope: this
}, '-', {
text: "保存列表样式",
id: "btnSaveTable_ZDDetail",
handler: function (button, event) {
//this.column = DsTruck.SaveGridPanel(GID, this.formname, this.gridList.columns, this.column, 1, true);
var tempcolumns = this.ZDDetailList.columns;
DsTruck.SaveGridPanel(USERID, this.formname_ZDDetail, tempcolumns, this.ZDDetail_colums, 0, true);
},
scope: this
}],
columns: this.ZDDetail_colums,
// paging bar on the bottom
bbar: Ext.create('Ext.PagingToolbar', {
store: this.storeBodyAddList,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
})
});
/////////////以下部分为获取存储的gridpanel显示样式
this.ZDDetail_colums = DsTruck.GetGridPanel(USERID, this.formname_ZDDetail, this.ZDDetail_colums, 0, true); //使用者id,表名,中间column数组,跳过一开始的几列
//this.girdcolums.unshift(new Ext.grid.RowNumberer());
this.ZDDetailList.reconfigure(this.storeZDDetailList, this.ZDDetail_colums);
//this.gridList.columns[0] = new Ext.grid.RowNumberer();
////////////////////////////////////////////////
//#endregion
//#region 账单费用列表
this.storeOrderChFee = Ext.create('Ext.data.Store', {
model: 'MsChFee_Sales',
remoteSort: false,
proxy: {
type: 'ajax',
url: '/Import/ImportSales/GetOrderDataList',
reader: {
id: 'GId',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.comboxCargo = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '币别',
allowBlank: false,
store: this.storeBodyList,
forceSelection: true,
name: 'CARGO_GID',
valueField: 'CARGO_GID',
displayField: 'NAME'
});
this.initOrderFeecolums = [
{
sortable: true,
dataIndex: 'GId',
header: '惟一编号',
hidden: true,
width: 160
}, {
sortable: true,
dataIndex: 'BsNo',
header: '业务编号',
hidden: true,
width: 200
}, {
sortable: true, hidden: true,
dataIndex: 'FeeStatus',
header: '费用状态',
renderer: function (value, p, record) {
return record.data.FeeStatus_Ref;
},
width: 66
}, {
sortable: true, hidden: true,
dataIndex: 'FeeType',
header: 'FeeType',
width: 66
}, {
sortable: true,
dataIndex: 'FeeName',
header: '账单项目',
editor: this.comboxFeeNameRef2,
width: 100
}, {
sortable: true, hidden: true,
dataIndex: 'CustomerType',
header: '客户类别',
editor: this.comboxCustType,
// hidden: true,
width: 80
}, {
sortable: true, hidden: true,
dataIndex: 'CustomerName',
header: '结算对象',
editor: this.comboxCustomerNameRef,
width: 120
}, {
sortable: true, hidden: true,
dataIndex: 'Unit',
header: '单位标准',
editor: this.comboxUnit,
width: 60
}, {
sortable: true, hidden: true,
dataIndex: 'UnitPrice',
header: '不含税单价',
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
selectOnFocus: true,
hideTrigger: true,
mouseWheelEnabled: false,
enableKeyEvents: true,
listeners: {
keydown: function (textfield, e) {
if (e.getKey() == 40) {
_this.onNextKeyClick(1, 8)
}
}
}
},
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 '' + lsValue + '';
}
}
else {
return value;
}
}
catch (e) {
return value;
}
return value;
},
align: 'right',
width: 80
}, {
sortable: true, hidden: true,
dataIndex: 'TaxRate',
header: '税率',
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
selectOnFocus: true,
hideTrigger: true,
mouseWheelEnabled: false,
enableKeyEvents: true,
listeners: {
keydown: function (textfield, e) {
if (e.getKey() == 40) {
_this.onNextKeyClick(1, 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 '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; },
align: 'right',
width: 60
}, {
sortable: true, hidden: true,
dataIndex: 'TaxUnitPrice',
header: '单价',
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
selectOnFocus: true,
hideTrigger: true,
mouseWheelEnabled: false,
enableKeyEvents: true,
listeners: {
keydown: function (textfield, e) {
if (e.getKey() == 40) {
_this.onNextKeyClick(1, 10)
}
}
}
},
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 '' + lsValue + '';
}
}
else {
return value;
}
}
catch (e) {
return value;
}
return value;
},
align: 'right',
width: 80
}, {
sortable: true, hidden: true,
dataIndex: 'Quantity',
header: '数量',
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
allowDecimals: true,
decimalPrecision: 3,
selectOnFocus: true,
hideTrigger: true,
mouseWheelEnabled: false,
enableKeyEvents: true,
listeners: {
keydown: function (textfield, e) {
if (e.getKey() == 40) {
_this.onNextKeyClick(1, 11)
}
}
}
},
width: 60
}, {
sortable: true, hidden: true,
dataIndex: 'NoTaxAmount',
header: '不含税金额',
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
selectOnFocus: true,
hideTrigger: true,
mouseWheelEnabled: false,
enableKeyEvents: true,
listeners: {
keydown: function (textfield, e) {
if (e.getKey() == 40) {
_this.onNextKeyClick(1, 12)
}
}
}
},
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 '' + lsValue + '';
}
}
else {
return value;
}
}
catch (e) {
return value;
}
return value;
},
align: 'right',
width: 80
}, {
sortable: true,
dataIndex: 'Amount',
header: '数量/金额',
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
try {
var lsValue = usMoney(value, 6, '', false);
if (lsValue != "NaN") {
value = lsValue; if (parseFloat(lsValue) < 0) {
return '' + lsValue + '';
}
}
else {
return value;
}
}
catch (e) {
return value;
}
return value;
},
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
selectOnFocus: true,
hideTrigger: true,
mouseWheelEnabled: false,
enableKeyEvents: true,
decimalPrecision: 6,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 6, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; },
listeners: {
keydown: function (textfield, e) {
if (e.getKey() == 40) {
_this.onNextKeyClick(1, 13)
}
}
}
},
align: 'right',
width: 80
}, {
sortable: true, hidden: true,
dataIndex: 'Currency',
header: '币别',
editor: this.comboxCurr,
width: 40
}, {
sortable: true, hidden: true,
dataIndex: 'ExChangerate',
header: '汇率',
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
selectOnFocus: true,
hideTrigger: true,
mouseWheelEnabled: false,
enableKeyEvents: true,
listeners: {
keydown: function (textfield, e) {
if (e.getKey() == 40) {
_this.onNextKeyClick(1, 15)
}
}
}
},
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 '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; },
align: 'right',
width: 60
}, {
sortable: true, hidden: true,
dataIndex: 'AccTaxRate',
header: '销项税率',
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
selectOnFocus: true,
hideTrigger: true,
mouseWheelEnabled: false,
enableKeyEvents: true,
listeners: {
keydown: function (textfield, e) {
if (e.getKey() == 40) {
_this.onNextKeyClick(1, 16)
}
}
}
},
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 '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; },
align: 'right',
width: 80
}, {
sortable: true, hidden: true,
dataIndex: 'Remark',
header: '备注',
editor: {
xtype: 'textfield',
selectOnFocus: true,
enableKeyEvents: true,
listeners: {
keydown: function (textfield, e) {
if (e.getKey() == 40) {
_this.onNextKeyClick(1, 17)
}
}
}
},
width: 150
}, {
sortable: true, hidden: true,
dataIndex: 'IsAdvancedpay',
header: '是否垫付',
editor: {
xtype: 'checkboxfield'
// selectOnFocus: true
},
width: 60
}, {
sortable: true, hidden: true,
dataIndex: 'FeeFrt',
header: 'FRT',
editor: this.comboxFeeFrt,
width: 40
}, {
sortable: true, hidden: true,
dataIndex: 'Commissionrate',
header: '佣金比率',
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
selectOnFocus: true,
mouseWheelEnabled: false,
enableKeyEvents: true,
listeners: {
keydown: function (textfield, e) {
if (e.getKey() == 40) {
_this.onNextKeyClick(1, 19)
}
}
}
},
width: 60
}, {
dataIndex: 'CARGO_GID',
header: '销售商品',
//allowBlank: false,
renderer: function (value, p, record) {
if (value == null || value == '')
return '';
else
return record.data.CARGO_NAME;
},
editor: this.comboxCargo,
width: 80
}, {
sortable: true, hidden: true,
dataIndex: 'CARGO_NAME',
header: 'CARGO_NAME',
width: 60
}, {
sortable: true, hiddenfield: true,
dataIndex: 'MODIFIEDUSER',
header: '修改人',
width: 60
}, {
sortable: true, hiddenfield: true,
dataIndex: 'MODIFIEDTIME',
header: '修改日期',
renderer: Ext.util.Format.dateRenderer('Y-m-d H:i:s'),
width: 80
}
];
this.OrderFeeColumn = this.initOrderFeecolums;
this.cellEditingOrderFee = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.OrderfeeCBM = Ext.create('Ext.selection.CheckboxModel');
this.gridListOrderFee = new Ext.grid.GridPanel({
store: this.storeOrderChFee,
title: '账单费用',
enableHdMenu: false,
//layout: "border",
region: 'east',
width: 400,
split: true,
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.cellEditingOrderFee],
selModel: this.OrderfeeCBM,
selType: 'cellmodel',
viewConfig: {
autoFill: true,
enableTextSelection: true,
getRowClass: function (record, rowIndex, rowParams, store) {
//var feeStatus = record.get('FeeStatus');
//return DsTruck.MsChFeeGetRowClass(feeStatus);
}
},
features: [{
id: 'group',
//ftype: 'grouping',
ftype: 'groupingsummary',
groupHeaderTpl: '{name}',
hideGroupedHeader: false,
enableGroupingMenu: true
}],
tbar: [{ xtype: 'label', id: 'label3', text: "账单费用" }, '-',
{
text: '增加明细', //hidden: true,
tooltip: '增加明细', id: "addOrderfee",
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddOrderClick(button, event);
},
scope: this
}, {
text: '删除明细', //hidden: true,
tooltip: '删除明细', id: "delOrderfee",
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelOrderClick(button, event);
},
scope: this
}, {
id: "SaveOrderfee", //hidden: true,
text: '保存修改',
tooltip: '保存修改',
iconCls: "btnsave",
handler: function (button, event) {
this.SaveOrderFee();
//alert(USERID);
},
scope: this
}, {
text: "保存列表样式",
id: "btnSaveTable3",
handler: function (button, event) {
var tempcolumns = this.gridListOrderFee.columns;
DsTruck.SaveGridPanel(USERID, this.formname_ZDFee, tempcolumns, this.OrderFeeColumn, 0, true);
},
scope: this
}],
columns: this.OrderFeeColumn
});
/////////////以下部分为获取存储的gridpanel显示样式
this.OrderFeeColumn = DsTruck.GetGridPanel(USERID, this.formname_ZDFee, this.OrderFeeColumn, 1); //使用者id,表名,中间column数组,跳过一开始的几列
this.OrderFeeColumn.unshift(new Ext.grid.RowNumberer());
this.gridListOrderFee.reconfigure(this.storeOrderChFee, this.OrderFeeColumn);
////////////////////////////////////////////////
this.gridListOrderFee.on('edit', function (editor, e, eOpts) {
//this.gridAddFeeListAfterEdit(editor, e, eOpts);
this.gridListOrderFeeAfterEdit(editor, e, eOpts);
}, this);
//#endregion
//#region 明细表-单据档案管理
this.storeReceiptid = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeReceiptid.load({ params: { enumTypeId: 2} });
this.comboxReceiptid = Ext.create('DsExt.ux.RefEnumCombox', {
store: this.storeReceiptid,
name: 'RECEIPTTYPE',
valueField: 'EnumValueName',
displayField: 'EnumValueName'
});
this.storeDocList = Ext.create('Ext.data.Store', {
model: 'ReceiptDocmb',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/Import/ReceiptDoc/GetDocList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//明细表表格
this.DocListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.DocCM = Ext.create('Ext.selection.CheckboxModel');
this.gridDocList = new Ext.grid.GridPanel({
store: this.storeDocList,
enableHdMenu: false,
region: 'west',
width: 350,
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.DocListCellEditing],
selModel: this.DocCM,
selType: 'cellmodel',
tbar: [{
text: '添加', hidden: true,
tooltip: '添加',
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddFileClick(button, event);
},
scope: this
}, '-', {
text: '删除', hidden: true,
tooltip: '删除',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelFileClick(button, event);
},
scope: this
}, '-', {
text: '保存', hidden: true,
tooltip: '保存',
iconCls: "btnsave",
handler: function (button, event) {
this.onPostFileClick(button, event);
},
scope: this
}, '-', {
text: '上传附件', hidden: true,
tooltip: '上传附件',
iconCls: "btnadddetail",
handler: function (button, event) {
this.onUpLoadFileClick(button, event);
},
scope: this
}],
columns: [{
sortable: true, hidden: true,
dataIndex: 'GID',
header: 'GID',
width: 80
},
{
sortable: true,
dataIndex: 'RECEIPTTYPE',
header: '单据类型',
editor: this.comboxReceiptid,
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'R_GID',
header: 'R_GID',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'BSNO',
header: 'BSNO',
width: 80
},
{
sortable: true,
dataIndex: 'URL',
header: '文件名',
width: 140,
editor: {
xtype: 'textfield'
}
},
{
sortable: true, hidden: true,
dataIndex: 'Driect_URL',
header: 'Driect_URL',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'MODIFIEDUSER',
header: 'MODIFIEDUSER',
width: 80
},
{
sortable: true,
dataIndex: 'MODIFIEDUSERRef',
header: '修改人',
width: 80
},
{
sortable: true,
dataIndex: 'MODIFIEDTIME',
header: '修改时间',
width: 85
}
]
});
this.gridDocList.getSelectionModel().on('select', function (model, record, index) {
if (this.Loading == true) {
return;
}
var PICURL = record.data.Driect_URL;
Ext.getCmp('panelPic').body.update(' ');
}, this);
//#endregion
//#region 布局
//控件布局
if (SPTYPE == "跟单销售") {
this.panelService = new Ext.Panel({
layout: "border",
region: 'center',
margin: '2 2',
items: [this.gridList]
});
this.panelPic = new Ext.Panel({
id: "panelPic",
layout: "fit",
region: "center",
autoScroll: true,
frame: false,
html: ' '//ftp://bjes:@120.27.53.37/dhm-11111/2.jpg
});
this.panelAddfee = new Ext.tab.Panel({
layout: "border",
region: "east",
width: 600,
split: true,
items: [
this.gridListChFee
]
});
this.paneldetail = new Ext.Panel({
title: '销售明细',
layout: "border",
height: 240,
region: "north",
split: true,
items: [
this.panelService, this.panelAddfee
]
});
this.panelAddService = new Ext.Panel({
layout: "border",
region: 'center',
margin: '2 2',
items: [this.gridAddList]
});
this.paneladddetail = new Ext.Panel({
layout: "border",
region: 'center',
height: 300,
items: [
this.panelAddService
]
});
this.paneladd = new Ext.Panel({
title: '添加销售明细', id: "paneladd",
layout: "border",
// region: 'south',
region: "center",
// height: 420,
items: [
this.formSearch, this.paneladddetail
]
});
this.paneldetailacc = new Ext.Panel({
//预收预付的使用列表
layout: "border",
height: 160,
region: "north",
split: true,
items: [
this.gridBodyListAcc
]
});
this.panelAddacc = new Ext.Panel({
//预收预付列表
layout: "border",
height: 160,
region: "center",
margin: '2 2',
items: [this.gridListAcc]
});
this.panelaccdetail = new Ext.Panel({
title: '认款/确认核销', id: "panelaccdetail",
layout: "border",
autoScroll: true,
//height: 360,
region: "center",
//split: true,
items: [
this.paneldetailacc, this.panelAddacc
]
});
var _this = this;
this.MainTab = new Ext.tab.Panel({
layout: "border",
region: "center",
split: true,
items: [this.paneladd//, this.panelaccdetail
],
listeners: {
tabchange: function (tp, p) {
if (p.title == '认款/确认核销') {
//autoResize();
//alert("刷新预收取用");
_this.LoadAccBodyList();
}
}
}
});
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 185,
items: [this.panelBtn, this.formEdit]
});
this.page1 = new Ext.Panel({
layout: "border", title: "销售单明细信息",
region: "center",
items: [this.paneldetail, this.MainTab]
});
this.page2 = new Ext.Panel({
layout: "border", title: "销售单账单",
region: "center",
items: [this.ZDList, this.ZDDetailList, this.gridListOrderFee]
});
this.page3 = new Ext.Panel({
layout: "border", title: "相关采购单附件",
region: "center",
items: [this.gridDocList, this.panelPic]
});
this.tabBottom = new Ext.TabPanel({
activeTab: 0,
autoWidth: true,
//border: true,
frame: false,
region: 'center',
//enableTabScroll: true,
items:
[
this.page1
, this.page2
, this.page3
]
});
Ext.apply(this, {
items: [this.panelTop, this.tabBottom]
});
}
if (SPTYPE == "财务核销") {
this.panelService = new Ext.Panel({
layout: "border",
region: 'center',
margin: '2 2',
items: [this.gridList]
});
this.panelPic = new Ext.Panel({
id: "panelPic",
layout: "fit",
region: "center",
autoScroll: true,
frame: false,
html: ' '//ftp://bjes:@120.27.53.37/dhm-11111/2.jpg
});
this.panelAddfee = new Ext.tab.Panel({
layout: "border", //hidden:true,
region: "east",
width: 600,
split: true,
items: [//this.gridListOrderFee,
this.gridListChFee
]
});
this.paneldetail = new Ext.Panel({
title: '销售明细',
layout: "border",
height: 240,
region: "north",
split: true,
items: [
this.panelService, this.panelAddfee
]
});
this.panelAddService = new Ext.Panel({
layout: "border",
region: 'center',
margin: '2 2',
items: [this.gridAddList]
});
this.paneladddetail = new Ext.Panel({
layout: "border",
region: 'center',
height: 300,
items: [
this.panelAddService
]
});
this.paneladd = new Ext.Panel({
title: '添加销售明细', id: "paneladd",
layout: "border", //hidden: true,
// region: 'south',
region: "center",
// height: 420,
items: [
this.formSearch, this.paneladddetail
]
});
this.paneldetailacc = new Ext.Panel({
//预收预付的使用列表
layout: "border",
height: 160,
region: "north",
split: true,
items: [
this.gridBodyListAcc
]
});
this.panelAddacc = new Ext.Panel({
//预收预付列表
layout: "border",
height: 160,
region: "center",
margin: '2 2',
items: [this.gridListAcc]
});
this.panelaccdetail = new Ext.Panel({
title: '认款/确认核销', id: "panelaccdetail",
layout: "border",
autoScroll: true,
//height: 360,
region: "center",
//split: true,
items: [
this.paneldetailacc, this.panelAddacc
]
});
var _this = this;
this.MainTab = new Ext.tab.Panel({
layout: "border",
region: "center",
split: true,
items: [//this.paneladd,
this.panelaccdetail
],
listeners: {
tabchange: function (tp, p) {
if (p.title == '认款/确认核销') {
//autoResize();
//alert("刷新预收取用");
_this.LoadAccBodyList();
}
}
}
});
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 185,
items: [this.panelBtn, this.formEdit]
});
this.page1 = new Ext.Panel({
layout: "border", title: "销售单明细信息",
region: "center",
items: [this.paneldetail, this.MainTab]
});
this.page2 = new Ext.Panel({
layout: "border", title: "相关采购单附件",
region: "center",
items: [this.gridDocList, this.panelPic]
});
this.tabBottom = new Ext.TabPanel({
activeTab: 0,
autoWidth: true,
//border: true,
frame: false,
region: 'center',
//enableTabScroll: true,
items:
[
this.page1
, this.page2
]
});
Ext.apply(this, {
items: [this.panelTop, this.tabBottom]
});
}
//#endregion
//绑定查询窗体
this.ParentWin = window.parent.opener;
//初始化数据
this.InitData();
//#region 绑定事件
var billno = '*';
if (this.opStatus == 'edit') {
billno = this.editRecord.get('BILLNO');
};
if (this.opStatus == 'Audit') {
billno = this.editRecord.get('SALESNO');
};
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.storeBodyAddList.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);
} else {
this.storeAddFeeList.removeAll();
}
}, this);
this.gridAddList.getSelectionModel().on('select', function (model, record, index) {
var bsno = record.data.BSNO;
var feeobjname = record.data.FEEOBJNAME;
var sql = "";
sql = " BSNO='" + bsno + "' AND CUSTOMERNAME='" + feeobjname + "'";
sql = sql + getAndConSql(sql, this.FeeSqlStr, this.FeeSqlStr);
this.storeAddFeeList.load({ params: { condition: sql} });
}, this);
this.gridList.on('edit', function (editor, e, eOpts) {
this.DetailAfterEdit(editor, e, eOpts);
}, this);
this.gridListChFee.on('edit', function (editor, e, eOpts) {
this.gridListChFeeAfterEdit(editor, e, eOpts);
}, this);
this.cellEditingChFee.on('beforeedit', function (editor, e) {
//Ext.getCmp("zongshu").setText("1234");
return this.cellEditingChFeeBeforeEdit(editor, e);
}, this);
//累积选中的“本次核销金额”
this.gridListAcc.getSelectionModel().on('select', function (button, event) {
this.onSelectAcc(button, event);
}, this);
this.gridListAcc.on('cellclick', function (button, event) {
this.onSelectAcc(button, event);
}, this);
this.gridListAcc.on('edit', function (editor, e, eOpts) {
this.onSelectAcc(editor, e, eOpts);
}, this);
//#endregion
}, //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];
//this.CWAuditSales = ret[3];
}
if (this.opStatus == 'edit')
condition = " s.GID='" + this.editRecord.get('GID') + "'";
if (this.opStatus == 'audit') {
//alert(this.CWAuditSales.SALESNO);
condition = " s.SALESNO='" + this.editRecord.get('SALESNO') + "'";
}
if (SPTYPE == "跟单销售") {
Ext.getCmp("delChfee").hide();
Ext.getCmp("SaveChfee").hide();
Ext.getCmp("AuditBackChfee").hide();
}
if (SPTYPE == "财务核销") {
Ext.getCmp("delChfee").show();
Ext.getCmp("SaveChfee").show();
Ext.getCmp("AuditBackChfee").show();
}
this.LoadData(this.opStatus, condition);
}, //end InitData
LoadData: function (opstatus, condition) {
this.serialNo = 0;
this.workSerialNo = 0;
this.bodyDel = [];
this.storeAccBodyList.removeAll();
this.opStatus = opstatus;
_this = this;
Ext.Ajax.request({
async: false,
waitMsg: '正在查询主表数据...',
url: '/Import/ImportSales/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;
if (data.SALESDATE == "") { data.SALESDATE = currdate.format('yyyy-MM-dd') };
if (data.OP == "") { data.OP = USERNAME };
if (data.BSSTATUS == "") { data.BSSTATUS = "0" };
if (data.FEESTATUS == "") { data.FEESTATUS = "0" };
if (data.PREPAYMENT == "") { data.PREPAYMENT = "0" };
//if (data.FUNDRATE == "") { data.FUNDRATE = "0" };
_this.formEdit.getForm().reset();
_this.formEdit.getForm().setValues(data);
_this.GetEditStatus();
Ext.getCmp("APSearch").setValue("1");
billno = data.SALESNO;
this.storeBodyListAcc.load({ params: { condition: " SETTLEBILLNO='" + billno + "'" },
callback: function (r, options, success) {
if (success) {
//if (_this.storeBodyListAcc.getCount() > 0) (this.comboxCurrADVANCE.readOnly = true)
}
},
scope: this
});
var condition2 = " BSNO in(select distinct BSNO from import_saleDetail where salesno= '" + billno + "') ";
this.Loading = true;
this.storeDocList.load({
params: { condition: condition2 },
waitMsg: "正在查询数据...",
scope: this,
callback: function () {
this.Loading = false;
}
});
this.storeZDList.load({
params: { condition: "SALESNO='" + billno + "'" },
waitMsg: "正在查询数据...",
scope: this
});
this.SetBtnEnable(data);
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
var billno = '*';
if (this.opStatus == 'edit') {
billno = this.editRecord.get('SALESNO');
};
this.storeBodyList.load({ params: { condition: " s.SalesNO='" + billno + "'" },
callback: function (r, options, success) {
if (success) {
if (this.storeBodyList.getCount() > 0) {
this.HTH = this.storeBodyList.getAt(0).data.HTH;
}
else {
//this.comboxCustCode.setReadOnly(false);
}
}
},
scope: this
});
this.storeBodyChFee.load({ params: { SALESNO: billno },
callback: function (r, options, success) {
if (success) {
if (this.storeBodyList.getCount() > 0) {
//this.comboxCustCode.setReadOnly(true);
}
else {
//this.comboxCustCode.setReadOnly(false);
}
}
},
scope: this
});
//this.storeOrderChFee.load({ params: { billno: billno, type: 1, optype: "进口贸易销售单"} });
}, // end LoadDate
SetBtnEnable: function (data) {
/*
if (SPTYPE == "跟单销售") {
Ext.getCmp("paneladd").show();
Ext.getCmp("panelaccdetail").hide();
}
if (SPTYPE == "财务核销") {
Ext.getCmp("paneladd").hide();
Ext.getCmp("panelaccdetail").show();
}*/
if (data.SALESTATUS == "1") {//财务允许出库
Ext.getCmp('btnESave').disable(); //保存按钮置灰
Ext.getCmp('btnESaveAndClose').disable(); //enable;
Ext.getCmp('btnSubmitAudit').enable();
Ext.getCmp('btnSubmitAuditBack').disable();
Ext.getCmp('btnEndSales').disable();
Ext.getCmp('btnUnEndSales').disable();
Ext.getCmp('btnaddbill').disable();
Ext.getCmp('btndeldetail').disable();
} else
if (data.SALESTATUS == "0") {//录入状态
Ext.getCmp('btnESave').enable(); //enable();
Ext.getCmp('btnESaveAndClose').enable(); //enable;
Ext.getCmp('btnSubmitAudit').disable();
Ext.getCmp('btnSubmitAuditBack').disable();
Ext.getCmp('btnEndSales').disable();
Ext.getCmp('btnUnEndSales').disable();
Ext.getCmp('btnaddbill').enable();
Ext.getCmp('btndeldetail').enable();
} else
if (data.SALESTATUS == "2") {//提交出库状态
Ext.getCmp('btnESave').disable(); //enable();
Ext.getCmp('btnESaveAndClose').disable(); //enable;
Ext.getCmp('btnSubmitAudit').disable();
Ext.getCmp('btnSubmitAuditBack').enable();
Ext.getCmp('btnEndSales').enable();
Ext.getCmp('btnUnEndSales').disable();
Ext.getCmp('btnaddbill').disable();
Ext.getCmp('btndeldetail').disable();
} else
if (data.SALESTATUS == "3") {//销售单结束状态
Ext.getCmp('btnESave').disable(); //enable();
Ext.getCmp('btnESaveAndClose').disable(); //enable;
Ext.getCmp('btnSubmitAudit').disable();
Ext.getCmp('btnSubmitAuditBack').disable();
Ext.getCmp('btnEndSales').disable();
Ext.getCmp('btnUnEndSales').enable();
Ext.getCmp('btnaddbill').disable();
Ext.getCmp('btndeldetail').disable();
}
if (this.OpStatus == "audit") {
Ext.getCmp('btnESave').disable(); //enable();
Ext.getCmp('btnESaveAndClose').disable(); //enable;
Ext.getCmp('btnSubmitAudit').disable();
Ext.getCmp('btnSubmitAuditBack').disable();
Ext.getCmp('btnEndSales').disable();
Ext.getCmp('btnUnEndSales').disable();
Ext.getCmp('btnaddbill').disable();
Ext.getCmp('btndeldetail').disable();
}
if (SPTYPE == "财务核销") {
Ext.getCmp('btnESave').disable(); //enable();
Ext.getCmp('btnESaveAndClose').disable(); //enable;
Ext.getCmp('btnSubmitAudit').disable();
Ext.getCmp('btnSubmitAuditBack').disable();
Ext.getCmp('btnEndSales').disable();
Ext.getCmp('btnUnEndSales').disable();
Ext.getCmp('btnaddbill').disable();
Ext.getCmp('btndeldetail').disable();
}
},
PrevRecord: function () {
if (this.opStatus == 'add') {
return;
}
var modifystr = this.getIsModify();
if (modifystr != "") {
Ext.Msg.show({ title: '警告', msg: modifystr + '未保存,如果离开此页,将丢失未保存的更改 !!!', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var j = this.StoreList.indexOf(this.editRecord);
if (j == 0) {
Ext.Msg.show({ title: '警告', msg: '已是最前一票', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
if (j == this.StoreList.count) {
Ext.Msg.show({ title: '警告', msg: '已是最后一票', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
j = j - 1;
this.editRecord = this.StoreList.getAt(j);
if (this.opStatus == 'edit') {
condition = "s.GID='" + this.editRecord.get('GID') + "'";
//this.storeBodyList.load({ params: { condition: condition} });
}
this.LoadData(this.opStatus, condition);
},
NextRecord: function () {
if (this.opStatus == 'add') {
return;
}
var modifystr = this.getIsModify();
if (modifystr != "") {
Ext.Msg.show({ title: '警告', msg: modifystr + '未保存,如果离开此页,将丢失未保存的更改 !!!', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var j = this.StoreList.indexOf(this.editRecord);
if (j == (this.StoreList.data.length - 1)) {
Ext.Msg.show({ title: '警告', msg: '已是最后一票', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
j = j + 1;
this.editRecord = this.StoreList.getAt(j);
if (this.opStatus == 'edit') {
condition = "s.GID='" + this.editRecord.get('GID') + "'";
//this.storeBodyList.load({ params: { condition: condition} });
}
this.LoadData(this.opStatus, condition);
},
Save: function (type) {
var basicForm = this.formEdit.getForm();
if (!basicForm.isValid()) {
return;
}
var data = basicForm.getValues();
var SALESNO = data.SALESNO;
var bodydatas = [];
for (var i = 0; i < this.storeBodyList.getCount(); i += 1) {
var member = this.storeBodyList.getAt(i);
bodydatas.push(member);
}
var jsonDetailBody = ConvertRecordsToJson(bodydatas);
var bodyChFeeDatas = [];
for (i = 0; i < this.storeBodyChFee.getCount(); i += 1) {
var memberyf = this.storeBodyChFee.getAt(i);
bodyChFeeDatas.push(memberyf);
var amount = memberyf.data.Amount;
if (amount == 0) {
Ext.Msg.show({ title: '警告',
msg: '费用的金额不允许为0,请修改后再保存',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
return;
}
};
var jsonChFeeBody = ConvertRecordsToJson(bodyChFeeDatas);
//var jsonChFeeDelBody = ConvertRecordsToJsonAll(this.feeBodyDel);
//////////////////////////////////////////
var bodyOrderFeeDatas = [];
for (i = 0; i < this.storeOrderChFee.getCount(); i += 1) {
var memberyf = this.storeOrderChFee.getAt(i);
bodyOrderFeeDatas.push(memberyf);
/*
var amount = memberyf.data.Amount;
if (amount == 0) {
Ext.Msg.show({ title: '警告',
msg: '费用的金额不允许为0,请修改后再保存',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
return;
}*/
};
var jsonOrderFeeBody = ConvertRecordsToJson(bodyOrderFeeDatas);
data.REPLY = this.formEdit.getForm().findField('REPLY').getValue() ? 1 : 0;
data.ISMAKED = this.formEdit.getForm().findField('ISMAKED').getValue() ? 1 : 0;
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
async: false,
url: '/Import/ImportSales/Save',
scope: this,
params: {
//opstatus: this.opStatus,
opstatus: this.opStatus,
data: Ext.JSON.encode(data),
SaleDetailList: jsonDetailBody,
OrderFeeList: jsonOrderFeeBody
},
callback: function (options, success, response) {
if (success) {
this.feeBodyDel = [];
this.storeBodyChFee.commitChanges();
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var returnData = jsonresult.Data;
this.formEdit.getForm().setValues(returnData);
this.storeBodyList.commitChanges();
if (this.opStatus == 'add') {
var arrNewRecords = this.StoreList.add(returnData);
this.editRecord = arrNewRecords[0];
}
else if (this.opStatus == 'edit') {
var editp = Ext.create('ImportSalesmb', 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.storeBodyList.load({ params: { condition: " s.SaleSNO='" + this.editRecord.get("SALESNO") + "'"} });
//this.storeOrderChFee.load({ params: { billno: this.editRecord.get("SALESNO"), type: 1, optype: "进口贸易销售单"} });
} 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
getIsModify: function () {
var DetailDirty = GetDirty1(panelEdit.storeBodyList);
if (panelEdit.formEdit.getForm().isDirty() == true) {
return '销售单信息';
}
else
if (DetailDirty == true) {
return '销售明细信息';
}
else return '';
},
onAddDetailClick: function (button, event) {
this.addstore = true;
this.addDetail();
}, //end onAddDetailClick
onAddBillClick: function (button, event) {
this.addstore = true;
this.addBill();
}, //end onAddDetailClick
onDelDetailClick: function (button, event, type) {
this.deleteDetail();
}, //onDelDetailClick
onAddClick: function (button, event) {
//传递GID参数
//添加销售
var formEdit = this.formEdit.getForm();
var CUSTOMERNAME = formEdit.findField('CUSTOMERNAME').getValue();
if (CUSTOMERNAME == "") {
alert("请先选择购货单位(销售对象)");
return;
/*
selectedRecords = this.gridAddList.selModel.getSelection();
var _CUSTOMERNAME="";
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
_CUSTOMERNAME=rec.get('CUSTOMERNAME');
}
Ext.getCmp("CUSTOMERNAME").setValue(_CUSTOMERNAME);
*/
} else {
formEdit = this.formEdit.getForm();
if (this.opStatus == "add") {
selectedRecords = this.gridAddList.selModel.getSelection();
var rec = selectedRecords[0];
formEdit.findField('SALESNO').setValue(rec.data.HTH);
this.HTH = rec.data.HTH;
}
this.Save('0');
var SALESNO = formEdit.findField('SALESNO').getValue();
if (SALESNO == "") {
return;
} else {
var condition2 = " BSNO in(select distinct BSNO from import_saleDetail where salesno= '" + SALESNO + "') ";
this.Loading = true;
this.storeDocList.load({
params: { condition: condition2 },
waitMsg: "正在查询数据...",
scope: this,
callback: function () {
this.Loading = false;
}
});
}
var MainList = "";
selectedRecords = this.gridAddList.selModel.getSelection();
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.get('HTH') != this.HTH && this.HTH != "") {
continue;
}
if (MainList == "") { MainList = "'" + rec.get('GID') + "'"; }
else {
MainList = MainList + ",'" + rec.get('GID') + "'";
this.HTH = rec.get('HTH');
}
}
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Import/ImportSales/AddSales',
scope: this,
params: {
SALESNO: SALESNO,
CargoList: MainList
},
callback: function (options, success, response) {
if (success) {
this.storeBodyList.load({ params: { condition: " s.SaleSNO='" + SALESNO + "'"} });
this.onRefreshClick();
} else {
Ext.Msg.show({ title: '请重试',
msg: '服务器响应出错',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
}
}
});
}
},
onDeleteClick: function (button, event) {
var MainList = "";
var GID = "";
selectedRecords = this.gridList.selModel.getSelection();
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (MainList == "") { MainList = "'" + rec.get('GID') + "'"; }
else {
MainList = MainList + ",'" + rec.get('GID') + "'";
}
}
var formEdit = this.formEdit.getForm();
var SALESNO = formEdit.findField('SALESNO').getValue();
if (MainList == "") {
return;
}
else
Ext.MessageBox.confirm('提示', '确定删除这些记录吗?(有相关费用的销售明细将无法删除)', function (btn) {
if (btn == 'yes') {
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
var GID = rec.get('GID');
//var SALESNO = rec.data.SALESNO;
var CARGONAME = rec.get('NAME');
var sql = " SALESNO in (select SALESNO from import_deliverydetail where SALEDETAIL_GID='" + GID + "')";
Ext.Ajax.request({
waitMsg: '正在查询数据...',
url: '/Import/XXH/GetChfee',
scope: this,
async: false,
params: { condition: sql },
waitMsg: "正在查询数据...",
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
var returnData = jsonresult.data;
//alert(returnData.Count);
this.ChfeeCount = parseInt(returnData.Count);
if (this.ChfeeCount != "") {
alert("商品<" + CARGONAME + ">的销售明细被包含在已生成费用的出库单下,不能删除");
return;
} else {
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/Import/ImportSales/DeleteDetail',
params: {
SALESNO: SALESNO,
GIDList: GID
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.storeBodyList.load({ params: { condition: " s.SaleSNO='" + SALESNO + "'"} });
//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 });
}
Ext.Msg.hide();
}
},
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
}
} else {
Ext.Msg.show({ title: '请重试',
msg: '服务器响应出错',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
return;
}
}
});
}
}
}, this);
}, //end onAddDetailClick
cellEditingChFeeBeforeEdit: function (editor, e) {
var chfeefeeStatus = e.record.get('FeeStatus');
var canedit = chfeefeeStatus == 1 || chfeefeeStatus == 6;
//alert(canedit);
return canedit;
},
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 });
},
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('CURR').getValue();
if ((CUSTOMERNAME == '') || (CUSTOMERNAME == null)) {
var selectedRecords = this.gridAddFeeList.selModel.getSelection();
if (selectedRecords.length > 0) {
var rec = selectedRecords[0];
var cust = rec.data.CustomerName;
var curr = rec.data.Currency;
if ((CUSTOMERNAME == '') || (CUSTOMERNAME == null))
this.formEdit.getForm().findField('CUSTOMERNAME').setValue(cust);
if ((CURR == '') || (CURR == null))
this.formEdit.getForm().findField('CURR').setValue(curr);
}
}
var STLDATE = this.formEdit.getForm().findField('PAYABLETIME').getValue();
if ((STLDATE == '') || (STLDATE == null)) {
var myDate = new Date();
var mydatestr = Ext.util.Format.date(myDate, 'Y-m-d');
this.formEdit.getForm().findField('PAYABLETIME').setValue(mydatestr);
}
if (!basicForm.isValid()) {
return;
}
var type = 0;
this.formEdit.getForm().findField('BILLSTATUS').setDisabled(false);
this.formEdit.getForm().findField('APPLICANT').setDisabled(false);
this.formEdit.getForm().findField('COMPANYID').setDisabled(false);
var data = basicForm.getValues();
this.formEdit.getForm().findField('BILLSTATUS').setDisabled(true);
this.formEdit.getForm().findField('APPLICANT').setDisabled(true);
this.formEdit.getForm().findField('COMPANYID').setDisabled(true);
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Account/Chfee_ForeignPay/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('MsChPayapplication', 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.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();
}
},
addDetailfn: function () {
if (this.addstore) {
this.storeCurrExrate.removeAll();
this.addstore = false;
}
var Duino = this.formEdit.getForm().findField('BILLNO').getValue();
var billstatus = this.formEdit.getForm().findField('BILLSTATUS').getValue();
if ((billstatus != 1) && (billstatus != 6)) {
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.CURR;
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.CustomerName;
var bsno = rec.data.BSNO;
var curr = rec.data.Currency;
var ExChangerate = rec.data.ExChangerate;
var CURR = this.formEdit.getForm().findField('CURR').getValue();
if ((CURR == '') || (CURR == null)) {
this.formEdit.getForm().findField('CURR').setValue(curr);
this.formSearch.getForm().findField('Currency').setValue(curr);
}
if (cust == billcust) {
if (billcurr == curr || billcurr == null || billcurr == '') {
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', ExChangerate);
return;
}
}
bodyAddDatas.push(rec);
} 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_ForeignPay/AddDetail',
params: {
bill: billno,
data: jsonbodyAddDatas,
curr: billcurr
},
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.storeBodyAddList.load({ params: { start: 0, limit: _this.PageSize, sort: '', 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_ForeignPay/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('MsChPayapplication', 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
});
},
addBill: 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('CURR').getValue();
if ((CUSTOMERNAME == '') || (CUSTOMERNAME == null)) {
if (this.storeAddFeeList.getCount() > 0) {
var rec = this.storeAddFeeList.getAt(0);
var cust = rec.data.CustomerName;
var curr = rec.data.Currency;
if ((CUSTOMERNAME == '') || (CUSTOMERNAME == null))
this.formEdit.getForm().findField('CUSTOMERNAME').setValue(cust);
// if ((CURR == '') || (CURR == null))
// this.formEdit.getForm().findField('CURR').setValue(curr);
} else {
Ext.Msg.show({ title: '提示', msg: '核算客户不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
}
var STLDATE = this.formEdit.getForm().findField('PAYABLETIME').getValue();
if ((STLDATE == '') || (STLDATE == null)) {
var myDate = new Date();
var mydatestr = Ext.util.Format.date(myDate, 'Y-m-d');
this.formEdit.getForm().findField('PAYABLETIME').setValue(mydatestr);
}
if (!basicForm.isValid()) {
return;
}
var type = 0;
var data = basicForm.getValues();
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Account/Chfee_ForeignPay/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('MsChPayapplication', 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.addBillfn();
} 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.addBillfn();
}
}, //end save
addBillfn: function () {
var billstatus = this.formEdit.getForm().findField('BILLSTATUS').getValue();
if ((billstatus != 1) && (billstatus != 6)) {
Ext.Msg.show({ title: '提示', msg: '当前状态无法添加付费申请明细!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
if (this.addstore) {
this.storeCurrExrate.removeAll();
this.addstore = false;
}
var billcust = this.editRecord.data.CUSTOMERNAME;
var billno = this.editRecord.data.BILLNO;
var billcurr = this.editRecord.data.CURR;
var feeBSNOSql = '';
var sql = '';
var selectedRecords = this.gridAddList.selModel.getSelection();
if (selectedRecords.length == 0) {
Ext.Msg.show({ title: '提示', msg: '没有选择要添加的业务!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
};
var bodyAddDatas = [];
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
var feeBSNO = "'" + rec.data.BSNO + "'";
if (feeBSNOSql == '') {
feeBSNOSql = feeBSNO;
} else {
feeBSNOSql = feeBSNOSql + "," + feeBSNO;
}
}
if (feeBSNOSql == '') {
sql = "";
}
else {
sql = " BSNO IN (" + feeBSNOSql + ")";
sql = sql + getAndConSql(sql, this.FeeSqlStr, this.FeeSqlStr);
}
_this = this;
var bodydatas = [];
for (var i = 0; i < this.storeCurrExrate.getCount(); i += 1) {
var member = this.storeCurrExrate.getAt(i);
if (member.data.EXRATE == 0) {
_this.ExrateConversion(member.CURR, billcurr, 'bill', 0);
return;
}
bodydatas.push(member);
}
var currBody = ConvertRecordsToJsonAll(bodydatas);
Ext.Ajax.request({
waitMsg: '正在添加数据...',
url: '/Account/Chfee_ForeignPay/AddBill',
params: {
billno: billno,
billcust: billcust,
billcurr: billcurr,
feesql: sql,
storeCurrExrate: currBody
},
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 {
dataList = result.Data;
if (dataList == null) {
var sql = this.BillSql;
this.storeBodyAddList.load({ params: { start: 0, limit: _this.PageSize, sort: '', 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_ForeignPay/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('MsChPayapplication', 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 {
for (var i = 0; i < dataList.length; i++) {
var record = dataList[i];
_this.storeCurrExrate.add(record);
}
_this.ExrateConversion(record.CURR, billcurr, 'bill', 0);
return;
}
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
},
deleteBill: function (type) {
var billno = this.formEdit.getForm().findField('BILLNO').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 billstatus = this.formEdit.getForm().findField('BILLSTATUS').getValue();
if ((billstatus != 1) && (billstatus != 6)) {
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;
_this = this;
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/Account/Chfee_ForeignPay/DelBill',
params: {
data: jsonbodyAddDatas,
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 {
var sql = this.BillSql;
this.storeBodyAddList.load({ params: { start: 0, limit: _this.PageSize, sort: '', 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_ForeignPay/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('MsChPayapplication', 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 formEdit = this.formEdit.getForm();
var SALESNO = formEdit.findField('SALESNO').getValue();
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Import/ImportSales/SetSaleStatus',
scope: this,
params: {
SALESNO: SALESNO,
SALESTATUS: "2"
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
Ext.getCmp("SALESTATUS").setValue("2");
if (this.opStatus == 'edit')
condition = " GID='" + this.editRecord.get('GID') + "'";
this.LoadData(this.opStatus, condition);
} 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
});
}
//alert('03');
}
});
},
onSubmitAuditBackClick: function () {
var formEdit = this.formEdit.getForm();
var SALESNO = formEdit.findField('SALESNO').getValue();
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Import/ImportSales/SetSaleStatus',
scope: this,
params: {
SALESNO: SALESNO,
SALESTATUS: "1"
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
Ext.getCmp("SALESTATUS").setValue("1");
if (this.opStatus == 'edit')
condition = " GID='" + this.editRecord.get('GID') + "'";
this.LoadData(this.opStatus, condition);
} 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
});
}
//alert('03');
}
});
},
EndSalesClick: function () {
var formEdit = this.formEdit.getForm();
var SALESNO = formEdit.findField('SALESNO').getValue();
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Import/ImportSales/SetSaleStatus',
scope: this,
params: {
SALESNO: SALESNO,
SALESTATUS: "3"
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
Ext.getCmp("SALESTATUS").setValue("2");
if (this.opStatus == 'edit')
condition = " GID='" + this.editRecord.get('GID') + "'";
this.LoadData(this.opStatus, condition);
} 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
});
}
//alert('03');
}
});
},
UnEndSalesClick: function () {
var formEdit = this.formEdit.getForm();
var SALESNO = formEdit.findField('SALESNO').getValue();
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Import/ImportSales/SetSaleStatus',
scope: this,
params: {
SALESNO: SALESNO,
SALESTATUS: "2"
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
Ext.getCmp("SALESTATUS").setValue("1");
if (this.opStatus == 'edit')
condition = " GID='" + this.editRecord.get('GID') + "'";
this.LoadData(this.opStatus, condition);
} 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
});
}
//alert('03');
}
});
},
setCURRENCY: function (field, newValue, oldValue) {
this.storeBodyList.each(function (record) {
record.set('CURRENCY', newValue);
});
},
setExchangeRate: function (field, newValue, oldValue) {
var AMOUNTRMB_ALL = 0;
this.storeBodyList.each(function (record) {
record.set('EXCHANGERATE', newValue);
var AMOUNT = record.get('AMOUNT');
record.set('AMOUNTRMB', Mul(AMOUNT, newValue, 2));
AMOUNTRMB_ALL = Add(AMOUNTRMB_ALL, Mul(AMOUNT, newValue, 2), 2);
});
Ext.getCmp("AMOUNTRMB").setValue(AMOUNTRMB_ALL);
},
onRefreshClick: function (button, event) {
//this.Save('0');
var sql = this.getCondition();
this.storeBodyAddList.load({ params: { start: 0, limit: this.PageSize, sort: '', condition: sql} });
//this.gridList.getSelectionModel().clearSelections();
//this.gridList.getView().refresh();
},
onClearSql: function () {
var form = this.formSearch.getForm();
form.reset();
},
getCondition: function () {
var form = this.formSearch.getForm();
if (!form.isValid()) {
Ext.Msg.alert('提示', '查询条件赋值错误,请检查。');
return '';
}
var formEdit = this.formEdit.getForm();
var SALESNO = formEdit.findField('SALESNO').getValue();
if (SALESNO == "") {
//this.Save('0');
}
var sql = " c.ISDELETE<>1 and c.gid not in (select cargo_gid from import_saledetail where SALESNO='" + SALESNO + "') and ((weight_remain>0 and boxcount_remain>0) or (weight_remain>0 and BoxCount_Act=0) )";
var HTH = form.findField('HTH').getValue();
sql = sql + getAndConSql(sql, HTH, " C.HTH like '%" + HTH + "%' ");
var CARGONAME = form.findField('CARGONAME').getValue();
sql = sql + getAndConSql(sql, CARGONAME, " C.name like '%" + CARGONAME + "%' ");
if (this.HTH != "") {
sql = sql + getAndConSql(sql, this.HTH, " C.HTH = '" + this.HTH + "' ");
}
var countryid = form.findField('countryid').getValue();
sql = sql + getAndConSql(sql, countryid, " C.countryid = '" + countryid + "' ");
var buyer = form.findField('CUSTOMERNAME').getValue();
sql = sql + getAndConSql(sql, buyer, " C.buyer = '" + buyer + "' ");
var FACTORYNO = form.findField('FACTORYNO').getValue();
sql = sql + getAndConSql(sql, FACTORYNO, " C.FACTORYNO like '%" + FACTORYNO + "%' ");
var ArrivalDate_min = form.findField('ArrivalDate_min').getRawValue();
sql = sql + getAndConSql(sql, ArrivalDate_min, "C.ArrivalDate >='" + ArrivalDate_min + "'");
var ArrivalDate_max = form.findField('ArrivalDate_max').getRawValue();
sql = sql + getAndConSql(sql, ArrivalDate_max, "C.ArrivalDate <='" + ArrivalDate_max + "'");
var Mainstate = form.findField('Mainstate').getValue();
sql = sql + getAndConSql(sql, Mainstate, " C.MainstateRef = '" + Mainstate + "' ");
//Mainstate//MainStateRef
return sql;
},
getFeeCondition: function () {
var form = this.formSearch.getForm();
var feesql = 'f.FEESTATUS IN (0,8,9) and (f.AMOUNT<>(f.SETTLEMENT+f.ORDERAMOUNT-ISNULL(f.ORDERSETTLEMENT,0))) ';
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, dfexrate) {
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,
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,
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,
iconCls: "addicon",
resizable: 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) {
for (var i = 0; i < me.storeCurrExrate.getCount(); i += 1) {
var member = me.storeCurrExrate.getAt(i);
if (member.data.CURR == bfcurr) {
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 FFrecords = DsStoreQueryBy(this.StoreDateCurr, 'CURR', afcurr);
if (FFrecords.getCount() > 0) {
var ffdata = FFrecords.getAt(0).data;
var DEFRATE = ffdata.DEFRATE;
} else {
var DFrecords = DsStoreQueryBy(this.StoreCurr, 'CURR', afcurr);
if (DFrecords.getCount() > 0) {
var dfdata = DFrecords.getAt(0).data;
var DEFRATE = dfdata.DEFRATE;
} else {
var DEFRATE = 1;
}
}
var field = formExrateConversion.getForm().findField('afcurr');
achange = true;
field.setValue(DEFRATE);
} else {
var field = formExrateConversion.getForm().findField('bfcurr');
var recs = DsStoreQueryBy(me.storeCurrExrate, 'CURR', bfcurr);
if (recs.getCount() > 0) {
var dfdata = recs.getAt(0).data;
var DEFRATE = dfdata.DFEXRATE;
} else var DEFRATE = dfexrate;
bchange = true;
field.setValue(DEFRATE);
}
winExrateShow.show();
},
//#region 根据权限和状态判断是否允许修改
GetEditStatus: function () {
var me = this;
Ext.Ajax.request({
waitMsg: '正在查询用户权限...',
url: '/CommMng/BasicDataRef/GetAuthorityRange',
params: {
modName: "modImportSales",
USERID: USERID
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
rec = result.data;
this.VISIBLERANGE = rec.VISIBLERANGE;
this.OPERATERANGE = rec.OPERATERANGE;
if (this.OPERATERANGE == "0" || this.OPERATERANGE == "2" || this.OPERATERANGE == "3") {
this.setSaveBtnStatus(true);
} else {
this.setSaveBtnStatus(false);
}
}
else
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
},
scope: this
}); //request over
/*
this.StoreOpRange.load({ params: { optype: "modImportSales" },
callback: function (r, options, success) {
if (success) {
if (r.length != 0) {
var records = DsStoreQueryBy(_this.StoreOpRange, 'OPID', op);
if (records.getCount() > 0) {
canedit = true;
if (bsStatus == 1||bsStatus == 6)
btnESubmitAudit.enable();
else
btnESubmitAudit.disable();
if (bsStatus == 2)
btnESubmitAuditBack.enable();
else
btnESubmitAuditBack.disable();
} else {
canedit = false;
btnESubmitAudit.disable();
btnESubmitAuditBack.disable();
}
if ((bsStatus != 1) && (bsStatus != 6)) {
_this.setSaveBtnStatus(false);
} else {
_this.setSaveBtnStatus(canedit);
}
}
}
}
});
*/
},
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');
if (enable) {
btnESave.enable();
btnESaveAndClose.enable();
btnESaveAndNew.enable();
btnEAddDetail.enable();
btnEDeleteDetail.enable();
} else {
btnESave.disable();
btnESaveAndClose.disable();
btnESaveAndNew.disable();
btnEAddDetail.disable();
btnEDeleteDetail.disable();
}
if (SPTYPE == "财务核销") {
Ext.getCmp('btnESave').disable(); //enable();
Ext.getCmp('btnESaveAndClose').disable(); //enable;
Ext.getCmp('btnSubmitAudit').disable();
Ext.getCmp('btnSubmitAuditBack').disable();
Ext.getCmp('btnEndSales').disable();
Ext.getCmp('btnUnEndSales').disable();
Ext.getCmp('btnaddbill').disable();
Ext.getCmp('btndeldetail').disable();
}
},
// #endregion
//#region 合计选中的费用数字和
onSelectFee: function (button, event) {
//Ext.getCmp("zongshu").setText("1234");
var selectedRecords = this.gridListChFee.selModel.getSelection();
var sum = 0;
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
sum = sum + rec.get("REMAIN");
}
sum = sum.toFixed(2);
Ext.getCmp("zongshu").setText(" 选中金额:" + sum);
var selectedRecords_YF = this.gridListChFee_YF.selModel.getSelection();
var sum_YF = 0;
for (var i = 0; i < selectedRecords_YF.length; i++) {
var rec = selectedRecords_YF[i];
sum_YF = sum_YF + rec.get("Amount");
}
sum_YF = sum_YF.toFixed(2);
Ext.getCmp("zongshu_YF").setText(" 选中金额:" + sum_YF);
}
,
DetailAfterEdit: function (editor, e, eOpts) {
//需要自己实现里面的事件
if (COMPANYID == "" || USERID == "") {
alert("登录信息不全,请退出重新登录");
returen;
}
if (e.field == 'WEIGHT' || e.field == 'PRICE' || e.field == 'EXCHANGERATE') {
var WEIGHT = parseFloat(e.record.data['WEIGHT']);
var PRICE = parseFloat(e.record.data['PRICE']);
var formEdit = this.formEdit.getForm();
var EXCHANGERATE = parseFloat(formEdit.findField('EXCHANGERATE').getValue());
var AMOUNT = Mul(WEIGHT, PRICE, 2);
var AMOUNTRMB = parseFloat(e.record.data['AMOUNTRMB']);
if (AMOUNTRMB == 0) {
//AMOUNTRMB = Mul(AMOUNT, EXCHANGERATE, 2);
//e.record.set('AMOUNTRMB', AMOUNTRMB);
//e.record.set('PRICERMB', Div(AMOUNTRMB,WEIGHT,6));
}
e.record.set('AMOUNT', AMOUNT);
}
if (e.field == 'PRICERMB') {
var WEIGHT = parseFloat(e.record.data['WEIGHT']);
var AMOUNTRMB = Mul(WEIGHT, e.value, 2);
e.record.set('AMOUNTRMB', AMOUNTRMB);
}
if (e.field == 'AMOUNTRMB') {
var WEIGHT = parseFloat(e.record.data['WEIGHT']);
var PRICERMB = Div(e.value, WEIGHT, 6);
e.record.set('PRICERMB', PRICERMB);
}
var AMOUNT_ALL = 0;
var AMOUNTRMB_ALL = 0;
var PREPAYMENT = 0;
for (var i = 0; i < this.storeBodyList.getCount(); i += 1) {
AMOUNT_ALL = Add(AMOUNT_ALL, parseFloat(this.storeBodyList.getAt(i).get("AMOUNT")));
AMOUNTRMB_ALL = Add(AMOUNTRMB_ALL, parseFloat(this.storeBodyList.getAt(i).get("AMOUNTRMB")));
PREPAYMENT = Add(PREPAYMENT, parseFloat(this.storeBodyList.getAt(i).get("PREPAYMENT")));
}
Ext.getCmp("AMOUNT").setValue(AMOUNT_ALL);
Ext.getCmp("AMOUNTRMB").setValue(AMOUNTRMB_ALL);
Ext.getCmp("PREPAYMENT").setValue(PREPAYMENT);
},
getCustName: function () {
var custName = this.formEdit.getForm().findField('CUSTOMERNAME');
return custName.getValue();
},
onAddFeeClick: function (BSNO) {
/* var formEdit=this.formEdit.getForm();
var BSNO = formEdit.findField('SALESNO').getValue();
var price = "0";
var Quantity = "1";
var Currency ="RMB";
var Exchangerate = "1.00";
var Remark = "";
this.addChFee(1,"",BSNO,BSNO,Currency,Exchangerate,"",price,Quantity,Remark,"","");*/
var formEdit = this.formEdit.getForm();
var SALESNO = formEdit.findField('SALESNO').getValue();
store = this.storeBodyChFee;
var record = null;
function GetDateStr(AddDayCount) {
var dd = new Date();
dd.setDate(dd.getDate() + AddDayCount); //获取AddDayCount天后的日期
var y = dd.getFullYear();
var m = dd.getMonth() + 1; //获取当前月份的日期
var d = dd.getDate();
return y + "-" + m + "-" + d;
}
var EnterDate = GetDateStr(0);
record = Ext.create('MsChFee_Sales', {
GId: NewGuid(),
BsNo: '',
FeeStatus: 1,
FeeStatus_Ref: '录入状态',
FeeType: 1,
FeeType_Ref: '应收',
FeeName: '',
FeeName_Ref: '',
FeeDescription: '',
CustomerType: '',
CustomerName: this.getCustName(),
CustomerName_Ref: '',
Unit: '',
UnitPrice: 0,
Quantity: 1,
Amount: 0,
Currency: 'RMB',
ExChangerate: 1,
Reason: '',
Remark: '',
Commissionrate: 0,
Settlement: 0,
Invoice: 0,
OrderAmount: 0,
OrderInvoice: 0,
SubmitDate: null,
Auditoperator: '',
AuditDate: null,
EnteroPerator: USERID,
EnterDate: EnterDate,
DebitNo: '',
IsDebit: "0",
IsOpen: "0",
IsAdvancedpay: "0",
Sort: "0",
IsInvoice: "0",
FeeFrt: 'pp',
IsCrmOrderFee: "0",
AuditStatus: 0,
InvoiceNum: '',
ChequeNum: '',
WmsOutBsNo: '',
SALESNO: SALESNO
});
store.add(record);
var editColumnIndex = 0;
var cellediting = null;
cellediting = this.cellEditingChFee;
editColumnIndex = 2;
var n = store.getCount();
cellediting.startEditByPosition({ row: n - 1, column: editColumnIndex });
},
onDelFeeClick: function (button, event, type) {
var selectedRecords = [];
selectedRecords = this.gridListChFee.selModel.getSelection();
var candelete = DsTruck.CheckChFeeDelete_Sales(selectedRecords, this.storeOpCode2);
if (candelete == false)
return;
if (selectedRecords.length > 0) {
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.BillNo != "" || rec.BillNo != "*") //如果是新增但没有保存的数据,没有必要提交到后台
{
this.feeBodyDel.push(rec);
}
this.storeBodyChFee.remove(selectedRecords[i]);
}
}
},
//#endregion
//#region 根据选定业务 生成应收费用
MakeFee: function (button, event) {
var MainList = "";
var GID = "";
selectedRecords = this.gridList.selModel.getSelection();
var formEdit = this.formEdit.getForm();
var SALESNO = formEdit.findField('SALESNO').getValue();
var _CustomerName = formEdit.findField('CUSTOMERNAME').getValue();
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
var BSNO = rec.get('BSNO');
var price = rec.get('PRICE');
var Quantity = rec.get('WEIGHT');
var Currency = rec.get('CURRENCY');
var Exchangerate = rec.get('EXCHANGERATE');
var Remark = "销售单" + SALESNO + " " + rec.get('HTH') + "_" + rec.get('NAME');
if (parseFloat(price) == 0 || parseFloat(Quantity) == 0) {
continue;
}
this.addChFee(1, _CustomerName, BSNO, SALESNO, Currency, Exchangerate, "购货款", price, Quantity, Remark, "", "");
}
},
addChFee: function (FeeType, _CustomerName, BSNO, SALESNO, Currency, Exchangerate, FeeName, price, Quantity, Remark, FeeDescription, feedate) {
var _Amount = 0;
function GetDateStr(AddDayCount) {
var dd = new Date();
dd.setDate(dd.getDate() + AddDayCount); //获取AddDayCount天后的日期
var y = dd.getFullYear();
var m = dd.getMonth() + 1; //获取当前月份的日期
var d = dd.getDate();
return y + "-" + m + "-" + d;
}
var EnterDate = GetDateStr(0);
if (feedate == "" || typeof (feedate) == "undefined") {
EnterDate = GetDateStr(0);
} else {
EnterDate = feedate;
}
//var ContractNo = Ext.getCmp("ContractNo").getValue();
var field = " (GId,BsNo,FeeStatus,FeeType,FeeName,FeeDescription,CustomerType,CustomerName,Unit,UnitPrice,Quantity "
field = field + " ,Amount,Currency,ExChangerate,Reason,Remark,Commissionrate,Settlement,Invoice,OrderAmount,OrderInvoice "
field = field + " ,Auditoperator,EnterOperator,EnterDate,DebitNo,IsDebit,IsOpen,IsAdvancedpay,IsInvoice,FeeFrt,IsCrmOrderFee,AuditStatus,SALESNO) "
var _value = " values ('" + NewGuid() + "','" + BSNO + "',1," + FeeType + ",'" + FeeName + "','','','" + _CustomerName + "',''," + price + "," + Quantity + ""
_value = _value + "," + price + "*" + Quantity + ",'" + Currency + "'," + Exchangerate + ",'','" + Remark + "',0,0,0,0,0 "
_value = _value + ",'','" + USERID + "','" + EnterDate + "','',0,0,0,0,'PP',0,0,'" + SALESNO + "')"
var SQL = " Insert into ch_fee " + field + _value;
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Import/ImportSync/SaveSync',
scope: this,
params: {
SQL: SQL
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
//刷新费用列表
this.storeBodyChFee.load({ params: { SALESNO: SALESNO} });
} else {
Ext.Msg.show({ title: '请重试',
msg: '服务器响应出错',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
}
//alert('03');
}
});
}
,
onRetractClick: function (button, event, type) {
var records = [];
if (type == '1') {
var selectedRecords = this.feeGridCheckBoxModel.selected.items;
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.get('FeeStatus') == "2" || rec.get('FeeStatus') == "0") {
records.push(rec);
}
}
} else if (type == '2') {
var selectedRecords = this.feeGridCheckBoxModel_YF.selected.items;
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.get('FeeStatus') == "2" || rec.get('FeeStatus') == "0") {
records.push(rec);
}
}
}
if (records.length > 0) {
DsTruck.MsChFeeAudit(records, 6, '正在提交审核数据, 请稍侯..', "False");
}
},
gridListChFeeAfterEdit: function (editor, e, eOpts) {
if (e.field == 'FeeType') {
var records = DsStoreQueryBy(this.storeFeeTypeRef, 'EnumValueId', e.value);
if (records.getCount() > 0) {
var data = records.getAt(0).data;
e.record.set('FeeType_Ref', data.EnumValueName);
} else {
e.record.set('FeeType_Ref', '');
}
}
if (e.field == 'UnitPrice' || e.field == 'Quantity' || e.field == 'ExChangerate') {
var unitPrice = e.record.data['UnitPrice'];
var quantity = e.record.data['Quantity'];
//var ExChangerate= e.record.data['ExChangerate'];
e.record.set('Amount', (unitPrice * quantity).toFixed(2));
}
},
onSelectAcc: function (button, event) {
//Ext.getCmp("zongshu").setText("1234");
var selectedRecords_YF = this.gridListAcc.selModel.getSelection();
var sum_YF = 0;
for (var i = 0; i < selectedRecords_YF.length; i++) {
var rec = selectedRecords_YF[i];
sum_YF = sum_YF + rec.get("REMAIN");
}
sum_YF = sum_YF.toFixed(2);
Ext.getCmp("zongshu_YF").setText(" 选中金额:" + sum_YF);
},
SaveFee: function (type) {
//费用
var bodyChFeeDatas = [];
for (i = 0; i < this.storeBodyChFee.getCount(); i += 1) {
var memberyf = this.storeBodyChFee.getAt(i);
bodyChFeeDatas.push(memberyf);
var amount = memberyf.data.Amount;
if (amount == 0) {
Ext.Msg.show({ title: '警告',
msg: '费用的金额不允许为0,请修改后再保存',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
return;
}
};
var jsonChFeeBody = ConvertRecordsToJson(bodyChFeeDatas);
var jsonChFeeDelBody = ConvertRecordsToJsonAll(this.feeBodyDel);
if (jsonChFeeDelBody == "" && jsonChFeeBody == "") {
return;
}
var formEdit = this.formEdit.getForm();
var SALESNO = formEdit.findField('SALESNO').getValue();
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Import/ImportSales/SaveZDFee',
scope: this,
params: {
SALESNO: SALESNO
, chfeebody: jsonChFeeBody
, chfeedelbody: jsonChFeeDelBody
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
//alert("保存成功");
var returnData = jsonresult.Data;
this.feeBodyDel = [];
this.storeBodyChFee.commitChanges();
} 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
});
}
//alert('03');
}
});
},
LoadAccBodyList: function (button, event) {
var custome = _this.formEdit.getForm().findField('CUSTOMERNAME').getValue();
var billno = _this.formEdit.getForm().findField('SALESNO').getValue();
var curr = "RMB";
/*
var sql = " Amount<>DoAmount and (ISFINISH=0 or ISFINISH IS NULL) AND FEETYPE=1 AND currency='" + curr + "' AND BILLNO<>'" + billno + "' ";
this.storeAccBodyList.load({ params: { start: 0, limit: _this.PageSize, sort: '', condition: sql} });
var sql = "";
if (newValue.checked) {*/
var sql = " Amount<>DoAmount and (ISFINISH=0 or ISFINISH IS NULL) AND FEETYPE=1 AND currency='" + curr + "' AND BILLNO<>'" + billno + "' AND BILLNO in(select AD_BILLNO from SalesAdvancePay_state where SALESNO like '%" + billno + "%') ";
_this.storeAccBodyList.load({ params: { start: 0, limit: _this.PageSize, sort: '', condition: sql} });
},
onAddAPDetailClick: function (button, event) {
var gid = this.formEdit.getForm().findField('GID').getValue();
var billno = this.getDelivertFee();
if (billno == "") { return; } //如果费用状态等非法的话不做处理
var formEdit = this.formEdit.getForm();
var SALESNO = formEdit.findField('SALESNO').getValue();
//20160203 增加判断,首先判断两边是否平衡,如不平衡则不写入核销明细
//核销金额
var selectedRecords = this.gridListAcc.selModel.getSelection();
var REMAIN = 0; //本次核销
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i].data;
REMAIN = Add(REMAIN, parseFloat(rec.REMAIN));
}
var selectedRecords2 = this.gridListChFee.selModel.getSelection();
var AMOUNTRMB = 0; //本次核销
for (var i = 0; i < selectedRecords2.length; i++) {
var rec = selectedRecords2[i].data;
AMOUNTRMB = Add(AMOUNTRMB, parseFloat(rec.AMOUNTRMB));
}
if (REMAIN != AMOUNTRMB) {
alert("本次取用预收金额" + REMAIN + "与本次核销金额" + AMOUNTRMB + "不相等,请检查!");
return;
}
//首先将核销明细加入,其中SETTLENO先用SALESNO填充
var bodyAddDatas = [];
_this = this;
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
bodyAddDatas.push(rec);
}
if (bodyAddDatas.length == 0) {
Ext.Msg.show({ title: '提示', msg: '没有要添加的费用明细!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
};
var jsonbodyAddDatas = ConvertRecordsToJsonAll(bodyAddDatas);
_this = this;
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Account/Chfee_Foreignsettlement/AddAPDetail',
scope: this,
async: false,
params: {
billno: SALESNO,
data: jsonbodyAddDatas,
stlnogid: gid,
feetype: 2
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
} else {
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
} else {
Ext.Msg.show({ title: '请重试',
msg: '服务器响应出错',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
}
}
});
//然后进行结算
//首先遍历选择费用,控制不合适的费用进入
var selectedRecords = [];
selectedRecords = this.gridListChFee.selModel.getSelection();
/*
var DELIVERYNO=this.getDelivertFee();//如果费用状态等非法的话不做处理
if (DELIVERYNO==""){return;}*/
var FEEIDLIST = [];
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
FEEIDLIST.push(rec);
}
var jsonFEEIDLIST = ConvertRecordsToJsonAll(FEEIDLIST);
_this = this;
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Import/ImportSales/SetSettlement',
scope: this,
async: false,
params: {
SALESNO: SALESNO,
chfeebody: jsonFEEIDLIST
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var SETTLEBILLNO = jsonresult.data;
_this.LoadAccBodyList();
_this.storeBodyListAcc.load({ params: { condition: " SETTLEBILLNO='" + SETTLEBILLNO + "'" },
callback: function (r, options, success) {
if (success) {
Ext.getCmp("zongshu_YF").setText("");
}
},
scope: this
});
_this.storeBodyChFee.load({ params: { SALESNO: SALESNO} });
} 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
});
}
}
});
},
AutoAPDetailClick: function (button, event) {
var gid = this.formEdit.getForm().findField('GID').getValue();
var billno = this.getDelivertFee();
if (billno == "") { return; } //如果费用状态等非法的话不做处理
//首先遍历待取用预收,同时遍历选中的费用,如全部预收少于核销费用则告警并退出
var AllAcc = 0.0;
//var grid = Ext.getCmp('gridListAcc');
this.gridListAcc.getSelectionModel().clearSelections();
this.gridListAcc.getView().refresh();
var sm = _this.AccCB;
var total = this.storeAccBodyList.getCount(); //数据行数
for (var i = 0; i < total; i++) {
var row = this.storeAccBodyList.getAt(i);
AllAcc = Add(AllAcc, row.get('REMAIN'), 2);
//if (Ext.Array.indexOf(_this.array, contractno, 0) > -1) {
//grid.selModel.select(i, true, false);
//}
}
var AllFee = 0.0;
var selectedRecords = this.gridListChFee.selModel.getSelection();
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
AllFee = Add(AllFee, rec.get('AMOUNTRMB'), 2);
}
if (parseFloat(AllAcc) < parseFloat(AllFee)) {
alert("剩余金额不足");
return;
}
//遍历待用预收,如此条小于待核费用总和,则将其设为选中,并转入下一条,从待核费用中减去此条待用预收金额
//如此条待用预收大于等于待核费用,将此条设为选中,REMAIN改为待核费用,设为选中 并结束循环
//最后调用“手动核销”
var total = this.storeAccBodyList.getCount(); //数据行数
for (var i = 0; i < total; i++) {
var row = this.storeAccBodyList.getAt(i);
REMAIN = parseFloat(row.get('REMAIN'));
if (REMAIN < parseFloat(AllFee)) {
this.gridListAcc.selModel.select(i, true, false);
AllFee = Cut(AllFee, REMAIN, 2);
} else {
this.gridListAcc.selModel.select(i, true, false);
row.set('REMAIN', AllFee);
break;
}
}
this.onAddAPDetailClick();
},
onDeleteApClick: function (button, event) {
var billno = this.formEdit.getForm().findField('SALESNO').getValue();
var selectedRecords = this.gridBodyListAcc.selModel.getSelection();
var bodyAddDatas = [];
_this = this;
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
var voucherno = rec.data.VOUCHERNO;
if (voucherno == '') {
bodyAddDatas.push(rec);
} 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);
_this = this;
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Account/Chfee_Foreignsettlement/DelAPBill',
scope: this,
params: {
data: jsonbodyAddDatas
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
/* var custome = _this.formEdit.getForm().findField('CUSTOMERNAME').getValue();
var billno = _this.formEdit.getForm().findField('SALESNO').getValue();
var curr = "RMB";
var sql = "CUSTOMERNAME='" + custome + "' and (ISFINISH=0 or ISFINISH IS NULL) AND FEETYPE=1 AND currency='" + curr + "' AND BILLNO<>'" + billno + "'";
_this.storeAccBodyList.load({ params: { start: 0, limit: _this.PageSize, sort: '', condition: sql} }); */
_this.LoadAccBodyList();
_this.storeBodyListAcc.load({ params: { condition: " SETTLEBILLNO='" + billno + "'" },
callback: function (r, options, success) {
if (success) {
if (_this.storeBodyListAcc.getCount() > 0) (this.comboxCurrADVANCE.readOnly = true)
}
},
scope: this
});
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/Account/Chfee_Foreignsettlement/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.formAHSR.getForm().reset();
_this.formADVANCE.getForm().reset();
_this.formAHSR.getForm().setValues(data);
_this.formADVANCE.getForm().setValues(data);
var editp = Ext.create('MsChSettlement', 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.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
});
}
}
});
}
, getDelivertFee: function () {
var selectedRecords = [];
//之前是用来获取出库编号
//现在用来验证选择费用的有效性
selectedRecords = this.gridListChFee.selModel.getSelection();
var DELIVERYNO = "";
//var FEEIDLIST=[];
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
// if (rec.get('DELIVERYNO')==""){
// alert("此处只能核销出库单产生的应收");
// return "";
// } else
// if (DELIVERYNO!="" && DELIVERYNO!=rec.get('DELIVERYNO')){
// alert("不可选择多个出库单的费用");
// return "";
// } else
if (rec.get('Settlement') == rec.get('Amount')) {
alert("不可选择已经结算完成的费用");
return "";
} else
if (rec.get('FeeStatus') != "0") {
alert("只能核销审核通过状态下的费用");
return "";
} else {
//FEEIDLIST.push(rec);
DELIVERYNO = "cando";
}
}
if (DELIVERYNO == "") {
alert("请选择要核销的费用");
return "";
} else {
return DELIVERYNO;
}
},
onSettlementClick: function (button, event) {//核销费用
var formEdit = this.formEdit.getForm();
var SALESNO = formEdit.findField('SALESNO').getValue();
//首先遍历选择费用,控制不合适的费用进入
var selectedRecords = [];
selectedRecords = this.gridListChFee.selModel.getSelection();
var DELIVERYNO = this.getDelivertFee();
if (DELIVERYNO == "") { return; }
var FEEIDLIST = [];
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
FEEIDLIST.push(rec);
}
var jsonFEEIDLIST = ConvertRecordsToJsonAll(FEEIDLIST);
_this = this;
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Import/ImportSales/SetSettlement',
scope: this,
params: {
//DELIVERYNO: DELIVERYNO,
chfeebody: jsonFEEIDLIST
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
/* var custome = _this.formEdit.getForm().findField('CUSTOMERNAME').getValue();
var billno = _this.formEdit.getForm().findField('SALESNO').getValue();
var curr = "RMB";
var sql = "CUSTOMERNAME='" + custome + "' and (ISFINISH=0 or ISFINISH IS NULL) AND FEETYPE=1 AND currency='" + curr + "' AND BILLNO<>'" + billno + "'";
_this.storeAccBodyList.load({ params: { start: 0, limit: _this.PageSize, sort: '', condition: sql} }); */
_this.LoadAccBodyList();
_this.storeBodyListAcc.load({ params: { condition: " SETTLEBILLNO='" + DELIVERYNO + "'" },
callback: function (r, options, success) {
if (success) {
if (_this.storeBodyListAcc.getCount() > 0) (this.comboxCurrADVANCE.readOnly = true)
}
},
scope: this
});
_this.storeBodyChFee.load({ params: { SALESNO: SALESNO} });
} 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
});
}
}
});
}
,
onUnSettlementClick: function (button, event) {
var formEdit = this.formEdit.getForm();
var SALESNO = formEdit.findField('SALESNO').getValue();
var selectedRecords = [];
selectedRecords = this.gridListChFee.selModel.getSelection();
var SETTLEBILLNO = "";
var FEEIDLIST = [];
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.get('SETTLEBILLNO') == "") {
alert("还未核销的业务不能做取消操作");
return;
} else
if (SETTLEBILLNO != '' && SETTLEBILLNO != rec.get('SETTLEBILLNO')) {
alert("只能一次取消一个核销单");
return;
} /*else
if (rec.get('Settlement')!=rec.get('Amount')){
alert("不可选择未核销过的费用");
return;
}*/
else {
FEEIDLIST.push(rec);
SETTLEBILLNO = rec.get('SETTLEBILLNO');
}
}
_this = this;
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Import/ImportSales/SetUnSettlement',
scope: this,
params: {
BILLNO: SETTLEBILLNO
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
/* var custome = _this.formEdit.getForm().findField('CUSTOMERNAME').getValue();
var billno = _this.formEdit.getForm().findField('SALESNO').getValue();
var curr = "RMB";
var sql = "CUSTOMERNAME='" + custome + "' and (ISFINISH=0 or ISFINISH IS NULL) AND FEETYPE=1 AND currency='" + curr + "' AND BILLNO<>'" + billno + "'";
_this.storeAccBodyList.load({ params: { start: 0, limit: _this.PageSize, sort: '', condition: sql} }); */
//alert(jsonresult.totalCount);
_this.LoadAccBodyList();
_this.storeBodyListAcc.load({ params: { condition: " SETTLEBILLNO='' " },
callback: function (r, options, success) {
if (success) {
if (_this.storeBodyListAcc.getCount() > 0) (this.comboxCurrADVANCE.readOnly = true)
}
},
scope: this
});
_this.storeBodyChFee.load({ params: { SALESNO: SALESNO} });
} 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
});
}
}
});
}
,
//#endregion
//#region 添加删除账单费用
GetHandleSerialNo: function (store, type) {
var result = 0;
if (type == 1) {
result = this.fixSerialNo;
} else if (type == 2) {
result = this.feeSerialNo;
}
if (result == 0) {
for (var i = 0; i < store.getCount(); i += 1) {
var member = store.getAt(i);
if (member.data.SerialNo > result) {
result = member.data.SerialNo;
}
}
}
result = result + 1;
if (type == 1) {
this.fixSerialNo = result;
} else if (type == 2) {
this.feeSerialNo = result;
}
return result;
},
onAddOrderClick: function (button, event, type) {
var store = null;
store = this.storeOrderChFee;
var custname = this.formEdit.getForm().findField('CUSTOMERNAME').value; //购货单位
var newSerialno = this.GetHandleSerialNo(store, type);
var newsort = store.getCount() + 1;
var myDate = new Date();
var record = null;
record = Ext.create('MsChFee_Sales', {
GId: NewGuid(),
BsNo: '*',
FeeStatus: 1,
FeeStatus_Ref: '录入状态',
FeeType: 1,
FeeName: '',
FeeDescription: '',
CustomerType: '',
CustomerName: custname,
Unit: '',
UnitPrice: 0,
TaxUnitPrice: 0,
Quantity: 1,
TaxRate: 0,
NoTaxAmount: 0,
Amount: 0,
AccTaxRate: 0,
Currency: 'RMB',
ExChangerate: 1,
Reason: '',
Remark: '',
Commissionrate: 0,
Settlement: 0,
Invoice: 0,
OrderAmount: 0,
OrderInvoice: 0,
SubmitDate: null,
Auditoperator: '',
AuditDate: null,
EnteroPerator: GetCookie_UserId(),
OpName: SHOWNAME,
EnterDate: myDate,
DebitNo: '',
IsDebit: "0",
IsOpen: "0",
IsAdvancedpay: "false",
Sort: newSerialno,
IsInvoice: "0",
FeeFrt: '',
IsCrmOrderFee: "0",
AuditStatus: 0,
InvoiceNum: '',
ChequeNum: '',
WmsOutBsNo: ''
});
store.add(record);
var editColumnIndex = 0;
var cellediting = this.cellEditingOrderFee;
editColumnIndex = 4;
var n = store.getCount();
cellediting.startEditByPosition({ row: n - 1, column: editColumnIndex });
}
,
onDelOrderClick: function (button, event, type) {
var feeGidSql = '';
var selectedRecords = [];
var SALESNO = this.formEdit.getForm().findField('SALESNO').value;
selectedRecords = this.OrderfeeCBM.selected.items;
if (selectedRecords.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择要删除的费用!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
Ext.MessageBox.confirm('提示', '确定要删除选中的费用吗?', function (btn) {
if (btn == 'yes') {
if (selectedRecords.length > 0) {
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.data.BsNo == "*") //如果是新增但没有保存的数据,没有必要提交到后台
{
this.storeOrderChFee.remove(selectedRecords[i]);
} else {
var feeGId = "'" + rec.data.GId + "'";
if (feeGidSql == '') {
feeGidSql = feeGId;
} else {
feeGidSql = feeGidSql + "," + feeGId;
}
}
}
}
_this = this;
Ext.Msg.wait('正在删除数据...');
if (feeGidSql != '') {
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/MvcShipping/MsChFee/OrderDelete',
params: {
bsno: SALESNO,
data: feeGidSql
},
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.storeOrderChFee.remove(selectedRecords[i]);
}
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
} else {
Ext.Msg.show({ title: '提示', msg: "删除成功!", icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
}
}
}, this);
//this.calcDetailTotal();
}
,
SaveOrderFee: function (type) {
selectedRecords = this.ZD_CBM.selected.items;
if (selectedRecords.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择要生成账单费用的账单!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var ZD_GID = selectedRecords[0].data.GID;
//费用
var bodyOrderFeeDatas = [];
for (i = 0; i < this.storeOrderChFee.getCount(); i += 1) {
var memberyf = this.storeOrderChFee.getAt(i);
bodyOrderFeeDatas.push(memberyf);
};
var jsonOrderFeeBody = ConvertRecordsToJson(bodyOrderFeeDatas);
//var jsonChFeeDelBody = ConvertRecordsToJsonAll(this.feeBodyDel);
if (jsonOrderFeeBody == "") {
return;
}
var formEdit = this.formEdit.getForm();
var SALESNO = formEdit.findField('SALESNO').getValue();
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Import/ImportSales/SaveOrderFee',
scope: this,
params: {
bsno: ZD_GID,
OrderFeeBody: jsonOrderFeeBody
//, chfeedelbody: jsonChFeeDelBody
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
//alert("保存成功");
var returnData = jsonresult.Data;
_this.storeOrderChFee.load({ params: { billno: ZD_GID} });
} else {
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
} else {
Ext.Msg.show({ title: '请重试',
msg: '服务器响应出错',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
}
//alert('03');
}
});
},
gridListOrderFeeAfterEdit: function (editor, e, eOpts) {
//需要自己实现里面的事件
/*
if (e.value == e.originalValue) return;
if (e.field == 'UnitPrice' || e.field == 'Quantity') {
var UnitPrice = e.record.data['UnitPrice'];
var Quantity = e.record.data['Quantity'];
e.record.set('Amount', Mul(UnitPrice, Quantity, 2));
}
if (e.field == 'Amount') {
var Amount = e.record.data['Amount'];
var Quantity = e.record.data['Quantity'];
e.record.set('UnitPrice', Div(Amount, Quantity, 2));
}
var apprecords = DsStoreQueryBy(this.storeBodyList, 'CARGO_GID', e.value);
if (apprecords.getCount() > 0) {
var appdata = apprecords.getAt(0).data;
e.record.set('CARGO_NAME', appdata.NAME);
} else {
e.record.set('CARGO_NAME', ' ');
}
*/
},
MakeOrderFee: function (FeeName, Amount) {
var store = null;
store = this.storeOrderChFee;
var custname = this.formEdit.getForm().findField('CUSTOMERNAME').value; //购货单位
var newSerialno = this.GetHandleSerialNo(store, type);
var newsort = store.getCount() + 1;
var myDate = new Date();
var record = null;
record = Ext.create('MsChFee_Sales', {
GId: NewGuid(),
BsNo: '*',
FeeStatus: 1,
FeeStatus_Ref: '录入状态',
FeeType: 1,
FeeName: FeeName,
FeeDescription: '',
CustomerType: '',
CustomerName: custname,
Unit: '',
UnitPrice: Amount,
TaxUnitPrice: 0,
Quantity: 1,
TaxRate: 0,
NoTaxAmount: 0,
Amount: Amount,
AccTaxRate: 0,
Currency: 'RMB',
ExChangerate: 1,
Reason: '',
Remark: '',
Commissionrate: 0,
Settlement: 0,
Invoice: 0,
OrderAmount: 0,
OrderInvoice: 0,
SubmitDate: null,
Auditoperator: '',
AuditDate: null,
EnteroPerator: GetCookie_UserId(),
OpName: SHOWNAME,
EnterDate: myDate,
DebitNo: '',
IsDebit: "0",
IsOpen: "0",
IsAdvancedpay: "false",
Sort: newSerialno,
IsInvoice: "0",
FeeFrt: '',
IsCrmOrderFee: "0",
AuditStatus: 0,
InvoiceNum: '',
ChequeNum: '',
WmsOutBsNo: ''
});
store.add(record);
var editColumnIndex = 0;
var cellediting = this.cellEditingOrderFee;
editColumnIndex = 4;
var n = store.getCount();
cellediting.startEditByPosition({ row: n - 1, column: editColumnIndex });
}
,
MakeOrderFee_RMB: function () {
var formEdit = this.formEdit.getForm();
var SALESNO = formEdit.findField('SALESNO').getValue();
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Import/ImportSales/MakeOrderFee_RMB',
scope: this,
params: {
SALESNO: SALESNO
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
//alert("保存成功");
var returnData = jsonresult.Data;
//this.storeOrderChFee.load({ params: { billno: SALESNO, type: 1, optype: "进口贸易销售单"} });
} 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
});
}
//alert('03');
}
});
}
,
MakeOrderFee_USD: function () {
var formEdit = this.formEdit.getForm();
var SALESNO = formEdit.findField('SALESNO').getValue();
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Import/ImportSales/MakeOrderFee_USD',
scope: this,
params: {
SALESNO: SALESNO
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
//alert("保存成功");
var returnData = jsonresult.Data;
} 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
});
}
//alert('03');
}
});
}
,
//#endregion
onAddZD: function (type) {
var formEdit = this.formEdit.getForm();
var SALESNO = formEdit.findField('SALESNO').getValue();
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Import/ImportSales/AddZD',
scope: this,
params: {
SALESNO: SALESNO,
type: type
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.storeZDList.load({ params: { condition: "SALESNO='" + SALESNO + "'"} });
this.storeZDDetailList.removeAll();
this.storeOrderChFee.removeAll();
} 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
});
}
//alert('03');
}
});
},
onDelZD: function () {
var formEdit = this.formEdit.getForm();
var SALESNO = formEdit.findField('SALESNO').getValue();
var selectedRecords = [];
selectedRecords = this.ZD_CBM.selected.items;
if (selectedRecords.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择要删除的账单!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Import/ImportSales/DelZD',
scope: this,
params: {
data: Ext.JSON.encode(selectedRecords[0].data)
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.storeZDList.load({ params: { condition: "SALESNO='" + SALESNO + "'"} });
this.storeZDDetailList.removeAll();
} 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
});
}
//alert('03');
}
});
},
onDelZDDetail: function (button, event, type) {
var selectedRecords = [];
//this.gridList.selModel.getSelection();
selectedRecords = this.ZDDetailList.selModel.getSelection();
if (selectedRecords.length > 0) {
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.ZD_GID != "" || rec.ZD_GID != "*") //如果是新增但没有保存的数据,没有必要提交到后台
{
this.ZDDetailDel.push(rec);
}
this.storeZDDetailList.remove(selectedRecords[i]);
}
}
},
onSaveZDDetail: function (type) {
//费用
var bodyZDDetailDatas = [];
for (i = 0; i < this.storeZDDetailList.getCount(); i += 1) {
var memberyf = this.storeZDDetailList.getAt(i);
bodyZDDetailDatas.push(memberyf);
};
var jsonZDDetailBody = ConvertRecordsToJson(bodyZDDetailDatas);
var jsonZDDetailDelBody = ConvertRecordsToJsonAll(this.ZDDetailDel);
if (jsonZDDetailBody == "" && jsonZDDetailDelBody == "") {
return;
}
selectedRecords = this.ZD_CBM.selected.items;
var ZD_GID = selectedRecords[0].data.GID;
var formEdit = this.formEdit.getForm();
var SALESNO = formEdit.findField('SALESNO').getValue();
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Import/ImportSales/SaveZDDetail',
scope: this,
params: {
SALESNO: SALESNO
, ZDDetail: jsonZDDetailBody
, ZDDetaildel: jsonZDDetailDelBody
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.storeZDDetailList.load({ params: { condition: "ZD_GID='" + ZD_GID + "'"} });
} else {
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
} else {
Ext.Msg.show({ title: '请重试',
msg: '服务器响应出错',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
}
//alert('03');
}
});
},
MakeOrderFee_RMB2: function (_type) {
selectedRecords = this.ZD_CBM.selected.items;
if (selectedRecords.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择要生成账单费用的账单!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var ZD_GID = selectedRecords[0].data.GID;
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Import/ImportSales/MakeOrderFee_RMB2',
scope: this,
params: {
ZD_GID: ZD_GID,
type: _type
},
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.storeOrderChFee.load({ params: { billno: ZD_GID} });
} else {
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
} else {
Ext.Msg.show({ title: '请重试',
msg: '服务器响应出错',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
}
//alert('03');
}
});
}
,
MakeOrderFee_USD2: function (_type) {
selectedRecords = this.ZD_CBM.selected.items;
if (selectedRecords.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择要生成账单费用的账单!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var ZD_GID = selectedRecords[0].data.GID;
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Import/ImportSales/MakeOrderFee_USD2',
scope: this,
params: {
ZD_GID: ZD_GID,
type: _type
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
_this.storeOrderChFee.load({ params: { billno: ZD_GID} });
} else {
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
} else {
Ext.Msg.show({ title: '请重试',
msg: '服务器响应出错',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
}
//alert('03');
}
});
}
,
onMarkClick: function () {
var USEBody = [];
var selectedRecords = this.ZDList.selModel.getSelection();
if (selectedRecords.length == 0) {
return;
}
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
USEBody.push(rec);
}
var formEdit = this.formEdit.getForm();
var SALESNO = formEdit.findField('SALESNO').getValue();
//商品明细
var DetailBody = ConvertRecordsToJsonAll(USEBody);
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Import/ImportSales/SetUse',
scope: this,
params: {
DetailBody: DetailBody
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
//this.onRefreshClick2();
this.storeZDList.load({ params: { condition: "SALESNO='" + SALESNO + "'"} });
}
}
});
},
Print: function () {
var basicForm = this.formEdit.getForm();
var billNo = basicForm.findField('SALESNO').value;
if (billNo == '*' || billNo == '') {
Ext.Msg.show({ title: '错误', msg: '单据还没有保存,请保存后再打印', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
function GetDateStr(AddDayCount) {
var dd = new Date();
dd.setDate(dd.getDate() + AddDayCount); //获取AddDayCount天后的日期
var y = dd.getFullYear();
var m = dd.getMonth() + 1; //获取当前月份的日期
var d = dd.getDate();
return y + "-" + m + "-" + d;
}
//alert(GetDateStr(+5));
var madedate = GetDateStr(0);
var CUSTOMERNAME = this.formEdit.findField('CUSTOMERNAME').value;
var printType = 'Import_SALES_1';
var sql1 = " select s.CUSTOMERNAME 客户名称,dbo.trimdate(DELIVERYDATE) 送货日期,SALER 销售人员,OP 销售助理,SALESDATE 销售日期 ";
sql1 = sql1 + " ,(select deptname from vw_user where SHOWNAME=SALER) 销售部门,s.SALESNO 销售单号,s.SALESNO ";
sql1 = sql1 + " ,(select top 1 storagename from wms where Cargo_gid in (select cargo_gid from import_sales where s.SALESNO='" + billNo + "')) 仓库 ";
sql1 = sql1 + " ,sas.DOAMOUNT,ap.AMOUNT 预收金额,ap.BILLNO 预收单号,ap.CREATETIME 预收日期 ";
sql1 = sql1 + " ,(select OFFICEPHONE from user_baseinfo where userid =(select top 1 userid from vw_user where showname=SALER)) 销售人员电话";
sql1 = sql1 + " ,(select top 1 SHOWNAME from info_client_contact where LINKID in(select gid from info_client where shortname=s.CUSTOMERNAME)) 客户联系人员";
sql1 = sql1 + " ,(select top 1 TEL from info_client_contact where LINKID in(select gid from info_client where shortname=s.CUSTOMERNAME)) 客户联系人员电话";
sql1 = sql1 + " ,s.prepayment 定金,s.Exchangerate 汇率,s.CURRENCY 币别,s.AMOUNT 原币金额,s.AMOUNTRMB 本币金额 ";
sql1 = sql1 + " from Import_SALES s ";
sql1 = sql1 + " left join SalesAdvancePay_state sas on sas.SALESNO=s.SALESNO ";
sql1 = sql1 + " left join ch_fee_advance_payment ap on ap.BILLNO=sas.AD_BILLNO ";
sql1 = sql1 + " WHERE s.SALESNO='" + billNo + "' ";
var sql2 = " select c.FactoryNo 厂号,c.Productiondate 生产日期起,c.productiondate_max 生产日期止,c.name 商品名称,s.[WEIGHT] 销售重量 ";
sql2 = sql2 + " ,s.BOXCOUNT 销售件数,s.price 单价,s.AMOUNT 金额,s.CURRENCY 币别,s.AMOUNTRMB RMB金额,s.REMARK 备注 ,m.hth 采购合同号 ";
sql2 = sql2 + " ,substring((select COUNTRY from code_country where COUNTRYID=m.countryid),0,(charindex('(',(select COUNTRY from code_country where COUNTRYID=m.countryid))) ) 国家 ";
sql2 = sql2 + " ,dbo.trimdate(m.paydate) 付汇时间,m.billno 提单号,m.containerno 箱号,m.arrivaldate 到港日 ";
sql2 = sql2 + " ,c.tax_1*s.[WEIGHT]/(case c.WEIGHT_ACT when 0 then 1 else c.WEIGHT_ACT end) 关税 ";
sql2 = sql2 + " ,c.tax_zz_1*s.[WEIGHT]/(case c.WEIGHT_ACT when 0 then 1 else c.WEIGHT_ACT end) 增值税 ";
sql2 = sql2 + " ,c.prepayments*s.[WEIGHT]/(case c.WEIGHT_ACT when 0 then 1 else c.WEIGHT_ACT end) 预付款 ";
sql2 = sql2 + " ,c.balance*s.[WEIGHT]/(case c.WEIGHT_ACT when 0 then 1 else c.WEIGHT_ACT end) 尾款 ";
sql2 = sql2 + " ,c.exchangerate 商务汇率 ";
sql2 = sql2 + " ,(select sum(amount*exchangerate) from ch_fee where deliveryno in(select gid from import_deliverydetail where saledetail_gid=s.gid)) 实际金额";
sql2 = sql2 + " ,(select sum(boxcount) from import_deliverydetail where saledetail_gid=s.gid) 实际件数";
sql2 = sql2 + " ,(select sum(weight) from import_deliverydetail where saledetail_gid=s.gid) 实际重量";
sql2 = sql2 + " ,s.PREPAYMENT 定金,Datename(year,m.Ex_sailingdate) 预计开船年,Datename(month,m.Ex_sailingdate) 预计开船月 ";
sql2 = sql2 + " ,(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=10 and EnumValueID=M.port) 目的港 ";
sql2 = sql2 + " ,(select storagename from wms where Cargo_gid=s.Cargo_gid) 仓库简称 ";
sql2 = sql2 + " ,PRICEREMARK 价格备注,s.PRICERMB RMB价格,s.AMOUNTRMB RMB金额 ";
sql2 = sql2 + " from Import_saledetail s ";
sql2 = sql2 + " left join ImportTrade_Cargo c on c.gid=s.CARGO_GID ";
sql2 = sql2 + " left join Import_Sales ss on ss.salesno=s.salesno ";
sql2 = sql2 + " left join import_main m on m.ContractNo=c.ContractNo ";
sql2 = sql2 + " where s.SALESNO='" + billNo + "'";
// var sql3 = " select * from company where gid=(select top 1 companyid from ch_fee_do where BILLNO='" + billNo + "') ";
var sql3 = " select enname 公司英文名称,ENADDRESS 公司英文地址,ORGANIZATIONCODE 组织机构代码 ";
sql3 = sql3 + " ,* from company where gid='" + COMPANYID + "' ";
var sql4 = "select '" + madedate + "' as madedate,(select DESCRIPTION from info_client where SHORTNAME='" + CUSTOMERNAME + "') as CUSTOMERNAME,'" + SHOWNAME + "' as SHOWNAME";
var sql5 = " select sum(c.balance) 外币尾款 ";
sql5 = sql5 + " ,dbo.f_fee(m.contractno,ss.CUSTOMERNAME,'RMB','电汇费') 电汇费 ";
sql5 = sql5 + " ,dbo.f_fee(m.contractno,ss.CUSTOMERNAME,'RMB','手续费') 手续费 ";
sql5 = sql5 + " ,dbo.f_fee(m.contractno,ss.CUSTOMERNAME,'RMB','尾款') 尾款 ";
sql5 = sql5 + " ,dbo.F_price(m.contractno) 单价,dbo.F_weight_KG(m.contractno) 净重 ";
sql5 = sql5 + " ,dbo.f_fee(m.contractno,ss.CUSTOMERNAME,'RMB','关税') 关税 ";
sql5 = sql5 + " ,dbo.f_fee(m.contractno,ss.CUSTOMERNAME,'RMB','增值税') 增值税 ";
sql5 = sql5 + " ,dbo.f_fee(m.contractno,ss.CUSTOMERNAME,'RMB','代理费') 代理费 ";
sql5 = sql5 + " ,dbo.f_fee(m.contractno,ss.CUSTOMERNAME,'RMB','冷藏费') 冷藏费 ";
sql5 = sql5 + " ,dbo.f_fee(m.contractno,ss.CUSTOMERNAME,'RMB','THC') THC ";
sql5 = sql5 + " from Import_saledetail s ";
sql5 = sql5 + " left join ImportTrade_Cargo c on c.gid=s.CARGO_GID ";
sql5 = sql5 + " left join Import_Sales ss on ss.salesno=s.salesno ";
sql5 = sql5 + " left join import_main m on m.ContractNo=c.ContractNo ";
sql5 = sql5 + " where s.SALESNO='" + billNo + "' group by m.ContractNo,ss.CUSTOMERNAME ";
var sql6 = " select ";
sql6 = sql6 + " dbo.F_GetSalesFee(SALESNO,1,'冷藏费') 冷藏费 ";
sql6 = sql6 + " ,dbo.F_GetSalesFee(SALESNO,1,'THC') THC ";
sql6 = sql6 + " from Import_Sales ";
sql6 = sql6 + " where SALESNO='" + billNo + "' ";
PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6);
}
,
Print_KHDZ4: function () {
var selections = this.ZD_CBM.selected.items;
if (selections.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择单据!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var record = selections[0];
var SALESNO = record.data.SALESNO;
var ZD_GID = record.data.GID;
function GetDateStr(AddDayCount) {
var dd = new Date();
dd.setDate(dd.getDate() + AddDayCount); //获取AddDayCount天后的日期
var y = dd.getFullYear();
var m = dd.getMonth() + 1; //获取当前月份的日期
var d = dd.getDate();
return y + "-" + m + "-" + d;
}
//alert(GetDateStr(+5));
var printdate = GetDateStr(0);
//var basicForm = this.formHead.getForm();
//var billNo = basicForm.findField('ContractNo').value;
if (ZD_GID == '*' || ZD_GID == '') {
//Ext.Msg.show({ title: '错误', msg: '单据还没有保存,请保存后再打印', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var printType = 'Print_importtrade_KHZD6';
var sql1 = " select HTH 合同号,Supplier_Billno 供应商合同号,Other_Billno 分公司合同号 ";
sql1 = sql1 + " ,dbo.trimdate(s.SALESDATE) 合同签订日期 ";
sql1 = sql1 + " ,dbo.trimdate((select top 1 STOCKDATE_1 from Import_SaleZDdetail where ZD_GID=ZD.GID)) 收取费用日期 ";
sql1 = sql1 + " ,dbo.trimdate((select top 1 STOCKDATE_2 from Import_SaleZDdetail where ZD_GID=ZD.GID)) 结束计费日期 ";
sql1 = sql1 + " ,dbo.F_Sales_ZDBoxCount(ZD.GID) 账单件数 ,dbo.[F_Sales_ZDWEIGHT](ZD.GID) 账单重量 ";
sql1 = sql1 + " ,s.CUSTOMERNAME 销售对象,m.buyer 购货方 ";
sql1 = sql1 + " ,(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=10 and EnumValueID=M.port) 目的港 ";
sql1 = sql1 + " ,m.ArrivalDate 到港日,m.ContainerNo 箱号 ";
sql1 = sql1 + " ,(select substring(country,0,(charindex('(',country)) ) from code_country where countryid=m.countryid) 进口国 ";
sql1 = sql1 + " ,dbo.F_CargoName_SaleZD(ZD.GID) 品名,(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=1 and EnumValueID=M.TransactionMethod) 成交方式 ";
sql1 = sql1 + " ,dbo.F_Saleprice(S.SalesNo) 价格,dbo.F_Saleprice3(ZD.GID) 销售单价格,s.saler 销售员 ";
sql1 = sql1 + " ,case (select top 1 CURRENCY from Import_Saledetail where BSNO=m.ContractNo) when 'USD' then '$' when 'RMB' then '¥' when 'EUR' then '€' else '' end 币别符号 ";
sql1 = sql1 + " ,dbo.F_Sales_FactoryNo(s.SALESNO) 厂号,(select top 1 CURRENCY from Import_Saledetail where BSNO=m.ContractNo) 币别 ";
sql1 = sql1 + " ,(case isnull(M.Inspection_Storage,0) when 1 then '是' when 0 then '否' else '' end) 是否商检慢检,dbo.trimdate(m.Unsealdate) 商检放行日期";
sql1 = sql1 + " ,dbo.trimdate((select min(wmsdate) from wms where ASSOCIATEDNO=m.contractno)) 入库日期";
sql1 = sql1 + " from Import_SaleZD ZD ";
sql1 = sql1 + " left join import_sales S on ZD.SALESNO=s.SALESNO ";
sql1 = sql1 + " left join import_main m on m.contractno=(select top 1 BSNO from import_saledetail where SalesNo=S.SalesNo) ";
sql1 = sql1 + " where ZD.GID ='" + ZD_GID + "' ";
var sql2 = " declare @sql varchar(8000) select @sql = isnull(@sql + ',' , '') + feename from ";
sql2 = sql2 + " (select distinct feename from ch_fee_order where BSNO='" + ZD_GID + "')t ";
sql2 = sql2 + " exec ('select * into KHDZ4 from (select salesno,cargo_gid, '+@sql+' from (select (select SALESNO from Import_SaleZD where gid=ch_fee_order.BSNO) SALESNO,cargo_gid, feename,amount from ch_fee_order where BSNO=''" + ZD_GID + "'' )t2 ";
sql2 = sql2 + " pivot (sum(amount) for feename in('+@sql+')) fn )t') ";
sql2 = sql2 + " select kt.* ,ic.name 品名 ";
sql2 = sql2 + " ,Convert(varchar,Sdd.exchangerate_cust) SD应收账单汇率 ";
sql2 = sql2 + " ,Convert(varchar,c.Exchangerate_Customs) SD海关汇率 ";
sql2 = sql2 + " ,dbo.trimdate(sdd.STOCKDATE_2) 出库时间 ";
sql2 = sql2 + " ,w.STORAGENAME 冷库 ";
sql2 = sql2 + " ,sdd.weight 千克数,convert(varchar,sdd.weight/1000) 吨数 ";
sql2 = sql2 + " from KHDZ4 kt ";
sql2 = sql2 + " left join import_cargo ic on kt.CARGO_GID=ic.GID ";
sql2 = sql2 + " left join Import_SaleZDdetail Sdd on ic.GID=(select cargo_gid from Import_Saledetail where GID=sdd.SALEDETAIL_GID) ";
sql2 = sql2 + " left join importtrade_cargo c on kt.cargo_gid=c.gid ";
sql2 = sql2 + " left join wms w on w.Cargo_gid=kt.CARGO_GID ";
sql2 = sql2 + " drop table KHDZ4 ";
/*
var sql2 = " declare @sql varchar(max) select @sql = isnull(@sql + ',' , '') + feename from ";
sql2 = sql2 + " (select distinct feename from ch_fee_order where BSNO='" + ZD_GID + "')t ";
sql2 = sql2 + " declare @sql2 varchar(max) select @sql2 = isnull(@sql2 + ',' , '') + 'convert(varchar(20),'+feename+') '+feename+'' from ";
sql2 = sql2 + " (select distinct feename from ch_fee_order where BSNO='" + ZD_GID + "')t2 ";
sql2 = sql2 + " exec ('select * into KHDZ4 from (select salesno,cargo_gid, '+@sql+' from (select (select SALESNO from Import_SaleZD where gid=ch_fee_order.BSNO) SALESNO,cargo_gid, feename,amount from ch_fee_order where BSNO=''" + ZD_GID + "'' )t2 ";
sql2 = sql2 + " pivot (sum(amount) for feename in('+@sql+')) fn )t') ";
sql2 = sql2 + " exec('select kt.salesno,kt.cargo_gid,'+@sql2+' ,(select top 1 name from Import_cargo where gid in( select CARGO_GID from Import_Saledetail where gid=sdd.SALEDETAIL_GID)) 品名 ";
sql2 = sql2 + " ,Convert(varchar,Sdd.exchangerate_cust) SD应收账单汇率 ";
sql2 = sql2 + " ,Convert(varchar,c.Exchangerate_Customs) SD海关汇率 ";
sql2 = sql2 + " ,dbo.trimdate(sdd.STOCKDATE_2) 出库时间 ";
sql2 = sql2 + " ,w.STORAGENAME 冷库 ";
sql2 = sql2 + " ,sdd.weight 千克数,sdd.weight/1000 吨数 ";
sql2 = sql2 + " from KHDZ4 kt ";
sql2 = sql2 + " left join Import_SaleZDdetail Sdd on kt.salesno=sdd.salesno and kt.cargo_gid=(select cargo_gid from Import_Saledetail where gid= Sdd.saledetail_GID) ";
sql2 = sql2 + " left join importtrade_cargo c on kt.cargo_gid=c.gid ";
sql2 = sql2 + " left join import_cargo ic on kt.CARGO_GID=ic.GID ";
sql2 = sql2 + " left join wms w on w.Cargo_gid=kt.CARGO_GID ') ";
sql2 = sql2 + " drop table KHDZ4 ";*/
//sql2 = sql2 + " where sd.SALESNO ='" + billNo + "' ";
//sql2 = sql2 + " drop table KHDZ4 ";
var sql3 = "";
var sql4 = "";
var sql5 = "";
var sql6 = "select '" + SHOWNAME + "' showname,'" + printdate + "' printdate";
PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6);
}
});