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/RptImportFeedetail/RptImportFeedetailEdit.js

522 lines
17 KiB
JavaScript

Ext.namespace('DsTruck');
DsTruck.RptImportFeedetailEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.DsTruck.RptImportFeedetailEdit.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);
Ext.extend(DsTruck.RptImportFeedetailEdit, Ext.Panel, {
parentWin: null,
OpStatus: 'add',
StoreList: null,
editRecord: null,
storeCargociq: null,
initUIComponents: function () {
//枚举参照相关
//表参照相关
/*
this.storeCountry = Ext.create('DsExt.ux.RefTableStore', {
model: 'ConutryRef',
proxy: { url: '/CommMng/BasicDataRef/GetCountryRefList' }
});
this.storeCountry.load({ params: { condition: ""} });
this.comboxCountry = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '进口国',
store: this.storeCountry,
name: 'Countryid',
valueField: 'countryid',
displayField: 'country_idandname'
});
this.storeport = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeport.load({ params: { enumTypeId: 10} });
this.comboxport = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: '受理机构',
store: this.storeport,
name: 'SLJG'
});
this.storestop = Ext.create('DsExt.ux.RefEnumStore', {});
this.storestop.load({ params: { enumTypeId: 0} });
this.comboxstop = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: '是否停用',
store: this.storestop,
name: 'isdeleted'
});
this.storeCompany = Ext.create('DsExt.ux.RefTableStore', {
model: 'companymb',
proxy: { url: '/CommMng/BasicDataRef/GetcompanyList' }
});
this.storeCompany.load({ params: { condition: ""} });
this.comboxCompany = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '用证公司',
store: this.storeCompany,
name: 'company',
valueField: 'gid',
displayField: 'name'
});
this.storedepot = Ext.create('DsExt.ux.RefEnumStore', {});
this.storedepot.load({ params: { enumTypeId: 19} });
this.comboxdepot = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: '关联仓库',
store: this.storedepot,
name: 'depot'
});
this.storeCargo = Ext.create('DsExt.ux.RefTableStore', {
model: 'CargoRef',
proxy: { url: '/CommMng/BasicDataRef/GetCargoRefList' }
});
this.storeCargo.load({ params: { condition: ""} });
this.comboxCargo = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: 'HS代码',
store: this.storeCargo,
name: 'cargoinfo_id',
valueField: 'id',
displayField: 'codeandname',
autoselect: true
});
this.comboxCargo.addListener('select', function (combo, record, index) {
var s = " cargoinfoid=" + combo.value;
//alert(s);
//this.storeCargociq.removeAll();
this.storeCargociq.load({ params: { condition: s} });
//this.comboxCargociq.setValue('请选择');
this.comboxCargociq.clearValue();
}, this);
this.storeCargociq = Ext.create('DsExt.ux.RefTableStore', {
model: 'CargociqRef',
proxy: { url: '/CommMng/BasicDataRef/GetCargociqRefList' }
});
//this.storeCargociq.load({ params: { condition: ""} });
this.comboxCargociq = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: 'CIQ代码',
store: this.storeCargociq,
name: 'cargociq_id',
valueField: 'id',
displayField: 'codeandname',
autoselect: true
//ciq代码
});*/
/*
//编辑form
this.formEdit = Ext.widget('form', {
// layout: "border",
region: 'center',
// height: 200,
frame: true,
bodyPadding: 5,
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.comboxCompany
, this.comboxport, //受理机构/目的港
{
fieldLabel: '许可证号',
name: 'APPNO'
}, {
fieldLabel: '申请单号',
name: 'SQDH'
},
{
fieldLabel: 'id',
name: 'id', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: 'gid',
name: 'gid', flex: 0, hidden: true, margins: '0'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxCargo,
this.comboxCargociq,
{
fieldLabel: '商品名称',
name: 'AppName'
}, this.comboxCountry]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '额度(吨)',
allowBlank: false,
name: 'Weight'
}, {
fieldLabel: '已经使用',
allowBlank: false,
name: 'usedweight'
}, {
fieldLabel: '已核销未使用',
allowBlank: false,
name: 'JustWriteoffs'
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '未核销(吨)',
name: 'remain',
disabled: true
}, {
fieldLabel: '已核销(吨)',
name: 'used',
disabled: true
}, {
fieldLabel: '未核销未配证(吨)',
name: 'canbeused',
disabled: true
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '有效期',
format: 'Y-m-d',
xtype: 'datefield',
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
name: 'ValidDate'
}, this.comboxdepot, this.comboxstop]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '备注',
name: 'REMARK'
}]
}]
}//end fieldset 1
]//end root items
}); //end this.formEdit
*/
//按钮Toolbar
/*
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
id: "savebtn",
text: "保存",
handler: function (button, event) {
this.Save('0');
},
scope: this
}, {
id: "saveandclose",
text: "保存并关闭",
handler: function (button, event) {
this.Save('1');
},
scope: this
},
{
id: "saveandnew",
text: "保存并新建",
handler: function (button, event) {
this.Save('2');
},
scope: this
}, '-',
{
id: "closebtn",
text: "关闭",
handler: function (button, event) {
window.close();
},
scope: this
}
]
}); //end 按钮Toolbar
*/
//////只显示不编辑:许可证的使用情况
//结果集
this.storeUsing = Ext.create('Ext.data.Store', {
model: 'Usingmb',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/Import/approval/GetUsing',
reader: {
id: 'id',
root: 'data',
totalProperty: 'totalCount'
}
}
});
/*
this.gridList = new Ext.grid.GridPanel({
store: this.storeList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
viewConfig: {
enableTextSelection: true
},
columns: [new Ext.grid.RowNumberer()],
bbar: Ext.create('Ext.PagingToolbar', {
store: this.storeList,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
})
});*/
//////
//布局
this.editpanel = new Ext.Panel({
region: 'north',
items: [this.formEdit]
});
this.usingpanel = new Ext.Panel({
region: 'center',
title: '使用情况列表',
items: [this.UsingGrid]
});
Ext.apply(this, {
items: [
this.panelBtn,
this.editpanel,
this.UsingGrid
]
});
parentWin = window.parent.opener;
this.InitData();
}, //end initUIComponents
Loadciq: function (cargoinfoid) {
var s = " cargoinfoid=" + cargoinfoid;
//alert(s);
this.storeCargociq.load({ params: { condition: s} });
},
InitData: function () {
this.opStatus = 'add';
var condition = '';
// alert("1:"+parentWin.toString());
if (parentWin) {
var ret = parentWin.OprationSwap();
this.opStatus = ret[0];
this.StoreList = ret[1];
this.editRecord = ret[2];
// alert("3:" + ret[0].toString() + "," + ret[1].toString() + "," + ret[2].toString());
}
if (this.opStatus == 'edit') {
//alert(this.editRecord.get('id') + ' ' + this.editRecord.get('cargoinfo_id'))
var hscode = this.editRecord.get('cargoinfo_id')
this.Loadciq(hscode);
condition = " a.id='" + this.editRecord.get('id') + "'";
}
this.LoadData(this.opStatus, condition);
}, //end InitData
LoadData: function (opstatus, condition) {
// alert(condition);
this.opStatus = opstatus;
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/Import/approval/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.ex_ == "") { data.OilLrDate = currdate.format('yyyy-MM-dd') };
this.formEdit.getForm().setValues(data);
var sql = 'app_id=' + data.id;
if (this.opStatus != 'add') {
this.storeUsing.load({
params: { start: 0, limit: 500, sort: '', condition: sql },
//params: { condition: sql },
waitMsg: "正在查询数据...",
scope: this
});
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
//var sql = this.getCondition();
}, // end LoadDate
Save: function (type) {
var basicForm = this.formEdit.getForm();
if (!this.formEdit.getForm().isValid()) {
return;
}
basicForm.findField('id').setDisabled(false);
var data = this.formEdit.getForm().getValues();
basicForm.findField('id').setDisabled(true);
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Import/approval/Save',
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];
this.opStatus = 'edit';
}
else if (this.opStatus == 'edit') {
var editp = Ext.create('approvalmb', 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';
} 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
OprationSwap: function () {
var ret = new Array();
ret[0] = 'edit';
ret[1] = "";
ret[2] = this.SelectedRecord;
return ret;
}
});