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/MsCodeExcelExpFormat/DsExcelExp.js

274 lines
8.6 KiB
JavaScript

3 years ago
Ext.namespace('Shipping');
Shipping.DsExcelExp = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
Shipping.DsExcelExp.superclass.constructor.call(this);
};
Ext.extend(Shipping.DsExcelExp, 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('MsCodeExcelExpFormat', {
extend: 'Ext.data.Model',
idProperty: 'GID',
fields: [
{ name: 'GID', type: 'string' },
{ name: 'FMNAME', type: 'string' },
{ name: 'FILEPATH', 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: 'MsCodeExcelExpFormat',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsCodeExcelExpFormat/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
}
]
});
//#region 下载窗体
this.formDownloadShow = Ext.widget('form', {
frame: true,
region: 'center',
height: 100,
bodyPadding: 5,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 90,
msgTarget: 'qtip'
},
items: [
{//fieldset 1
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
id: 'downloadfile',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'label',
html: '',
width: 120,
text: ''
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
});
DSEXCELEXP = this;
this.winDownloadShow = Ext.create('Ext.window.Window', {
title: "下载文件",
width: 450,
height: 120,
//plain : true,
iconCls: "addicon",
resizable: false,
// 是否可以拖动
// draggable:false,
collapsible: true, // 允许缩放条
closeAction: 'close',
closable: true,
modal: 'true',
buttonAlign: "center",
bodyStyle: "padding:0 0 0 0",
items: [this.formDownloadShow],
buttons: [{
text: "关闭",
minWidth: 70,
handler: function () {
DSEXCELEXP.winDownloadShow.close();
}
}]
});
//#endregion
this.formExcelFormat = Ext.widget('form', {
frame: true,
region: 'center',
bodyPadding: 5,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 60,
msgTarget: 'qtip'
},
items: [{
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [this.gridList]
}],
buttons: [{
text: "导出EXCEL",
id: 'btnExpEXCEL',
handler: function (button, event) {
_thisexcelexp.ExpExcel();
},
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,
items: [this.formExcelFormat],
layout: "border",
width: 500,
xtype: "window",
id: "DsExcelExpWin",
listeners: {
scope: this,
'beforeshow': function (thewin, eOpts) {
this.storeList.load({ params: { condition: " BSTYPE='" + this.bstype + "'"} });
}
}
});
}, //onDeleteClick
ExpExcel: 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;
Ext.Msg.wait('正在导出...');
Ext.Ajax.request({
waitMsg: '正在导出...',
url: '/MvcShipping/MsCodeExcelExpFormat/SaveExcel',
params: {
bstype: _thisexcelexp.bstype,
bsno: _thisexcelexp.BSNO,
fmid: GID
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
Ext.Msg.close();
if (!result.Success) {
Ext.Msg.show({
title: '提示',
msg: result.Message,
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
return;
} else {
var downloadfile = Ext.getCmp('downloadfile');
var children = downloadfile.items;
if (children) {
for (var i = 0, len = children.length; i < len; i++) {
downloadfile.remove(children.items[i], true);
}
}
var downloadfiles = '<a href="' + result.Data + '" style=' + '"text-decoration:none"' + '>' + result.Message + '</a>';
var htmla = Ext.widget('label', {
html: downloadfiles,
width: 120,
text: ''
});
downloadfile.items.add(htmla);
_thisexcelexp.winDownloadShow.show();
}
} else {
Ext.MessageBox.alert('The Server Response Error, Please Try Again', response.responseText);
}
},
scope: this
});
var win = Ext.getCmp("DsExcelExpWin");
win.close();
}
});