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.

470 lines
14 KiB
JavaScript

Ext.namespace('Shipping');
Shipping.FeeTemplateCtnApplyAdd = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.FeeTemplateCtnApplyAdd.superclass.constructor.call(this);
};
Ext.extend(Shipping.FeeTemplateCtnApplyAdd, Ext.Panel, {
PageSize: 100,
ParentWin: null,
feeType: 0,
feeTypeRef: '',
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
MainEditRecord: null,
storeBodyCostList: null,
StoreCurr: null,
EditRecord: null,
stroplb: '',
strGID: '',
initUIComponents: function () {
Ext.define('MsOpCtnApplyCostItems', {
extend: 'Ext.data.Model',
idProperty: 'GID',
fields: [
{ name: 'GID', type: 'string' },
{ name: 'LINKGID', type: 'string' },
{ name: 'ITEMSNO', type: 'number' },
{ name: 'CUSTOMERNAME', type: 'string' },
{ name: 'FEENAME', type: 'string' },
{ name: 'UNIT', type: 'string' },
{ name: 'UNITPRICE', type: 'number' },
{ name: 'CURRENCY', type: 'string' },
{ name: 'QUANTITY', type: 'number' },
{ name: 'AMOUNT', type: 'number' },
{ name: 'EXCHANGERATE', type: 'number' },
{ name: 'PRICETYPE', type: 'string' },
{ name: 'REMARKS', type: 'string' },
{ name: 'GOODSNAME', type: 'string' },
{ name: 'INPUTBY', type: 'string' },
{ name: 'INPUTBYREF', type: 'string' },
{ name: 'INPUTTIME', type: 'string' },
{ name: 'AUDITSTATUS', type: 'string' },
{ name: 'AUDITBY', type: 'string' },
{ name: 'AUDITTIME', type: 'string' },
{ name: 'AUDITRESULT', type: 'string' }
]
});
this.StoreDateCurr = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsFeeCurr',
proxy: { url: '/MvcShipping/MsChFee/GetFeeDateCurrList' }
});
this.StoreDateCurr.load();
this.StoreCurr = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsFeeCurr',
proxy: { url: '/MvcShipping/MsChFee/GetFeeCurrList' }
});
this.StoreCurr.load({ params: { condition: "" } });
this.DEFORDERCUST = "";
//定义数据集
this.storeList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'MsCodeFeeTemplate',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsCodeFeeTemplateCtnApply/GetDataList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//#region 主grid
this.gridListCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
this.gridList = new Ext.grid.GridPanel({
store: this.storeList,
enableHdMenu: false,
region: 'north',
height: 350,
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
selModel: this.gridListCheckBoxModel,
columns: [{
sortable: true,
dataIndex: 'NAME',
header: '模板名称',
width: 130
}, {
sortable: true,
dataIndex: 'DESCRIPTION',
header: '模板说明',
width: 160
}, {
sortable: true,
dataIndex: 'REMARK',
header: '备注',
width: 220
}
],
// paging bar on the bottom
bbar: Ext.create('Ext.PagingToolbar', {
store: this.storeList,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
})
});
//#endregion
//#region 固定费用明细表
//#region 费用表
//明细表-数据集
this.storeBodyChFee = Ext.create('Ext.data.Store', {
model: 'MsCodeFeeTemplateCtnApplyDetail',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsCodeFeeTemplateCtnApply/GetBodyList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//明细表表格
// this.feeGridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
_this = this;
this.gridListChFee = new Ext.grid.GridPanel({
store: this.storeBodyChFee,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
// selModel: this.feeGridCheckBoxModel,
selType: 'cellmodel',
columns: [{
sortable: true,
dataIndex: 'GID',
header: Zi.LAN.GID, //'GID',
hidden: true,
width: 100
}, {
sortable: true,
dataIndex: 'TEMPLATEID',
header: Zi.LAN.TEMPLATEID, //'TEMPLATEID',
hidden: true,
width: 100
}, {
sortable: true,
dataIndex: 'FEENAME',
header: '费用名称', //'费用名称',
width: 140
}, {
sortable: true,
dataIndex: 'CUSTOMERNAME',
header: '费用对象', //'备注',
width: 150
}, {
sortable: true,
dataIndex: 'CURRENCY',
header: '币别', //'币别',
width: 100
}, {
sortable: true,
dataIndex: 'UNIT',
header: '标准', //'标准',
width: 80
}, {
sortable: true,
dataIndex: 'UNITPRICE',
header: '单价', //'单价',
align: 'right',
width: 80
},{
sortable: true,
dataIndex: 'SORT',
header: '排序', //'排序',
align: 'right',
width: 80
}, {
sortable: true,
dataIndex: 'REMARK',
header: '备注', //'备注',
width: 150
}
],
// paging bar on the bottom
bbar: [{
xtype: "button",
id: "button_add",
iconCls: "btnadd",
text: "引入费用",
handler: function (button, event) {
_this.onAddDetailClick(button, event);
}
},
'-',
{
xtype: "button",
id: "button_close",
text: "取消退出",
handler: function (button, event) {
window.close();
}
}
]
});
//#endregion
//#region formSearch
//#region formSearch枚举参照相关
//#endregion
this.formSearch = 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: '模板名称',
name: 'NAME'
}, {
fieldLabel: '模板说明',
name: 'DESCRIPTION'
}, {
xtype: 'button',
width: 90,
text: "执行查询",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onRefreshClick(button, event);
},
scope: this
}
]
}]
}]
});
//#endregion formSearch
//#region 按钮ToolBar
//#endregion
//#region 布局
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 55,
items: [this.formSearch]
});
this.panelBodyChFee = new Ext.Panel({
title: '费用明细',
layout: "border",
region: 'center',
margin: '5 10',
items: [this.gridListChFee]
});
this.panelFee = new Ext.Panel({
layout: "border",
region: "center",
items: [
this.panelBodyChFee
]
});
Ext.apply(this, {
items: [this.panelTop, this.gridList, this.panelFee]
});
//#endregion
this.parentWin = window.parent.opener._this;
if (this.parentWin) {
this.storeBodyCostList = this.parentWin.storeBodyCostList;
this.MainEditRecord = this.parentWin.editRecord;
}
//#region 事件绑定
this.storeList.on('beforeload', function (store) {
var sql = this.getCondition();
Ext.apply(store.proxy.extraParams, { condition: sql });
}, this);
this.storeList.on('load', function (store, records) {
if (store.getCount() > 0) {
this.gridList.getSelectionModel().select(0);
//this.gridListCheckBoxModel.selectAll();
}
}, this);
this.gridList.getSelectionModel().on('select', function (model, record, index) {
//alert(record.data.BillNo);
var bsno = record.data.GID;
this.strGID = record.data.GID;
var sql = " TEMPLATEID='" + bsno + "'";
this.storeBodyChFee.load({ params: { condition: sql} });
}, this);
//#endregion
//#region 自动刷新(已经提交但是尚未审核的业务,哪怕一票货中有一笔费用没审核也显示)
this.onAutoRefresh();
//#endregion
// this.SetBtnRight();
}, //end initUIComponents
onAutoRefresh: function () {
var sql = '';
this.storeList.load({
params: { start: 0, limit: this.PageSize, sort: '', condition: sql },
waitMsg: "正在查询数据...",
scope: this
});
},
onRefreshClick: function (button, event) {
var sql = this.getCondition();
this.storeList.load({
params: { start: 0, limit: this.PageSize, sort: '', condition: sql },
waitMsg: "正在查询数据...",
scope: this
});
},
onAddDetailClick: function (button, event) {
for (i = 0; i < this.storeBodyChFee.getCount(); i += 1) {
var memberyf = this.storeBodyChFee.getAt(i);
var newsort = this.storeBodyCostList.getCount() + 1;
var QUANTITY = 1;
var AMOUNT = memberyf.data.UNITPRICE;
if (this.MainEditRecord.get('CTNALL') == memberyf.data.UNIT) {
QUANTITY = this.MainEditRecord.get('CTNNUM');
AMOUNT = Mul(memberyf.data.UNITPRICE, QUANTITY);
}
var exchange = this.calExchange(memberyf.data.CURRENCY);
var record = Ext.create('MsOpCtnApplyCostItems', {
GID: '*',
LINKGID: '*',
PRICETYPE: '0',
ITEMSNO: newsort,
CUSTOMERNAME: memberyf.data.CUSTOMERNAME,
FEENAME: memberyf.data.FEENAME,
UNIT: memberyf.data.UNIT,
UNITPRICE: memberyf.data.UNITPRICE,
QUANTITY: QUANTITY,
AMOUNT: AMOUNT,
CURRENCY: memberyf.data.CURRENCY,
EXCHANGERATE: exchange,
REMARKS: memberyf.data.REMARKS
});
record.id = NewGuid();
record.internalId = NewGuid();
this.storeBodyCostList.add(record);
};
_this = this;
window.closeAction = 'destroy';
window.close();
},
calExchange: function (curr) {
var result = 1;
if (curr != 'RMB') {
var FFrecords = DsStoreQueryBy(this.StoreDateCurr, 'CURR', curr);
if (FFrecords.getCount() > 0) {
var ffdata = FFrecords.getAt(0).data;
result = ffdata.DEFRATE;
} else {
var DFrecords = DsStoreQueryBy(this.StoreCurr, 'CURR', curr);
if (DFrecords.getCount() > 0) {
var dfdata = DFrecords.getAt(0).data;
result = dfdata.DEFRATE;
} else {
}
}
}
return result;
},
getCondition: function () {
var form = this.formSearch.getForm();
if (!form.isValid()) {
Ext.Msg.alert('提示', '查询条件赋值错误,请检查。');
return '';
}
var sql = '';
var custName = form.findField('NAME').getValue();
sql = sql + getAndConSql(sql, custName, " Name like '%" + custName + "%'");
var mblNo = form.findField('DESCRIPTION').getValue();
sql = sql + getAndConSql(sql, mblNo, " Description like '%" + mblNo + "%'");
return sql;
}
});