diff --git a/src/main/resources/static/js/imageUpload/safetyViolations/child/safetyViolationsForm.js b/src/main/resources/static/js/imageUpload/safetyViolations/child/safetyViolationsForm.js index 0cb6f1a..a65cade 100644 --- a/src/main/resources/static/js/imageUpload/safetyViolations/child/safetyViolationsForm.js +++ b/src/main/resources/static/js/imageUpload/safetyViolations/child/safetyViolationsForm.js @@ -1,4 +1,4 @@ -let form, layer, util, idParam, laydate; +let form, layer, util, idParam, laydate, details; let arr = ['background', 'web', 'mobile', 'wx']; let background, web, mobile, wx; let data = []; @@ -8,202 +8,153 @@ let proList; let majorList; let processList; +let vrImgList = []; // 违章照片 +let correctionImgList = []; // 整改照片 -// 模拟后台返回的数据结构 -const mockBackendResponse = (file) => { - const originalPath = `/uploads/original/${file.name}`; - const compressedPath = `/uploads/compressed/${file.name}`; - const watermarkedPath = `/uploads/watermarked/${file.name}`; - return { - code: 200, - msg: '上传成功', - data: { - originalPath, - compressedPath, - watermarkedPath - } - }; -}; - -// 存储图片路径信息 -var imagePaths = []; +const deleteFileList = [];// 删除照片 +let CODE_1 = 0, CODE_2 = 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: 1, // 上传类型 + sourceType: 1, // 来源类型 + sourceTypeName: "安全违章-违章照片" // 来源类型名称 + }) + + + var correction = JSON.stringify({ + uploadType: 1, // 上传类型 + sourceType: 2, // 来源类型 + 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) + } + }); // 多图片上传 - upload.render({ - elem: '#ID-upload-demo-btn-2', - url: '/your/upload/endpoint', - // url: 'javascript:;', // 阻止真实请求 + var uploadcom2 = upload.render({ + elem: '#test2', + url: '/imgTool/sys/file/uploadFile?token=' + tokens, multiple: true, - auto: true, + auto: false, + exts: 'jpg|png|jpeg', + field: 'files', + data: {params: correction}, + bindAction: '#hideUpload2', //绑定的按钮 // 文件选择后的回调 choose: function (obj) { - // 当前已有的图片数量 - const currentImages = $('#upload-demo-preview div').length; - // 获取当前批次选择的文件列表 - const newFiles = obj.pushFile(); - const newFilesCount = Object.keys(newFiles).length; - // 总图片数量 - const totalImages = currentImages + newFilesCount; - if (totalImages > 9) { - layer.alert(`最多只能上传9张图片,当前已选 ${currentImages} 张,此次选择了 ${newFilesCount} 张`, { icon: 2 }); - return false; // 阻止上传 - } - }, - before: function (obj) { + CODE_2 = 1; + uploadcom2.config.elem.next()[0].value = ''; + let files = obj.pushFile(); obj.preview(function (index, file, result) { - const uniqueId = new Date().getTime() + '-' + index; - $('#upload-demo-preview').append( - '
' + - '' + file.name + '' + - '' + - '
' - ); - }); - }, - done: function (res, index, upload) { - // 获取当前上传的文件 - const files = this.files; - const file = files[index]; - const backendResponse = mockBackendResponse(file); - if (backendResponse.code === 200) { - const imageData = { - uniqueId: `${new Date().getTime()}-${index}`, - originalPath: backendResponse.data.originalPath, - compressedPath: backendResponse.data.compressedPath, - watermarkedPath: backendResponse.data.watermarkedPath - }; - imagePaths.push(imageData); - $('#imagePaths').val(JSON.stringify(imagePaths)); - } else { - layer.alert('上传失败: ' + res.msg, {icon: 2}); - } - console.log("imagePaths",imagePaths) - } - }); - - - upload.render({ - elem: '#ID-upload-demo-btn-3', - url: '/your/upload/endpoint', - // url: 'javascript:;', // 阻止真实请求 - multiple: true, - auto: true, - // 文件选择后的回调 - choose: function (obj) { - // 当前已有的图片数量 - const currentImages = $('#upload-demo-preview div').length; - // 获取当前批次选择的文件列表 - const newFiles = obj.pushFile(); - const newFilesCount = Object.keys(newFiles).length; - // 总图片数量 - const totalImages = currentImages + newFilesCount; - if (totalImages > 9) { - layer.alert(`最多只能上传9张图片,当前已选 ${currentImages} 张,此次选择了 ${newFilesCount} 张`, { icon: 2 }); - return false; // 阻止上传 - } - }, - before: function (obj) { - obj.preview(function (index, file, result) { - const uniqueId = new Date().getTime() + '-' + index; - $('#upload-demo-preview-3').append( - '
' + - '' + file.name + '' + - '' + - '
' - ); - }); - }, - done: function (res, index, upload) { - // 获取当前上传的文件 - const files = this.files; - const file = files[index]; - const backendResponse = mockBackendResponse(file); - if (backendResponse.code === 200) { - const imageData = { - uniqueId: `${new Date().getTime()}-${index}`, - originalPath: backendResponse.data.originalPath, - compressedPath: backendResponse.data.compressedPath, - watermarkedPath: backendResponse.data.watermarkedPath - }; - imagePaths.push(imageData); - $('#imagePaths').val(JSON.stringify(imagePaths)); - } else { - layer.alert('上传失败: ' + res.msg, {icon: 2}); - } - console.log("imagePaths",imagePaths) - } - }); - - $('#ID-upload-submit-btn').click(function() { - if (imagePaths.length === 0) { - layer.msg('请先选择图片', {icon: 2}); - return; - } - - layer.msg('模拟上传中...', {icon: 16, time: 2000}); - - // 模拟上传延迟 - setTimeout(function() { - // 清空旧数据(仅保留成功上传的) - const successPaths = []; - - // 遍历所有图片,模拟上传 - imagePaths.forEach(item => { - const backendResponse = mockBackendResponse(item.file); - if (backendResponse.code === 200) { - successPaths.push({ - uniqueId: item.uniqueId, - originalPath: backendResponse.data.originalPath, - compressedPath: backendResponse.data.compressedPath, - watermarkedPath: backendResponse.data.watermarkedPath - }); + var length = $('#demo2 img').length; + if (length > 8) { + delete files[index];//删除指定图片 + $(this).remove(); + return layer.msg("附件为1-9张,请勿过多上传", {icon: 5}); } + const uniqueId = new Date().getTime() + '-' + index; + $('#demo2').append( + '
' + + '' + file.name + '' + + '' + + '
' + ); }); + }, + before: function (obj) { + }, + done: function (res, index, upload) { + if (res.code === 200) { + correctionImgList.push(res.data[0]); + } else { - // 更新数据 - imagePaths = successPaths; - $('#imagePaths').val(JSON.stringify(imagePaths)); + } + }, + allDone: function (res, index, upload) { - layer.msg('上传成功!', {icon: 1}); - console.log("当前图片数据:", imagePaths); - }, 1500); + }, + error: function (e) { + //请求异常回调 + console.log(e) + } }); + window.removeImage = function (uniqueId) { $('#img-' + uniqueId).remove(); - const indexToRemove = imagePaths.findIndex(path => path.uniqueId === uniqueId); - if (indexToRemove !== -1) { - imagePaths.splice(indexToRemove, 1); - $('#imagePaths').val(JSON.stringify(imagePaths)); - } }; laydate = layui.laydate; - // Render date pickers - laydate.render({ - elem: '#violationTime', - }); - laydate.render({ - elem: '#rectificationDeadline', - }); - laydate.render({ - elem: '#correctionTime', - }); - + laydate.render({ + elem: '#vioDate', + }); + laydate.render({ + elem: '#rectDate', + }); + laydate.render({ + elem: '#rectTime', + }); }); function setParams(params) { - console.log(params) idParam = JSON.parse(params).id; + details = JSON.parse(params).details; layui.use(['form', 'layer', 'util'], function () { layer = layui.layer; form = layui.form; @@ -215,12 +166,37 @@ function setParams(params) { 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); }); - }); } @@ -228,11 +204,14 @@ function setParams(params) { * 获取工程数据 */ 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) { - setSelectValueName(result.data, 'projectName', "请选择项目(可搜索)"); + setSelectValueName(result.data, 'proId', "请选择项目(可搜索)"); } else { layer.alert(result.msg, {icon: 2}) } @@ -249,7 +228,7 @@ function getMajorSelected() { ajaxRequest(url, "GET", null, true, function () { }, function (result) { if (result.code === 200) { - setSelectValueName(result.data, 'specialty', "请选择专业"); + setSelectValueName(result.data, 'majorId', "请选择专业"); } else { layer.alert(result.msg, {icon: 2}) } @@ -263,10 +242,13 @@ function getMajorSelected() { */ function getProcessSelected() { 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) { - setSelectValueName(result.data, 'process', '请选择工序'); + setSelectValueName(result.data, 'gxId', '请选择工序'); } else { layer.alert(result.msg, {icon: 2}) } @@ -279,7 +261,7 @@ function getProcessSelected() { // 根据id获取用户信息 function getUserById() { let loadingMsg = layer.msg("数据加载中,请稍候...", {icon: 16, scrollbar: false, time: 0,}); - let url = dataUrl + "/users/getById"; + let url = dataUrl + "/imgUpload/safetyViolation/getSafetyViolationById"; let params = { id: idParam } @@ -287,7 +269,7 @@ function getUserById() { params = { encryptedData: encryptCBC(JSON.stringify(params)) } - ajaxRequest(url, "POST", params, true, function () { + ajaxRequest(url, "GET", params, true, function () { }, function (result) { layer.close(loadingMsg); // 关闭提示层 if (result.code === 200) { @@ -307,28 +289,108 @@ function setFormData(data) { console.log("data:", data) if (data) { $('#id').val(data.id) - $('#inspector').val("修改") - $('#loginName').val(data.loginName) - $('#phone').val(data.phone) - $('#roleId option[value=' + data.roleId + ']').attr('selected', true) + $('#proId option[value=' + data.proId + ']').attr('selected', true) + $('#majorId option[value=' + data.majorId + ']').attr('selected', true) + $('#gxId option[value=' + data.gxId + ']').attr('selected', true) + $('#checkUserName').val(data.checkUserName) + $('#vioDate').val(data.vioDate) + $('#vioPlace').val(data.vioPlace) + $('#rectDate').val(data.rectDate) + $('#vioDesc').val(data.vioDesc) + + var vioPhotoListEdit = data.vioPhotoList; + if (vioPhotoListEdit && vioPhotoListEdit.length > 0) { + var html = ""; + var demo1 = $("#demo1"); + for (var i = 0; i < vioPhotoListEdit.length; i++) { + html = html + '
' + + '' + data.vioPhotoList[i].fileName + '' ; + if (details != 1) { + html = html + ''; + } + html = html + '
'; + } + demo1.append(html); + } + + var rectPhotoListEdit = data.rectPhotoList; + if (rectPhotoListEdit && rectPhotoListEdit.length > 0) { + var demo2 = $("#demo2"); + var html = ""; + for (var i = 0; i < rectPhotoListEdit.length; i++) { + html = html + '
' + + '' + data.rectPhotoList[i].fileName + ''; + if (details != 1) { + html = html + ''; + } + html = html + '
'; + } + demo2.append(html); + } + + + $('#rectUserName').val(data.rectUserName) + $('#rectTime').val(data.rectTime) + $('#rectDesc').val(data.rectDesc) + + if(details == 1){ + document.querySelector('.layui-btn.save').style.display = 'none'; + document.getElementById("test1").style.display = 'none'; + document.getElementById("test2").style.display = 'none'; + } layui.form.render(); } } +function removeImageUpdate(uniqueId, id) { + $('#img-' + uniqueId).remove(); + let ids = {"id":id} + deleteFileList.push(ids) +}; + function saveData2() { $('#formSubmit').trigger('click') } // 保存数据 function saveData(data) { + if(idParam ==""){ + if (CODE_1 == 0) { + layer.msg("请上传违章照片", {icon: 2, time: 2000}); + return ""; + } + } + $("#hideUpload1").trigger("click"); + if (CODE_2 != 0) { + $("#hideUpload2").trigger("click"); + } + let loadingMsg = layer.msg('数据上传中,请稍候...', {icon: 16, scrollbar: false, time: 0}); - let url = dataUrl + "/users/addTemp"; + let url = dataUrl + "/imgUpload/safetyViolation/insertSafetyViolation"; + data.field.uploadType = "1"; + data.field.dataSource = 1; + + data.field.fileList = [...vrImgList, ...correctionImgList]; + if (correctionImgList.length > 0) { + data.field.rectStatus = 1; + } else { + data.field.rectStatus = 0; + } + data.field.delFileList = deleteFileList; + + 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 + "/users/update"; + url = dataUrl + "/imgUpload/safetyViolation/updateSafetyViolationById"; } - console.log(params) + console.log("params:", params) params = { encryptedData: encryptCBC(JSON.stringify(params)) } diff --git a/src/main/resources/static/js/imageUpload/safetyViolations/safetyViolationsList.js b/src/main/resources/static/js/imageUpload/safetyViolations/safetyViolationsList.js index 08ef263..4219561 100644 --- a/src/main/resources/static/js/imageUpload/safetyViolations/safetyViolationsList.js +++ b/src/main/resources/static/js/imageUpload/safetyViolations/safetyViolationsList.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; @@ -14,7 +13,6 @@ layui.use(['form', 'layer', 'table', 'laydate'], function () { pages(1, 10, 1); }) -// http://127.0.0.1:11997/imgTool/imgUpload/safetyViolation/getList function pages(pageNum, pageSize, typeNum) { let params = getReqParams(pageNum, pageSize, typeNum); let url = dataUrl + "/imgUpload/safetyViolation/getList" @@ -72,57 +70,47 @@ function initTable(dataList, limit, page) { return (page - 1) * limit + d.LAY_INDEX; } }, - {field: "loginName", title: "项目名称",width: 110, unresize: true, align: "center" }, - {field: "username", title: "工序",width: 110, unresize: true, align: "center"}, - {field: "orgName", title: "违章地点",width: 110, unresize: true, align: "center"}, - {field: "roleName", title: "违章描述",width: 110, unresize: true, align: "center"}, - {field: "phone", title: "违章照片",width: 110, unresize: true, align: "center", + {field: "proName", title: "项目名称",width: 110, unresize: true, align: "center" }, + {field: "gxName", title: "工序",width: 110, unresize: true, align: "center"}, + {field: "vioPlace", title: "违章地点",width: 110, unresize: true, align: "center"}, + {field: "vioDesc", title: "违章描述",width: 110, unresize: true, align: "center"}, + {field: "", title: "违章照片",width: 110, unresize: true, align: "center", templet: function (d) { - let html=""+d.delFlag+""; - if(d.delFlag>0){ - return ''; - } + let html=""+d.vioPhotoNum+""; return html; } }, - {field: "userType", title: "检查人",width: 110, unresize: true, align: "center"}, - {field: "userType", title: "违章时间",width: 110, unresize: true, align: "center"}, - {field: "userType", title: "整改期限",width: 110, unresize: true, align: "center"}, - {field: "userType", title: "整改状态",width: 110, unresize: true, align: "center", + {field: "checkUserName", title: "检查人",width: 110, unresize: true, align: "center"}, + {field: "vioDate", title: "违章时间",width: 110, unresize: true, align: "center"}, + {field: "rectDate", title: "整改期限",width: 110, unresize: true, align: "center"}, + {field: "", title: "整改状态",width: 110, unresize: true, align: "center", templet: function (d) { var html=""; - if (d.sex == 0) { + if (d.rectStatus == 0) { html="待整改" return html; - } else if (d.sex == 1) { - html="待整改" + } else if (d.rectStatus == 1) { + html="已整改" return html; } } }, - {field: "userType", title: "整改照片",width: 110, unresize: true, align: "center", + {field: "", title: "整改照片",width: 110, unresize: true, align: "center", templet: function (d) { - let html=""+d.delFlag+""; - if(d.delFlag>0){ - return ''; - } + let html=""+d.rectPhotoNum+""; return html; } }, - {field: "userType", title: "整改说明",width: 110, unresize: true, align: "center"}, - {field: "userType", title: "整改人",width: 110, unresize: true, align: "center"}, - {field: "userType", title: "整改时间",width: 110, unresize: true, align: "center"}, + {field: "rectDesc", title: "整改说明",width: 110, unresize: true, align: "center"}, + {field: "rectUserName", title: "整改人",width: 110, unresize: true, align: "center"}, + {field: "rectTime", title: "整改时间",width: 110, 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; } }, @@ -141,25 +129,24 @@ 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('') + $('#stateId').val('') + layui.form.render(); } + obj = { + page: page + "", + limit: limit + "", + keyWord: $('#keyWord').val(), + proId: $('#proId').val(), + proType: $('#proTypeId').val(), + gxId: $('#processId').val(), + proStatus: $('#stateId').val() + + }; console.log(obj) obj={ encryptedData:encryptCBC(JSON.stringify(obj)) @@ -178,16 +165,9 @@ function query(type) { }); } pageNum = 1; - pages(1, limitSize); + pages(1, limitSize,type); } - -//重置 -function reset() { - pages(1, limitSize, 1) -} - - function reloadData() { pages(pageNum, limitSize); } @@ -196,7 +176,8 @@ function reloadData() { function detailsData(id) { let title = '详情' let param = { - 'id': id + 'id': id, + 'details':'1' } openIframe2("detailsSafetyViolations", title, "child/safetyViolationsForm.html", '1200px', '625px', param); } @@ -209,7 +190,8 @@ function addData(id) { title = '修改'; } let param = { - 'id': id + 'id': id, + 'details':'' } openIframe2("addOrEditSafetyViolations", title, "child/safetyViolationsForm.html", '1200px', '625px', param); } @@ -220,14 +202,14 @@ function delData(id) { move: false }, function () { let loadingMsg = layer.msg('数据删除中,请稍候...', {icon: 16, scrollbar: false, time: 0}); - let url = dataUrl + "/users/delById"; + let url = dataUrl + "/imgUpload/safetyViolation/delSafetyViolationById"; let params = { 'id': id } params={ encryptedData:encryptCBC(JSON.stringify(params)) } - ajaxRequest(url, "POST", params, true, function () { + ajaxRequest(url, "DELETE", params, true, function () { }, function (result) { layer.close(loadingMsg); // 关闭提示层 if (result.code === 200) { @@ -243,45 +225,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','请选择工程'); @@ -297,25 +249,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','请选择工程类型'); @@ -332,7 +271,11 @@ 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','请选择工序类型'); @@ -348,8 +291,11 @@ function getProcessIdSelected() { * 获取状态 */ function getStateIdSelected() { - let url = dataUrl + '/users/getRoleAll'; - ajaxRequest(url, "POST", null, true, function () { + let url = dataUrl + '/sys/select/getDictSelectByType'; + let data={ + encryptedData:encryptCBC(JSON.stringify({"code":"pro_status"})) + } + ajaxRequest(url, "GET", data, true, function () { }, function (result) { if (result.code === 200) { setSelectValue(result.data, 'stateId','请选择状态类型'); @@ -385,4 +331,35 @@ function violationPhoto(id){ */ function correctionPhoto(id){ alert(id) +} + +function exportExcel() { + let obj = { + keyWord: $('#keyWord').val(), + proId: $('#proId').val(), + proType: $('#proTypeId').val(), + gxId: $('#processId').val(), + proStatus: $('#stateId').val() + }; + let loadingMsg = layer.msg("数据导出中,请稍候...", {icon: 16, scrollbar: false, time: 0,}); + let url = dataUrl + "/imgUpload/safetyViolation/downloadExcel?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/safetyViolations/child/safetyViolationsForm.html b/src/main/resources/static/pages/imageUpload/safetyViolations/child/safetyViolationsForm.html index 2977c11..0146791 100644 --- a/src/main/resources/static/pages/imageUpload/safetyViolations/child/safetyViolationsForm.html +++ b/src/main/resources/static/pages/imageUpload/safetyViolations/child/safetyViolationsForm.html @@ -60,7 +60,7 @@
-
@@ -68,13 +68,13 @@
-
-
@@ -85,29 +85,29 @@
- +
- +
- +
- +
- +
@@ -115,15 +115,15 @@
-
预览图: -
+
-
+
@@ -131,33 +131,33 @@
- +
- +
- +
- +
- +
-
预览图: -
+
- +
diff --git a/src/main/resources/static/pages/imageUpload/safetyViolations/safetyViolationsList.html b/src/main/resources/static/pages/imageUpload/safetyViolations/safetyViolationsList.html index 8dfb9de..17910b0 100644 --- a/src/main/resources/static/pages/imageUpload/safetyViolations/safetyViolationsList.html +++ b/src/main/resources/static/pages/imageUpload/safetyViolations/safetyViolationsList.html @@ -59,9 +59,9 @@
- -