diff --git a/src/main/resources/static/js/imageUpload/importantMatter/child/importantMatterForm.js b/src/main/resources/static/js/imageUpload/importantMatter/child/importantMatterForm.js new file mode 100644 index 0000000..ffa00f0 --- /dev/null +++ b/src/main/resources/static/js/imageUpload/importantMatter/child/importantMatterForm.js @@ -0,0 +1,329 @@ +let form, layer, util, idParam, laydate; +let arr = ['background', 'web', 'mobile', 'wx']; +let background, web, mobile, wx; +let data = []; + +// 初始化下拉选 +let proList; +let majorList; +let processList; + +let vrImgList = []; // 违章照片 +let CODE_1 = 0; + +let proId, proName, majorId, majorName, gxId, gxName; +layui.use(['laydate', 'upload'], function () { + var upload = layui.upload; + var layer = layui.layer; + var element = layui.element; + var $ = layui.$; + + var violation = JSON.stringify({ + uploadType: 5, // 上传类型 + sourceType: 9, // 来源类型 + sourceTypeName: "重要事项及宣传照片" // 来源类型名称 + }) + + // 多图片上传 + var uploadcom1 = upload.render({ + elem: '#test1', + url: '/imgTool/sys/file/uploadFile?token=' + tokens, + multiple: true, + auto: false, + exts: 'jpg|png|jpeg', + field: 'files', + data: {params: violation}, + bindAction: '#hideUpload1', //绑定的按钮 + // 文件选择后的回调 + choose: function (obj) { + CODE_1 = 1; + uploadcom1.config.elem.next()[0].value = ''; + let files = obj.pushFile(); + obj.preview(function (index, file, result) { + var length = $('#demo1 img').length; + if (length > 8) { + delete files[index];//删除指定图片 + $(this).remove(); + return layer.msg("附件为1-9张,请勿过多上传", {icon: 5}); + } + + const uniqueId = new Date().getTime() + '-' + index; + $('#demo1').append( + '
' + + '' + file.name + '' + + '' + + '
' + ); + }); + }, + before: function (obj) { + + }, + done: function (res, index, upload) { + if (res.code === 200) { + vrImgList.push(res.data[0]); + } else { + + } + }, + allDone: function (res, index, upload) { + + }, + error: function (e) { + //请求异常回调 + console.log(e) + } + }); + + window.removeImage = function (uniqueId) { + $('#img-' + uniqueId).remove(); + }; + + laydate = layui.laydate; + laydate.render({ + elem: '#time', + }); + +}); + + +function setParams(params) { + idParam = JSON.parse(params).id; + details = JSON.parse(params).details; + layui.use(['form', 'layer', 'util'], function () { + layer = layui.layer; + form = layui.form; + util = layui.util; + var $ = layui.jquery; + proList = getProSelected(); + majorList = getMajorSelected(); + processList = getProcessSelected(); + if (idParam) { + getUserById(); + } + + form.on('select(proId)', function (data) { + // 获取选中的 id 和 name + const selectedId = data.value; // 获取选中项的 value 值 + const selectedName = $(data.elem).find("option:selected").text(); // 获取选中项的文本 + proId = selectedId; + proName = selectedName; + }); + + form.on('select(majorId)', function (data) { + const selectedId = data.value; // 获取选中项的 value 值 + const selectedName = $(data.elem).find("option:selected").text(); // 获取选中项的文本 + majorId = selectedId; + majorName = selectedName; + + let gxs = getGxsSelect(data.value); + setSelectValueName(gxs, 'gxId', '请选择工序'); + }); + + form.on('select(gxId)', function (data) { + const selectedId = data.value; // 获取选中项的 value 值 + const selectedName = $(data.elem).find("option:selected").text(); // 获取选中项的文本 + gxId = selectedId; + gxName = selectedName; + }); + + form.render();//重新渲染页面checkbox控件 + form.on('submit(formData)', function (data) { + data.field.id = $('#id').val(); + saveData(data); + }); + + }); +} + +/** + * 获取工程数据 + */ +function getProSelected() { + let url = dataUrl + '/sys/select/getProsSelect'; + let data = { + encryptedData: encryptCBC(JSON.stringify({})) + } + ajaxRequest(url, "POST", data, true, function () { + }, function (result) { + if (result.code === 200) { + setSelectValueName(result.data, 'proId', "请选择项目(可搜索)"); + } else { + layer.alert(result.msg, {icon: 2}) + } + }, function (xhr) { + error(xhr) + }); +} + +/** + * 获取专业数据 + */ +function getMajorSelected() { + let url = dataUrl + '/sys/select/getProfessionSelect'; + ajaxRequest(url, "GET", null, true, function () { + }, function (result) { + if (result.code === 200) { + setSelectValueName(result.data, 'majorId', "请选择专业"); + } else { + layer.alert(result.msg, {icon: 2}) + } + }, function (xhr) { + error(xhr) + }); +} + +/** + * 获取工序数据 + */ +function getProcessSelected() { + let url = dataUrl + '/sys/select/getProcessSelect'; + let data = { + encryptedData: encryptCBC(JSON.stringify({})) + } + ajaxRequest(url, "GET", data, true, function () { + }, function (result) { + if (result.code === 200) { + setSelectValueName(result.data, 'gxId', '请选择工序'); + } else { + layer.alert(result.msg, {icon: 2}) + } + }, function (xhr) { + error(xhr) + }); +} + + +// 根据id获取用户信息 +function getUserById() { + let loadingMsg = layer.msg("数据加载中,请稍候...", {icon: 16, scrollbar: false, time: 0,}); + let url = dataUrl + "/importantMatter/getImportantMatterById"; + let params = { + id: idParam + } + console.log(params) + params = { + encryptedData: encryptCBC(JSON.stringify(params)) + } + ajaxRequest(url, "POST", params, true, function () { + }, function (result) { + layer.close(loadingMsg); // 关闭提示层 + if (result.code === 200) { + console.log(result) + setFormData(result.data); + } else if (result.code === 500) { + layer.alert(result.msg, {icon: 2}) + } + }, function (xhr) { + layer.close(loadingMsg); // 关闭提示层 + error(xhr) + }); +} + +// 设置表单内容 +function setFormData(data) { + console.log("data:", data) + if (data) { + $('#id').val(data.id) + $('#proId option[value=' + data.proId + ']').attr('selected', true) + $('#majorId option[value=' + data.majorId + ']').attr('selected', true) + $('#gxId option[value=' + data.gxId + ']').attr('selected', true) + $('#time').val(data.time) + $('#title').val(data.title) + $('#content').val(data.content) + + vrImgList = data.sysFileResourceList; + var vioPhotoListEdit = data.sysFileResourceList; + if (vioPhotoListEdit && vioPhotoListEdit.length > 0) { + var html = ""; + var demo1 = $("#demo1"); + for (var i = 0; i < vioPhotoListEdit.length; i++) { + html = html + '
' + + '' +vioPhotoListEdit[i].fileName + '' ; + if (details != 1) { + html = html + ''; + } + html = html + '
'; + } + demo1.append(html); + } + + if(details == 1){ + document.querySelector('.layui-btn.save').style.display = 'none'; + document.getElementById("test1").style.display = 'none'; + } + layui.form.render(); + } +} + +function removeImageUpdate(uniqueId) { + console.log("uniqueId:", uniqueId) + $('#img-' + uniqueId).remove(); + uniqueId = parseInt(uniqueId, 10); // 转换为数字类型 + vrImgList = vrImgList.filter(item => item.id !== uniqueId); + console.log("importantMatter",vrImgList) +} + +function saveData2() { + $('#formSubmit').trigger('click') +} + +// 保存数据 +function saveData(data) { + if(idParam =="" || idParam == null || idParam == undefined){ + if (CODE_1 == 0) { + layer.msg("请上传现场照片", {icon: 2, time: 2000}); + return ""; + } + } + $("#hideUpload1").trigger("click"); + let loadingMsg = layer.msg('数据上传中,请稍候...', {icon: 16, scrollbar: false, time: 0}); + let url = dataUrl + "/importantMatter/addImportantMatter"; + data.field.uploadType = "5"; + data.field.dataSource = 1; + data.field.sysFileResourceList = [...vrImgList]; + + data.field.proId = proId; + data.field.proName = proName; + data.field.majorId = majorId; + data.field.majorName = majorName; + data.field.gxId = gxId; + data.field.gxName = gxName; + console.log("data:", data) + let params = data.field; + if (params.id != "") { + url = dataUrl + "/importantMatter/updateImportantMatter"; + } + console.log(params) + params = { + encryptedData: encryptCBC(JSON.stringify(params)) + } + ajaxRequest(url, "POST", params, true, function () { + $('.save').addClass("layui-btn-disabled").attr("disabled", true); + $('.cancel').addClass("layui-btn-disabled").attr("disabled", true); + }, function (result) { + layer.close(loadingMsg); // 关闭提示层 + if (result.code === 200) { + closePage(1); + parent.layer.msg(result.msg, {icon: 1}); + } else { + layer.alert(result.msg, {icon: 2}) + $('.save').removeClass("layui-btn-disabled").attr("disabled", false); + $('.cancel').removeClass("layui-btn-disabled").attr("disabled", false); + } + }, function (xhr) { + layer.close(loadingMsg); // 关闭提示层 + $('.save').removeClass("layui-btn-disabled").attr("disabled", false); + $('.cancel').removeClass("layui-btn-disabled").attr("disabled", false); + error(xhr) + }); +} + +// 关闭页面 +function closePage(type) { + let index = parent.layer.getFrameIndex(window.name); //先得到当前 iframe层的索引 + parent.layer.close(index); //再执行关闭 + if (type === 1) { + parent.reloadData() + } +} \ No newline at end of file diff --git a/src/main/resources/static/js/imageUpload/publicize/publicizeList.js b/src/main/resources/static/js/imageUpload/importantMatter/importantMatterList.js similarity index 63% rename from src/main/resources/static/js/imageUpload/publicize/publicizeList.js rename to src/main/resources/static/js/imageUpload/importantMatter/importantMatterList.js index 207a9d9..bde0f95 100644 --- a/src/main/resources/static/js/imageUpload/publicize/publicizeList.js +++ b/src/main/resources/static/js/imageUpload/importantMatter/importantMatterList.js @@ -1,6 +1,5 @@ let form, layer, table, tableIns; let pageNum = 1, limitSize = 10; // 默认第一页,分页数量为10 -let selectOrgId=""; layui.use(['form', 'layer', 'table', 'laydate'], function () { form = layui.form; @@ -16,14 +15,14 @@ layui.use(['form', 'layer', 'table', 'laydate'], function () { function pages(pageNum, pageSize, typeNum) { let params = getReqParams(pageNum, pageSize, typeNum); - let url = dataUrl + "/users/getList" + let url = dataUrl + "/importantMatter/getImportantMatterList" ajaxRequest(url, "POST", params, true, function () { }, function (result) { console.log(result); if (result.code === 200) { if (result.data) { - initTable(result.data, result.limit, result.curr) - laypages(result.count, result.curr, result.limit) + initTable(result.data.list, result.data.pageSize, result.data.startRow) + laypages(result.data.total, result.data.startRow, result.data.pageSize) } } else if (result.code === 500) { layer.alert(result.msg, {icon: 2}) @@ -71,32 +70,25 @@ function initTable(dataList, limit, page) { return (page - 1) * limit + d.LAY_INDEX; } }, - {field: "loginName", title: "项目名称",width: 310, unresize: true, align: "center" }, - {field: "username", title: "工序",width: 200, unresize: true, align: "center"}, - {field: "orgName", title: "标题",width: 210, unresize: true, align: "center"}, - {field: "roleName", title: "内容",width: 310, unresize: true, align: "center"}, - {field: "phone", title: "照片",width: 150, unresize: true, align: "center", + {field: "proName", title: "项目名称",width: 310, unresize: true, align: "center" }, + {field: "gxName", title: "工序",width: 200, unresize: true, align: "center"}, + {field: "title", title: "标题",width: 210, unresize: true, align: "center"}, + {field: "content", title: "内容",width: 310, unresize: true, align: "center"}, + {field: "", title: "照片",width: 150, unresize: true, align: "center", templet: function (d) { - let html=""+d.delFlag+""; - if(d.delFlag>0){ - return ''; - } + let html=""+d.sysFileResourceList.length+""; return html; } }, - {field: "userType", title: "上传人",width: 110, unresize: true, align: "center"}, - {field: "userType", title: "更新时间",width: 140, unresize: true, align: "center"}, + {field: "createUserName", title: "上传人",width: 110, unresize: true, align: "center"}, + {field: "createTime", title: "更新时间",width: 140, unresize: true, align: "center"}, {title: "操作", unresize: true, width: 170, align: "center", templet: function (d) { - let html = ''; let updaetpwd=""; let del="" let edit=""; html=updaetpwd + edit+del; - if(d.delFlag==1){ - return ''; - } return html; } }, @@ -115,25 +107,23 @@ function initTable(dataList, limit, page) { // 获取参数 function getReqParams(page, limit, type) { let obj = {}; - if (!type) { - obj = { - page: page + "", - limit: limit + "", - userName: $('#userName').val(), - phone: $('#phone').val(), - orgId: selectOrgId, - userType: $('#userType').val(), - }; - } else { - obj = { - page: '1', - limit: '10', - userName: '', - phone:'', - orgId:'', - userType: '', - }; + + if (type === 2) { + $('#keyWord').val('') + $('#proId').val('') + $('#proTypeId').val('') + $('#processId').val('') + layui.form.render(); } + + obj = { + page: page + "", + limit: limit + "", + keyWord: $('#keyWord').val(), + proId: $('#proId').val(), + majorId: $('#proTypeId').val(), + gxId: $('#processId').val(), + }; console.log(obj) obj={ encryptedData:encryptCBC(JSON.stringify(obj)) @@ -152,16 +142,9 @@ function query(type) { }); } pageNum = 1; - pages(1, limitSize); + pages(1, limitSize,type); } - -//重置 -function reset() { - pages(1, limitSize, 1) -} - - function reloadData() { pages(pageNum, limitSize); } @@ -170,9 +153,10 @@ function reloadData() { function detailsData(id) { let title = '详情' let param = { - 'id': id + 'id': id, + 'details':'1' } - openIframe2("detailsSafetyViolations", title, "child/publicizeForm.html", '1200px', '625px', param); + openIframe2("detailsSafetyViolations", title, "child/importantMatterForm.html", '1200px', '625px', param); } @@ -183,9 +167,10 @@ function addData(id) { title = '修改'; } let param = { - 'id': id + 'id': id, + 'details':'' } - openIframe2("addOrEditSafetyViolations", title, "child/publicizeForm.html", '1200px', '625px', param); + openIframe2("addOrEditSafetyViolations", title, "child/importantMatterForm.html", '1200px', '625px', param); } /*删除用户*/ @@ -194,7 +179,7 @@ function delData(id) { move: false }, function () { let loadingMsg = layer.msg('数据删除中,请稍候...', {icon: 16, scrollbar: false, time: 0}); - let url = dataUrl + "/users/delById"; + let url = dataUrl + "/importantMatter/deleteImportantMatter"; let params = { 'id': id } @@ -204,11 +189,11 @@ function delData(id) { ajaxRequest(url, "POST", params, true, function () { }, function (result) { layer.close(loadingMsg); // 关闭提示层 - if (result.code === 200) { - parent.layer.msg(result.msg, {icon: 1}) + if (result.status === 200) { + parent.layer.msg("删除成功", {icon: 1}) query() - } else if (result.code === 500) { - layer.alert(result.msg, {icon: 2}) + } else if (result.status === 500) { + layer.alert("删除失败", {icon: 2}) } }, function (xhr) { layer.close(loadingMsg); // 关闭提示层 @@ -217,45 +202,15 @@ function delData(id) { }) } -// 启用/停用/解除锁定 -function editUserAccountStatus(id, status, type) { - let url = dataUrl + "/sys/user/editUserAccountStatus?token=" + token; - let params = { - 'id': id, - 'accountStatus': status, - 'type': type - } - ajaxRequest(url, "POST", params, true, function () { - }, function (result) { - if (result.code === 200) { - if(type){ - reloadData(); - } - parent.layer.msg(result.msg, {icon: 1}) - } else if (result.code === 500) { - layer.alert(result.msg, {icon: 2}) - } - }, function (xhr) { - error(xhr) - }); -} - -// 管理员修改密码 -function resetPwd(id) { - let param = { - 'id': id, - 'type': '1' - } - openIframe2("addOrEditUnifyUser", '修改密码', "password.html", '770px', '400px', param); -} - - /** * 获取工程 */ function getProSelected() { - let url = dataUrl + '/users/getRoleAll'; - ajaxRequest(url, "POST", null, true, function () { + let url = dataUrl + '/sys/select/getProsSelect'; + let data={ + encryptedData:encryptCBC(JSON.stringify({})) + } + ajaxRequest(url, "POST", data, true, function () { }, function (result) { if (result.code === 200) { setSelectValue(result.data, 'proId','请选择工程'); @@ -271,25 +226,12 @@ function getProSelected() { * 获取工程类型 */ function getProTypeSelected() { - let url = dataUrl + '/users/getRoleAll'; - ajaxRequest(url, "POST", null, true, function () { - }, function (result) { - if (result.code === 200) { - setSelectValue(result.data, 'proTypeId','请选择工程类型'); - } else { - layer.alert(result.msg, {icon: 2}) - } - }, function (xhr) { - error(xhr) - }); -} + let url = dataUrl + '/sys/select/getDictSelectByType'; -/** - * 获取工程类型 - */ -function getProTypeSelected() { - let url = dataUrl + '/users/getRoleAll'; - ajaxRequest(url, "POST", null, true, function () { + let data={ + encryptedData:encryptCBC(JSON.stringify({"code":"pro_type"})) + } + ajaxRequest(url, "GET", data, true, function () { }, function (result) { if (result.code === 200) { setSelectValue(result.data, 'proTypeId','请选择工程类型'); @@ -306,7 +248,10 @@ function getProTypeSelected() { */ function getProcessIdSelected() { let url = dataUrl + '/sys/select/getProcessSelect'; - ajaxRequest(url, "GET", null, true, function () { + let data={ + encryptedData:encryptCBC(JSON.stringify({})) + } + ajaxRequest(url, "GET", data, true, function () { }, function (result) { if (result.code === 200) { setSelectValue(result.data, 'processId','请选择工序类型'); @@ -336,10 +281,32 @@ function violationPhoto(id){ alert(id) } -/** - * 修正照片 - * @param id - */ -function correctionPhoto(id){ - alert(id) +function exportExcel() { + let obj = { + keyWord: $('#keyWord').val(), + proId: $('#proId').val(), + majorId: $('#proTypeId').val(), + gxId: $('#processId').val(), + }; + let loadingMsg = layer.msg("数据导出中,请稍候...", {icon: 16, scrollbar: false, time: 0,}); + let url = dataUrl + "/importantMatter/importantMatterExport?token=" + tokens + "&encryptedData=" + encodeURIComponent(encryptCBC(JSON.stringify(obj))); + let xhr = new XMLHttpRequest(); + xhr.open("post", url, true); + xhr.responseType = "blob"; // 转换流 + xhr.setRequestHeader('Content-Type','application/json;charset=UTF-8') + xhr.onload = function () { + layer.close(loadingMsg); + if (this.status === 200) { + let blob = this.response; + var a = document.createElement("a"); + var url = window.URL.createObjectURL(blob); + a.href = url; + a.download = "重要事项及宣传照片列表" + ".xlsx"; // 文件名 + } else { + layer.msg("数据导出发生异常,请稍后重试", {icon: 16, scrollbar: false, time: 2000}); + } + a.click(); + window.URL.revokeObjectURL(url); + }; + xhr.send(); } \ No newline at end of file diff --git a/src/main/resources/static/pages/imageUpload/publicize/child/publicizeForm.html b/src/main/resources/static/pages/imageUpload/importantMatter/child/importantMatterForm.html similarity index 81% rename from src/main/resources/static/pages/imageUpload/publicize/child/publicizeForm.html rename to src/main/resources/static/pages/imageUpload/importantMatter/child/importantMatterForm.html index 7ff0c87..ab08297 100644 --- a/src/main/resources/static/pages/imageUpload/publicize/child/publicizeForm.html +++ b/src/main/resources/static/pages/imageUpload/importantMatter/child/importantMatterForm.html @@ -60,7 +60,7 @@
-
@@ -68,13 +68,13 @@
-
-
@@ -86,21 +86,21 @@
- +
- +
- +
@@ -108,15 +108,15 @@
-
预览图: -
+
-
+
@@ -129,5 +129,5 @@ - + \ No newline at end of file diff --git a/src/main/resources/static/pages/imageUpload/publicize/publicizeList.html b/src/main/resources/static/pages/imageUpload/importantMatter/importantMatterList.html similarity index 92% rename from src/main/resources/static/pages/imageUpload/publicize/publicizeList.html rename to src/main/resources/static/pages/imageUpload/importantMatter/importantMatterList.html index b27d045..63eb1b2 100644 --- a/src/main/resources/static/pages/imageUpload/publicize/publicizeList.html +++ b/src/main/resources/static/pages/imageUpload/importantMatter/importantMatterList.html @@ -51,9 +51,9 @@
- -