/** * 公共附件管理初始化 */ var CommonFile = { id: "CommonFileTable", //表格id seItem: null, //选中的条目 table: null, layerIndex: -1 }; /** * 初始化表格的列 */ CommonFile.initColumn = function () { return [ {field: 'selectItem', radio: true}, {title: '附件原名', field: 'originalName', visible: true, align: 'center', valign: 'middle', 'class': 'uitd_showTip',width:"20%"}, {title: '下载地址', field: 'url', visible: true, align: 'center', valign: 'middle', 'class': 'uitd_showTip',width:"40%", formatter : function(value,row,index){ return ""+value+""; } }, {title: '备注', field: 'description', visible: true, align: 'center', valign: 'middle', 'class': 'uitd_showTip',width:"20%"}, {title: '上传时间', field: 'createTime', visible: true, align: 'center', valign: 'middle', 'class': 'uitd_showTip',width:"10%"}, {title: '创建用户', field: 'createUser', visible: true, align: 'center', valign: 'middle', 'class': 'uitd_showTip',width:"10%"}, ]; }; CommonFile.downloadFileByUrl = function(url){ window.location.href = Feng.ctxPath + "/api/commonDownload/downloadByUrl?url=" + url; } /** * 检查是否选中 */ CommonFile.check = function () { var selected = $('#' + this.id).bootstrapTable('getSelections'); if(selected.length == 0){ Feng.info("请先选中表格中的某一记录!"); return false; }else{ CommonFile.seItem = selected[0]; return true; } }; /** * 点击添加公共附件 */ CommonFile.openAddCommonFile = function () { var index = layer.open({ type: 1, title: '添加公共附件', area: ['800px', '420px'], //宽高 fix: false, //不固定 maxmin: true, content: "
", btn: [' 提交' ,' 关闭'], btnAlign: 'c', yes: function (index, layero) { $("#index").val(index); $("#commonFileForm")[0].submit(); } }); this.layerIndex = index; }; /** * 删除公共附件 */ CommonFile.delete = function () { if (this.check()) { var operation = function () { var ajax = new $ax(Feng.ctxPath + "/commonFile/delete", function (data) { if(data.code == 200){ Feng.success(data.msg); CommonFile.table.refresh(); }else{ Feng.info(data.msg); } }, function (data) { Feng.error("删除失败!" + data.responseJSON.message + "!"); }); ajax.set("commonFileId",CommonFile.seItem.id); ajax.start(); } Feng.confirm("确认删除吗?", operation); } }; CommonFile.fileChange = function(context){ var file = $(context).val(); var pos = file.lastIndexOf("\\"); $("#fileInput").val(file.substring(pos+1)); } CommonFile.callback = function(data){ if(data.code == 200){ Feng.success(data.msg); layer.close(data.obj); CommonFile.table.refresh(); }else{ Feng.info(data.msg); } } $(function () { var defaultColunms = CommonFile.initColumn(); var table = new BSTable(CommonFile.id, "/commonFile/list", defaultColunms); table.setPaginationType("server"); CommonFile.table = table.init(); });