Index: ssts-web/src/main/webapp/knowledge/viewExt.js
===================================================================
diff -u -r29552 -r29987
--- ssts-web/src/main/webapp/knowledge/viewExt.js (.../viewExt.js) (revision 29552)
+++ ssts-web/src/main/webapp/knowledge/viewExt.js (.../viewExt.js) (revision 29987)
@@ -6,6 +6,7 @@
var trainingRecordStore;
var formPanel;
+//删除
function deleteFileAndFolder(){
var moduleId = getModuleId();
var ids = grid.getSelectedValues('prefixId', ';');
@@ -17,9 +18,43 @@
if(confirm("若删除文件夹,将删除该文件夹下的所有文件,确定删除选中的文件和文件夹吗?")){
KnowledgeTableManager.deleteByIds(moduleId, ids, function(){reloadTreeAndTable();});
}
+}
+/**
+ * 点击产生阅读记录
+ * @param {文件id} id
+ * @param {点击类型} type
+ * @param {参数} params
+ */
+function accumulateReadRecord(id,type,params){
+ Ext.Ajax.request({
+ url: WWWROOT + '/disinfectSystem/baseData/readRecordAction!accumulateReadRecord.do?moduleId=trainingManage&id='+id,
+ success: function (response, options) {
+ var result = Ext.decode(response.responseText);
+ if(result.success){
+ if(type == 'video'){
+ var url = Ext.urlEncode({
+ videoName : params.videoName, //视频播放文件名
+ fileName : params.fileName //文件名
+ });
+ openModalWindowForExt(WWWROOT+"/knowledge/watchVideo.jsp?"+url,'', "观看视频", "600", "400");
+ }else if(type == 'image'){
+ document.getElementById('clickTab').click();
+ }else {
+ location.href = params.url
+ }
+ }else {
+ showResult(result.msg);
+ }
+ },
+ failure: function (response, options) {
+ var result = Ext.decode(response.responseText);
+ showResult(result.msg);
+ }
+ });
}
+//刷新表格
function reloadTreeAndTable(){
var folderKeyId = document.getElementById("parm_s_parentId").value;
if(folderKeyId == ""){
@@ -37,6 +72,7 @@
grid.dwrReload();
}
+//修改文件或文件夹
function updateFileAndFolder(){
var moduleId = getModuleId();
if(havaSelectedOnlyOne('文件或文件夹','id')){
@@ -47,14 +83,18 @@
}
var id = grid.getSelectedValues('prefixId', ';');
if(id.indexOf(fileIdPrefix) == 0 ){
- location.href = WWWROOT + "/networkdisk/addFileForm.mhtml?moduleId="+moduleId+"&Action=u&id="+id.substring(fileIdPrefix.length, id.length)+"&folderKeyId="+folderId;
+ var params = {
+ url:WWWROOT + "/networkdisk/addFileForm.mhtml?moduleId="+moduleId+"&Action=u&id="+id.substring(fileIdPrefix.length, id.length)+"&folderKeyId="+folderId
+ }
+ accumulateReadRecord(id.substring(fileIdPrefix.length, id.length),'url',params);
} else if(id.indexOf(folderIdPrefix) == 0){
location.href = WWWROOT + "/networkdisk/addFolderForm.mhtml?moduleId="+moduleId+"&id="+id.substring(folderIdPrefix.length, id.length);
}
}
}
+//添加文件
function addFile(){
var moduleId = getModuleId();
var id = document.getElementById('parm_s_parentId').value;
@@ -65,6 +105,7 @@
}
}
+//添加文件夹
function addFolder(){
var moduleId = getModuleId();
var id = document.getElementById('parm_s_parentId').value;
@@ -76,6 +117,7 @@
}
}
+//判断是否选择了文件或文件夹
function havaSelectedOnlyOne(msg){
var selectedAmount = grid.getSelectionModel().getCount();
if(selectedAmount == 0 ){
@@ -88,86 +130,76 @@
}
return true;
-
}
+//点击节点事件
function onClickTreeNode(node, e){
var nodeKeyId = node.attributes['keyId'];
setTopToolbarDisabled(node);
Ext.fly("parm_s_parentId").dom.value = nodeKeyId;
grid.gotoFirstPage();
// grid.dwrReload();
}
+
+//播放视频
function playVideo(videoName,fileName,id){
- var url = Ext.urlEncode({
- videoName : videoName, //视频播放文件名
- fileName : fileName //文件名
- });
- Ext.Ajax.request({
- url: WWWROOT + '/disinfectSystem/baseData/readRecordAction!accumulateReadRecord.do?moduleId=trainingManage&id='+id,
- success: function (response, options) {
- var result = Ext.decode(response.responseText);
- if(result.success){
- openModalWindowForExt(WWWROOT+"/knowledge/watchVideo.jsp?"+url,'', "观看视频", "600", "400");
- }else {
- showResult(result.msg);
- }
- },
- failure: function (response, options) {
- var result = Ext.decode(response.responseText);
- showResult(result.msg);
- }
- });
+ var params = {
+ videoName:videoName,
+ fileName:fileName
+ }
+ accumulateReadRecord(id,'video',params);
}
+
+//打开图片
function openImg(attachFileId,moduleId,id){
var linkUrl = WWWROOT + "/attachfiles/fileDownLoad?loadType=open&id=" + attachFileId + "&moduleId=" + moduleId;
document.getElementById('clickTab').setAttribute('href',linkUrl);
- Ext.Ajax.request({
- url: WWWROOT + '/disinfectSystem/baseData/readRecordAction!accumulateReadRecord.do?moduleId=trainingManage&id='+id,
- success: function (response, options) {
- var result = Ext.decode(response.responseText);
- if(result.success){
- document.getElementById('clickTab').click();
- }else {
- showResult(result.msg);
- }
- },
- failure: function (response, options) {
- var result = Ext.decode(response.responseText);
- showResult(result.msg);
- }
- });
+ accumulateReadRecord(id,'image');
}
+
+function openUrl(id,url){
+ var params = {
+ url:url
+ }
+ accumulateReadRecord(id,'url',params);
+}
+
+//名称列重新渲染
function rendererImgLink(v, p, record){
var linkUrl = record.data['linkUrl'];
var attachFileType = record.data['attacnFileType'];
- var attachFileId = record.data['attachFileId'];
+ var attachFileId = record.data['attachFileId'];
if (!isUndefinedOrNullOrEmpty(attachFileId) && attachFileId.indexOf(",") == -1){
//判断类型是否包含video包含为视频文件
if(attachFileType.indexOf("video")>=0){
v = '
' + v + '';
}else{
v = '
' + v + '';
}
- }
- else{
+ }else{
//如果不为空,则目前加载的文件,要重新设置对应文件的url,如果是目前加载目录,这个url是一个js的方法
if (!isUndefinedOrNullOrEmpty(record.get('folderId'))){
linkUrl = WWWROOT + linkUrl;
+ v = '
' + v + '';
+ }else {
+ v = '
' + v + '';
}
- v = '
' + v + '';
}
return v;
}
+//返回上个文件夹
function moveUpFileOrFolder(id){
KnowledgeTableManager.moveUp(getModuleId(),id, function(){reloadTreeAndTable();});
}
+
+//向下返回文件夹
function moveDownFileOrFolder(id){
KnowledgeTableManager.moveDown(getModuleId(), id, function(){reloadTreeAndTable();});
}
+//获取moduleId
function getModuleId(){
var moduleId = document.getElementById("parm_s_moduleId").value;
return moduleId;
@@ -182,6 +214,7 @@
grid.dwrReload();
}
+
function setTopToolbarDisabled(node){
var nodeKeyId = node.attributes['keyId'];
if(nodeKeyId != 0){
@@ -215,6 +248,7 @@
grid.dwrReload();
}
}
+
function addOrUpdateForm(id){
formPanel = new top.Ext.FormPanel({
id : 'addOrUpdateForm',