initiatedProcess.js 6.5 KB
Newer Older
doc_wei's avatar
doc_wei 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35

var processInstanceId = "";//流程id

var sequenceId = "";//动态表单类型的流程

var rowId = "";//用户提交的表单数据的id

var taskId = "";//任务id

layui.config({
	base: basePath, 
	version: skyeyeVersion
}).extend({
    window: 'js/winui.window'
}).define(['window', 'table', 'jquery', 'winui', 'form', 'laydate'], function (exports) {
	winui.renderColor();
	var $ = layui.$,
		table = layui.table,
		laydate = layui.laydate,
		form = layui.form;
	
	//'申请时间'页面的选取时间段表格
	laydate.render({
		elem: '#createTime', //指定元素
		range: '~'
	});
	
	//申请时间
	var startTime = "", endTime = "";
	
	// 我启动的流程
	table.render({
	    id: 'messageMyStartTable',
	    elem: '#messageMyStartTable',
	    method: 'post',
doc_wei's avatar
doc_wei 已提交
36
	    url: flowableBasePath + 'activitimode013',
doc_wei's avatar
doc_wei 已提交
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
	    where:{startTime: startTime, endTime: endTime, processInstanceId: $("#processInstanceId").val()},
	    even:true,
	    page: true,
		limits: getLimits(),
		limit: getLimit(),
	    cols: [[
	        { title: systemLanguage["com.skyeye.serialNumber"][languageType], type: 'numbers'},
	        { field: 'processInstanceId', title: '流程ID', width: 100 },
	        { field: 'taskType', title: '类型', width: 100 },
	        { field: 'createName', title: '申请人', width: 100},
	        { field: 'createTime', title: '申请时间', align: 'center', width: 140, templet: function(d){
	        	if(!isNull(d.createTime)){
		        	var str = d.createTime.toString();
		        	str = str.substring(0, str.length - 3);
		        	return date('Y-m-d H:i', str);
	        	}else{
	        		return "";
	        	}
	        }},
	        { field: 'name', title: '当前节点', width: 130, templet: function(d){
	        	return '[' + d.name + ']';
	        }},
	        { field: 'agencyName', title: '审批人', width: 120},
	        { field: 'suspended', title: '状态<i id="stateDesc" class="fa fa-question-circle" style="margin-left: 5px"></i>', align: 'center', width: 130, templet: function(d){
	        	if(d.suspended){
	        		return "<span class='state-down'>挂起</span>";
	        	}else{
	        		return "<span class='state-up'>正常</span>";
	        	}
	        }},
	        { field: 'weatherEnd', title: '审批进度', align: 'left', width: 80, templet: function(d){
	        	if(d.weatherEnd == 0){
	        		return "<span class='state-down'>进行中</span>";
	        	}else{
	        		return "<span class='state-up'>已完成</span>";
	        	}
	        }},
	        { title: systemLanguage["com.skyeye.operation"][languageType], fixed: 'right', align: 'center', width: 240, toolbar: '#myStartTableBar'}
	    ]],
	    done: function(){
	    	matchingLanguage();
	    }
	});
	
	table.on('tool(messageMyStartTable)', function (obj) {
        var data = obj.data;
        var layEvent = obj.event;
        if (layEvent === 'edit') { //编辑
        	edit(data);
        } else if (layEvent === 'details') { //详情
			activitiUtil.activitiDetails(data);
        } else if (layEvent === 'revoke') { //撤销
        	revoke(data);
        } else if (layEvent === 'refreshPic') { //刷新流程图
        	refreshPic(data);
        }
    });
	
	//编辑
	function edit(data){
		sequenceId = data.sequenceId;
		taskId = data.id;
		processInstanceId = data.processInstanceId;
		rowId = data.dataId;
		_openNewWindows({
			url: data.pageUrl, 
			title: systemLanguage["com.skyeye.editPageTitle"][languageType],
			pageId: "myactivitiedit",
			area: ['90vw', '90vh'],
			callBack: function(refreshCode){
                if (refreshCode == '0') {
                	winui.window.msg(systemLanguage["com.skyeye.successfulOperation"][languageType], {icon: 1,time: 2000});
                } else if (refreshCode == '-9999') {
                	winui.window.msg(systemLanguage["com.skyeye.operationFailed"][languageType], {icon: 2,time: 2000});
                }
			}
		});
	}

	//撤销
	function revoke(data){
		if(isNull(data.revokeMapping)){//撤销接口为空
			winui.window.msg('撤销接口调用失败', {icon: 2,time: 2000});
			return false;
		}
		layer.confirm('确定撤销该流程吗?', { icon: 3, title: '撤销操作' }, function (index) {
			layer.close(index);
doc_wei's avatar
doc_wei 已提交
124
	        AjaxPostUtil.request({url:reqBasePath + data.revokeMapping, params:{processInstanceId: data.processInstanceId}, type: 'json', callback: function(json){
doc_wei's avatar
doc_wei 已提交
125 126 127 128 129 130 131 132 133 134 135 136 137 138
				if(json.returnCode == 0){
					winui.window.msg("撤销成功", {icon: 1,time: 2000});
					reloadMyStartTable();
				}else{
					winui.window.msg(json.returnMessage, {icon: 2,time: 2000});
				}
			}});
		});
	}
	
	//刷新流程图
	function refreshPic(data){
		layer.confirm('确认重新生成流程图吗?', { icon: 3, title: '刷新流程图操作' }, function (i) {
			layer.close(i);
doc_wei's avatar
doc_wei 已提交
139
            AjaxPostUtil.request({url:flowableBasePath + "activitimode027", params: {processInstanceId: data.processInstanceId}, type: 'json', callback: function(json){
doc_wei's avatar
doc_wei 已提交
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
 	   			if(json.returnCode == 0){
                	winui.window.msg(systemLanguage["com.skyeye.successfulOperation"][languageType], {icon: 1,time: 2000});
 	   			}else{
 	   				winui.window.msg(json.returnMessage, {icon: 2,time: 2000});
 	   			}
 	   		}});
		});
	}
	
    //刷新我启用的流程
	$("body").on("click", "#reloadMyStartTable", function(){
		reloadMyStartTable();
	});
	
	//搜索
	$("body").on("click", "#formSearch", function(){
		searchMyStartTable();
	});
	
    function reloadMyStartTable(){
    	if(!isNull($("#createTime").val())){//一定要记得,当createTime为空时
    		startTime = $("#createTime").val().split('~')[0].trim() + ' 00:00:00';
    		endTime = $("#createTime").val().split('~')[1].trim() + ' 23:59:59';
    	}else{
    		startTime = "";
    		endTime = "";
    	}
    	table.reload("messageMyStartTable", {where:{startTime: startTime, endTime: endTime, processInstanceId: $("#processInstanceId").val()}});
    }
    
    function searchMyStartTable(){
    	if(!isNull($("#createTime").val())){//一定要记得,当createTime为空时
    		startTime = $("#createTime").val().split('~')[0].trim() + ' 00:00:00';
    		endTime = $("#createTime").val().split('~')[1].trim() + ' 23:59:59';
    	}else{
    		startTime = "";
    		endTime = "";
    	}
    	table.reload("messageMyStartTable", {page: {curr: 1}, where:{startTime: startTime, endTime: endTime, processInstanceId: $("#processInstanceId").val()}});
    }
    
    $("body").on("click", "#stateDesc", function() {
		layer.tips('该状态分为挂机和正常,被挂机待办无法进行审批操作', $("#stateDesc"), {
			tips: [1, '#3595CC'],
			time: 4000
		});
	});
    
    exports('initiatedProcess', {});
});