diff --git a/src/main/resources/static/js/safetyViolations/child/safetyViolationsForm.js b/src/main/resources/static/js/imageUpload/implement/child/implementForm.js similarity index 100% rename from src/main/resources/static/js/safetyViolations/child/safetyViolationsForm.js rename to src/main/resources/static/js/imageUpload/implement/child/implementForm.js diff --git a/src/main/resources/static/js/imageUpload/implement/implementList.js b/src/main/resources/static/js/imageUpload/implement/implementList.js new file mode 100644 index 0000000..863a542 --- /dev/null +++ b/src/main/resources/static/js/imageUpload/implement/implementList.js @@ -0,0 +1,363 @@ +let form, layer, table, tableIns; +let pageNum = 1, limitSize = 10; // 默认第一页,分页数量为10 +let selectOrgId=""; + +layui.use(['form', 'layer', 'table', 'laydate'], function () { + form = layui.form; + layer = layui.layer; + table = layui.table; + layui.form.render(); + getProSelected(); + getProTypeSelected(); + getProcessIdSelected(); + getStateIdSelected(); + pages(1, 10, 1); + +}) + +function pages(pageNum, pageSize, typeNum) { + let params = getReqParams(pageNum, pageSize, typeNum); + let url = dataUrl + "/users/getList" + 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) + } + } else if (result.code === 500) { + layer.alert(result.msg, {icon: 2}) + } + }, function (xhr) { + error(xhr) + }); + +} + +function laypages(total, page, limit) { + layui.use(['laypage'], function () { + let laypage = layui.laypage; + laypage.render({ + elem: 'voi-page', + count: total, + curr: page, + limit: limit, + limits: [10, 20, 50, 100, 200, 500], + layout: ['prev', 'page', 'next', 'skip', 'count', 'limit'], + groups: 5, + jump: function (obj, first) { + if (!first) { + pageNum = obj.curr, limitSize = obj.limit; + pages(obj.curr, obj.limit, null); + } + } + }); + }) +} + +/*初始化表格*/ +function initTable(dataList, limit, page) { + let loadingMsg = layer.msg("数据加载中,请稍候...", {icon: 16, scrollbar: false, time: 0,}); + tableIns = table.render({ + elem: "#table_data", + height: "full-130", + data: dataList, + limit: limit, + cols: [ + [ + //表头 + {title: "序号", width: 80, unresize: true, align: "center", + templet: function (d) { + return (page - 1) * limit + d.LAY_INDEX; + } + }, + {field: "loginName", title: "项目名称",width: 210, 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: 210, unresize: true, align: "center"}, + {field: "phone", title: "现场照片",width: 150, unresize: true, align: "center", + templet: function (d) { + let html=""+d.delFlag+""; + if(d.delFlag>0){ + return ''; + } + return html; + } + }, + {field: "userType", title: "检查人",width: 90, unresize: true, align: "center"}, + {field: "userType", 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; + } + }, + ], + ], + done: function (res, curr, count) { + layer.close(loadingMsg); + table.resize("table_data"); + count || this.elem.next(".layui-table-view").find(".layui-table-header").css("display", "inline-block"); + count || this.elem.next(".layui-table-view").find(".layui-table-box").css("overflow", "auto"); + }, + }); +} + + +// 获取参数 +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: '', + }; + } + console.log(obj) + obj={ + encryptedData:encryptCBC(JSON.stringify(obj)) + } + return obj; +} + +// 查询/重置 +function query(type) { + let pattern = new RegExp("[%_<>]"); + if (pattern.test($("#keyWord").val())) { + $("#keyWord").val(''); + return layer.msg('关键字查询包含特殊字符,请重新输入', { + icon: 2, + time: 2000 //2秒关闭(如果不配置,默认是3秒) + }); + } + pageNum = 1; + pages(1, limitSize); +} + + +//重置 +function reset() { + pages(1, limitSize, 1) +} + + +function reloadData() { + pages(pageNum, limitSize); +} + +//详情 +function detailsData(id) { + let title = '详情' + let param = { + 'id': id + } + openIframe2("detailsSafetyViolations", title, "child/implementForm.html", '1200px', '625px', param); +} + + +// 新增/修改 +function addData(id) { + let title = '新增' + if (id) { + title = '修改'; + } + let param = { + 'id': id + } + openIframe2("addOrEditSafetyViolations", title, "child/implementForm.html", '1200px', '625px', param); +} + +/*删除用户*/ +function delData(id) { + layer.confirm("确定删除吗?", { + move: false + }, function () { + let loadingMsg = layer.msg('数据删除中,请稍候...', {icon: 16, scrollbar: false, time: 0}); + let url = dataUrl + "/users/delById"; + let params = { + 'id': id + } + params={ + encryptedData:encryptCBC(JSON.stringify(params)) + } + ajaxRequest(url, "POST", params, true, function () { + }, function (result) { + layer.close(loadingMsg); // 关闭提示层 + if (result.code === 200) { + parent.layer.msg(result.msg, {icon: 1}) + query() + } else if (result.code === 500) { + layer.alert(result.msg, {icon: 2}) + } + }, function (xhr) { + layer.close(loadingMsg); // 关闭提示层 + error(xhr) + }); + }) +} + +// 启用/停用/解除锁定 +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 () { + }, function (result) { + if (result.code === 200) { + setSelectValue(result.data, 'proId','请选择工程'); + } else { + layer.alert(result.msg, {icon: 2}) + } + }, function (xhr) { + error(xhr) + }); +} + +/** + * 获取工程类型 + */ +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) + }); +} + +/** + * 获取工程类型 + */ +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) + }); +} + +/** + * 获取工序 + */ +function getProcessIdSelected() { + let url = dataUrl + '/sys/select/getProcessSelect'; + ajaxRequest(url, "GET", null, true, function () { + }, function (result) { + if (result.code === 200) { + setSelectValue(result.data, 'processId','请选择工序类型'); + } else { + layer.alert(result.msg, {icon: 2}) + } + }, function (xhr) { + error(xhr) + }); +} + +/** + * 获取状态 + */ +function getStateIdSelected() { + let url = dataUrl + '/users/getRoleAll'; + ajaxRequest(url, "POST", null, true, function () { + }, function (result) { + if (result.code === 200) { + setSelectValue(result.data, 'stateId','请选择状态类型'); + } else { + layer.alert(result.msg, {icon: 2}) + } + }, function (xhr) { + error(xhr) + }); +} + +/*下拉选表单赋值*/ +function setSelectValue(list, selectName, placeholder) { + let html = ''; + $.each(list, function (index, item) { + html += ''; + }) + $('#' + selectName).empty().append(html); + layui.form.render(); +} + +/** + * 违规照片 + * @param id + */ +function violationPhoto(id){ + alert(id) +} + +/** + * 修正照片 + * @param id + */ +function correctionPhoto(id){ + alert(id) +} \ No newline at end of file diff --git a/src/main/resources/static/js/imageUpload/qualityInspection/child/qualityInspectionForm.js b/src/main/resources/static/js/imageUpload/qualityInspection/child/qualityInspectionForm.js new file mode 100644 index 0000000..0cb6f1a --- /dev/null +++ b/src/main/resources/static/js/imageUpload/qualityInspection/child/qualityInspectionForm.js @@ -0,0 +1,363 @@ +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; + + +// 模拟后台返回的数据结构 +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 = []; + +layui.use(['laydate', 'upload'], function () { + var upload = layui.upload; + var layer = layui.layer; + var element = layui.element; + var $ = layui.$; + + + // 多图片上传 + upload.render({ + elem: '#ID-upload-demo-btn-2', + 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').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 + }); + } + }); + + // 更新数据 + imagePaths = successPaths; + $('#imagePaths').val(JSON.stringify(imagePaths)); + + layer.msg('上传成功!', {icon: 1}); + console.log("当前图片数据:", imagePaths); + }, 1500); + }); + + 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', + }); + + +}); + + +function setParams(params) { + console.log(params) + idParam = JSON.parse(params).id; + 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.render();//重新渲染页面checkbox控件 + form.on('submit(formData)', function (data) { + data.field.id = $('#id').val(); + saveData(data); + }); + + }); +} + +/** + * 获取工程数据 + */ +function getProSelected() { + let url = dataUrl + '/users/getRoleAll'; + ajaxRequest(url, "POST", null, true, function () { + }, function (result) { + if (result.code === 200) { + setSelectValueName(result.data, 'projectName', "请选择项目(可搜索)"); + } 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, 'specialty', "请选择专业"); + } else { + layer.alert(result.msg, {icon: 2}) + } + }, function (xhr) { + error(xhr) + }); +} + +/** + * 获取工序数据 + */ +function getProcessSelected() { + let url = dataUrl + '/sys/select/getProcessSelect'; + ajaxRequest(url, "GET", null, true, function () { + }, function (result) { + if (result.code === 200) { + setSelectValueName(result.data, 'process', '请选择工序'); + } 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 + "/users/getById"; + 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) + $('#inspector').val("修改") + $('#loginName').val(data.loginName) + $('#phone').val(data.phone) + $('#roleId option[value=' + data.roleId + ']').attr('selected', true) + + layui.form.render(); + } +} + +function saveData2() { + $('#formSubmit').trigger('click') +} + +// 保存数据 +function saveData(data) { + let loadingMsg = layer.msg('数据上传中,请稍候...', {icon: 16, scrollbar: false, time: 0}); + let url = dataUrl + "/users/addTemp"; + let params = data.field; + if (params.id != "") { + url = dataUrl + "/users/update"; + } + 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/qualityInspection/qualityInspectionList.js b/src/main/resources/static/js/imageUpload/qualityInspection/qualityInspectionList.js new file mode 100644 index 0000000..0edb82e --- /dev/null +++ b/src/main/resources/static/js/imageUpload/qualityInspection/qualityInspectionList.js @@ -0,0 +1,388 @@ +let form, layer, table, tableIns; +let pageNum = 1, limitSize = 10; // 默认第一页,分页数量为10 +let selectOrgId=""; + +layui.use(['form', 'layer', 'table', 'laydate'], function () { + form = layui.form; + layer = layui.layer; + table = layui.table; + layui.form.render(); + getProSelected(); + getProTypeSelected(); + getProcessIdSelected(); + getStateIdSelected(); + pages(1, 10, 1); + +}) + +function pages(pageNum, pageSize, typeNum) { + let params = getReqParams(pageNum, pageSize, typeNum); + let url = dataUrl + "/users/getList" + 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) + } + } else if (result.code === 500) { + layer.alert(result.msg, {icon: 2}) + } + }, function (xhr) { + error(xhr) + }); + +} + +function laypages(total, page, limit) { + layui.use(['laypage'], function () { + let laypage = layui.laypage; + laypage.render({ + elem: 'voi-page', + count: total, + curr: page, + limit: limit, + limits: [10, 20, 50, 100, 200, 500], + layout: ['prev', 'page', 'next', 'skip', 'count', 'limit'], + groups: 5, + jump: function (obj, first) { + if (!first) { + pageNum = obj.curr, limitSize = obj.limit; + pages(obj.curr, obj.limit, null); + } + } + }); + }) +} + +/*初始化表格*/ +function initTable(dataList, limit, page) { + let loadingMsg = layer.msg("数据加载中,请稍候...", {icon: 16, scrollbar: false, time: 0,}); + tableIns = table.render({ + elem: "#table_data", + height: "full-130", + data: dataList, + limit: limit, + cols: [ + [ + //表头 + {title: "序号", width: 80, unresize: true, align: "center", + templet: function (d) { + 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: 150, unresize: true, align: "center", + templet: function (d) { + let html=""+d.delFlag+""; + if(d.delFlag>0){ + return ''; + } + return html; + } + }, + {field: "userType", title: "检查人",width: 90, 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", + templet: function (d) { + var html=""; + if (d.sex == 0) { + html="待整改" + return html; + } else if (d.sex == 1) { + html="待整改" + return html; + } + } + }, + {field: "userType", title: "整改照片",width: 110, unresize: true, align: "center", + templet: function (d) { + let html=""+d.delFlag+""; + if(d.delFlag>0){ + return ''; + } + return html; + } + }, + {field: "userType", title: "整改说明",width: 110, unresize: true, align: "center"}, + {field: "userType", title: "整改人",width: 90, unresize: true, align: "center"}, + {field: "userType", 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; + } + }, + ], + ], + done: function (res, curr, count) { + layer.close(loadingMsg); + table.resize("table_data"); + count || this.elem.next(".layui-table-view").find(".layui-table-header").css("display", "inline-block"); + count || this.elem.next(".layui-table-view").find(".layui-table-box").css("overflow", "auto"); + }, + }); +} + + +// 获取参数 +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: '', + }; + } + console.log(obj) + obj={ + encryptedData:encryptCBC(JSON.stringify(obj)) + } + return obj; +} + +// 查询/重置 +function query(type) { + let pattern = new RegExp("[%_<>]"); + if (pattern.test($("#keyWord").val())) { + $("#keyWord").val(''); + return layer.msg('关键字查询包含特殊字符,请重新输入', { + icon: 2, + time: 2000 //2秒关闭(如果不配置,默认是3秒) + }); + } + pageNum = 1; + pages(1, limitSize); +} + + +//重置 +function reset() { + pages(1, limitSize, 1) +} + + +function reloadData() { + pages(pageNum, limitSize); +} + +//详情 +function detailsData(id) { + let title = '详情' + let param = { + 'id': id + } + openIframe2("detailsSafetyViolations", title, "child/qualityInspectionForm.html", '1200px', '625px', param); +} + + +// 新增/修改 +function addData(id) { + let title = '新增' + if (id) { + title = '修改'; + } + let param = { + 'id': id + } + openIframe2("addOrEditSafetyViolations", title, "child/qualityInspectionForm.html", '1200px', '625px', param); +} + +/*删除用户*/ +function delData(id) { + layer.confirm("确定删除吗?", { + move: false + }, function () { + let loadingMsg = layer.msg('数据删除中,请稍候...', {icon: 16, scrollbar: false, time: 0}); + let url = dataUrl + "/users/delById"; + let params = { + 'id': id + } + params={ + encryptedData:encryptCBC(JSON.stringify(params)) + } + ajaxRequest(url, "POST", params, true, function () { + }, function (result) { + layer.close(loadingMsg); // 关闭提示层 + if (result.code === 200) { + parent.layer.msg(result.msg, {icon: 1}) + query() + } else if (result.code === 500) { + layer.alert(result.msg, {icon: 2}) + } + }, function (xhr) { + layer.close(loadingMsg); // 关闭提示层 + error(xhr) + }); + }) +} + +// 启用/停用/解除锁定 +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 () { + }, function (result) { + if (result.code === 200) { + setSelectValue(result.data, 'proId','请选择工程'); + } else { + layer.alert(result.msg, {icon: 2}) + } + }, function (xhr) { + error(xhr) + }); +} + +/** + * 获取工程类型 + */ +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) + }); +} + +/** + * 获取工程类型 + */ +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) + }); +} + +/** + * 获取工序 + */ +function getProcessIdSelected() { + let url = dataUrl + '/sys/select/getProcessSelect'; + ajaxRequest(url, "GET", null, true, function () { + }, function (result) { + if (result.code === 200) { + setSelectValue(result.data, 'processId','请选择工序类型'); + } else { + layer.alert(result.msg, {icon: 2}) + } + }, function (xhr) { + error(xhr) + }); +} + +/** + * 获取状态 + */ +function getStateIdSelected() { + let url = dataUrl + '/users/getRoleAll'; + ajaxRequest(url, "POST", null, true, function () { + }, function (result) { + if (result.code === 200) { + setSelectValue(result.data, 'stateId','请选择状态类型'); + } else { + layer.alert(result.msg, {icon: 2}) + } + }, function (xhr) { + error(xhr) + }); +} + +/*下拉选表单赋值*/ +function setSelectValue(list, selectName, placeholder) { + let html = ''; + $.each(list, function (index, item) { + html += ''; + }) + $('#' + selectName).empty().append(html); + layui.form.render(); +} + +/** + * 违规照片 + * @param id + */ +function violationPhoto(id){ + alert(id) +} + +/** + * 修正照片 + * @param id + */ +function correctionPhoto(id){ + alert(id) +} \ No newline at end of file diff --git a/src/main/resources/static/js/imageUpload/safetyViolations/child/safetyViolationsForm.js b/src/main/resources/static/js/imageUpload/safetyViolations/child/safetyViolationsForm.js new file mode 100644 index 0000000..0cb6f1a --- /dev/null +++ b/src/main/resources/static/js/imageUpload/safetyViolations/child/safetyViolationsForm.js @@ -0,0 +1,363 @@ +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; + + +// 模拟后台返回的数据结构 +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 = []; + +layui.use(['laydate', 'upload'], function () { + var upload = layui.upload; + var layer = layui.layer; + var element = layui.element; + var $ = layui.$; + + + // 多图片上传 + upload.render({ + elem: '#ID-upload-demo-btn-2', + 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').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 + }); + } + }); + + // 更新数据 + imagePaths = successPaths; + $('#imagePaths').val(JSON.stringify(imagePaths)); + + layer.msg('上传成功!', {icon: 1}); + console.log("当前图片数据:", imagePaths); + }, 1500); + }); + + 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', + }); + + +}); + + +function setParams(params) { + console.log(params) + idParam = JSON.parse(params).id; + 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.render();//重新渲染页面checkbox控件 + form.on('submit(formData)', function (data) { + data.field.id = $('#id').val(); + saveData(data); + }); + + }); +} + +/** + * 获取工程数据 + */ +function getProSelected() { + let url = dataUrl + '/users/getRoleAll'; + ajaxRequest(url, "POST", null, true, function () { + }, function (result) { + if (result.code === 200) { + setSelectValueName(result.data, 'projectName', "请选择项目(可搜索)"); + } 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, 'specialty', "请选择专业"); + } else { + layer.alert(result.msg, {icon: 2}) + } + }, function (xhr) { + error(xhr) + }); +} + +/** + * 获取工序数据 + */ +function getProcessSelected() { + let url = dataUrl + '/sys/select/getProcessSelect'; + ajaxRequest(url, "GET", null, true, function () { + }, function (result) { + if (result.code === 200) { + setSelectValueName(result.data, 'process', '请选择工序'); + } 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 + "/users/getById"; + 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) + $('#inspector').val("修改") + $('#loginName').val(data.loginName) + $('#phone').val(data.phone) + $('#roleId option[value=' + data.roleId + ']').attr('selected', true) + + layui.form.render(); + } +} + +function saveData2() { + $('#formSubmit').trigger('click') +} + +// 保存数据 +function saveData(data) { + let loadingMsg = layer.msg('数据上传中,请稍候...', {icon: 16, scrollbar: false, time: 0}); + let url = dataUrl + "/users/addTemp"; + let params = data.field; + if (params.id != "") { + url = dataUrl + "/users/update"; + } + 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/safetyViolations/safetyViolationsList.js b/src/main/resources/static/js/imageUpload/safetyViolations/safetyViolationsList.js similarity index 100% rename from src/main/resources/static/js/safetyViolations/safetyViolationsList.js rename to src/main/resources/static/js/imageUpload/safetyViolations/safetyViolationsList.js diff --git a/src/main/resources/static/pages/imageUpload/implement/child/implementForm.html b/src/main/resources/static/pages/imageUpload/implement/child/implementForm.html new file mode 100644 index 0000000..4186dc9 --- /dev/null +++ b/src/main/resources/static/pages/imageUpload/implement/child/implementForm.html @@ -0,0 +1,175 @@ + + + + + + + + + + + + + + + 安全措施落实-新增/修改 + + +
+
+ +
项目信息
+
+ +
+ +
+
+
+ +
+ +
+ +
+ +
+
+ + +
违章信息
+
+ +
+ +
+ +
+ +
+
+ +
+ +
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+
+ +
+ 预览图: +
+
+ +
+
+
+ +
整改信息
+
+ +
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+
+ +
+ 预览图: +
+
+ +
+
+
+ + +
+
+
+ + +
+ + + \ No newline at end of file diff --git a/src/main/resources/static/pages/imageUpload/implement/implementList.html b/src/main/resources/static/pages/imageUpload/implement/implementList.html new file mode 100644 index 0000000..a98964f --- /dev/null +++ b/src/main/resources/static/pages/imageUpload/implement/implementList.html @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + 安全措施落实 + + +
+ +
+
+
+
+
+ + + + + \ No newline at end of file diff --git a/src/main/resources/static/pages/imageUpload/qualityInspection/child/qualityInspectionForm.html b/src/main/resources/static/pages/imageUpload/qualityInspection/child/qualityInspectionForm.html new file mode 100644 index 0000000..f05a56e --- /dev/null +++ b/src/main/resources/static/pages/imageUpload/qualityInspection/child/qualityInspectionForm.html @@ -0,0 +1,175 @@ + + + + + + + + + + + + + + + 质量检查-新增/修改 + + +
+
+ +
项目信息
+
+ +
+ +
+
+
+ +
+ +
+ +
+ +
+
+ + +
违章信息
+
+ +
+ +
+ +
+ +
+
+ +
+ +
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+
+ +
+ 预览图: +
+
+ +
+
+
+ +
整改信息
+
+ +
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+
+ +
+ 预览图: +
+
+ +
+
+
+ + +
+
+
+ + +
+ + + \ No newline at end of file diff --git a/src/main/resources/static/pages/imageUpload/qualityInspection/qualityInspectionList.html b/src/main/resources/static/pages/imageUpload/qualityInspection/qualityInspectionList.html new file mode 100644 index 0000000..0b62137 --- /dev/null +++ b/src/main/resources/static/pages/imageUpload/qualityInspection/qualityInspectionList.html @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + 质量检查 + + +
+ +
+
+
+
+
+ + + + + \ 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 f79d410..2977c11 100644 --- a/src/main/resources/static/pages/imageUpload/safetyViolations/child/safetyViolationsForm.html +++ b/src/main/resources/static/pages/imageUpload/safetyViolations/child/safetyViolationsForm.html @@ -171,5 +171,5 @@ - + \ No newline at end of file diff --git a/src/main/resources/static/pages/imageUpload/safetyViolations/safetyViolationsList.html b/src/main/resources/static/pages/imageUpload/safetyViolations/safetyViolationsList.html index f4dd886..8dfb9de 100644 --- a/src/main/resources/static/pages/imageUpload/safetyViolations/safetyViolationsList.html +++ b/src/main/resources/static/pages/imageUpload/safetyViolations/safetyViolationsList.html @@ -85,5 +85,5 @@ } - + \ No newline at end of file