safesite/safesite/templates/offence.html

106 lines
4.4 KiB
HTML

<table id="offencetable" style="width:auto;height:100%;"></table>
<a id="downa" href="" target="_blank" style="display:none"></a>
<div id="offencetablebar" style="padding: 4px">
<div >
<form id='searchoffenceff'>
<!-- <label>巡检部门</label><input id="sxjbm" name="xjbm" editable=false /> -->
<label>提交时间</label><input name='qssj' id='sqssj' class="easyui-datebox" editable=false>-<input name='jssj' id='sjssj'
class="easyui-datebox" editable=false>
<a id="offencesearch" onclick="offencesearch()" class="easyui-linkbutton" data-options="iconCls: 'fa-search'">查询</a>
<a id="searchreset" onclick="reset()" class="easyui-linkbutton">重置</a>
</form>
</div>
<div >
<!-- <a id="xjdetail" onclick="xjdetail()" class="easyui-linkbutton" data-options="iconCls: 'fa-info-circle',plain:true">查看详情</a> -->
<!-- {% load myfilter %}
{% if request|has_permission:'b_inspect_exportxls' %}
<a id="exportxjexcel" onclick="exportxjexcel()" class="easyui-linkbutton" data-options="iconCls: 'fa-download',plain:true">导出Excel</a>
{% endif %}
{% if request|has_permission:'b_inspect_del' %}
<a id="delxj" onclick="delxj()" class="easyui-linkbutton" data-options="iconCls: 'fa-trash',plain:true">删除</a>
{% endif %} -->
<a id="deloffence" onclick="deloffence()" class="easyui-linkbutton" data-options="iconCls: 'fa-trash',plain:true">删除</a>
<a id="offencedetail" onclick="offencedetail()" class="easyui-linkbutton" data-options="iconCls: 'fa-info-circle',plain:true">查看详情</a>
</div>
</div>
<script>
$(function(){
$('#offencetable').datagrid({url:'api/offence/',queryParams:{a:'listall'}});
$("#searchoffenceff").form('clear');
})
function offencesearch() {
var querydata = $('#searchoffenceff').serializeJSON();
querydata['a'] = 'listall'
$('#offencetable').datagrid('load',querydata);
}
function reset() {
$('#searchoffenceff').form('clear')
$('#offencetable').datagrid('options').queryParams = {
a:'listall'
}
$('#offencetable').datagrid('load');
}
$('#offencetable').datagrid({
url: '',
rownumbers: true,
singleSelect: true,
striped: true,
fitColumns: true,
method: 'get',
pagination: 'true',
pageSize: 20,
toolbar: '#offencetablebar',
border:false,
columns: [[
{ field: 'id', title: 'ID', hidden: true },
{ field: 'happentime', title: '发现时间', width: 80 },
{ field: 'type', title: '人员类型', width: 100 },
{ field: 'dept', title: '车间', width: 100 },
{ field: 'area__name', title: '区域', width: 80 },
{ field: 'place', title: '地点', width: 100 },
{ field: 'parter', title: '当事人', width: 80 },
{ field: 'description', title: '描述', width: 200 },
{ field: 'reporter__name', title: '举报人', width: 80 },
]]
});
function exportxjexcel() {
var querydata = $('#searchoffenceff').serializeJSON();
console.log(querydata)
let url = 'api/offence?a=exportexcel&'+parseParams(querydata)
$('<form method="post" action="' + url + '"></form>').appendTo('body').submit().remove();
}
function deloffence(){
var row = $('#offencetable').datagrid('getSelected');
if (row) {
var data = {id:row.id}
$.ajax({
type: "POST",
url: 'api/offence/?a=del',
data: JSON.stringify(data),
datatype: "json",
processData: false,
contentType: "application/json;charset=utf-8",
success: function (data) {
if (data.code == 1) {
$('#offencetable').datagrid('reload');
} else { $.messager.alert('提示', '失败!'); }
},
});
}
else { $.messager.alert('提示', '请选择一行数据!'); }
}
function offencedetail(){
var row = $('#offencetable').datagrid('getSelected');
if (row) {
var url = 'html/offence/detail/' + row.id
opendg('查看详情',url)
}
else { $.messager.alert('提示', '请选择一行数据!'); }
}
</script>