safesite/enp/templates/gastestequipment.html

143 lines
5.9 KiB
HTML

<div class="easyui-layout" style="width:100%;height:100%;">
<div data-options="region:'center',split:true,border:false" style="height:100%;">
<div id="waterequipmentTableBar">
<a onclick="addwaterequipment()" class="easyui-linkbutton" data-options="iconCls: 'fa-plus',plain: true">新增</a>
<a onclick="ediwaterequipment()" class="easyui-linkbutton" data-options="iconCls: 'fa-pencil',plain: true">编辑</a>
<a onclick="delwaterequipment()" class="easyui-linkbutton" data-options="iconCls: 'fa-trash',plain: true">删除</a>
</div>
<table id="waterequipmentTable" style="height:100%"></table>
</div>
</div>
<div id="waterequipmentDialog" 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="waterequipmentForm">
<input name="id" type="hidden">
<div style="margin-bottom:10px">
<input name="number" data-options="label:'排放口编号', labelWidth:100" class="easyui-textbox" style="width:600px;" ></input>
</div>
<div style="margin-bottom:10px">
<input name="type" data-options="label:'污染物种类',labelWidth:100" class="easyui-textbox" style="width:600px;" ></input>
</div>
<div style="margin-bottom:10px">
<input name="methods" data-options="label:'监测采样方法及个数',labelWidth:150" class="easyui-textbox" style="width:600px;" ></input>
</div>
<div style="margin-bottom:10px">
<input name="count" data-options="label:'监测次数',labelWidth:100" class="easyui-numberbox" style="width:600px;" ></input>
</div>
<div style="margin-bottom:10px">
<input name="identification" data-options="label:'鉴定方法',labelWidth:100" class="easyui-textbox" style="width:600px;" ></input>
</div>
<div style="margin-bottom:10px">
<input name="jcyqmodel" data-options="label:'监测仪器型号', labelWidth:100" class="easyui-textbox" style="width:600px;" ></input>
</div>
<div style="margin-bottom:10px">
<input name="note" data-options="label:'备注', labelWidth:100" class="easyui-textbox" style="width:600px;" ></input>
</div>
<div style="text-align: center;">
<a class="easyui-linkbutton" iconCls="fa-floppy-o" onclick="savewaterequipment()">保存</a>
</div>
</form>
</div>
<script>
var waterequipment_action_url = '/api/enp/gastestequipment/create/';
$('#waterequipmentTable').datagrid({
url: '/api/enp/gastestequipment/list/',
rownumbers: true,
singleSelect: true,
striped: true,
method: 'get',
toolbar: '#waterequipmentTableBar',
border: false,
columns: [[
{ field: 'id', title: 'ID', hidden: true },
{ field: 'drain__name', title: '排放口', width: 200 },
{ field: 'contaminant', title: '污染物', width: 200 },
{ field: 'model', title: '仪器型号', width: 200 },
{ field: 'state', title: '设备状态', width: 200 },
{ field: 'remark', title: '备注', width: 200 },
]],
onClickRow: function (index, row) {
}
});
//新增
function addwaterequipment() {
$('#waterequipmentDialog').dialog('open').dialog('setTitle', '新增').window('center');
$('#waterequipmentForm').form('clear');
waterequipment_action_url = '/api/enp/gastestequipment/create/'
}
//保存数据
function savewaterequipment() {
var data = $('#waterequipmentForm').serializeJSON();
$.ajax({
type: "POST",
url: waterequipment_action_url,
data: JSON.stringify(data),
datatype: "json",
processData: false,
contentType: "application/json;charset=utf-8",
beforeSend: function () {
return $('#waterequipmentForm').form('validate')
},
success: function (data) {
$("#waterequipmentTable").datagrid('reload');
$("#waterequipmentDialog").dialog("close");
},
});
}
//编辑数据
function ediwaterequipment(){
var row = $('#waterequipmentTable').datagrid('getSelected');
if(row){
$('#waterequipmentDialog').dialog('open').dialog('setTitle', '编辑').window('center');
$('#waterequipmentForm').form('load', row);
waterequipment_action_url = '/api/enp/gastestequipment/update/'}
else{
$.messager.alert('提示', '请选择一条数据!');
}
}
//删除数据
function delwaterequipment(){
var row = $('#waterequipmentTable').datagrid('getSelected');
if (row) {
$.messager.confirm('提示', '确定删除吗?', function (r) {
if (r) {
var data = { id: row.id }
$.ajax({
type: "POST",
url: '/api/enp/gastestequipment/delete/',
data: JSON.stringify(data),
datatype: "json",
beforeSend: function () { },
success: function (data) {
if (data.code == 1) {
$("#waterequipmentTable").datagrid('reload');
$("#waterequipmentTable").datagrid('reload');
}
else {
$.messager.alert('提示', '操作失败!');
}
},
});
}
});
}
else { $.messager.alert('提示', '请选择一条数据!'); }
}
</script>