From eb0353bfdc6519baf6f0084493a2cd395964f6b2 Mon Sep 17 00:00:00 2001 From: lSun <15893999301@qq.com> Date: Mon, 31 Mar 2025 18:48:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=89=E5=85=A8=E8=BF=9D=E7=AB=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../child/safetyViolationsForm.js | 258 ++++++++++++ .../safetyViolations/safetyViolationsList.js | 387 ++++++++++++++++++ src/main/resources/static/js/select.js | 10 + .../child/safetyViolationsForm.html | 133 ++++++ .../safetyViolationsList.html | 89 ++++ 5 files changed, 877 insertions(+) create mode 100644 src/main/resources/static/js/safetyViolations/child/safetyViolationsForm.js create mode 100644 src/main/resources/static/js/safetyViolations/safetyViolationsList.js create mode 100644 src/main/resources/static/pages/imageUpload/safetyViolations/child/safetyViolationsForm.html create mode 100644 src/main/resources/static/pages/imageUpload/safetyViolations/safetyViolationsList.html diff --git a/src/main/resources/static/js/safetyViolations/child/safetyViolationsForm.js b/src/main/resources/static/js/safetyViolations/child/safetyViolationsForm.js new file mode 100644 index 0000000..4895904 --- /dev/null +++ b/src/main/resources/static/js/safetyViolations/child/safetyViolationsForm.js @@ -0,0 +1,258 @@ +let form, layer, util, idParam; +let arr = ['background', 'web', 'mobile', 'wx']; +let background, web, mobile, wx; +let data = []; + +// 初始化下拉选 +let proList; +let majorList; +let processList; +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(); + console.log( data.field.orgId_select_nodeId); + if(!data.field.orgId_select_nodeId){ + return layer.alert("请选择组织机构!", {icon: 2}) + } + let phone = $('#phone').val(); + if(phone){ + if (!(/^1[3456789]\d{9}$/.test(phone))) { + return layer.alert("请输入正确的手机号", {icon: 2}) + } + } + 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 + '/users/getRoleAll'; + ajaxRequest(url, "POST", 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 + '/users/getRoleAll'; + ajaxRequest(url, "POST", 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) { + $("#password").removeAttr("lay-verify"); + $("#pwd").css("display","none"); + $('#id').val(data.id) + // $('#userCode').val(data.userCode) + $('#username').val(data.username) + $('#loginName').val(data.loginName) + $('#phone').val(data.phone) + + // 设置选中状态 + if (data.sex === 1) { + document.getElementById('sex_1').checked = true; + } else if (data.sex === 0) { + document.getElementById('sex_0').checked = true; + } + + if (data.userType === '1') { + document.getElementById('userType_1').checked = true; + } else if (data.userType === '0') { + document.getElementById('userType_0').checked = true; + } + + if (data.state === 1) { + document.getElementById('state_1').checked = true; + } else if (data.state === 0) { + document.getElementById('state_0').checked = true; + } + $('#type_'+data.type).attr('checked', true) + $('#orgId').val(data.orgId) + $('#roleId').val(data.roleId) + $('#roleId option[value=' + data.roleId + ']').attr('selected', true) + $('#teamId').val(data.teamId) + $('#teamId option[value=' + data.teamId + ']').attr('selected', true) + var arrCB = data.loginTypes; + for (var j = 0; j < arrCB.length; j++) { + var cbthis = $("input[name='loginType']"); + for (var i = 0; i < cbthis.length; i++) { + if (cbthis[i].value == arrCB[j]) { + cbthis[i].checked = 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; + var arr_box = [];//固定复选框 + $('#cbGuDing input[type=checkbox]:checked').each(function () { + arr_box.push($(this).val()); + }); + console.log(arr_box) + params.loginType = arr_box.join() + params.orgId = params.orgId_select_nodeId; + 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 isRepeat(paramName, phone) { + let data = {}; + let url = dataUrl + "/sys/user/isRepeat"; + let params = { + 'value': phone, + 'paramName': paramName + } + ajaxRequest(url, "POST", params, false, function () { + }, function (result) { + if (result.code === 200) { + data = result + } else if (result.code === 500) { + } + }, function (xhr) { + error(xhr) + }); + return data; +} + +function getPasswordConfig(callback) { + let url = dataUrl + "/users/getPasswordConfig" + ajaxRequest(url, "POST", null, true, function () {}, function (result) { + // layer.close(loadingMsg); // 关闭提示层 + if (result.status === 200) { + callback(result.data); + } else if (result.status === 500) { + layer.alert(result.msg, {icon: 2}) + } + }, function (xhr) { + 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/safetyViolations/safetyViolationsList.js new file mode 100644 index 0000000..4030be0 --- /dev/null +++ b/src/main/resources/static/js/safetyViolations/safetyViolationsList.js @@ -0,0 +1,387 @@ +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: 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: 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: 110, 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 addData(id) { + let title = '新增用户' + if (id) { + title = '修改用户'; + } + let param = { + 'id': id + } + openIframe2("addOrEditUser", title, "child/userForm.html", '1000px', '625px', param); +} + +function addData(id) { + let title = '新增' + let param = { + 'id': id + } + openIframe2("addOrEditSafetyViolations", title, "child/safetyViolationsForm.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) + }); +} + +/** + * 获取工序 http://127.0.0.1:11997/imgTool/sys/select/getProfessionSelect + * http://127.0.0.1:11997/imgTool/sys/select/getProcessSelect + */ +function getProcessIdSelected() { + let url = dataUrl + '/sys/select/getProcessSelect'; + ajaxRequest(url, "POST", 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/select.js b/src/main/resources/static/js/select.js index 2f079b7..3362005 100644 --- a/src/main/resources/static/js/select.js +++ b/src/main/resources/static/js/select.js @@ -300,3 +300,13 @@ function setDictSelectValue(list, selectName) { $('#' + selectName).empty().append(html); layui.form.render(); } + + +function setSelectValueName(list, selectName, placeholder) { + let html = ''; + $.each(list, function (index, item) { + html += ''; + }) + $('#' + selectName).empty().append(html); + layui.form.render(); +} \ 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 new file mode 100644 index 0000000..3032787 --- /dev/null +++ b/src/main/resources/static/pages/imageUpload/safetyViolations/child/safetyViolationsForm.html @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + 安全违章-新增/修改 + + +
+
+ + + +
项目信息
+
+ +
+ +
+
+
+ +
+ +
+ +
+ +
+
+ + +
违章信息
+
+ +
+ +
+ +
+ +
+
+ +
+ +
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ + +
+
+
+ + +
+ + + \ 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 new file mode 100644 index 0000000..f4dd886 --- /dev/null +++ b/src/main/resources/static/pages/imageUpload/safetyViolations/safetyViolationsList.html @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + 安全违章 + + +
+ +
+
+
+
+
+ + + + + \ No newline at end of file