safesite/enp/templates/abnormal.html

146 lines
6.4 KiB
HTML

<div class="easyui-layout" style="width:100%;height:100%;">
<div data-options="region:'center',title:'防治设施异常表',split:true,border:false" style="height:100%;">
<div id="abnormalTableBar">
<a onclick="addabnormal()" class="easyui-linkbutton" data-options="iconCls: 'fa-plus',plain: true">新增</a>
<a onclick="ediabnormal()" class="easyui-linkbutton" data-options="iconCls: 'fa-pencil',plain: true">编辑</a>
<a onclick="delabnormal()" class="easyui-linkbutton" data-options="iconCls: 'fa-trash',plain: true">删除</a>
</div>
<table id="abnormalTable" style="height:100%"></table>
</div>
</div>
<div id="abnormalDialog" class="easyui-dialog" style="width:700px;height:600px;padding:20px 25px;"
data-options="resizable:true,modal:true,closed:true,border:false">
<form method="post" id="abnormalForm">
<input name="id" type="hidden">
<div style="margin-bottom:10px">
<input name="name" data-options="label:'设施异常名称', labelWidth:100" class="easyui-textbox" style="width:300px;" required></input>
<input name="number" data-options="label:'编码', labelWidth:100" class="easyui-textbox" style="width:300px;" required></input>
</div>
<div style="margin-bottom:10px">
<input name="start_time" data-options="label:'异常起始时刻', editable:false, labelWidth:100" class="easyui-datetimespinner" style="width:300px;" ></input>
<input name="end_time" data-options="label:'异常终止时刻', editable:false, labelWidth:100" class="easyui-datetimespinner" style="width:300px;" ></input>
</div>
<div style="margin-bottom:10px">
<input name="type" data-options="label:'污染物种类',labelWidth:100" class="easyui-textbox" style="width:300px;" ></input>
<input name="pfnd" data-options="label:'排放浓度', labelWidth:100" class="easyui-textbox" style="width:300px;" ></input>
</div>
<div style="margin-bottom:10px">
<input name="pffx" data-options="label:'排放方向',labelWidth:100" class="easyui-textbox" style="width:300px;" ></input>
<input name="sjyy" data-options="label:'事件原因', labelWidth:100" class="easyui-textbox" style="width:300px;" ></input>
</div>
<div style="margin-bottom:10px">
<input name="sfbg" data-options="label:'是否报告',labelWidth:100" class="easyui-textbox" style="width:300px;" ></input>
<input name="ydcs" data-options="label:'应对措施', labelWidth:100" class="easyui-textbox" style="width:300px;" ></input>
</div>
<div style="text-align: center;">
<a class="easyui-linkbutton" iconCls="fa-floppy-o" onclick="saveabnormal()">保存</a>
</div>
</form>
</div>
<script>
var abnormal_action_url = '/api/enp/abnormal/create/';
$('#abnormalTable').datagrid({
url: '/api/enp/abnormal/list/',
rownumbers: true,
singleSelect: true,
striped: true,
method: 'get',
toolbar: '#abnormalTableBar',
border: false,
columns: [[
{ field: 'id', title: 'ID', hidden: true },
{ field: 'name', title: '设施异常名称', width: 200 },
{ field: 'number', title: '编码', width: 200 },
{ field: 'start_time', title: '异常起始时刻', width: 200 },
{ field: 'end_time', title: '异常终止时刻', width: 200 },
{ field: 'type', title: '排放浓度', width: 200 },
{ field: 'pfnd', title: '中间产品', width: 200 },
{ field: 'pffx', title: '排放方向', width: 200 },
{ field: 'sjyy', title: '事件原因', width: 200 },
{ field: 'sfbg', title: '是否报告', width: 200 },
{ field: 'ydcs', title: '应对措施', width: 200 },
]],
onClickRow: function (index, row) {
}
});
//新增
function addabnormal() {
$('#abnormalDialog').dialog('open').dialog('setTitle', '新增设施异常名称').window('center');
$('#abnormalForm').form('clear');
abnormal_action_url = '/api/enp/abnormal/create/'
}
//保存数据
function saveabnormal() {
var data = $('#abnormalForm').serializeJSON();
$.ajax({
type: "POST",
url: abnormal_action_url,
data: JSON.stringify(data),
datatype: "json",
processData: false,
contentType: "application/json;charset=utf-8",
beforeSend: function () {
return $('#abnormalForm').form('validate')
},
success: function (data) {
$("#abnormalTable").datagrid('reload');
$("#abnormalDialog").dialog("close");
},
});
}
//编辑数据
function ediabnormal(){
var row = $('#abnormalTable').datagrid('getSelected');
if(row){
$('#abnormalDialog').dialog('open').dialog('setTitle', '编辑设施异常名称').window('center');
$('#abnormalForm').form('load', row);
abnormal_action_url = '/api/enp/abnormal/update/'}
else{
$.messager.alert('提示', '请选择一条数据!');
}
}
//删除数据
function delabnormal(){
var row = $('#abnormalTable').datagrid('getSelected');
if (row) {
$.messager.confirm('提示', '确定删除吗?', function (r) {
if (r) {
var data = { id: row.id }
$.ajax({
type: "POST",
url: '/api/enp/abnormal/delete/',
data: JSON.stringify(data),
datatype: "json",
beforeSend: function () { },
success: function (data) {
if (data.code == 1) {
$("#abnormalTable").datagrid('reload');
$("#abnormalTable").datagrid('reload');
}
else {
$.messager.alert('提示', '操作失败!');
}
},
});
}
});
}
else { $.messager.alert('提示', '请选择一条数据!'); }
}
</script>