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 = $('
' + file.name + '
' + '' + '' + '