/** * 选择用户 */ Ext.define("PSI.Attachment.AttachmentList", { extend: "PSI.AFX.BaseDialogForm", config: { parentForm: null, linkTableName: "", linkDataId:"" }, title: "附件列表", width: 800, height: 600, modal: true, // layout: "fit", initComponent: function () { var me = this; Ext.define("PSIAttachment_AttachmentList", { extend: "Ext.data.Model", fields: ["id", "fileName", "fullName", "fileType","linkTableName","linkDataId","createOn"] }); var userStore = Ext.create("Ext.data.Store", { model: "PSIAttachment_AttachmentList", autoLoad: false, data: [] }); var grid = Ext.create("Ext.grid.Panel", { cls: "PSI", header: { height: 30, title: me.formatGridHeaderTitle("附件") }, padding: 5, selModel: { mode: "MULTI" }, selType: "checkboxmodel", viewConfig: { deferEmptyText: false, emptyText: "" }, store: userStore, columnLines: true, columns: [{ header: "附件名", dataIndex: "fileName", width: 300, menuDisabled: true, renderer: function (value, md, record) { return "" + record.get("fileName") + ""; } }, { header: "附件类型", dataIndex: "fileType", width: 120, menuDisabled: true }, { header: "上传时间", dataIndex: "createOn", width: 170, menuDisabled: true },{ header: "操作", dataIndex: "fullName", width: 110, menuDisabled: true, sortable: false, renderer: function (value, md, record) { return "下载"; } }] }); me.__grid = grid; var buttons = []; buttons.push( { text: "关闭", handler: function () { me.close(); }, scope: me }); Ext.apply(me, { items: [{ id: "panelUploadCmp", region: "north", height: 50, layout: "fit", border: 0, header: false, layout: { type: "table", columns: 2 }, items: me.getUploadCmp() }, { region: "center", layout: "border", layout: "fit", height: 480, border: 0, items: [grid] }, {buttons:buttons} ], listeners: { show: { fn: me.onWndShow, scope: me } } }); me.callParent(arguments); }, getUploadCmp: function () { var me = this; return [ { id: "importForm", border:0, margin: "10 0 0 0", xtype: "form", layout: { type: "table", columns: 1 }, height: "100%", bodyPadding: 5, fieldDefaults: { labelWidth: 60, labelAlign: "right", labelSeparator: "", msgTarget: 'side' }, items: [{ xtype: 'filefield', name: 'data_file', afterLabelTextTpl: '*', fieldLabel: '文件', labelWidth: 50, width: 400, msgTarget: 'side', allowBlank: false, anchor: '100%', buttonText: '选择文件', }, { xtype: "hidden", id: "hiddenLinkTableName", name: "linkTableName", value: me.getLinkTableName() }, { xtype: "hidden", id: "hiddenLinkDataId", name: "linkDataId", value: me.getLinkDataId() }] }, { xtype: "container", items: [{ xtype: "button", text: "上传", width: 100, height: 20, margin: "10 1 5 30", handler: me.onUpload, scope: me }] }]; }, onWndShow: function () { var me = this; var pLinkTableName = me.getLinkTableName(); var pLinkDataId = me.getLinkDataId(); var userStore = me.__grid.getStore(); var el = me.getEl() || Ext.getBody(); el.mask("数据加载中..."); Ext.Ajax.request({ url: PSI.Const.BASE_URL + "Home/Attachment/attachmentList", params: { linkTableName: pLinkTableName, linkDataId:pLinkDataId }, method: "POST", callback: function (options, success, response) { if (success) { var data = Ext.JSON .decode(response.responseText); userStore.removeAll(); for (var i = 0; i < data.length; i++) { var item = data[i]; userStore.add({ id: item.id, fileName: item.file_name, fullName: item.full_name, fileType: item.file_type, linkTableName:item.link_table_name, linkDataId:item.link_data_id, createOn:item.create_on }); } } el.unmask(); } }); }, onUpload: function () { var me = this; var f = Ext.getCmp("importForm"); var el = f.getEl(); el && el.mask('正在导入...'); f.submit({ url: PSI.Const.BASE_URL + "Home/Attachment/uploadFile", method: "POST", success: function (form, action) { el && el.unmask(); PSI.MsgBox.showInfo("上传成功"); me.onWndShow(); //me.close(); //me.getParentForm().freshGoodsGrid(); }, failure: function (form, action) { el && el.unmask(); PSI.MsgBox.showInfo(action.result.msg); } }); } });