initiatedProcess.js 6.6 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
	    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},
W
weizhiqiang 已提交
47
	        { field: 'createTime', title: '申请时间', align: 'center', width: 140, templet: function (d) {
doc_wei's avatar
doc_wei 已提交
48 49 50 51
	        	if(!isNull(d.createTime)){
		        	var str = d.createTime.toString();
		        	str = str.substring(0, str.length - 3);
		        	return date('Y-m-d H:i', str);
doc_wei's avatar
doc_wei 已提交
52
	        	} else {
doc_wei's avatar
doc_wei 已提交
53 54 55
	        		return "";
	        	}
	        }},
W
weizhiqiang 已提交
56
	        { field: 'name', title: '当前节点', width: 130, templet: function (d) {
doc_wei's avatar
doc_wei 已提交
57 58 59
	        	return '[' + d.name + ']';
	        }},
	        { field: 'agencyName', title: '审批人', width: 120},
W
weizhiqiang 已提交
60
	        { field: 'suspended', title: '状态<i id="stateDesc" class="fa fa-question-circle" style="margin-left: 5px"></i>', align: 'center', width: 130, templet: function (d) {
doc_wei's avatar
doc_wei 已提交
61 62
	        	if(d.suspended){
	        		return "<span class='state-down'>挂起</span>";
doc_wei's avatar
doc_wei 已提交
63
	        	} else {
doc_wei's avatar
doc_wei 已提交
64 65 66
	        		return "<span class='state-up'>正常</span>";
	        	}
	        }},
W
weizhiqiang 已提交
67
	        { field: 'weatherEnd', title: '审批进度', align: 'left', width: 80, templet: function (d) {
doc_wei's avatar
doc_wei 已提交
68 69
	        	if(d.weatherEnd == 0){
	        		return "<span class='state-down'>进行中</span>";
doc_wei's avatar
doc_wei 已提交
70
	        	} else {
doc_wei's avatar
doc_wei 已提交
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
	        		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') {
doc_wei's avatar
doc_wei 已提交
108
                	winui.window.msg(systemLanguage["com.skyeye.successfulOperation"][languageType], {icon: 1, time: 2000});
doc_wei's avatar
doc_wei 已提交
109
                } else if (refreshCode == '-9999') {
doc_wei's avatar
doc_wei 已提交
110
                	winui.window.msg(systemLanguage["com.skyeye.operationFailed"][languageType], {icon: 2, time: 2000});
doc_wei's avatar
doc_wei 已提交
111 112 113 114 115 116 117 118
                }
			}
		});
	}

	//撤销
	function revoke(data){
		if(isNull(data.revokeMapping)){//撤销接口为空
doc_wei's avatar
doc_wei 已提交
119
			winui.window.msg('撤销接口调用失败', {icon: 2, time: 2000});
doc_wei's avatar
doc_wei 已提交
120 121 122 123
			return false;
		}
		layer.confirm('确定撤销该流程吗?', { icon: 3, title: '撤销操作' }, function (index) {
			layer.close(index);
W
weizhiqiang 已提交
124
	        AjaxPostUtil.request({url: flowableBasePath + data.revokeMapping, params:{processInstanceId: data.processInstanceId}, type: 'json', method: "PUT", callback: function (json) {
doc_wei's avatar
doc_wei 已提交
125 126
				if (json.returnCode == 0) {
					winui.window.msg("撤销成功", {icon: 1, time: 2000});
doc_wei's avatar
doc_wei 已提交
127
					reloadMyStartTable();
doc_wei's avatar
doc_wei 已提交
128 129
				} else {
					winui.window.msg(json.returnMessage, {icon: 2, time: 2000});
doc_wei's avatar
doc_wei 已提交
130 131 132 133 134 135 136 137 138
				}
			}});
		});
	}
	
	//刷新流程图
	function refreshPic(data){
		layer.confirm('确认重新生成流程图吗?', { icon: 3, title: '刷新流程图操作' }, function (i) {
			layer.close(i);
W
weizhiqiang 已提交
139
            AjaxPostUtil.request({url:flowableBasePath + "activitimode027", params: {processInstanceId: data.processInstanceId}, type: 'json', callback: function (json) {
doc_wei's avatar
doc_wei 已提交
140 141
 	   			if (json.returnCode == 0) {
                	winui.window.msg(systemLanguage["com.skyeye.successfulOperation"][languageType], {icon: 1, time: 2000});
doc_wei's avatar
doc_wei 已提交
142
 	   			} else {
doc_wei's avatar
doc_wei 已提交
143
 	   				winui.window.msg(json.returnMessage, {icon: 2, time: 2000});
doc_wei's avatar
doc_wei 已提交
144 145 146 147 148 149
 	   			}
 	   		}});
		});
	}
	
    //刷新我启用的流程
doc_wei's avatar
doc_wei 已提交
150
	$("body").on("click", "#reloadMyStartTable", function() {
doc_wei's avatar
doc_wei 已提交
151 152 153 154
		reloadMyStartTable();
	});
	
	//搜索
doc_wei's avatar
doc_wei 已提交
155
	$("body").on("click", "#formSearch", function() {
doc_wei's avatar
doc_wei 已提交
156 157 158 159 160 161 162
		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';
doc_wei's avatar
doc_wei 已提交
163
    	} else {
doc_wei's avatar
doc_wei 已提交
164 165 166 167 168 169 170 171 172 173
    		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';
doc_wei's avatar
doc_wei 已提交
174
    	} else {
doc_wei's avatar
doc_wei 已提交
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
    		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', {});
});