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

3060 lines
109 KiB
JavaScript

2 years ago
Ext.namespace('DsTruck');
DsTruck.CWAdvancePaymentIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.DsTruck.CWAdvancePaymentIndex.superclass.constructor.call(this);
};
Ext.extend(DsTruck.CWAdvancePaymentIndex, Ext.Panel, {
PageSize: 500,
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
isShowAdvancedQuery: 0, //是否显示高级查询面板
sqlcontext: '',
editype: '',
selectbsno: '',
sortfield: '',
sortdire: '',
remind: null,
CurrentBill: null,
initUIComponents: function () {
//定义数据集
this.storeList = Ext.create('Ext.data.Store', {
model: 'CWAdvancePaymentmb',
remoteSort: false,
pageSize: this.PageSize,
proxy: {
type: 'ajax',
url: '/Import/CWAdvancePayment/GetDataList_Import',
reader: {
idProperty: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.formname = "AdvancePayment";
this.RKformname = "AdvancePayment_RK";
this.BILLNO = "";
this.CUSTOMERNAME = "";
this.BILL = "";
this.SalesDel = [];
this.BodyDel = [];
this.caneditYS = false;
//#region 枚举参照
var _this = this;
this.storeBuyer = Ext.create('DsExt.ux.RefTableStore', {
model: 'Tradermb',
proxy: { url: '/CommMng/BasicDataRef/GetTrader' }
});
this.storeBuyer.load({ params: { condition: "1=1"} });
this.comboxBuyer = Ext.create('Ext.ux.form.field.BoxSelect', {
fieldLabel: '客户',
autosize: true,
bodyPadding: 7,
flex: 2,
labelWidth: 60,
store: this.storeBuyer,
queryMode: 'local',
triggerOnClick: false,
valueField: 'name',
displayField: 'codename',
matchFieldWidth: false,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
});
this.storeAccitems = Ext.create('DsExt.ux.RefTableStore', {
model: 'Accitemsmb',
proxy: { url: '/CommMng/BasicDataRef/GetAccitems' }
});
this.storeAccitems.load({ params: { condition: " isITEMACC=1 "} }); //是否核算客户
this.comboxBANK = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '收支账户', //收支的银行账户
store: this.storeAccitems,
name: 'BANKACCID', id: "BANKACCID",
valueField: 'ACCID',
matchFieldWidth: false,
displayField: 'ACCIDNAME',
flex: 1
});
this.storeFEETYPE = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeFEETYPE.load({ params: { enumTypeId: 21} });
this.comboxFEETYPE = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: '收付类型',
store: this.storeFEETYPE,
name: 'FEETYPE',
allowBlank: false, id: "FEETYPE"
, value: '1'
});
//#endregion
Ext.grid.RowNumberer = Ext.extend(Ext.grid.RowNumberer, {
width: 30
});
this.column = [{
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: 80
},
{
sortable: true,
dataIndex: 'FEETYPEREF',
header: '收付类型',
width: 80
},
{
sortable: true,
dataIndex: 'CUSTOMERNAME',
header: '结算对象',
width: 80
},
{
sortable: true,
dataIndex: 'CURRENCY',
header: '币别',
width: 80
},
{
sortable: true,
dataIndex: 'AMOUNT',
header: '金额',
width: 95, align: 'right',
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
},
{
sortable: true,
dataIndex: 'REASON',
header: '资金用途',
width: 80, align: 'left'
},
{
sortable: true,
dataIndex: 'DOAMOUNT',
header: '已核销金额',
width: 95, align: 'right',
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
}, {
sortable: true,
dataIndex: 'REMAIN',
header: '剩余金额',
width: 95, align: 'right',
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
},
{
sortable: true,
dataIndex: 'RKAMOUNT',
header: '已认款金额',
width: 80,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
},
{
sortable: true,
dataIndex: 'UnRKAMOUNT',
header: '未认款金额',
width: 80,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
//var _UNRK = Cut(record.data.AMOUNT, record.data.RKAMOUNT);
value = usMoney(value, 2, '', true);
return value;
}
},
{
sortable: true,
dataIndex: 'CREATEUSER',
header: 'CREATEUSER',
width: 80, hidden: true
},
{
sortable: true,
dataIndex: 'CREATEUSERREF',
header: '录入人',
width: 80
},
{
sortable: true,
dataIndex: 'CREATETIME',
header: '录入时间',
width: 80
},
{
sortable: true,
dataIndex: 'SETTLEUSER',
header: 'SETTLEUSER',
width: 80, hidden: true
},
{
sortable: true,
dataIndex: 'SETTLETIME',
header: 'SETTLETIME',
width: 80, hidden: true
},
{
sortable: true,
dataIndex: 'REMARK',
header: '备注',
width: 120
},
{
sortable: true,
dataIndex: 'ISDELETE',
header: 'ISDELETE',
width: 80, hidden: true
},
{
sortable: true,
dataIndex: 'DELETEUSER',
header: 'DELETEUSER',
width: 80, hidden: true
},
{
sortable: true,
dataIndex: 'DELETETIME',
header: 'DELETETIME',
width: 80, hidden: true
},
{
sortable: true,
dataIndex: 'ISFINISHREF',
header: '是否全部完成核销',
width: 80//, hidden: true
},
{
sortable: true,
dataIndex: 'COMPANYID',
header: 'COMPANYID',
width: 80, hidden: true
}, {
sortable: true,
dataIndex: 'COMPANYREF',
header: '所属分公司',
width: 80, hidden: true
},
{
sortable: true,
dataIndex: 'ISVOU',
header: '生成凭证',
width: 80
}, {
sortable: true,
dataIndex: 'VOUCHERNO',
header: '凭证号',
width: 80
}];
//定义Grid
this.gridList = new Ext.grid.GridPanel({
store: this.storeList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
stripeRows: true,
viewConfig: {
enableTextSelection: true
},
columns: [new Ext.grid.RowNumberer()],
bbar: Ext.create('Ext.PagingToolbar', {
store: this.storeList,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
})
});
/////////////以下部分为获取存储的gridpanel显示样式
this.column = DsTruck.GetGridPanel(USERID, this.formname, this.column);
this.column.unshift(new Ext.grid.RowNumberer());
this.gridList.reconfigure(this.storeList, this.column);
////////////////////////////
//#region 明细内容 核销明细
this.storeBodyList = Ext.create('Ext.data.Store', {
model: 'CWAdvancePaymentBodymb',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/Import/CWAdvancePayment/GetBodyList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.cellEditingBody = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this._BodyModel = Ext.create('Ext.selection.CheckboxModel');
this.gridBodyList = new Ext.grid.GridPanel({
store: this.storeBodyList,
enableHdMenu: false,
region: 'center',
//height: 600,
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.cellEditingBody],
selType: 'cellmodel',
selModel: this._BodyModel,
viewConfig: {
autoFill: true,
enableTextSelection: true
},
tbar: [{
text: '增加明细',
tooltip: '增加明细',
iconCls: "btnadddetail", id: "BodyAdd",
handler: function (button, event) {
this.onAddBodyClick(button, event);
},
scope: this
}, {
text: '删除明细',
tooltip: '注意删除后要点保存', id: "BodyDel",
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelBodyClick(button, event);
},
scope: this
}, '-', {
text: '保存',
tooltip: '保存修改',
iconCls: "btnsave", id: "BodySave",
handler: function (button, event) {
this.onSaveBodyClick(button, event);
},
scope: this
}, '-', {
text: '打印退款单',
tooltip: '打印退款单',
iconCls: "", //id: "BodySave",
handler: function (button, event) {
this.onPrintBackClick(button, event);
},
scope: this
}],
columns: [new Ext.grid.RowNumberer(),
{
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: 130
},
{
sortable: true,
dataIndex: 'SETTLELINKGID',
header: 'SETTLELINKGID', hidden: true,
width: 80
},
{
sortable: true,
dataIndex: 'SETTLEBILLNO',
header: '核销使用单号',
width: 130
},
{
sortable: true, hidden: true,
dataIndex: 'FEETYPE',
header: 'FEETYPE',
width: 80
},
{
sortable: true,
dataIndex: 'CUSTOMERNAME',
header: '结算对象', hidden: true,
width: 80
},
{
sortable: true,
dataIndex: 'CURRENCY',
header: '币别',
width: 80
},
{
sortable: true,
dataIndex: 'DOAMOUNT',
header: '核销金额',
width: 95, align: 'right',
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
},
editor: {
xtype: 'numberfield',
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'SETTLEUSERREF',
header: '核销人',
width: 80
},
{
sortable: true,
dataIndex: 'SETTLETIME',
header: '核销时间',
width: 150
},
{
sortable: true,
dataIndex: 'REMARK',
header: '备注',
width: 120,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'ISDELETE',
header: 'ISDELETE', hidden: true,
width: 80
},
{
sortable: true,
dataIndex: 'DELETEUSER',
header: 'DELETEUSER', hidden: true,
width: 80
},
{
sortable: true,
dataIndex: 'DELETETIME',
header: 'DELETETIME', hidden: true,
width: 80
},
{
sortable: true,
dataIndex: 'COMPANYID',
header: 'COMPANYID', hidden: true,
width: 80
},
{
sortable: true,
dataIndex: 'VOUCHERNO',
header: '凭证号',
width: 80
}
],
// paging bar on the bottom
bbar: Ext.create('Ext.PagingToolbar', {
store: this.storeBodyList,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
})
});
//#endregion
//#region 明细内容 关联销售单
this.storeSalesList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'SalesStateAuditmb',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/Import/ImportSales/GetSalesStateDataList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.storeSalesAddList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'ImportSalesmb',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/Import/ImportSales/GetDataList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.comboxSalesAdd = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '购货单位',
store: this.storeSalesAddList,
//allowBlank: false,
//forceSelection: true,
name: 'SALESNO',
valueField: 'SALESNO',
displayField: 'SALESNO'
});
this.RKcolumn = [
{
sortable: true, hidden: true,
dataIndex: 'GID',
header: 'GID',
width: 80
},
{
sortable: true,
dataIndex: 'SALESNO',
header: '销售单号',
width: 130,
editor: this.comboxSalesAdd
},
{
sortable: true,
dataIndex: 'CUSTOMERNAME',
header: '客户名称',
width: 80
}, {
sortable: true,
dataIndex: 'CURRENCY',
header: '币别',
width: 35
}, {
sortable: true, align: 'right',
dataIndex: 'AMOUNT',
header: '金额',
width: 95, align: 'right',
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
}, {
sortable: true, align: 'right',
dataIndex: 'AMOUNTRMB',
header: 'RMB金额',
width: 95, align: 'right',
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
}, {
dataIndex: 'DOAMOUNT',
header: '认款金额',
width: 95,
editor: {
xtype: 'textfield',
selectOnFocus: true
}, align: 'right',
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
}, {
dataIndex: 'AD_BILLNO', hidden: true,
header: '预收单号',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
},
{
dataIndex: 'CREATEUSER', hidden: true,
header: 'CREATEUSER',
width: 80
},
{
dataIndex: 'CREATEUSER_REF',
header: '建立人',
width: 80
},
{
dataIndex: 'CREATETIME',
header: '到账日期',
width: 80
},
{
dataIndex: 'AUDITOR_REF',
header: '审核人',
width: 80
},
{
dataIndex: 'AUDITOR', hidden: true,
header: 'AUDITOR',
width: 80
},
{
dataIndex: 'AUDITTIME',
header: '审核时间',
width: 80
},
{
sortable: true,
dataIndex: 'Forecast_Amount',
header: '已认款金额',
width: 80, align: 'right',
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
},
{
sortable: true,
dataIndex: 'Forecast_Remain',
header: '未认款金额',
width: 80,
renderer: function (value) {
if (parseFloat(value) > 0) {
return "<a><font color='#FF0000'>" + usMoney(value, 2, '', true); +"</font></a>";
} else if (parseFloat(value) <= 0) {
return "<a><font color='#0000FF'>" + usMoney(value, 2, '', true); +"</font></a>";
} else {
return "";
}
}, align: 'right'
},
{
dataIndex: 'PASSED', hidden: true,
header: 'PASSED',
width: 80
},
{
dataIndex: 'PASSED_REF',
header: '财务审核情况',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'OP',
header: 'OP',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'SALER',
header: 'SALER',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'CORPID',
header: 'CORPID',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'DEPTGID',
header: 'DEPTGID',
width: 80
},
{
sortable: true,
dataIndex: 'CARGONAME',
header: '商品摘要',
width: 130
},
{
sortable: true, align: 'right',
dataIndex: 'EXCHANGERATE',
header: '汇率',
width: 60
},
{
sortable: true,
dataIndex: 'SALESDATE',
header: '销售日期',
width: 80
},
{
sortable: true, align: 'right',
dataIndex: 'DELIVERYWEIGHT',
header: '已出库重量',
width: 80
},
{
sortable: true,
dataIndex: 'DELIVERYADDRESS',
header: '送货地址',
width: 80
},
{
sortable: true,
dataIndex: 'DELIVERYCONTACTS',
header: '送货联系人',
width: 80
},
{
sortable: true,
dataIndex: 'DELIVERYTEL',
header: '送货联系电话',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'BSSTATUS',
header: 'BSSTATUS',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'FEESTATUS',
header: 'FEESTATUS',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'TIMEMARK',
header: 'TIMEMARK',
width: 80
},
{
sortable: true,
dataIndex: 'OP',
header: '销售助理',
width: 80
},
{
sortable: true,
dataIndex: 'SALER',
header: '销售员',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'BSSTATUSRef',
header: '业务状态',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'FEESTATUSRef',
header: '费用状态',
width: 80
},
{
sortable: true,
dataIndex: 'MAINSTATERef',
header: '销售方式',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'MAINSTATE',
header: 'MAINSTATE',
width: 80
},
{
sortable: true,
dataIndex: 'SALESTATUSRef',
header: '财务审核出库状态',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'SALESTATUS',
header: 'SALESTATUS',
width: 80
}, {
sortable: true,
dataIndex: 'REMARK',
header: '备注',
width: 80
}
];
//定义Grid
this.cellEditingSaleStatus = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this._Model = Ext.create('Ext.selection.CheckboxModel');
this.gridSalesList = new Ext.grid.GridPanel({
store: this.storeSalesList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.cellEditingSaleStatus],
selType: 'cellmodel',
selModel: this._Model,
viewConfig: {
enableTextSelection: true,
autoFill: true,
getRowClass: function (record, rowIndex, rowParams, store) {
var PASSED = record.get('PASSED');
return DsTruck.DeliveryGetRowClass(PASSED);
}
},
tbar: [{
text: '增加明细',
tooltip: '增加明细',
iconCls: "btnadddetail", id: "SalesAdd",
handler: function (button, event) {
this.onAddStateClick(button, event);
},
scope: this
}, {
text: '删除明细',
tooltip: '注意删除后要点保存', id: "SalesDel",
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelStateClick(button, event);
},
scope: this
}, '-', {
text: '保存',
tooltip: '保存修改',
iconCls: "btnsave", id: "SalesSave",
handler: function (button, event) {
this.onSaveStateClick(button, event);
},
scope: this
}, '-', {
text: '仅确认预收认款',
tooltip: '此操作可以让你在“只显示未审核”时不再看到此条认款,但不允许此销售出库',
iconCls: "btnAuditState", id: "AuditState",
handler: function (button, event) {
this.AuditState(button, event);
},
scope: this
}, {
text: '撤回确认',
tooltip: '反操作确认预收认款',
iconCls: "btnAuditState", id: "UnAuditState",
handler: function (button, event) {
this.UnAuditState(button, event);
},
scope: this
}, '-', {
text: '允许出库',
tooltip: '允许该票业务提交出库',
iconCls: "btnWMSOut", id: "SalesAudit",
handler: function (button, event) {
this.AuditOut(button, event);
},
scope: this
}, '-', {
text: '撤回许可',
tooltip: '撤回对该业务的出库许可。如果已经进行出库录入,请先删除出库记录才能撤回许可。',
iconCls: "btnCargoLock", id: "SalesUnAudit",
handler: function (button, event) {
this.UnAuditOut(button, event);
},
scope: this
}, '-', {
text: "保存列表样式",
id: "btntest2",
handler: function (button, event) {
//this.column = DsTruck.SaveGridPanel(USERID, this.formname, this.gridList.columns, this.column, 1, false);
var tempcolumns = this.gridSalesList.columns;
DsTruck.SaveGridPanel(USERID, this.RKformname, tempcolumns, this.RKcolumn, 1, false);
},
scope: this
}],
columns: this.RKcolumn,
// paging bar on the bottom
bbar: Ext.create('Ext.PagingToolbar', {
store: this.storeSalesList,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
})
});
this.gridSalesList.addListener('itemdblclick', function (dataview, record, item, index, e, b) {
this.SelectedRecord = record;
this.OprationStatus = 'audit';
DsOpenEditWin('/Import/ImportSales/BLEdit', "编辑销售单");
}, this);
///////////////
this.RKcolumn = DsTruck.GetGridPanel(USERID, this.RKformname, this.RKcolumn);
//this.RKcolumn.unshift(new Ext.grid.RowNumberer());
this.gridSalesList.reconfigure(this.storeSalesList, this.RKcolumn);
///////////////////
this.storeBuyer2 = Ext.create('DsExt.ux.RefTableStore', {
model: 'Tradermb',
proxy: { url: '/CommMng/BasicDataRef/GetTrader' }
});
this.storeBuyer2.load({ params: { condition: ""} });
this.comboxBuyer2 = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '销售对象',
store: this.storeBuyer2, labelWidth: 65, width: 120,
//allowBlank: false,
//forceSelection: true,
name: 'name', id: "add_CUSTOMERNAME",
valueField: 'name',
displayField: 'codename',
matchFieldWidth: false
});
this.storeOpCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.UserRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetUserRefList' }
});
this.storeOpCode.load();
//揽货人
this.comboxSALE = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '销售人',
store: this.storeOpCode, labelWidth: 65, width: 120,
forceSelection: true,
name: 'SALER', id: "add_SALER",
valueField: 'UserName',
displayField: 'CodeAndName',
matchFieldWidth: false
});
//this.comboxSALE.addListener('expend', this.comBoxListResize);
this._AddModel = Ext.create('Ext.selection.CheckboxModel');
this.gridSalesAddList = new Ext.grid.GridPanel({
store: this.storeSalesAddList,
enableHdMenu: false,
region: 'center',
width: 400,
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
selType: 'cellmodel',
selModel: this._AddModel,
tbar: [{
text: '添加',
tooltip: '增加至认款明细',
iconCls: "btnadddetail", id: "SalesAdd2",
handler: function (button, event) {
this.onAddSalesClick(button, event);
},
scope: this
}, '-', {
text: '查询',
tooltip: '注意删除后要点保存', id: "SalesSearch",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onRefreshClick2(button, event);
},
scope: this
}, { id: "add_SALESNO",
fieldLabel: "销售单号",
labelWidth: 65, width: 120,
xtype: 'textfield',
name: 'SALESNO',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick2();
}
}
}
}, this.comboxBuyer2, this.comboxSALE],
columns: [
{
sortable: true, hidden: true,
dataIndex: 'GID',
header: 'GID',
width: 80
},
{
sortable: true,
dataIndex: 'SALESNO',
header: '销售单号',
width: 130,
editor: this.comboxSalesAdd
},
{
sortable: true,
dataIndex: 'CUSTOMERNAME',
header: '客户名称',
width: 80
}, {
sortable: true, hidden: true,
dataIndex: 'CURRENCY',
header: '币别',
width: 35
}, {
sortable: true, align: 'right',
dataIndex: 'AMOUNT', hidden: true,
header: '金额',
width: 95, align: 'right',
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
}, {
sortable: true, align: 'right',
dataIndex: 'AMOUNTRMB',
header: 'RMB金额',
width: 95, align: 'right',
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
}, {
dataIndex: 'DOAMOUNT', hidden: true,
header: '认款金额',
width: 95,
editor: {
xtype: 'textfield',
selectOnFocus: true
}, align: 'right',
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
}, {
dataIndex: 'AD_BILLNO', hidden: true,
header: '预收单号',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
},
{
dataIndex: 'CREATEUSER', hidden: true,
header: 'CREATEUSER',
width: 80
},
{
dataIndex: 'CREATEUSER_REF', hidden: true,
header: '建立人',
width: 80
},
{
dataIndex: 'CREATETIME', hidden: true,
header: '到账日期',
width: 80
},
{
dataIndex: 'AUDITOR_REF', hidden: true,
header: '审核人',
width: 80
},
{
dataIndex: 'AUDITOR', hidden: true,
header: 'AUDITOR',
width: 80
},
{
dataIndex: 'AUDITTIME', hidden: true,
header: '审核时间',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'Forecast_Amount',
header: '已认款金额',
width: 80, align: 'right',
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
},
{
sortable: true,
dataIndex: 'Forecast_Remain',
header: '未认款金额',
width: 80,
renderer: function (value) {
if (parseFloat(value) > 0) {
return "<a><font color='#FF0000'>" + usMoney(value, 2, '', true); +"</font></a>";
} else if (parseFloat(value) <= 0) {
return "<a><font color='#0000FF'>" + usMoney(value, 2, '', true); +"</font></a>";
} else {
return "";
}
}, align: 'right'
},
{
dataIndex: 'PASSED', hidden: true,
header: 'PASSED',
width: 80
},
{
dataIndex: 'PASSED_REF', //hidden: true,
header: '财务审核情况',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'OP',
header: 'OP',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'SALER',
header: 'SALER',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'CORPID',
header: 'CORPID',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'DEPTGID',
header: 'DEPTGID',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'CARGONAME',
header: '商品摘要',
width: 130
},
{
sortable: true, align: 'right', hidden: true,
dataIndex: 'EXCHANGERATE',
header: '汇率',
width: 60
},
{
sortable: true, hidden: true,
dataIndex: 'SALESDATE',
header: '销售日期',
width: 80
},
{
sortable: true, align: 'right', hidden: true,
dataIndex: 'DELIVERYWEIGHT',
header: '已出库重量',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'DELIVERYADDRESS',
header: '送货地址',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'DELIVERYCONTACTS',
header: '送货联系人',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'DELIVERYTEL',
header: '送货联系电话',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'BSSTATUS',
header: 'BSSTATUS',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'FEESTATUS',
header: 'FEESTATUS',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'TIMEMARK',
header: 'TIMEMARK',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'OP',
header: '销售助理',
width: 80
},
{
sortable: true,
dataIndex: 'SALER',
header: '销售员',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'BSSTATUSRef',
header: '业务状态',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'FEESTATUSRef',
header: '费用状态',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'MAINSTATERef',
header: '销售方式',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'MAINSTATE',
header: 'MAINSTATE',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'SALESTATUSRef',
header: '销售单状态',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'SALESTATUS',
header: 'SALESTATUS',
width: 80
}, {
sortable: true, hidden: true,
dataIndex: 'REMARK',
header: '备注',
width: 80
}
],
// paging bar on the bottom
bbar: Ext.create('Ext.PagingToolbar', {
store: this.storeSalesAddList,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
})
});
//#endregion
//#region 明细内容 认款删除记录
this.storeSalesAdvancePay_state_DEL = Ext.create('Ext.data.Store', {
pageSize: 500,
model: 'SalesAdvancePay_state_DELmb',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/Import/ImportSales/GetSalesAdvancePay_state_DELList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.RKDELcolumn = [
{
sortable: true, hidden: true,
dataIndex: 'GID',
header: 'GID',
width: 80
},
{
sortable: true,
dataIndex: 'SALESNO',
header: '销售单号',
width: 80
},
{
sortable: true,
dataIndex: 'DOAMOUNT',
header: '认款金额',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'PASSED',
header: 'PASSED',
width: 80
},
{
sortable: true,
dataIndex: 'AD_BILLNO',
header: '预收单号',
width: 80
},
{
sortable: true,
dataIndex: 'CREATEUSER',
header: '认款建立人',
width: 80
},
{
sortable: true,
dataIndex: 'CREATETIME',
header: '认款时间',
width: 80
},
{
sortable: true,
dataIndex: 'DELETEUSER',
header: '删除人',
width: 80
},
{
sortable: true,
dataIndex: 'DELETETIME',
header: '删除时间',
width: 80
}
];
//定义Grid
this.gridSalesAdvancePay_state_DEL = new Ext.grid.GridPanel({
store: this.storeSalesAdvancePay_state_DEL,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
columns: this.RKDELcolumn,
// paging bar on the bottom
bbar: Ext.create('Ext.PagingToolbar', {
store: this.storeSalesAdvancePay_state_DEL,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
})
});
//#endregion
this.gridList.addListener('itemdblclick', function (dataview, record, item, index, e, b) {
if (this.CaneditYS == false) {
return;
}
this.SelectedRecord = record;
this.OprationStatus = 'edit';
DsOpenEditWin('/Import/ImportAdvancePayment/Edit', '', 300, 950, 400, 300);
}, this);
this.storeUser = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsTruckMng.ux.UserRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetUserRefList' }
});
this.storeUser.load({ params: { condition: ""} });
this.comboxUser = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '制单人',
store: this.storeUser,
name: 'OP',
valueField: 'UserCode',
displayField: 'CodeAndName',
value: SHOWNAME
});
this.CheckRate = new Ext.form.Checkbox({
fieldLabel: '用系统录入汇率',
checked: true
});
this.formVoucherShow = 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: '凭证日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'VoucherDate'
}, this.comboxUser
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '美元汇率',
xtype: 'numberfield',
name: 'UsdExrate'
}, this.CheckRate
]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
});
me = this;
this.winVoucherShow = Ext.create('Ext.window.Window', {
title: "添加凭证",
width: 450,
//height : 120,
//plain : true,
iconCls: "addicon",
resizable: false,
// 是否可以拖动
// draggable:false,
collapsible: true, // 允许缩放条
closeAction: 'close',
closable: true,
modal: 'true',
buttonAlign: "center",
bodyStyle: "padding:0 0 0 0",
items: [this.formVoucherShow],
buttons: [{
text: "生成凭证",
minWidth: 70,
handler: function () {
var selectedRecords = me.gridList.selModel.getSelection();
if (selectedRecords.length == 0) {
Ext.Msg.show({ title: '提示', msg: '没有选择要生成凭证的业务!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
};
var form = me.formVoucherShow.getForm();
var VoucherDate = form.findField('VoucherDate').getRawValue();
if (VoucherDate == '' || VoucherDate == null || VoucherDate == undefined) {
Ext.Msg.show({ title: '提示', msg: '必须填凭证日期!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
};
var UsdExrate = form.findField('UsdExrate').getValue();
if (!me.CheckRate.checked) {
if (UsdExrate == '' || UsdExrate == null || UsdExrate == undefined) {
Ext.Msg.show({ title: '提示', msg: '必须填凭证汇率!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
};
};
var User = me.comboxUser.getValue();
if (User == '' || User == null || User == undefined) {
Ext.Msg.show({ title: '提示', msg: '必须填凭证制单人!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
};
me.onCreateVoucherClick();
}
}, {
text: "关闭",
minWidth: 70,
handler: function () {
me.winVoucherShow.close();
}
}]
});
var _this = this;
this.formSearch = Ext.widget('form', {
frame: true,
region: 'center',
bodyPadding: 5,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 100,
msgTarget: 'qtip'
},
items: [
{//fieldset 1
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxBuyer,
this.comboxBANK, {
fieldLabel: '结算单号',
name: 'BILLNO',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, {
fieldLabel: '资金用途',
name: 'REASON',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}]
}]
}
, {//fieldset 1
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '从..到账日',
format: 'Y-m-d',
xtype: 'datefield',
//labelWidth:60,
name: 'CREATETIME_min',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, {
fieldLabel: '到..到账日',
format: 'Y-m-d',
xtype: 'datefield',
name: 'CREATETIME_max',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, {
fieldLabel: '备注中包含',
name: 'remark',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, {
fieldLabel: '包含金额为零的',
xtype: 'checkbox',
name: 'I_ZERO'
}, {
fieldLabel: '只显示待通过业务',
xtype: 'checkbox',
name: 'NeedAudit'
}]
}]
}
, {//fieldset 1
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
labelWidth: 60,
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '认款的销售单',
//labelWidth: 60,
name: 'SALESNO_RK',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, {
fieldLabel: '核销的销售单',
//labelWidth: 60,
name: 'SALESNO_HX',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, {
fieldLabel: '预收金额',
name: 'AMOUNT',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, {
fieldLabel: '认款金额',
name: 'AMOUNT_RK',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, {
fieldLabel: '核销金额',
name: 'AMOUNT_HX',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}]
}]
}
, {//fieldset 1
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
labelWidth: 60,
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '已认预收待出库',
xtype: 'checkbox',
name: 'NeedOut'
}, this.comboxFEETYPE
, {
xtype: 'hiddenfield', flex: 3
}]
}]
}
]//end root items
});
//#endregion formSearch
//查询工具条
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
text: "新建", id: "YSADD",
iconCls: "btnadd",
handler: function (button, event) {
this.OprationStatus = 'add';
DsOpenEditWin("/Import/ImportAdvancePayment/Edit", "新建合同", "300", "950");
},
scope: this
},
{
text: "删除", id: "YSDEL",
iconCls: "btndelete",
handler: function (button, event) {
this.onDeleteClick(button, event);
},
scope: this
}, '-', {
text: "执行查询",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onRefreshClick(button, event);
},
scope: this
},
{
text: "重置条件",
iconCls: "btnreset",
handler: function (button, event) {
//this.onResetClick(button, event);
//alert(this.getCondition);
},
scope: this
}, '-', {
text: "生成凭证", id: "VOUCHER",
iconCls: "btnadd",
handler: function (button, event) {
var form = this.formVoucherShow.getForm();
var VoucherDate = form.findField('VoucherDate');
this.thisday = this.getToday();
VoucherDate.setRawValue(this.thisday)
this.winVoucherShow.show();
},
scope: this
}, '-', {
text: "保存列表样式",
id: "btntest",
handler: function (button, event) {
//this.column = DsTruck.SaveGridPanel(USERID, this.formname, this.gridList.columns, this.column, 1, false);
var tempcolumns = this.gridList.columns;
DsTruck.SaveGridPanel(USERID, this.formname, tempcolumns, this.column, 1, false);
},
scope: this
}, {
text: "导出Excel",
id: "btnExportExcel",
iconCls: 'btnexportexcel',
handler: function (button, event) {
this.onExportClick(button, event);
},
scope: this
},
{
text: "打印",
iconCls: 'btnprint',
menu: [{
text: '当前预收款情况汇总',
handler: function (menu, event) {
_this.Print_Info();
}
}, {
text: '当前预付情况汇总',
handler: function (menu, event) {
_this.Print_Info_YF();
}
}
],
scope: this
}
]
});
//选择load
this.gridList.getSelectionModel().on('select', function (model, record, index) {
this.BILL = record.data;
this.BILLNO = record.data.BILLNO;
this.CUSTOMERNAME = record.data.CUSTOMERNAME;
if (this.BILLNO != "") {
this.storeBodyList.load({ params: { condition: this.BILLNO} });
this.storeSalesList.load({ params: { start: "0", limit: "999", sort: "", condition: " a.AD_BILLNO='" + this.BILLNO + "'"} });
//加载待添加的销售单
this.storeSalesAddList.load({
params: { start: "0", limit: "999", sort: "", condition: " s.CUSTOMERNAME='" + this.CUSTOMERNAME + "' and SALESTATUS =0 " }
});
this.storeSalesAdvancePay_state_DEL.load({ params: { start: "0", limit: "999", sort: "", condition: " AD_BILLNO='" + this.BILLNO + "'"} });
} else { this.storeBodyList.removeAll(); }
//
}, this);
//#region 布局
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 155,
items: [this.formSearch, this.panelBtn]
});
this.panelContract = new Ext.Panel({
//title: '',
layout: "border",
region: 'center',
height: 600,
margin: '1 2',
split: true,
items: [this.gridList]
});
this.panelBody = new Ext.Panel({
title: '实际核销明细',
layout: "border",
region: 'center',
//height: 300,
margin: '1 1',
split: true,
items: [this.gridBodyList]
});
this.panelSalesList = new Ext.Panel({
//title: '实际核销明细',
layout: "border",
region: 'center',
//height: 300,
margin: '1 1',
split: true,
items: [this.gridSalesList]
});
this.panelSalesAddList = new Ext.Panel({
//title: '实际核销明细',
layout: "border",
region: 'east',
width: 500,
margin: '1 1',
split: true,
items: [this.gridSalesAddList]
});
this.panelSalesBody = new Ext.Panel({
title: '销售单关联明细',
layout: "border",
region: 'center',
//width: 300,
margin: '1 1',
split: true,
items: [this.panelSalesList, this.panelSalesAddList
]
});
this.panelSalesAdvancePay_state_DEL = new Ext.Panel({
title: '已删除的认款明细',
layout: "border",
region: 'center',
//width: 300,
margin: '1 1',
split: true,
items: [this.gridSalesAdvancePay_state_DEL
]
});
this.MainTab = new Ext.tab.Panel({
layout: "border",
region: 'south',
height: 300,
margin: '1 2',
split: true,
items: [this.panelBody, this.panelSalesBody, this.panelSalesAdvancePay_state_DEL
]
});
Ext.apply(this, {
items: [this.panelTop, this.panelContract, this.MainTab]
});
//#endregion
this.SetBtnState();
this.gridSalesList.on('edit', function (editor, e, eOpts) {
this.SalesAfterEdit(editor, e, eOpts);
}, this);
this.storeSalesList.on('beforeload', function (store) {
var sql = ""
if (this.BILLNO != "") {
sql = " a.AD_BILLNO='" + this.BILLNO + "'";
}
else {
sql = " 1=2 "
}
Ext.apply(store.proxy.extraParams, { condition: sql });
}, this);
this.storeBodyList.on('beforeload', function (store) {
var sql = ""
if (this.BILLNO != "") {
sql = this.BILLNO;
}
else {
sql = " 0 "
}
Ext.apply(store.proxy.extraParams, { condition: sql });
}, this);
this.cellEditingBody.on('beforeedit', function (editor, e) {
return this.BodyBeforeEdit(editor, e);
}, this);
this.cellEditingSaleStatus.on('beforeedit', function (editor, e) {
return this.RKBeforeEdit(editor, e);
}, this);
}, //end initUIComponents
SetBtnState: 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;
//alert(rec.VISIBLERANGE);
//alert(rec.OPERATERANGE);
//可视范围无限制。
//可操作为0则全都可见
//4为所有按钮均不可见只能查询
//3为特殊账户可以编辑不可添加预收可以加销售单审销售单
//2为业务只能新增删除销售单不能操作预收
//1为财务可以新建删除预收审批销售出库不可操作销售单
this.VISIBLERANGE = rec.VISIBLERANGE;
this.OPERATERANGE = rec.OPERATERANGE;
if (this.OPERATERANGE == '0') {
Ext.getCmp("YSADD").enable();
Ext.getCmp("YSDEL").enable();
Ext.getCmp("VOUCHER").enable();
Ext.getCmp("SalesAudit").enable();
Ext.getCmp("SalesUnAudit").enable();
this.CaneditYS = true;
Ext.getCmp("SalesAdd").enable();
Ext.getCmp("SalesDel").enable();
Ext.getCmp("SalesSave").enable();
}
if (this.OPERATERANGE == '1') {
Ext.getCmp("YSADD").enable();
Ext.getCmp("YSDEL").enable();
Ext.getCmp("VOUCHER").enable();
Ext.getCmp("SalesAudit").enable();
Ext.getCmp("SalesUnAudit").enable();
this.CaneditYS = true;
Ext.getCmp("SalesAdd").disable();
Ext.getCmp("SalesDel").disable();
Ext.getCmp("SalesSave").disable();
}
if (this.OPERATERANGE == '2') {
Ext.getCmp("YSADD").disable();
Ext.getCmp("YSDEL").disable();
Ext.getCmp("VOUCHER").disable();
Ext.getCmp("SalesAudit").disable();
Ext.getCmp("SalesUnAudit").disable();
this.CaneditYS = false;
Ext.getCmp("SalesAdd").enable();
Ext.getCmp("SalesDel").enable();
Ext.getCmp("SalesSave").enable();
}
if (this.OPERATERANGE == '3') {
Ext.getCmp("YSADD").disable();
Ext.getCmp("YSDEL").disable();
Ext.getCmp("VOUCHER").disable();
Ext.getCmp("SalesAudit").enable();
Ext.getCmp("SalesUnAudit").enable();
this.CaneditYS = true;
Ext.getCmp("SalesAdd").enable();
Ext.getCmp("SalesDel").enable();
Ext.getCmp("SalesSave").enable();
}
if (this.OPERATERANGE == '4') {
Ext.getCmp("YSADD").disable();
Ext.getCmp("YSDEL").disable();
Ext.getCmp("VOUCHER").disable();
Ext.getCmp("SalesAudit").disable();
Ext.getCmp("SalesUnAudit").disable();
this.CaneditYS = false;
Ext.getCmp("SalesAdd").disable();
Ext.getCmp("SalesDel").disable();
Ext.getCmp("SalesSave").disable();
}
}
else
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
},
scope: this
}); //request over
},
checkHandler: function () {
alert('Checked a menu item');
},
onRefreshClick: function (button, event) {
var sql = this.getCondition();
this.storeList.load({
params: { start: 0, limit: this.PageSize, sort: '', condition: sql },
waitMsg: "正在查询数据...",
callback: function (options, success, response) {
if (success) {
//alert("");
}
},
scope: this
});
this.BILLNO = "";
this.CUSTOMERNAME = "";
this.storeBodyList.removeAll();
this.storeSalesList.removeAll();
},
onRefreshClick2: function (button, event) {
var sql = this.getCondition2();
this.storeSalesAddList.load({
params: { start: 0, limit: 9999, sort: '', condition: sql },
waitMsg: "正在查询数据...",
callback: function (options, success, response) {
if (success) {
//alert("");
}
},
scope: this
});
},
onDeleteClick: function (button, event) {
var selections = this.gridList.getSelectionModel().getSelection();
if (selections.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择单据!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var record = selections[0];
if (record.data.ISVOU == '是') {
Ext.Msg.show({ title: '提示', msg: '已生成凭证,不能删除业务!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
};
var n1 = this.storeSalesList.getCount();
var n2 = this.storeBodyList.getCount();
if (n1 > 0) {
Ext.Msg.show({ title: '提示', msg: '有认款记录的预收不能删除!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
if (n2 > 0) {
Ext.Msg.show({ title: '提示', msg: '有核销记录的预收不能删除!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/Import/CWAdvancePayment/Delete',
params: {
data: Ext.JSON.encode(record.data),
USERID: USERID
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.storeList.remove(record);
Ext.Msg.show({ title: '提示', msg: jsonresult.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
}
else {
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
}
},
failure: function (response, options) {
Ext.Msg.show({ title: '警告', msg: '服务器响应出错,请重试', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
},
success: function (response, options) {
},
scope: this
}); //end Ext.Ajax.request
}
}, this);
}, //onDeleteClick
onCreateVoucherClick: function (button, event) {
var feeBSNOSql = '';
var selectedRecords = this.gridList.selModel.getSelection();
var form = this.formVoucherShow.getForm();
var selections = this.gridList.getSelectionModel().getSelection();
if (selections.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择单据!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var record = selections[0];
if (record.data.ISVOU == '是') {
Ext.Msg.show({ title: '提示', msg: '没有选择要生成凭证的业务,必须是没有生成凭证的业务!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
};
var VoucherDate = form.findField('VoucherDate').getRawValue();
var UsdExrate = form.findField('UsdExrate').getValue();
var User = this.comboxUser.getValue();
var useRate = 1;
if (!this.CheckRate.checked) { useRate = 0 };
Ext.Ajax.request({
waitMsg: '正在添加数据...',
url: '/Import/CWAdvancePayment/CreateVoucher',
params: {
VoucherDate: VoucherDate,
UsdExrate: UsdExrate,
User: User,
useRate: useRate,
data: Ext.JSON.encode(record.data)
},
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 {
this.winVoucherShow.close();
this.onRefreshClick();
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
},
getToday: function () {
var now = new Date();
var year = now.getFullYear(); //年
var month = now.getMonth() + 1; //月
var day = now.getDate(); //日
var clock = year + "-";
if (month < 10)
clock += "0";
clock += month + "-";
if (day < 10)
clock += "0";
clock += day + " ";
return (clock);
},
onResetClick: function (button, event) {
this.formSearch.getForm().reset();
},
getStrValue: function (list) {
var _list = [];
for (var _i = 0; _i < list.length; _i++) {
_list.push("'" + list[_i] + "'");
}
return _list;
},
getCondition: function () {
var form = this.formSearch.getForm();
if (!form.isValid()) {
Ext.Msg.alert('提示', '查询条件赋值错误,请检查。');
return '';
}
var sql = '';
var buyer = this.getStrValue(this.comboxBuyer.getValue());
sql = sql + getAndConSql(sql, buyer, "ap.CUSTOMERNAME in (" + buyer + ")");
var CREATETIME_min = form.findField('CREATETIME_min').getRawValue();
sql = sql + getAndConSql(sql, CREATETIME_min, "ap.CREATETIME >= '" + CREATETIME_min + "'");
var CREATETIME_max = form.findField('CREATETIME_max').getRawValue();
sql = sql + getAndConSql(sql, CREATETIME_max, "ap.CREATETIME <= '" + CREATETIME_max + " 23:59:59'");
var billNo = form.findField('BILLNO').getValue();
sql = sql + getAndConSql(sql, billNo, " ap.BILLNO like '%" + billNo + "%' ");
var REASON = form.findField('REASON').getValue();
sql = sql + getAndConSql(sql, REASON, " ap.REASON like '%" + REASON + "%' ");
var remark = form.findField('remark').getValue();
sql = sql + getAndConSql(sql, remark, " ap.remark like '%" + remark + "%' ");
var BANKACCID = form.findField('BANKACCID').getValue();
sql = sql + getAndConSql(sql, BANKACCID, " ap.BANKACCID = '" + BANKACCID + "' ");
var I_ZERO = form.findField("I_ZERO").getValue();
if (I_ZERO)
{ sql = sql + getAndConSql(sql, I_ZERO, " 1=1 "); }
else
{ sql = sql + getAndConSql(sql, true, " ap.AMOUNT<>ap.DOAMOUNT "); }
var NeedAudit = form.findField("NeedAudit").getValue();
if (NeedAudit)
{ sql = sql + getAndConSql(sql, true, " ap.BILLNO in(select AD_BILLNO from SalesAdvancePay_state where PASSED=0) "); }
else
{ sql = sql + getAndConSql(sql, true, " 1=1 "); }
var NeedOut = form.findField("NeedOut").getValue();
if (NeedOut)
{ sql = sql + getAndConSql(sql, true, " EXISTS ( select * from Import_Sales where SALESTATUS=0 and SALESNO in(select SALESNO from SalesAdvancePay_state where AD_BILLNO=ap.BILLNO and PASSED=1) ) "); }
else
{ }
var SALESNO_RK = form.findField('SALESNO_RK').getValue();
sql = sql + getAndConSql(sql, SALESNO_RK, " ap.BILLNO in(select AD_BILLNO from SalesAdvancePay_state where SALESNO like '%" + SALESNO_RK + "%' ) ");
var SALESNO_HX = form.findField('SALESNO_HX').getValue();
sql = sql + getAndConSql(sql, SALESNO_HX, " ap.BILLNO in(select billno from ch_fee_advance_payment_detail where SETTLEBILLNO in(select billno from ch_Fee_do where FEEID in(select gid from ch_fee where SALESNO like '%" + SALESNO_HX + "%'))) ");
var AMOUNT = form.findField('AMOUNT').getValue();
sql = sql + getAndConSql(sql, AMOUNT, " ap.AMOUNT='" + AMOUNT + "' ");
var AMOUNT_RK = form.findField('AMOUNT_RK').getValue();
sql = sql + getAndConSql(sql, AMOUNT_RK, " ap.BILLNO in(select AD_BILLNO from SalesAdvancePay_state where DOAMOUNT= " + AMOUNT_RK + " ) ");
var AMOUNT_HX = form.findField('AMOUNT_HX').getValue();
sql = sql + getAndConSql(sql, AMOUNT_HX, " ap.BILLNO in(select billno from ch_fee_advance_payment_detail where DOAMOUNT= " + AMOUNT_HX + ") ");
var FEETYPE = form.findField('FEETYPE').getValue();
sql = sql + getAndConSql(sql, FEETYPE, " ap.FEETYPE = " + FEETYPE + " ");
return sql;
},
getCondition2: function () {
var sql = '';
var SALESNO = Ext.getCmp("add_SALESNO").getValue();
sql = sql + getAndConSql(sql, SALESNO, " s.SALESNO like '%" + SALESNO + "%' ");
var CUSTOMERNAME = Ext.getCmp("add_CUSTOMERNAME").getValue();
sql = sql + getAndConSql(sql, CUSTOMERNAME, " s.CUSTOMERNAME= '" + CUSTOMERNAME + "' ");
var SALER = Ext.getCmp("add_SALER").getValue();
sql = sql + getAndConSql(sql, SALER, " s.SALER = '" + SALER + "' ");
return sql;
},
onGetremind: function (field, newValue, oldValue) {
if (newValue != null) {
this.storeList.load({
params: { start: 0, limit: this.PageSize, sort: '', condition: newValue },
waitMsg: "正在查询数据...",
scope: this
});
}
},
OprationSwap: function () {
var ret = new Array();
ret[0] = this.OprationStatus;
ret[1] = this.storeList;
ret[2] = this.SelectedRecord;
ret[3] = this.BILL;
return ret;
},
onExportClick: function (button, event) {
GridExportExcelPage(this.gridList);
},
onAddStateClick: function (button, event) {
if (this.BILLNO == "") {
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 _thisdate = GetDateStr(0);
var record = Ext.create('SalesStateAuditmb', {
'id': '',
'GID': NewGuid(),
'SALESNO': '',
'DOAMOUNT': '0',
'AD_BILLNO': '',
'CREATEUSER': USERID,
'CREATEUSER_REF': SHOWNAME,
'CREATETIME': _thisdate,
'AUDITOR_REF': '',
'AUDITOR': '',
'AUDITTIME': ''
});
this.storeSalesList.add(record);
var n = this.storeSalesList.getCount();
this.cellEditingSaleStatus.startEditByPosition({ row: n - 1, column: 3 });
//aftereditform();
}
, onDelStateClick: function (button, event) {
var selectedRecords = this.gridSalesList.selModel.getSelection();
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.get("PASSED") == "1") {
alert("已审核通过的销售单不能直接删除,需通知财务部门撤销此条审核。");
return;
}
if (rec.get("AD_BILLNO") != "" || rec.get("AD_BILLNO") != "*") //如果是新增但没有保存的数据,没有必要提交到后台
{
this.SalesDel.push(rec);
}
//alert(i);
this.storeSalesList.remove(selectedRecords[i]);
}
}
, SalesAfterEdit: function (editor, e, eOpts) {
if (e.field == 'SALESNO') {
var records = DsStoreQueryBy(this.storeSalesAddList, 'SALESNO', e.value);
if (records.getCount() > 0) {
var _d = records.getAt(0).data;
e.record.set('CUSTOMERNAME', _d.CUSTOMERNAME);
e.record.set('CARGONAME', _d.CARGONAME);
e.record.set('CURRENCY', _d.CURRENCY);
e.record.set('AMOUNT', _d.AMOUNT);
e.record.set('AMOUNTRMB', _d.AMOUNTRMB);
//此处首先获得该预收总额
var Amount_1 = this.BILL.AMOUNT;
//然后遍历该store取得其他已声明使用的金额之和
var Amount_2 = 0;
for (var i = 0; i < this.storeSalesAddList.getCount(); i += 1) {
var _r = this.storeSalesAddList.getAt(i).data;
if (_r.SALESNO == e.value) { continue; }
else {
Amount_2 = Amount_2 + parseFloat(_r.Forecast_Remain);
}
}
var KS = Cut(Amount_1, Amount_2, 2); //预收总额-‘其他’已声明使用的金额之和
//最后在Doamount当中添加AMOUNTRMB,和 预收总额-‘其他’已声明使用的金额之和 之最小者
if (KS <= 0) {
e.record.set('DOAMOUNT', "0");
}
else
if (Cut(Amount_1, Amount_2, 2) >= parseFloat(_d.AMOUNTRMB)) {
e.record.set('DOAMOUNT', _d.AMOUNTRMB);
} else {
e.record.set('DOAMOUNT', Cut(Amount_1, Amount_2, 2));
}
} else {
e.record.set('CUSTOMERNAME', '');
}
}
}
, onAddSalesClick: function () {
if (this.BILLNO == "") {
return;
}
var selectedRecords = this.gridSalesAddList.selModel.getSelection();
for (var i = 0; i < selectedRecords.length; i++) {
var _d = selectedRecords[i].data;
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 _thisdate = GetDateStr(0);
/*
e.record.set('SALESNO', _d.SALESNO);
e.record.set('CUSTOMERNAME', _d.CUSTOMERNAME);
e.record.set('CARGONAME', _d.CARGONAME);
e.record.set('CURRENCY', _d.CURRENCY);
e.record.set('AMOUNT', _d.AMOUNT);
e.record.set('AMOUNTRMB', _d.AMOUNTRMB);*/
//此处首先获得该预收总额
var Amount_1 = this.BILL.AMOUNT;
//然后遍历该store取得其他已声明使用的金额之和
var Amount_2 = 0;
for (var i = 0; i < this.storeSalesAddList.getCount(); i += 1) {
var _r = this.storeSalesAddList.getAt(i).data;
if (_r.SALESNO == _d.SALESNO) { continue; }
else {
Amount_2 = Amount_2 + parseFloat(_r.Forecast_Remain);
}
}
var KS = Cut(Amount_1, Amount_2, 2); //预收总额-‘其他’已声明使用的金额之和
var DOAMOUNT = 0;
//最后在Doamount当中添加AMOUNTRMB,和 预收总额-‘其他’已声明使用的金额之和 之最小者
if (KS <= 0) {
//e.record.set('DOAMOUNT', "0");
}
else
if (Cut(Amount_1, Amount_2, 2) >= parseFloat(_d.AMOUNTRMB)) {
DOAMOUNT = _d.AMOUNTRMB;
} else {
DOAMOUNT = Cut(Amount_1, Amount_2, 2);
}
var record = Ext.create('SalesStateAuditmb', {
'id': '',
'GID': NewGuid(),
'SALESNO': _d.SALESNO,
'CUSTOMERNAME': _d.CUSTOMERNAME,
'CARGONAME': _d.CARGONAME,
'CURRENCY': _d.CURRENCY,
'AMOUNT': _d.AMOUNT,
'AMOUNTRMB': _d.AMOUNTRMB,
'DOAMOUNT': DOAMOUNT,
'AD_BILLNO': '',
'CREATEUSER': '', //USERID,
'CREATEUSER_REF': '', //SHOWNAME,
'CREATETIME': _thisdate,
'AUDITOR_REF': '',
'AUDITOR': '',
'AUDITTIME': ''
});
this.storeSalesList.add(record);
var n = this.storeSalesList.getCount();
this.cellEditingSaleStatus.startEditByPosition({ row: n - 1, column: 3 });
}
for (var i = 0; i < this.storeSalesList.getCount(); i++) {
_f = this.storeSalesList.getAt(i); //遍历每一行
if (_f.get('CREATEUSER') == "") {
_f.set('CREATEUSER', USERID);
_f.set('CREATEUSER_REF', SHOWNAME);
}
}
}
, onSaveStateClick: function (type) {
var Salesdatas = [];
for (var i = 0; i < this.storeSalesList.getCount(); i += 1) {
var member = this.storeSalesList.getAt(i);
Salesdatas.push(member);
}
//商品明细
var SalesBody = ConvertRecordsToJson(Salesdatas);
var SalesDelBody = ConvertRecordsToJsonAll(this.SalesDel);
if (SalesBody == "" && SalesDelBody == "") {
return;
}
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Import/ImportSales/SaveSalesState',
scope: this,
params: {
YSYFNO: this.BILLNO,
SalesStateBody: SalesBody,
SalesStateDelBody: SalesDelBody
},
callback: function (options, success, response) {
this.SalesDel = [];
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.storeSalesList.load({ params: { start: "0", limit: "999", sort: "", condition: " a.AD_BILLNO='" + this.BILLNO + "'"} });
this.storeSalesAddList.load({
params: { start: "0", limit: "999", sort: "", condition: " s.CUSTOMERNAME='" + this.CUSTOMERNAME + "' and SALESTATUS =0 " }
});
} 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');
}
});
}
, DoAuditOut: function () {
var selectedRecords = this.gridSalesList.selModel.getSelection();
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i].data;
if (rec.PASSED == "1" && rec.SALESTATUS == "2") {
continue;
}
var SALESNO = rec.SALESNO;
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Import/ImportSales/SetSaleStatus',
scope: this,
async: false,
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) {
//提示操作成功
if (parseInt(jsonresult.totalCount) > 0) {
alert("操作成功。");
} else {
alert("没有操作成功记录。");
}
//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');
}
});
}
this.storeSalesList.load({ params: { start: "0", limit: "999", sort: "", condition: " a.AD_BILLNO='" + this.BILLNO + "'"} });
//加载待添加的销售单
this.storeSalesAddList.load({
params: { start: "0", limit: "999", sort: "", condition: " s.CUSTOMERNAME='" + this.CUSTOMERNAME + "' and SALESTATUS =0 " }
});
}
, AuditOut: function () {
var REMAIN = parseFloat(this.BILL.REMAIN);
var AMOUNT = 0;
var selectedRecords = this.gridSalesList.selModel.getSelection();
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i].data;
if (rec.PASSED == "1" && rec.SALESTATUS == "2") {
continue;
}
AMOUNT = AMOUNT + parseFloat(rec.DOAMOUNT);
}
var _this = this;
if (AMOUNT > REMAIN) {
Ext.MessageBox.confirm('提示', '此次通过的总金额超过此预收的剩余金额,您确定该客户有其他足额的可用预收吗?', function (btn) {
if (btn == 'yes') {
_this.DoAuditOut();
}
});
} else
this.DoAuditOut();
}
, UnAuditOut: function () {
var selectedRecords = this.gridSalesList.selModel.getSelection();
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i].data;
if (rec.PASSED == "0") {
continue;
}
var SALESNO = rec.SALESNO;
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Import/ImportSales/SetSaleStatus',
scope: this,
async: false,
params: {
SALESNO: SALESNO,
SALESTATUS: "0"
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
//加载待添加的销售单
this.storeSalesAddList.load({
params: { start: "0", limit: "999", sort: "", condition: " s.CUSTOMERNAME='" + this.CUSTOMERNAME + "' and SALESTATUS =0 " }
});
} 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');
}
});
}
this.storeSalesList.load({ params: { start: "0", limit: "999", sort: "", condition: " a.AD_BILLNO='" + this.BILLNO + "'"} });
//加载待添加的销售单
this.storeSalesAddList.load({
params: { start: "0", limit: "999", sort: "", condition: " SALESNO not in(select SALESNO from SalesAdvancePay_state ) and s.CUSTOMERNAME='" + this.CUSTOMERNAME + "' and SALESTATUS =0 " }
});
}
, AuditState: function () {
var selectedRecords = this.gridSalesList.selModel.getSelection();
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i].data;
if (rec.PASSED == "1") {
continue;
}
var GID = rec.GID;
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Import/ImportSales/SetRKState',
scope: this,
async: false,
params: {
GID: GID,
PASSED: "1"
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
//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');
}
});
}
this.storeSalesList.load({ params: { start: "0", limit: "999", sort: "", condition: " a.AD_BILLNO='" + this.BILLNO + "'"} });
}
, UnAuditState: function () {
var selectedRecords = this.gridSalesList.selModel.getSelection();
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i].data;
if (rec.PASSED == "0") {
continue;
}
var GID = rec.GID;
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Import/ImportSales/SetRKState',
scope: this,
async: false,
params: {
GID: GID,
PASSED: "0"
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
//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');
}
});
}
this.storeSalesList.load({ params: { start: "0", limit: "999", sort: "", condition: " a.AD_BILLNO='" + this.BILLNO + "'"} });
}
, BodyBeforeEdit: function (editor, e) {
var SETTLEBILLNO = e.record.get('SETTLEBILLNO');
var canedit = true;
if (SETTLEBILLNO != "") {
//才能进行编辑 删除
canedit = false;
} else {
}
return canedit;
}
, RKBeforeEdit: function (editor, e) {
var PASSED = e.record.get('PASSED');
var canedit = true;
if (PASSED == "0"||PASSED=="") {
//才能进行编辑 删除
canedit = true;
} else {
canedit = false;
}
return canedit;
}
, onAddBodyClick: function () {
if (this.BILLNO == "") {
return;
}
//this.BILL是当前选中行的数据集
var myDate = new Date();
myDate.toLocaleDateString();
var record = Ext.create('CWAdvancePaymentBodymb', {
'GID': NewGuid(),
'LINKGID': "",
'BILLNO': this.BILLNO,
'SETTLELINKGID': this.BILLNO,
'SETTLEBILLNO': "",
'FEETYPE': "2",
'FEETYPEREF': "付款",
'CUSTOMERNAME': this.BILL.CUSTOMERNAME,
'CURRENCY': this.BILL.CURRENCY,
'DOAMOUNT': "0", //Cut(this.BILL.AMOUNT,this.BILL.DOAMOUNT)
'SETTLEUSER': USERID,
'SETTLEUSERREF': SHOWNAME,
'SETTLETIME': myDate.toLocaleDateString(),
'REMARK': "",
'ISDELETE': "",
'DELETEUSER': "",
'DELETETIME': "",
'COMPANYID': "",
'VOUCHERNO': ""
});
this.storeBodyList.add(record);
var n = this.storeBodyList.getCount();
this.cellEditingBody.startEditByPosition({ row: n - 1, column: 9 });
}
, onDelBodyClick: function (button, event) {
var selectedRecords = this.gridBodyList.selModel.getSelection();
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.get("SETTLEBILLNO") != "") {
alert("由结算产生的核销明细不能删除");
return;
}
if (rec.get("AD_BILLNO") != "" || rec.get("AD_BILLNO") != "*") //如果是新增但没有保存的数据,没有必要提交到后台
{
this.BodyDel.push(rec);
}
//alert(i);
this.storeBodyList.remove(selectedRecords[i]);
}
}
, onSaveBodyClick: function (type) {
var Bodydatas = [];
for (var i = 0; i < this.storeBodyList.getCount(); i += 1) {
var member = this.storeBodyList.getAt(i);
Bodydatas.push(member);
}
//商品明细
var Body = ConvertRecordsToJson(Bodydatas);
var DelBody = ConvertRecordsToJsonAll(this.BodyDel);
if (Body == "" && DelBody == "") {
return;
}
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Import/ImportAdvancePayment/SaveBody',
scope: this,
params: {
YSYFNO: this.BILLNO,
Body: Body,
DelBody: DelBody
},
callback: function (options, success, response) {
this.BodyDel = [];
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
/*
this.storeSalesList.load({ params: { start: "0", limit: "999", sort: "", condition: " a.AD_BILLNO='" + this.BILLNO + "'"} });
this.storeSalesAddList.load({
params: { start: "0", limit: "999", sort: "", condition: " s.CUSTOMERNAME='" + this.CUSTOMERNAME + "' and SALESTATUS =0 " }
});
*/
this.storeBodyList.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');
}
});
}
, Print_Info: function () {
var condition = "";
var buyer = this.getStrValue(this.comboxBuyer.getValue());
if (buyer != "") {
condition = " and ap.CUSTOMERNAME in (" + buyer + ")";
}
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 printType = 'Print_ImportAdvancePay_YS'; //期货 牛羊
var sql1 = " select customername,currency,sum(amount) 预收款,sum(doamount) 已核销,sum(RK_Amount) 已认款 from ";
sql1 = sql1 + " (select ap.billno ,CUSTOMERNAME,ap.AMOUNT,ap.DOAMOUNT,ap.CURRENCY,ap.EXCHANGERATE ";
sql1 = sql1 + " ,isnull((select sum(isnull(doamount,0)) from SalesAdvancePay_state where AD_BILLNO=ap.BILLNO),0) RK_Amount ";
sql1 = sql1 + " ,isnull((select sum(isnull(doamount,0)) from ch_fee_advance_payment_detail where BILLNO=ap.BILLNO),0) HX_Amount ";
sql1 = sql1 + " FROM ch_fee_advance_payment ap where ap.FEETYPE=1 and isdelete=0 ";
sql1 = sql1 + condition;
sql1 = sql1 + " )t group by t.customername,t.CURRENCY order by customername,CURRENCY ";
var sql2 = "";
var sql3 = "";
var sql4 = "";
var sql5 = "";
var sql6 = "";
PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6);
}
, Print_Info_YF: function () {
var condition = "";
var buyer = this.getStrValue(this.comboxBuyer.getValue());
if (buyer != "") {
condition = " and ap.CUSTOMERNAME in (" + buyer + ") ";
}
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 printType = 'Print_ImportAdvancePay_YF'; //期货 牛羊
var sql1 = " select customername,currency,sum(amount) 预收款,sum(doamount) 已核销,sum(RK_Amount) 已认款 from ";
sql1 = sql1 + " (select ap.billno ,CUSTOMERNAME,ap.AMOUNT,ap.DOAMOUNT,ap.CURRENCY,ap.EXCHANGERATE ";
sql1 = sql1 + " ,isnull((select sum(isnull(doamount,0)) from SalesAdvancePay_state where AD_BILLNO=ap.BILLNO),0) RK_Amount ";
sql1 = sql1 + " ,isnull((select sum(isnull(doamount,0)) from ch_fee_advance_payment_detail where BILLNO=ap.BILLNO),0) HX_Amount ";
sql1 = sql1 + " FROM ch_fee_advance_payment ap where ap.FEETYPE=2 and isdelete=0 ";
sql1 = sql1 + condition;
sql1 = sql1 + " )t group by t.customername,t.CURRENCY order by customername,CURRENCY ";
var sql2 = "";
var sql3 = "";
var sql4 = "";
var sql5 = "";
var sql6 = "";
PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6);
}
, onPrintBackClick: function () {
if (this.BILLNO == "") {
return;
}
/*
var basicForm = this.formEdit.getForm();
var billNo = this.BILLNO;
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 = basicForm.findField('CUSTOMERNAME').value;
var selectedRecords = this.gridBodyList.selModel.getSelection();
var DetailList = "";
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.get("SETTLEBILLNO") != "") {
alert("由结算产生的核销明细不能加入");
return;
}
if (rec.get("AD_BILLNO") != "" || rec.get("AD_BILLNO") != "*") //如果是新增但没有保存的数据,没有必要提交到后台
{
this.BodyDel.push(rec);
}
//alert(i);
if (DetailList == "") {
DetailList = rec.get("SETTLEBILLNO");
}
}
var printType = 'CH_fee_AdvancePayment_payback';
var sql1 = "select CUSTOMERNAME 客户,CREATETIME 汇款日期,(select showname from [user] where gid=CREATEUSER) 认款人 ";
sql1 = sql1 + ",(select ACCNAME from cw_accitems where ACCID=BANKACCID) 银行,Amount 认款金额 ";
sql1 = sql1 + ",GID 预收预付编号,remark 摘要,CREATETIME 到账时间 ";
sql1 = sql1 + " from ch_fee_advance_payment WHERE GID='" + billNo + "' ";
var sql2 = "select bankname2 from sys_bank where linkid=(select companyid from ch_fee_advance_payment WHERE GID='" + billNo + "') ";
// var sql3 = " select * from company where gid=(select top 1 companyid from ch_fee_do where BILLNO='" + billNo + "') ";
var sql3 = " select FULLNAME 全称, enname 公司英文名称,ENADDRESS 公司英文地址,ORGANIZATIONCODE 组织机构代码 ";
sql3 = sql3 + " ,* from company where gid=(select companyid from ch_fee_advance_payment WHERE GID='" + billNo + "') ";
var sql4 = "select '" + madedate + "' as madedate,'" + CUSTOMERNAME + "' as CUSTOMERNAME,'" + SHOWNAME + "' as SHOWNAME";
var sql5 = "";
var sql6 = "";
PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6);
*/
}
});