safesite/enp/templates/waste.html

215 lines
9.7 KiB
HTML

<div class="easyui-layout" style="width:100%;height:100%;">
<div data-options="region:'west', title:'一般固废名称', split:true, border:false" style="width: 300px;height:100%;">
<div id="wasteTableBar">
<a onclick="addWaste()" class="easyui-linkbutton" data-options="iconCls: 'fa-plus',plain: true">新增</a>
<a onclick="editWaste()" class="easyui-linkbutton" data-options="iconCls: 'fa-pencil',plain: true">编辑</a>
<a onclick="delWaste()" class="easyui-linkbutton" data-options="iconCls: 'fa-trash',plain: true">删除</a>
</div>
<table id="wasteTable" style="height:100%"></table>
</div>
<div data-options="region:'center',title:'一般固废台账',split:true,border:false" style="height:100%;">
<div id="normalWasteRecordTableBar">
<a onclick="addNormalWasteRecord()" class="easyui-linkbutton"
data-options="iconCls: 'fa-plus',plain: true">新增</a>
<a onclick="delNormalWasteRecord()" class="easyui-linkbutton"
data-options="iconCls: 'fa-trash',plain: true">删除</a>
</div>
<table id="normalWasteRecordTable" style="height:100%"></table>
</div>
</div>
<div id="wasteDialog" class="easyui-dialog" style="width:400px;height:200px;padding:5px 15px;"
data-options="resizable:true,modal:true,closed:true,border:false">
<form method="post" id="wasteForm">
<input name="id" type="hidden">
<input name="type" type="hidden" id="typeFormItem">
<div style="margin-bottom:10px">
<input name="number" data-options="label:'废物编号'" class="easyui-textbox" style="width:300px;" required></input>
</div>
<div style="margin-bottom:10px">
<input name="name" data-options="label:'废物名称'" class="easyui-textbox" style="width:300px;"
required></input>
</div>
<div style="text-align: center;">
<a class="easyui-linkbutton" iconCls="fa-floppy-o" onclick="saveWaste()">保存</a>
</div>
</form>
</div>
<div id="normalWasteRecordDialog" class="easyui-dialog" style="width:400px;height:600px;padding:5px 15px;"
data-options="resizable:true,modal:true,closed:true,border:false">
<form method="post" id="normalWasteRecordForm">
<input name="id" type="hidden">
<input name="waste" type="hidden" id="wasteFormItem">
<input name="operator" type="hidden" id="operatorFormItem">
<div style="margin-bottom:10px">
<input name="gen_date" data-options="label:'产生日期', editable:false, labelWidth:100" class="easyui-datebox" style="width:300px;" required ></input>
</div>
<div style="margin-bottom:10px">
<input name="gen_count" data-options="label:'产生数量(吨)', labelWidth:100, min:0,precision:2" class="easyui-numberbox" style="width:300px;" required></input>
</div>
<div style="margin-bottom:10px">
<input name="dis_date" data-options="label:'处置日期', editable:false, labelWidth:100" class="easyui-datebox" style="width:300px;" required ></input>
</div>
<div style="margin-bottom:10px">
<input name="dis_count" data-options="label:'委托处置量(吨)', labelWidth:100, min:0,precision:2" class="easyui-numberbox" style="width:300px;" required></input>
</div>
<div style="margin-bottom:10px">
<input name="inv_count" data-options="label:'库存(吨)', labelWidth:100, min:0,precision:2" class="easyui-numberbox" style="width:300px;" required></input>
</div>
<div style="margin-bottom:10px">
<input name="operator__name" data-options="label:'经办人', labelWidth:100" class="easyui-textbox" style="width:300px;" id="operator__nameFormItem"
required readonly></input>
<a class='easyui-linkbutton' onclick="choseuser('operator')" style="width:auto">选择</a>
</div>
<div style="text-align: center;">
<a class="easyui-linkbutton" iconCls="fa-floppy-o" onclick="saveNormalWasteRecord()">保存</a>
</div>
</form>
</div>
<script>
function aaa(x) {
if (x == "operator") {
$('#operatorFormItem').attr('value', top.$('#in').val());
$('#operator__nameFormItem').textbox('setValue', top.$('#in').attr('show'));
}
}
var waste_action_url = '/api/enp/waste/create/';
var record_action_url = '/api/enp/normalwasterecord/create/';
$('#wasteTable').datagrid({
url: '/api/enp/waste/list/?type=1',
rownumbers: true,
singleSelect: true,
striped: true,
method: 'get',
toolbar: '#wasteTableBar',
border: false,
fitColumns: true,
columns: [[
{ field: 'id', title: 'ID', hidden: true },
{ field: 'number', title: '废物编号', width: 100 },
{ field: 'name', title: '废物名称', width: 100 },
]],
onClickRow: function (index, row) {
$('#normalWasteRecordTable').datagrid({
url: '/api/enp/normalwasterecord/list/?waste=' + row.id
})
}
});
$('#normalWasteRecordTable').datagrid({
url: '/api/enp/normalwasterecord/list/',
rownumbers: true,
singleSelect: true,
striped: true,
method: 'get',
toolbar: '#normalWasteRecordTableBar',
border: false,
fitColumns: true,
columns: [[
{ field: 'id', title: 'ID', hidden: true },
{ field: 'operator', title: 'operator', hidden: true },
{ field: 'waste', title: 'waste', hidden: true },
{ field: 'waste__name', title: '废物名称', width: 100 },
{ field: 'gen_date', title: '产生日期', width: 100 },
{ field: 'gen_count', title: '产生数量(吨)', width: 100 },
{ field: 'dis_date', title: '处置日期', width: 100 },
{ field: 'dis_count', title: '委托处置量(吨)', width: 100 },
{ field: 'inv_count', title: '库存量(吨)', width: 100 },
{ field: 'operator__name', title: '经办人', width: 100 },
]],
onClickRow: function (index, row) {
}
});
function addWaste() {
$('#wasteDialog').dialog('open').dialog('setTitle', '新增一般固废名').window('center');
$('#wasteForm').form('clear');
$('#typeFormItem').attr('value',1);
waste_action_url = '/api/enp/waste/create/'
}
function addNormalWasteRecord() {
var row = $('#wasteTable').datagrid('getSelected');
if(row){
$('#normalWasteRecordDialog').dialog('open').dialog('setTitle', '新增记录').window('center');
$('#normalWasteRecordForm').form('clear');
$('#wasteFormItem').attr('value', row.id);
record_action_url = '/api/enp/normalwasterecord/create/';
}else{
$.messager.alert('提示', '请先选择左侧废物!');
}
}
function editWaste(){
var row = $('#wasteTable').datagrid('getSelected');
if(row){
$('#wasteDialog').dialog('open').dialog('setTitle', '编辑一般固废名').window('center');
$('#wasteForm').form('load', row);
waste_action_url = '/api/enp/waste/update/'}
else{
$.messager.alert('提示', '请选择一条数据!');
}
}
function saveWaste() {
var data = $('#wasteForm').serializeJSON();
$.ajax({
type: "POST",
url: waste_action_url,
data: JSON.stringify(data),
datatype: "json",
processData: false,
contentType: "application/json;charset=utf-8",
beforeSend: function () {
return $('#wasteForm').form('validate')
},
success: function (data) {
$("#wasteTable").datagrid('reload');
$("#wasteDialog").dialog("close");
},
});
}
function saveNormalWasteRecord() {
var data = $('#normalWasteRecordForm').serializeJSON();
$.ajax({
type: "POST",
url: record_action_url,
data: JSON.stringify(data),
datatype: "json",
processData: false,
contentType: "application/json;charset=utf-8",
beforeSend: function () {
return $('#normalWasteRecordForm').form('validate')
},
success: function (data) {
$("#normalWasteRecordTable").datagrid('reload');
$("#normalWasteRecordDialog").dialog("close");
},
});
}
function delWaste() {
var row = $('#wasteTable').datagrid('getSelected');
if (row) {
$.messager.confirm('提示', '确定删除吗?', function (r) {
if (r) {
var data = { id: row.id }
$.ajax({
type: "POST",
url: '/api/enp/waste/delete/',
data: JSON.stringify(data),
datatype: "json",
beforeSend: function () { },
success: function (data) {
if (data.code == 1) {
$("#wasteTable").datagrid('reload');
$("#normalWasteRecordTable").datagrid('reload');
}
else {
$.messager.alert('提示', '操作失败!');
}
},
});
}
});
}
else { $.messager.alert('提示', '请选择一条数据!'); }
}
</script>