附件集成演示
功能?標(biāo):為學(xué)???中的每?個(gè)學(xué)?信息添加附件管理功能,要求可以學(xué)?維護(hù)多個(gè)附件,并且可以下載和刪除。
-
在系統(tǒng)前端新建?錄 Home/ORA_2062/學(xué)?管理 ,其中附件?錄 學(xué)?管理 的關(guān)鍵屬性如下:
** 附件文件夾:**
image.png
** 附件目錄:**
image.png
開(kāi)始寫(xiě)代碼了....
新建??student_attachment.html 并利? 附件上傳 的功能進(jìn)?附件功能初始化(不要格式化html代碼),
<#include "../include/header.html">
<body>
<div style="width:780px;margin:10px;">
${attachmentProvider.getAttachHtml("ORA_20796_STUDENT",RequestParameters.studentId,base.locale, base.contextPath,true,true)}
</div>
</body>
</html>
attachmentProvider 的關(guān)鍵屬性如下:
| 參數(shù) | 值 | 說(shuō)明 |
|---|---|---|
| sourceType | ORA_20796_STUDENT | (之前在界面操作的時(shí)候命名的) |
| sourceKey | RequestParameters.studentId | ??參數(shù)學(xué)?ID,這樣才能知道這個(gè)附件屬于哪個(gè)學(xué)生的 |
現(xiàn)在開(kāi)始更改student.html
在 KendoGrid 新增列,?于打開(kāi)每?名學(xué)?的附件界?:
//點(diǎn)擊彈出附件上傳窗口
{
title:'<@spring.message "attachcategory.attachmentmanagement"/>',
width : 40,
headerAttributes: {
style : "text-align: center"
},
attributes: {style: "text-align:center"},
template : function (rowdata) {
if (!!rowdata.studentId) {
return '<a href="#" onclick="openAttachmentWindow(' + rowdata.studentId + ')"><i class="fa fa-paperclip"></i></a>'
} else return ''
},
sortable: false
},
<!--附件上傳管理DIV-->
<div id="attachment-window"></div>
//初始化附件選擇window
$("#attachment-window").kendoWindow({
width: "800px",
height:"300px",
title: '<@spring.message "attachcategory.attachmentmanagement"/>',
modal:true,
resizable: false,
visible:false,
iframe:true
});
/**
* 打開(kāi)附件窗口,盡量在最上面的<script></script>里面寫(xiě)
* @param studentId
*/
function openAttachmentWindow(studentId) {
var win = $("#attachment-window").data("kendoWindow");
win.refresh('student_attachment.html?studentId=' + studentId);
win.center().open();
}
注意div的id=attachment-window,還有點(diǎn)擊事件openAttachmentWindow()是否對(duì)應(yīng)
之前:

image.png
之后:

image.png

