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/TruckMng/Viewsjs/MsWl_Port/CtnEdit.js

1063 lines
36 KiB
JavaScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

///<reference path="../../../../Views/../TruckMng/Scripts/vswd-ext_2.0.2.js" />
Ext.namespace('DsTruck');
DsTruck.CtnEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.DsTruck.CtnEdit.superclass.constructor.call(this);
};
Date.prototype.format = function (format) {
var o = {
"M+": this.getMonth() + 1, //month
"d+": this.getDate(), //day
"h+": this.getHours(), //hour
"m+": this.getMinutes(), //minute
"s+": this.getSeconds(), //second
"q+": Math.floor((this.getMonth() + 3) / 3), //quarter
"S": this.getMilliseconds() //millisecond
}
if (/(y+)/.test(format)) format = format.replace(RegExp.$1,
(this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o) if (new RegExp("(" + k + ")").test(format))
format = format.replace(RegExp.$1,
RegExp.$1.length == 1 ? o[k] :
("00" + o[k]).substr(("" + o[k]).length));
return format;
}
var xhr = new XMLHttpRequest();
var currdate = new Date();
if (!xhr) {
//...其他生成xmlhttprequest方法
}
xhr.open("HEAD", location.href, true);
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
var datestr = xhr.getResponseHeader("Date");
currdate = new Date(datestr);
// alert(currdate.format('yyyy-MM-dd'));
}
}
xhr.send(null);
function getSaved() {
var feedirty = DsTruck.GetDirty(panelEdit.storeBodyChfee, panelEdit.storeBodyChfeeDel);
if (panelEdit.formEdit.getForm().isDirty()== true )
{
return true;
}
else return false;
}
Ext.extend(DsTruck.CtnEdit, Ext.Panel, {
parentWin: null,
OpStatus: 'add',
StoreList: null,
editRecord: null,
BXSTATUS: 1,
// parentfunction: null,
_First: true,
VISIBLERANGE: 0,
OPERATERANGE: 0,
WorkFlowName: "",
WorkFlowID: "",
BSNO: "",
initUIComponents: function () {
//this.feeSerialNo = 0;
this.CtnDel = [];
//this.PayBodyDel = [];
//#region 枚举参照相关(编辑form)
WorkFlowName = 'BaoxiaoMod';
Ext.define('BodyTypeMd', {
extend: 'Ext.data.Model',
fields: [
{ name: 'BODYTYPE', type: 'tmswl_port_ctn' },
{ name: 'BODYTYPE_REF', type: 'string' }
]
});
var BodyTypeData = [{ "BODYTYPE": "Ctn", "BODYTYPE_REF": "集装箱" },
{ "BODYTYPE": "Other", "BODYTYPE_REF": "杂项" },
{ "BODYTYPE": "RO", "BODYTYPE_REF": "滚装" },
{ "BODYTYPE": "MovCtn", "BODYTYPE_REF": "外部拖箱"}];
this.storeBodyType = Ext.create('Ext.data.Store', {
model: 'BodyTypeMd',
data: BodyTypeData
});
this.comboxBodyType = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: '业务类型',
forceSelection: true,
store: this.storeBodyType,
name: 'BODYTYPE',
valueField: 'BODYTYPE',
displayField: 'BODYTYPE_REF',
values: "Ctn"
});
this.storeTruckNo = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsWlBsHeadRefMsWlTruck',
proxy: { url: '/TruckMng/MsWlPc/GetTruckNoList' }
});
this.storeTruckNo.load({ params: { condition: " NativeAddr like '%码头%' "} });
this.comboxTruckNo = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '车牌号',
store: this.storeTruckNo,
name: 'TRUCKNO',
valueField: 'TruckNo',
displayField: 'WORKNOTruckNo',
listeners: {
change: function (field, newValue, oldValue) {
//this.tonAndTruckNoChange(field, newValue, oldValue);
},
scope: this
}
});
this.storeDrvName = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsWlBsHeadRefMsWlDriver',
proxy: { url: '/TruckMng/MsWlPc/GetDrvNameList' }
});
this.storeDrvName.load({ params: { condition: ""} });
this.comboxDrvName = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '司机',
store: this.storeDrvName,
name: 'DRVCODE',
valueField: 'DrvCode',
displayField: 'CodeAndName',
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (records.length > 0) {
//this.setDrvName(records[0].data.DrvCode);
}
}
}
});
//#endregion
this.storePrice = Ext.create('DsExt.ux.RefEnumStore', {});
this.storePrice.load({ params: { enumTypeId: 99043} });
//费用参数
/* this.comboxMainstate = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: '合同状态',
store: this.storeMainstate,
name: 'Mainstate'
//,value: '0'
});*/
//////////////////
//编辑form:formEdit
this.formEdit = Ext.widget('form', {
// layout: "border",
region: 'north',
frame: true,
bodyPadding: 1,
trackResetOnLoad: true,
fieldDefaults: {
margins: '1 1 1 1',
labelAlign: 'right',
flex: 1,
labelWidth: 90,
msgTarget: 'qtip'
//,split:true
},
//bodyStyle: 'background:#FFF',
items: [
{//fieldset 1
xtype: 'fieldset',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{//container_1
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '业务序列号',
// allowBlank: false,
readOnly: true,
name: 'GID'
}, this.comboxBodyType,
{
fieldLabel: '制单时间',
format: 'Y-m-d', id: "EXPDATE",
xtype: 'datefield',
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
name: 'EXPDATE',
listeners: {
change: function (field, eOpts) {
if (field.lastValue != "") {
var ACCDATE = (this.formEdit.getForm().findField('ACCDATE').getRawValue());
if (ACCDATE == "" || ACCDATE == null) {
_M = field.lastValue.getMonth() + 1;
var _M2 = "";
if (_M < 10) {
_M2 = "0" + _M;
} else {
_M2 = "" + _M;
}
_a = field.lastValue.getFullYear() + '-' + _M2;
this.formEdit.getForm().findField('ACCDATE').setValue(_a);
}
}
this.Cansearch = false;
},
scope: this
}
}, {
xtype: 'hiddenfield',
flex: 1
}
//this.comboxFEENAME,
/*{
fieldLabel: '时间戳',
name: 'TimeMark', flex: 0, hidden: true, margins: '0'
}*/
]
}, //container_1 end
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '会计月份',
// allowBlank: false,
//disabled: true,
name: 'ACCDATE'
}, {
fieldLabel: '应收',
name: 'Amount_1', id: "Amount_1",
flex: 1
}, {
fieldLabel: '应付',
name: 'Amount_2', id: "Amount_2",
flex: 1
}/*, {
xtype: 'hiddenfield',
flex: 1
}*/, {
fieldLabel: '时间戳',
name: 'TimeMark', flex: 1, hidden: true, margins: '0'
}, {
xtype: 'checkbox', flex: 1,
fieldLabel: '业务锁定',
name: 'Locked', readOnly: true
}
]
},
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '备注',
name: 'REMARK',
flex: 2
}
]
}
]
}
]
});
//////////////////////////////////
//明细 <<<< 收支费用明细 >>>>
//
/*
this.storeAccitems = Ext.create('DsExt.ux.RefTableStore', {
model: 'Accitemsmb',
proxy: { url: '/CommMng/BasicDataRef/GetAccitems' }
});
this.storeAccitems.load({ params: { condition: ""} });
*/
//数据集
this.storeCtn = Ext.create('Ext.data.Store', {
model: 'PortCtnmb',
remoteSort: false,
pruneModifiedRecords: true,
proxy: {
type: 'ajax',
url: '/TruckMng/MsWl_Port/GetCtn',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//表格
this.cellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.CBModel = Ext.create('Ext.selection.CheckboxModel');
Ext.grid.RowNumberer = Ext.extend(Ext.grid.RowNumberer, {
width: 50
});
this.formCtn = new Ext.grid.GridPanel({
store: this.storeCtn,
enableHdMenu: false,
region: 'center',
title: '集装箱',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
features: [{
ftype: 'summary'//Ext.grid.feature.Summary表格汇总特性
}],
plugins: [this.cellEditing],
selModel: this.CBModel,
selType: 'cellmodel',
tbar: [{
text: '增加明细', id: "add1",
tooltip: '增加明细',
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddCtnClick(button, event);
},
scope: this
}, '-', {
text: '删除明细', id: "del1",
tooltip: '删除明细',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelCtnClick(button, event);
},
scope: this
}],
columns: [
new Ext.grid.RowNumberer(),
{
sortable: true, hidden: true,
dataIndex: 'GID',
header: 'GID',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'LINKID',
header: 'LINKID',
width: 80
},
{
sortable: true,
dataIndex: 'DRVCODE',
header: '驾驶员姓名',
width: 80,
renderer: function (value, p, record) {
if (value == null || value == '') return '';
else return record.data.DRVNAME;
},
width: 80,
editor: this.comboxDrvName
},
{
sortable: true, hidden: true,
dataIndex: 'DRVNAME',
header: 'DRVNAME'
},
{
sortable: true,
dataIndex: 'Mobile',
header: '电话',
width: 80,
editor: {
xtype: 'textfield', //numberfield textfield
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'TRUCKNO',
header: '车号',
width: 80,
editor: this.comboxTruckNo
},
{
sortable: true,
dataIndex: 'Ctn20',
header: '20',
width: 90,
editor: {
xtype: 'numberfield', //numberfield textfield
selectOnFocus: true
},
summaryType: 'sum',
summaryRenderer: Ext.util.Format.numberRenderer('00.00')
},
{
sortable: true,
dataIndex: 'Ctn40',
header: '40',
width: 90,
editor: {
xtype: 'textfield', //numberfield
selectOnFocus: true
},
summaryType: 'sum',
summaryRenderer: Ext.util.Format.numberRenderer('00.00')
},
{
sortable: true,
dataIndex: 'Ctn45',
header: '45',
width: 90,
editor: {
xtype: 'numberfield', //numberfield textfield
selectOnFocus: true
},
summaryType: 'sum',
summaryRenderer: Ext.util.Format.numberRenderer('00.00')
},
{
sortable: true,
dataIndex: 'Mov',
header: '次数',
width: 90,
editor: {
xtype: 'numberfield', //numberfield textfield
selectOnFocus: true
},
summaryType: 'sum',
summaryRenderer: Ext.util.Format.numberRenderer('00.00')
},
{
sortable: true,
dataIndex: 'TEU',
header: 'TEU',
width: 100,
editor: {
xtype: 'numberfield', //numberfield textfield
selectOnFocus: true
},
summaryType: 'sum',
summaryRenderer: Ext.util.Format.numberRenderer('00.00')
},
{
sortable: true, hidden: true,
dataIndex: 'Price_1',
header: '小箱费率',
width: 80,
editor: {
xtype: 'numberfield', //numberfield textfield
selectOnFocus: true
}
},
{
sortable: true, hidden: true,
dataIndex: 'Price_2',
header: '大箱费率',
width: 80,
editor: {
xtype: 'numberfield', //numberfield textfield
selectOnFocus: true
}
},
{
sortable: true, //hidden: true,
dataIndex: 'AvrOil',
header: '油价',
width: 80,
editor: {
xtype: 'numberfield', //numberfield textfield
selectOnFocus: true
}
},
{
sortable: true, hidden: true,
dataIndex: 'Factor',
header: '系数',
width: 80,
editor: {
xtype: 'numberfield', //numberfield textfield
selectOnFocus: true
}
},
{
sortable: true, hidden: true,
dataIndex: 'Plus',
header: '尾数',
width: 80,
editor: {
xtype: 'numberfield', //numberfield textfield
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'Amount_1',
header: '应收(结算)',
width: 100,
editor: {
xtype: 'numberfield', //numberfield textfield
selectOnFocus: true
},
summaryType: 'sum',
summaryRenderer: Ext.util.Format.numberRenderer('00.00')
},
{
sortable: true,
dataIndex: 'Amount_2',
header: '应付(核算)',
width: 100,
editor: {
xtype: 'numberfield', //numberfield textfield
selectOnFocus: true
},
summaryType: 'sum',
summaryRenderer: Ext.util.Format.numberRenderer('00.00')
}]
});
//////////////////////////////////////////////明细<<<< 集装箱信息 >>>>结束
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
// id: "saveandclose",
text: "保存",
iconCls: "btnsave",
handler: function (button, event) {
this.Save('0');
},
scope: this
}, {
// id: "saveandclose",
text: "保存并关闭",
handler: function (button, event) {
this.Save('1');
},
scope: this
}, '-',
{
// id: "saveandclose",
text: "关闭",
handler: function (button, event) {
window.close();
},
scope: this
}, {
text: "导入码头Excel表格",
tooltip: '注意写有导入内容的工作表名称应该是英文的而且是xls文件内第一个工作表。文件格式应当是97-2003的xls文件。',
iconCls: "btnexportexcel",
handler: function (button, event) {
if (this.formEdit.getForm().findField('GID').getValue() == "") {
//alert("请先保存以获取单号");
// this.save("0");
this.Save('0');
}
var winAccess = new DsTruck.FileImport({});
var _r = this.storePrice.findRecord("EnumValueId", "油价加");
var priceAdd = parseFloat(_r.get('EnumValueName'));
var _r = this.storePrice.findRecord("EnumValueId", "油价减");
var priceCut = parseFloat(_r.get('EnumValueName'));
var _r = this.storePrice.findRecord("EnumValueId", "油价系数");
var priceMul = parseFloat(_r.get('EnumValueName'));
var _r = this.storePrice.findRecord("EnumValueId", "20GP系数");
var _20GPMul = parseFloat(_r.get('EnumValueName'));
var _r = this.storePrice.findRecord("EnumValueId", "40GP系数");
var _40GPMul = parseFloat(_r.get('EnumValueName'));
winAccess.StoreList = this.storeCtn;
winAccess.BSNO = this.formEdit.getForm().findField('GID').getValue();
winAccess.priceAdd = priceAdd;
winAccess.priceCut = priceCut;
winAccess.priceMul = priceMul;
winAccess._20GPMul = _20GPMul;
winAccess._40GPMul = _40GPMul;
winAccess.show();
},
scope: this
}
]
}); //end 按钮Toolbar
//布局
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 30,
items: [this.panelBtn]
});
this.panelCtn = new Ext.Panel({
layout: "border",
region: 'center',
margin: '1 1',
height: 230,
split: true,
items: [this.formEdit, this.formCtn]
});
Ext.apply(this, {
items: [this.panelTop, this.panelCtn]
});
parentWin = window.parent.opener;
this.InitData();
//集中绑定事件
this.formCtn.on('edit', function (editor, e, eOpts) {
this.CtnAfterEdit(editor, e, eOpts);
}, this);
this.cellEditing.on('beforeedit', function (editor, e) {
//Ext.getCmp("zongshu").setText("1234");
return this.CtnBeforeEdit(editor, e);
}, this);
}, //end initUIComponents
parentfunction: function (button, event) {
var ret1 = window.parent.opener.OprationSwap();
// alert(this.First);
ret1[3]();
},
onAddCtnClick: function (button, event, type) {
var store = null;
store = this.storeCtn;
//var newSerialno = this.GetHandleSerialNo(store, type);
var record = null;
record = Ext.create('PortCtnmb', {
GID: newGuid(),
LINKID: "",
DRVCODE: "",
DRVNAME: "",
Mobile: "",
TRUCKNO: "",
Ctn20: "0",
Ctn40: "0",
Ctn45: "0",
Mov: "0",
TEU: "0",
Price_1: "2",
Price_2: "1.2",
AvrOil: "6",
Factor: "0.7",
Plus: "11.5",
Amount_1: "0",
Amount_2: "0"
});
store.add(record);
cellediting = this.cellEditing;
var n = store.getCount();
cellediting.startEditByPosition({ row: n - 1, column: 2 });
},
onDelCtnClick: function (button, event) {
var selectedRecords = this.formCtn.selModel.getSelection();
Ext.MessageBox.confirm('提示', '确定删除记录吗?', function (btn) {
if (btn == 'yes') {
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.GID != "" || rec.GID != "*") //如果是新增但没有保存的数据,没有必要提交到后台
{
this.CtnDel.push(rec);
}
this.storeCtn.remove(selectedRecords[i]);
}
}
}, this);
//aftereditform();
var Amount_ALL = 0;
for (var i = 0; i < this.storeCtn.getCount(); i += 1) {
Amount_ALL = Add(Amount_ALL, parseFloat(this.storeCtn.getAt(i).get("Amount")));
}
Ext.getCmp("AMOUNT_ALL").setValue(Amount_ALL + "");
},
CtnAfterEdit: function (editor, e, eOpts) {
//需要自己实现里面的事件
if (COMPANYID == "") {
alert("登录信息不全,请退出重新登录");
returen;
}
/*20GP系数 1.2
40GP系数 2
油价加 11.5
油价减 5.4
油价系数 0.7*/
var _r = this.storePrice.findRecord("EnumValueId", "油价加");
var priceAdd = parseFloat(_r.get('EnumValueName'));
var _r = this.storePrice.findRecord("EnumValueId", "油价减");
var priceCut = parseFloat(_r.get('EnumValueName'));
var _r = this.storePrice.findRecord("EnumValueId", "油价系数");
var priceMul = parseFloat(_r.get('EnumValueName'));
var _r = this.storePrice.findRecord("EnumValueId", "20GP系数");
var _20GPMul = parseFloat(_r.get('EnumValueName'));
var _r = this.storePrice.findRecord("EnumValueId", "40GP系数");
var _40GPMul = parseFloat(_r.get('EnumValueName'));
if (e.field == 'DRVCODE') {
var BSrecords = DsStoreQueryBy(this.storeDrvName, 'DrvCode', e.value);
if (BSrecords.getCount() > 0) {
var BSdata = BSrecords.getAt(0).data;
e.record.set('DRVNAME', BSdata.DrvName); //Mobile
e.record.set('Mobile', BSdata.Mobile);
} else {
e.record.set('DRVNAME', '');
}
}
if (e.field == 'Ctn20' || e.field == 'Ctn40' || e.field == 'Ctn45') {
var TEU = 0;
var _20 = parseFloat(e.record.get('Ctn20'));
var _40 = parseFloat(e.record.get('Ctn40'));
var _45 = parseFloat(e.record.get('Ctn45'));
var TEU = Add(_20, Mul(_40, 2));
TEU = Add(TEU, Mul(_45, 2.25));
var AvrOil = parseFloat(e.record.get('AvrOil'));
var Amount_1 = Mul(Add(Mul(Cut(AvrOil, priceCut), priceMul), priceAdd), TEU);
var Amount_2 = Add(Mul(_20, _20GPMul), Mul(Add(_40, _45), _40GPMul));
var Mov = Add(Add(_20, _40), _45);
e.record.set('TEU', TEU);
e.record.set('Amount_1', Amount_1);
e.record.set('Amount_2', Amount_2);
e.record.set('Mov', Mov);
}
if (e.field == 'TRUCKNO') {
if (e.record.get('TruckNo') != "") {
//获取油价
var form = this.formEdit.getForm();
if (!form.isValid()) {
Ext.Msg.alert('提示', '查询条件赋值错误,请检查。');
return '';
}
var TruckNo = e.record.get('TRUCKNO');
var EXPDATE = form.findField('EXPDATE').getValue();
//通过 日期 燃油 类型从 燃油表中获取油价 select * from tMsWl_Port_FuelPrice
var FuelPrice = "0";
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/TruckMng/MsWl_Port/GetFuelPrice',
params: {
DATE: EXPDATE,
TruckNo: TruckNo
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (!result.Success) {
Ext.Msg.show({
title: '提示',
msg: result.Message,
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
return;
}
var data = result.data;
FuelPrice = data.Price;
e.record.set('AvrOil', parseFloat(FuelPrice)); //Mobile
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
} else {
//e.record.set('AvlOil', 0);
}
}
},
CtnBeforeEdit: function (editor, e) {
},
InitData: function () {
this.OpStatus = 'add';
var condition = '';
if (parentWin) {
var ret = parentWin.OprationSwap();
this.OpStatus = ret[0];
this.StoreList = ret[1];
this.editRecord = ret[2];
// this.parentfunction = ret[3];
}
if (this.OpStatus == 'edit') {
condition = " P.GID='" + this.editRecord.get('GID') + "'";
}
this.LoadData(this.OpStatus, condition);
//var storeWorkFlowStep = GetWorkFlowStep('')
}, //end InitData
ReflashEdt: function (BSNO) {
this.OpStatus = 'edit';
condition = " P.GID='" + BSNO + "'";
this.LoadData(this.OpStatus, condition);
}, //end InitData
//载入数据
LoadData: function (OpStatus, condition) {
if (COMPANYID == "") {
alert("登录信息不全,请退出重新登录");
return;
}
this.OpStatus = OpStatus;
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/TruckMng/MsWl_Port/GetData',
params: {
handle: OpStatus,
condition: condition
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (!result.Success) {
Ext.Msg.show({
title: '提示',
msg: result.Message,
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
return;
}
var data = result.data;
// this.formEdit.getForm().reset();
if (data.EXPDATE == "") { data.EXPDATE = currdate.format('yyyy-MM-dd') };
data.BODYTYPE = "Ctn";
this.formEdit.getForm().setValues(data);
//alert(data.TimeMark);
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
}); //request over
if (this.OpStatus == 'edit') {
//this.formEdit.getForm().findField('BXGID').setDisabled(false);
var GID = this.editRecord.get('GID');
this.storeCtn.load({ params: { start: 0, limit: 999, GID: GID} });
}
}, // end LoadDate
Save: function (type) {
var Amount_1 = 0;
var Amount_2 = 0;
for (var i = 0; i < this.storeCtn.getCount(); i += 1) {
Amount_1 = Add(Amount_1, parseFloat(this.storeCtn.getAt(i).get("Amount_1")));
Amount_2 = Add(Amount_2, parseFloat(this.storeCtn.getAt(i).get("Amount_2")));
}
Ext.getCmp("Amount_1").setValue(Amount_1 + "");
Ext.getCmp("Amount_2").setValue(Amount_2 + "");
var basicForm = this.formEdit.getForm();
if (!basicForm.isValid()) {
return;
}
var data = this.formEdit.getForm().getValues();
var GID = data.GID;
if (data.Locked == "on") {
alert("请先解除锁定");
return false;
}
data.Locked = this.formEdit.getForm().findField('Locked').getValue() ? 1 : 0;
if (COMPANYID == "") {
alert("登录信息不全,请退出重新登录");
return;
}
var Ctns = [];
for (var i = 0; i < this.storeCtn.getCount(); i += 1) {
var member = this.storeCtn.getAt(i);
Ctns.push(member);
/*
var Amount = member.data.Amount_1;
if (Amount == 0 || NOTAXAMOUNT == 0) {
Ext.Msg.show({ title: '警告',
msg: '不含税价格和价税合计金额均不允许为0请修改后再保存',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
return;
}*/
}
var Ctn = ConvertRecordsToJson(Ctns);
var CtnDel = ConvertRecordsToJsonAll(this.CtnDel);
var _this = this;
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/TruckMng/MsWl_Port/SaveCtn',
scope: this,
async: false,
params: {
OpStatus: this.OpStatus,
data: Ext.JSON.encode(data),
Ctn: Ctn,
CtnDel: CtnDel
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var returnData = jsonresult.Data;
this.formEdit.getForm().setValues(returnData);
if (this.OpStatus == 'add') {
var arrNewRecords = this.StoreList.add(returnData);
this.editRecord = arrNewRecords[0];
// alert(editRecord.get('ContractNo'));
}
else if (this.OpStatus == 'edit') {
var editp = Ext.create('MsWl_Portmb', returnData);
this.editRecord.fields.each(function (field) {
if (field.persist) {
name = field.name;
//alert(name + ' -- ' + editp.get(name));
if (name != 'GID')
this.editRecord.set(name, editp.get(name));
}
}, this);
this.editRecord.commit();
}
this.storeCtn.commitChanges();
this.BSNO = this.editRecord.get('GID');
if (type == '0') {
this.OpStatus = 'edit';
this.storeCtn.load({ params: { start: 0, limit: 999, GID: this.BSNO} });
} else if (type == '1') {//保存并关闭
window.close();
} else if (type == '2') {//保存并全部新建
this.LoadData('add', '');
}
} else {
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
} else {
Ext.Msg.show({ title: '请重试',
msg: '服务器响应出错',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
}
//alert('03');
}
});
}
//end save
, DoPrint: function () {
var basicForm = this.formEdit.getForm();
var GID = this.editRecord.get('GID')
/*
if (ContractNo == '*' || ContractNo == '') {
Ext.Msg.show({ title: '错误', msg: '单据还没有保存,请保存后再打印', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}*/
function GetDateStr(AddDayCount) {
var dd = new Date();
dd.setDate(dd.getDate() + AddDayCount); //获取AddDayCount天后的日期
var y = dd.getFullYear();
var m = dd.getMonth() + 1; //获取当前月份的日期
var d = dd.getDate();
return y + "-" + m + "-" + d;
}
//alert(GetDateStr(+5));
var needdate = GetDateStr(+5);
var printdate = GetDateStr(0);
var _date = Ext.getCmp("CREATEDATE").getRawValue();
var printType = 'Baoxiao'; //客户对账_KC
//
var sql1 = " select OA_Baoxiao.*,sd.deptname DN ";
var sql1 = sql1 + " from OA_Baoxiao left join [user] U on U.showname=OA_Baoxiao.createuser ";
var sql1 = sql1 + " left join [user_baseinfo] ub on ub.userid=u.gid ";
var sql1 = sql1 + " left join sys_dept sd on sd.gid=OA_Baoxiao.DEPTNAME ";
var sql1 = sql1 + " where BXGID='" + BXGID + "' ";
var sql2 = " select vs.mblno,vs.CUSTNO, c.* from ch_fee c ";
var sql2 = sql2 + " left join vw_settlement vs on vs.bsno=c.bsno ";
var sql2 = sql2 + " where BXGID ='" + BXGID + "' order by c.CHEQUENUM,c.remark";
var sql3 = "select createuser from oa_baoxiao where bxgid ='" + BXGID + "' ";
var sql4 = "select dbo.GetRemain_ZWC ('" + DEPTGID + "','" + _date + "')"; //获取该部门剩余资金
var sql5 = "";
var sql6 = "";
PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6);
}
});