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.

1514 lines
52 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');
var C_cargoinfo_id="";
var HTHCount=0;
var APPUsingCount=0;
DsTruck.MsOpAirn_Freight_Edit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.DsTruck.MsOpAirn_Freight_Edit.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(), //sedcond
"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 cargodirty = DsTruck.GetDirty(panelEdit.storeDetail, panelEdit.DetailDel);
if (panelEdit.formEdit.getForm().isDirty()== true || cargodirty==true)
{
return true;
}
else return false;
}
Ext.extend(DsTruck.MsOpAirn_Freight_Edit, Ext.Panel, {
parentWin: null,
opStatus: 'add',
StoreList: null,
editRecord: null,
// parentfunction: null,
_First: true,
PLAN_GID: "",
AIRLINES: "",
initUIComponents: function () {
this.DetailDel = [];
this.feeSerialNo = 0;
this.feeBodyDel = [];
this.DetailListName = "Airn_FreightDetail";
this.FactoryNo = "";
//#region 枚举参照相关(编辑form)
var _this = this;
this.storeSeller = Ext.create('DsExt.ux.RefTableStore', {
model: 'Tradermb',
proxy: { url: '/CommMng/BasicDataRef/GetTrader' }
});
this.storeSeller.load({ params: { condition: " isairlines=1"} });
this.comboxSeller = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '结算对象',
forceSelection: true,
store: this.storeSeller,
name: 'CUSTCODE',
valueField: 'code',
displayField: 'codename',
listeners: {
blur: function (field, newValue, oldValue) {
if (field.displayTplData[0].ISSTOP == "True") {
alert("该往来单位已经停用");
}
Ext.getCmp("CUSTOMERNAME").setValue(field.displayTplData[0].name);
if (field.displayTplData[0].code != "") {
_this.storeDetailName.load({ params: { start: 0, limit: 9999, condition: " CLIENTGID=(select gid from info_client where codename='" + field.displayTplData[0].code + "') "} });
}
},
change: function (field, newValue, oldValue) {
if (field.displayTplData[0].code != "") {
_this.storeDetailName.load({ params: { start: 0, limit: 9999, condition: " CLIENTGID=(select gid from info_client where codename='" + field.displayTplData[0].code + "') "} });
}
},
scope: this
}
});
this.storeUser = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsTruckMng.ux.UserRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetUserRefList' }
});
this.storeUser.load({ params: { condition: ""} });
this.comboxCreator = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '接单人',
forceSelection: true,
store: this.storeUser,
name: 'creator',
valueField: 'UserName',
displayField: 'CodeAndName',
allowBlank: false
});
this.storeOP = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsTruckMng.ux.UserRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetUserRefList' }
});
this.storeOP.load({ params: { condition: ""} });
this.comboxOP = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '录入人',
forceSelection: true,
store: this.storeOP,
name: 'ENTEROPERATOR',
valueField: 'UserName',
displayField: 'CodeAndName'
});
this.storeBLTYPE = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeBLTYPE.load({ params: { enumTypeId: 38} });
this.comboxBLTYPE = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: '运单类型',
forceSelection: true,
store: this.storeBLTYPE,
valueField: 'EnumValueName',
displayField: 'EnumValueName',
name: 'BLTYPE'
});
//#endregion
//编辑form:formEdit
this.formEdit = Ext.widget('form', {
// layout: "border",
region: 'center',
frame: true,
bodyPadding: 5,
trackResetOnLoad: true, //不加的话load之后isdirty即变为true
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 90,
msgTarget: 'qtip'
//,split:true
},
items: [
{//fieldset 1
xtype: 'fieldset',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{//container_1
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: 'GID',
hidden: true,
name: 'GID'
}, {
fieldLabel: '方案名称',
// allowBlank: false,
name: 'DESCRIPTION',
flex: 2
}
, this.comboxSeller
, {
fieldLabel: '结算对象名称',
readOnly: true,
name: 'CUSTOMERNAME', id: "CUSTOMERNAME"
}, {
fieldLabel: '时间戳',
name: 'TimeMark', flex: 0, hidden: true, margins: '0'
}
]
}, //container_1 end
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
{
fieldLabel: '适用范围',
name: 'AREA',
flex: 1
},
this.comboxBLTYPE
, {
fieldLabel: '生效时间',
format: 'Y-m-d H:i:s',
xtype: 'datefield',
renderer: Ext.util.Format.dateRenderer('Y-m-d H:i:s'),
name: 'STARTDATE'
}
, {
fieldLabel: '失效时间',
format: 'Y-m-d H:i:s',
xtype: 'datefield',
renderer: Ext.util.Format.dateRenderer('Y-m-d H:i:s'),
name: 'ENDDATE'
}
]
},
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
this.comboxOP
, {
fieldLabel: '录入时间', readOnly: true,
format: 'Y-m-d H:i:s',
xtype: 'datefield',
renderer: Ext.util.Format.dateRenderer('Y-m-d H:i:s'),
name: 'ENTERDATE'
}, {
xtype: 'checkbox', flex: 1,
fieldLabel: '是否启用',
name: 'INUSE'
}, { xtype: 'hiddenfield', flex: 1 }
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
////
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
////
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
////
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
////
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
////
]
}]
}]
});
//////////////////////////////////
//#region 方案明细
//#region 相关参照
this.storeDetailinfo = Ext.create('DsExt.ux.RefTableStore', {
model: 'CargoTax',
proxy: { url: '/CommMng/BasicDataRef/GetCargoTax' }
});
// this.storeDetailinfo.load({ params: { condition: ""} });
this.comboxCargoinfo = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeDetailinfo,
forceSelection: true,
name: 'Cargoinfo_id',
valueField: 'id',
displayField: 'codeandname'
//HS代码
});
this.storeDetailciq = Ext.create('DsExt.ux.RefTableStore', {
model: 'CargociqRef',
proxy: { url: '/CommMng/BasicDataRef/GetCargociqRefList' }
});
//this.storeDetailciq.load({ params: { condition: ""} });
this.comboxCargociq = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeDetailciq,
forceSelection: true,
name: 'Cargociq_id',
valueField: 'id',
displayField: 'codeandname',
async: false
//ciq代码
});
///币别代码币别
this.storecurr = Ext.create('DsExt.ux.RefTableStore', {
model: 'currRef',
proxy: { url: '/CommMng/BasicDataRef/GetcurrRefList' }
});
this.storecurr.load({ params: { condition: ""} });
this.comboxcurr = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storecurr,
name: 'currid',
valueField: 'gid',
displayField: 'codename'
//币别
});
//枚举参照
this.storeUnit = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeUnit.load({ params: { enumTypeId: 11} });
this.comboxUnit = Ext.create('DsExt.ux.RefEnumCombox', {
store: this.storeUnit,
forceSelection: true,
name: 'Unit'
, value: '2'
});
this.storepaypart = Ext.create('DsExt.ux.RefEnumStore', {});
this.storepaypart.load({ params: { enumTypeId: 12} });
this.comboxpaypart = Ext.create('DsExt.ux.RefEnumCombox', {
store: this.storepaypart,
forceSelection: true,
name: 'paypart'
});
this.storeExporter = Ext.create('DsExt.ux.RefTableStore', {
model: 'Tradermb',
proxy: { url: '/CommMng/BasicDataRef/GetTrader' }
});
this.storeExporter.load({ params: { condition: " isenterp=1 and isnull(ISSTOP,0)=0 "} });
this.comboxExporter = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '出口商',
//forceSelection: true,
store: this.storeExporter,
name: 'Exporter',
valueField: 'name',
displayField: 'codename'
});
this.storeDetailName = Ext.create('DsExt.ux.RefTableStore', {
model: 'CargoNamemb',
proxy: { url: '/Import/CargoName/GetCargoNameList' }
});
//this.storeDetailName.load({ params: { start: 0, limit: 9999, condition: " isnull(codename,'')<>'' "} });
this.comboxCargoName = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '出口商',
//forceSelection: true,
store: this.storeDetailName,
name: 'CARGOGID',
valueField: 'GID',
displayField: 'CODEandNAME'
});
this.storeDetailType = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeDetailType.load({ params: { enumTypeId: 30} });
this.comboxCargoType = Ext.create('DsExt.ux.RefEnumCombox', {
store: this.storeDetailType,
forceSelection: true,
name: 'CargoType',
valueField: 'EnumValueName',
displayField: 'EnumValueName'
});
//商品规格 20160420
this.storeSPECIFICATIONS = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeSPECIFICATIONS.load({ params: { enumTypeId: 34} });
this.comboxSPECIFICATIONS = Ext.create('DsExt.ux.RefEnumCombox', {
store: this.storeSPECIFICATIONS,
forceSelection: true,
name: 'SPECIFICATIONS',
valueField: 'EnumValueName',
displayField: 'EnumValueName'
});
this.storeCodeDisport = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.MsCodeAirPort',
proxy: { url: '/MvcShipping/MsCodeAirPort/GetDataList' }
});
this.storeCodeDisport.load();
this.storeCodeDisport2 = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.MsCodeAirPort',
proxy: { url: '/MvcShipping/MsCodeAirPort/GetDataList' }
});
this.storeCodeDisport2.load();
this.comboxPORTLOADID = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '始发地',
store: this.storeCodeDisport,
name: 'PORTLOADID',
valueField: 'PORTID',
displayField: 'CODEANDCNAME'/*,
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (records.length > 0) {
var selectrecords = DsStoreQueryBy(this.storeCodeDisport, 'PORTID', combo.value);
if (selectrecords.getCount() > 0) {
var selectdata = selectrecords.getAt(0).data;
this.formEdit.getForm().findField('PORTLOAD').setValue(selectdata.PORTENAME);
} else {
this.formEdit.getForm().findField('PORTLOAD').setValue('');
}
}
}
}*/
});
this.comboxPORTDISCHARGEID = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '到达地',
store: this.storeCodeDisport2,
name: 'PORTDISCHARGEID',
valueField: 'PORTID',
displayField: 'CODEANDCNAME'
});
//#endregion
//数据集
this.storeDetail = Ext.create('Ext.data.Store', {
pageSize: 9999,
model: 'FreightDetailmb',
remoteSort: false,
pruneModifiedRecords: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsOpAirn_Freight/GetBodyList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//表格
this.DetailColumns = [
{
sortable: true, hidden: true,
dataIndex: 'GID',
header: 'GID',
width: 80
},
{
sortable: true,
dataIndex: 'DESCRIPTION',
header: '描述',
width: 80,
editor: {
xtype: 'textfield'
}
},
{
sortable: true, hidden: true,
dataIndex: 'PLAN_GID',
header: 'PLAN_GID',
width: 80
},
{
sortable: true,
dataIndex: 'CARGOGID',
header: '商品代码/名称',
width: 100,
renderer: function (value, p, record) {
if (value == null || value == '') return '';
else return record.data.CARGO_CODE;
},
editor: this.comboxCargoName
},
{
sortable: true, hidden: true,
dataIndex: 'CARGO_CODE',
header: 'CARGO_CODE',
width: 80
},
{
sortable: true,
dataIndex: 'CARGONAME',
header: '商品名称',
width: 80
},
{
sortable: true,
dataIndex: 'MINFEE',
header: '最低费用',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'MINWEIGHT',
header: '最低重量',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'W_5',
header: '5',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'W_10',
header: '10',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'W_N',
header: 'N',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'W_45',
header: '45',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'W_100',
header: '100',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'W_300',
header: '300',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'W_500',
header: '500',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'W_1000',
header: '1000',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'REMARK',
header: '备注',
width: 80,
editor: {
xtype: 'textfield'
}
},
{
sortable: true,
dataIndex: 'REMARK_2',
header: '储运注意事项',
width: 80,
editor: {
xtype: 'textfield'
}
},
{
sortable: true,
dataIndex: 'REMARK_3',
header: '结算注意事项',
width: 80,
editor: {
xtype: 'textfield'
}
},
{
sortable: true,
dataIndex: 'PORTLOADID',
header: '始发地',
width: 80,
width: 100,
renderer: function (value, p, record) {
if (value == null || value == '') return '';
else return record.data.PORTLOADID_REF;
},
editor: this.comboxPORTLOADID
},
{
sortable: true,
dataIndex: 'PORTDISCHARGEID',
header: '到达地',
width: 80,
width: 100,
renderer: function (value, p, record) {
if (value == null || value == '') return '';
else return record.data.PORTDISCHARGEID_REF;
},
editor: this.comboxPORTDISCHARGEID
},
{
sortable: true,
dataIndex: 'VESSELHEAD',
header: '航司前缀',
width: 80,
editor: {
xtype: 'textfield'
}
},
{
sortable: true,
dataIndex: 'VESSEL',
header: '航班号',
width: 80,
editor: {
xtype: 'textfield'
}
},
{
sortable: true, hidden: true,
dataIndex: 'PORTLOADID_REF',
header: 'PORTLOADID_REF',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'PORTDISCHARGEID_REF',
header: 'PORTDISCHARGEID_REF',
width: 80
},
{
sortable: true,
dataIndex: 'D_INFO',
header: '条款名称',
width: 140
}
];
this.cellEditingCargo = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.cargoCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
var _this = this;
this.formDetail = new Ext.grid.GridPanel({
store: this.storeDetail,
enableHdMenu: false,
layout: 'border',
region: 'center', //bodyStyle: 'background:#FFF',
trackResetOnLoad: true,
//height: 160,
autoScroll: true,
title: '商品信息',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.cellEditingCargo],
selModel: this.cargoCheckBoxModel,
selType: 'cellmodel',
tbar: [{
text: '增加明细',
tooltip: '增加明细',
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddCargoClick(button, event);
},
scope: this
}, '-', {
text: '删除明细',
tooltip: '删除明细',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelCargoClick(button, event);
},
scope: this
}, {
text: '库存初始化',
tooltip: '库存初始化',
iconCls: "btnKCStart", hidden: true,
handler: function (button, event) {
this.onKCStartClick(button, event);
},
scope: this
}, {
text: '生成应收应付',
tooltip: '生成应收应付',
iconCls: "btnCWStart", hidden: true,
handler: function (button, event) {
this.onbtnCWStartClick(button, event);
},
scope: this
}, {
text: "保存列表样式",
id: "btnsavelist",
handler: function (button, event) {
var tempcolumns = this.formDetail.columns;
DsTruck.SaveGridPanel(USERID, _this.DetailListName, tempcolumns);
},
scope: this
}],
columns: this.DetailColumns
});
this.DetailColumns = DsTruck.GetGridPanel(USERID, this.DetailListName, this.DetailColumns);
//使用者id表名 中间column数组跳过一开始的几列
this.formDetail.reconfigure(this.storeDetail, this.DetailColumns);
//#endregion
//公共按钮Toolbar:panelBtn
_this = this;
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
// id: "saveandclose",
text: "保存",
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('CUSTCODE').getValue() == "") {
alert("必须要选择航空公司");
return;
}
this.Save('0');
//异步保存时,数据还没更新,这种方式是错误的,参数传递有问题!!!!!
//this.PLAN_GID = this.formEdit.getForm().findField('GID').getValue();
//this.AIRLINES = this.formEdit.getForm().findField('CUSTCODE').getValue();
var winAccess = new DsTruck.FileImport({});
winAccess.StoreList = this.storeDetail;
winAccess.show();
},
scope: this
}, '-',
{
text: "打印",
iconCls: 'btnprint',
handler: function () {
_this.Print();
},
scope: this
}
]
}); //end 按钮Toolbar
//布局
/* 3 */
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 140,
items: [this.panelBtn, this.formEdit]
});
this.panelCargoandApp = new Ext.Panel({
layout: "border",
region: 'center',
split: true,
height: 500,
margin: '1 1',
items: [this.formDetail
]
});
Ext.apply(this, {
items: [this.panelTop, this.panelCargoandApp]
});
parentWin = window.parent.opener;
this.InitData();
//集中绑定编辑后事件
this.formDetail.on('edit', function (editor, e, eOpts) {
this.DetailAfterEdit(editor, e, eOpts);
}, this);
}, //end initUIComponents
////////<<<商品>>>明细表相关方法
reLine: function (button, event) {
var _L = 1;
this.storeDetail.each(function (record) {
var ln = _L + "";
_L = _L + 1;
record.set('SEQUENCE', ln);
});
},
onAddCargoClick: function (button, event) {
//var linenum=this.storeDetail.getCount()+1;
//var _r=this.reLine();
var record = Ext.create('FreightDetailmb', {
'GID': NewGuid(),
'DESCRIPTION': '',
'PLAN_GID': '',
'CARGOGID': '',
'CARGO_CODE': '',
'CARGO_NAME': '',
'MINFEE': '0',
'MINWEIGHT': '0',
'W_5': '0',
'W_10': '0',
'W_N': '0',
'W_45': '0',
'W_100': '0',
'W_300': '0',
'W_500': '0',
'W_1000': '0',
'REMARK': '',
'REMARK_2': '',
'REMARK_3': '',
'PORTLOADID': '',
'PORTDISCHARGEID': '',
'VESSEL': '',
'PORTLOADID_REF': '',
'PORTDISCHARGEID_REF': '',
'D_INFO': ''
});
this.storeDetail.add(record);
var n = this.storeDetail.getCount();
this.cellEditingCargo.startEditByPosition({ row: n - 1, column: 2 });
//aftereditform();
},
onDelCargoClick: function (button, event) {
var selectedRecords = this.formDetail.selModel.getSelection();
Ext.MessageBox.confirm('提示', '确定删除记录吗?', function (btn) {
if (btn == 'yes') {
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.PLAN_GID != "" || rec.PLAN_GID != "*") //如果是新增但没有保存的数据,没有必要提交到后台
{
this.DetailDel.push(rec);
}
this.storeDetail.remove(selectedRecords[i]);
}
}
}, this);
//aftereditform();
},
CargoBeforeEdit: function (editor, e) {
var cargo_id = e.record.get('id');
if (cargo_id == "" || cargo_id == null) { cargo_id = -1; }
var canedit = true;
this.APPUsingCount = 0;
Ext.Ajax.request({
waitMsg: '正在查询数据...',
url: '/Import/UseApproval/Getused',
scope: this,
async: false,
params: { cargo_id: cargo_id },
waitMsg: "正在查询数据...",
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
var returnData = jsonresult.data;
//alert(returnData.Count);
this.APPUsingCount = parseInt(returnData.Count);
} else {
Ext.Msg.show({ title: '请重试',
msg: '服务器响应出错',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
return;
}
}
});
if (e.field == 'cargoinfo_id' || e.field == 'cargociq_id' || e.field == 'Unit'
|| e.field == 'U_weight' || e.field == 'FactoryNo' || e.field == 'Exporter') {
if (this.APPUsingCount > 0) {
canedit = false;
}
}
if (e.field == 'cargociq_id') {
//20150112
var cargoinfoid = e.record.get('cargoinfo_id');
if (cargoinfoid != "" && cargoinfoid != null) {
var s = " cargoinfoid=" + cargoinfoid;
this.storeDetailciq.load({ params: { condition: s} });
}
}
if (e.field == 'FactoryNo') {
if (e.record.get('Exporter') == "") {
//canedit=false;
//alert("请先选择出口商!");
} else {
//this.storeFactoryNo.load({ params: { condition: " CLIENTGID=(select gid from info_client where shortname='"+e.record.get('Exporter')+"') "} });
}
}
if (e.field == 'name') {
var HS_ID = e.record.get('cargoinfo_id');
if (HS_ID == null) { HS_ID = ""; }
if (e.record.get('FactoryNo') == "" || e.record.get('FactoryNo') == null) {
var Ename = e.record.get('Ename');
if (Ename == "" || Ename == null) {
if (HS_ID == "" || this.APPUsingCount == 0) {
this.storeDetailName.load({ params: {
start: 0, limit: 5000, sort: '',
condition: ""
}
});
} else {
this.storeDetailName.load({ params: {
start: 0, limit: 5000, sort: '',
condition: "HS_ID=" + e.record.get('cargoinfo_id')
}
});
}
} else {
if (HS_ID == "" || this.APPUsingCount == 0) {
this.storeDetailName.load({ params: {
start: 0, limit: 5000, sort: '',
condition: " ENNAME='" + Ename + "'"
}
});
} else {
this.storeDetailName.load({ params: {
start: 0, limit: 5000, sort: '',
condition: " ENNAME='" + Ename + "' and HS_ID=" + e.record.get('cargoinfo_id')
}
});
}
}
} else {
//if (this.FactoryNo!=e.record.get('FactoryNo'))
if (HS_ID == "" || this.APPUsingCount == 0) {
this.storeDetailName.load({ params: {
start: 0, limit: 5000, sort: '',
condition: " FACTORYNOGID=(select gid from import_factoryno where factoryno='" + e.record.get('FactoryNo') + "') "
} //
});
} else {
this.storeDetailName.load({ params: {
start: 0, limit: 5000, sort: '',
condition: " FACTORYNOGID=(select gid from import_factoryno where factoryno='" + e.record.get('FactoryNo') + "') and HS_ID=" + e.record.get('cargoinfo_id')
} //
});
}
this.FactoryNo = e.record.get('FactoryNo');
}
}
if (e.field == 'Ename') {
var HS_ID = e.record.get('cargoinfo_id');
if (HS_ID == null) { HS_ID = ""; }
if (e.record.get('FactoryNo') == "" || e.record.get('FactoryNo') == null) {
var name = e.record.get('name');
if (name == "" || name == null) {
if (HS_ID == "" || this.APPUsingCount == 0) {
this.storeDetailName.load({ params: {
start: 0, limit: 5000, sort: '',
condition: ""
}
});
} else {
this.storeDetailName.load({ params: {
start: 0, limit: 5000, sort: '',
condition: "HS_ID=" + e.record.get('cargoinfo_id')
}
});
}
} else {
if (HS_ID == "" || this.APPUsingCount == 0) {
this.storeDetailName.load({ params: {
start: 0, limit: 5000, sort: '',
condition: " CNNAME='" + Ename + "'"
}
});
} else {
this.storeDetailName.load({ params: {
start: 0, limit: 5000, sort: '',
condition: " CNNAME='" + Ename + "' and HS_ID=" + e.record.get('cargoinfo_id')
}
});
}
}
} else {
//if (this.FactoryNo!=e.record.get('FactoryNo'))
if (HS_ID == "" || this.APPUsingCount == 0) {
this.storeDetailName.load({ params: {
start: 0, limit: 5000, sort: '',
condition: " FACTORYNOGID=(select gid from import_factoryno where factoryno='" + e.record.get('FactoryNo') + "') "
} //
});
} else {
this.storeDetailName.load({ params: {
start: 0, limit: 5000, sort: '',
condition: " FACTORYNOGID=(select gid from import_factoryno where factoryno='" + e.record.get('FactoryNo') + "') and HS_ID=" + e.record.get('cargoinfo_id')
} //
});
}
this.FactoryNo = e.record.get('FactoryNo');
}
}
//20150505 当合同状态为审单或更往后的状态 禁止修改单价和重量。
if (this.opStatus == 'edit') {
var Mainstate = parseInt(this.editRecord.get('Mainstate'));
if (Mainstate > 1 && (e.field == 'weight' || e.field == 'price' || e.field == 'price_agio' || e.field == 'price_limit')) {
canedit = false;
alert("审单之后即不能修改重量和价格");
}
}
if (e.field == 'Cargoinfo_id' || e.field == 'Cargociq_id') {
var countryid = this.formEdit.getForm().findField('countryid').getRawValue();
if (countryid == "") {
alert("添加货物之前必须先选择进口国");
canedit = false;
}
}
if (e.field == 'SPECIFICATIONS') {
var cicodeandname = e.record.get('cicodeandname');
if (cicodeandname != "0203290090_其他冻藏猪肉") {
//alert("只有HS代码为0203290090的商品才能修改规格");
canedit = false;
} else {
if (this.APPUsingCount > 0) {
canedit = false;
}
}
}
if (e.field == 'cargoinfo_id') {
var FactoryNo = e.record.get('FactoryNo');
var name = e.record.get('name');
if ((FactoryNo == "" || FactoryNo == null) && (name != "" && name != null)) {
//如果没选厂号 选了中文品名
//根据品名确定范围
var s = " countryid='" + this.formEdit.getForm().findField('countryid').getValue() + "'";
s = s + " and ci.id in(select hs_id from Import_Cargoname where CNNAME='" + name + "')"
this.storeDetailinfo.load({ params: { condition: s} });
} else
if ((FactoryNo != "" && FactoryNo != null) && (name != "" && name != null)) {
//如果选了厂号 选了中文品名
//根据厂号和品名确定范围
var s = " countryid='" + this.formEdit.getForm().findField('countryid').getValue() + "'";
s = s + " and ci.id in(select hs_id from Import_Cargoname where CNNAME='" + name + "' and FactoryNoGID in(select GID from Import_Factoryno where FactoryNo='" + FactoryNo + "')) "
this.storeDetailinfo.load({ params: { condition: s} });
} else {
this.storeDetailinfo.load({ params: { condition: ""} });
}
}
return canedit;
},
DetailAfterEdit: function (editor, e, eOpts) {
if (e.field == 'CARGOGID') {
var Cargoinforecords = DsStoreQueryBy(this.storeDetailName, 'GID', e.value);
if (Cargoinforecords.getCount() > 0) {
var Cargoinfodata = Cargoinforecords.getAt(0).data;
e.record.set('CARGO_CODE', Cargoinfodata.CODEandNAME);
} else {
e.record.set('CARGO_CODE', '');
}
}
if (e.field == 'PORTLOADID') {
var Cargoinforecords = DsStoreQueryBy(this.storeCodeDisport, 'PORTID', e.value);
if (Cargoinforecords.getCount() > 0) {
var Cargoinfodata = Cargoinforecords.getAt(0).data;
e.record.set('PORTLOADID_REF', Cargoinfodata.PORTID + "-" + Cargoinfodata.PORTCNAME);
} else {
e.record.set('PORTLOADID_REF', '');
}
}
if (e.field == 'PORTDISCHARGEID') {
var Cargoinforecords = DsStoreQueryBy(this.storeCodeDisport2, 'PORTID', e.value);
if (Cargoinforecords.getCount() > 0) {
var Cargoinfodata = Cargoinforecords.getAt(0).data;
e.record.set('PORTDISCHARGEID_REF', Cargoinfodata.PORTCNAME);
} else {
e.record.set('PORTDISCHARGEID_REF', '');
}
}
},
/////////////明细表<<<商品>>>的相关方法
parentfunction: function (button, event) {
var ret1 = window.parent.opener.OprationSwap();
// alert(this.First);
ret1[3]();
},
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 = " GID='" + this.editRecord.get('GID') + "'";
this.LoadData(this.opStatus, condition);
}, //end InitData
//载入数据
LoadData: function (opstatus, condition) {
this.opStatus = opstatus;
var PLAN_GID = "";
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/MvcShipping/MsOpAirn_Freight/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();
PLAN_GID = data.GID;
if (data.INUSE == "1") {
data.INUSE = '1';
} else { data.INUSE = '0' };
this.formEdit.getForm().setValues(data);
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
}); //request over
if (this.opStatus == 'edit') {
this.storeDetail.load({ params: { start: 0, limit: 9999, condition: " PLAN_GID='" + this.editRecord.get('GID') + "'"} });
}
}, // end LoadDate
ReflashEdt: function (PLAN_GID) {
this.opStatus = 'edit';
condition = " GID='" + PLAN_GID + "'";
this.LoadData(this.opStatus, condition);
//this.storeDetail.load({ params: { condition: condition} });
}, //end InitData
checkedit: function () {
var _r = true;
if (this.HTHCount > 0) {
alert("合同号重复");
_r = false;
} else {
var ContractStatus = this.formEdit.getForm().findField('ContractStatus').getValue() ? 1 : 0
if (ContractStatus == 1) {
alert("已经锁定");
_r = false;
} else
{ } //return true;
}
if (this.storeDetail.getCount() == 0) { } //return true;
else {
for (var i = 0; i < this.storeDetail.getCount(); i += 1) {
var cargomember = this.storeDetail.getAt(i).data;
if (cargomember.weight == "0") {
alert("请填写货物重量,请注意单位是千克");
_r = false;
} else
if (cargomember.name == "") {
alert("请填写货名。");
_r = false;
} else
if (cargomember.cicodeandname == '0203290090_其他冻藏猪肉' && (cargomember.SPECIFICATIONS == "" || cargomember.SPECIFICATIONS == null)) {
alert("0203290090_其他冻藏猪肉的商品必须选择商品规格(去骨/带骨)");
_r = false;
}
} //end for
} //end if
/* if (e.field == 'SPECIFICATIONS'){
var cicodeandname=e.record.get('cicodeandname');
if (cicodeandname!="0202300090_其他冻藏猪肉" ){
//alert("只有HS代码为0203290090的商品才能修改规格");
canedit=false;
}else{
//canedit=true;
}
}*/
_form = this.formEdit.getForm();
var seller_name = _form.findField('seller').getValue();
if (CheckISSTOP(this.storeSeller, 'name', seller_name) == true) {
alert("你选择的贸易商已经停用");
_r = false;
}
var buyer_name = _form.findField('buyer').getValue();
var buyer = DsStoreQueryBy(this.storeBuyer, 'name', buyer_name);
if (buyer.getCount() > 0) {
var buyerdata = buyer.getAt(0).data;
if (buyerdata.ISSTOP == "True") {
alert("你选择的购货商已经停用");
//return;
_r = false;
}
}
var TRADINGAGENCY_name = _form.findField('TRADINGAGENCY').getValue();
var TRADINGAGENCY = DsStoreQueryBy(this.storeTRADINGAGENCY, 'name', TRADINGAGENCY_name);
if (TRADINGAGENCY.getCount() > 0) {
var buyerdata = TRADINGAGENCY.getAt(0).data;
if (buyerdata.ISSTOP == "True") {
alert("你选择的中间商已经停用");
//return;
_r = false;
}
}
return _r;
},
Save: function (type) {
var basicForm = this.formEdit.getForm();
if (!basicForm.isValid()) {
return;
}
//basicForm.findField('ContractNo').setDisabled(false);
var data = this.formEdit.getForm().getValues();
//var HTH = data.HTH;
//var ContractNo = data.ContractNo;
//basicForm.findField('ContractNo').setDisabled(true);
var Cargodatas = [];
for (var i = 0; i < this.storeDetail.getCount(); i += 1) {
var member = this.storeDetail.getAt(i);
Cargodatas.push(member);
}
//商品明细
var CargoBody = ConvertRecordsToJson(Cargodatas);
var CargoDelBody = ConvertRecordsToJsonAll(this.DetailDel);
//将复选框值转化为1/0
//data.ContractStatus=this.formEdit.getForm().findField('ContractStatus').getValue()?1:0;
//data.HaveContract=this.formEdit.getForm().findField('HaveContract').getValue()?1:0;
data.INUSE = this.formEdit.getForm().findField('INUSE').getValue() ? 1 : 0;
var _this = this;
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsOpAirn_Freight/Save',
scope: this,
params: {
opstatus: this.opStatus,
data: Ext.JSON.encode(data),
CargoBody: CargoBody,
CargoDelBody: CargoDelBody
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.storeDetail.commitChanges();
var returnData = jsonresult.Data;
this.formEdit.getForm().setValues(returnData);
if (this.opStatus == 'add') {
var arrNewRecords = this.StoreList.add(returnData);
this.editRecord = arrNewRecords[0];
this.PLAN_GID = this.formEdit.getForm().findField('GID').getValue();
this.AIRLINES = this.formEdit.getForm().findField('CUSTCODE').getValue();
}
else if (this.opStatus == 'edit') {
var editp = Ext.create('FreightPLANmb', returnData);
this.editRecord.fields.each(function (field) {
if (field.persist) {
name = field.name;
//alert(name + ' -- ' + editp.get(name));
if (name != 'id')
this.editRecord.set(name, editp.get(name));
}
}, this);
this.editRecord.commit();
}
if (type == '0') {
this.opStatus = 'edit';
this.storeDetail.load({ params: { start: 0, limit: 9999, condition: " PLAN_GID='" + this.editRecord.get('GID') + "'"} });
} else if (type == '1') {//保存并关闭
window.close();
} else if (type == '2') {//保存并全部新建
}
} 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: function () {//船期表
var MainList = "";
var selectedRecords = [];
selectedRecords = this.formDetail.selModel.getSelection();
var PLAN_GID = this.formEdit.getForm().findField('GID').getValue();
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (MainList == "") { MainList = "'" + rec.get('GID') + "'"; }
else {
MainList = MainList + ",'" + rec.get('GID') + "'";
}
}
var printType = 'OpAirn_FreightDetail'; //船期
var sql1 = " select * from OpAirn_Freight_Detail "; ///WHERE M.HTH LIKE '%1433%'
if (MainList == "") {
sql1 = sql1 + " where PLAN_GID='" + PLAN_GID + "' ";
} else {
sql1 = sql1 + " where GID in(" + MainList + ") ";
}
sql1 = sql1 + " order by CARGOGID ";
var sql2 = "";
var sql3 = "";
var sql4 = "";
var sql5 = "";
var sql6 = "";
PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6);
}
});