You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/Areas/MvcShipping/Viewsjs/MsOpCtnRepair/MsOpCtnRepairEdit.js

886 lines
32 KiB
JavaScript

3 years ago
Ext.namespace('Shipping');
Shipping.MsOpCtnRepairEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsOpCtnRepairEdit.superclass.constructor.call(this);
};
var RepairID='';
var IsLock = '0';
var ShuiLv = 0;
var SumGongShiFei=0;
var SumCaiLiaoFei=0;
Ext.extend(Shipping.MsOpCtnRepairEdit, Ext.Panel, {
ParentWin: null,
OpStatus: 'add',
storeList: null,
EditRecord: null,
status: null,
feeType: 0,
StoreFee: null,
initUIComponents: function () {
this.serialNo = 0;
this.workSerialNo = 0;
this.bodyDel = [];
//#region 编辑form
//枚举参照相关(编辑form)
//箱主
this.storeCARRIER = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefListCARRIER' }
});
this.storeCARRIER.load({ params: { condition: "ISCARRIER='1'"} });
this.comboxCARRIER = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '箱主',
store: this.storeCARRIER,
name: 'XiangZhu',
valueField: 'CustName',
displayField: 'CodeAndName',
allowBlank: false
});
//场站
this.storeYARD = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefListYARD' }
});
this.storeYARD.load();
this.comboxYARD = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '场站名称',
store: this.storeYARD,
forceSelection: true,
name: 'ChangZhan',
valueField: 'CustName',
displayField: 'CodeAndName'
});
//箱型
this.storeCodeCtn = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CodeCtnModel',
proxy: { url: '/CommMng/BasicDataRef/GetCodeCtnList' }
});
this.storeCodeCtn.load();
this.comboxCTNTYPE = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '箱型',
store: this.storeCodeCtn,
name: 'XiangXing',
valueField: 'CTN',
displayField: 'CTN'
});
//币别
this.StoreCurr = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsFeeCurr',
proxy: { url: '/MvcShipping/MsChFee/GetFeeCurrList' }
});
this.StoreCurr.load({ params: { condition: ""} });
this.comboxCurr = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '币别',
store: this.StoreCurr,
name: 'BiBie',
valueField: 'CURR',
displayField: 'CURR'
});
//责任人
this.StoreZeRenRen = Ext.create('Ext.data.Store', {
fields: ['value', 'text']
});
this.StoreZeRenRen.add({ "value": "O", "text": "O" });
this.StoreZeRenRen.add({ "value": "T", "text": "T" });
this.comboxZeRenRen = Ext.create('DsExt.ux.RefTableCombox', {
store: this.StoreZeRenRen,
forceSelection: true,
name: 'ZeRenRen',
valueField: 'value',
displayField: 'text'
});
//是否维修
this.StoreIsRepair = Ext.create('Ext.data.Store', {
fields: ['value', 'text']
});
this.StoreIsRepair.add({ "value": "0", "text": "否" });
this.StoreIsRepair.add({ "value": "1", "text": "是" });
this.comboxIsRepair = Ext.create('DsExt.ux.RefTableCombox', {
store: this.StoreIsRepair,
forceSelection: true,
name: 'IsRepair',
valueField: 'value',
displayField: 'text'
});
//是否收费
this.StoreIsShouFei = Ext.create('Ext.data.Store', {
fields: ['value', 'text']
});
this.StoreIsShouFei.add({ "value": "0", "text": "否" });
this.StoreIsShouFei.add({ "value": "1", "text": "是" });
this.comboxIsShouFei = Ext.create('DsExt.ux.RefTableCombox', {
store: this.StoreIsShouFei,
forceSelection: true,
name: 'IsShouFei',
valueField: 'value',
displayField: 'text'
});
//表参照相关(编辑form)
//编辑form
this.formEdit = Ext.widget('form', {
title: '修箱信息',
region: 'center',
frame: true,
bodyPadding: 5,
autoScroll: true,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 90,
msgTarget: 'qtip'
},
items: [
{
xtype: 'fieldset',
defaultType: 'textfield',
layout: 'anchor',
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
{
fieldLabel: 'GID',
name: 'GID',
hidden:true
},
{
fieldLabel: '箱号',
name: 'XiangHao'
},
{
fieldLabel: '船名',
name: 'ChuanMing'
}, {
fieldLabel: '主提单号',
name: 'MBLNO'
}, {
fieldLabel: '修箱单号',
name: 'XiuXiangDanHao'
}, this.comboxCTNTYPE
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
this.comboxCARRIER, {
fieldLabel: '工时费',
name: 'GongShiFei'
},{
fieldLabel: '税率',
name: 'ShuiLv'
}, this.comboxCurr
, {
fieldLabel: '测量单位',
name: 'CeLiangDanWei'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxYARD, {
fieldLabel: '进场日期',
format: 'Y-m-d',
xtype: 'datefield',
flex: 1, name: 'JinChangRiQi',
allowBlank: false
}, {
fieldLabel: '修箱日期',
format: 'Y-m-d',
xtype: 'datefield',
flex: 1, name: 'XiuXiangRiQi',
allowBlank: false
}, {
fieldLabel: '造箱日期',
format: 'Y-m-d',
xtype: 'datefield',
flex: 1, name: 'ZaoXiangRiQi',
allowBlank: false
}, { xtype: 'hidden' }
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '场站描述',
name: 'ChangZhanSub'
}
]
}]
}
]
});
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
text: "保存",
iconCls: "btnsave",
id:'btnSave',
name:'btnSave',
handler: function (button, event) {
this.Save('0');
},
scope: this
},'-',
{
text: "锁定",
iconCls: 'new_lock',
id:'btnLock',
name:'btnLock',
handler: function (button, event) {
this.Save('2');
},
scope: this
},{
text: "解锁",
iconCls: 'new_lock',
id:'btnUnLock',
name:'btnUnLock',
handler: function (button, event) {
this.UnLock();
},
scope: this
},'-',{
text: "打印",
id: "btnprint",
iconCls: 'btnprint',
handler: function (button, event) {
this.onPrintClick(button, event);
},
scope: this
}
]
}); //end 按钮Toolbar
//#endregion
//#region 明细表
//明细表-数据集
this.storeBodyList = Ext.create('Ext.data.Store', {
model: 'OpCtnRepairDetailsModel',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsOpCtnRepair/GetDetailsList',
reader: {
root: 'data',
totalProperty: 'totalCount'
}
}
});
//明细表表格
this.gridListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.WMSCB = Ext.create('Ext.selection.CheckboxModel', { checkOnly: true });
this.gridList = new Ext.grid.GridPanel({
store: this.storeBodyList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
selModel: this.WMSCB,
plugins: [this.gridListCellEditing],
features: [{
ftype: 'summary'//Ext.grid.feature.Summary表格汇总特性
}],
selType: 'cellmodel',
tbar: [{
text: '增加修箱明细',
tooltip: '增加修箱明细',
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddDetailClick(button, event, 1);
},
scope: this
}, '-', {
text: '删除修箱明细',
tooltip: '删除修箱明细',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelDetailClick(button, event, 1);
},
scope: this
}],
columns: [{
sortable: true,
dataIndex: 'GID',
header: 'GID',
hidden: true,
width: 100
}, {
sortable: true,
dataIndex: 'RepairID',
header: 'RepairID',
hidden: true,
width: 100
}, {
sortable: true,
dataIndex: 'XiuXiangDanHao',
header: '修箱单号',
width: 95,
hidden:true
}, {
sortable: true,
dataIndex: 'XuHao',
header: '序号',
width: 95,
editor: {
xtype: 'numberfield',
}
}, {
sortable: true,
dataIndex: 'WeiXiuMiaoShu',
header: '维修描述',
width: 200,
editor: {
xtype: 'textfield',
}
}, {
sortable: true,
dataIndex: 'ShuLiang',
header: '数量',
width: 95,
editor: {
xtype: 'numberfield',
}
}, {
sortable: true,
dataIndex: 'ZeRenRen',
header: '责任人',
width: 95,
editor:this.comboxZeRenRen
}, {
sortable: true,
dataIndex: 'WeiXiuGongShi',
header: '维修工时',
width: 95,
editor: {
xtype: 'numberfield',
},
summaryType: 'sum',
summaryRenderer: function (value) {
return "小计:";
},
}, {
sortable: true,
dataIndex: 'GongShiFei',
header: '工时费',
width: 95,
renderer:function(value, cellmeta, record, rowIndex, columnIndex, store){
SumGongShiFei=0;
for (var i = 0; i < store.data.items.length; i++) {
var c = store.data.items[i].data;
if (!(c.IsRepair=="0"&&c.IsShouFei=="0")) {
SumGongShiFei+=c.GongShiFei;
}
}
if (record.data.IsRepair=="0"&&record.data.IsShouFei=="0") {
return "<div style=\"text-decoration:line-through;color:#FF0000\"><p style=\"color:#000000\">"+value+"</p></div>";
}else {
return "<p>"+value+"</p>";
}
},
summaryType: 'sum',
summaryRenderer: function (value) {
// SumGongShiFei = value;
return Ext.util.Format.number(SumGongShiFei, '0.00');
},
editor: {
xtype: 'numberfield',
}
}, {
sortable: true,
dataIndex: 'CaiLiaoFei',
header: '材料费',
renderer:function(value, cellmeta, record, rowIndex, columnIndex, store){
SumCaiLiaoFei=0;
for (var i = 0; i < store.data.items.length; i++) {
var c = store.data.items[i].data;
if (!(c.IsRepair=="0"&&c.IsShouFei=="0")) {
SumCaiLiaoFei+=c.CaiLiaoFei;
}
}
if (record.data.IsRepair=="0"&&record.data.IsShouFei=="0") {
return "<div style=\"text-decoration:line-through;color:#FF0000\"><p style=\"color:#000000\">"+value+"</p></div>";
}else {
return "<p>"+value+"</p>";
}
},
summaryType: 'sum',
summaryRenderer: function (value, summaryData, dataIndex) {
return Ext.util.Format.number(SumCaiLiaoFei, '0.00');
},
width: 95,
editor: {
xtype: 'numberfield',
}
}, {
sortable: true,
dataIndex: 'IsRepair',
header: '是否维修',
width: 95,
summaryType: 'sum',
summaryRenderer: function (value) {
var fee= (SumGongShiFei+SumCaiLiaoFei)*ShuiLv/100;
return '税费:'+Ext.util.Format.number(fee, '0.00');
},
editor: this.comboxIsRepair,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
return value == "0" ? "否" : "是";
}
}, {
sortable: true,
dataIndex: 'IsShouFei',
header: '是否收费',
width: 95,
editor: this.comboxIsShouFei,
summaryType: 'sum',
summaryRenderer: function (value) {
var fee= (SumGongShiFei+SumCaiLiaoFei)*ShuiLv/100;
var Sum=SumGongShiFei+SumCaiLiaoFei+fee;
return '总计:'+Ext.util.Format.number(Sum, '0.00');
},
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
return value == "0" ? "否" : "是";
}
}
]
});
this.panelService = new Ext.Panel({
title: '修箱明细',
layout: "border",
region: 'center',
margin: '5 10',
items: [this.gridList]
});
this.paneldetail = new Ext.Panel({
layout: "border",
region: "center",
items: [
this.panelService
]
});
//#region 费用信息
this.panelFee = new Shipping.FeeEditGrid({
region: 'center',
layout: 'border'
});
this.panelFee.panelDrChFee.anchor = '100% 40%';
this.panelFee.panelCrChFee.anchor = '100% 60%';
this.panelFee.stroplb = 'op_other';
this.panelFee.StoreCustType.add({ "SCUSTTYPE": "WTDW-委托单位", "CUSTTYPE": "委托单位", "CUSTNAME": "CUSTOMERNAME" });
this.panelFee.StoreCustType.add({ "SCUSTTYPE": "CD-车队", "CUSTTYPE": "车队", "CUSTNAME": "TRUCKNAME" });
this.panelFee.StoreCustType.add({ "SCUSTTYPE": "MDGDL-目的港代理", "CUSTTYPE": "目的港代理", "CUSTNAME": "AGENTNAME" });
this.panelFee.StoreCustType.add({ "SCUSTTYPE": "DCGS-订舱公司", "CUSTTYPE": "订舱公司", "CUSTNAME": "AGENTNAME" });
this.panelFee.StoreDrOpRange.load({ params: { optype: "modOtherRecvFeeManagement"} });
this.panelFee.StoreCrOpRange.load({ params: { optype: "modOtherPayFeeManagement"} });
this.panelFee.storeFeeNameRef.load({ params: { condition: ""} });
this.panelDrCrFee = new Ext.Panel({
layout: "border",
region: 'center',
animate: true,
// autoScroll: true,
// containerScroll: true,
frame: false,
items: [this.panelFee]
});
//#endregion
this.page_1 = new Ext.Panel({
id: "page_1",
title: "修箱明细",
autoScroll: true,
layout: "border",
region: 'center',
closable: true,
items: [this.panelService]
});
this.page_2 = new Ext.Panel({
id: "page_2",
title: "费用信息",
autoScroll: true,
layout: "border",
region: 'center',
closable: true,
items: [this.panelDrCrFee]
});
this.MainTab = new Ext.tab.Panel({
layout: "border",
height: 430,
region: "north", split: true,
items: [
this.page_1
, this.page_2
]
});
//绑定查询窗体
//初始化数据
this.ParentWin = window.parent.opener;
this.InitData();
}, //end initUIComponents
LoadFeeData: function (EditRecord) {
this.panelFee.EditRecord = EditRecord;
if (this.bsno == undefined) {
var bsno = this.editRecord.get('GID');
} else {
var bsno = this.bsno;
}
this.panelFee.strBSNO = bsno;
this.panelFee.StoreDateCurr.load({ params: { optype: "OpCtnBsCard", bsno: bsno} });
this.panelFee.StoreUnit.load({ params: { bsno: bsno, bstype: "OpCtnBsCard"} });
this.panelFee.storeDrChFee.load({ params: { billno: bsno, type: 1, optype: "OpCtnBsCard"} });
this.panelFee.storeCrChFee.load({ params: { billno: bsno, type: 2, optype: "OpCtnBsCard"} });
this.panelFee.storeBodySum.load({ params: { bsno: bsno },
callback: function (r, options, success) {
if (success) {
_thisfee.setTotalHead();
}
}
});
this.panelFee.storeChFeeGain.load({ params: { bsno: bsno} });
}, // end LoadDate
InitData: function () {
// this.opStatus = 'add';
var condition = '';
if (this.ParentWin) {
var ret = this.ParentWin.OprationSwap();
this.opStatus = ret[0];
this.storeList = ret[1];
this.editRecord = ret[2];
this.status = ret[3];
}
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 215,
items: [this.panelBtn, this.formEdit]
});
Ext.apply(this, {
items: [this.panelTop, this.MainTab]
});
if (this.opStatus == 'edit') {
condition = "GID='" + this.editRecord.get('GID') + "'";
this.LoadData(this.opStatus, condition);
} else {
}
}, //end InitData
LoadData: function (opstatus, condition) {
this.serialNo = 0;
this.workSerialNo = 0;
this.bodyDel = [];
this.opStatus = opstatus;
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/MvcShipping/MsOpCtnRepair/GetData',
params: {
opstatus: 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;
}
this.LoadFeeData(this.editRecord);
var data = result.data;
IsLock = data.IsLock;
ShuiLv = data.ShuiLv;
this.formEdit.getForm().reset();
this.formEdit.getForm().setValues(data);
if (IsLock=='1') {
Ext.getCmp("btnLock").setDisabled(true);
Ext.getCmp("btnSave").setDisabled(true);
Ext.getCmp("btnUnLock").setDisabled(false);
}else {
Ext.getCmp("btnLock").setDisabled(false);
Ext.getCmp("btnSave").setDisabled(false);
Ext.getCmp("btnUnLock").setDisabled(true);
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
if (this.opStatus == 'edit') {
RepairID = this.editRecord.get('GID');
}
this.storeBodyList.load({ params: { condition: " RepairID='" + RepairID + "'"} });
}, // end LoadDate
Save: function (type) {
if (IsLock=='1') {
Ext.Msg.alert('提示', '已锁定的业务不允许修改!');
return;
}
var data = "";
var basicForm = this.formEdit.getForm();
if (!basicForm.isValid()) {
return;
};
data = basicForm.getValues();
var bodydatas = [];
for (var i = 0; i < this.storeBodyList.getCount(); i += 1) {
var member = this.storeBodyList.getAt(i);
bodydatas.push(member);
}
var jsonBody = ConvertRecordsToJsonAll(bodydatas);
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsOpCtnRepair/Save',
scope: this,
params: {
opstatus: this.opStatus,
maindata: Ext.JSON.encode(data),
body: jsonBody,
status: this.status
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
RepairID = jsonresult.Data;
if (type == '0') {
if (this.opStatus == 'add') {
Ext.Msg.alert('提示', '保存成功');
var arrNewRecords = this.storeList.add(returnData);
this.editRecord = arrNewRecords[0];
}
else if (this.opStatus == 'edit') {
this.opStatus = 'edit';
Ext.Msg.alert('提示', '保存成功');
this.storeList.reload();
this.editRecord.commit();
}
this.opStatus = 'edit';
var condition = "GID='" + this.editRecord.get('GID') + "'";
this.LoadData(this.opStatus, condition);
} else if (type == '1') {
window.close();
}else if(type=='2'){
//锁定/生成费用
var islock = '0';
if (type=='2') {
islock='1';
}else if(type=='3') {
islock='0';
}
if (RepairID == ''|| RepairID ==null) {
Ext.MessageBox.alert('提示', '');
return;
}
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/MvcShipping/MsOpCtnRepair/LockAndCreateCost',
params: {
RepairID: RepairID,
IsLock:islock
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (result.Success == true) {
Ext.MessageBox.alert('提示', result.Message);
var condition = "GID='" + RepairID + "'";
this.LoadData('edit', condition);
} else {
Ext.MessageBox.alert('提示', result.Message);
return;
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
}
} else {
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
} else {
Ext.Msg.show({ title: '请重试',
msg: '服务器响应出错',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
}
}
});
}, //end save
UnLock:function(){
var RepairIds= "'"+RepairID+"'";
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/MvcShipping/MsOpCtnRepair/UnLock',
params: {
RepairIDs: RepairIds
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (result.Success == true) {
Ext.MessageBox.alert('提示', result.Message);
var condition = "GID='" + RepairID + "'";
this.LoadData('edit', condition);
} else {
Ext.MessageBox.alert('提示', result.Message);
return;
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
},
onAddDetailClick: function (button, event, type) {
this.addDetail(type);
}, //end onAddDetailClick
onDelDetailClick: function (button, event, type) {
this.deleteDetail(type);
}, //onDelDetailClick
gridAfterEdit: function (editor, e, eOpts) {
},
addDetail: function (type) {
var newSerialno = 0;
store = this.storeBodyList;
var record = Ext.create('OpCtnRepairDetailsModel', {
GID: NewGuid(),
RepairID: '',
XiuXiangDanHao:'',
XuHao: '',
WeiXiuMiaoShu: '',
ShuLiang: '0',
ZeRenRen: '',
WeiXiuGongShi: '0',
GongShiFei: '0',
CaiLiaoFei: '0',
IsRepair: '0',
IsShouFei: '0',
});
store.add(record);
this.gridListCellEditing.startEditByPosition({ row: 2, column: 1 });
},
deleteDetail: function (type) {
var selectedRecords = this.gridList.selModel.getSelection();
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
this.storeBodyList.remove(rec);
}
},onPrintClick: function (button, event) {
if (IsLock=='0') {
Ext.MessageBox.alert('提示','未锁定无法打印!');
return;
}
var printType = 'MsOpCtnRepairDetails';
var uid = USERID;
var sql1 = "select * from Op_CtnRepair where gid = '"+RepairID+"'";
var sql2 = "select * from Op_CtnRepairDetails where RepairID= '"+RepairID+"'";
PrintComm(printType, sql1,sql2);
//更改邮件发送状态
//更改邮件发送状态
var ids = "'"+RepairID+"'";
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/MvcShipping/MsOpCtnRepair/ChangeMailStatus',
params: {
RepairIDs: ids
},
callback: function (options, success, response) {
if (success) {
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
}
});