diff --git a/js/corporateOrg/CorporateGovernance.js b/js/corporateOrg/CorporateGovernance.js index 805d760..e3197f7 100644 --- a/js/corporateOrg/CorporateGovernance.js +++ b/js/corporateOrg/CorporateGovernance.js @@ -7,7 +7,7 @@ layui.use(['table', 'layer', 'laydate', 'jquery', 'form'], function () { table = layui.table; laydate = layui.laydate; form = layui.form; - if ($.inArray('sysCompanyManage:add', pers) < 0) { + if (pers && $.inArray('sysCompanyManage:add', pers) < 0) { var addDiv=document.getElementById('addDiv'); if(addDiv){ document.getElementById('addDiv').remove(); diff --git a/js/corporateOrg/ProjectDepartment.js b/js/corporateOrg/ProjectDepartment.js index fbfba1a..dc11c3c 100644 --- a/js/corporateOrg/ProjectDepartment.js +++ b/js/corporateOrg/ProjectDepartment.js @@ -8,7 +8,7 @@ layui.use(['table', 'layer', 'laydate', 'jquery', 'form'], function () { table = layui.table; laydate = layui.laydate; form = layui.form; - if ($.inArray('sysProjectContent:add', pers) < 0) { + if (pers && $.inArray('sysProjectContent:add', pers) < 0) { var addDiv=document.getElementById('addDiv'); if(addDiv){ document.getElementById('addDiv').remove(); diff --git a/js/corporateOrg/branch.js b/js/corporateOrg/branch.js index 7d92699..8f77acd 100644 --- a/js/corporateOrg/branch.js +++ b/js/corporateOrg/branch.js @@ -7,7 +7,7 @@ layui.use(['table', 'layer', 'laydate', 'jquery', 'form'], function () { table = layui.table; laydate = layui.laydate; form = layui.form; - if ($.inArray('sysMsgContent:add', pers) < 0) { + if (pers && $.inArray('sysMsgContent:add', pers) < 0) { var addDiv=document.getElementById('addDiv'); if(addDiv){ document.getElementById('addDiv').remove(); diff --git a/js/jq.js b/js/jq.js index e997b6c..df99fe5 100644 --- a/js/jq.js +++ b/js/jq.js @@ -1,4 +1,13 @@ +var pagesPathNew = getContextPathNew(); + +function getContextPathNew() { + var pathName = document.location.pathname; + var index = pathName.substr(1).indexOf("/"); + var result = pathName.substr(0, index + 1); + return result; +} $.ajaxSetup({ +<<<<<<< .mine cache : false, headers : { "token" : localStorage.getItem("token") @@ -20,32 +29,67 @@ $.ajaxSetup({ layer.msg('系统错误:' + message); } } + +======= + cache: false, + headers: { + token: localStorage.getItem("token"), + }, + error: function (xhr, textStatus, errorThrown) { + var msg = xhr.responseText; + var response = JSON.parse(msg); + var code = response.code; + var message = response.message; + if (code == 400) { + layer.msg(message); + } else if (code == 401) { + localStorage.removeItem("token"); + // location.href = "/hnbcbackstage/login.html"; + location.href = pagesPathNew + "/login.html"; + } else if (code == 403) { + console.log("未授权:" + message); + layer.msg("未授权"); + } else if (code == 500) { + layer.msg("系统错误:" + message); + } + }, +>>>>>>> .theirs }); -function buttonDel(data, permission, pers){ - if(permission != ""){ - if ($.inArray(permission, pers) < 0) { - return ""; - } - } - - var btn = $(""); - return btn.prop("outerHTML"); +function buttonDel(data, permission, pers) { + if (permission != "") { + if ($.inArray(permission, pers) < 0) { + return ""; + } + } + + var btn = $( + "" + ); + return btn.prop("outerHTML"); } -function buttonEdit(href, permission, pers){ - if(permission != ""){ - if ($.inArray(permission, pers) < 0) { - return ""; - } - } - - var btn = $(""); - return btn.prop("outerHTML"); +function buttonEdit(href, permission, pers) { + if (permission != "") { + if ($.inArray(permission, pers) < 0) { + return ""; + } + } + + var btn = $( + "" + ); + return btn.prop("outerHTML"); } - -function deleteCurrentTab(){ - var lay_id = $(parent.document).find("ul.layui-tab-title").children("li.layui-this").attr("lay-id"); - parent.active.tabDelete(lay_id); +function deleteCurrentTab() { + var lay_id = $(parent.document) + .find("ul.layui-tab-title") + .children("li.layui-this") + .attr("lay-id"); + parent.active.tabDelete(lay_id); } diff --git a/js/main.js b/js/main.js index 4b98759..4506917 100644 --- a/js/main.js +++ b/js/main.js @@ -6,8 +6,13 @@ function initMenu() { async: false, success: function (data) { if (!$.isArray(data)) { +<<<<<<< .mine // location.href = contentPath+'/login.html'; +======= + // location.href = ctxPath + "/login.html"; + location.href = pagesPath + "/login.html"; +>>>>>>> .theirs return; } var menu = $("#menu"); @@ -106,7 +111,13 @@ function logout() { url: ctxPath + "/logout", success: function (data) { localStorage.removeItem("token"); +<<<<<<< .mine location.href = contentPath+'/login.html'; + +======= + // location.href = ctxPath + "/login.html"; + location.href = pagesPath + "/login.html"; +>>>>>>> .theirs }, }); } diff --git a/js/my/permission.js b/js/my/permission.js index 9285ee8..40aac05 100644 --- a/js/my/permission.js +++ b/js/my/permission.js @@ -3,6 +3,11 @@ function checkPermission() { $.ajax({ type : 'get', url : ctxPath + '/permissions/owns', +<<<<<<< .mine + +======= + // contentType : "application/json; charset=utf-8", +>>>>>>> .theirs async : false, success : function(data) { pers = data; diff --git a/js/personnelPool/dome.js b/js/personnelPool/dome.js index 1476fe0..82d25a9 100644 --- a/js/personnelPool/dome.js +++ b/js/personnelPool/dome.js @@ -1,150 +1,159 @@ var startWorkFiles = {}; -var table -var form -var upload +var table; +var form; +var upload; var example = null; var pers = null; // 设置全局变量以保存选中行信息 let ids = new Array(); $(function () { - layui.use(['layer','form','table','upload'], function () { + layui.use(["layer", "form", "table", "upload"], function () { var layer = layui.layer; form = layui.form; table = layui.table; upload = layui.upload; - init(table,form,''); + init(table, form, ""); var uploadIns = upload.render({ - elem: '#importBt', //绑定元素 + elem: "#importBt", //绑定元素 url: ctxPath + "/ma/sendoff/import", - accept: 'file', //允许上传的文件类型 - exts: 'xlsx|xls', - auto: true, //是否自动上传 - multiple: false, //是否支持多文件上传 - choose: function(obj){ //选择文件后的回调函数 - + accept: "file", //允许上传的文件类型 + exts: "xlsx|xls", + auto: true, //是否自动上传 + multiple: false, //是否支持多文件上传 + choose: function (obj) { + //选择文件后的回调函数 }, - before:function(){ - layer.msg('数据导入中,请稍等。。。', { - icon: 4 + before: function () { + layer.msg("数据导入中,请稍等。。。", { + icon: 4, }); this.data = { - "fileType": "sendoff" + fileType: "sendoff", }; }, - done: function(res, index, upload){ //上传完毕的回调函数 + done: function (res, index, upload) { + //上传完毕的回调函数 layer.closeAll("loading"); - if (res.code == 200){ - layer.msg('导入成功', {icon: 1, time: 2000},function () { - table.reload('layuiTable'); + if (res.code == 200) { + layer.msg("导入成功", { icon: 1, time: 2000 }, function () { + table.reload("layuiTable"); }); } else { - layer.msg(res.msg,{icon:2}) + layer.msg(res.msg, { icon: 2 }); } - - } - ,error: function(){ + }, + error: function () { layer.closeAll("loading"); console.log("请求异常回调"); - } + }, }); $("#searchBt").click(function () { var keyWord = $("#keyWord").val(); // var title = $("#title").val(); - init(table,form,keyWord) + init(table, form, keyWord); }); $("#resetBt").click(function () { - var keyWord = '' + var keyWord = ""; $("#keyWord").val(""); // $("#title").val(""); - layui.form.render('select'); - init(table,form,keyWord) + layui.form.render("select"); + init(table, form, keyWord); }); - - }); pers = checkPermission(); -}) +}); - -function init(table,form,keyWord) { +function init(table, form, keyWord) { table.render({ - elem: '#layuiTable' - ,url: ctxPath + "/ma/sendoff/list?keyWord="+keyWord - ,method:'post' - ,cols: [[ - {type: 'checkbox', fixed: 'left'} - , { field: 'ID', title: '序号',width:'3%', sort: true, type:'numbers'} - , { field: 'cxPzTime', title: '冲销凭证日期',align:'center'} - , { field: 'cxPzCode', title: '冲销凭证号',align:'center'} - , { field: 'maCode', title: '物料号',align:'center'} - , { field: 'maName', title: '物料名称',align:'center'} - , { field: 'fhPzCode', title: '发货凭证号',align:'center'} - , {field:'right', title: '操作',toolbar:"#barDemo",align:'center'} - ]] - ,limits: [5,10,20,50,100,500] //一页选择显示3,5或10条数据 - , limit: 10 //一页显示5条数据 - , response: { - statusCode: 200 //规定成功的状态码,默认:0 - } - , parseData: function (res) { //将原始数据解析成 table 组件所规定的数据,res为从url中get到的数据 + elem: "#layuiTable", + url: ctxPath + "/ma/sendoff/list?keyWord=" + keyWord, + method: "post", + cols: [ + [ + { type: "checkbox", fixed: "left" }, + { + field: "ID", + title: "序号", + width: "3%", + sort: true, + type: "numbers", + }, + { field: "cxPzTime", title: "冲销凭证日期", align: "center" }, + { field: "cxPzCode", title: "冲销凭证号", align: "center" }, + { field: "maCode", title: "物料号", align: "center" }, + { field: "maName", title: "物料名称", align: "center" }, + { field: "fhPzCode", title: "发货凭证号", align: "center" }, + { + field: "right", + title: "操作", + toolbar: "#barDemo", + align: "center", + }, + ], + ], + limits: [5, 10, 20, 50, 100, 500], //一页选择显示3,5或10条数据 + limit: 10, //一页显示5条数据 + response: { + statusCode: 200, //规定成功的状态码,默认:0 + }, + parseData: function (res) { + //将原始数据解析成 table 组件所规定的数据,res为从url中get到的数据 let result; if (res.count > 0) { if (this.page.curr) { - result = res.data.slice(this.limit * (this.page.curr - 1), this.limit * this.page.curr); + result = res.data.slice( + this.limit * (this.page.curr - 1), + this.limit * this.page.curr + ); } else { result = res.data.slice(0, this.limit); } } return { - "code": res.code, //解析接口状态 - "msg": res.msg, //解析提示文本 - "count": res.count, //解析数据长度 - "data": result //解析数据列表 + code: res.code, //解析接口状态 + msg: res.msg, //解析提示文本 + count: res.count, //解析数据长度 + data: result, //解析数据列表 }; - } - ,id: 'layuiTable' - ,page: true //开启分页 - ,height: 600 + }, + id: "layuiTable", + page: true, //开启分页 + height: 600, }); - table.on('tool(contact)', function(obj){ + table.on("tool(contact)", function (obj) { var data = obj.data; - if(obj.event === 'del'){ + if (obj.event === "del") { del(data.id); - } else if(obj.event === 'edit'){ + } else if (obj.event === "edit") { edit(data.id); } }); - - } - /** * 新增 */ -function add(){ - localStorage.setItem('type','1') +function add() { + localStorage.setItem("type", "1"); var index = layer.open({ - title: '新增', + title: "新增", type: 2, - content: './child/sendoffAddForm.html', - area: ['80%', '70%'], + content: "./child/sendoffAddForm.html", + area: ["80%", "70%"], maxmin: false, - btn:['确定 ','取消'], - yes:function(index,layero){ - var formSubmit=layer.getChildFrame('form', index); - var submited = formSubmit.find('button')[0]; + btn: ["确定 ", "取消"], + yes: function (index, layero) { + var formSubmit = layer.getChildFrame("form", index); + var submited = formSubmit.find("button")[0]; // 触发点击事件,会对表单进行验证,验证成功则提交表单,失败则返回错误信息 submited.click(); }, - btn2:function(index,layero){ - - } + btn2: function (index, layero) {}, }); } @@ -152,137 +161,137 @@ function add(){ * 修改 * */ function edit(id) { - localStorage.setItem('type','2') + localStorage.setItem("type", "2"); $.ajax({ - type: 'post', - url: ctxPath + '/ma/sendoff/getById', + type: "post", + url: ctxPath + "/ma/sendoff/getById", data: { - "id":id + id: id, }, - dataType: 'text', + dataType: "text", success: function (data) { - var height = '80%'; - var width = '70%'; + var height = "80%"; + var width = "70%"; var index = layer.open({ - title: '修改', + title: "修改", type: 2, - content: './child/sendoffForm.html', + content: "./child/sendoffForm.html", area: [width, height], maxmin: false, - btn:['确定 ','取消'], - success:function(layero,index){ - var myIframe = window[layero.find('iframe')[0]['name']]; + btn: ["确定 ", "取消"], + success: function (layero, index) { + var myIframe = window[layero.find("iframe")[0]["name"]]; var fnc = myIframe.setData(data); //aaa()为子页面的方法 }, - yes:function(index,layero){ - var formSubmit=layer.getChildFrame('form', index); - var submited = formSubmit.find('button')[0]; + yes: function (index, layero) { + var formSubmit = layer.getChildFrame("form", index); + var submited = formSubmit.find("button")[0]; // 触发点击事件,会对表单进行验证,验证成功则提交表单,失败则返回错误信息 submited.click(); }, - btn2:function(index,layero){ - - } + btn2: function (index, layero) {}, }); - } - }) + }, + }); } /** * 删除 * */ function del(id) { - layer.confirm("确定删除吗?",function () { + layer.confirm("确定删除吗?", function () { $.ajax({ - type: 'post', - url: ctxPath + '/ma/sendoff/delete', + type: "post", + url: ctxPath + "/ma/sendoff/delete", data: { - "id":id + id: id, }, success: function (data) { - if(data.code == 200){ - layer.alert('删除成功', {icon: 1},()=>{ + if (data.code == 200) { + layer.alert("删除成功", { icon: 1 }, () => { location.reload(); }); - }else{ - layer.alert('删除失败', {icon: 2}); + } else { + layer.alert("删除失败", { icon: 2 }); } - - } - }) - }) + }, + }); + }); } - -function getData(day){ - var today=new Date() - var targetday=today.getTime() +1000*60*60*24* day - today.setTime(targetday) - var tYear=today.getFullYear() - var tMonth=today.getMonth() - var tDate=today.getDate() - tMonth=this.doHandMonth(tMonth+1) - tDate=this.doHandMonth(tDate) - return tYear +"-" + tMonth+"-"+tDate +function getData(day) { + var today = new Date(); + var targetday = today.getTime() + 1000 * 60 * 60 * 24 * day; + today.setTime(targetday); + var tYear = today.getFullYear(); + var tMonth = today.getMonth(); + var tDate = today.getDate(); + tMonth = this.doHandMonth(tMonth + 1); + tDate = this.doHandMonth(tDate); + return tYear + "-" + tMonth + "-" + tDate; } - -function doHandMonth(month){ - var m=month - if(month.toString().length==1){ - m="0"+month +function doHandMonth(month) { + var m = month; + if (month.toString().length == 1) { + m = "0" + month; } - return m + return m; } -function batchDeleteBtn(){ - var selectData = layui.table.checkStatus('layuiTable').data; +function batchDeleteBtn() { + var selectData = layui.table.checkStatus("layuiTable").data; console.log(selectData); let ids = []; - for (let i = 0; i < selectData.length; i++){ - ids.push(selectData[i].id) + for (let i = 0; i < selectData.length; i++) { + ids.push(selectData[i].id); } console.log(ids); - if(ids.toString() == ''){ - return layer.alert('请选择需要删除的数据',{icon: 0}); - }else{ - layer.confirm("确定删除所选 "+ids.length+" 条数据吗?",function () { - $.ajax({ - type: 'delete', - url: ctxPath + '/ma/sendoff/' + ids.toString(), - success: function (data) { - if(data.code == 200){ - layer.msg('删除成功', {icon: 1},function () { - table.reload('layuiTable'); - }); - }else{ - layer.alert('删除失败', {icon: 2}); - } - - } - }) - }) + if (ids.toString() == "") { + return layer.alert("请选择需要删除的数据", { icon: 0 }); + } else { + layer.confirm( + "确定删除所选 " + ids.length + " 条数据吗?", + function () { + $.ajax({ + type: "delete", + url: ctxPath + "/ma/sendoff/" + ids.toString(), + success: function (data) { + if (data.code == 200) { + layer.msg("删除成功", { icon: 1 }, function () { + table.reload("layuiTable"); + }); + } else { + layer.alert("删除失败", { icon: 2 }); + } + }, + }); + } + ); } } function exportData() { - var index = layer.msg('数据导出中,请稍等。。。', { - icon: 4 + var index = layer.msg("数据导出中,请稍等。。。", { + icon: 4, }); var token = localStorage.getItem("token"); var djCode = $("#djCode").val(); var maCode = $("#maCode").val(); var param = { - djCode:djCode, - maCode:maCode - } - var url = ctxPath + "/ma/sendoff/export?param=" + encodeURIComponent(JSON.stringify(param)); + djCode: djCode, + maCode: maCode, + }; + var url = + ctxPath + + "/ma/sendoff/export?param=" + + encodeURIComponent(JSON.stringify(param)); var xhr = new XMLHttpRequest(); xhr.open("get", url, true); //设置xhr请求的超时时间 xhr.timeout = 100000; //设置响应返回的数据格式 - xhr.responseType = "blob"; // 转换流 + xhr.responseType = "blob"; // 转换流 xhr.setRequestHeader("token", token); //构造表单数据 xhr.onload = function () { @@ -295,9 +304,25 @@ function exportData() { a.download = "发货冲销对应表-导出.xlsx"; // 文件名 } else if (this.status === 401) { localStorage.removeItem("token"); +<<<<<<< .mine layer.msg('用户登录过期,请重新登录', {icon: 5, time: 2000}, function () { location.href = contentPath+'/login.html'; }); + + + + + +======= + layer.msg( + "用户登录过期,请重新登录", + { icon: 5, time: 2000 }, + function () { + // location.href = ctxPath + '/login.html'; + location.href = pagesPath + "/login.html"; + } + ); +>>>>>>> .theirs } a.click(); window.URL.revokeObjectURL(url); @@ -307,6 +332,8 @@ function exportData() { function downloadFile() { var token = localStorage.getItem("token"); - window.location.href = ctxPath + "/download/download?filename=发货冲销对应表-导入模板.xlsx&token=" + token; + window.location.href = + ctxPath + + "/download/download?filename=发货冲销对应表-导入模板.xlsx&token=" + + token; } - diff --git a/js/project/proScheduleManagementView.js b/js/project/proScheduleManagementView.js index 8d622aa..a811594 100644 --- a/js/project/proScheduleManagementView.js +++ b/js/project/proScheduleManagementView.js @@ -1,3 +1,4 @@ +const token = localStorage.getItem("token"); layui.config({ base: '../../js/layuiModules/', // 第三方模块所在目录 version: 'v1.6.4' // 插件版本号 @@ -414,6 +415,26 @@ function getFileList() { }, toolbar: "#toolbar" }); + + //监听工具条 + table.on('tool(fileDemo)', function (obj) { + var data = obj.data; //当前行数据 + var fileName = data.fileName; + var filePath = data.filePath; + var rowIndex = obj.index; + var layEvent = obj.event; //当前点击的事件名 + if (layEvent === 'download') { + downloads(fileName,filePath) + } + if (layEvent === 'del') { + var index = layer.confirm('确定要删除吗?', { + btn : [ '确定', '取消' ] + }, function() { + layer.close(index); + ajaxCommonMethod('/proProgress/delById',{'id': data.id},"删除成功","删除失败"); + }); + } + }); } function layerOpenFormForSecond(title, contentUrl) { @@ -520,4 +541,49 @@ function reloadTip(tip,message,type){ type: type, message: message }); +} + +function downloads(fileName,filePath){ + const url = ctxPath + `/proProgress/download?filePath=${encodeURIComponent(filePath)}` +`&token=`+token; + fetch(url) + .then(response => { + if (!response.ok) throw new Error('下载失败'); + return response.blob(); + }) + .then(blob => { + const downloadUrl = window.URL.createObjectURL(blob); + const link = document.createElement('a'); + link.href = downloadUrl; + link.download = fileName; // 设置下载时显示的文件名 + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); + window.URL.revokeObjectURL(downloadUrl); // 释放内存 + }) + .catch(error => { + console.error('文件下载出错:', error); + alert('下载失败,请重试'); + }); +} + +function ajaxCommonMethod(url,data,success,error){ + $.ajax({ + type: 'POST', + async: false, // 默认异步true,false表示同步 + url: ctxPath + url,// 请求地址 + contentType: "application/x-www-form-urlencoded", + dataType: 'json', // 服务器返回数据类型 + data: data, //获取提交的表单字段 + success: function (data) { + var resMsg = data.resMsg; + if ("数据获取成功" == resMsg) { + reloadTip("删除",success,'success'); + setTimeout(function(){ + getFileList(); + }, 2000); + }else { + reloadTip("删除",error,"error"); + } + } + }); } \ No newline at end of file diff --git a/js/publicJs.js b/js/publicJs.js index b3256cb..542a140 100644 --- a/js/publicJs.js +++ b/js/publicJs.js @@ -1,11 +1,13 @@ // var ctxPath = getContextPath(); let contentPath="/czl-web" +var pagesPath = getContextPath(); +<<<<<<< .mine let host=window.location.host; let ctxPath; console.log(window.location.protocol) ctxPath=window.location.protocol+"//"+host+"/czl"; -//本地 +// ctxPath = window.location.protocol+"//192.168.0.14:42880/czl"; // function getContextPath() { @@ -14,3 +16,18 @@ ctxPath = window.location.protocol+"//192.168.0.14:42880/czl"; // var result = pathName.substr(0, index + 1); // return result; // } +======= +function getContextPath() { + var pathName = document.location.pathname; + var index = pathName.substr(1).indexOf("/"); + var result = pathName.substr(0, index + 1); + return result; +} + + + + + + + +>>>>>>> .theirs diff --git a/login.html b/login.html index 155cc8e..3b86c57 100644 --- a/login.html +++ b/login.html @@ -135,7 +135,13 @@ url: ctxPath + '/users/current?token=' + token, success: function (data) { localStorage.setItem("userId", data.id); +<<<<<<< .mine window.location.href=contentPath+"/index.html"; + +======= + // location.href = ctxPath + '/index.html'; + location.href = pagesPath + '/index.html'; +>>>>>>> .theirs }, error: function (xhr, textStatus, errorThrown) { var msg = xhr.responseText; @@ -156,8 +162,13 @@ //请求方式 type: "GET", //请求的媒体类型 +<<<<<<< .mine // contentType: "application/json;charset=UTF-8", +======= + // contentType: "application/json;charset=UTF-8", + +>>>>>>> .theirs //请求地址 url: url, //请求成功 @@ -217,13 +228,24 @@ time: 3000, area: ['350px', '70px'] }, function () { +<<<<<<< .mine // location.href = ctxPath + '/index.html'; window.location.href=contentPath+"/index.html"; //location.href = '/index.html'; +======= + location.href = pagesPath + '/index.html'; + // location.href = 'http://127.0.0.1:5502/index.html'; + +>>>>>>> .theirs }); } else { +<<<<<<< .mine // location.href = ctxPath + '/index.html'; window.location.href=contentPath+"/index.html"; +======= + location.href = pagesPath + '/index.html'; + // location.href = 'http://127.0.0.1:5502/index.html'; +>>>>>>> .theirs } }, error: function (xhr, textStatus, errorThrown) { diff --git a/pages/menu/addMenu.html b/pages/menu/addMenu.html index 212f21b..ec900c2 100644 --- a/pages/menu/addMenu.html +++ b/pages/menu/addMenu.html @@ -1,80 +1,80 @@ +
- - - + + + + -