layui.use(['laytpl', 'upload'], function () { var form = layui.form , laytpl = layui.laytpl , upload = layui.upload; var projectId = GetQueryString("project_id"); var stepCode = GetQueryString("step_code"); var progressId = GetQueryString("progress_id"); var canDo = GetQueryString("can_do"); var backParms = GetQueryString("back"); var radioId = 0; var currentStepCode = ""; // 选中步骤 $("#" + stepCode.substring(0, 2)).find("#divShadow").addClass('xmjdshadowSelected'); // $("#01").attr('disabled', false); // 获取项目信息 $.ajax({ type: "GET", dataType: "json", url: "/dsBase/gtzz/getSubjectInfo", data: { subject_id: projectId }, success: function (data) { var projectInfoTpl = projectInfoScript.innerHTML, projectInfoView = document.getElementById('projectInfoView'); laytpl(projectInfoTpl).render(data, function (html) { projectInfoView.innerHTML = html; }); } }); var tpl = timeLineScript.innerHTML, view = document.getElementById('timeLineView'); timeLineLoadData(); function timeLineLoadData() { $.ajax({ type: "GET", dataType: "json", async: false, url: '/dsBase/gtzz/getTimeLineData', data: { progress_id: progressId, step_code: stepCode, can_do: canDo }, success: function (data) { laytpl(tpl).render(data, function (html) { view.innerHTML = html; }); currentStepCode = data.current_step_code.substring(0, 2); upload.render({ elem: '#uploadFile_0' //绑定元素 , accept: "file" , url: '/dsBase/gtzz/uploadFile' //上传接口 , data: { type_id: 1, progress_id: progressId, document_type_id: function () { return $('#uploadFile_0').attr("type_id"); } } , done: function (res) { if (res.success) { var _fielName = res.fileName; if (_fielName.length > 20) { _fielName = res.fileName.substring(0, 20) + "..."; } var progressId = $('#uploadFile_0').attr("progress_id"); var typeId = $('#uploadFile_0').attr("type_id"); $("#fileList_" + progressId + "_" + typeId).append('
' + _fielName + '
' + res.file_size + '
') } } , error: function (res) { //请求异常回调 console.log(res); } }); upload.render({ elem: '#uploadFile_1' //绑定元素 , accept: "file" , url: '/dsBase/gtzz/uploadFile' //上传接口 , data: { type_id: 1, progress_id: progressId, document_type_id: function () { return $('#uploadFile_1').attr("type_id"); } } , done: function (res) { if (res.success) { var _fielName = res.fileName; if (_fielName.length > 20) { _fielName = res.fileName.substring(0, 20) + "..."; } var progressId = $('#uploadFile_1').attr("progress_id"); var typeId = $('#uploadFile_1').attr("type_id"); $("#fileList_" + progressId + "_" + typeId).append('
' + _fielName + '
' + res.file_size + '
') } } , error: function (res) { //请求异常回调 console.log(res); } }); } }); }; if(currentStepCode === '02') { $("#03").find("i").css("color","#AAAAAA"); $("#03").find(".xmjdText").css("color","#AAAAAA"); $("#03").removeClass("xmjd"); $("#03").addClass("xmjdNone"); } if(currentStepCode === '03') { $("#02").find("i").css("color","#2FC25B"); } if(currentStepCode === '04') { $("#02").find("i").css("color","#2FC25B"); $("#03").find("i").css("color","#2FC25B"); } getSubmitStatus(); // 获取提交按钮状态是否显示 function getSubmitStatus() { $.ajax({ type: "GET", dataType: "json", url: "/dsBase/gtzz/getStepInfoByProgressId", data: { progress_id: progressId }, success: function (data) { data.can_do = canDo; var submitTpl = submitScript.innerHTML, submitView = document.getElementById('submitView'); laytpl(submitTpl).render(data, function (html) { submitView.innerHTML = html; }); } }); } $(".xmjd").click(function () { let _id = $(this).attr("id"); $(this).siblings().find("#divShadow").removeClass('xmjdshadowSelected'); $(this).find("#divShadow").addClass('xmjdshadowSelected'); stepCode = _id; timeLineLoadData(); }); // 返回 $("#back").click(function () { var backUrlArr = document.referrer.split("="); if (backParms === '00') { window.location.href = document.referrer + "?back=00"; } else { window.location.href = backUrlArr[0] + "=" + backParms; } // // window.history.go(-1); }); // 移除附件元素 window.removeFile = function (fileId) { layer.confirm('是否删除文件?', { icon: 0 }, function (index) { deleteFile(fileId); layer.close(index); }); }; // 删除文件接口 function deleteFile(fileId) { $.ajax({ type: "POST", dataType: "json", url: '/dsBase/gtzz/deleteProgressFile', data: { progress_id: progressId, file_id: fileId }, success: function (data) { if (data.success) { $("#" + fileId).remove(); } else { layer.msg("删除失败!" + data.message, { icon: 2, time: 1500, shade: [0.1, '#000', true] }); } } }); }; // 提交 window.submit = function (fileId) { $.ajax({ type: "POST", dataType: "json", url: '/dsBase/gtzz/submitStep', data: { progress_id: progressId, radio_id: radioId, message: $("#inputValue").val() }, success: function (data) { if (data.success) { layer.msg("提交成功!", { icon: 1, time: 1250, shade: [0.1, '#000', true] }, function () { var index = parent.layer.getFrameIndex(window.name); parent.layer.close(index); window.parent.parentTableRender(backParms); }); } else { layer.msg("提交失败!" + data.message, { icon: 2, time: 2000, shade: [0.1, '#000', true] }); } } }); }; // 点击radioButton事件 window.radioChange = function (radioValue,radioText) { if(radioText === '通过' || radioText === '退回' || radioText === '不通过') { $("#inputValue").val(radioText); } radioId = radioValue; } // 获取参数值 function GetQueryString(name, istop) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); var r = window.location.search.substr(1).match(reg); if (typeof (istop) != "undefined") r = top.location.search.substr(1).match(reg); if (r != null) return unescape(r[2]); return null; } // 填写验收明细事件 window.mxDetail = function (stepCode) { if (stepCode === '0304') { layer.open({ type: 2, title: '

维护验收明细

', shadeClose: true, shade: false, maxmin: false, //开启最大化最小化按钮 area: ['600px', '430px'], content: '../xx/xmdb/xmdwys/entryList.html?project_id=' + projectId, cancel: function () { timeLineLoadData(); } }); } else { layer.open({ type: 2, title: '

维护验收明细

', shadeClose: true, shade: false, maxmin: false, //开启最大化最小化按钮 area: ['600px', '307px'], content: '../zj/xmdb/xmsjys/entryList.html?project_id=' + projectId, cancel: function () { // timeLineLoadData(); } }); } }; window.questionDetail = function (subject_id) { layer.open({ type: 2, title: '

问题列表

', shadeClose: true, shade: false, maxmin: false, //开启最大化最小化按钮 move: false, area: ['1200px', '600px'], offset:['20px'], content: './questionList.html?subject_id=' + subject_id, cancel: function () { timeLineLoadData(); } }); } });