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.

957 lines
33 KiB
JavaScript

Ext.namespace('Shipping');
Shipping.MsOpCtnInsuranceEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsOpCtnInsuranceEdit.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsOpCtnInsuranceEdit, Ext.Panel, {
ParentWin: null,
OpStatus: 'add',
StoreList: null,
editRecord: null,
editFactryRecord: null,
FactryStatus: 'add',
initUIComponents: function () {
this.serialNo = 0;
this.workSerialNo = 0;
this.bodyDel = [];
this.storePLList = Ext.create('Ext.data.Store', {
model: 'MsOpCtnInsurance'
});
//#region 编辑form
//枚举参照相关(编辑form)
this.isaddInsurance = getUrlParam('isaddInsurance');
//表参照相关(编辑form)
this.storeCUSTOMER = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefListRm' }
});
this.storeCUSTOMER.load();
//委托单位
this.comboxCUSTOMER = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '保险公司',
store: this.storeCUSTOMER,
// forceSelection: true,
queryMode: 'remote',
minChars: 1,
queryParam: 'CODENAME',
name: 'INSURANCENAME',
valueField: 'CustName',
displayField: 'CodeAndName'
});
this.storeOpCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.UserRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetUserLinkRefListRm' }
});
this.storeOpCode.load();
this.comboxINSURANCEOP = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel:'经办人',
store: this.storeOpCode,
forceSelection: true,
queryMode: 'remote',
minChars: 0,
queryParam: 'CODENAME',
name: 'INSURANCEOP',
valueField: 'UserName',
displayField: 'CodeAndName',
value: SHOWNAME
});
this.storeFeeNameRef = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.FeeTypeRefModel',
proxy: { url: '/MvcShipping/MsChFee/GetFeeTypeRefList' }
});
this.storeFeeNameRef.load({ params: { condition: "" } });
this.comboxFeeNameRef = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '费用名称',
store: this.storeFeeNameRef,
forceSelection: true,
name: 'FEENAME',
valueField: 'Name',
displayField: 'CodeAndName'
});
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,
forceSelection: true,
name: 'CURRENCY',
valueField: 'CURR',
displayField: 'CURR'
});
//编辑form
this.formEdit = Ext.widget('form', {
region: 'north',
height:260,
frame: true,
bodyPadding: 5,
autoScroll: true,
trackResetOnLoad: 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: [{
fieldLabel: 'GID',
name: 'GID', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: 'FEEID',
name: 'FEEID', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: 'COMPANYID',
name: 'COMPANYID', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: '报案号',
name: 'INSURANCENO'
}, this.comboxCUSTOMER, {
fieldLabel: '保险公司联系人',
name: 'INSURANCEATTN'
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '报案日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'INSURANCEDATE'
},this.comboxINSURANCEOP, {
fieldLabel: '录入方式',
flex: 1,
name: 'INPUTTYPE'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '进展情况',
flex: 2,
name: 'INSURANCESTATUS'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '预计理赔时间',
format: 'Y-m-d',
xtype: 'datefield',
name: 'PRECLAIMSDATE'
}, {
fieldLabel: '发生地点',
flex: 2,
name: 'INSURANCEADDR'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [ {
fieldLabel: '索赔事由',
flex: 2,
name: 'INSURANCEDETAIL'
}, {
fieldLabel: '是否结算',
name: 'ISSTL',
inputValue: 'True',
xtype: 'checkboxfield'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '委托编号',
name: 'CUSTNO'
}, {
fieldLabel: '箱号',
name: 'CTNNO'
}, {
fieldLabel: '开船日期',
name: 'ETD'
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxFeeNameRef, this.comboxCurr, {
fieldLabel: '金额',
name: 'AMOUNT'
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '操作',
name: 'OP'
}, {
fieldLabel: '录入人',
name: 'INPUTBYREF'
}, {
fieldLabel: '录入时间',
name: 'INPUTTIME'
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '备注',
name: 'REMARKS'
}]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
}); //end this.formEdit
//#endregion
//#region 按钮Toolbar
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
text: "保存",
iconCls: "btnsave",
handler: function (button, event) {
this.Save('0');
},
scope: this
},
{
text: "保存并关闭",
handler: function (button, event) {
this.Save('1');
},
scope: this
},
'-',
{
text: "保存并新建",
handler: function (button, event) {
this.Save('2');
},
scope: this
}
]
}); //end 按钮Toolbar
//#endregion
this.panelFee = new Shipping.FeeViewGrid({
region: 'center',
layout: 'border'
});
this.panelFee.stroplb = 'OpCtnBsCard';
//#region 明细表-单据图片档案管理
_this = this;
this.storeDocList = Ext.create('Ext.data.Store', {
model: 'ReceiptDocmb',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/Import/ReceiptDoc/GetDocList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//明细表表格
this.DocListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.DocCM = Ext.create('Ext.selection.CheckboxModel');
this.StoreFILETYPE2 = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsExtEnumModel',
proxy: { url: '/CommMng/PubSys/GetEnumValueList' }
});
this.StoreFILETYPE2.load({ params: { enumTypeId: 97056 } });
this.comboxFILETYPE2 = Ext.create('DsExt.ux.RefTableCombox', {
store: this.StoreFILETYPE2,
forceSelection: true,
name: 'FILETYPE',
valueField: 'EnumValueName',
displayField: 'EnumValueName',
value: '罐证'
});
this.gridDocList = new Ext.grid.GridPanel({
store: this.storeDocList,
enableHdMenu: false,
region: 'center',
// width: 350,
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.DocListCellEditing],
selModel: this.DocCM,
selType: 'cellmodel',
tbar: [{
text: '删除',
tooltip: '删除',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelFileClick(button, event);
},
scope: this
}
, '-', {
text: '上传附件',
tooltip: '上传附件',
iconCls: "btnadddetail",
handler: function (button, event) {
this.onUpLoadFileClick(button, event);
},
scope: this
}, '-', {
text: '保存',
tooltip: '保存',
// iconCls: "btnadddetail",
handler: function (button, event) {
this.onPostFileClick(button, event);
},
scope: this
}
],
columns: [{
sortable: true, hidden: true,
dataIndex: 'GID',
header: 'GID',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'R_GID',
header: 'R_GID',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'BSNO',
header: 'BSNO',
width: 80
},
{
sortable: true,
dataIndex: 'URL',
header: '文件名',
width: 140,
renderer: function (value, p, record) {
return '<a href="' + record.data.Driect_URL + '" style=' + '"text-decoration:none"' + '>' + value + '</a>';
}
}, {
xtype: 'actioncolumn',
width: 150,
text: '预览', //操作
items: [{
icon: '/images/icons/L5.gif', // Use a URL in the icon config
tooltip: '预览',
getClass: function (v, meta, rec) {
var filePath = rec.get('URL');
if (filePath == '' || filePath == null) {
return '';
} else {
return 'button_view';
}
},
handler: function (grid, rowIndex, colIndex) {
var rec = grid.getStore().getAt(rowIndex);
var filePath = rec.get('Driect_URL');
if (filePath == '') {
Ext.Msg.show({ title: '提示', msg: '没有文件无法预览!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var openSet = "height=700, width=1024, toolbar=no, menubar=no,scrollbars=1, resizable=1,location=no, status=no,Top= " + (screen.height - 750) / 2 + ",Left= " + (screen.width - 1100) / 2
var openType = "_blank";
var openUrl = "";
openUrl = "../../MvcContainer/MsOpCtnBsCard/ZipView?handle=check&filePath=" + filePath;
window.open(openUrl, openType, openSet);
//DsOpenEditWin(filePath, "", "650", "1250");
}
}]
},
{
sortable: true,
dataIndex: 'RECEIPTTYPE',
header: '附件类型',
width: 135,
editor: this.comboxFILETYPE2
}, {
sortable: true,
dataIndex: 'REMARK',
header: '备注',
editor: {
xtype: 'textfield',
selectOnFocus: true,
enableKeyEvents: true
},
width: 250
},
{
sortable: true, hidden: true,
dataIndex: 'Driect_URL',
header: 'Driect_URL',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'MODIFIEDUSER',
header: 'MODIFIEDUSER',
width: 80
},
{
sortable: true,
dataIndex: 'MODIFIEDUSERRef',
header: '上传人',
width: 80
},
{
sortable: true,
dataIndex: 'MODIFIEDTIME',
header: '上传时间',
width: 135
}
]
});
this.panelDoc = new Ext.Panel({
id: "panelDoc",
layout: "border",
region: "center",
title: '相关文件', //autoScroll: true,
frame: false,
split: true,
items: [this.gridDocList]
});
//#endregion
//#region 布局
//控件布局
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 500,
items: [this.panelBtn, this.formEdit, this.panelDoc]
});
Ext.apply(this, {
items: [this.panelTop, this.panelFee]
});
//#endregion
//绑定查询窗体
this.ParentWin = window.parent.opener;
//初始化数据
if (this.isaddInsurance != '1') {
this.InitData();
} else {
if (this.ParentWin) {
var ret = this.ParentWin._thistkfee.OprationSwap();
this.opStatus ="add";
this.StoreList = this.storePLList;
this.editRecord = null;
this.SelectedRecord = ret[4];
this.formEdit.getForm().reset();
this.formEdit.getForm().findField('INSURANCENAME').setValue(this.SelectedRecord.data.CustomerName);
this.formEdit.getForm().findField('FEENAME').setValue(this.SelectedRecord.data.FeeName);
this.formEdit.getForm().findField('CURRENCY').setValue(this.SelectedRecord.data.Currency);
this.formEdit.getForm().findField('AMOUNT').setValue(this.SelectedRecord.data.Amount);
this.formEdit.getForm().findField('FEEID').setValue(this.SelectedRecord.data.GId);
this.formEdit.getForm().findField('CUSTNO').setValue(this.ParentWin._thistkfee.EditRecord.data.CUSTNO);
this.formEdit.getForm().findField('CTNNO').setValue(this.ParentWin._thistkfee.EditRecord.data.CTNNO);
this.formEdit.getForm().findField('ETD').setValue(this.ParentWin._thistkfee.EditRecord.data.ETD);
this.formEdit.getForm().findField('OP').setValue(this.ParentWin._thistkfee.EditRecord.data.OP);
// this.formEdit.getForm().setValues(this.SelectedRecord.data);
}
}
//绑定事件
}, //end initUIComponents
InitData: function () {
this.opStatus = 'add';
this.FactryStatus = 'add';
var condition = '';
if (this.ParentWin) {
var ret = this.ParentWin.OprationSwap();
this.opStatus = ret[0];
this.StoreList = ret[1];
this.editRecord = ret[2];
}
if (this.opStatus == 'edit')
condition = " GID='" + this.editRecord.get('GID') + "'";
this.LoadData(this.opStatus, condition);
}, //end InitData
LoadData: function (opstatus, condition) {
this.serialNo = 0;
this.workSerialNo = 0;
this.bodyDel = [];
this.opStatus = opstatus;
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/MvcContainer/MsOpCtnBsCard/GetInsuranceData',
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();
this.formEdit.getForm().setValues(data);
this.panelFee.strBSNO ='';
var feesql = " FeeType=1 AND FEENAME='" + data.FEENAME + "' and BSNO IN (SELECT BSNO FROM CH_FEE WHERE GID='" + data.FEEID + "') "
this.panelFee.storeDrChFee.load({ params: { billno: '', type: 1, optype: '', condition: feesql} });
var acondition = " BSNO='" + data.GID + "'";
_this.Loading = true;
_this.storeDocList.load({
params: { condition: acondition },
waitMsg: "正在查询数据...",
scope: this,
callback: function () {
_this.Loading = false;
}
});
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
}, // end LoadDate
Save: function (type) {
var basicForm = this.formEdit.getForm();
if (!basicForm.isValid()) {
return;
}
basicForm.findField('GID').setDisabled(false);
var data = basicForm.getValues();
basicForm.findField('GID').setDisabled(true);
if (this.opStatus == 'add') {
data.GID = NewGuid();
}
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcContainer/MsOpCtnBsCard/SaveInsurance',
scope: this,
params: {
opstatus: this.opStatus,
data: Ext.JSON.encode(data)
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var returnData = jsonresult.Data;
this.formEdit.getForm().setValues(returnData);
if (this.opStatus == 'add') {
var arrNewRecords = this.StoreList.add(returnData);
this.editRecord = arrNewRecords[0];
}
else if (this.opStatus == 'edit') {
this.editRecord = returnData;
this.editRecord.commit();
}
if (type == '0') {
this.opStatus = 'edit';
basicForm.findField('GID').setDisabled(true);
} else if (type == '1') {
window.close();
} else {
this.LoadData('add', '');
basicForm.findField('GID').setDisabled(false);
}
} 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
getIsModify: function () {
return '';
}, //
//#region 上传图片
onPostFileClick: function (button, event) {
var billno = this.formEdit.getForm().findField("GID").getValue();
var custno = this.formEdit.getForm().findField("CTNNO").getValue();
var bodyDatas = [];
var i;
for (var i = 0; i < this.storeDocList.getCount(); i += 1) {
var member = this.storeDocList.getAt(i);
bodyDatas.push(member);
}
var DocBody = ConvertRecordsToJson(bodyDatas);
_this = this;
var _this = this;
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsOpReceipt/SaveUploadFile',
scope: this,
params: {
data: DocBody
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var condition2 = " BSNO='" + billno + "' ";
_this.Loading = true;
_this.storeDocList.load({
params: { condition: condition2 },
waitMsg: "正在查询数据...",
scope: this,
callback: function () {
_this.Loading = false;
}
});
} 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
onDelFileClick: function (button, event) {
var feeGidSql = '';
var selectedRecords = [];
selectedRecords = this.DocCM.selected.items;
if (selectedRecords.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择要删除的附件!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
Ext.MessageBox.confirm('提示', '确定要删除选中的附件吗?', function (btn) {
if (btn == 'yes') {
if (selectedRecords.length > 0) {
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.data.GID == "*") //如果是新增但没有保存的数据,没有必要提交到后台
{
this.storeDocList.remove(selectedRecords[i]);
} else {
var feeGId = "'" + rec.data.GID + "'";
if (feeGidSql == '') {
feeGidSql = feeGId;
} else {
feeGidSql = feeGidSql + "," + feeGId;
}
}
}
}
_this = this;
Ext.Msg.wait('正在删除数据...');
if (feeGidSql != '') {
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/MvcShipping/MsOpReceipt/DeleteUploadFile',
params: {
data: feeGidSql
},
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.storeDocList.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
} else {
Ext.Msg.show({ title: '提示', msg: "删除成功!", icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
}
}
}, this);
}
, onUpLoadFileClick: function (button, event) {
var billno = this.formEdit.getForm().findField("GID").getValue();
var custno = this.formEdit.getForm().findField("CTNNO").getValue();
me = this;
this.StoreFILETYPE = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsExtEnumModel',
proxy: { url: '/CommMng/PubSys/GetEnumValueList' }
});
this.StoreFILETYPE.load({ params: { enumTypeId: 97056 } });
this.comboxFILETYPE = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '附件类型', //'装运方式',
store: this.StoreFILETYPE,
forceSelection: true,
name: 'FILETYPE',
valueField: 'EnumValueName',
displayField: 'EnumValueName'
});
var imgform = new Ext.FormPanel({
region: 'center',
labelWidth: 40,
frame: true,
bodyStyle: 'padding:5px 5px 0',
autoScroll: true,
border: false,
fileUpload: true,
items: [{
xtype: 'fileuploadfield',
id: 'LoadFile',
name: 'LoadFile',
emptyText: '请选择文件',
fieldLabel: '文件',
buttonText: '选择文件',
allowBlank: false,
buttonCfg:
{
iconCls: 'uploaddialog'
},
anchor: '98%'
}, this.comboxFILETYPE],
buttons: [{
text: '上传',
type: 'submit',
handler: function () {
var UserFilePath = Ext.getCmp('LoadFile').getValue();
// if (!CheckFileExt(UserFilePath, /.jpg|.gif|.png|.bmp|.pdf/i)) {
// Ext.Msg.show({ title: '错误', msg: '请确认你上传的文件为图片文件!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
// return;
// }
if (!imgform.form.isValid()) { return; }
imgform.form.submit({
url: '/MvcShipping/MsOpReceipt/UploadFile',
waitMsg: '正在上传',
method: 'POST',
submitEmptyText: false,
async: false,
params: {
CUSTNO: custno,
BSNO: billno,
TYPE: me.comboxFILETYPE.getRawValue(),
},
success: function (form, action) {
win.close(this);
Ext.Msg.show({ title: '提示', msg: '上传成功!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
var condition = billno;
var condition2 = " BSNO='" + condition + "' ";
me.Loading = true;
me.storeDocList.load({
params: { condition: condition2 },
waitMsg: "正在查询数据...",
scope: this,
callback: function () {
me.Loading = false;
}
});
},
failure: function (form, action) {
form.reset();
if (action.failureType == Ext.form.Action.SERVER_INVALID)
Ext.MessageBox.alert('警告', action.result.errors.msg);
}
});
}
}, {
text: '关闭',
type: 'submit',
handler: function () {
win.close(this);
}
}]
});
var win = new Ext.Window({
title: "上传文件",
width: 360,
height: 120,
modal: true,
resizable: false,
border: false,
items: imgform
});
win.show();
}
//#endregion
});