commit | author | age
|
325e0c
|
1 |
/** |
Z |
2 |
* 选择用户 |
|
3 |
*/ |
|
4 |
Ext.define("PSI.Attachment.AttachmentList", { |
|
5 |
extend: "PSI.AFX.BaseDialogForm", |
|
6 |
|
|
7 |
config: { |
|
8 |
parentForm: null, |
|
9 |
linkTableName: "", |
|
10 |
linkDataId:"" |
|
11 |
}, |
|
12 |
|
|
13 |
title: "附件列表", |
|
14 |
width: 800, |
|
15 |
height: 600, |
|
16 |
modal: true, |
98d165
|
17 |
// layout: "fit", |
325e0c
|
18 |
|
Z |
19 |
initComponent: function () { |
|
20 |
var me = this; |
|
21 |
Ext.define("PSIAttachment_AttachmentList", { |
|
22 |
extend: "Ext.data.Model", |
|
23 |
fields: ["id", "fileName", "fullName", "fileType","linkTableName","linkDataId","createOn"] |
|
24 |
}); |
|
25 |
|
|
26 |
var userStore = Ext.create("Ext.data.Store", { |
|
27 |
model: "PSIAttachment_AttachmentList", |
|
28 |
autoLoad: false, |
|
29 |
data: [] |
|
30 |
}); |
|
31 |
|
|
32 |
var grid = Ext.create("Ext.grid.Panel", { |
|
33 |
cls: "PSI", |
|
34 |
header: { |
|
35 |
height: 30, |
|
36 |
title: me.formatGridHeaderTitle("附件") |
|
37 |
}, |
|
38 |
padding: 5, |
|
39 |
selModel: { |
|
40 |
mode: "MULTI" |
|
41 |
}, |
|
42 |
selType: "checkboxmodel", |
|
43 |
viewConfig: { |
|
44 |
deferEmptyText: false, |
98d165
|
45 |
emptyText: "" |
325e0c
|
46 |
}, |
Z |
47 |
store: userStore, |
|
48 |
columnLines: true, |
|
49 |
columns: [{ |
|
50 |
header: "附件名", |
|
51 |
dataIndex: "fileName", |
|
52 |
width: 300, |
5a1dc2
|
53 |
menuDisabled: true, |
Z |
54 |
renderer: function (value, md, record) { |
|
55 |
return "<a href='" |
|
56 |
+ PSI.Const.BASE_URL |
|
57 |
+ record.get("fullName") |
|
58 |
+ "' target='_blank'>" + record.get("fileName") + "</a>"; |
|
59 |
} |
325e0c
|
60 |
}, { |
Z |
61 |
header: "附件类型", |
|
62 |
dataIndex: "fileType", |
|
63 |
width: 120, |
|
64 |
menuDisabled: true |
|
65 |
}, { |
|
66 |
header: "上传时间", |
|
67 |
dataIndex: "createOn", |
|
68 |
width: 170, |
|
69 |
menuDisabled: true |
be0349
|
70 |
},{ |
Z |
71 |
header: "操作", |
|
72 |
dataIndex: "fullName", |
|
73 |
width: 110, |
|
74 |
menuDisabled: true, |
|
75 |
sortable: false, |
|
76 |
renderer: function (value, md, record) { |
|
77 |
return "<a href='" |
|
78 |
+ PSI.Const.BASE_URL |
|
79 |
+ record.get("fullName") |
|
80 |
+ "' target='_blank'>下载</a>"; |
|
81 |
} |
325e0c
|
82 |
}] |
Z |
83 |
}); |
|
84 |
|
|
85 |
me.__grid = grid; |
|
86 |
|
98d165
|
87 |
var buttons = []; |
325e0c
|
88 |
|
98d165
|
89 |
buttons.push( { |
Z |
90 |
text: "关闭", |
|
91 |
handler: function () { |
|
92 |
me.close(); |
|
93 |
}, |
|
94 |
scope: me |
|
95 |
}); |
|
96 |
|
|
97 |
Ext.apply(me, { |
|
98 |
items: [{ |
|
99 |
id: "panelUploadCmp", |
|
100 |
region: "north", |
|
101 |
height: 50, |
|
102 |
layout: "fit", |
|
103 |
border: 0, |
|
104 |
header: false, |
|
105 |
layout: { |
|
106 |
type: "table", |
|
107 |
columns: 2 |
|
108 |
}, |
|
109 |
items: me.getUploadCmp() |
|
110 |
}, |
|
111 |
{ |
|
112 |
region: "center", |
|
113 |
layout: "border", |
|
114 |
layout: "fit", |
|
115 |
height: 480, |
|
116 |
border: 0, |
|
117 |
items: [grid] |
|
118 |
}, |
|
119 |
{buttons:buttons} |
|
120 |
], |
|
121 |
listeners: { |
|
122 |
show: { |
|
123 |
fn: me.onWndShow, |
|
124 |
scope: me |
|
125 |
} |
|
126 |
} |
|
127 |
}); |
|
128 |
me.callParent(arguments); |
|
129 |
}, |
|
130 |
|
|
131 |
getUploadCmp: function () { |
|
132 |
var me = this; |
|
133 |
return [ |
|
134 |
{ |
|
135 |
id: "importForm", |
|
136 |
border:0, |
|
137 |
margin: "10 0 0 0", |
|
138 |
xtype: "form", |
|
139 |
layout: { |
|
140 |
type: "table", |
|
141 |
columns: 1 |
|
142 |
}, |
|
143 |
height: "100%", |
|
144 |
bodyPadding: 5, |
|
145 |
fieldDefaults: { |
|
146 |
labelWidth: 60, |
|
147 |
labelAlign: "right", |
|
148 |
labelSeparator: "", |
|
149 |
msgTarget: 'side' |
|
150 |
}, |
|
151 |
items: [{ |
|
152 |
xtype: 'filefield', |
|
153 |
name: 'data_file', |
|
154 |
afterLabelTextTpl: '<span style="color:red;font-weight:bold" data-qtip="必须选择一个要上传的文件">*</span>', |
|
155 |
fieldLabel: '文件', |
|
156 |
labelWidth: 50, |
|
157 |
width: 400, |
|
158 |
msgTarget: 'side', |
|
159 |
allowBlank: false, |
|
160 |
anchor: '100%', |
|
161 |
buttonText: '选择文件', |
|
162 |
}, |
|
163 |
{ |
|
164 |
xtype: "hidden", |
|
165 |
id: "hiddenLinkTableName", |
|
166 |
name: "linkTableName", |
|
167 |
value: me.getLinkTableName() |
|
168 |
}, |
|
169 |
{ |
|
170 |
xtype: "hidden", |
|
171 |
id: "hiddenLinkDataId", |
|
172 |
name: "linkDataId", |
|
173 |
value: me.getLinkDataId() |
|
174 |
}] |
|
175 |
}, |
|
176 |
{ |
|
177 |
xtype: "container", |
|
178 |
items: [{ |
|
179 |
xtype: "button", |
|
180 |
text: "上传", |
|
181 |
width: 100, |
|
182 |
height: 20, |
|
183 |
margin: "10 1 5 30", |
|
184 |
handler: me.onUpload, |
|
185 |
scope: me |
|
186 |
}] |
|
187 |
}]; |
325e0c
|
188 |
}, |
Z |
189 |
|
|
190 |
onWndShow: function () { |
|
191 |
var me = this; |
|
192 |
var pLinkTableName = me.getLinkTableName(); |
|
193 |
var pLinkDataId = me.getLinkDataId(); |
|
194 |
var userStore = me.__grid.getStore(); |
|
195 |
|
|
196 |
var el = me.getEl() || Ext.getBody(); |
|
197 |
el.mask("数据加载中..."); |
|
198 |
Ext.Ajax.request({ |
|
199 |
url: PSI.Const.BASE_URL |
|
200 |
+ "Home/Attachment/attachmentList", |
|
201 |
params: { |
|
202 |
linkTableName: pLinkTableName, |
|
203 |
linkDataId:pLinkDataId |
|
204 |
}, |
|
205 |
method: "POST", |
|
206 |
callback: function (options, success, response) { |
|
207 |
if (success) { |
|
208 |
var data = Ext.JSON |
|
209 |
.decode(response.responseText); |
98d165
|
210 |
userStore.removeAll(); |
325e0c
|
211 |
for (var i = 0; i < data.length; i++) { |
Z |
212 |
var item = data[i]; |
|
213 |
userStore.add({ |
|
214 |
id: item.id, |
|
215 |
fileName: item.file_name, |
be0349
|
216 |
fullName: item.full_name, |
325e0c
|
217 |
fileType: item.file_type, |
Z |
218 |
linkTableName:item.link_table_name, |
|
219 |
linkDataId:item.link_data_id, |
|
220 |
createOn:item.create_on |
|
221 |
}); |
|
222 |
} |
|
223 |
} |
|
224 |
el.unmask(); |
|
225 |
} |
|
226 |
}); |
|
227 |
}, |
98d165
|
228 |
|
Z |
229 |
onUpload: function () { |
|
230 |
var me = this; |
|
231 |
var f = Ext.getCmp("importForm"); |
|
232 |
var el = f.getEl(); |
|
233 |
el && el.mask('正在导入...'); |
|
234 |
f.submit({ |
|
235 |
url: PSI.Const.BASE_URL + "Home/Attachment/uploadFile", |
|
236 |
method: "POST", |
|
237 |
success: function (form, action) { |
|
238 |
el && el.unmask(); |
325e0c
|
239 |
|
98d165
|
240 |
PSI.MsgBox.showInfo("上传成功"); |
Z |
241 |
me.onWndShow(); |
325e0c
|
242 |
|
98d165
|
243 |
//me.close(); |
Z |
244 |
//me.getParentForm().freshGoodsGrid(); |
|
245 |
}, |
|
246 |
failure: function (form, action) { |
|
247 |
el && el.unmask(); |
|
248 |
PSI.MsgBox.showInfo(action.result.msg); |
|
249 |
} |
|
250 |
}); |
325e0c
|
251 |
} |
Z |
252 |
}); |