From 3e7b34762384a30bb05d80fce09f5ceb3adea556 Mon Sep 17 00:00:00 2001 From: weizhiqiang <598748873@qq.com> Date: Sun, 4 Dec 2022 20:07:42 +0800 Subject: [PATCH] =?UTF-8?q?=E9=99=84=E4=BB=B6=E7=AE=A1=E7=90=86=E6=95=B4?= =?UTF-8?q?=E6=94=B9=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sysEnclosure/enclosureBusinessChoose.js | 148 +++++ .../js/sysEnclosure/enclosureUpload.js | 34 ++ .../js/sysEnclosure/myEnclosureList.js | 91 +++ .../template/js/sysenclosure/addenclosure.js | 40 -- .../template/js/sysenclosure/editenclosure.js | 47 -- .../js/sysenclosure/enclosureupload.js | 428 -------------- .../js/sysenclosure/mysysenclosure.js | 197 ------- .../template/js/uploadFile/uploadFile.js | 123 ++-- .../sysEnclosure/enclosureBusinessChoose.html | 44 ++ .../tpl/sysEnclosure/enclosureUpload.html | 26 + .../tpl/sysEnclosure/myEnclosureList.html | 38 ++ .../tpl/sysenclosure/addenclosure.html | 38 -- .../tpl/sysenclosure/editenclosure.html | 38 -- .../tpl/sysenclosure/enclosureupload.html | 59 -- .../tpl/sysenclosure/mysysenclosure.html | 51 -- .../template/tpl/uploadFile/uploadFile.html | 39 +- .../template/assets/lib/layui/custom.js | 1 + .../lib/layui/customer/skyeyeEnclosure.js | 6 +- .../layui/customer/tree/catalogTreeUtil.js | 151 +++++ .../template/assets/lib/winui/css/winui.css | 18 +- .../template/js/common/enclosureupload.js | 544 ------------------ .../template/json/sysServiceMation.json | 3 +- .../template/tpl/common/enclosureupload.html | 76 --- 23 files changed, 624 insertions(+), 1616 deletions(-) create mode 100644 common/src/main/resources/template/js/sysEnclosure/enclosureBusinessChoose.js create mode 100644 common/src/main/resources/template/js/sysEnclosure/enclosureUpload.js create mode 100644 common/src/main/resources/template/js/sysEnclosure/myEnclosureList.js delete mode 100644 common/src/main/resources/template/js/sysenclosure/addenclosure.js delete mode 100644 common/src/main/resources/template/js/sysenclosure/editenclosure.js delete mode 100644 common/src/main/resources/template/js/sysenclosure/enclosureupload.js delete mode 100644 common/src/main/resources/template/js/sysenclosure/mysysenclosure.js create mode 100644 common/src/main/resources/template/tpl/sysEnclosure/enclosureBusinessChoose.html create mode 100644 common/src/main/resources/template/tpl/sysEnclosure/enclosureUpload.html create mode 100644 common/src/main/resources/template/tpl/sysEnclosure/myEnclosureList.html delete mode 100644 common/src/main/resources/template/tpl/sysenclosure/addenclosure.html delete mode 100644 common/src/main/resources/template/tpl/sysenclosure/editenclosure.html delete mode 100644 common/src/main/resources/template/tpl/sysenclosure/enclosureupload.html delete mode 100644 common/src/main/resources/template/tpl/sysenclosure/mysysenclosure.html create mode 100644 web/src/main/resources/template/assets/lib/layui/customer/tree/catalogTreeUtil.js delete mode 100644 web/src/main/resources/template/js/common/enclosureupload.js delete mode 100644 web/src/main/resources/template/tpl/common/enclosureupload.html diff --git a/common/src/main/resources/template/js/sysEnclosure/enclosureBusinessChoose.js b/common/src/main/resources/template/js/sysEnclosure/enclosureBusinessChoose.js new file mode 100644 index 000000000..53c59bede --- /dev/null +++ b/common/src/main/resources/template/js/sysEnclosure/enclosureBusinessChoose.js @@ -0,0 +1,148 @@ + +var enclosureList = new Array(); + +layui.config({ + base: basePath, + version: skyeyeVersion +}).extend({ + window: 'js/winui.window' +}).define(['window', 'jquery', 'winui', 'fsTree'], function (exports) { + winui.renderColor(); + var index = parent.layer.getFrameIndex(window.name); + var $ = layui.$, + form = layui.form, + fsTree = layui.fsTree; + + var boxId = GetUrlParam('boxId'); + enclosureList = [].concat(JSON.parse(parent.$("#" + boxId).attr(skyeyeEnclosure.enclosureListKey))); + + matchingLanguage(); + form.render(); + + var ztree = null; + /********* tree 处理 start *************/ + fsTree.render({ + id: "treeDemo", + url: reqBasePath + "queryEnclosureTree", + checkEnable: true, + loadEnable: false,//异步加载 + showLine: false, + showIcon: true, + onDblClick: function(){ + }, + onAsyncSuccess: function(id){ + }, + onCheck: zTreeOnCheck //选中回调函数 + }, function(id){ + ztree = $.fn.zTree.getZTreeObj(id); + var zTreeChecked = ztree.getCheckedNodes(false); + for (var i = 0; i < zTreeChecked.length; i++) { + for(var j = 0; j < enclosureList.length; j++){ + if(zTreeChecked[i].id == enclosureList[j].id){ + ztree.checkNode(zTreeChecked[i], true, true); + } + } + } + }); + + //选中或取消选中的回调函数 + function zTreeOnCheck(event, treeId, treeNode) { + //获取选中节点 + var zTree = ztree.getCheckedNodes(true); + for (var i = 0; i < zTree.length; i++) { + if (!isNull(zTree[i].objectType) && zTree[i].objectType != "catalog"){ + addToArray({ + id: zTree[i].id, + name: zTree[i].name, + fileAddress: zTree[i].fileAddress + }); + } + } + //获取未选中节点 + zTree = ztree.getCheckedNodes(false); + for (var i = 0; i < zTree.length; i++) { + if (!isNull(zTree[i].objectType) && zTree[i].objectType != "catalog"){ + removeToArray(zTree[i].id); + } + } + } + + /********* tree 处理 end *************/ + + // 取消 + $("body").on("click", "#cancle", function() { + parent.layer.close(index); + }); + + // 确定 + $("body").on("click", "#confimChoose", function() { + var nodes = ztree.getCheckedNodes(true); + for(var i = 0; i < nodes.length; i++){ + var node = nodes[i]; + if (!isNull(node.objectType) && node.objectType != "catalog") { + addToArray({ + id: node.id, + name: node.name, + fileAddress: node.fileAddress + }); + } + } + parent.layer.close(index); + parent.$("#" + boxId).attr(skyeyeEnclosure.enclosureListKey, JSON.stringify(enclosureList)); + parent.refreshCode = '0'; + }); +}); + +// 向集合中添加元素 +function addToArray(data) { + var inArray = false; + $.each(enclosureList, function(i, item) { + if(item.id === data.id){ + inArray = true; + return false; + } + }); + if(!inArray){//如果该元素在集合中不存在 + enclosureList.push({ + id: data.id, + name: data.name, + fileAddress: data.fileAddress + }); + } +} + +// 移除集合中的元素 +function removeToArray(id){ + var inArray = -1; + $.each(enclosureList, function(i, item) { + if(id === item.id) { + inArray = i; + return false; + } + }); + if(inArray != -1){//如果该元素在集合中存在 + enclosureList.splice(inArray, 1); + } +} + +/** + * 文件上传成功后的回调函数 + * @param json + */ +function uploadFileCallback(json) { + var params = { + name: json.bean.name, + path: json.bean.fileAddress, + type: json.bean.fileType, + size: json.bean.size, + sizeType: json.bean.fileSizeType, + catalog: '0' + }; + AjaxPostUtil.request({url: reqBasePath + "createEnclosure", params: params, type: 'json', method: 'POST', callback: function (data) { + addToArray({ + id: data.bean.id, + name: json.bean.name, + fileAddress: json.bean.fileAddress + }); + }}); +} diff --git a/common/src/main/resources/template/js/sysEnclosure/enclosureUpload.js b/common/src/main/resources/template/js/sysEnclosure/enclosureUpload.js new file mode 100644 index 000000000..55a17472b --- /dev/null +++ b/common/src/main/resources/template/js/sysEnclosure/enclosureUpload.js @@ -0,0 +1,34 @@ + +layui.config({ + base: basePath, + version: skyeyeVersion +}).extend({ + window: 'js/winui.window' +}).define(['window', 'jquery', 'winui'], function (exports) { + winui.renderColor(); + var index = parent.layer.getFrameIndex(window.name); + var $ = layui.$, + form = layui.form; + + matchingLanguage(); + form.render(); +}); + +/** + * 文件上传成功后的回调函数 + * @param json + */ +function uploadFileCallback(json) { + var params = { + name: json.bean.name, + path: json.bean.fileAddress, + type: json.bean.fileType, + size: json.bean.size, + sizeType: json.bean.fileSizeType, + catalog: isNull(parent.categoryId) ? '0' : parent.categoryId, + }; + AjaxPostUtil.request({url: reqBasePath + "createEnclosure", params: params, type: 'json', method: 'POST', callback: function (json) { + + }}); +} + diff --git a/common/src/main/resources/template/js/sysEnclosure/myEnclosureList.js b/common/src/main/resources/template/js/sysEnclosure/myEnclosureList.js new file mode 100644 index 000000000..f1be99a9c --- /dev/null +++ b/common/src/main/resources/template/js/sysEnclosure/myEnclosureList.js @@ -0,0 +1,91 @@ + +var rowId; + +var categoryId = ""; + +layui.config({ + base: basePath, + version: skyeyeVersion +}).extend({ + window: 'js/winui.window' +}).define(['window', 'table', 'jquery', 'winui'], function (exports) { + winui.renderColor(); + var $ = layui.jquery, + form = layui.form, + table = layui.table; + var serviceClassName = sysServiceMation["enclosure"]["key"]; + + catalogTreeUtil.init({ + boxId: 'catalogBox', + className: serviceClassName, + addOrUser: true, + isRoot: 1, + chooseCallback: function (chooseId) { + categoryId = chooseId; + refreshTable(); + } + }); + + table.render({ + id: 'messageTable', + elem: '#messageTable', + method: 'post', + url: reqBasePath + 'sysenclosure004', + where: getTableParams(), + even: true, + page: true, + limits: getLimits(), + limit: getLimit(), + cols: [[ + { title: systemLanguage["com.skyeye.serialNumber"][languageType], type: 'numbers' }, + { field: 'name', title: '文件名', align: 'left', width: 400 }, + { field: 'size', title: '文件大小', align: 'center', width: 120 }, + { field: 'createTime', title: '上传时间', align: 'center', width: 150 }, + { title: systemLanguage["com.skyeye.operation"][languageType], fixed: 'right', align: 'center', width: 150, toolbar: '#tableBar' } + ]], + done: function(json) { + matchingLanguage(); + initTableSearchUtil.initAdvancedSearch(this, json.searchFilter, form, "请输入文件名", function () { + table.reloadData("messageTable", {page: {curr: 1}, where: getTableParams()}); + }); + } + }); + + table.on('tool(messageTable)', function (obj) { + var data = obj.data; + var layEvent = obj.event; + if (layEvent === 'download'){ //下载 + download(fileBasePath + data.path, data.name); + } + }); + + // 上传附件 + $("body").on("click", "#addSenclosureBean", function (e) { + _openNewWindows({ + url: "../../tpl/sysEnclosure/enclosureUpload.html", + title: "上传附件", + pageId: "enclosureUpload", + area: ['70vw', '70vh'], + callBack: function (refreshCode) { + loadThisFolderChild(); + }}); + }); + + form.render(); + $("body").on("click", "#reloadTable", function() { + loadTable(); + }); + function loadTable() { + table.reloadData("messageTable", {where: getTableParams()}); + } + + function refreshTable(){ + table.reloadData("messageTable", {page: {curr: 1}, where: getTableParams()}); + } + + function getTableParams() { + return $.extend(true, {catelogId: categoryId}, initTableSearchUtil.getSearchValue("messageTable")); + } + + exports('myEnclosureList', {}); +}); diff --git a/common/src/main/resources/template/js/sysenclosure/addenclosure.js b/common/src/main/resources/template/js/sysenclosure/addenclosure.js deleted file mode 100644 index dfc5e642b..000000000 --- a/common/src/main/resources/template/js/sysenclosure/addenclosure.js +++ /dev/null @@ -1,40 +0,0 @@ - -layui.config({ - base: basePath, - version: skyeyeVersion -}).extend({ - window: 'js/winui.window' -}).define(['window', 'jquery', 'winui'], function (exports) { - winui.renderColor(); - layui.use(['form'], function (form) { - var index = parent.layer.getFrameIndex(window.name); - var $ = layui.$; - - var parentId = parent.folderId; - - $("#parentFolderName").html(parent.folderName); - - matchingLanguage(); - form.render(); - form.on('submit(formAddBean)', function (data) { - if (winui.verifyForm(data.elem)) { - if(parentId == 1 || parentId === '1'){ - parentId = "0"; - } - var params = { - typeName: $("#typeName").val(), - parentId: parentId - }; - AjaxPostUtil.request({url: reqBasePath + "sysenclosure002", params: params, type: 'json', callback: function (json) { - parent.layer.close(index); - parent.refreshCode = '0'; - }}); - } - return false; - }); - - $("body").on("click", "#cancle", function() { - parent.layer.close(index); - }); - }); -}); \ No newline at end of file diff --git a/common/src/main/resources/template/js/sysenclosure/editenclosure.js b/common/src/main/resources/template/js/sysenclosure/editenclosure.js deleted file mode 100644 index 85a4df775..000000000 --- a/common/src/main/resources/template/js/sysenclosure/editenclosure.js +++ /dev/null @@ -1,47 +0,0 @@ - -layui.config({ - base: basePath, - version: skyeyeVersion -}).extend({ - window: 'js/winui.window' -}).define(['window', 'jquery', 'winui'], function (exports) { - winui.renderColor(); - layui.use(['form'], function (form) { - var index = parent.layer.getFrameIndex(window.name); - var $ = layui.$; - - var fileType = parent.fileType; - - AjaxPostUtil.request({url: reqBasePath + "sysenclosure005", params: {rowId: parent.fileId}, type: 'json', callback: function (json) { - if(isNull(json.bean)){ - winui.window.msg("该数据不存在", {icon: 5,time: 2000}); - parent.layer.close(index); - parent.refreshCode = '0'; - } else { - $("#parentFolderName").html(parent.folderName); - $("#typeName").val(json.bean.typeName); - } - }}); - - matchingLanguage(); - form.render(); - form.on('submit(formAddBean)', function (data) { - if (winui.verifyForm(data.elem)) { - var params = { - typeName: $("#typeName").val(), - fileType: fileType, - rowId: parent.fileId - }; - AjaxPostUtil.request({url: reqBasePath + "sysenclosure006", params: params, type: 'json', callback: function (json) { - parent.layer.close(index); - parent.refreshCode = '0'; - }}); - } - return false; - }); - - $("body").on("click", "#cancle", function() { - parent.layer.close(index); - }); - }); -}); \ No newline at end of file diff --git a/common/src/main/resources/template/js/sysenclosure/enclosureupload.js b/common/src/main/resources/template/js/sysenclosure/enclosureupload.js deleted file mode 100644 index eaa0def8d..000000000 --- a/common/src/main/resources/template/js/sysenclosure/enclosureupload.js +++ /dev/null @@ -1,428 +0,0 @@ - -var folderId = ""; - -layui.config({ - base: basePath, - version: skyeyeVersion -}).extend({ - window: 'js/winui.window' -}).define(['window', 'jquery', 'winui', 'webuploader'], function (exports) { - winui.renderColor(); - layui.use(['form'], function (form) { - var index = parent.layer.getFrameIndex(window.name); - var $ = layui.$; - - //附件所属目录 - folderId = parent.folderId; - if(folderId == 1 || folderId === '1'){ - folderId = "0"; - } - - //初始化上传 - loadUploadMethod(); - matchingLanguage(); - form.render(); - form.on('submit(fileUploadStart)', function (data) { - - if (winui.verifyForm(data.elem)) { - uoloadObj.upload(); - } - return false; - }); - }); -}); - -function loadUploadMethod(){ - $wrap = $('#uploader'), - // 文件容器 - $queue = $('').appendTo( $wrap.find('.queueList') ), - // 状态栏,包括进度和控制按钮 - $statusBar = $wrap.find('.statusBar'), - // 文件总体选择信息。 - $info = $statusBar.find('.info'), - // 上传按钮 - $upload = $wrap.find('.uploadBtn'), - // 没选择文件之前的内容。 - $placeHolder = $wrap.find('.placeholder'), - // 总体进度条 - $progress = $statusBar.find('.progress').hide(), - // 添加的文件数量 - fileCount = 0, - // 添加的文件总大小 - fileSize = 0, - // 优化retina, 在retina下这个值是2 - ratio = window.devicePixelRatio || 1, - // 缩略图大小 - thumbnailWidth = 110 * ratio, - thumbnailHeight = 110 * ratio, - // 可能有pedding, ready, uploading, confirm, done. - state = 'pedding', - // 所有文件的进度信息,key为file id - percentages = {}, - supportTransition = (function(){ - var s = document.createElement('p').style, - r = 'transition' in s || - 'WebkitTransition' in s || - 'MozTransition' in s || - 'msTransition' in s || - 'OTransition' in s; - s = null; - return r; - })(), - // WebUploader实例 - uploader; - if (!WebUploader.Uploader.support()) { - alert( 'Web Uploader 不支持您的浏览器!如果你使用的是IE浏览器,请尝试升级 flash 播放器'); - throw new Error( 'WebUploader does not support the browser you are using.' ); - } - - var md5; - //监听分块上传过程中的三个时间点 - WebUploader.Uploader.register({ - "before-send-file": "beforeSendFile", - "before-send": "beforeSend", - "after-send-file": "afterSendFile" - }, { - //时间点1:所有分块进行上传之前调用此函数 - beforeSendFile: function(file) { - var deferred = WebUploader.Deferred(); - //1、计算文件的唯一标记,用于断点续传 - (new WebUploader.Uploader()).md5File(file, 0, 10 * 1024 * 1024) - .progress(function(percentage) { - $('#' + file.id).find("p.state").text("正在读取文件信息..."); - }) - .then(function(val) { - md5 = val; - $('#' + file.id).find("p.state").text("成功获取文件信息..."); - //获取文件信息后进入下一步 - deferred.resolve(); - }); - return deferred.promise(); - }, - //时间点2:如果有分块上传,则每个分块上传之前调用此函数 - beforeSend: function(block) { - var deferred = WebUploader.Deferred(); - var params = { - //文件唯一标记 - "md5": md5, - //当前分块下标 - "chunk": block.chunk, - //当前分块大小 - "chunkSize": block.end - block.start - }; - AjaxPostUtil.request({url: reqBasePath + "sysenclosure009", params: params, type: 'json', callback: function (json) { - //分块存在,跳过 - deferred.reject(); - }, errorCallback: function () { - //分块不存在或不完整,重新发送该分块内容 - deferred.resolve(); - }, async: false}); - this.owner.options.formData.md5 = md5; - deferred.resolve(); - return deferred.promise(); - }, - //时间点3:所有分块上传成功后调用此函数 - afterSendFile: function (data) { - //如果分块上传成功,则通知后台合并分块 - AjaxPostUtil.request({url: reqBasePath + "sysenclosure008", params: {md5: md5, folderId: folderId, name: data.name, size: data.size}, type: 'json', callback: function (json) { - }}); - } - }); - - // 实例化 - uploader = WebUploader.create({ - pick: { - id: '#filePicker', - label: '选择文件' - }, - formData: { - folderId: folderId - }, - dnd: '#uploader .queueList', - paste: document.body, - // swf文件路径 - swf: fileBasePath + '/assets/images/Uploader.swf', - disableGlobalDnd: true,//是否禁掉整个页面的拖拽功能 - chunked: true,//是否要分片处理大文件上传 - chunkSize: 10 * 1024 * 1024, - chunkRetry: 3,//网络问题上传失败后重试次数 - threads: 1, //上传并发数 - fileSizeLimit: 2000 * 1024 * 1024,//最大2GB - fileSingleSizeLimit: 2000 * 1024 * 1024, - resize: false,//不压缩 - server: reqBasePath + 'sysenclosure007', - fileNumLimit: 300, - }); - // 添加“添加文件”的按钮, - uploader.addButton({ - id: '#filePicker2', - label: '继续添加' - }); - uploader.onUploadProgress = function(file, percentage) { - var $li = $('#'+file.id), - $percent = $li.find('.progress span'); - $percent.css('width', percentage * 100 + '%'); - percentages[file.id][1] = percentage; - updateTotalProgress(); - }; - uploader.onFileQueued = function(file) { - fileCount++; - fileSize += file.size; - if (fileCount === 1) { - $placeHolder.addClass( 'element-invisible' ); - $statusBar.show(); - } - addFile(file); - setState('ready'); - updateTotalProgress(); - }; - uploader.onFileDequeued = function(file) { - fileCount--; - fileSize -= file.size; - if (!fileCount) { - setState( 'pedding' ); - } - removeFile(file); - updateTotalProgress(); - }; - uploader.on( 'all', function( type ) { - var stats; - switch( type ) { - case 'uploadFinished': - setState( 'confirm' ); - break; - case 'startUpload': - setState( 'uploading' ); - break; - case 'stopUpload': - setState( 'paused' ); - break; - } - }); - uploader.on('uploadBeforeSend', function(block, data, headers) { - headers['X-Requested-With']= 'XMLHttpRequest'; - $.extend(headers, getRequestHeaders()); - data.folderId = folderId; - data.md5 = md5; - data.chunk = block.chunk; - data.chunkSize = block.end - block.start; - }); - uploader.onError = function(code) { - alert('Eroor: ' + code); - }; - $upload.on('click', function() { - if ($(this).hasClass( 'disabled')) { - return false; - } - if (state === 'ready') { - uploader.upload(); - } else if (state === 'paused') { - uploader.upload(); - } else if (state === 'uploading') { - uploader.stop(true); - } - }); - $info.on('click', '.retry', function() { - uploader.retry(); - }); - $info.on('click', '.ignore', function() { - alert('todo'); - }); - $upload.addClass('state-' + state); - updateTotalProgress(); -} - -//当有文件添加进来时执行,负责view的创建 -function addFile( file ) { - var $li = $( '
  • ' + '

    ' + file.name + '

    ' + '

    ' + '

    ' + '
  • ' ), - $btns = $('
    ' + '删除' + '向右旋转' + '向左旋转
    ').appendTo( $li ), - $prgress = $li.find('p.progress span'), - $wrap = $li.find( 'p.imgWrap' ), - $info = $('

    '), - showError = function( code ) { - switch( code ) { - case 'exceed_size': - text = '文件大小超出'; - break; - - case 'interrupt': - text = '上传暂停'; - break; - - default: - text = '上传失败,请重试'; - break; - } - $info.text( text ).appendTo( $li ); - }; - if ( file.getStatus() === 'invalid' ) { - showError( file.statusText ); - } else { - $wrap.text( '预览中' ); - uploader.makeThumb( file, function( error, src ) { - if ( error ) { - $wrap.text( '不能预览' ); - return; - } - var img = $(''); - $wrap.empty().append( img ); - }, thumbnailWidth, thumbnailHeight ); - percentages[ file.id ] = [ file.size, 0 ]; - file.rotation = 0; - } - file.on('statuschange', function( cur, prev ) { - if ( prev === 'progress' ) { - $prgress.hide().width(0); - } else if ( prev === 'queued' ) { - $li.off( 'mouseenter mouseleave' ); - $btns.remove(); - } - // 成功 - if ( cur === 'error' || cur === 'invalid' ) { - showError( file.statusText ); - percentages[ file.id ][ 1 ] = 1; - } else if ( cur === 'interrupt' ) { - showError( 'interrupt' ); - } else if ( cur === 'queued' ) { - percentages[ file.id ][ 1 ] = 0; - } else if ( cur === 'progress' ) { - $info.remove(); - $prgress.css('display', 'block'); - } else if ( cur === 'complete' ) { - $li.append( '' ); - } - $li.removeClass( 'state-' + prev ).addClass( 'state-' + cur ); - }); - $li.on( 'mouseenter', function() { - $btns.stop().animate({height: 30}); - }); - $li.on( 'mouseleave', function() { - $btns.stop().animate({height: 0}); - }); - $btns.on( 'click', 'span', function() { - var index = $(this).index(), deg; - switch ( index ) { - case 0: - uploader.removeFile( file ); - return; - - case 1: - file.rotation += 90; - break; - - case 2: - file.rotation -= 90; - break; - } - if ( supportTransition ) { - deg = 'rotate(' + file.rotation + 'deg)'; - $wrap.css({ - '-webkit-transform': deg, - '-mos-transform': deg, - '-o-transform': deg, - 'transform': deg - }); - } else { - $wrap.css( 'filter', 'progid:DXImageTransform.Microsoft.BasicImage(rotation='+ (~~((file.rotation/90)%4 + 4)%4) +')'); - } - }); - $li.appendTo( $queue ); -} - -// 负责view的销毁 -function removeFile(file) { - var $li = $('#' + file.id); - delete percentages[file.id]; - updateTotalProgress(); - $li.off().find('.file-panel').off().end().remove(); -} - -function updateTotalProgress() { - var loaded = 0, - total = 0, - spans = $progress.children(), - percent; - $.each(percentages, function(k, v) { - total += v[ 0 ]; - loaded += v[ 0 ] * v[ 1 ]; - }); - percent = total ? loaded / total : 0; - spans.eq( 0 ).text( Math.round( percent * 100 ) + '%' ); - spans.eq( 1 ).css( 'width', Math.round( percent * 100 ) + '%' ); - updateStatus(); -} - -function updateStatus() { - var text = '', stats; - if (state === 'ready') { - text = '选中' + fileCount + '个文件,共' + WebUploader.formatSize(fileSize) + '。'; - } else if (state === 'confirm') { - stats = uploader.getStats(); - if (stats.uploadFailNum) { - text = '已成功上传' + stats.successNum+ '个照片至服务器,'+ stats.uploadFailNum + '个文件上传失败,重新上传失败文件或忽略' - } - } else { - stats = uploader.getStats(); - text = '共' + fileCount + '张(' + WebUploader.formatSize(fileSize) + '),已上传' + stats.successNum + '张'; - if (stats.uploadFailNum) { - text += ',失败' + stats.uploadFailNum + '张'; - } - } - $info.html(text); -} - -function setState(val) { - var file, stats; - if (val === state) { - return; - } - $upload.removeClass('state-' + state); - $upload.addClass('state-' + val); - state = val; - switch (state) { - case 'pedding': - $placeHolder.removeClass('element-invisible'); - $queue.parent().removeClass('filled'); - $queue.hide(); - $statusBar.addClass('element-invisible'); - uploader.refresh(); - break; - case 'ready': - $placeHolder.addClass('element-invisible'); - $( '#filePicker2' ).removeClass( 'element-invisible'); - $queue.parent().addClass('filled'); - $queue.show(); - $statusBar.removeClass('element-invisible'); - uploader.refresh(); - break; - case 'uploading': - $( '#filePicker2' ).addClass( 'element-invisible' ); - $progress.show(); - $upload.text( '暂停上传' ); - break; - case 'paused': - $progress.show(); - $upload.text( '继续上传' ); - break; - case 'confirm': - $progress.hide(); - $upload.text( '开始上传' ).addClass( 'disabled' ); - stats = uploader.getStats(); - if ( stats.successNum && !stats.uploadFailNum ) { - setState( 'finish' ); - return; - } - break; - case 'finish': - stats = uploader.getStats(); - if (stats.successNum) { - alert( '上传成功' ); - } else { - // 没有成功的文件,重设 - state = 'done'; - location.reload(); - } - break; - } - updateStatus(); -} diff --git a/common/src/main/resources/template/js/sysenclosure/mysysenclosure.js b/common/src/main/resources/template/js/sysenclosure/mysysenclosure.js deleted file mode 100644 index 94b904d28..000000000 --- a/common/src/main/resources/template/js/sysenclosure/mysysenclosure.js +++ /dev/null @@ -1,197 +0,0 @@ - -var folderId = "1";//当前树所在文件夹目录的位置 -var folderName = "";//当前树所在文件夹目录的位置名称 -var fileType = "";//表格编辑时的文件类型 -var fileId = "";//表格编辑时的文件id - -layui.config({ - base: basePath, - version: skyeyeVersion -}).extend({ - window: 'js/winui.window' -}).define(['window', 'table', 'jquery', 'winui', 'fsCommon', 'fsTree', 'viewer', 'contextMenu'], function (exports) { - winui.renderColor(); - - var $ = layui.jquery, - fsTree = layui.fsTree, - fsCommon = layui.fsCommon, - table = layui.table; - - //模板对象 - var treeNorightTemplate = $('#treeNorightTemplate').html(), - treerightTemplate = $("#treerightTemplate").html(); - - /********* tree 处理 start *************/ - var ztree = null; - fsTree.render({ - id: "treeDemo", - url: reqBasePath + "sysenclosure001", - checkEnable: false, - loadEnable: true,//异步加载 - showLine: false, - showIcon: true, - clickCallback: zTreeOnClick, - onDblClick: function(){ - }, - onAsyncSuccess: function(id){ - } - }, function(id){ - ztree = $.fn.zTree.getZTreeObj(id); - loadThisFolderChild();//加载子文件夹 - }); - - /** - * 点击事件 - */ - function zTreeOnClick(event, treeId, treeNode) { - if(treeNode.id != folderId){ - folderId = treeNode.id; - loadThisFolderChild(); - } - //展开 - if(!treeNode.open){//如果节点不展开,则展开 - ztree.expandNode(treeNode); - } - }; - - /********* tree 处理 end *************/ - - - //默认初始化树 - var initTreeSel = false; - - /** - * 加载子文件夹过度动画 - */ - function loadThisFolderChild(){ - setTimeout(function(){ - loadThisFolderChildData(); - }, 200); - } - - /** - * 加载子文件夹 - */ - function loadThisFolderChildData(){ - - if(!initTreeSel){ - initTreeSel = true; - ztree.expandNode(ztree.getNodeByParam("id", folderId, null));//展开指定节点-我的文档 - ztree.selectNode(ztree.getNodeByParam("id", folderId, null));//选中指定节点-我的文档 - table.render({ - id: 'messageTable', - elem: '#messageTable', - method: 'post', - url: reqBasePath + 'sysenclosure004', - where: {parentId: folderId}, - even: true, - page: false, - cols: [[ - { title: systemLanguage["com.skyeye.serialNumber"][languageType], type: 'numbers' }, - { field: 'name', title: '文件名', align: 'left', width: 400 }, - { field: 'fileSize', title: '文件大小', align: 'center', width: 120}, - { field: 'createTime', title: '上传时间', align: 'center', width: 150 }, - { title: systemLanguage["com.skyeye.operation"][languageType], fixed: 'right', align: 'center', width: 150, toolbar: '#tableBar'} - ]], - done: function(json) { - matchingLanguage(); - } - }); - - table.on('tool(messageTable)', function (obj) { - var data = obj.data; - var layEvent = obj.event; - if (layEvent === 'edit') { //编辑 - edit(data); - } else if (layEvent === 'download'){ //下载 - download(fileBasePath + data.fileAddress, data.name); - } - }); - } else { - table.reloadData("messageTable", {where:{parentId: folderId}}); - } - - } - - //编辑 - function edit(data) { - var node = ztree.getNodeByParam("id", folderId, null); - folderName = getFilePath(node); - fileType = data.fileType; - fileId = data.id; - var _title = ""; - if (data.fileType === 'folder'){ - _title = "编辑文件夹"; - } else { - _title = "编辑文件"; - } - _openNewWindows({ - url: "../../tpl/sysenclosure/editenclosure.html", - title: _title, - pageId: "editenclosurepage", - area: ['400px', '200px'], - callBack: function (refreshCode) { - winui.window.msg(systemLanguage["com.skyeye.successfulOperation"][languageType], {icon: 1, time: 2000}); - refreshTreePointNode(); - loadThisFolderChild(); - }}); - } - - //刷新树指定节点 - function refreshTreePointNode(){ - //刷新节点 - var nownode = ztree.getNodesByParam("id", folderId, null); - ztree.reAsyncChildNodes(nownode[0], "refresh"); - } - - //新增文件夹 - $("body").on("click", "#addFolderBean", function (e) { - var node = ztree.getNodeByParam("id", folderId, null); - folderName = getFilePath(node); - if(folderName.split('/').length >= 4){ - winui.window.msg("只允许添加两层级别的文件夹", {icon: 5,time: 2000}); - return; - } - _openNewWindows({ - url: "../../tpl/sysenclosure/addenclosure.html", - title: "新增文件夹", - pageId: "addenclosurepage", - area: ['400px', '200px'], - callBack: function (refreshCode) { - winui.window.msg(systemLanguage["com.skyeye.successfulOperation"][languageType], {icon: 1, time: 2000}); - refreshTreePointNode(); - loadThisFolderChild(); - }}); - }); - - //上传附件 - $("body").on("click", "#addSenclosureBean", function (e) { - _openNewWindows({ - url: "../../tpl/sysenclosure/enclosureupload.html", - title: "上传附件", - pageId: "enclosureuploadpage", - area: ['400px', '350px'], - callBack: function (refreshCode) { - loadThisFolderChild(); - }}); - }); - - //刷新数据 - $("body").on("click", "#reloadTable", function (e) { - refreshTreePointNode(); - loadThisFolderChild(); - }); - - //获取指定节点的所有父节点的名字 - function getFilePath(treeObj) { - if (treeObj == null) return ""; - var filename = treeObj.name + '/'; - var pNode = treeObj.getParentNode(); - if (pNode != null) { - filename = getFilePath(pNode) + filename; - } - return filename; - } - - exports('myNote', {}); -}); diff --git a/common/src/main/resources/template/js/uploadFile/uploadFile.js b/common/src/main/resources/template/js/uploadFile/uploadFile.js index 0b8941437..25f6e4399 100644 --- a/common/src/main/resources/template/js/uploadFile/uploadFile.js +++ b/common/src/main/resources/template/js/uploadFile/uploadFile.js @@ -7,64 +7,66 @@ layui.config({ window: 'js/winui.window' }).define(['window', 'jquery', 'winui', 'webuploader'], function (exports) { winui.renderColor(); - layui.use(['form'], function (form) { - var index = parent.layer.getFrameIndex(window.name); - var $ = layui.$; - type = GetUrlParam("type"); - - // 初始化上传 - loadUploadMethod(); - matchingLanguage(); - form.render(); - form.on('submit(fileUploadStart)', function (data) { - if (winui.verifyForm(data.elem)) { - uoloadObj.upload(); - } - return false; - }); + var index = parent.layer.getFrameIndex(window.name); + var $ = layui.$, + form = layui.form; + type = GetUrlParam("type"); + if (isNull(type)) { + winui.window.msg('文件类型不能为空.', {icon: 2, time: 2000}); + return false; + } + // 初始化上传 + loadUploadMethod(); + matchingLanguage(); + form.render(); + form.on('submit(fileUploadStart)', function (data) { + if (winui.verifyForm(data.elem)) { + uoloadObj.upload(); + } + return false; }); }); function loadUploadMethod(){ $wrap = $('#uploader'), - // 文件容器 - $queue = $('').appendTo( $wrap.find('.queueList') ), - // 状态栏,包括进度和控制按钮 - $statusBar = $wrap.find('.statusBar'), - // 文件总体选择信息。 - $info = $statusBar.find('.info'), - // 上传按钮 - $upload = $wrap.find('.uploadBtn'), - // 没选择文件之前的内容。 - $placeHolder = $wrap.find('.placeholder'), - // 总体进度条 - $progress = $statusBar.find('.progress').hide(), - // 添加的文件数量 - fileCount = 0, - // 添加的文件总大小 - fileSize = 0, - // 优化retina, 在retina下这个值是2 - ratio = window.devicePixelRatio || 1, - // 缩略图大小 - thumbnailWidth = 110 * ratio, - thumbnailHeight = 110 * ratio, - // 可能有pedding, ready, uploading, confirm, done. - state = 'pedding', - // 所有文件的进度信息,key为file id - percentages = {}, - supportTransition = (function(){ - var s = document.createElement('p').style, - r = 'transition' in s || - 'WebkitTransition' in s || - 'MozTransition' in s || - 'msTransition' in s || - 'OTransition' in s; - s = null; - return r; - })(), - // WebUploader实例 - uploader; + // 文件容器 + $queue = $('').appendTo( $wrap.find('.queueList') ), + // 状态栏,包括进度和控制按钮 + $statusBar = $wrap.find('.statusBar'), + // 文件总体选择信息。 + $info = $statusBar.find('.info'), + // 上传按钮 + $upload = $wrap.find('.uploadBtn'), + // 没选择文件之前的内容。 + $placeHolder = $wrap.find('.placeholder'), + // 总体进度条 + $progress = $statusBar.find('.progress').hide(), + // 添加的文件数量 + fileCount = 0, + // 添加的文件总大小 + fileSize = 0, + // 优化retina, 在retina下这个值是2 + ratio = window.devicePixelRatio || 1, + // 缩略图大小 + thumbnailWidth = 110 * ratio, + thumbnailHeight = 110 * ratio, + // 可能有pedding, ready, uploading, confirm, done. + state = 'pedding', + // 所有文件的进度信息,key为file id + percentages = {}, + supportTransition = (function(){ + var s = document.createElement('p').style, + r = 'transition' in s || + 'WebkitTransition' in s || + 'MozTransition' in s || + 'msTransition' in s || + 'OTransition' in s; + s = null; + return r; + })(), + // WebUploader实例 + uploader; if (!WebUploader.Uploader.support()) { alert( 'Web Uploader 不支持您的浏览器!如果你使用的是IE浏览器,请尝试升级 flash 播放器'); throw new Error( 'WebUploader does not support the browser you are using.' ); @@ -97,9 +99,9 @@ function loadUploadMethod(){ beforeSend: function(block) { var deferred = WebUploader.Deferred(); var params = { - "md5": md5, - "chunk": block.chunk, - "chunkSize": block.end - block.start + md5: md5, + chunk: block.chunk, + chunkSize: block.end - block.start }; // 判断指定块是否已经上传 AjaxPostUtil.request({url: reqBasePath + "checkUploadFileChunks", params: params, type: 'json', method: 'POST', callback: function (json) { @@ -118,11 +120,14 @@ function loadUploadMethod(){ var params = { md5: md5, name: data.name, - size: data.size + size: data.size, + type: type }; // 如果分块上传成功,则通知后台合并分块 - AjaxPostUtil.request({url: reqBasePath + "uploadFileChunks", params: params, type: 'json', method: 'POST', callback: function (json) { - // todo 待处理 + AjaxPostUtil.request({url: reqBasePath + "skyeyeUploadFileChunks", params: params, type: 'json', method: 'POST', callback: function (json) { + if (typeof(parent.uploadFileCallback) == "function") { + parent.uploadFileCallback(json); + } }}); } }); @@ -145,7 +150,7 @@ function loadUploadMethod(){ fileSizeLimit: 2000 * 1024 * 1024,//最大2GB fileSingleSizeLimit: 2000 * 1024 * 1024, resize: false,//不压缩 - server: reqBasePath + 'uploadFile', + server: reqBasePath + 'skyeyeUploadFile', fileNumLimit: 300 }); // 添加“添加文件”的按钮, diff --git a/common/src/main/resources/template/tpl/sysEnclosure/enclosureBusinessChoose.html b/common/src/main/resources/template/tpl/sysEnclosure/enclosureBusinessChoose.html new file mode 100644 index 000000000..06adfa76f --- /dev/null +++ b/common/src/main/resources/template/tpl/sysEnclosure/enclosureBusinessChoose.html @@ -0,0 +1,44 @@ + + + + + + + + + + + +
    + +
    +
    + +
    +
    +
      +
      +
      +
      +
      +
      + + +
      +
      + + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/resources/template/tpl/sysEnclosure/enclosureUpload.html b/common/src/main/resources/template/tpl/sysEnclosure/enclosureUpload.html new file mode 100644 index 000000000..8e15f2fd5 --- /dev/null +++ b/common/src/main/resources/template/tpl/sysEnclosure/enclosureUpload.html @@ -0,0 +1,26 @@ + + + + + + + + + +
      + +
      +
      + +
      +
      +
      + + + + + \ No newline at end of file diff --git a/common/src/main/resources/template/tpl/sysEnclosure/myEnclosureList.html b/common/src/main/resources/template/tpl/sysEnclosure/myEnclosureList.html new file mode 100644 index 000000000..ae41d5a51 --- /dev/null +++ b/common/src/main/resources/template/tpl/sysEnclosure/myEnclosureList.html @@ -0,0 +1,38 @@ + + + + + + + + + +
      +
      + + +
      +
      +
      +
      +
      + +
      +
      +
      +
      + +
      +
      + + + + + + \ No newline at end of file diff --git a/common/src/main/resources/template/tpl/sysenclosure/addenclosure.html b/common/src/main/resources/template/tpl/sysenclosure/addenclosure.html deleted file mode 100644 index 795285811..000000000 --- a/common/src/main/resources/template/tpl/sysenclosure/addenclosure.html +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - -
      -
      -
      - -
      - -
      -
      -
      - -
      - -
      -
      -
      -
      - - -
      -
      -
      -
      - - - - - \ No newline at end of file diff --git a/common/src/main/resources/template/tpl/sysenclosure/editenclosure.html b/common/src/main/resources/template/tpl/sysenclosure/editenclosure.html deleted file mode 100644 index 862cebaba..000000000 --- a/common/src/main/resources/template/tpl/sysenclosure/editenclosure.html +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - -
      -
      -
      - -
      - -
      -
      -
      - -
      - -
      -
      -
      -
      - - -
      -
      -
      -
      - - - - - \ No newline at end of file diff --git a/common/src/main/resources/template/tpl/sysenclosure/enclosureupload.html b/common/src/main/resources/template/tpl/sysenclosure/enclosureupload.html deleted file mode 100644 index d45fee36c..000000000 --- a/common/src/main/resources/template/tpl/sysenclosure/enclosureupload.html +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - -
      -
      - -
      -
      -
      -
      -
      -
      -
      -
      -

      或将文件拖到这里,单次最多可选300个

      -
      -
      - -
      -
      -
      -
      -
      2
      -
      -
      -
      - - - - - \ No newline at end of file diff --git a/common/src/main/resources/template/tpl/sysenclosure/mysysenclosure.html b/common/src/main/resources/template/tpl/sysenclosure/mysysenclosure.html deleted file mode 100644 index aed81de4d..000000000 --- a/common/src/main/resources/template/tpl/sysenclosure/mysysenclosure.html +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - - - -
      -
      - - - -
      -
      -
      -
      -
      - ‘我的附件’属于根目录,不算在文件夹级别内,除了‘我的附件’只允许添加两层级别的文件夹 -
      -
      -
        -
        -
        -
        -
        - -
        -
        - - - - - - - - - - \ No newline at end of file diff --git a/common/src/main/resources/template/tpl/uploadFile/uploadFile.html b/common/src/main/resources/template/tpl/uploadFile/uploadFile.html index f281ca1ca..f532d1305 100644 --- a/common/src/main/resources/template/tpl/uploadFile/uploadFile.html +++ b/common/src/main/resources/template/tpl/uploadFile/uploadFile.html @@ -8,7 +8,6 @@ -
        -
        -
        -
        -
        -
        -
        -

        或将文件拖到这里,单次最多可选300个

        -
        -
        - + +
        +
        +
        +
        +

        或将文件拖到这里,单次最多可选300个

        - -
        + +
        + `; + $("#" + showBoxId).append(_html + _js); + } else { + var _html = catalogTreeUtil.getShowTteeHtml(showBoxId, isRoot); + var _js = ``; + $("#" + showBoxId).append(_html + _js); + $("#" + showBoxId + "Choose").on("change", function() { + if (typeof (catalogTreeUtil.config.chooseCallback) == "function") { + catalogTreeUtil.config.chooseCallback($(this).val()); + } + }); + } + }, + + getShowTteeHtml: function (showBoxId, isRoot) { + var _html = ` + +
        +
        + + +
        +
        +
        +
          +
          + + + + + `; + return _html; + }, + + /** + * 一次性获取所有数据 + */ + getData: function () { + var data = []; + var params = { + objectId: catalogTreeUtil.config.objectId, + objectKey: catalogTreeUtil.config.className, + addOrUser: catalogTreeUtil.config.addOrUser + }; + AjaxPostUtil.request({url: reqBasePath + "queryCatalogForTree", params: params, type: 'json', method: "POST", callback: function(json) { + data = [].concat(json.rows); + }, async: false}); + return data; + } + +}; diff --git a/web/src/main/resources/template/assets/lib/winui/css/winui.css b/web/src/main/resources/template/assets/lib/winui/css/winui.css index 72e7d2ac0..ce28ebf00 100644 --- a/web/src/main/resources/template/assets/lib/winui/css/winui.css +++ b/web/src/main/resources/template/assets/lib/winui/css/winui.css @@ -4858,6 +4858,7 @@ body .layer-ext-winconfirm .layui-layer-content { } .wu-example { + height: calc(100% - 20px); position: relative; padding: 0px 15px 15px; margin: 0; @@ -4884,10 +4885,10 @@ body .layer-ext-winconfirm .layui-layer-content { } #uploader .placeholder { - min-height: 350px; - padding-top: 178px; + min-height: 90px; + padding-top: 110px; text-align: center; - background: url(../../../images/image.png) center 93px no-repeat; + background: url(../../../images/image.png) center 20px no-repeat; color: #cccccc; font-size: 18px; position: relative; @@ -4976,6 +4977,7 @@ body .layer-ext-winconfirm .layui-layer-content { } #uploader .queueList { + max-height: calc(100% - 20px); margin: 10px 5px; border: 3px dashed #e6e6e6; } @@ -4996,16 +4998,6 @@ body .layer-ext-winconfirm .layui-layer-content { clip: rect(1px,1px,1px,1px); } -#uploader .placeholder { - min-height: 90px; - padding-top: 110px; - text-align: center; - background: url(../../../images/image.png) center 20px no-repeat; - color: #cccccc; - font-size: 13px; - position: relative; -} - #uploader .placeholder .webuploader-pick { font-size: 13px; background: #00b7ee; diff --git a/web/src/main/resources/template/js/common/enclosureupload.js b/web/src/main/resources/template/js/common/enclosureupload.js deleted file mode 100644 index 1b0c8499b..000000000 --- a/web/src/main/resources/template/js/common/enclosureupload.js +++ /dev/null @@ -1,544 +0,0 @@ - -var folderId = ""; - -var enclosureList = new Array(); - -layui.config({ - base: basePath, - version: skyeyeVersion -}).extend({ - window: 'js/winui.window' -}).define(['window', 'jquery', 'winui', 'webuploader', 'fsTree'], function (exports) { - winui.renderColor(); - layui.use(['form'], function (form) { - var index = parent.layer.getFrameIndex(window.name); - var $ = layui.$, - fsTree = layui.fsTree; - - // 附件所属目录 - folderId = "0"; - var boxId = GetUrlParam('boxId'); - enclosureList = [].concat(JSON.parse(parent.$("#" + boxId).attr(skyeyeEnclosure.enclosureListKey))); - - // 初始化上传 - loadUploadMethod(); - matchingLanguage(); - form.render(); - form.on('submit(fileUploadStart)', function (data) { - if (winui.verifyForm(data.elem)) { - uoloadObj.upload(); - } - return false; - }); - - var ztree = null; - /********* tree 处理 start *************/ - loadMyEnclosureList(); - function loadMyEnclosureList(){ - fsTree.render({ - id: "treeDemo", - url: reqBasePath + "sysenclosure010", - checkEnable: true, - loadEnable: false,//异步加载 - showLine: false, - showIcon: true, - onDblClick: function(){ - }, - onAsyncSuccess: function(id){ - }, - onCheck: zTreeOnCheck //选中回调函数 - }, function(id){ - ztree = $.fn.zTree.getZTreeObj(id); - var zTreeChecked = ztree.getCheckedNodes(false); - for (var i = 0; i < zTreeChecked.length; i++) { - for(var j = 0; j < enclosureList.length; j++){ - if(zTreeChecked[i].id == enclosureList[j].id){ - ztree.checkNode(zTreeChecked[i], true, true); - } - } - } - loadThisFolderChild(); - }); - } - - function loadThisFolderChild(){ - ztree.expandNode(ztree.getNodeByParam("id", "1", null));//展开指定节点-我的文档 - ztree.selectNode(ztree.getNodeByParam("id", "1", null));//选中指定节点-我的文档 - } - - //选中或取消选中的回调函数 - function zTreeOnCheck(event, treeId, treeNode){ - //获取选中节点 - var zTree = ztree.getCheckedNodes(true); - for (var i = 0; i < zTree.length; i++) { - if (!isNull(zTree[i].fileType) && zTree[i].fileType != "folder"){ - addToArray({ - id: zTree[i].id, - name: zTree[i].name, - fileAddress: zTree[i].fileAddress - }); - } - } - //获取未选中节点 - zTree = ztree.getCheckedNodes(false); - for (var i = 0; i < zTree.length; i++) { - if (!isNull(zTree[i].fileType) && zTree[i].fileType != "folder"){ - removeToArray(zTree[i].id); - } - } - } - - /********* tree 处理 end *************/ - - // 取消 - $("body").on("click", "#cancle", function() { - parent.layer.close(index); - }); - - //确定 - $("body").on("click", "#confimChoose", function() { - var nodes = ztree.getCheckedNodes(true); - for(var i = 0; i < nodes.length; i++){ - var node = nodes[i]; - if (!isNull(node.fileType) && node.fileType != "folder"){ - addToArray({ - id: node.id, - name: node.name, - fileAddress: node.fileAddress - }); - } - } - parent.layer.close(index); - parent.$("#" + boxId).attr(skyeyeEnclosure.enclosureListKey, JSON.stringify(enclosureList)); - parent.refreshCode = '0'; - }); - - }); -}); - -//向集合中添加元素 -//参数为json -function addToArray(data) { - var inArray = false; - $.each(enclosureList, function(i, item) { - if(item.id === data.id){ - inArray = true; - return false; - } - }); - if(!inArray){//如果该元素在集合中不存在 - enclosureList.push({ - id: data.id, - name: data.name, - fileAddress: data.fileAddress - }); - } -} - -//移除集合中的元素 -function removeToArray(id){ - var inArray = -1; - $.each(enclosureList, function(i, item) { - if(id === item.id) { - inArray = i; - return false; - } - }); - if(inArray != -1){//如果该元素在集合中存在 - enclosureList.splice(inArray, 1); - } -} - -function loadUploadMethod(){ - $wrap = $('#uploader'), - // 文件容器 - $queue = $('
            ').appendTo( $wrap.find('.queueList') ), - // 状态栏,包括进度和控制按钮 - $statusBar = $wrap.find('.statusBar'), - // 文件总体选择信息。 - $info = $statusBar.find('.info'), - // 上传按钮 - $upload = $wrap.find('.uploadBtn'), - // 没选择文件之前的内容。 - $placeHolder = $wrap.find('.placeholder'), - // 总体进度条 - $progress = $statusBar.find('.progress').hide(), - // 添加的文件数量 - fileCount = 0, - // 添加的文件总大小 - fileSize = 0, - // 优化retina, 在retina下这个值是2 - ratio = window.devicePixelRatio || 1, - // 缩略图大小 - thumbnailWidth = 110 * ratio, - thumbnailHeight = 110 * ratio, - // 可能有pedding, ready, uploading, confirm, done. - state = 'pedding', - // 所有文件的进度信息,key为file id - percentages = {}, - supportTransition = (function(){ - var s = document.createElement('p').style, - r = 'transition' in s || - 'WebkitTransition' in s || - 'MozTransition' in s || - 'msTransition' in s || - 'OTransition' in s; - s = null; - return r; - })(), - // WebUploader实例 - uploader; - if (!WebUploader.Uploader.support()) { - alert( 'Web Uploader 不支持您的浏览器!如果你使用的是IE浏览器,请尝试升级 flash 播放器'); - throw new Error( 'WebUploader does not support the browser you are using.' ); - } - - var md5; - //监听分块上传过程中的三个时间点 - WebUploader.Uploader.register({ - "before-send-file": "beforeSendFile", - "before-send": "beforeSend", - "after-send-file": "afterSendFile" - }, { - //时间点1:所有分块进行上传之前调用此函数 - beforeSendFile: function(file) { - var deferred = WebUploader.Deferred(); - //1、计算文件的唯一标记,用于断点续传 - (new WebUploader.Uploader()).md5File(file, 0, 10 * 1024 * 1024) - .progress(function(percentage) { - $('#' + file.id).find("p.state").text("正在读取文件信息..."); - }) - .then(function(val) { - md5 = val; - $('#' + file.id).find("p.state").text("成功获取文件信息..."); - //获取文件信息后进入下一步 - deferred.resolve(); - }); - return deferred.promise(); - }, - //时间点2:如果有分块上传,则每个分块上传之前调用此函数 - beforeSend: function(block) { - var deferred = WebUploader.Deferred(); - var params = { - "md5": md5, - "chunk": block.chunk, - "chunkSize": block.end - block.start - }; - AjaxPostUtil.request({url: reqBasePath + "checkUploadFileChunks", params: params, type: 'json', callback: function (json) { - //分块存在,跳过 - deferred.reject(); - }, errorCallback: function () { - //分块不存在或不完整,重新发送该分块内容 - deferred.resolve(); - },async: false}); - this.owner.options.formData.md5 = md5; - deferred.resolve(); - return deferred.promise(); - }, - //时间点3:所有分块上传成功后调用此函数 - afterSendFile: function (data) { - //如果分块上传成功,则通知后台合并分块 - AjaxPostUtil.request({url: reqBasePath + "uploadFileChunks", params: {md5: md5, folderId: folderId, name: data.name, size: data.size}, type: 'json', callback: function (json) { - addToArray(json.bean); - }}); - } - }); - - // 实例化 - uploader = WebUploader.create({ - pick: { - id: '#filePicker', - label: '选择文件' - }, - formData: { - folderId: folderId - }, - dnd: '#uploader .queueList', - paste: document.body, - // swf文件路径 - swf: fileBasePath + '/assets/images/Uploader.swf', - disableGlobalDnd: true,//是否禁掉整个页面的拖拽功能 - chunked: true,//是否要分片处理大文件上传 - chunkSize: 10 * 1024 * 1024, - chunkRetry: 3,//网络问题上传失败后重试次数 - threads: 1, //上传并发数 - fileSizeLimit: 2000 * 1024 * 1024,//最大2GB - fileSingleSizeLimit: 2000 * 1024 * 1024, - resize: false,//不压缩 - server: reqBasePath + 'uploadFile', - fileNumLimit: 300 - }); - // 添加“添加文件”的按钮, - uploader.addButton({ - id: '#filePicker2', - label: '继续添加' - }); - uploader.onUploadProgress = function(file, percentage) { - var $li = $('#'+file.id), - $percent = $li.find('.progress span'); - $percent.css('width', percentage * 100 + '%'); - percentages[file.id][1] = percentage; - updateTotalProgress(); - }; - uploader.onFileQueued = function(file) { - fileCount++; - fileSize += file.size; - if (fileCount === 1) { - $placeHolder.addClass( 'element-invisible' ); - $statusBar.show(); - } - addFile(file); - setState('ready'); - updateTotalProgress(); - }; - uploader.onFileDequeued = function(file) { - fileCount--; - fileSize -= file.size; - if (!fileCount) { - setState( 'pedding' ); - } - removeFile(file); - updateTotalProgress(); - }; - uploader.on( 'all', function( type ) { - var stats; - switch( type ) { - case 'uploadFinished': - setState( 'confirm' ); - break; - case 'startUpload': - setState( 'uploading' ); - break; - case 'stopUpload': - setState( 'paused' ); - break; - } - }); - uploader.on('uploadBeforeSend', function(block, data, headers) { - headers['X-Requested-With']= 'XMLHttpRequest'; - $.extend(headers, getRequestHeaders()); - data.folderId = folderId; - data.md5 = md5; - data.chunk = block.chunk; - data.chunkSize = block.end - block.start; - }); - uploader.onError = function(code) { - alert('Eroor: ' + code); - }; - $upload.on('click', function() { - if ($(this).hasClass( 'disabled')) { - return false; - } - if (state === 'ready') { - uploader.upload(); - } else if (state === 'paused') { - uploader.upload(); - } else if (state === 'uploading') { - uploader.stop(true); - } - }); - $info.on('click', '.retry', function() { - uploader.retry(); - }); - $info.on('click', '.ignore', function() { - alert('todo'); - }); - $upload.addClass('state-' + state); - updateTotalProgress(); -} - -//当有文件添加进来时执行,负责view的创建 -function addFile( file ) { - var $li = $( '
          • ' + '

            ' + file.name + '

            ' + '

            ' + '

            ' + '
          • ' ), - $btns = $('
            ' + '删除' + '向右旋转' + '向左旋转
            ').appendTo( $li ), - $prgress = $li.find('p.progress span'), - $wrap = $li.find( 'p.imgWrap' ), - $info = $('

            '), - showError = function( code ) { - switch( code ) { - case 'exceed_size': - text = '文件大小超出'; - break; - - case 'interrupt': - text = '上传暂停'; - break; - - default: - text = '上传失败,请重试'; - break; - } - $info.text( text ).appendTo( $li ); - }; - if ( file.getStatus() === 'invalid' ) { - showError( file.statusText ); - } else { - $wrap.text( '预览中' ); - uploader.makeThumb( file, function( error, src ) { - if ( error ) { - $wrap.text( '不能预览' ); - return; - } - var img = $(''); - $wrap.empty().append( img ); - }, thumbnailWidth, thumbnailHeight ); - percentages[ file.id ] = [ file.size, 0 ]; - file.rotation = 0; - } - file.on('statuschange', function( cur, prev ) { - if ( prev === 'progress' ) { - $prgress.hide().width(0); - } else if ( prev === 'queued' ) { - $li.off( 'mouseenter mouseleave' ); - $btns.remove(); - } - // 成功 - if ( cur === 'error' || cur === 'invalid' ) { - showError( file.statusText ); - percentages[ file.id ][ 1 ] = 1; - } else if ( cur === 'interrupt' ) { - showError( 'interrupt' ); - } else if ( cur === 'queued' ) { - percentages[ file.id ][ 1 ] = 0; - } else if ( cur === 'progress' ) { - $info.remove(); - $prgress.css('display', 'block'); - } else if ( cur === 'complete' ) { - $li.append( '' ); - } - $li.removeClass( 'state-' + prev ).addClass( 'state-' + cur ); - }); - $li.on( 'mouseenter', function() { - $btns.stop().animate({height: 30}); - }); - $li.on( 'mouseleave', function() { - $btns.stop().animate({height: 0}); - }); - $btns.on( 'click', 'span', function() { - var index = $(this).index(), deg; - switch ( index ) { - case 0: - uploader.removeFile( file ); - return; - - case 1: - file.rotation += 90; - break; - - case 2: - file.rotation -= 90; - break; - } - if ( supportTransition ) { - deg = 'rotate(' + file.rotation + 'deg)'; - $wrap.css({ - '-webkit-transform': deg, - '-mos-transform': deg, - '-o-transform': deg, - 'transform': deg - }); - } else { - $wrap.css( 'filter', 'progid:DXImageTransform.Microsoft.BasicImage(rotation='+ (~~((file.rotation/90)%4 + 4)%4) +')'); - } - }); - $li.appendTo( $queue ); -} - -// 负责view的销毁 -function removeFile(file) { - var $li = $('#' + file.id); - delete percentages[file.id]; - updateTotalProgress(); - $li.off().find('.file-panel').off().end().remove(); -} - -function updateTotalProgress() { - var loaded = 0, - total = 0, - spans = $progress.children(), - percent; - $.each(percentages, function(k, v) { - total += v[ 0 ]; - loaded += v[ 0 ] * v[ 1 ]; - }); - percent = total ? loaded / total : 0; - spans.eq( 0 ).text( Math.round( percent * 100 ) + '%' ); - spans.eq( 1 ).css( 'width', Math.round( percent * 100 ) + '%' ); - updateStatus(); -} - -function updateStatus() { - var text = '', stats; - if (state === 'ready') { - text = '选中' + fileCount + '个文件,共' + WebUploader.formatSize(fileSize) + '。'; - } else if (state === 'confirm') { - stats = uploader.getStats(); - if (stats.uploadFailNum) { - text = '已成功上传' + stats.successNum+ '个照片至服务器,'+ stats.uploadFailNum + '个文件上传失败,重新上传失败文件或忽略' - } - } else { - stats = uploader.getStats(); - text = '共' + fileCount + '张(' + WebUploader.formatSize(fileSize) + '),已上传' + stats.successNum + '张'; - if (stats.uploadFailNum) { - text += ',失败' + stats.uploadFailNum + '张'; - } - } - $info.html(text); -} - -function setState(val) { - var file, stats; - if (val === state) { - return; - } - $upload.removeClass('state-' + state); - $upload.addClass('state-' + val); - state = val; - switch (state) { - case 'pedding': - $placeHolder.removeClass('element-invisible'); - $queue.parent().removeClass('filled'); - $queue.hide(); - $statusBar.addClass('element-invisible'); - uploader.refresh(); - break; - case 'ready': - $placeHolder.addClass('element-invisible'); - $( '#filePicker2' ).removeClass( 'element-invisible'); - $queue.parent().addClass('filled'); - $queue.show(); - $statusBar.removeClass('element-invisible'); - uploader.refresh(); - break; - case 'uploading': - $( '#filePicker2' ).addClass( 'element-invisible' ); - $progress.show(); - $upload.text( '暂停上传' ); - break; - case 'paused': - $progress.show(); - $upload.text( '继续上传' ); - break; - case 'confirm': - $progress.hide(); - $upload.text( '开始上传' ).addClass( 'disabled' ); - stats = uploader.getStats(); - if ( stats.successNum && !stats.uploadFailNum ) { - setState( 'finish' ); - return; - } - break; - case 'finish': - stats = uploader.getStats(); - if (stats.successNum) { - alert( '上传成功' ); - } else { - // 没有成功的文件,重设 - state = 'done'; - location.reload(); - } - break; - } - updateStatus(); -} - diff --git a/web/src/main/resources/template/json/sysServiceMation.json b/web/src/main/resources/template/json/sysServiceMation.json index d6ec114ee..37a353bf6 100644 --- a/web/src/main/resources/template/json/sysServiceMation.json +++ b/web/src/main/resources/template/json/sysServiceMation.json @@ -67,5 +67,6 @@ "dictData": {"name": "数据字典", "key": "com.skyeye.eve.service.impl.SysDictDataServiceImpl"}, - "contacts": {"name": "联系人", "key": "com.skyeye.contacts.service.impl.ContactsServiceImpl"} + "contacts": {"name": "联系人", "key": "com.skyeye.contacts.service.impl.ContactsServiceImpl"}, + "enclosure": {"name": "附件", "key": "com.skyeye.enclosure.service.impl.SysEnclosureServiceImpl"} } \ No newline at end of file diff --git a/web/src/main/resources/template/tpl/common/enclosureupload.html b/web/src/main/resources/template/tpl/common/enclosureupload.html deleted file mode 100644 index 42212d33b..000000000 --- a/web/src/main/resources/template/tpl/common/enclosureupload.html +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - - - - - -
            -
            -
              -
            • 本地上传
            • -
            • 我的附件库
            • -
            -
            -
            -
            -
            -
            -
            -
            -
            -

            或将文件拖到这里,单次最多可选300个

            -
            -
            - -
            -
            -
            -
            -
            -
              -
              -
              -
              -
              -
              - - -
              -
              -
              - - - - - - - - - \ No newline at end of file -- GitLab