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/MvcShipping/Viewsjs/MsOpSubSeaOrder/MsCompanyOrderFeeEdit.js

508 lines
15 KiB
JavaScript

3 years ago
Ext.namespace('Shipping');
Shipping.MsCompanyOrderFeeEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsCompanyOrderFeeEdit.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsCompanyOrderFeeEdit, Ext.Panel, {
ParentWin: null,
OpStatus: 'add',
StoreList: null,
EditRecord: null,
Editdata: null,
isAudit: null,
accdate: null,
seaeop: "",
seaecustservice: "",
reason: "",
BillType: null,
OrType: null,
initUIComponents: function () {
this.serialNo = 0;
//this.bodyDel = [];
this.itemindex = 1;
this.StoreFeeAGENTFEE = Ext.create('Ext.data.Store', {
fields: ['CODE','AGENTFEE']
});
this.StoreFeeAGENTFEE.add({ "CODE": 1, "AGENTFEE": "是" });
this.StoreFeeAGENTFEE.add({ "CODE": 0, "AGENTFEE": "否" });
this.comboxAGENTFEE = Ext.create('DsExt.ux.RefTableCombox', {
store: this.StoreFeeAGENTFEE,
forceSelection: true,
name: 'AGENTFEE',
valueField: 'CODE',
displayField: 'AGENTFEE'
});
this.storeFeeNameRef = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.FeeTypeRefModel',
proxy: { url: '/MvcShipping/MsChFee/GetFeeTypeRefList' }
});
this.storeFeeNameRef.load({ params: { condition: ""} });
this.comboxFeeNameRef = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeFeeNameRef,
forceSelection: true,
name: 'FEENAME',
valueField: 'Name',
displayField: 'CodeAndName'
});
this.StoreCurr = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsFeeCurr',
proxy: { url: '/MvcShipping/MsChFee/GetFeeCurrList' }
});
this.StoreCurr.load({ params: { condition: ""} });
this.comboxCurr = Ext.create('DsExt.ux.RefTableCombox', {
store: this.StoreCurr,
forceSelection: true,
name: 'CURRENCY',
valueField: 'CURR',
displayField: 'CURR'
});
this.storeFeeUnit = Ext.create('DsExt.ux.RefTableStore', {
fields: ['UNIT'],
proxy: { url: '/MvcShipping/MsCodeFeeTemplate/GetFeeUnit' }
});
this.storeFeeUnit.load({ params: { condition: ""} });
this.comboxFeeUnit = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeFeeUnit,
name: 'UNIT',
valueField: 'UNIT',
displayField: 'UNIT'
});
this.storeFee = Ext.create('Ext.data.Store', {
model: 'MsCompanyOrderFee',
remoteSort: false,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsOpSubSeaOrder/GetCompanyFeeList',
reader: {
id: 'GId',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.cellEditingDrChFee = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
_this = this;
this.gridFee = new Ext.grid.GridPanel({
store: this.storeFee,
enableHdMenu: false,
region: "center",
height: 280,
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.cellEditingDrChFee],
selType: 'cellmodel',
tbar: [{
text: '保存明细',
tooltip: '保存明细',
id: "btnadddetail",
iconCls: "btnsave",
handler: function (button, event) {
this.onSaveDetailClick(button, event);
},
scope: this
}, '-', {
text: '增加明细',
tooltip: '增加明细',
id: "btnaddafeedetail",
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddDetailClick(button, event);
},
scope: this
}, '-', {
text: '删除明细',
tooltip: '删除明细',
id: "btndelafeedetail",
iconCls: "btndeletedetail",
handler: function (button, event) {
this.deleteDetail(button, event);
},
scope: this
}],
columns: [{
sortable: true,
dataIndex: 'GID',
header: '惟一编号',
hidden: true,
width: 160
}, {
sortable: true,
dataIndex: 'COMPANYID',
header: 'COMPANYID',
hidden: true,
width: 160
}, {
sortable: true,
dataIndex: 'FEENAME',
header: '费用名称',
editor: this.comboxFeeNameRef,
width: 100
}, {
sortable: true,
dataIndex: 'UNITPRICE',
header: '单价',
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
selectOnFocus: true,
hideTrigger: true,
mouseWheelEnabled: false,
enableKeyEvents: true
},
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
try {
var lsValue = usMoney(value, 2, '', false);
if (lsValue != "NaN") {
value = lsValue; if (parseFloat(lsValue) < 0) {
return '<SPAN style="COLOR: red">' + lsValue + '</SPAN>';
}
}
else {
return value;
}
}
catch (e) {
return value;
}
return value;
},
align: 'right',
width: 80
}, {
sortable: true,
dataIndex: 'CURRENCY',
header: '币别',
editor: this.comboxCurr,
width: 60
}, {
sortable: true,
dataIndex: 'UNIT',
header: '标准',
editor: this.comboxFeeUnit,
width: 80
}, {
sortable: true,
dataIndex: 'EXCHANGERATE',
header: '汇率',
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
selectOnFocus: true,
hideTrigger: true,
mouseWheelEnabled: false,
enableKeyEvents: true
},
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '<SPAN style="COLOR: red">' + lsValue + '</SPAN>'; } } else { return value; } } catch (e) { return value; } return value; },
align: 'right',
width: 60
}, {
sortable: true,
dataIndex: 'SORT',
header: '排序',
editor: {
xtype: 'numberfield',
keyNavEnabled: false,
selectOnFocus: true,
hideTrigger: true,
mouseWheelEnabled: false,
enableKeyEvents: true
},
align: 'right',
width: 80
}, {
sortable: true,
dataIndex: 'AGENTFEE',
header: '是否代理费用',
editor: this.comboxAGENTFEE,
align: 'right',
width: 80
}
]
});
this.gridFee.on('edit', function (editor, e, eOpts) {
this.gridListChFeeAfterEdit(editor, e, eOpts);
}, this);
// this.gridFee.on('beforeedit', function (editor, e) {
// return this.cellEditingChFeeBeforeEdit(editor, e);
// }, this);
//#region 框架结构
this.panelpage = new Ext.Panel({
title: '模板明细',
layout: "border",
region: 'center',
animate: true,
autoScroll: true,
// containerScroll: true,
frame: false,
items: [this.gridFee]
});
this.panelSeae = new Ext.Panel({
id: 'pnlmodSeaeOrderInfo',
layout: "border",
region: 'center',
animate: true,
autoScroll: true,
frame: false,
//closable:true,
items: [this.panelpage]
});
Ext.apply(this, {
items: [this.panelSeae]
});
//#endregion
//#region 其他
this.InitData();
//#endregion
}, //end initUIComponents
//#region 加载事件
InitData: function () {
this.storeFee.load({ params: { condition:''} });
}, //end InitData
//#endregion
//#region 保存
onAddDetailClick: function (button, event) {
var newSerialno = 0;
store = this.storeFee;
var record = Ext.create('MsCompanyOrderFee', {
GID: '',
FEENAME: "",
UNITPRICE: 0,
SORT: 0,
EXCHANGERATE: 1,
CURRENCY: "",
UNIT: "",
AGENTFEE: 1
});
store.add(record);
this.cellEditingDrChFee.startEditByPosition({ row: n - 1, column: 1 });
},
deleteDetail: function (button, event) {
var selectedRecords = this.gridFee.selModel.getSelection();
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
this.storeFee.remove(rec);
}
},
onSaveDetailClick: function (button, event) {
var feedatas = [];
for (var i = 0; i < this.storeFee.getCount(); i += 1) {
var member = this.storeFee.getAt(i);
feedatas.push(member);
}
//
var jsonfee = ConvertRecordsToJsonAll(feedatas);
//
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsOpSubSeaOrder/SaveCompanyFee',
scope: this,
params: {
fee: jsonfee
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
for (var j = 0; j < this.storeFee.getCount(); j += 1) {
var memberbody = this.storeFee.getAt(j);
memberbody.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
//#endregion
getToMonth: function () {
var now = new Date();
var year = now.getFullYear(); //年
var month = now.getMonth() + 1; //月
var clock = year + "-";
if (month < 10)
clock = clock + "0" + month;
else
clock = clock + month;
return (clock);
},
//#region 编辑时按钮等的状态
GetStringNum: function (str) {
var num = 0;
if (str == null || str == '') return num;
if (str.length == 0) return num;
var if_find = false;
var str_num = '';
for (var i = 0; i < str.length; i += 1) {
var member = str.substr(i, 1);
if ((member == '0') || (member == '1') || (member == '2') || (member == '3')
|| (member == '4') || (member == '5') || (member == '6') || (member == '7')
|| (member == '8') || (member == '9') || (member == '.') || (member == '-')) {
if (!if_find) {
str_num = str_num + member;
}
} else {
if_find = true;
}
}
return str_num;
},
setBtnStatus: function (enable) {
var btnESave = Ext.getCmp('btnESave');
var btnESaveAndClose = Ext.getCmp('btnESaveAndClose');
var btnESaveAndNew = Ext.getCmp('btnESaveAndNew');
if (enable == 2) {
btnESave.setVisible(false); ;
btnESaveAndClose.setVisible(false);
btnESaveAndNew.setVisible(false);
} else {
btnESave.setVisible(true); ;
btnESaveAndClose.setVisible(true);
btnESaveAndNew.setVisible(true);
}
},
setSaveBtnStatus: function (enable) {
var btnESave = Ext.getCmp('btnESave');
var btnESaveAndClose = Ext.getCmp('btnESaveAndClose');
var btnESaveAndNew = Ext.getCmp('btnESaveAndNew');
if (enable) {
btnESave.enable();
btnESaveAndClose.enable();
btnESaveAndNew.enable();
} else {
btnESave.disable();
btnESaveAndClose.disable();
btnESaveAndNew.disable();
}
},
//#endregion
//#region 打印
Print: function () {
/*
var basicForm = this.formEdit.getForm();
var billNo = basicForm.findField('BillNo').value;
if (billNo == '*' || billNo == '') {
Ext.Msg.show({ title: '错误', msg: '单据还没有保存,请保存后再打印', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var printType = 'MSWLBULKBS';
var sql1 = "SET LANGUAGE 'us_english' SELECT * FROM tMsWlBulkHead WHERE BillNo = '" + billNo + "'";
var sql2 = "";
var sql3 = "";
var sql4 = "";
var sql5 = "";
var sql6 = "";
PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6);
*/
}
//#endregion
});