let form, layer, upload, laydate, idParam, isAppealParam, statusParam,formSelects,classParam,scoreParam,userParam; let fileList = new Array(), imgListUp = new Array(); let supTypeParam = ''; function setParams(id,classId) { idParam = id; classParam=classId; layui.config({ base: "../../../js/layui/", //此处路径请自行处理, 可以使用绝对路径 }).extend({ formSelects: 'formSelects-v4' }).use(['form', 'layer', 'upload', 'laydate','formSelects'], function () { layer = layui.layer; form = layui.form; upload = layui.upload; formSelects = layui.formSelects; laydate = layui.laydate; getTeamPersonnel(); form.render(); laydate.render({ elem: '#rectFinshTime', //指定元素 元素选择器 type: 'date', //选择时间类型 可选值:year(年) month(年月) date(年月日) time(时分秒) datetime(年月日时分秒) trigger: 'click', min: Date.parse(new Date()), format: 'yyyy-MM-dd', //时间格式 常用时间格式:yyyy-MM-dd HH:mm:ss btns: ['now', 'confirm'], //选择框右下角显示的按钮 清除-现在-确定 done: function (value, date) { //时间回调 } }); getNoticeVoiRectById(); $('#rectFinshTime').val(getNowTime()) let uploadObj = upload.render({ elem: '#test2', multiple: true, dataType: "json", exts: 'jpg|png|jpeg|doc|docx|pdf', // acceptMime: 'image/jpg,image/png,image/jpeg', // number: 3, //最大上传数量 size: 1024 * 100, //最大文件大小,单位k auto: false, //是否自动上传 ,默认为true bindAction: '#hideUpload', //绑定的按钮 choose: function (obj) { uploadObj.config.elem.next()[0].value = ''; obj.preview(function (index, file, result) { console.log(file) if (isFile(file.name)) { $('#uploader-list').append( '
' + '

x

' + '
' + setFileBack(file.name) + '

' + file.name + '

' + '
' + // '' + '
' ); } else { $('#uploader-list').append( '
' + '

x

' + '' + '
' ); } let map = new Map();//将选择的图片索引和图片写成对象存入集合 map.index = index; map.file = file; fileList.push(map); }); } }); }); } function getTeamPersonnel() { let params = { classId: classParam, userName: '' } $.ajax({ headers: { "encrypt": sm3(JSON.stringify(params)) }, type: "post", url: dataUrl + 'proteam/pot/todayTask/getPersonList?token=' + token, data: params, async:false, success: function (result) { if (result.code === 200) { console.log(result); let keys = []; $.each(result.data, function (index, item) { let temp = { "name": item.userName, "value": item.idNumber }; keys.push(temp); }) formSelects.data('vioUsers', 'local', { arr: keys }); layui.form.render(); } else if (result.code === 500) { return layer.alert(data.msg, {icon: 2}) } else if (result.code === 401) { logout(1); } }, error: function () { initClassTable(null); } }); } // 提交数据 function saveData() { let rectExplain = $('#rectExplain').val(); let dutyUnit = $('#dutyUnit').val(); let dutyUser = $('#dutyUser').val(); let contactPhone = $('#contactPhone').val(); let rectFinshTime = $('#rectFinshTime').val(); let value = $('input[type=radio]:checked').val(); let users=formSelects.value('vioUsers', 'val').toString() let namesParam=formSelects.value('vioUsers', 'name').toString() if(users=='' ||users==null){ return layer.msg("请选择违章人员", {icon: 5}); } if(users==userParam){ users=''; console.log("未修改人员"); } console.log(users); console.log(userParam); if (!dutyUnit) { if (isAppealParam) { if (isAppealParam === '0') return layer.msg("请填写责任单位", {icon: 5}) } else { if (value === '0') return layer.msg("请填写责任单位", {icon: 5}) } } if (!dutyUser) { if (isAppealParam) { if (isAppealParam === '0') return layer.msg("请填写责任人", {icon: 5}) } else { if (value === '0') return layer.msg("请填写责任人", {icon: 5}) } } if (!contactPhone) { if (isAppealParam) { if (isAppealParam === '0') return layer.msg("请填写联系人及电话", {icon: 5}) } else { if (value === '0') return layer.msg("请填写联系人及电话", {icon: 5}) } } if (!rectExplain) { if (isAppealParam) { if (isAppealParam === '0') { return layer.msg("请填写整改说明", {icon: 5}) } else { return layer.msg("请填写申诉说明", {icon: 5}) } } else { if (value === '0') { return layer.msg("请填写整改说明", {icon: 5}) } else { return layer.msg("请填写申诉说明", {icon: 5}) } } } if (fileList.length === 0) { if (isAppealParam) { if (isAppealParam === '0') { return layer.msg("请上传整改照片", {icon: 5}) } else { return layer.msg("请上传申诉照片", {icon: 5}) } } else { if (value === '0') { return layer.msg("请上传整改照片", {icon: 5}) } else { return layer.msg("请上传申诉照片", {icon: 5}) } } } let formData = new FormData(); //遍历最终图片集合 for (let i = 0; i < fileList.length; i++) { formData.append("file[]", fileList[i].file) } formData.append("params", JSON.stringify({ 'usersParam':users, 'scoreParam':scoreParam, 'namesParam':namesParam, 'rectExplain': rectExplain, 'classParam':classParam, 'notiId': idParam, 'dutyUnit': dutyUnit, 'dutyUser': dutyUser, 'contactPhone': contactPhone, 'rectFinshTime': rectFinshTime, 'supType':supTypeParam })) if (isAppealParam) { formData.append("isAppeal", isAppealParam); } else { formData.append("isAppeal", value); } // 加载提示 let loadingMsg = layer.msg('数据上传中,请稍候...', {icon: 16, scrollbar: false, time: 0}); $.ajax({ /*headers: { "encrypt": sm3(JSON.stringify(params)) },*/ url: dataUrl + 'proteam/pot/superStatistics/uploadNoticeVioRect?token=' + token, type: 'POST', data: formData, dataType: 'json', processData: false, contentType: false, beforeSend: function () { $('.save').addClass("layui-btn-disabled").attr("disabled", true); $('.cancel').addClass("layui-btn-disabled").attr("disabled", true); }, success: function (result) { layer.close(loadingMsg); // 关闭提示层 if (result.msg === 'success') { closePage(1); if (isAppealParam) { if (isAppealParam === '0') { parent.layer.msg('违章整改成功', {icon: 1}); } else { parent.layer.msg('违章申诉成功', {icon: 1}); } } else { if (value === '0') { parent.layer.msg('违章整改成功', {icon: 1}); } else { parent.layer.msg('违章申诉成功', {icon: 1}); } } } else { layer.msg('服务异常,请稍后重试', {icon: 2}); $('.save').removeClass("layui-btn-disabled").attr("disabled", false); $('.cancel').removeClass("layui-btn-disabled").attr("disabled", false); } }, error: function (result) { layer.close(loadingMsg); // 关闭提示层 layer.msg('服务异常,请稍后重试', {icon: 16, scrollbar: false, time: 2000}); $('.save').removeClass("layui-btn-disabled").attr("disabled", false); $('.cancel').removeClass("layui-btn-disabled").attr("disabled", false); } }); } function getNoticeVoiRectById() { let loadingMsg = layer.msg("数据加载中,请稍候...", {icon: 16, scrollbar: false, time: 0,}); $.ajax({ headers: { "encrypt": sm3(JSON.stringify({ id: idParam })) }, url: dataUrl + 'proteam/pot/superStatistics/getNoticeVoiRectById?token=' + token, data: { id: idParam }, type: 'POST', async: false, success: function (result) { layer.close(loadingMsg); if (result.code === 200) { setData(result.data); } else if (result.code === 500) { layer.alert(result.msg, {icon: 2}) } else if (result.code === 401) { logout(1) } }, error: function () { layer.close(loadingMsg); setData(null); } }); } /*页面赋值*/ function setData(data) { console.log(data); supTypeParam = data.supType; $('#status').html(data.status) $('#createTime').html(data.createTime) $('#voiType').html(data.voiType) $('#levelId').html(data.levelId) $('#type').html(data.type) $('#org').html(data.org) // $('#vioUsers').html(data.vioUsers) $('#voiYj').html(data.voiYj) $('#content').html(data.content) $('#recRequirement').html(data.recRequirement) let vioUsers=[]; var userList=data.userList; if(userList.length>0){ scoreParam=userList[0].score; for (var i = 0; i < userList.length; i++) { vioUsers.push(userList[i].idNumber); } formSelects.value('vioUsers', vioUsers); userParam=formSelects.value('vioUsers', 'val').toString(); } let imgPath = data.imgPath, imgPathArr = imgPath.split(','), html = '' $.each(imgPathArr, function (index, item) { let path = photoUrl + item + '?token=' + token html += '' }) $('.supervision-img').empty().append(html) statusParam = data.status if (data.isAppeal) { isAppealParam = data.isAppeal; if (data.isAppeal === '0') { $('#rect-name').html('整改反馈') $('#rect-img-name').html('整改照片') $('#explain').html('整改说明:') $('.rect-form').removeAttr('style') } else { $('#rect-name').html('申诉反馈') $('#rect-img-name').html('申诉照片') $('#explain').html('申诉说明:') } if (data.list) { let cent = '整改照片', cent2 = '整改说明'; if (data.isAppeal === '1') { cent = '申诉照片', cent2 = '申诉说明'; } let html = ''; $.each(data.list, function (index, item) { html += '
' + '
' + '

' + (index + 1) + '

' + '
' + '
' + '
' + '

' + cent + ':

' + '
' + setImg(item) + '
' + '
' + setRectInfo(data.isAppeal, item) + '
' + '

' + cent2 + ':

' + '

' + item.rectExplain + '

' + '
' + '
' + '

驳回说明:

' + '

' + setValue2(item.checkOpinion) + '

' + '
' + '
' + '
' + '
' }) $('.rect-content').empty().append(html) } } else { $('.choose-rectify-type').removeAttr('style') $('.rect-form').removeAttr('style') } let viewer = new Viewer(document.getElementById('dc-img'), { url: 'data-original', show: function () { viewer.update(); } }); } function setRectInfo(isAppeal, item) { console.error(item) let html = ''; if (isAppeal === '0') { html += '
' + '

责任单位:' + item.dutyUnit + '

' + '

责任人:' + item.dutyUser + '

' + '
' + '
' + '

整改完成时间:' + item.rectFinshTime + '

' + '

联系人及电话:' + item.contactPhone + '

' + '
'; } return html; } function setImg(data) { let imgPath = data.imagePath, imgPathArr = imgPath.split(','), html = '' $.each(imgPathArr, function (index, item) { let path = photoUrl + item + '?token=' + token html += '' }) return html; } function chooseType() { let value = $('input[type=radio]:checked').val() if (value === '0') { $('#rect-name').html('整改反馈') $('#rect-img-name').html('整改照片') $('#explain').html('整改说明:') $('.rect-form').removeAttr('style') } else { $('#rect-name').html('申诉反馈') $('#rect-img-name').html('申诉照片') $('#explain').html('申诉说明:') $('.rect-form').css('display', 'none') } } // 删除图片 $(document).on("click", ".file-iteme .handle", function (event) { imgListUp.splice(0, imgListUp.length); let index = $(this).next().attr('data-index'); $.each(fileList, function (inx, ele) { //对比删除图片索引 //将未删除的存入新集合 if (index != ele.index) { imgListUp.push(ele); } }); $(this).parent().remove(); //将新图片集合替换老集合 fileList.splice(0, fileList.length); $.each(imgListUp, function (inx, ele) { fileList.push(ele) }); }); // 是否是文件 function isFile(value) { if (value.indexOf("docx") > 0 || value.indexOf("doc") > 0 || value.indexOf("pdf") > 0) { return true } else { return false; } } // 设置文件背景 function setFileBack(value) { if (value.indexOf("docx") > 0) { return ''; } else if (value.indexOf("doc") > 0) { return ''; } else if (value.indexOf("pdf") > 0) { return ''; } } // 关闭页面 function closePage(type) { let index = parent.layer.getFrameIndex(window.name); //先得到当前 iframe层的索引 parent.layer.close(index); //再执行关闭 if (type === 1) { window.parent.reloadData() } }