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

1538 lines
50 KiB
JavaScript

3 years ago
Ext.namespace('Shipping');
Shipping.MsOpSeaeFenAdd = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsOpSeaeFenAdd.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsOpSeaeFenAdd, Ext.Panel, {
ParentWin: null,
OpStatus: 'add',
StoreList: null,
EditRecord: null,
addstore: false,
PageSize: 30,
FenBsNo:'',
initUIComponents: function () {
this.serialNo = 0;
this.workSerialNo = 0;
this.bodyDel = [];
this.FeeSql = '';
this.BsNo = '*';
this.DuiBillSql = '';
this.IsDebit = '0';
//#region 编辑form
//枚举参照相关(编辑form)
//表参照相关(编辑form)
//#region 明细表
//明细表表格相关
this.GridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
//明细表-数据集
this.storeBodyList = Ext.create('Ext.data.Store', {
model: 'ImportTrademb',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/Import/ImportTrade/GetFenList',
reader: {
id: 'BSNO',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//明细表表格
_thisfenadd=this;
this.gridList = new Ext.grid.GridPanel({
store: this.storeBodyList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
selModel: this.GridCheckBoxModel,
tbar: [{
text: '添加至主票',
tooltip: '添加至主票',
iconCls: "btnadddetail",
id: "btnadddetail",
handler: function (button, event) {
this.onAddClick(button, event);
},
scope: this
}],
columns: [{
sortable: true,
dataIndex: 'MASTERNO',
header: '主编号',
hidden: true,
width: 0
}, {
sortable: true,
dataIndex: 'BSNO',
header: '业务编号',
hidden: true,
width: 0
}, {
dataIndex: 'MBLNO',
header: '主提单号',
width: 130
}, {
dataIndex: 'HBLNO',
header: '分提单号',
width: 130
}, {
dataIndex: 'CUSTOMERNAME',
header: '委托单位',
width: 120
}, {
dataIndex: 'SALE',
header: '销售',
width: 70
}, {
sortable: true,
dataIndex: 'PKGS',
header: '件数',
width: 80
}, {
dataIndex: 'KINDPKGS',
header: '包装',
width: 100
}, {
dataIndex: 'KGS',
header: '重量',
width: 80
}, {
dataIndex: 'CBM',
header: '尺码',
width: 80
}, {
dataIndex: 'BLFRT',
header: '付费方式',
width: 120
}, {
dataIndex: 'DESTINATION',
header: '目的地',
width: 140
}, {
dataIndex: 'PLACEDELIVERY',
header: '交货地',
width: 140
}, {
dataIndex: 'REMARK',
header: '备注',
width: 150
}
]
});
//#region 添加业务列表
this.storeBodyAddList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'ImportTrademb',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/Import/ImportTrade/GetFenList',
reader: {
id: 'BSNO',
root: 'data',
totalProperty: 'totalCount'
}
}
});
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,
columns: [{
sortable: true,
dataIndex: 'BSNO',
header: 'BSNO',
hidden: true,
width: 100
}, {
sortable: true,
dataIndex: 'MBLNO',
header: '主提单号',
width: 120
}, {
dataIndex: 'VESSEL',
header: '船名',
width: 160
}, {
dataIndex: 'VOYNO',
header: '航次',
width: 60
}, {
dataIndex: 'ETD',
header: '开船日期',
width: 80
}, {
dataIndex: 'PORTDISCHARGE',
header: '卸货港',
width: 140
}, {
dataIndex: 'PORTLOAD',
header: '装货港',
width: 140
}, {
sortable: true,
dataIndex: 'CUSTNO',
header: '委托编号',
width: 108
}, {
sortable: true,
dataIndex: 'PKGS',
header: '件数',
width: 80
}, {
dataIndex: 'KINDPKGS',
header: '包装',
width: 100
}, {
dataIndex: 'KGS',
header: '重量',
width: 80
}, {
dataIndex: 'CBM',
header: '尺码',
width: 80
}, {
dataIndex: 'BLFRT',
header: '付费方式',
width: 120
}, {
dataIndex: 'REMARK',
header: '备注',
width: 150
}
]
});
_this = this;
//#endregion
//#region 添加费用列表
this.storeAddFenList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'ImportTrademb',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/Import/ImportTrade/GetFenList',
reader: {
id: 'BSNO',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.AddFenGridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
this.gridAddFenList = new Ext.grid.GridPanel({
store: this.storeAddFenList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
selModel: this.AddFenGridCheckBoxModel,
tbar: [{
text: '取消装箱',
tooltip: '取消装箱',
id: 'btndeldetail',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDeleteClick(button, event);
},
scope: this
}],
columns: [{
sortable: true,
dataIndex: 'MASTERNO',
header: '主编号',
hidden: true,
width: 0
}, {
sortable: true,
dataIndex: 'BSNO',
header: '业务编号',
hidden: true,
width: 0
}, {
dataIndex: 'MBLNO',
header: '主提单号',
width: 130
}, {
dataIndex: 'HBLNO',
header: '分提单号',
width: 130
}, {
dataIndex: 'CUSTOMERNAME',
header: '委托单位',
width: 120
}, {
dataIndex: 'SALE',
header: '销售',
width: 70
}, {
sortable: true,
dataIndex: 'PKGS',
header: '件数',
width: 80
}, {
dataIndex: 'KINDPKGS',
header: '包装',
width: 100
}, {
dataIndex: 'KGS',
header: '重量',
width: 80
}, {
dataIndex: 'CBM',
header: '尺码',
width: 80
}, {
dataIndex: 'BLFRT',
header: '付费方式',
width: 120
}, {
dataIndex: 'DESTINATION',
header: '目的地',
width: 140
}, {
dataIndex: 'PLACEDELIVERY',
header: '交货地',
width: 140
}, {
dataIndex: 'REMARK',
header: '备注',
width: 150
}
]
});
this.gridAddFenList.on('edit', function (editor, e, eOpts) {
this.gridAddFenListAfterEdit(editor, e, eOpts);
}, this);
//#endregion
_this = this;
this.storeVoyVeg = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.VesselModel',
proxy: { url: '/CommMng/BasicDataRef/GetVesselList' }
});
this.storeVoyVeg.load({ params: { condition: ""} });
this.comboxVoyVeg = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '船 名',
store: this.storeVoyVeg,
name: 'VESSEL',
valueField: 'VESSEL',
flex: 1,
displayField: 'VESSEL',
enableKeyEvents: true,
listeners: {
keyup: function (field, e) {
if (e.getKey() == e.ENTER) {
_thisfenadd.onRefreshClick();
}
}
}
});
this.comboxVoyVeg2 = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '船 名',
store: this.storeVoyVeg,
name: 'VESSEL2',
valueField: 'VESSEL',
flex: 1,
displayField: 'VESSEL',
enableKeyEvents: true,
listeners: {
keyup: function (field, e) {
if (e.getKey() == e.ENTER) {
_thisfenadd.onRefresh2Click();
}
}
}
});
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: [{
fieldLabel: '编号',
name: 'MBLNO',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_thisfenadd.onRefreshClick();
}
}
}
}, this.comboxVoyVeg, {
fieldLabel: '航次',
name: 'VOYNO',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_thisfenadd.onRefreshClick();
}
}
}
}, {
fieldLabel: '从开船日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'ExpDateBgn',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_thisfenadd.onRefreshClick();
}
}
}
}, {
fieldLabel: '到开船日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'ExpDateEnd',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_thisfenadd.onRefreshClick();
}
}
}
}, {
xtype: 'button',
width: 90,
text: "查询分票",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onRefreshClick(button, event);
},
scope: this
}, {
xtype: 'button',
width: 90,
text: "重置条件",
iconCls: "btnreset",
handler: function (button, event) {
this.onClearSql(button, event);
},
scope: this
}
]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
});
this.formSearch2 = 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: [{
fieldLabel: '编号',
name: 'MBLNO2',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_thisfenadd.onRefresh2Click();
}
}
}
}, this.comboxVoyVeg2, {
fieldLabel: '航次',
name: 'VOYNO2',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_thisfenadd.onRefresh2Click();
}
}
}
}, {
fieldLabel: '从开船日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'ExpDateBgn2',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_thisfenadd.onRefresh2Click();
}
}
}
}, {
fieldLabel: '到开船日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'ExpDateEnd2',
enableKeyEvents: true,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_thisfenadd.onRefresh2Click();
}
}
}
}, {
xtype: 'button',
width: 90,
text: "查询主票",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onRefresh2Click(button, event);
},
scope: this
}, {
xtype: 'button',
width: 90,
text: "重置条件",
iconCls: "btnreset",
handler: function (button, event) {
this.onClearSql2(button, event);
},
scope: this
}
]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
});
this.panelService = new Ext.Panel({
layout: "border",
region: 'center',
margin: '2 2',
items: [this.gridList]
});
this.paneldetail = new Ext.Panel({
title: '未配箱拼箱分票',
layout: "border",
region: "center",
split: true,
items: [
this.formSearch,
this.panelService
]
});
//#region 集装箱-数据集
this.storeBodyListCtn = Ext.create('Ext.data.Store', {
model: 'MsOpSeaeDetail',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/Import/ImportTrade/GetBodyList',
reader: {
id: 'BsNo,CTNCODE,CTN_ID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.gridListCtnCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
this.gridListCtn = new Ext.grid.GridPanel({
store: this.storeBodyListCtn,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
selModel: this.gridListCtnCheckBoxModel,
selType: 'cellmodel',
columns: [{
sortable: true,
dataIndex: 'CTN_ID',
header: '编号',
hidden: true,
width: 0
}, {
sortable: true,
dataIndex: 'BSNO',
header: '业务编号',
hidden: true,
width: 0
}, {
sortable: true,
dataIndex: 'CTNCODE',
header: '序号',
width: 30
}, {
dataIndex: 'CTNALL',
header: '箱型',
width: 48
}, {
dataIndex: 'CTNNUM',
header: '箱量',
width: 30
}, {
dataIndex: 'CNTRNO',
header: '箱号',
width: 100
}, {
dataIndex: 'SEALNO',
header: '封号',
width: 65
}, {
sortable: true,
dataIndex: 'PKGS',
header: '件数',
width: 60
}, {
dataIndex: 'KINDPKGS',
header: '包装',
width: 70
}, {
dataIndex: 'KGS',
header: '重量',
width: 60
}, {
dataIndex: 'CBM',
header: '尺码',
width: 60
}, {
dataIndex: 'TAREWEIGHT',
header: '箱皮重',
width: 60
}, {
dataIndex: 'REMARK',
header: '备注',
width: 150
}]
});
//#endregion
this.panelBodyCtn = new Ext.Panel({
title: '主票集装箱信息',
layout: "border",
height: 120,
region: 'south',
//margin: '5 10',
frame: true,
items: [this.gridListCtn]
});
//#region 分票集装箱明细
this.storeCodePackage = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CodePackageModel',
proxy: { url: '/CommMng/BasicDataRef/GetCodePackageList' }
});
this.storeCodePackage.load();
this.comboxKINDPKGS_CTN = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '件数包装',
store: this.storeCodePackage,
// forceSelection: true,
name: 'KINDPKGS',
valueField: 'PKGS',
displayField: 'PKGS'
});
this.comboxCTNNO = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeBodyListCtn,
name: 'CTNNO',
valueField: 'CTN_ID',
flex: 1,
displayField: 'CNTRNO'
});
this.storeBodyFenCtn = Ext.create('Ext.data.Store', {
model: 'MsOpSeaeDetail',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/Import/ImportTrade/GetFenCtnList',
reader: {
id: 'BSNO,CTN_ID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.gridListFenCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.gridListFenCtn = new Ext.grid.GridPanel({
store: this.storeBodyFenCtn,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.gridListFenCellEditing],
selType: 'cellmodel',
tbar: [{
text: '增加明细',
tooltip: '增加明细',
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddFenCtnDetailClick(button, event);
},
scope: this
}, '-', {
text: '删除明细',
tooltip: '删除明细',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelFenCtnDetailClick(button, event);
},
scope: this
}, '-', {
text: '保存明细',
tooltip: '保存明细',
iconCls: "btnsave",
handler: function (button, event) {
this.onPostFenCtnDetailClick(button, event);
},
scope: this
}],
columns: [{
sortable: true,
dataIndex: 'GID',
header: '编号',
hidden: true,
width: 0
}, {
sortable: true,
dataIndex: 'BSNO',
header: '业务编号',
hidden: true,
width: 0
}, {
dataIndex: 'CTN_ID',
header: '箱号',
width: 100,
editor: this.comboxCTNNO,
renderer: function (value, p, record) {
return record.data.CNTRNO;
},
}, {
dataIndex: 'CTNALL',
header: '箱型',
width: 48
}, {
dataIndex: 'SEALNO',
header: '封号',
width: 65
}, {
sortable: true,
dataIndex: 'PKGS',
header: '件数',
width: 60,
editor: {
xtype: 'numberfield',
allowBlank: false,
selectOnFocus: true
}
}, {
dataIndex: 'KINDPKGS',
header: '包装',
width: 70,
editor: this.comboxKINDPKGS_CTN
}, {
dataIndex: 'KGS',
header: '重量',
width: 60,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}, {
dataIndex: 'CBM',
header: '尺码',
width: 60,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}, {
dataIndex: 'REMARK',
header: '备注',
width: 150
}]
});
this.panelBodyFenCtn = new Ext.Panel({
// title: '分票装箱信息',
layout: "border",
region: 'center',
//margin: '5 10',
frame: true,
items: [this.gridListFenCtn]
});
this.gridListFenCtn.on('edit', function (editor, e, eOpts) {
this.gridListFenAfterEdit(editor, e, eOpts);
}, this);
//#endregion
//#region 合计列表
this.SumField = [
{ name: 'NOBILL', type: 'number' },
{ name: 'KGS', type: 'number' },
{ name: 'PKGS', type: 'number' },
{ name: 'CBM', type: 'number' }
];
this.storeSumList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
fields: this.SumField,
remoteSort: true,
proxy: {
type: 'ajax',
url: '/Import/ImportTrade/GetDataListSum',
reader: {
id: '',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.girdcolumsSum = [{
sortable: true,
dataIndex: 'NOBILL',
header: '票数',
align: 'right',
width: 60
}, {
sortable: true,
dataIndex: 'PKGS',
header: '件数',
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '<SPAN style="COLOR: red">' + lsValue + '</SPAN>'; } } else { return value; } } catch (e) { return value; } return value; },
align: 'right',
width: 80
}, {
sortable: true,
dataIndex: 'KGS',
header: '毛重',
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '<SPAN style="COLOR: red">' + lsValue + '</SPAN>'; } } else { return value; } } catch (e) { return value; } return value; },
align: 'right',
width: 80
}, {
sortable: true,
dataIndex: 'CBM',
header: '尺码',
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '<SPAN style="COLOR: red">' + lsValue + '</SPAN>'; } } else { return value; } } catch (e) { return value; } return value; },
align: 'right',
width: 60
}
];
this.gridListSum = new Ext.grid.GridPanel({
store: this.storeSumList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
columns: this.girdcolumsSum
});
this.panelSum = new Ext.Panel({
title: '分票合计',
layout: "border",
width: 300,
region: 'west',
margin: '0 0',
frame: true,
items: [this.gridListSum]
});
//#endregion
this.panelBodysouth = new Ext.Panel({
layout: "border",
height: 160,
region: 'south',
//margin: '5 10',
frame: true,
items: [this.panelSum,this.panelBodyFenCtn]
});
this.panelAddService = new Ext.Panel({
layout: "border",
region: 'west',
title: '拼箱主票',
width: 550,
margin: '2 2',
items: [this.gridAddList, this.panelBodyCtn]
});
this.panelAddfen = new Ext.Panel({
layout: "border",
region: 'center',
title: '已配箱分票',
split: true,
margin: '2 2',
items: [this.gridAddFenList, this.panelBodysouth]
});
this.paneladddetail = new Ext.Panel({
layout: "border",
region: 'center',
// height: 400,
items: [this.panelAddService, this.panelAddfen
]
});
this.paneladd = new Ext.Panel({
layout: "border",
height: 500,
region: "north",
items: [
this.formSearch2, this.paneladddetail
]
});
//#endregion 明细表
//#region 布局
//控件布局
Ext.apply(this, {
items: [this.paneladd, this.paneldetail]
});
//#endregion
//绑定查询窗体
this.ParentWin = window.parent.opener;
//初始化数据
this.InitData();
//绑定事件
this.storeBodyList.on('beforeload', function (store) {
var sql = this.getCondition();
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.getCondition2();
Ext.apply(store.proxy.extraParams, { condition: sql });
}, this);
this.storeBodyAddList.on('load', function (store, records) {
if (store.getCount() > 0) {
this.gridAddList.getSelectionModel().select(0);
} else {
this.storeAddFenList.removeAll();
_thisfenadd.BsNo = '*';
}
}, this);
this.gridAddList.getSelectionModel().on('select', function (model, record, index) {
_thisfenadd.BsNo = record.data.BSNO;
var sql = "";
sql = " MASTERNO='" + _thisfenadd.BsNo + "' AND BSNO<>MASTERNO";
this.storeAddFenList.load({ params: { condition: sql} });
this.storeSumList.load({ params: { condition: sql} });
this.storeBodyListCtn.load({ params: { condition: " BSNO='" + _thisfenadd.BsNo + "'"} });
}, this);
this.gridAddFenList.getSelectionModel().on('select', function (model, record, index) {
var drmodify = this.storeBodyFenCtn.getModifiedRecords();
if (drmodify.length != 0)
_thisfenadd.onPostFenCtnDetailClick();
_thisfenadd.FenBsNo=record.data.BSNO;
var sql = "";
sql = " f.BSNO='"+record.data.BSNO+"'";
this.storeBodyFenCtn.load({ params: { condition: sql} });
}, this);
this.storeAddFenList.on('beforeload', function (store) {
var sql = "";
sql = " MASTERNO='" + _thisfenadd.BsNo + "' AND BSNO<>MASTERNO";
Ext.apply(store.proxy.extraParams, { condition: sql });
}, this);
this.storeBodyFenCtn.on('beforeload', function (store) {
var sql = " f.BSNO='" +_thisfenadd.FenBsNo + "'";
Ext.apply(store.proxy.extraParams, { condition: sql });
}, this);
}, //end initUIComponents
InitData: function () {
this.onRefreshClick();
this.onRefresh2Click();
}, //end InitData
onAddClick: function (button, event) {
this.addBill();
},
onDeleteClick: function (button, event) {
this.deleteBill();
}, //end onAddDetailClick
addBill: function () {
if (_thisfenadd.BsNo=='*') {
Ext.Msg.show({ title: '提示', msg: '请选择要添加分票的拼箱主票!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
};
var selectedRecords = this.gridList.selModel.getSelection();
if (selectedRecords.length == 0) {
Ext.Msg.show({ title: '提示', msg: '没有选择要添加的业务!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
};
var bodyAddDatas = [];
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
bodyAddDatas.push(rec);
}
var jsonbodyAddDatas = ConvertRecordsToJsonAll(bodyAddDatas);
_thisfenadd = this;
var ctnid="";
var selections = this.gridListFenCtn.getSelectionModel().getSelection();
if (selections.length == 0) {
} else {
var record = selections[0];
ctnid=record.data.CTN_ID;
}
Ext.Ajax.request({
waitMsg: '正在添加数据...',
url: '/Import/ImportTrade/AddFenAdd',
params: {
bsno: _thisfenadd.BsNo,
data: jsonbodyAddDatas,
ctnid:ctnid
},
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 {
_thisfenadd.onRefreshClick();
var sql = " MASTERNO='" + _thisfenadd.BsNo + "' AND BSNO<>MASTERNO";
this.storeAddFenList.load({ params: { condition: sql} });
this.storeSumList.load({ params: { condition: sql} });
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
},
deleteBill: function () {
var selectedRecords = this.gridAddFenList.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];
bodyAddDatas.push(rec);
}
var jsonbodyAddDatas = ConvertRecordsToJsonAll(bodyAddDatas);
var sql = this.BillSql;
_thisfenadd = this;
Ext.Ajax.request({
waitMsg: '正在处理数据...',
url: '/Import/ImportTrade/CancelFenAdd',
params: {
data: jsonbodyAddDatas
},
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 {
_thisfenadd.onRefreshClick();
var sql = " MASTERNO='" + _thisfenadd.BsNo + "' AND BSNO<>MASTERNO";
this.storeAddFenList.load({ params: { condition: sql} });
this.storeSumList.load({ params: { condition: sql} });
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
},
//#region 分票集装箱操作
gridListFenAfterEdit: function (editor, e, eOpts) {
if (e.value == e.originalValue) return;
if (e.field == 'CTN_ID') {
var selectrecords = DsStoreQueryBy(this.storeBodyListCtn, 'CTN_ID', e.value);
if (selectrecords.getCount() > 0) {
var selectdata = selectrecords.getAt(0).data;
e.record.set('CTNALL', selectdata.CTNALL);
e.record.set('CNTRNO', selectdata.CNTRNO);
e.record.set('SEALNO', selectdata.SEALNO);
} else {
e.record.set('CTNALL', '');
e.record.set('CNTRNO', '');
e.record.set('SEALNO', '');
}
}
},
onAddFenCtnDetailClick: function (button, event) {
var allow = this.getAllowOperationDetail();
if (allow == false) {
return;
}
if (this.storeBodyListCtn.getCount() == 0) {
Ext.Msg.show({ title: '提示', msg: '主票不存在集装箱信息,请先维护主票集装箱信息!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var recordctn =this.storeBodyListCtn.getAt(0);
if (this.storeBodyAddList.getCount() == 0) {
Ext.Msg.show({ title: '提示', msg: '不存在分票信息,不能添加分票集装箱!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var selections = this.gridAddList.getSelectionModel().getSelection();
if (selections.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择要添加集装箱信息的分票!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var record = selections[0];
var record = Ext.create('MsOpSeaeDetail', {
GID:NewGuid(),
CTN_ID:recordctn.data.CTN_ID,
MASTERNO:'*',
BSNO: record.data.BSNO,
CTNCODE:0,
CTNALL: recordctn.data.CTNALL,
CNTRNO:recordctn.data.CNTRNO,
SEALNO:recordctn.data.SEALNO,
PKGS:record.data.PKGS,
KINDPKGS:record.data.KINDPKGS,
KGS:record.data.KGS,
TAREWEIGHT: 0,
CBM: record.data.CBM,
REMARK: ''
});
this.storeBodyFenCtn.add(record);
var n = this.storeBodyFenCtn.getCount();
this.gridListFenCellEditing.startEditByPosition({ row: n - 1, column: 3 });
},
onPostFenCtnDetailClick: function (button, event) {
var bodyDatas = [];
var i;
for (i = 0; i < this.storeBodyFenCtn.getCount(); i += 1) {
var memberyf = this.storeBodyFenCtn.getAt(i);
bodyDatas.push(memberyf);
};
var jsonBody = ConvertRecordsToJsonAll(bodyDatas);
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Import/ImportTrade/SaveFenCtn',
scope: this,
params: {
bsno: _thisfenadd.BsNo,
fenbody: jsonBody
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
for (var i = 0; i < this.storeBodyFenCtn.getCount(); i += 1) {
var member = this.storeBodyFenCtn.getAt(i);
member.set("MASTERNO", _thisfenadd.BsNo);
member.commit();
}
} 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
onDelFenCtnDetailClick: function (button, event) {
var allow = this.getAllowOperationDetail();
if (allow == false) {
return;
}
var selectedRecords = this.gridListFenCtn.selModel.getSelection();
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.data.MASTERNO == "" || rec.data.MASTERNO == "*")//如果是新增但没有保存的数据,没有必要提交到后台
{
this.storeBodyFenCtn.remove(selectedRecords[i]);
}
else {
Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/Import/ImportTrade/DeleteFenCtn',
params: {
data: Ext.JSON.encode(rec.data)
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.storeBodyFenCtn.remove(rec);
Ext.Msg.show({ title: '提示', msg: jsonresult.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
}
else {
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
}
},
failure: function (response, options) {
Ext.Msg.show({ title: '警告', msg: '服务器响应出错,请重试', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
},
scope: this
}); //end Ext.Ajax.request
}
}, this);
}
//this.storeBodyList.remove(selectedRecords[i]);
}
},
//#endregion
onRefreshClick: function (button, event) {
var sql = this.getCondition();
this.storeBodyList.load({ params: { start: 0, limit: this.PageSize, sort: '', condition: sql} });
},
onRefresh2Click: function (button, event) {
var sql = this.getCondition2();
this.storeBodyAddList.load({ params: { start: 0, limit: this.PageSize, sort: '', condition: sql} });
this.storeSumList.load({ params: { condition: sql} });
},
onClearSql: function () {
var form = this.formSearch.getForm();
form.reset();
},
onClearSql2: function () {
var form = this.formSearch2.getForm();
form.reset();
},
getCondition: function () {
var form = this.formSearch.getForm();
if (!form.isValid()) {
Ext.Msg.alert('提示', '查询条件赋值错误,请检查。');
return '';
}
var sql = " B.BLTYPE='拼箱分票' AND BSNO=MASTERNO ";
var customNo = form.findField('MBLNO').getValue();
sql = sql + getAndConSql(sql, customNo, " (B.CUSTNO like '%" + customNo + "%' or B.MBLNO like '%" + customNo + "%' or B.HBLNO like '%" + customNo + "%' )");
var expDateBgn = form.findField('ExpDateBgn').getRawValue();
sql = sql + getAndConSql(sql, expDateBgn, "B.ETD >='" + expDateBgn + "'");
var expDateEnd = form.findField('ExpDateEnd').getRawValue();
sql = sql + getAndConSql(sql, expDateEnd, "B.ETD <='" + expDateEnd + "'");
//船名
var VESSEL = form.findField('VESSEL').getValue();
sql = sql + getAndConSql(sql, VESSEL, "B.VESSEL like '%" + VESSEL + "%'");
//航次
var VOYNO = form.findField('VOYNO').getValue();
sql = sql + getAndConSql(sql, VOYNO, "B.VOYNO like '%" + VOYNO + "%'");
return sql;
},
getCondition2: function () {
var form = this.formSearch2.getForm();
if (!form.isValid()) {
Ext.Msg.alert('提示', '查询条件赋值错误,请检查。');
return '';
}
var sql = " B.BLTYPE='拼箱主票' AND B.BSSTATUS<>1 ";
var customNo = form.findField('MBLNO2').getValue();
sql = sql + getAndConSql(sql, customNo, " (B.CUSTNO like '%" + customNo + "%' or B.MBLNO like '%" + customNo + "%' or B.HBLNO like '%" + customNo + "%' )");
var expDateBgn = form.findField('ExpDateBgn2').getRawValue();
sql = sql + getAndConSql(sql, expDateBgn, "B.ETD >='" + expDateBgn + "'");
var expDateEnd = form.findField('ExpDateEnd2').getRawValue();
sql = sql + getAndConSql(sql, expDateEnd, "B.ETD <='" + expDateEnd + "'");
//船名
var VESSEL = form.findField('VESSEL2').getValue();
sql = sql + getAndConSql(sql, VESSEL, "B.VESSEL like '%" + VESSEL + "%'");
//航次
var VOYNO = form.findField('VOYNO2').getValue();
sql = sql + getAndConSql(sql, VOYNO, "B.VOYNO like '%" + VOYNO + "%'");
return sql;
},
// #region 根据权限和状态判断是否允许修改
GetEditStatus: function () {
var canedit = false;
this.formEdit.getForm().findField('BILLSTATUS').setDisabled(false);
var bsStatus = this.formEdit.getForm().findField('BILLSTATUS').getValue();
var op = this.formEdit.getForm().findField('APPLICANTNAME').getValue();
this.formEdit.getForm().findField('BILLSTATUS').setDisabled(true);
_thisfenadd = this;
this.StoreOpRange.load({ params: { optype: "modPaySettleAppList" },
callback: function (r, options, success) {
if (success) {
if (r.length != 0) {
var records = DsStoreQueryBy(_thisfenadd.StoreOpRange, 'OPID', op);
if ((bsStatus != 1) && (bsStatus != 6)) {
this.setSaveBtnStatus(false);
} else {
_thisfenadd.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();
}
}
});