//全局的页面遮盖
let loadingMsg;
var startWorkFiles = {};
var upload;
var id;
var formData;

function setData(yjId,insMonth){
	layui.use(['form', 'table', 'upload'], function () {
	    let form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功
	    form.render();
	    upload = layui.upload;
	
	
	    form.on('submit(formDemo)', function (data) {
			edit(yjId,insMonth);
	    });
		
		$("#closeBt").click(function(){
			var index = parent.layer.getFrameIndex(window.name); //先得到当前 iframe层的索引
			parent.layer.close(index); //再执行关闭
		});
		
		
		
	});
}

function edit(yjId,insMonth){
	var reason = $("#revokeReason").val();
	// 加载提示
	let loadingMsg = layer.msg('数据上传中,请稍候...', {
		icon: 16,
		scrollbar: false,
		time: 0,
		shade: [0.8, '#393D49']
	});
	$.ajax({
		type: 'POST',
		url: PATH_URL + '/inspectionPlan/updateRevokeReason',
		contentType: "application/json; charset=utf-8",
		data: JSON.stringify({ "yjId": yjId,"insMonth": insMonth,"reason":"" }),
		success: function (data) {
			layer.close(loadingMsg); // 关闭提示层
			if (data.code == 200) {
				parent.layer.msg("撤销成功", {
					icon: 1
				});
				
				
				var index = parent.layer.getFrameIndex(window.name); //先得到当前 iframe层的索引
				parent.layer.close(index); //再执行关闭
			} else {
				layer.alert(data.msg);
			}
		},
		error: function(XMLHttpRequest, textStatus, e) {
			layer.close(loadingMsg);
			layer.msg('数据请求发生异常,请稍后重试', {
				icon: 16,
				scrollbar: false
			});
		}
	})
}



//设置弹窗关闭
function reloading() {
    var index = parent.layer.getFrameIndex(window.name); //先得到当前 iframe层的索引
    parent.layer.close(index); //再执行关闭
    window.parent.location.reload();
}


//字数检测
function wordCount(event){
	var count = $("#revokeReason").val().length;
	$("#wordCount").text(count);
}