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.

1122 lines
33 KiB
JavaScript

Ext.namespace('Shipping');
Shipping.PiLiangServiceFeeEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.PiLiangServiceFeeEdit.superclass.constructor.call(this);
};
Ext.extend(Shipping.PiLiangServiceFeeEdit, Ext.Panel, {
PageSize: 15,
ParentWin: null,
OprationStatus: null, //仅当弹出界面时使用
EditRecord: null,
strbsno: '',
initUIComponents: function () {
this.storeServiceFeeTemplete = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsCodeServiceFeeTemplate',
proxy: { url: '/MvcShipping/MsCodeServiceFeeTemplate/GetDataList' }
});
this.storeServiceFeeTemplete.load({ params: { condition: "OPTYPE='5'"} });
this.comboxServiceFeeTemplete = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeServiceFeeTemplete,
forceSelection: true,
name: 'GID',
valueField: 'GID',
displayField: 'NAME',
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (records.length > 0) {
var GID = records[0].data.GID;
this.storeBodyList.load({ params: { condition: " TemplateID='" + GID + "'"} });
var CUSTOMERNAME = this.formEdit.getForm().findField('CUSTOMERNAME');
CUSTOMERNAME.setValue(records[0].data.CUSTOMERNAME);
var DESCRIPTION = this.formEdit.getForm().findField('DESCRIPTION');
DESCRIPTION.setValue(records[0].data.DESCRIPTION);
}
}
}
});
//编辑form
this.formEdit = Ext.widget('form', {
region: 'north',
frame: true,
height: 55,
bodyPadding: 5,
autoScroll: true,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 90,
msgTarget: 'qtip'
},
items: [
{//fieldset 1
xtype: 'fieldset',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxServiceFeeTemplete, {
fieldLabel: '客户名称',
readOnly: true,
name: 'CUSTOMERNAME'
}, {
fieldLabel: '模板说明',
readOnly: true,
name: 'DESCRIPTION'
}
]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
}); //end this.formEdit
//#region 明细表
//明细表表格相关
//明细表-数据集
this.storeBodyList = Ext.create('Ext.data.Store', {
model: 'MsCodeServiceFeeTemplateDetail',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsCodeServiceFeeTemplate/GetBodyList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//明细表表格
this.gridListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.gridList = new Ext.grid.GridPanel({
store: this.storeBodyList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
selType: 'cellmodel',
columns: [{
sortable: true,
dataIndex: 'GID',
header: 'GID',
hidden: true,
width: 100
}, {
sortable: true,
dataIndex: 'TemplateID',
header: 'TemplateID',
hidden: true,
width: 100
}, {
sortable: true,
dataIndex: 'CustomerType',
header: '客户类别',
width: 160
}, {
sortable: true,
dataIndex: 'CustomerName',
header: '客户名称',
width: 160
}, {
sortable: true,
dataIndex: 'OPField',
header: '服务项目',
renderer: function (value, p, record) {
if (value == null || value == '')
return '';
else
return record.data.SERVICENAME;
},
width: 160
}, {
sortable: true,
dataIndex: 'FeeName',
header: '费用名称',
width: 160
}, {
sortable: true,
dataIndex: 'FeeType',
header: '收/付',
width: 160,
renderer: function (value, p, record) {
if (value == 2)
return '付';
else
return '收';
}
}, {
sortable: true,
dataIndex: 'Unit',
header: '单位标准',
width: 60
}, {
sortable: true,
dataIndex: 'UnitPrice',
header: '单价',
width: 80,
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;
}
}, {
sortable: true,
dataIndex: 'Currency',
header: '币别',
width: 40
}, {
sortable: true,
dataIndex: 'ExchangeRate',
header: '汇率',
width: 60
}, {
sortable: true,
dataIndex: 'Remark',
header: '备注',
width: 150
}
]
});
this.panelService = new Ext.Panel({
title: '费用方案明细',
layout: "border",
region: 'center',
margin: '5 10',
items: [this.gridList]
});
//#endregion 明细表
this.girdcolums = [{
sortable: true,
dataIndex: 'BSNO',
header: '业务编号',
hidden: true,
width: 150
}, {
sortable: true,
dataIndex: 'CUSTNO',
header: '委托编号',
width: 130
}, {
sortable: true,
dataIndex: 'CUSTOMNO',
header: '报关单号',
width: 120
}, {
sortable: true,
dataIndex: 'BSDATE',
header: '录入日期',
width: 90
},
{
sortable: true,
id: '',
dataIndex: 'BSSTATUSREF',
header: '业务锁定',
align: 'center',
width: 60,
renderer: function (value, cellmeta) {
if (value == '锁定') {
return "<img src='../../../../TruckMng/Content/Images/Lock.png' />";
}
}
},
{
sortable: true,
id: '',
dataIndex: 'FEESTATUSREF',
header: '费用锁定',
align: 'center',
width: 60,
renderer: function (value, cellmeta) {
if (value == '锁定') {
return "<img src='../../../../TruckMng/Content/Images/Lock.png' />";
}
}
}, {
sortable: true,
dataIndex: 'BSTYPEREF',
header: '运输类型',
width: 90
}, {
sortable: true,
dataIndex: 'ACCDATE',
header: '会计期间',
width: 80
}, {
sortable: true,
dataIndex: 'OPDATE',
header: '业务日期',
width: 80
}, {
sortable: true,
dataIndex: 'MBLNO',
header: '提单号',
width: 100
}, {
sortable: true,
dataIndex: 'HBLNO',
header: '分提单号',
width: 100
}, {
sortable: true,
dataIndex: 'CUSTOMERNAME',
header: '委托单位',
width: 100
}, {
sortable: true,
dataIndex: 'ENTERP',
header: '经营单位',
width: 100
}, {
sortable: true,
dataIndex: 'BSTYPE',
header: '业务类型',
hidden: true,
width: 80
}, {
sortable: true,
dataIndex: 'VESSEL',
header: '船名',
width: 100
}, {
sortable: true,
dataIndex: 'VOYNO',
header: '航次',
width: 40
}, {
sortable: true,
dataIndex: 'ETD',
header: '开船日期',
width: 90
}, {
sortable: true,
dataIndex: 'ETA',
header: '到港日期',
width: 90
}, {
sortable: true,
dataIndex: 'PORTLOAD',
header: '装货港',
width: 100
}, {
sortable: true,
dataIndex: 'PORTDISCHARGE',
header: '卸货港',
width: 100
}, {
sortable: true,
dataIndex: 'OP',
header: '操作',
width: 80
}, {
sortable: true,
dataIndex: 'SALE',
header: '销售',
width: 80
}, {
sortable: true,
dataIndex: 'CUSTOMSER',
header: '报关行',
width: 80
}, {
sortable: true,
dataIndex: 'BSSOURCE',
header: '业务来源',
width: 100
}, {
sortable: true,
dataIndex: 'BSSOURCEDETAIL',
header: '来源明细',
width: 80
}, {
sortable: true,
dataIndex: 'PKGS',
header: '件数',
width: 80
}, {
sortable: true,
dataIndex: 'KGS',
header: '重量',
width: 80
}, {
sortable: true,
dataIndex: 'NETWEIGHT',
header: '净重',
width: 80
}, {
sortable: true,
dataIndex: 'CBM',
header: '尺码',
width: 80
}, {
sortable: true,
dataIndex: 'CUSTOMDATE',
header: '报关日期',
width: 100
}, {
sortable: true,
dataIndex: 'INSPECTIONNO',
header: '商检单号',
width: 100
}, {
sortable: true,
dataIndex: 'INSPECTIONDATE',
header: '商检日期',
hidden: true,
width: 80
}, {
sortable: true,
dataIndex: 'INVNO',
header: '发票号',
width: 80
}, {
sortable: true,
dataIndex: 'CONTRACTNO',
header: '合同号',
width: 160
}, {
sortable: true,
dataIndex: 'ARCOUNTRY',
header: '货源国别',
width: 80
}, {
sortable: true,
dataIndex: 'GOODSOURCE',
header: '货源地',
width: 80
}, {
sortable: true,
dataIndex: 'DOCNO',
header: '批准文号',
width: 80
}, {
sortable: true,
dataIndex: 'TRADETYPE',
header: '贸易方式',
width: 80
}, {
sortable: true,
dataIndex: 'SERVICE1',
header: '服务项目1',
hidden: true,
renderer: function (value, meta, record) {
if (value == '未完成') {
meta.tdCls = 'nopass';
}
return value;
},
width: 100
}, {
sortable: true,
dataIndex: 'SERVICE2',
header: '服务项目2',
hidden: true,
renderer: function (value, meta, record) {
if (value == '未完成') {
meta.tdCls = 'nopass';
}
return value;
},
width: 100
}, {
sortable: true,
dataIndex: 'SERVICE3',
header: '服务项目3',
hidden: true,
renderer: function (value, meta, record) {
if (value == '未完成') {
meta.tdCls = 'nopass';
}
return value;
},
width: 100
}, {
sortable: true,
dataIndex: 'SERVICE4',
header: '服务项目4',
hidden: true,
renderer: function (value, meta, record) {
if (value == '未完成') {
meta.tdCls = 'nopass';
}
return value;
},
width: 100
}, {
sortable: true,
dataIndex: 'SERVICE5',
header: '服务项目5',
hidden: true,
renderer: function (value, meta, record) {
if (value == '未完成') {
meta.tdCls = 'nopass';
}
return value;
},
width: 100
}, {
sortable: true,
dataIndex: 'SERVICE6',
header: '服务项目6',
hidden: true,
renderer: function (value, meta, record) {
if (value == '未完成') {
meta.tdCls = 'nopass';
}
return value;
},
width: 100
}, {
sortable: true,
dataIndex: 'SERVICE7',
header: '服务项目7',
hidden: true,
renderer: function (value, meta, record) {
if (value == '未完成') {
meta.tdCls = 'nopass';
}
return value;
},
width: 100
}, {
sortable: true,
dataIndex: 'SERVICE8',
header: '服务项目8',
hidden: true,
renderer: function (value, meta, record) {
if (value == '未完成') {
meta.tdCls = 'nopass';
}
return value;
},
width: 100
}, {
sortable: true,
dataIndex: 'SERVICE9',
header: '服务项目9',
hidden: true,
renderer: function (value, meta, record) {
if (value == '未完成') {
meta.tdCls = 'nopass';
}
return value;
},
width: 100
}, {
sortable: true,
dataIndex: 'SERVICE10',
header: '服务项目10',
hidden: true,
renderer: function (value, meta, record) {
if (value == '未完成') {
meta.tdCls = 'nopass';
}
return value;
},
width: 100
}, {
sortable: true,
dataIndex: 'SERVICE11',
header: '服务项目11',
hidden: true,
renderer: function (value, meta, record) {
if (value == '未完成') {
meta.tdCls = 'nopass';
}
return value;
},
width: 100
}, {
sortable: true,
dataIndex: 'SERVICE12',
header: '服务项目12',
hidden: true,
renderer: function (value, meta, record) {
if (value == '未完成') {
meta.tdCls = 'nopass';
}
return value;
},
width: 100
}, {
sortable: true,
dataIndex: 'SERVICE13',
header: '服务项目13',
hidden: true,
renderer: function (value, meta, record) {
if (value == '未完成') {
meta.tdCls = 'nopass';
}
return value;
},
width: 100
}, {
sortable: true,
dataIndex: 'SERVICE14',
header: '服务项目14',
hidden: true,
renderer: function (value, meta, record) {
if (value == '未完成') {
meta.tdCls = 'nopass';
}
return value;
},
width: 100
}, {
sortable: true,
dataIndex: 'SERVICE15',
header: '服务项目15',
hidden: true,
renderer: function (value, meta, record) {
if (value == '未完成') {
meta.tdCls = 'nopass';
}
return value;
},
width: 100
}, {
sortable: true,
dataIndex: 'SERVICE16',
header: '服务项目16',
hidden: true,
renderer: function (value, meta, record) {
if (value == '未完成') {
meta.tdCls = 'nopass';
}
return value;
},
width: 100
}, {
sortable: true,
dataIndex: 'IsSERVICE1',
header: '服务项目1',
hidden: true,
width: 100,
renderer: function (value, meta, record) {
if (value == true)
return '√';
else
return '';
}
}, {
sortable: true,
dataIndex: 'IsSERVICE2',
header: '服务项目2',
hidden: true,
width: 100,
renderer: function (value, meta, record) {
if (value == true)
return '√';
else
return '';
}
}, {
sortable: true,
dataIndex: 'IsSERVICE3',
header: '服务项目3',
hidden: true,
width: 100,
renderer: function (value, meta, record) {
if (value == true)
return '√';
else
return '';
}
}, {
sortable: true,
dataIndex: 'IsSERVICE4',
header: '服务项目4',
hidden: true,
width: 100,
renderer: function (value, meta, record) {
if (value == true)
return '√';
else
return '';
}
}, {
sortable: true,
dataIndex: 'IsSERVICE5',
header: '服务项目5',
hidden: true,
width: 100,
renderer: function (value, meta, record) {
if (value == true)
return '√';
else
return '';
}
}, {
sortable: true,
dataIndex: 'IsSERVICE6',
header: '服务项目6',
hidden: true,
width: 100,
renderer: function (value, meta, record) {
if (value == true)
return '√';
else
return '';
}
}, {
sortable: true,
dataIndex: 'IsSERVICE7',
header: '服务项目7',
hidden: true,
width: 100,
renderer: function (value, meta, record) {
if (value == true)
return '√';
else
return '';
}
}, {
sortable: true,
dataIndex: 'IsSERVICE8',
header: '服务项目8',
hidden: true,
width: 100,
renderer: function (value, meta, record) {
if (value == true)
return '√';
else
return '';
}
}, {
sortable: true,
dataIndex: 'IsSERVICE9',
header: '服务项目9',
hidden: true,
width: 100,
renderer: function (value, meta, record) {
if (value == true)
return '√';
else
return '';
}
}, {
sortable: true,
dataIndex: 'IsSERVICE10',
header: '服务项目10',
hidden: true,
width: 100,
renderer: function (value, meta, record) {
if (value == true)
return '√';
else
return '';
}
}, {
sortable: true,
dataIndex: 'IsSERVICE11',
header: '服务项目11',
hidden: true,
width: 100,
renderer: function (value, meta, record) {
if (value == true)
return '√';
else
return '';
}
}, {
sortable: true,
dataIndex: 'IsSERVICE12',
header: '服务项目12',
hidden: true,
width: 100,
renderer: function (value, meta, record) {
if (value == true)
return '√';
else
return '';
}
}, {
sortable: true,
dataIndex: 'IsSERVICE13',
header: '服务项目13',
hidden: true,
width: 100,
renderer: function (value, meta, record) {
if (value == true)
return '√';
else
return '';
}
}, {
sortable: true,
dataIndex: 'IsSERVICE14',
header: '服务项目14',
hidden: true,
width: 100,
renderer: function (value, meta, record) {
if (value == true)
return '√';
else
return '';
}
}, {
sortable: true,
dataIndex: 'IsSERVICE15',
header: '服务项目15',
hidden: true,
width: 100,
renderer: function (value, meta, record) {
if (value == true)
return '√';
else
return '';
}
}, {
sortable: true,
dataIndex: 'IsSERVICE16',
header: '服务项目16',
hidden: true,
width: 100,
renderer: function (value, meta, record) {
if (value == true)
return '√';
else
return '';
}
}
];
this.storeBodyAddList = Ext.create('Ext.data.Store', {
model: 'MsOpApply'
});
//明细表表格
this.gridAddList = new Ext.grid.GridPanel({
store: this.storeBodyAddList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
columns: this.girdcolums
});
parentWin = window.parent.opener;
this.InitData();
//#endregion
//#region 按钮ToolBar
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
text: "新建",
iconCls: "btnadd",
handler: function (button, event) {
this.addDetail();
},
scope: this
},
{
text: "删除",
iconCls: "btndelete",
handler: function (button, event) {
this.deleteDetail();
},
scope: this
},
'-',
{
text: "生成费用",
iconCls: "btnsave",
handler: function (button, event) {
this.onPostDetailClick(button, event);
},
scope: this
}
]
});
//#endregion
//#region 布局
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 250,
items: [this.panelBtn, this.formEdit, this.gridList]
});
this.panelFee = new Ext.Panel({
layout: "border",
region: "center",
items: [
this.gridAddList
]
});
Ext.apply(this, {
items: [this.panelTop, this.panelFee]
});
//#endregion
this.InitGrid();
// this.SetBtnRight();
}, //end initUIComponents
InitData: function () {
var condition = '';
_this = this;
if (parentWin) {
var ret = parentWin.OprationSwap();
var AddList = ret[5];
for (var j = 0; j < AddList.getCount(); j += 1) {
var memberbody = AddList.getAt(j);
this.storeBodyAddList.add(memberbody);
};
}
},
InitGrid: function () {
var agirdcolums = this.girdcolums;
this.storecodeservice = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsCodeOpService',
proxy: { url: '/MvcShipping/MsCodeOpService/GetDataList' }
});
this.storecodeservice.load({ params: { condition: "OPTYPE='5'" },
callback: function (r, options, success) {
if (success) {
if (r.length != 0) {
for (i = 0; i < this.storecodeservice.getCount(); i += 1) {
var memberyf = this.storecodeservice.getAt(i);
for (var j = 0; j < agirdcolums.length; j++) {
if (agirdcolums[j].dataIndex == memberyf.data.OPField) {
agirdcolums[j].header = memberyf.data.SERVICENAME + '(状态)';
agirdcolums[j].hidden = false;
} else if (agirdcolums[j].dataIndex == 'Is' + memberyf.data.OPField) {
agirdcolums[j].header = memberyf.data.SERVICENAME;
agirdcolums[j].hidden = false;
}
}
};
}
this.gridAddList.reconfigure(this.storeBodyAddList, agirdcolums);
}
},
scope: this
});
},
addDetail: function () {
var newSerialno = DsGetNewSerialNo(this.storeList, 0);
var n = this.storeList.getCount();
var myDate = new Date();
var mydatestr = Ext.util.Format.date(myDate, 'Y-m-d');
var record = Ext.create('MsOpStatus', {
ST_ID: NewGuid(),
BSNO: '*',
ORDNO: n + 1,
STATUS: '',
COMPTIME: mydatestr,
COMPOP: SHOWNAME,
REMARK: ''
});
this.storeList.add(record);
var n = this.storeList.getCount();
this.gridListCellEditing.startEditByPosition({ row: n - 1, column: 2 });
},
deleteDetail: function () {
var selectedRecords = this.CheckBoxModel.selected.items;
Ext.MessageBox.confirm('提示', '确定要删除选中的明细吗?', function (btn) {
if (btn == 'yes') {
var bodyDatas = [];
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.BSNO == "" || rec.BSNO == "*") //如果是新增但没有保存的数据,没有必要提交到后台
{
this.storeList.remove(selectedRecords[i]);
} else {
bodyDatas.push(rec);
}
}
var jsonBody = ConvertRecordsToJsonAll(bodyDatas);
_this = this;
Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/MvcShipping/MsOpStatus/Delete',
params: {
bsno: _this.BsNo,
data: jsonBody
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
for (var i = 0; i < selectedRecords.length; i++) {
this.storeList.remove(selectedRecords[i]);
}
Ext.Msg.show({ title: '提示', msg: jsonresult.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
}
else {
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
}
},
failure: function (response, options) {
Ext.Msg.show({ title: '警告', msg: '服务器响应出错,请重试', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
},
success: function (response, options) {
},
scope: this
}); //end Ext.Ajax.request
}
}, this);
},
onPostDetailClick: function (button, event) {
var bodyBillDatas = [];
for (i = 0; i < this.storeBodyAddList.getCount(); i += 1) {
var memberyf = this.storeBodyAddList.getAt(i);
bodyBillDatas.push(memberyf);
};
var jsonbodyBill = ConvertRecordsToJsonAll(bodyBillDatas);
var bodyFeeDatas = [];
for (i = 0; i < this.storeBodyList.getCount(); i += 1) {
var memberyf = this.storeBodyList.getAt(i);
bodyFeeDatas.push(memberyf);
};
var jsonbodyFee = ConvertRecordsToJsonAll(bodyFeeDatas);
_this = this;
Ext.Msg.wait('正在生成数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在生成数据...',
url: '/MvcShipping/MsOpApply/PiliangServiceFee',
scope: this,
params: {
bill: jsonbodyBill,
fee: jsonbodyFee
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
Ext.Msg.show({ title: '提示', msg: jsonresult.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
} 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
});
}
}
});
}
});