完善流程

This commit is contained in:
wenc000 2020-04-02 22:50:09 +08:00
parent 8a31bbfb53
commit 9b025f0f99
8 changed files with 430 additions and 460 deletions

View File

@ -92,6 +92,11 @@ public class CheckServiceImpl extends BaseService implements ICheckService {
processService.setTaskVariableByTaskId(task.getId(), "isReport", null);
processService.setTaskVariableByTaskId(task.getId(), "isLeader", null);
processService.setTaskVariableByTaskId(task.getId(), "lastCheckId", null);
String businessCheckId = task.getBusinessKey().split(":")[1];
updateCheckIsCompleteInfo(null, checkId, 1);
if (!StringUtils.equals(businessCheckId, checkId)) {
updateCheckIsCompleteInfo(null, businessCheckId, 1);
}
} else {
LOG.debug("领导检查处理失败,交由上级领导处理");
processService.setTaskVariableByTaskId(task.getId(), "isLeader", 1);
@ -163,7 +168,7 @@ public class CheckServiceImpl extends BaseService implements ICheckService {
if (isCoordination == 1) {
saveHiddenDangerReport(token, checkVO, checkId, oldCheckId, userId, task, params);
} else {
setLeaderCheck(userId, checkId, oldCheckId, task, params);
setLeaderCheck(token, userId, checkId, oldCheckId, task, params);
}
processService.saveTaskCompleteByTaskId(task.getId(), params);
}
@ -220,11 +225,11 @@ public class CheckServiceImpl extends BaseService implements ICheckService {
*
* @param userId
* @param checkId
* @param newCheckId
* @param oldCheckId
* @param task
* @param params
*/
private void setLeaderCheck(String userId, String checkId, String newCheckId, Task task, Map<String, Object> params) {
private void setLeaderCheck(String token, String userId, String checkId, String oldCheckId, Task task, Map<String, Object> params) {
LOG.debug("1.isCoordination2, 不配合");
String leaderUserId = getLeaderId(userId, 1);
params.put("leader", leaderUserId);
@ -233,6 +238,12 @@ public class CheckServiceImpl extends BaseService implements ICheckService {
processService.setTaskVariableByTaskId(task.getId(), "isReport", null);
LOG.debug("2.标记上一次的检查项");
processService.setTaskVariableByTaskId(task.getId(), "lastCheckId", checkId);
// 业务ID
String businessCheckId = task.getBusinessKey().split(":")[1];
if (oldCheckId != null && !StringUtils.equals(businessCheckId, oldCheckId)) {
LOG.debug("3.标记复查为完成状态");
updateCheckIsCompleteInfo(token, oldCheckId, 1);
}
}
/**

View File

@ -263,4 +263,25 @@ public interface IProcessService {
*/
List<HistoricTaskInstance> listHistoricTaskInstance();
/**
* 激活任务
*
* @param processId
*/
void activeTaskByProcessId(String processId);
/**
* 挂起任务
*
* @param processId
*/
void suspendTaskByProcessId(String processId);
/**
* 删除任务
*
* @param processId
*/
void deleteTaskByProcessId(String processId);
}

View File

@ -234,5 +234,20 @@ public class ProcessServiceImpl implements IProcessService {
return historyService.createHistoricTaskInstanceQuery().list();
}
@Override
public void activeTaskByProcessId(String processId) {
runtimeService.activateProcessInstanceById(processId);
}
@Override
public void suspendTaskByProcessId(String processId) {
runtimeService.suspendProcessInstanceById(processId);
}
@Override
public void deleteTaskByProcessId(String processId) {
runtimeService.deleteProcessInstance(processId, "结束");
}
}

View File

@ -1,294 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<base href="/inspection/">
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
</head>
<body>
<div class="layui-fluid layui-anim layui-anim-fadein">
<div class="layui-row layui-col-space15">
<div class="layui-col-md12">
<div class="layui-card">
<div class="layui-card-body">
<div class="test-table-reload-btn" style="margin-bottom: 10px;">
<div class="layui-inline">
<input type="text" id="keywords" class="layui-input search-item" placeholder="输入关键字">
</div>
<button type="button" id="search" class="layui-btn layui-btn-sm">
<i class="fa fa-lg fa-search"></i> 搜索
</button>
</div>
<table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>
<!-- 表头按钮组 -->
<script type="text/html" id="headerToolBar">
<div class="layui-btn-group">
<button type="button" class="layui-btn layui-btn-sm" lay-event="saveEvent">
<i class="fa fa-lg fa-plus"></i> 新增
</button>
<button type="button" class="layui-btn layui-btn-normal layui-btn-sm" lay-event="updateEvent">
<i class="fa fa-lg fa-edit"></i> 编辑
</button>
<button type="button" class="layui-btn layui-btn-danger layui-btn-sm" lay-event="removeEvent">
<i class="fa fa-lg fa-trash"></i> 删除
</button>
</div>
</script>
</div>
</div>
</div>
</div>
</div>
<script src="assets/layuiadmin/layui/layui.js"></script>
<script>
layui.config({
base: 'assets/layuiadmin/'
}).extend({
index: 'lib/index'
}).use(['index', 'table', 'laydate', 'common'], function() {
var $ = layui.$;
var $win = $(window);
var table = layui.table;
var admin = layui.admin;
var laydate = layui.laydate;
var common = layui.common;
var resizeTimeout = null;
var tableUrl = 'api/check/listpagecheck';
// 初始化表格
function initTable() {
table.render({
elem: '#dataTable',
id: 'dataTable',
url: top.restAjax.path(tableUrl, []),
width: admin.screen() > 1 ? '100%' : '',
height: $win.height() - 90,
limit: 20,
limits: [20, 40, 60, 80, 100, 200],
toolbar: '#headerToolBar',
request: {
pageName: 'page',
limitName: 'rows'
},
cols: [[
{type:'checkbox', fixed: 'left'},
{field:'rowNum', width:80, title: '序号', fixed: 'left', align:'center', templet: '<span>{{d.LAY_INDEX}}</span>'},
{field: 'nameJoinByEnterpriseId', width: 200, title: '企业名称', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'typeDictionaryName', width: 200, title: '类型', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'addressJoinByEnterpriseId', width: 200, title: '详细地址', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'industryDictionaryName', width: 200, title: '管理行业', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'engagedCountJoinByEnterpriseId', width: 100, title: '从业人数', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'riskOperationDictionaryName', width: 200, title: '风险作业', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'masterJoinByEnterpriseId', width: 150, title: '负责人', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'phoneJoinByEnterpriseId', width: 150, title: '联系电话', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'checkType', width: 150, title: '检查类型', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'isCoordination', width: 100, title: '是否配合', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'isComplete', width: 100, title: '是否完成', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
]],
page: true,
parseData: function(data) {
return {
'code': 0,
'msg': '',
'count': data.total,
'data': data.rows
};
}
});
}
// 重载表格
function reloadTable(currentPage) {
table.reload('dataTable', {
url: top.restAjax.path(tableUrl, []),
where: {
keywords: $('#keywords').val(),
},
page: {
curr: currentPage
},
height: $win.height() - 90,
});
}
// 删除
function removeData(ids) {
top.dialog.msg(top.dataMessage.delete, {
time: 0,
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
shade: 0.3,
yes: function (index) {
top.dialog.close(index);
var layIndex;
top.restAjax.delete(top.restAjax.path('api/check/removecheck/{ids}', [ids]), {}, null, function (code, data) {
top.dialog.msg(top.dataMessage.deleteSuccess, {time: 1000});
reloadTable();
}, function (code, data) {
top.dialog.msg(data.msg);
}, function () {
layIndex = top.dialog.msg(top.dataMessage.deleting, {icon: 16, time: 0, shade: 0.3});
}, function () {
top.dialog.close(layIndex);
});
}
});
}
initTable();
// 事件 - 页面变化
$win.on('resize', function() {
clearTimeout(resizeTimeout);
resizeTimeout = setTimeout(function() {
reloadTable();
}, 500);
});
// 事件 - 搜索
$(document).on('click', '#search', function() {
reloadTable(1);
});
// 事件 - 增删改
table.on('toolbar(dataTable)', function(obj) {
var layEvent = obj.event;
var checkStatus = table.checkStatus('dataTable');
var checkDatas = checkStatus.data;
if(layEvent === 'saveEvent') {
layer.open({
type: 2,
title: false,
closeBtn: 0,
area: ['100%', '100%'],
shadeClose: true,
anim: 2,
content: top.restAjax.path('route/check/save-check.html', []),
end: function() {
reloadTable();
}
});
} else if(layEvent === 'updateEvent') {
if(checkDatas.length === 0) {
top.dialog.msg(top.dataMessage.table.selectEdit);
} else if(checkDatas.length > 1) {
top.dialog.msg(top.dataMessage.table.selectOneEdit);
} else {
layer.open({
type: 2,
title: false,
closeBtn: 0,
area: ['100%', '100%'],
shadeClose: true,
anim: 2,
content: top.restAjax.path('route/check/update-check.html?checkId={checkId}', [checkDatas[0].checkId]),
end: function() {
reloadTable();
}
});
}
} else if(layEvent === 'removeEvent') {
if(checkDatas.length === 0) {
top.dialog.msg(top.dataMessage.table.selectDelete);
} else {
var ids = '';
for(var i = 0, item; item = checkDatas[i++];) {
if(i > 1) {
ids += '_';
}
ids += item['checkId'];
}
removeData(ids);
}
}
});
});
</script>
</body>
</html>

View File

@ -281,7 +281,7 @@
area: ['100%', '100%'],
shadeClose: true,
anim: 2,
content: top.restAjax.path('route/check/update-check-mine.html?checkId={checkId}', [data.checkId]),
content: top.restAjax.path('route/check/save-recheck-mine.html?checkId={checkId}', [data.checkId]),
end: function() {
reloadTable();
}

View File

@ -273,13 +273,31 @@
$(document).on('click', '#search', function() {
reloadTable(1);
});
// 执行检查
function inspect(msg, checkId, type) {
top.dialog.confirm(msg, function(index) {
top.dialog.close(index);
var loadLayerIndex;
top.restAjax.post(top.restAjax.path('api/check/saveinspect/{checkId}', [checkId]), {
type: type
}, null, function(code, data) {
reloadTable();
}, function(code, data) {
top.dialog.msg(data.msg);
}, function() {
loadLayerIndex = top.dialog.msg('提交中...', {icon: 16, time: 0, shade: 0.3});
}, function() {
top.dialog.close(loadLayerIndex);
});
});
}
table.on('tool(dataTable)', function(obj) {
var layEvent = obj.event;
var data = obj.data;
if(layEvent === 'handleEvent') {
inspect('确定处理完毕?', data.checkId, 1);
} else if(layEvent === 'leaderEvent') {
inspect('确定上级处理?', data.checkId, 2);
}
});
});

View File

@ -0,0 +1,359 @@
<!doctype html>
<html lang="en">
<head>
<base href="/inspection/">
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
</head>
<body>
<div class="layui-fluid layui-anim layui-anim-fadein">
<div class="layui-card">
<div class="layui-card-header">
<span class="layui-breadcrumb" lay-filter="breadcrumb" style="visibility: visible;">
<a class="close" href="javascript:void(0);">上级列表</a><span lay-separator="">/</span>
<a href="javascript:void(0);"><cite>复查内容</cite></a>
</span>
</div>
<div class="layui-card-body" style="padding: 15px;">
<form class="layui-form layui-form-pane" lay-filter="dataForm">
<div class="layui-form-item">
<label class="layui-form-label">企业</label>
<div class="layui-input-block layui-form">
<input type="hidden" id="enterpriseId" name="enterpriseId" class="layui-input">
<input type="text" id="enterpriseName" name="enterpriseName" lay-verify="required" class="layui-input" placeholder="请选择企业" style="cursor: pointer;">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">是否配合</label>
<div class="layui-input-block">
<select name="isCoordination" lay-verify="required">
<option value="">请选择</option>
<option value="0">不配合</option>
<option value="1">配合</option>
</select>
</div>
</div>
<div class="layui-form-item layui-form-text">
<div class="layui-input-block" id="checkItemTemplateBox"></div>
<script id="checkItemTemplate" type="text/html">
<table class="layui-table">
<thead>
<tr>
<th>检查项</th>
<th>检查结果</th>
</tr>
</thead>
<tbody>
{{# for(var i = 0, item; item = d[i++]; ) { }}
<tr>
<td>{{item.name}}({{item.type == '1' ? '必查': '选查'}})</td>
<td>
<input type="radio" name="hd_checkResult_{{item.checkItemId}}" value="0" title="未检查" lay-filter="checkResultFilter" checked>
<input type="radio" name="hd_checkResult_{{item.checkItemId}}" value="1" title="通过" lay-filter="checkResultFilter">
<input type="radio" name="hd_checkResult_{{item.checkItemId}}" value="2" title="立即整改" lay-filter="checkResultFilter">
<input type="radio" name="hd_checkResult_{{item.checkItemId}}" value="3" title="限期整改" lay-filter="checkResultFilter">
<input type="radio" name="hd_checkResult_{{item.checkItemId}}" value="4" title="不配合" lay-filter="checkResultFilter">
</td>
</tr>
<tr id="hd_immediatelyChangeType_{{item.checkItemId}}_Box" style="display: none;">
<td></td>
<td>
<input type="radio" name="hd_immediatelyChangeType_{{item.checkItemId}}" value="1" title="当场" checked>
<input type="radio" name="hd_immediatelyChangeType_{{item.checkItemId}}" value="2" title="当天">
</td>
</tr>
<tr id="hd_rectificationDays_{{item.checkItemId}}_Box" style="display: none;">
<td></td>
<td>
<input type="radio" name="hd_rectificationDays_{{item.checkItemId}}" value="1" title="1天" checked>
<input type="radio" name="hd_rectificationDays_{{item.checkItemId}}" value="5" title="5天">
<input type="radio" name="hd_rectificationDays_{{item.checkItemId}}" value="15" title="15天">
<input type="radio" name="hd_rectificationDays_{{item.checkItemId}}" value="20" title="20天">
<input type="radio" name="hd_rectificationDays_{{item.checkItemId}}" value="25" title="25天">
<input type="radio" name="hd_rectificationDays_{{item.checkItemId}}" value="30" title="30天">
</td>
</tr>
<tr id="hd_scenePhotos_{{item.checkItemId}}_Box" style="display: none;">
<td></td>
<td>
<input type="hidden" id="hd_scenePhotos_{{item.checkItemId}}" name="hd_scenePhotos_{{item.checkItemId}}"/>
<div id="hd_scenePhotos_{{item.checkItemId}}_ImageBox" style="display: inline-block"></div>
<div class="upload-image-box" style="width: auto; height: auto; padding: 5px;">
<a href="javascript:void(0);" lay-form-button data-explain="厂区大门" data-name="hd_scenePhotos_{{item.checkItemId}}" lay-filter="scenePhotosUploadFiles">
<i class="fa fa-plus-square-o" style="font-size: 70px;"></i>
</a>
</div>
</td>
</tr>
{{# } }}
</tbody>
</table>
</script>
</div>
<div class="layui-form-item layui-layout-admin">
<div class="layui-input-block">
<div class="layui-footer" style="left: 0;">
<button type="button" class="layui-btn" lay-submit lay-filter="submitForm">提交新增</button>
<button type="button" class="layui-btn layui-btn-primary close">返回上级</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
<script src="assets/layuiadmin/layui/layui.js"></script>
<script>
layui.config({
base: 'assets/layuiadmin/' //静态资源所在路径
}).extend({
index: 'lib/index' //主入口模块
}).use(['index', 'form', 'laydate', 'laytpl'], function(){
var $ = layui.$;
var form = layui.form;
var laytpl = layui.laytpl;
var laydate = layui.laydate;
var checkId = top.restAjax.params(window.location.href).checkId;
function closeBox() {
parent.layer.close(parent.layer.getFrameIndex(window.name));
}
/**
* 初始化检查项
*
* @param data
*/
function initReCheckItem(checkId) {
top.restAjax.get(top.restAjax.path('api/check/listcheckitemunpassbycheckid/{checkId}', [checkId]), {}, null, function(code, data) {
laytpl(document.getElementById("checkItemTemplate").innerHTML).render(data, function(html) {
document.getElementById("checkItemTemplateBox").innerHTML = html;
});
form.render('radio');
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
// 初始化内容
function initData() {
var loadLayerIndex;
top.restAjax.get(top.restAjax.path('api/check/getcheckbyid/{checkId}', [checkId]), {}, null, function(code, data) {
var dataFormData = {
enterpriseId: data.enterpriseId,
enterpriseName: data.nameJoinByEnterpriseId,
};
form.val('dataForm', dataFormData);
form.render(null, 'dataForm');
initReCheckItem(data.checkId);
}, function(code, data) {
top.dialog.msg(data.msg);
}, function() {
loadLayerIndex = top.dialog.msg(top.dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
}, function() {
top.dialog.close(loadLayerIndex);
});
}
initData();
// 提交表单
form.on('submit(submitForm)', function(formData) {
var field = formData.field;
// 获取隐患项列表
var hdFieldArray = [];
for(var i in field) {
if(i.indexOf('hd_') > -1) {
hdFieldArray.push({
k: i,
v: field[i]
});
delete field[i];
}
}
// 筛选隐藏项
var hiddenDangerReports = [];
var temp;
for(var i = 0, item; item = hdFieldArray[i]; i++) {
var hiddenDangerReportArray = item.k.split('_');
var checkItemId = hiddenDangerReportArray[2];
var removeItemCount = 0;
var hiddenDangerReport = {
checkItemId: checkItemId
};
for(var j = 0, checkItem; checkItem = hdFieldArray[j]; j++) {
var checkItemKey = checkItem.k;
if(checkItemKey.indexOf(checkItemId) > -1) {
if(checkItemKey.indexOf('checkResult') > -1) {
hiddenDangerReport.checkResult = checkItem.v;
hdFieldArray.splice(j, 1);
j--;
removeItemCount++;
} else if(checkItemKey.indexOf('immediatelyChangeType') > -1) {
hiddenDangerReport.immediatelyChangeType = checkItem.v;
hdFieldArray.splice(j, 1);
j--;
removeItemCount++;
} else if(checkItemKey.indexOf('rectificationDays') > -1) {
hiddenDangerReport.rectificationDays = checkItem.v;
hdFieldArray.splice(j, 1);
j--;
removeItemCount++;
} else if(checkItemKey.indexOf('scenePhotos') > -1) {
hiddenDangerReport.scenePhotos = checkItem.v;
hdFieldArray.splice(j, 1);
j--;
removeItemCount++;
}
}
}
hiddenDangerReports.push(hiddenDangerReport);
if(removeItemCount > 0) {
i--;
}
}
field.hiddenDangerReports = hiddenDangerReports;
top.dialog.confirm(top.dataMessage.commit, function(index) {
top.dialog.close(index);
var loadLayerIndex;
top.restAjax.post(top.restAjax.path('api/check/saverecheck/{checkId}', [checkId]), formData.field, null, function(code, data) {
var layerIndex = top.dialog.msg('提交成功', {
time: 0,
btn: [top.dataMessage.button.yes],
shade: 0.3,
yes: function(index) {
top.dialog.close(index);
closeBox();
},
});
}, function(code, data) {
top.dialog.msg(data.msg);
}, function() {
loadLayerIndex = top.dialog.msg(top.dataMessage.committing, {icon: 16, time: 0, shade: 0.3});
}, function() {
top.dialog.close(loadLayerIndex);
});
});
return false;
});
$('.close').on('click', function() {
closeBox();
});
// 校验
form.verify({
});
form.on('radio(checkResultFilter)', function(data) {
var name = data.elem.name;
var checkItemId = name.split('_')[2];
if(data.value == 2) {
$('#hd_immediatelyChangeType_'+ checkItemId +'_Box').show();
$('#hd_rectificationDays_'+ checkItemId +'_Box').hide();
} else if(data.value == 3) {
$('#hd_rectificationDays_'+ checkItemId +'_Box').show();
$('#hd_immediatelyChangeType_'+ checkItemId +'_Box').hide();
} else {
$('#hd_rectificationDays_'+ checkItemId +'_Box').hide();
$('#hd_immediatelyChangeType_'+ checkItemId +'_Box').hide();
}
if(data.value != 0) {
$('#hd_scenePhotos_'+ checkItemId +'_Box').show();
} else {
$('#hd_scenePhotos_'+ checkItemId +'_Box').hide();
}
form.render('radio');
});
function refreshDownloadTemplet(fileName, file) {
var dataRander = {};
dataRander[fileName] = file;
var photos = '';
for(var i = 0, item; item = file[i++];) {
photos += '<div class="upload-image-box">'+
'<span class="upload-image-span">'+
'<img src="route/file/downloadfile/false/'+ item.fileId +'" align="加载失败">'+
'</span>'+
'<a class="layui-btn layui-btn-xs layui-btn-danger text-danger remove-image" href="javascript:void(0);" lay-form-button data-id="'+ item.fileId +'" data-name="'+ fileName +'" lay-filter="scenePhotosRemoveFile">'+
'<i class="fa fa-trash-o"></i>'+
'</a>'+
'</div>';
}
$('#'+ fileName +'_ImageBox').empty();
$('#'+ fileName +'_ImageBox').append(photos);
}
// 初始化文件列表
function initFileList(fileName, ids, callback) {
var dataForm = {};
dataForm[fileName] = ids;
form.val('dataForm', dataForm);
if(!ids) {
refreshDownloadTemplet(fileName, []);
if(callback) {
callback(fileName, []);
}
return;
}
top.restAjax.get(top.restAjax.path('api/file/listfilebyfileid', []), {
ids: ids
}, null, function(code, data) {
refreshDownloadTemplet(fileName, data);
if(callback) {
callback(fileName, data);
}
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
// 上传图片
form.on('button(scenePhotosUploadFiles)', function(obj) {
var name = this.dataset.name;
var explain = this.dataset.explain;
top.dialog.file({
type: 'image',
title: '上传'+ explain,
width: '400px',
height: '420px',
maxFileCount: '1',
onClose: function() {
var uploadFileArray = top.dialog.dialogData.uploadFileArray;
if(typeof(uploadFileArray) != 'undefined' && uploadFileArray.length > 0) {
var files = $('#'+ name).val();
for(var j = 0, file = uploadFileArray[j]; file = uploadFileArray[j++];) {
if(files.length > 0) {
files += ',';
}
files += file.data;
}
initFileList(name, files, function(fileName) {});
}
}
});
});
form.on('button(scenePhotosRemoveFile)', function(obj) {
var name = this.dataset.name;
var id = this.dataset.id;
var files = $('#'+ name).val().replace(id, '');
files = files.replace(/\,+/g, ',');
if(files.charAt(0) == ',') {
files = files.substring(1);
}
if(files.charAt(files.length - 1) == ',') {
files = files.substring(0, files.length - 2);
}
initFileList(name, files, function(fileName) {});
});
});
</script>
</body>
</html>

View File

@ -1,160 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<base href="/inspection/">
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
</head>
<body>
<div class="layui-fluid layui-anim layui-anim-fadein">
<div class="layui-card">
<div class="layui-card-header">
<span class="layui-breadcrumb" lay-filter="breadcrumb" style="visibility: visible;">
<a class="close" href="javascript:void(0);">上级列表</a><span lay-separator="">/</span>
<a href="javascript:void(0);"><cite>编辑内容</cite></a>
</span>
</div>
<div class="layui-card-body" style="padding: 15px;">
<form class="layui-form layui-form-pane" lay-filter="dataForm">
<div class="layui-form-item">
<label class="layui-form-label">企业ID</label>
<div class="layui-input-block layui-form" id="enterpriseIdJoinTemplateBox" lay-filter="enterpriseIdJoinTemplateBox"></div>
<script id="enterpriseIdJoinTemplate" type="text/html">
<select name="enterpriseId">
<option value="">选择企业ID</option>
{{# for(var i = 0, item; item = d[i++];) { }}
<option value="{{item.enterpriseId}}">{{item.name}}</option>
{{# } }}
</select>
</script>
</div>
<div class="layui-form-item">
<label class="layui-form-label">检查类型</label>
<div class="layui-input-block">
<select name="checkType" required>
<option value="">请选择检查类型</option>
<option value="1">检查</option>
<option value="2">复查</option>
</select>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">是否配合</label>
<div class="layui-input-block">
<input type="radio" name="isCoordination" value="0" title="否">
<input type="radio" name="isCoordination" value="1" title="是">
</div>
</div>
<div class="layui-form-item layui-layout-admin">
<div class="layui-input-block">
<div class="layui-footer" style="left: 0;">
<button type="button" class="layui-btn" lay-submit lay-filter="submitForm">提交编辑</button>
<button type="button" class="layui-btn layui-btn-primary close">返回上级</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
<script src="assets/layuiadmin/layui/layui.js"></script>
<script>
layui.config({
base: 'assets/layuiadmin/' //静态资源所在路径
}).extend({
index: 'lib/index' //主入口模块
}).use(['index', 'form', 'laydate', 'laytpl'], function(){
var $ = layui.$;
var form = layui.form;
var laytpl = layui.laytpl;
var laydate = layui.laydate;
var checkId = top.restAjax.params(window.location.href).checkId;
function closeBox() {
parent.layer.close(parent.layer.getFrameIndex(window.name));
}
// 初始化企业ID联表
function initEnterpriseIdJoinTable(joinValue){
top.restAjax.get(top.restAjax.path('api/enterprise/listenterprise', []), {}, null, function(code, data) {
laytpl(document.getElementById('enterpriseIdJoinTemplate').innerHTML).render(data, function(html) {
document.getElementById('enterpriseIdJoinTemplateBox').innerHTML = html;
});
form.render('select', 'enterpriseIdJoinTemplateBox');
// 初始化选择
var formSelectData = {};
formSelectData['enterprise'] = joinValue;
form.val('dataForm', formSelectData);
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
// 初始化内容
function initData() {
var loadLayerIndex;
top.restAjax.get(top.restAjax.path('api/check/getcheckbyid/{checkId}', [checkId]), {}, null, function(code, data) {
var dataFormData = {};
for(var i in data) {
dataFormData[i] = data[i];
}
form.val('dataForm', dataFormData);
form.render(null, 'dataForm');
initEnterpriseIdJoinTable(data['enterpriseId']);
}, function(code, data) {
top.dialog.msg(data.msg);
}, function() {
loadLayerIndex = top.dialog.msg(top.dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
}, function() {
top.dialog.close(loadLayerIndex);
});
}
initData();
// 提交表单
form.on('submit(submitForm)', function(formData) {
top.dialog.confirm(top.dataMessage.commit, function(index) {
top.dialog.close(index);
var loadLayerIndex;
top.restAjax.put(top.restAjax.path('api/check/updatecheck/{checkId}', [checkId]), formData.field, null, function(code, data) {
var layerIndex = top.dialog.msg(top.dataMessage.updateSuccess, {
time: 0,
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
shade: 0.3,
yes: function(index) {
top.dialog.close(index);
window.location.reload();
},
btn2: function() {
closeBox();
}
});
}, function(code, data) {
top.dialog.msg(data.msg);
}, function() {
loadLayerIndex = top.dialog.msg(top.dataMessage.committing, {icon: 16, time: 0, shade: 0.3});
}, function() {
top.dialog.close(loadLayerIndex);
});
});
return false;
});
$('.close').on('click', function() {
closeBox();
});
// 校验
form.verify({
});
});
</script>
</body>
</html>