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.
210 lines
6.6 KiB
JavaScript
210 lines
6.6 KiB
JavaScript
Ext.namespace('Shipping');
|
|
Shipping.DsExcelImp = function (config) {
|
|
Ext.applyIf(this, config);
|
|
this.initUIComponents();
|
|
Shipping.DsExcelImp.superclass.constructor.call(this);
|
|
};
|
|
Ext.extend(Shipping.DsExcelImp, Ext.Window, {
|
|
StoreList: null,
|
|
bstype: '',
|
|
BSNO: '',
|
|
start: 0,
|
|
limit: 100,
|
|
condition: '',
|
|
returnsql: null,
|
|
initUIComponents: function () {
|
|
// BEGIN OF CODE GENERATION PARTS, DON'T DELETE CODE BELOW
|
|
|
|
this.bstype = '海运出口';
|
|
this.BSNO = '';
|
|
|
|
Ext.define('MsCodeExcelImpFormat', {
|
|
extend: 'Ext.data.Model',
|
|
idProperty: 'GID',
|
|
fields: [
|
|
{ name: 'GID', type: 'string' },
|
|
{ name: 'FMNAME', type: 'string' },
|
|
{ name: 'CREATEUSER', type: 'string' },
|
|
{ name: 'CREATEUSERREF', type: 'string' },
|
|
{ name: 'CREATETIME', type: 'string' },
|
|
{ name: 'MODIFIEDUSER', type: 'string' },
|
|
{ name: 'MODIFIEDTIME', type: 'string' },
|
|
{ name: 'CREATETIME', type: 'string' },
|
|
{ name: 'CORPID', type: 'string' },
|
|
{ name: 'BSTYPE', type: 'string' },
|
|
{ name: 'REMARK', type: 'string' }
|
|
]
|
|
});
|
|
|
|
this.storeList = Ext.create('Ext.data.Store', {
|
|
model: 'MsCodeExcelImpFormat',
|
|
remoteSort: true,
|
|
proxy: {
|
|
type: 'ajax',
|
|
url: '/MvcShipping/MsCodeExcelImpFormat/GetDataList',
|
|
reader: {
|
|
id: 'GID',
|
|
root: 'data',
|
|
totalProperty: 'totalCount'
|
|
}
|
|
}
|
|
});
|
|
|
|
this.GridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
|
|
this.gridList = new Ext.grid.GridPanel({
|
|
store: this.storeList,
|
|
// height: 180,
|
|
enableHdMenu: false,
|
|
region: 'center',
|
|
loadMask: { msg: "数据加载中,请稍等..." },
|
|
trackMouseOver: true,
|
|
selModel: this.GridCheckBoxModel,
|
|
disableSelection: false,
|
|
columns: [{
|
|
sortable: true,
|
|
dataIndex: 'GID',
|
|
header: 'GID',
|
|
hidden: true,
|
|
width: 120
|
|
}, {
|
|
sortable: true,
|
|
dataIndex: 'FMNAME',
|
|
header: '模板名称',
|
|
width: 120
|
|
}, {
|
|
sortable: true,
|
|
dataIndex: 'REMARK',
|
|
header: '说明',
|
|
width: 120
|
|
}
|
|
|
|
]
|
|
});
|
|
|
|
this.formExcelFormat = new Ext.FormPanel({
|
|
frame: true,
|
|
region: 'south',
|
|
height:80,
|
|
bodyPadding: 5,
|
|
fileUpload: true,
|
|
items: [{
|
|
xtype: 'filefield',
|
|
id: 'DsLoadExcel',
|
|
name: 'DsLoadExcel',
|
|
emptyText: '请选择EXCEL文件', //'请选择EXCEL文件',
|
|
fieldLabel: 'EXCEL文件', //'EXCEL',
|
|
buttonText: '选择文件', //'选择文件',
|
|
allowBlank: false,
|
|
width: 200,
|
|
buttonCfg:
|
|
{
|
|
iconCls: 'uploaddialog'
|
|
},
|
|
anchor: '98%'
|
|
}],
|
|
buttons: [{
|
|
text: "上传EXCEL",
|
|
id: 'btnImpEXCEL',
|
|
type: 'submit',
|
|
handler: function (button, event) {
|
|
_thisexcelexp.ImpExcel();
|
|
},
|
|
scope: this
|
|
}, {
|
|
text: "关闭",
|
|
handler: function (button, event) {
|
|
var win = this.up("window");
|
|
win.close();
|
|
}
|
|
}]
|
|
});
|
|
_thisexcelexp = this;
|
|
|
|
Ext.apply(this, {
|
|
height: 250,
|
|
closable: true,
|
|
draggable: true,
|
|
title: 'EXCEL模板导入',
|
|
defaultButton: 'btnQuery',
|
|
resizable: false,
|
|
modal: true,
|
|
items: [this.gridList,this.formExcelFormat],
|
|
layout: "border",
|
|
width: 500,
|
|
xtype: "window",
|
|
id: "DsExcelImpWin",
|
|
listeners: {
|
|
scope: this,
|
|
'beforeshow': function (thewin, eOpts) {
|
|
this.storeList.load({ params: { condition: " BSTYPE='" + this.bstype + "'"} });
|
|
|
|
}
|
|
}
|
|
});
|
|
|
|
|
|
|
|
}, //onDeleteClick
|
|
|
|
|
|
ImpExcel: function () {
|
|
var selections = this.GridCheckBoxModel.selected.items;
|
|
if (selections.length == 0) {
|
|
Ext.Msg.show({ title: '提示', msg: '请先选择要导入的模板!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
|
|
return;
|
|
}
|
|
var rec = selections[0];
|
|
var GID = rec.data.GID;
|
|
|
|
var UserFilePath = Ext.getCmp('DsLoadExcel').getValue();
|
|
if (!CheckFileExt(UserFilePath, /.xls|.xlsx/i)) {
|
|
Ext.Msg.show({ title: '错误', msg:'请确认你上传的文件为EXCEL文件!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); //'请确认你上传的文件为EXCEL文件!'
|
|
return;
|
|
}
|
|
if (!this.formExcelFormat.form.isValid()) { return; }
|
|
|
|
this.formExcelFormat.form.submit({
|
|
url: '/MvcShipping/MsCodeExcelImpFormat/ImpExcel',
|
|
waitMsg:'正在操作数据',
|
|
method: 'POST',
|
|
params: {
|
|
bstype: _thisexcelexp.bstype,
|
|
fmid: GID
|
|
},
|
|
success: function (form, action) {
|
|
var result = action.result;
|
|
// Ext.Msg.close();
|
|
if (!result.success) {
|
|
Ext.Msg.show({
|
|
title: '提示',
|
|
msg: result.Message,
|
|
icon: Ext.MessageBox.ERROR,
|
|
buttons: Ext.Msg.OK
|
|
});
|
|
return;
|
|
} else {
|
|
Ext.Msg.show({
|
|
title: '提示',
|
|
msg: result.Message,
|
|
icon: Ext.Msg.INFO,
|
|
buttons: Ext.Msg.OK
|
|
});
|
|
var win = Ext.getCmp("DsExcelImpWin");
|
|
win.close();
|
|
return;
|
|
|
|
}
|
|
|
|
},
|
|
failure: function (form, action) {
|
|
form.reset();
|
|
Ext.MessageBox.alert(Zi.LAN.JingGao, action.result.Message);
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
});
|