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/MsOpApplyService/MsOpApplyServiceEdit.js

1375 lines
47 KiB
JavaScript

3 years ago
Ext.namespace('Shipping');
Shipping.MsOpApplyServiceEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsOpApplyServiceEdit.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsOpApplyServiceEdit, Ext.Panel, {
ParentWin: null,
OpStatus: 'add',
StoreList: null,
EditRecord: null,
Editdata: null,
type: '',
servicename: '',
initUIComponents: function () {
this.serialNo = 0;
this.bodyDel = [];
this.itemindex = 1;
//枚举参照相关
//表参照相关
this.storecodeservice = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsCodeOpService',
proxy: { url: '/MvcShipping/MsCodeOpService/GetDataList' }
});
this.storeOpCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.UserRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetUserRefList' }
});
this.storeOpCode.load();
this.storeBsType = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeBsType.load({ params: { enumTypeId: 96004} });
this.comboxBsType = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: '运输类型',
store: this.storeBsType,
readOnly: true,
forceSelection: true,
name: 'BSTYPE'
});
this.formHead = Ext.widget('form', {
region: 'north',
frame: true,
bodyPadding: 5,
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: '业务编号',
name: 'BSNO', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: '委托编号',
readOnly: true,
name: 'CUSTNO'
}, {
fieldLabel: '业务锁定',
readOnly: true,
name: 'BSSTATUSREF'
}, {
fieldLabel: '费用锁定',
readOnly: true,
name: 'FEESTATUSREF'
}, {
fieldLabel: '会计期间',
readOnly: true,
name: 'ACCDATE'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '委托单位',
readOnly: true,
name: 'CUSTOMERNAME'
}, {
fieldLabel: '业务来源',
readOnly: true,
name: 'BSSOURCE'
}, {
fieldLabel: '来源明细',
readOnly: true,
name: 'BSSOURCEDETAIL'
}, {
fieldLabel: '业务日期',
format: 'Y-m-d',
xtype: 'datefield',
readOnly: true,
name: 'OPDATE'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '操 作',
readOnly: true,
name: 'OP'
}, {
fieldLabel: '揽货人',
readOnly: true,
name: 'SALE'
}, this.comboxBsType, {
fieldLabel: '报关单号',
readOnly: true,
name: 'CUSTOMNO'
}
]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
}); //end this.formEdit
//编辑form
this.formEdit = Ext.widget('form', {
region: 'north',
frame: true,
bodyPadding: 5,
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: '提单号',
name: 'MBLNO'
}, {
fieldLabel: '船名',
name: 'VESSEL'
}, {
fieldLabel: '航次',
name: 'VOYNO'
}, {
fieldLabel: '开船日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'ETD'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [, {
fieldLabel: '装货港',
name: 'PORTLOAD'
}, {
fieldLabel: '卸货港',
name: 'PORTDISCHARGE'
}, {
fieldLabel: '到港日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'ETA'
}, {
fieldLabel: '所在海关',
name: 'BYCUSTOM'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '经营单位名称',
name: 'ENTERP'
}, {
fieldLabel: '经营单位编码',
name: 'ENTERPID'
}, {
fieldLabel: '货源国别',
name: 'ARCOUNTRY'
}, {
fieldLabel: '货源地',
name: 'GOODSOURCE'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '报关日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'CUSTOMDATE'
}, {
fieldLabel: '商检单号',
name: 'INSPECTIONNO'
}, {
fieldLabel: '商检日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'INSPECTIONDATE'
}, {
fieldLabel: '报关行',
name: 'CUSTOMSER'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '手册号',
name: 'BOOKNO'
}, {
fieldLabel: '发票号',
name: 'INVNO'
}, {
fieldLabel: '合同号',
name: 'CONTRACTNO'
}, {
fieldLabel: '批准文号',
name: 'DOCNO'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '件数',
name: 'PKGS'
}, {
fieldLabel: '毛重',
name: 'KGS'
}, {
fieldLabel: '净重',
name: 'NETWEIGHT'
}, {
fieldLabel: '尺码',
name: 'CBM'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '备注',
name: 'REMARK'
}
]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
}); //end this.formEdit
//明细表-数据集
this.storeBodyList = Ext.create('Ext.data.Store', {
model: 'MsOpApplyDetail',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsOpApply/GetBodyList',
reader: {
id: 'BsNo,SerialNo',
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,
plugins: [this.gridListCellEditing],
selType: 'cellmodel',
columns: [{
sortable: true,
dataIndex: 'BsNo',
header: '业务编号',
hidden: true,
width: 120
}, {
sortable: true,
dataIndex: 'SerialNo',
header: '序号',
width: 30
}, {
sortable: true,
dataIndex: 'GoodsCode',
header: '商品编码',
editor: {
xtype: 'textfield',
selectOnFocus: true
},
width: 120
}, {
sortable: true,
dataIndex: 'GoodsName',
header: '商品名称',
editor: {
xtype: 'textfield',
selectOnFocus: true
},
width: 120
}, {
sortable: true,
dataIndex: 'Pkgs',
header: '件数',
editor: {
xtype: 'numberfield',
allowBlank: false,
selectOnFocus: true
},
width: 120
}, {
sortable: true,
dataIndex: 'Price',
header: '单价',
editor: {
xtype: 'numberfield',
allowBlank: false,
selectOnFocus: true
},
width: 100,
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: 'Total',
header: '总价',
editor: {
xtype: 'numberfield',
allowBlank: false,
selectOnFocus: true
},
width: 120,
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: '币别',
editor: {
xtype: 'textfield',
allowBlank: false,
selectOnFocus: true
},
width: 120
}, {
sortable: true,
dataIndex: 'Remark',
header: '其他',
editor: {
xtype: 'textfield',
selectOnFocus: true
},
width: 110
}
]
});
this.storeServiceList = Ext.create('Ext.data.Store', {
model: 'MsOpApplyServiceDetail',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsOpApplyService/GetServiceDetailList',
reader: {
id: 'BsNo,SerialNo',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.gridserviceListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.comboxOp = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '操作',
store: this.storeOpCode,
forceSelection: true,
name: 'OP',
labelWidth: 60,
width:180,
valueField: 'UserName',
displayField: 'CodeAndName'
});
this.storeCodeService = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsCodeOpServiceDetail',
proxy: { url: '/MvcShipping/MsCodeOpService/GetBodyList' }
});
this.comboxCodeService = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '服务项目类别',
store: this.storeCodeService,
forceSelection: true,
name: 'SERVICE',
labelWidth: 80,
width: 180,
valueField: 'NAME',
displayField: 'NAME'
});
this.storeCodeWork = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsCodeOpServiceDetail',
proxy: { url: '/MvcShipping/MsCodeOpService/GetWorkList' }
});
this.comboxCodeWork = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeCodeWork,
name: 'WORK',
labelWidth: 80,
forceSelection: true,
valueField: 'NAME',
displayField: 'NAME'
});
this.comboxhelpOp = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeOpCode,
forceSelection: true,
name: 'HELPOP',
valueField: 'UserName',
displayField: 'CodeAndName'
});
this.servicepanel = Ext.widget('form', {
bodyPadding: 3,
layout: "border",
region: 'north',
height: 40,
frame: false, fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
msgTarget: 'qtip'
},
items: [
{//fieldset 1
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '业务编号',
name: 'BSNO', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: '服务项目',
name: 'OPFIELD', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: '当前状态',
labelWidth: 60,
width: 120,
readOnly: true,
name: 'STATUS'
}, this.comboxOp, this.comboxCodeService, {
fieldLabel: '开始时间',
// format: 'Y-m-d H:i:s',
// xtype: 'datetimefield',
labelWidth: 60,
readOnly: true,
name: 'STARTDATETIME'
}, {
fieldLabel: '计划完成时间',
// format: 'Y-m-d H:i:s',
// xtype: 'datetimefield',
readOnly: true,
labelWidth: 80,
name: 'PLANENDTIME'
}, {
fieldLabel: '实际完成时间',
// format: 'Y-m-d H:i:s',
// xtype: 'datetimefield',
labelWidth: 80,
readOnly: true,
name: 'ENDDATETIME'
}, {
fieldLabel: '完成人',
labelWidth: 50,
width: 120,
readOnly: true,
name: 'ENDOP'
}
]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
});
this.panelserviceBtn = new Ext.Panel({
region: "north",
tbar: [
{
id: 'WorkSave',
text: "保存",
iconCls: "btnsave",
handler: function (button, event) {
var basicForm = this.servicepanel.getForm();
if (!basicForm.isValid()) {
return;
}
var bodydatas = [];
for (var i = 0; i < this.storeServiceList.getCount(); i += 1) {
var member = this.storeServiceList.getAt(i);
bodydatas.push(member);
}
var jsonBody = ConvertRecordsToJsonAll(bodydatas);
var data = this.servicepanel.getForm().getValues();
var billno = this.editRecord.get('BSNO');
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsOpApplyService/Save',
scope: this,
params: {
bsno: billno,
data: Ext.JSON.encode(data),
body: jsonBody
},
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.servicepanel.getForm().setValues(returnData);
for (var j = 0; j < this.storeServiceList.getCount(); j += 1) {
var memberbody = this.storeServiceList.getAt(j);
memberbody.set("BSNO", billno);
memberbody.commit();
};
} 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
});
}
}
});
},
scope: this
},
{
id: 'btnWorkNew',
text: "添加流程",
iconCls: "btnadd",
handler: function (button, event) {
var newSerialno = this.storeServiceList.getCount() + 1;
var billno = this.editRecord.get('BSNO');
var type = this.editRecord.get('OPFIELD');
var record = Ext.create('MsOpApplyServiceDetail', {
BSNO: '*',
GID: '',
SerialNo: newSerialno,
OPFIELD: type,
WORK: '',
STATUS:'未完成',
NOFINISHRESON: '',
OTADVICE: '',
HELPOP: '',
ENDOP: '',
Remark: ''
});
this.storeServiceList.add(record);
var n = this.storeServiceList.getCount();
this.gridserviceListCellEditing.startEditByPosition({ row: n - 1, column: 1 });
},
scope: this
}, {
id: 'btnWorkdel',
text: "删除流程",
iconCls: "btndelete",
handler: function (button, event) {
var selectedRecords = this.servicegridList.selModel.getSelection();
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
this.storeServiceList.remove(selectedRecords[i]);
}
},
scope: this
}, {
id: 'btnWorkover',
text: "流程确认完成",
handler: function (button, event) {
var selectedRecords = this.servicegridList.selModel.getSelection();
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
rec.data.STATUS ='已完成';
rec.data.ENDOP = getSessgionNAME();
var myDate = new Date();
rec.data.ENDDATETIME = myDate;
rec.commit();
}
},
scope: this
}
, '-', {
text: "关闭",
handler: function (button, event) {
window.close();
},
scope: this
},
'-',
{
text: "打印",
iconCls: "btnprint",
handler: function (button, event) {
this.Print();
},
scope: this
},
'-',
{
id: 'btnover',
text: "确认完成",
handler: function (button, event) {
var opstr = this.formHead.getForm().findField('OP').getValue();
if (SHOWNAME != opstr) {
Ext.Msg.show({ title: '警告', msg: '你无权审核完成 ', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var field = this.servicepanel.getForm().findField('STATUS');
field.setValue('已完成');
var myDate = new Date();
var field2 = this.servicepanel.getForm().findField('ENDDATETIME');
var mydatestr = Ext.util.Format.date(myDate, 'Y-m-d H:i:s');
field2.setValue(mydatestr);
var field3 = this.servicepanel.getForm().findField('ENDOP');
var opname = getSessgionNAME();
field3.setValue(opname);
},
scope: this
}
]
});
this.serviceGridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
this.servicegridList = new Ext.grid.GridPanel({
store: this.storeServiceList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.gridserviceListCellEditing],
selModel: this.serviceGridCheckBoxModel,
selType: 'cellmodel',
columns: [{
sortable: true,
dataIndex: 'BSNO',
header: '业务编号',
hidden: true,
width: 120
}, {
sortable: true,
dataIndex: 'OPFIELD',
header: '服务类型',
hidden: true,
width: 120
}, {
sortable: true,
dataIndex: 'GID',
header: 'GID',
hidden: true,
width: 120
}, {
sortable: true,
dataIndex: 'SerialNo',
header: '序号',
width: 30
}, {
sortable: true,
dataIndex: 'WORK',
header: '流程',
editor: this.comboxCodeWork,
width: 120
}, {
sortable: true,
dataIndex: 'STATUS',
header: '流程状态',
width: 120
}
/*
, {
sortable: true,
dataIndex: 'STARTDATETIME',
header: '开始时间',
editor: {
xtype: 'datetimefield',
format: 'Y-m-d H:i:s',
allowBlank: false,
selectOnFocus: true
},
renderer: Ext.util.Format.dateRenderer('Y-m-d H:i:s'),
width: 130
}
*/
, {
sortable: true,
dataIndex: 'PLANENDTIME',
header: '计划完成时间',
editor: {
xtype: 'datetimefield',
format: 'Y-m-d H:i:s',
allowBlank: false,
selectOnFocus: true
},
renderer: Ext.util.Format.dateRenderer('Y-m-d H:i:s'),
width: 130
}, {
sortable: true,
dataIndex: 'ENDDATETIME',
header: '完成时间',
renderer: Ext.util.Format.dateRenderer('Y-m-d H:i:s'),
width: 130
}, {
sortable: true,
dataIndex: 'NOFINISHRESON',
header: '未完成原因',
editor: {
xtype: 'textfield',
allowBlank: false,
selectOnFocus: true
},
width: 120
}, {
sortable: true,
dataIndex: 'NEXTPLAN',
header: '下步计划',
editor: {
xtype: 'textfield',
selectOnFocus: true
},
width: 110
}, {
sortable: true,
dataIndex: 'HELPOP',
header: '协助解决人',
editor: this.comboxhelpOp,
width: 110
}, {
sortable: true,
dataIndex: 'ENDOP',
header: '完成人',
width: 110
}
]
});
this.panelServicetop = new Ext.Panel({
layout: "border",
region: "north",
height: 60,
items: [this.panelserviceBtn, this.servicepanel]
});
this.panelService = new Ext.Panel({
title: '服务项目详细信息',
height: 200,
layout: "border",
region: 'north',
// animate: true,
// autoScroll: true,
// containerScroll: true,
frame: false,
items: [this.panelServicetop, this.servicegridList]
});
this.panelBodyChFee = new Ext.Panel({
title: '商品明细',
layout: "border",
region: 'center',
margin: '5 10',
frame: true,
items: [this.gridList]
});
this.panelpage1 = new Ext.Panel({
title: '业务基本信息',
layout: "border",
region: 'center',
animate: true,
autoScroll: true,
containerScroll: true,
frame: false,
items: [this.formHead, this.formEdit, this.panelBodyChFee]
});
this.panelapply = new Ext.Panel({
layout: "border",
region: 'center',
animate: true,
autoScroll: true,
frame: false,
items: [this.panelService, this.panelpage1]
});
Ext.apply(this, {
items: [this.panelapply]
});
parentWin = window.parent.opener;
this.InitData();
//绑定事件
this.gridList.on('edit', function (editor, e, eOpts) {
this.gridAfterEdit(editor, e, eOpts);
}, this);
this.storeServiceList.on('beforeload', function (store) {
var billno = this.editRecord.get('BSNO');
var type = this.editRecord.get('OPFIELD');
Ext.apply(store.proxy.extraParams, { BsNo: billno, OPField: type });
}, this);
}, //end initUIComponents
InitData: function () {
this.opStatus = 'add';
var condition = '';
_this = this;
if (parentWin) {
var ret = parentWin.OprationSwap();
this.opStatus = ret[0];
this.StoreList = ret[1];
this.editRecord = ret[2];
}
if (this.opStatus == 'edit') {
condition = " BsNo='" + this.editRecord.get('BSNO') + "'";
}
this.storecodeservice.load({ params: { condition: "OPTYPE='5'" },
callback: function (r, options, success) {
if (success) {
if (r.length != 0) {
var checkboxitems = "";
checkboxitems = "[";
for (i = 0; i < this.storecodeservice.getCount(); i += 1) {
var memberyf = this.storecodeservice.getAt(i);
if (i == 0) {
var checkboxSingleItem = "{boxLabel:'" + memberyf.data.SERVICENAME + "',inputValue:'1',name:'Is" + memberyf.data.OPField + "',id:'Is" + memberyf.data.OPField + "'";
checkboxSingleItem += "}";
} else {
var checkboxSingleItem = ",{boxLabel:'" + memberyf.data.SERVICENAME + "',inputValue:'1',name:'Is" + memberyf.data.OPField + "',id:'Is" + memberyf.data.OPField + "'";
checkboxSingleItem += "}";
}
checkboxitems += checkboxSingleItem;
};
checkboxitems += "]";
_this.myCheckboxGroup = new Ext.form.CheckboxGroup({
id: 'myGroup',
xtype: 'checkboxgroup',
fieldLabel: '服务项目',
columns: 6,
items: eval(checkboxitems)
});
this.formHead.add(_this.myCheckboxGroup);
this.formHead.doLayout();
}
this.LoadData(this.opStatus, condition);
}
},
scope: this
});
}, //end InitData
LoadData: function (opstatus, condition) {
this.serialNo = 0;
this.bodyDel = [];
this.opStatus = opstatus;
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/MvcShipping/MsOpApply/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;
}
data = result.data;
this.formEdit.getForm().reset();
this.formEdit.getForm().setValues(data);
this.formHead.getForm().reset();
this.formHead.getForm().setValues(data);
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
var billno = '*';
var gid = '*';
var type = '*';
if (this.opStatus == 'edit') {
billno = this.editRecord.get('BSNO');
type = this.editRecord.get('OPFIELD');
}
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/MvcShipping/MsOpApplyService/GetData',
params: {
BsNo: billno,
OPField: type
},
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;
this.servicepanel.getForm().reset();
this.servicepanel.getForm().setValues(data);
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
this.storeServiceList.load({ params: { BsNo: billno, OPField: type} });
this.panelService.setTitle(this.editRecord.get('SERVICETYPE') + '业务流程信息');
var Acondition = "OS_ID in (select OS_ID from code_op_service where OPTYPE='5' and OPField='" + type + "')"
this.storeCodeService.load({ params: { condition: Acondition} });
this.storeCodeWork.load({ params: { condition: Acondition} });
this.storeBodyList.load({ params: { BsNo: billno} });
}, // end LoadDate
Save: function (type) {
var basicForm = this.formEdit.getForm();
var basicForm2 = this.formHead.getForm();
if (!basicForm.isValid()) {
return;
}
if (!basicForm2.isValid()) {
return;
}
var bodydatas = [];
for (var i = 0; i < this.storeBodyList.getCount(); i += 1) {
var member = this.storeBodyList.getAt(i);
bodydatas.push(member);
}
var jsonBody = ConvertRecordsToJson(bodydatas);
var jsonDelBody = ConvertRecordsToJsonAll(this.bodyDel);
var data = this.formHead.getForm().getValues();
var data2 = this.formEdit.getForm().getValues();
/*
for (var i = 0; i < this.myCheckboxGroup.items.length; i++) {
if (this.myCheckboxGroup.items.items[i].checked) {
data["'"+this.myCheckboxGroup.items.items[i].name+"'"]=1;
}
}
*/
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsOpApply/Save',
scope: this,
params: {
opstatus: this.opStatus,
data: Ext.JSON.encode(data),
data2: Ext.JSON.encode(data2),
body: jsonBody
},
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.formHead.getForm().setValues(returnData);
this.formEdit.getForm().setValues(returnData);
if (this.opStatus == 'add') {
var arrNewRecords = this.StoreList.add(returnData);
this.editRecord = arrNewRecords[0];
}
else if (this.opStatus == 'edit') {
var editp = Ext.create('MsOpApply', returnData);
this.editRecord.fields.each(function (field) {
if (field.persist) {
name = field.name;
if (name != 'id')
this.editRecord.set(name, editp.get(name));
}
}, this);
this.editRecord.commit();
}
if (type == '0') {
this.opStatus = 'edit';
basicForm2.findField('BSNO').setDisabled(true);
for (var j = 0; j < this.storeBodyList.getCount(); j += 1) {
var memberbody = this.storeBodyList.getAt(j);
memberbody.set("BSNO", this.editRecord.get('BSNO'));
memberbody.commit();
};
} else if (type == '1') {
window.close();
} else {
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
});
}
}
});
} //end save
,
onAddDetailClick: function (button, event) {
this.addDetail();
}, //end onAddDetailClick
onDelDetailClick: function (button, event) {
this.deleteDetail();
}, //onDelDetailClick
gridAfterEdit: function (editor, e, eOpts) {
if (e.field == 'Pkgs' || e.field == 'Price') {
var Pkgs = e.record.data['Pkgs'];
var Price = e.record.data['Price'];
e.record.set('Total', (Pkgs * Price).toFixed(2));
}
},
addDetail: function () {
var newSerialno = DsGetNewSerialNo(this.storeBodyList, this.serialNo);
this.serialNo = newSerialno;
this.tabtree.expandAll();
var record = Ext.create('MsOpApplyDetail', {
BsNo: '*',
SerialNo: newSerialno,
GoodsCode: '',
GoodsName: '',
Pkgs: 0,
Price: 0,
Total: 0,
Currency: '',
Remark: ''
});
this.storeBodyList.add(record);
var n = this.storeBodyList.getCount();
this.gridListCellEditing.startEditByPosition({ row: n - 1, column: 2 });
},
deleteDetail: function () {
this.serialNo = DsGetCurSerialNo(this.storeBodyList, this.serialNo);
var selectedRecords = this.gridList.selModel.getSelection();
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.BsNo != "" || rec.BsNo != "*") //如果是新增但没有保存的数据,没有必要提交到后台
{
this.bodyDel.push(rec);
}
this.storeBodyList.remove(selectedRecords[i]);
}
},
GetEditStatus: function () {
var canedit = false;
var bsStatus = this.editRecord.get('BSSTATUS');
var inputby = this.editRecord.get('INPUTBY');
var op = this.editRecord.get('OP');
_this = this;
if (bsStatus) { canedit = false } else {
this.StoreOpRange.load({ params: { optype: "modOpApplyOpwt" },
callback: function (r, options, success) {
if (success) {
if (r.length != 0) {
var records = DsStoreQueryBy(_this.StoreOpRange, 'OPID', op);
if (records.getCount() > 0) {
canedit = true;
} else {
var recordins = DsStoreQueryBy(_this.StoreOpRange, 'OPID', inputby);
if (recordins.getCount() > 0) {
canedit = true;
} else {
canedit = false;
}
}
} else { canedit = false; }
}
}
});
}
this.setSaveBtnStatus(canedit)
},
gettype: function () {
},
setSaveBtnStatus: function (enable) {
var btnESave = Ext.getCmp('btnESave');
var btnESaveAndClose = Ext.getCmp('btnESaveAndClose');
var btnESaveAndNew = Ext.getCmp('btnESaveAndNew');
var btnEAddDetail = Ext.getCmp('btnadddetail');
var btnEDeleteDetail = Ext.getCmp('btndeldetail');
if (enable) {
btnESave.enable();
btnESaveAndClose.enable();
btnESaveAndNew.enable();
btnEAddDetail.enable();
btnEDeleteDetail.enable();
} else {
btnESave.disable();
btnESaveAndClose.disable();
btnESaveAndNew.disable();
btnEAddDetail.disable();
btnEDeleteDetail.disable();
}
},
Print: function () {
/*
this.panelservice.add(({
xtype: 'checkboxfield',
fieldLabel: '服务项目',
id: 'Service1',
flex: 1,
allowBlank: false,
name: 'IsService1',
listeners: {
change: function (field, newValue, oldValue, eOpts) {
server1 = Ext.getCmp('Service1');
server1.fieldLabel = '报关';
}
}
}));
this.panelservice.doLayout();
*/
/*
server1 = Ext.getCmp('Service1');
server1.fieldLabel = '报关';
this.formHead.doLayout();
*/
/*
var basicForm = this.formEdit.getForm();
var billNo = basicForm.findField('BillNo').value;
if (billNo == '*' || billNo == '') {
Ext.Msg.show({ title: '错误', msg: '单据还没有保存,请保存后再打印', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var printType = 'MSWLBULKBS';
var sql1 = "SET LANGUAGE 'us_english' SELECT * FROM tMsWlBulkHead WHERE BillNo = '" + billNo + "'";
var sql2 = "";
var sql3 = "";
var sql4 = "";
var sql5 = "";
var sql6 = "";
PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6);
*/
}
});