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/ReceiptIO/ReceiptIOEdit.js

1429 lines
50 KiB
JavaScript

2 years ago
///<reference path="../../../../Views/../TruckMng/Scripts/vswd-ext_2.0.2.js" />
Ext.namespace('DsTruck');
var C_cargoinfo_id = "";
var HTHCount = 0;
DsTruck.ReceiptIOEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.DsTruck.ReceiptIOEdit.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.storeReceiptBody);
if (panelEdit.formEdit.getForm().isDirty() == true) {
return true;
}
else return false;
}
Ext.extend(DsTruck.ReceiptIOEdit, Ext.Panel, {
parentWin: null,
OpStatus: 'add',
StoreList: null,
editRecord: null,
BXSTATUS: 1,
// parentfunction: null,
_First: true,
VISIBLERANGE: 0,
OPERATERANGE: 0,
WorkFlowName: "",
WorkFlowID: "",
initUIComponents: function () {
this.feeSerialNo = 0;
this.BodyDel = [];
//#region 枚举参照相关(编辑form)
//WorkFlowName = 'BaoxiaoMod';
//通过mblno获取bsno
this.storeBS = Ext.create('DsExt.ux.RefTableStore', {
model: 'BSmb',
proxy: { url: '/OA/Baoxiao/GetAllBSNO', timeout: 180000 }
});
//this.storeBS.load({ params: { condition:" and CUSTNO<>'' "} });
this.comboxCUSTNO = Ext.create('DsExt.ux.RefTableCombox', {
forceSelection: true,
store: this.storeBS,
name: 'BSNO',
valueField: 'BSNO',
displayField: 'CUSTNO',
allowBlank: false,
enableKeyEvents: true,
listeners: {
keydown: function (textfield, e) {
if (e.getKey() == 9 || e.getKey() == 13) {
var rows = _this.formReceiptBody.getSelectionModel().getSelection();
var row = rows[rows.length - 1];
var s = _this.formReceiptBody.getStore();
var number = s.indexOf(row);
_this.cellEditing.startEditByPosition({ row: number, column: 10 });
}
}
}
});
this.comboxMBLNO = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '业务编号',
forceSelection: true,
store: this.storeBS,
name: 'MBLNO',
valueField: 'MBLNO',
displayField: 'MBLNO',
allowBlank: false,
enableKeyEvents: true,
listeners: {
keydown: function (textfield, e) {
if (e.getKey() == 9 || e.getKey() == 13) {
var rows = _this.formReceiptBody.getSelectionModel().getSelection();
var row = rows[rows.length - 1];
var s = _this.formReceiptBody.getStore();
var number = s.indexOf(row);
_this.cellEditing.startEditByPosition({ row: number, column: 10 });
}
}
}
});
this.comboxHBLNO = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '业务编号',
forceSelection: true,
store: this.storeBS,
name: 'HBLNO',
valueField: 'HBLNO',
displayField: 'HBLNO',
allowBlank: false,
enableKeyEvents: true,
listeners: {
keydown: function (textfield, e) {
if (e.getKey() == 9 || e.getKey() == 13) {
var rows = _this.formReceiptBody.getSelectionModel().getSelection();
var row = rows[rows.length - 1];
var s = _this.formReceiptBody.getStore();
var number = s.indexOf(row);
_this.cellEditing.startEditByPosition({ row: number, column: 10 });
}
}
}
});
this.storeUser = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsTruckMng.ux.UserRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetUserRefList' }
});
this.storeUser.load({ params: { condition: ""} });
this.comboxUser = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '制单人', flex: 1,
store: this.storeUser,
name: 'OP',
valueField: 'UserCode',
displayField: 'CodeAndName',
value: SHOWNAME
});
Ext.define('IOTYPEmb', {
extend: 'Ext.data.Model',
fields: [
{ name: 'ID', type: 'string' },
{ name: 'IOTYPERef', type: 'string' }
]
});
var IOTYPEData = [{ "ID": "0", "IOTYPERef": "收" },
{ "ID": "1", "IOTYPERef": "发"}];
this.storeIOTYPE = Ext.create('Ext.data.Store', {
model: 'IOTYPEmb',
data: IOTYPEData
});
this.comboxIOTYPE = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '收发方向',
flex: 1,
store: this.storeIOTYPE,
name: 'IOTYPE', //id: "ISPAYED",
valueField: 'ID',
displayField: 'IOTYPERef'
});
this.storeReceiptName = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeReceiptName.load({ params: { enumTypeId: 2} });
this.comboxReceiptName = Ext.create('DsExt.ux.RefEnumCombox', {
//fieldLabel: '单据类型',
store: this.storeReceiptName,
name: 'RECEIPTNAME',
valueField: 'EnumValueName',
displayField: 'EnumValueName',
enableKeyEvents: true,
listeners: {
keydown: function (textfield, e) {
if (e.getKey() == 9 || e.getKey() == 13) {
var rows = _this.formReceiptBody.getSelectionModel().getSelection();
var row = rows[rows.length - 1];
var s = _this.formReceiptBody.getStore();
var number = s.indexOf(row);
_this.cellEditing.startEditByPosition({ row: number, column: 11 });
}
}
}
});
Ext.define('IOTYPEmb', {
extend: 'Ext.data.Model',
fields: [
{ name: 'ID', type: 'string' },
{ name: 'IOTYPERef', type: 'string' }
]
});
var IOTYPEData = [{ "ID": "1", "IOTYPERef": "收" },
{ "ID": "2", "IOTYPERef": "发"}];
this.storeIOTYPE = Ext.create('Ext.data.Store', {
model: 'IOTYPEmb',
data: IOTYPEData
});
this.comboxIOTYPE = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '收发方向',
store: this.storeIOTYPE,
name: 'IOTYPE', //id: "ISPAYED",
valueField: 'ID',
displayField: 'IOTYPERef'
});
this.storeRecvCompany = Ext.create('DsExt.ux.RefTableStore', {
model: 'Tradermb',
proxy: { url: '/CommMng/BasicDataRef/GetTrader' }
});
this.storeRecvCompany.load({ params: { condition: ""} });
this.comboxRecvCompany = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '收件单位',
forceSelection: true,
store: this.storeRecvCompany,
name: 'RecvCompany',
valueField: 'name',
displayField: 'codename',
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (records.length > 0) {
var s = " LINKID in (select gid from [info_client] where SHORTNAME='" + combo.value + "') ";
this.storeInfoClientContact.load({ params: { condition: s },
callback: function (r, options, success) {
if (success) {
if (this.storeInfoClientContact.getCount() > 0) {
var member = this.storeInfoClientContact.getAt(0);
} else {
this.comboxInfoClientContact.setValue('');
}
}
},
scope: this
});
}
}
}
});
//委托单位_联系人
this.storeInfoClientContact = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.InfoClientContactModel',
proxy: { url: '/CommMng/BasicDataRef/GetInfoClientContactList' }
});
this.comboxInfoClientContact = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '收件人',
store: this.storeInfoClientContact,
forceSelection: true,
id: 'RecvName',
name: 'RecvName',
valueField: 'SHOWNAME',
displayField: 'SHOWNAME'
});
this.storeBillType = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeBillType.load({ params: { enumTypeId: 6} });
this.comboxBillType = Ext.create('DsExt.ux.RefEnumCombox', {
//fieldLabel: '提单提交方式',
forceSelection: true,
store: this.storeBillType,
name: 'BillType', flex: 1
});
//#endregion////////////////
//编辑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: 60,
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: [
this.comboxUser,
this.comboxIOTYPE,
this.comboxCreator,
this.comboxRecvCompany,
this.comboxInfoClientContact
]
}, //container_1 end
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: 'GID',
name: 'GID', hidden: true
}, {
fieldLabel: '收发时间',
format: 'Y-m-d H:i:s', id: "CREATETIME",
xtype: 'datefield',
renderer: Ext.util.Format.dateRenderer('Y-m-d H:i:s'),
name: 'CREATETIME', flex: 1
}, {
fieldLabel: '快递单号',
// allowBlank: false,
//disabled: true,
name: 'TRANCNO', flex: 1
}, {
fieldLabel: '备注',
name: 'REMARK', flex: 2
}]
},
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: []
}
]
}
]
});
//////////////////////////////////
//明细 <<<< 单据明细 >>>>
//#region 明细用参照
this.storeCustomerNameRef = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsTruckMng.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
});
this.storeCustomerNameRef.load({ params: { condition: ""} });
this.comboxCustomerNameRef = Ext.create('DsExt.ux.RefTableCombox', {
forceSelection: true,
store: this.storeCustomerNameRef,
name: 'CustomerName',
valueField: 'CustName',
displayField: 'CodeAndName'
});
Ext.define('NeedTypemb', {
extend: 'Ext.data.Model',
fields: [
{ name: 'ID', type: 'string' },
{ name: 'NeedTypeRef', type: 'string' }
]
});
var NeedTypeData = [{ "ID": "Recv", "NeedTypeRef": "接单" },
{ "ID": "Send", "NeedTypeRef": "送单" },
{ "ID": "Repeat", "NeedTypeRef": "回单" },
{ "ID": "Return", "NeedTypeRef": "还单"}];
this.storeNeedType = Ext.create('Ext.data.Store', {
model: 'NeedTypemb',
data: NeedTypeData
});
var _this = this;
this.comboxNeedType = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '单据操作',
store: this.storeNeedType,
name: 'NeedType', //id: "ISPAYED",
valueField: 'NeedTypeRef',
displayField: 'NeedTypeRef',
enableKeyEvents: true,
listeners: {
keydown: function (textfield, e) {
//alert(e.getKey());
if (e.getKey() == 9) {
// _thisfee.onNextKeyClick(1, 8)
_this.onAddReceiptClick();
} else {
//alert(e.getKey());
}
}
}
});
//#endregion
//数据集
this.storeReceiptBody = Ext.create('Ext.data.Store', {
model: 'ReceiptIOBodymb',
remoteSort: false,
async: false,
pruneModifiedRecords: true,
proxy: {
type: 'ajax',
url: '/Import/ReceiptIO/GetBodyList',
reader: {
id: 'gid',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//表格
this.cellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.CheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
this.formReceiptBody = new Ext.grid.GridPanel({
store: this.storeReceiptBody,
enableHdMenu: false,
region: 'center',
title: '单据明细',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.cellEditing],
selModel: this.CheckBoxModel,
selType: 'cellmodel',
tbar: [{
text: '增加单据', id: "add1",
tooltip: '增加单据',
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddReceiptClick(button, event);
},
scope: this
}, {
text: '删除', id: "del1",
tooltip: '删除',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelReceiptClick(button, event);
},
scope: this
}, '-', {
text: '查询全部', id: "",
tooltip: '在下拉菜单中载入全部业务',
iconCls: "btnrefresh",
handler: function (button, event) {
Ext.getCmp("cxzt").setText(" 查询中... ");
_this.storeBS.load({
params: { condition: " CUSTNO<>'' " }
, timeout: 180000,
callback: function (options, success, response) {
if (success) {
Ext.getCmp("cxzt").setText(" ");
} else {
Ext.MessageBox.alert('请求发生异常!', response.responseText);
}
}
});
},
scope: this
}, '-', { id: "S_HTH",
fieldLabel: "合同号/提单号/箱号",
labelWidth: 120,
xtype: 'textfield',
name: 'HTH',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
var hth = Ext.getCmp("S_HTH").getValue();
if (hth != "") {
Ext.getCmp("cxzt").setText(" 查询中... ");
_this.storeBS.load({
params: { condition: " CUSTNO<>'' and( CUSTNO like '%" + hth + "%' or CUSTNO like '%" + hth + "%' or MBLNO like '%" + hth + "%' or HBLNO like '%" + hth + "%')" }
,
callback: function (options, success, response) {
if (success) {
Ext.getCmp("cxzt").setText(" ");
}
}
});
}
}
}
}
}, { xtype: "label", id: "cxzt", text: ""
}],
columns: [
{
sortable: true, hidden: true,
dataIndex: 'GID',
header: 'GID',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'IO_GID',
header: 'IO_GID',
width: 80
},
{
dataIndex: 'SEQUENCE',
header: '序号',
width: 44,
editor: {
xtype: 'numberfield', //numberfield textfield
selectOnFocus: true
}
},
{
sortable: true,
dataIndex: 'BSNO',
header: '委托编号',
width: 100,
renderer: function (value, p, record) {
if (value == null || value == '')
return '';
else
return record.data.CUSTNO;
},
editor: this.comboxCUSTNO
}, {
sortable: true, id: "CUSTNO", hidden: true,
dataIndex: 'CUSTNO',
header: '委托编号',
width: 250
},
{
sortable: true,
dataIndex: 'MBLNO',
header: '主提单号',
width: 140,
renderer: function (value, p, record) {
if (value == null || value == '')
return '';
else
return record.data.MBLNO;
},
editor: this.comboxMBLNO
},
{
sortable: true,
dataIndex: 'HBLNO',
header: '分提单号/箱号',
width: 140,
renderer: function (value, p, record) {
if (value == null || value == '')
return '';
else
return record.data.HBLNO;
},
editor: this.comboxHBLNO
},
{
sortable: true,
dataIndex: 'CUSTOMERNAME',
header: '客户名称',
width: 80
},
{
sortable: true,
dataIndex: 'OP',
header: '操作人',
width: 80
},
{
sortable: true,
dataIndex: 'PORTDISCHARGE',
header: '目的港',
width: 60
},
{
sortable: true,
dataIndex: 'ReceiptName',
header: '单据类型',
width: 80,
editor: this.comboxReceiptName
},
{
sortable: true,
dataIndex: 'NeedType',
header: '单据操作',
width: 80,
editor: this.comboxNeedType
},
{
dataIndex: 'BillType', id: "BillType", hidden: true,
header: '提单提交方式',
renderer: function (value, p, record) {
if (value == null || value == '') return '';
else return record.data.BillTypeREF;
},
editor: this.comboxBillType,
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'BillTypeREF',
header: 'BillTypeREF',
width: 80
}, {
sortable: true, id: "ArrivalDate", hidden: true,
dataIndex: 'ArrivalDate',
header: '到港日',
width: 100
}, {
sortable: true, id: "Remark", hidden: true,
dataIndex: 'Remark',
header: '备注',
editor: {
xtype: 'textfield',
selectOnFocus: true
},
width: 350
}]
});
//////////////////////////////////////////////明细<<<< 收支费用明细 >>>>结束
///////////////////////下半部分 显示选中行所关联的业务目前已经收发的单据
//数据集
this.storeReceiptList = Ext.create('Ext.data.Store', {
model: 'ReceiptListmb',
remoteSort: false,
pruneModifiedRecords: true,
proxy: {
type: 'ajax',
url: '/Import/RPTReceiptList/GetDataList',
reader: {
id: 'RECEIPTNAME' + 'NEEDTYPE',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//表格
this.formReceiptList = new Ext.grid.GridPanel({
layout: 'border',
store: this.storeReceiptList,
enableHdMenu: false,
region: 'center',
trackResetOnLoad: true,
//split:true,
//height: 160,
title: '该业务目前的单据收发状态',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
//plugins: [this.cellEditing_S],
//selModel: this.CheckBoxModel_S,
selType: 'cellmodel',
tbar: [],
columns: [
{
sortable: true, hidden: true,
dataIndex: 'BSNO',
header: 'BSNO',
width: 80
},
{
sortable: true,
dataIndex: 'RECEIPTNAME',
header: '单据名',
width: 80
},
{
sortable: true,
dataIndex: 'NEEDTYPE',
header: '单据操作',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'NEED',
header: 'NEED',
width: 80
},
{
sortable: true,
dataIndex: 'NEEDREF',
header: '是否必需',
width: 80
},
{
sortable: true,
dataIndex: 'TRANCNO',
header: '快递号',
width: 80
},
{
sortable: true,
dataIndex: 'R_DATE',
header: '时间',
width: 120
},
{
sortable: true, hidden: true,
dataIndex: 'GID',
header: 'GID',
width: 80
},
{
sortable: true,
dataIndex: 'OPLBNAME',
header: '业务类型',
width: 80
},
/*{
sortable: true,
dataIndex: 'CREATETIME',
header: '业务时间',
width: 80
},*/
{
sortable: true,
dataIndex: 'CUSTNO',
header: '委托编号',
width: 80
},
{
sortable: true,
dataIndex: 'MBLNO',
header: '主提单号',
width: 80
},
{
sortable: true,
dataIndex: 'HBLNO',
header: '分提单号',
width: 80
},
{
sortable: true,
dataIndex: 'CUSTOMERNAME',
header: '委托单位',
width: 80
},
{
sortable: true,
dataIndex: 'PORTLOAD',
header: '装货港',
width: 80
},
{
sortable: true,
dataIndex: 'PORTDISCHARGE',
header: '卸货港',
width: 80
},
{
sortable: true,
dataIndex: 'COMPANY',
header: '分公司',
width: 80
}]
});
/////////////////////////////////end
//公共按钮Toolbar:panelBtn
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) {
this.Save('2');
},
scope: this
}, '-',
{
// id: "saveandclose",
text: "关闭",
handler: function (button, event) {
window.close();
},
scope: this
}, '-', {
text: "导出Excel",
id: "btnExportExcel",
iconCls: 'btnexportexcel',
handler: function (button, event) {
this.onExportClick(button, event);
},
scope: this
}, '-',
{
// id: "saveandclose",
text: "打印",
handler: function (button, event) {
this.DoPrint();
},
scope: this
}
]
}); //end 按钮Toolbar
//布局
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 30,
items: [this.panelBtn]
});
this.panelFee = new Ext.Panel({
layout: "border",
region: 'north',
margin: '1 1',
height: 230,
split: true,
items: [this.panelTop, this.formReceiptBody]
});
this.panelPayBody = new Ext.Panel({
layout: "border",
region: 'center',
split: true,
height: 300,
margin: '1 1',
items: [this.formEdit, this.formReceiptList]
});
/*
this.panelBottom = new Ext.Panel({
layout: "border",
region: 'south',
items: [this.formEdit, this.panelPayBody
]
});*/
Ext.apply(this, {
items: [this.panelTop, this.panelFee, this.panelPayBody]
});
parentWin = window.parent.opener;
this.InitData();
//集中绑定事件
this.formReceiptBody.on('edit', function (editor, e, eOpts) {
this.ReceiptAfterEdit(editor, e, eOpts);
}, this);
//选择load
this.formReceiptBody.getSelectionModel().on('select', function (model, record, index) {
var BSNO = record.data.BSNO;
//this.storeBodyChFee.load({ params: { billno: ContractNo} });
this.storeReceiptList.load({ params: { start: 0, limit: this.PageSize, condition: " BSNO='" + BSNO + "' and gid is not null "} });
}, this);
}, //end initUIComponents
parentfunction: function (button, event) {
var ret1 = window.parent.opener.OprationSwap();
// alert(this.First);
ret1[3]();
},
reLine: function (button, event) {
var _L = 1;
this.storeReceiptBody.each(function (record) {
var ln = _L + "";
_L = _L + 1;
record.set('SEQUENCE', ln);
});
},
onAddReceiptClick: function (button, event, type) {
var store = null;
store = this.storeReceiptBody;
var record = null;
var i = this.storeReceiptBody.getCount();
var linenum = this.storeReceiptBody.getCount() + 1;
var _r = this.reLine();
if (i > 0) {
var member = this.storeReceiptBody.getAt(i - 1);
record = Ext.create('ReceiptIOBodymb', {
GID: NewGuid(),
IO_GID: "",
SEQUENCE: linenum,
ReceiptName: member.data.ReceiptName,
NeedType: member.data.NeedType,
BSNO: "",
Receipt_GID: "",
CUSTNO: "",
MBLNO: ""
});
} else {
record = Ext.create('ReceiptIOBodymb', {
GID: NewGuid(),
SEQUENCE: linenum,
IO_GID: "",
ReceiptName: "",
NeedType: "",
BSNO: "",
Receipt_GID: "",
CUSTNO: "",
MBLNO: ""
});
}
store.add(record);
cellediting = this.cellEditing;
var n = store.getCount();
cellediting.startEditByPosition({ row: n - 1, column: 2 });
},
onDelReceiptClick: function (button, event) {
var selectedRecords = this.formReceiptBody.selModel.getSelection();
Ext.MessageBox.confirm('提示', '确定删除记录吗?', function (btn) {
if (btn == 'yes') {
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.IO_GID != "" || rec.IO_GID != "*") //如果是新增但没有保存的数据,没有必要提交到后台
{
this.BodyDel.push(rec);
}
this.storeReceiptBody.remove(selectedRecords[i]);
}
var _r = this.reLine();
}
}, this);
//aftereditform();
},
ReceiptAfterEdit: function (editor, e, eOpts) {
//需要自己实现里面的事件
if (COMPANYID == "" || USERID == "") {
alert("登录信息不全,请退出重新登录");
returen;
}
if (e.field == 'BSNO') {
var BSrecords = DsStoreQueryBy(this.storeBS, 'BSNO', e.value);
if (BSrecords.getCount() > 0) {
var BSdata = BSrecords.getAt(0).data;
e.record.set('BSNO', BSdata.BSNO);
e.record.set('MBLNO', BSdata.MBLNO);
e.record.set('CUSTNO', BSdata.CUSTNO);
e.record.set('OPLB', BSdata.OPLB);
e.record.set('HBLNO', BSdata.HBLNO);
} else {
e.record.set('BSNO', '');
e.record.set('MBLNO', '');
e.record.set('CUSTNO', '');
e.record.set('OPLB', '');
e.record.set('HBLNO', '');
}
if (BSdata.OPLB == "import_main") {
Ext.getCmp("Remark").show();
Ext.getCmp("BillType").show();
Ext.getCmp("ArrivalDate").show();
this.LoadRemark(BSdata.BSNO, e.record);
//var Remark = this.LoadRemark(BSdata.BSNO);
//e.record.set('Remark', Remark);
}
}
if (e.field == 'MBLNO') {
var BSrecords = DsStoreQueryBy(this.storeBS, 'MBLNO', e.value);
if (BSrecords.getCount() > 0) {
var BSdata = BSrecords.getAt(0).data;
e.record.set('BSNO', BSdata.BSNO);
e.record.set('MBLNO', BSdata.MBLNO);
e.record.set('CUSTNO', BSdata.CUSTNO);
e.record.set('OPLB', BSdata.OPLB);
//e.record.set('Remark', BSdata.Remark);
} else {
e.record.set('BSNO', '');
e.record.set('MBLNO', '');
e.record.set('CUSTNO', '');
e.record.set('OPLB', '');
//e.record.set('Remark', '');
}
if (BSdata.OPLB == "import_main") {
Ext.getCmp("Remark").show();
Ext.getCmp("BillType").show();
Ext.getCmp("ArrivalDate").show();
this.LoadRemark(BSdata.BSNO, e.record);
//var Remark = this.LoadRemark(BSdata.BSNO);
//e.record.set('Remark', Remark);
}
}
if (e.field == 'HBLNO') {
var BSrecords = DsStoreQueryBy(this.storeBS, 'HBLNO', e.value);
if (BSrecords.getCount() > 0) {
var BSdata = BSrecords.getAt(0).data;
e.record.set('BSNO', BSdata.BSNO);
e.record.set('MBLNO', BSdata.MBLNO);
e.record.set('CUSTNO', BSdata.CUSTNO);
e.record.set('OPLB', BSdata.OPLB);
//e.record.set('Remark', BSdata.Remark);
} else {
e.record.set('BSNO', '');
e.record.set('MBLNO', '');
e.record.set('CUSTNO', '');
e.record.set('OPLB', '');
//e.record.set('Remark', '');
}
if (BSdata.OPLB == "import_main") {
Ext.getCmp("Remark").show();
Ext.getCmp("BillType").show();
Ext.getCmp("ArrivalDate").show();
this.LoadRemark(BSdata.BSNO, e.record);
//var Remark = this.LoadRemark(BSdata.BSNO);
//e.record.set('Remark', Remark);
}
}
if (e.field == 'BillType') {
var BillTyperecords = DsStoreQueryBy(this.storeBillType, 'EnumValueId', e.value);
if (BillTyperecords.getCount() > 0) {
var BillTypeDate = BillTyperecords.getAt(0).data;
e.record.set('BillTypeREF', BillTypeDate.EnumValueName);
} else {
e.record.set('BillTypeREF', '');
}
}
},
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') + "'";
}
else {
}
this.LoadData(this.OpStatus, condition);
}, //end InitData
//载入数据
LoadData: function (OpStatus, condition) {
if (COMPANYID == "" || USERID == "") {
alert("登录信息不全,请退出重新登录");
return;
}
this.OpStatus = OpStatus;
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/Import/ReceiptIO/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.OP == "") { data.OP = SHOWNAME };
if (data.CREATETIME == "") { data.CREATETIME = currdate.format('yyyy-MM-dd hh:mm:ss') };
if (data.RecvCompany != "") {
var s = " LINKID in (select gid from [info_client] where SHORTNAME='" + data.RecvCompany + "') ";
this.storeInfoClientContact.load({ params: { condition: s },
callback: function (r, options, success) {
if (success) {
if (this.storeInfoClientContact.getCount() > 0) {
var member = this.storeInfoClientContact.getAt(0);
} else {
this.comboxInfoClientContact.setValue('');
}
}
},
scope: this
});
}
var basicForm = this.formEdit.getForm();
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');
var _this = this;
this.storeReceiptBody.load({ params: { GID: GID }
, callback: function (records, options, success) {
var _show = false;
for (var i = 0; i < _this.storeReceiptBody.getCount(); i++) {
var _b = _this.storeReceiptBody.getAt(i).data;
if (_b.OPLB = "import_main") {
_show = true;
}
}
if (_show == true) {
Ext.getCmp("Remark").show();
Ext.getCmp("BillType").show();
Ext.getCmp("ArrivalDate").show();
}
}
});
}
}, // end LoadDate
LoadRemark: function (BSNO, record) {
/*
var Remark = "";
Ext.Ajax.request({
async: false,
waitMsg: '正在查询主表数据...',
url: '/Import/ReceiptIO/GetRemark',
params: {
BSNO: BSNO
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
var data = result.data;
Remark = data[0].Remark.toString();
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
}); //request over
return Remark;*/
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/Import/XXH/GetData',
params: {
handle: 'edit',
condition: " M.contractno='" + BSNO + "' "
},
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;
}
data = result.data;
record.set('Remark', data.Receiptremark);
record.set('BillType', data.BillType);
record.set('ArrivalDate', data.ArrivalDate);
var BillTyperecords = DsStoreQueryBy(this.storeBillType, 'EnumValueId', data.BillType);
if (BillTyperecords.getCount() > 0) {
var BillTypeDate = BillTyperecords.getAt(0).data;
record.set('BillTypeREF', BillTypeDate.EnumValueName);
} else {
record.set('BillTypeREF', '');
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
}); //request over
}, // end Load
checkedit: function (status) {
},
Save: function (type) {
var Amount_ALL = 0;
var basicForm = this.formEdit.getForm();
if (!basicForm.isValid()) {
return;
}
var data = this.formEdit.getForm().getValues();
var GID = data.GID;
if (COMPANYID == "" || USERID == "") {
alert("登录信息不全,请退出重新登录");
return;
}
var Bodydatas = [];
for (var i = 0; i < this.storeReceiptBody.getCount(); i += 1) {
var member = this.storeReceiptBody.getAt(i);
if (member.data.BSNO != "") {
Bodydatas.push(member);
}
}
//单据收发明细
//var Body = ConvertRecordsToJson(Bodydatas);
var Body = ConvertRecordsToJsonAll(Bodydatas);
var DelBody = ConvertRecordsToJsonAll(this.BodyDel);
var _this = this;
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Import/ReceiptIO/Save',
scope: this,
async: false,
params: {
OpStatus: this.OpStatus,
data: Ext.JSON.encode(data),
Body: Body,
DelBody: DelBody
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.BodyDel = []; //清空删除字段
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('ReceiptIOmb', 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));
//alert(name + " " + editp.get(name));
}
}
}, this);
this.editRecord.commit();
//this.onRefreshClick(button, event);
}
this.storeReceiptBody.commitChanges();
if (type == '0') {
this.OpStatus = 'edit';
//basicForm.findField('Feeid').setDisabled(false);
//this.storeApp.load({ params: { condition: this.editRecord.get('ContractNo')} });
//this.storeCargo.load({ params: { condition: this.editRecord.get('ContractNo')} });
//basicForm.findField('Feeid').setDisabled(true);
this.storeReceiptBody.load({ params: { GID: this.editRecord.get('GID')} });
} 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
onExportClick: function (button, event) {
GridExportExcelPage(this.formReceiptBody);
}
, 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("CREATETIME").getRawValue();
var printType = 'ReceiptList';
//
var sql1 = " select hth,buyer,OP,(select name from company where gid=M.company) company,stt,M.ArrivalDate,substring(cc.country,0,(charindex('(',cc.country)) ) country ,dbo.f_str(m.ContractNo) ";
var sql1 = sql1 + " ,(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=6 and EnumValueID=M.Billtype) as BilltypeREF ";
var sql1 = sql1 + " ,Receiptremark,case M.ReceiptStatus when 1 then '单据完备' else '' end ReceiptStatusRef ";
var sql1 = sql1 + " ,M.remark ";
var sql1 = sql1 + " from Import_main M ";
var sql1 = sql1 + " left join code_country cc on cc.COUNTRYID=m.countryid ";
var sql1 = sql1 + " where M.ContractNo in(select BSNO from OP_Receipt_IO_body where IO_GID='" + GID + "' ) ";
var sql2 = " select op,(select fullname from company where name=v1.companyname) companyname ";
var sql2 = sql2 + " ,ub.OFFICEPHONE ";
var sql2 = sql2 + " ,o.RecvCompany,o.RecvName,c.TEL,o.CREATETIME,o.TRANCNO ";
var sql2 = sql2 + " from OP_Receipt_IO o ";
var sql2 = sql2 + " left join vw_user V1 on v1.showname=o.op and v1.COMPANYID=o.CORPID ";
var sql2 = sql2 + " left join info_client_contact c on c.SHOWNAME=o.RecvName and c.LINKID=(select gid from info_client where SHORTNAME=o.recvcompany) ";
var sql2 = sql2 + " left join [user_baseinfo] ub on V1.userid =ub.userid ";
var sql2 = sql2 + " where o.GID ='" + GID + "' ";
var sql3 = " SELECT B.SEQUENCE,b.GID,b.IO_GID,b.BSNO,(select Custno from v_op_bs where BSNO=B.bsno) CUSTNO ";
sql3 = sql3 + " ,vb.MBLNO,vb.CUSTOMERNAME ,Receipt_GID,ReceiptName,NeedType ";
sql3 = sql3 + " ,case (select oplb from v_op_bs where bsno=b.BSNO) when 'import_main' then (select receiptremark from import_main where contractno=b.bsno) else '' end remark ";
sql3 = sql3 + " ,(select oplb from v_op_bs where bsno=b.BSNO) OPLB ";
sql3 = sql3 + " ,vb.PORTDISCHARGE,vb.HBLNO,vb.ETD,(select name from company where gid=vb.CORPID) company ";
sql3 = sql3 + " from op_Receipt_IO_Body B ";
sql3 = sql3 + " left join v_op_bs vb on vb.BSNO=b.bsno ";
sql3 = sql3 + " where b.IO_GID ='" + GID + "' ";
var sql4 = "";
var sql5 = "";
var sql6 = "";
PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6);
}
});