inspect detail

This commit is contained in:
caoqianming 2020-08-18 11:28:53 +08:00
parent c463c9ef24
commit 89476bc3ed
6 changed files with 337 additions and 59 deletions

View File

@ -1,61 +1,71 @@
<table id="xjtable" style="width:auto;height:100%;"></table>
<a id="downa" href="" target="_blank" style="display:none"></a>
<div id="xjtablebar" style="padding: 4px">
<div class="easyui-layout" style="width:100%;height: 100%;">
<div data-options="region:'center', spilt:true, border: false">
<table id="xjtable" style="width:auto;height:100%;"></table>
<a id="downa" href="" target="_blank" style="display:none"></a>
<div id="xjtablebar" style="padding: 4px">
<div >
<label>快捷查询</label>
<select id='kjcxxj' style='width:150px'>
<div>
<label>快捷查询</label>
<select id='kjcxxj' style='width:150px'>
<option value="">请选择</option>
<option value="listself">我的巡检</option>
<option value="listall">全部记录</option>
</select>
<a onclick="javascript:$('#sdg_xj').dialog('open')" class="easyui-linkbutton" data-options="iconCls: 'fa-search',plain:true">详细筛选</a>
</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 %}
</div>
<div id="sdg_xj" class="easyui-dialog" title="筛选条件" style="width:400px;height:300px;"
data-options="iconCls:'fa-search',resizable:true,modal:true,closed:true,border:false">
<div class="easyui-layout" style="width:100%;height:100%;">
<div data-options="region:'center'" style="height:100%;text-align:center">
<form id='searchxjff'>
<div style="margin-top:6px"><label>巡检部门</label><input id="sxjbm" name="xjbm" style="width:300px;"
editable=false /></div>
<div style="margin-top:6px"><label>巡检人</label><input id="sxjr" name="xjr" style="width:300px;" class="easyui-combobox"
editable=false /></div>
<div style="margin-top:6px"><label>设备编号</label><input id="num" name="num" style="width:300px;" class="easyui-textbox"
/></div>
<div style="margin-top:6px"><label>起始时间</label><input name='qssj' id='sqssj' style="width:300px"
class="easyui-datebox" editable=false></div>
<div style="margin-top:6px"><label>结束时间</label><input name='jssj' id='sjssj' style="width:300px"
class="easyui-datebox" editable=false></div>
<a onclick="javascript:$('#sdg_xj').dialog('open')" class="easyui-linkbutton"
data-options="iconCls: 'fa-search',plain:true">详细筛选</a>
</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="xjdetail" onclick="xjdetail()" class="easyui-linkbutton" data-options="iconCls: 'fa-info-circle',plain:true">查看详情</a>
</div>
<div id="sdg_xj" class="easyui-dialog" title="筛选条件" style="width:400px;height:300px;"
data-options="iconCls:'fa-search',resizable:true,modal:true,closed:true,border:false">
<div class="easyui-layout" style="width:100%;height:100%;">
<div data-options="region:'center'" style="height:100%;text-align:center">
<form id='searchxjff'>
<div style="margin-top:6px"><label>巡检部门</label><input id="sxjbm" name="xjbm"
style="width:300px;" editable=false /></div>
<div style="margin-top:6px"><label>巡检人</label><input id="sxjr" name="xjr"
style="width:300px;" class="easyui-combobox" editable=false /></div>
<div style="margin-top:6px"><label>设备编号</label><input id="num" name="num"
style="width:300px;" class="easyui-textbox" /></div>
<div style="margin-top:6px"><label>起始时间</label><input name='qssj' id='sqssj'
style="width:300px" class="easyui-datebox" editable=false></div>
<div style="margin-top:6px"><label>结束时间</label><input name='jssj' id='sjssj'
style="width:300px" class="easyui-datebox" editable=false></div>
<div style="margin-top:6px"><label>设备状态</label>
<select name='state' id='sstate' style="width:300px" class="easyui-combobox" editable=false>
<select name='state' id='sstate' style="width:300px" class="easyui-combobox"
editable=false>
<option value="">请选择</option>
<option value="1">正常</option>
<option value="0">异常</option>
</select>
</div>
</form>
</div>
</form>
</div>
<div id='southdiv' data-options="region:'south'" style="height:46px;text-align:center;padding:6px">
<a id="xjsearch" onclick="xjsearch()" class="easyui-linkbutton"
data-options="iconCls: 'fa-search'">查询</a>
</div>
</div>
</div>
<div id='southdiv' data-options="region:'south'" style="height:46px;text-align:center;padding:6px">
<a id="xjsearch" onclick="xjsearch()" class="easyui-linkbutton" data-options="iconCls: 'fa-search'">查询</a>
</div>
</div>
</div>
</div>
<script>
$(function(){
$(function () {
var option = $('#main').attr('value')
$('#xjtable').datagrid({url:'api/inspect',queryParams:{a:option}});
$('#xjtable').datagrid({ url: 'api/inspect', queryParams: { a: option } });
$("#searchxjff").form('clear');
})
$("#sxjbm").combotree({
@ -71,15 +81,15 @@
}
return s;
},
onSelect: function (node) {
onSelect: function (node) {
$('#sxjr').combobox({ url: 'getuser?partid=' + node.id + '&a=combobox', })
}
});
$('#kjcxxj').combobox({
editable:false,
editable: false,
onSelect: function (node) {
if(node.value != 0){
$('#xjtable').datagrid({url:'api/inspect',queryParams:{a:node.value}});
if (node.value != 0) {
$('#xjtable').datagrid({ url: 'api/inspect', queryParams: { a: node.value } });
}
}
});
@ -87,7 +97,7 @@
var querydata = $('#searchxjff').serializeJSON();
querydata['a'] = 'listsearch'
$("#sdg_xj").dialog("close");
$('#xjtable').datagrid('load',querydata);
$('#xjtable').datagrid('load', querydata);
}
$('#xjtable').datagrid({
url: '',
@ -99,7 +109,7 @@
pagination: 'true',
pageSize: 20,
toolbar: '#xjtablebar',
border:false,
border: false,
columns: [[
{ field: 'id', title: 'ID', hidden: true },
{ field: 'user__ubelongpart__partname', title: '巡检部门', width: 100 },
@ -130,7 +140,7 @@
// case 7: return 'background-color:yellow;'; break;
// }
// if(row.zgqx){
// }
// }, formatter: function (value, row, index) {
// switch (value) {
@ -151,35 +161,43 @@
// }
// }},
{ field: 'creattime', title: '提交时间', width: 100 },
]]
});
function xjdetail(){
function xjdetail() {
var row = $('#xjtable').datagrid('getSelected');
if (row) {
var url = 'misshtml/detail/' + row.missid
opendg('查看详情',url)
opendg('查看详情', url)
}
else { $.messager.alert('提示', '请选择一行数据!'); }
}
function exportxjexcel() {
var querydata = $('#searchxjff').serializeJSON();
console.log(querydata)
let url = 'api/inspect?a=exportexcel&'+parseParams(querydata)
let url = 'api/inspect?a=exportexcel&' + parseParams(querydata)
$('<form method="post" action="' + url + '"></form>').appendTo('body').submit().remove();
}
function delxj(){
function delxj() {
var row = $('#xjtable').datagrid('getSelected');
if (row) {
var url = 'api/inspect?a=del&id=' + row.id
$.get(url,function(res){
if(res.code==1){
$.get(url, function (res) {
if (res.code == 1) {
$('#xjtable').datagrid('reload')
}else{
} else {
$.messager.alert('提示', '没有权限!');
}
})
}
else { $.messager.alert('提示', '请选择一行数据!'); }
else { $.messager.alert('提示', '请选择一行数据!'); }
}
function xjdetail(){
var row = $('#xjtable').datagrid('getSelected');
if (row) {
var url = 'html/inspect/detail/' + row.id
opendg('查看详情',url)
}
else { $.messager.alert('提示', '请选择一行数据!'); }
}
</script>

View File

@ -0,0 +1,138 @@
<div class="easyui-layout" id="result" style="width:100%;height:100%"></div>
<script type="text/html" id="text">
{% verbatim %}
<div data-options="region:'south'" id='southdiv' style="height:50px;text-align:center;padding:5px">
<!-- <a id="exportword" onclick="exportword()" class="easyui-linkbutton" data-options="iconCls: 'fa-download'">导出</a> -->
<a iconCls="fa-close" class="easyui-linkbutton" onclick="closeForm()">关闭</a>
</div>
<div data-options="region:'center'" style="height:100%;padding:15px 15px;">
<div class="labeldiv">巡检概况</div>
<table class='detailtable'>
<tr>
<td>巡检类型:{{type__dickeyname}}</td>
<td>创建时间:{{creattime| dateFormat 'yyyy-MM-dd hh:mm'}}</td>
</tr>
<tr>
<td style="width:50%">所属部门:{{user__ubelongpart__partname}}</td>
<td>巡检人:{{user__name}}</td>
</tr>
<tr>
<td>设备:{{equipment__num + '-' + equipment__name}}</td>
<td>所在区域:{{equipment__area__name}}</td>
</tr>
<tr>
<td colspan="2">设备状态:
{{if state==1}}
<span style="color:green">正常</span>
{{else}}
<span style="color:red">异常</span>
{{/if}}
</td>
</tr>
</table>
<table class='detailtable'>
<tr>
{{each lookimg value index}}
<td><img onclick='bigger(this)' class='tp' width="180" height="180" src='{{value}}' /></td>
{{/each}}
</tr>
</table>
<div class="labeldiv">具体记录</div>
<table class='detailtable'>
<thead>
<tr>
<th style="width:20%">
检查项目
</th>
<th style="width:40%">
具体内容
</th>
<th style="width:40%">
结论
</th>
</tr>
</thead>
{{each items}}
<tr>
<td>{{$value.checkitem__name}}</td>
<td>{{$value.checkitem__content}}</td>
<td>{{$value.state}}</td>
</tr>
{{/each}}
</table>
</div>
{% endverbatim %}
</script>
<script type="text/javascript" src="/static/safesite/mystatic/js/template-web.js"></script>
<script>
var html;
var formid = {{ id }};
var formdata
template.defaults.imports.dateFormat = function (date, format) {
date = new Date(date);
var map = {
"M": date.getMonth() + 1, //月份
"d": date.getDate(), //日
"h": date.getHours(), //小时
"m": date.getMinutes(), //分
"s": date.getSeconds(), //秒
"q": Math.floor((date.getMonth() + 3) / 3), //季度
"S": date.getMilliseconds() //毫秒
};
format = format.replace(/([yMdhmsqS])+/g, function (all, t) {
var v = map[t];
if (v !== undefined) {
if (all.length > 1) {
v = '0' + v;
v = v.substr(v.length - 2);
}
return v;
}
else if (t === 'y') {
return (date.getFullYear() + '').substr(4 - all.length);
}
return all;
});
return format;
};
template.defaults.imports.gfilename = function(value){
x = value.split('/').pop();
return x;
}
$.ajax({
type: "get",
url: "api/inspect?a=detail",
data: { id: formid },
async: false, // ajax同步使用false
success: function (data) {
formdata = data
$.ajax({
type: "get",
url: "api/inspectitem?a=listall",
data: { inspect: data.id, pageoff:1 },
async: false, // ajax同步使用false
success: function (data) {
formdata.items = data.rows
html = template('text', formdata);
}
});
}
});
$('#result').html(html);
// function exportword(){
// $.ajax({
// type: "post",
// url: "gchandle?a=exportword",
// contentType:'application/json; charset=utf-8',
// data: JSON.stringify(formdata),
// success: function (data) {
// window.open(data.downloadurl);
// }
// });
// }
</script>

View File

@ -20,6 +20,7 @@
{% 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="xjdetail2" onclick="xjdetail2()" class="easyui-linkbutton" data-options="iconCls: 'fa-info-circle',plain:true">查看详情</a>
</div>
<div id="sdg_xj" class="easyui-dialog" title="筛选条件" style="width:400px;height:300px;"
data-options="iconCls:'fa-search',resizable:true,modal:true,closed:true,border:false">
@ -158,4 +159,12 @@
}
else { $.messager.alert('提示', '请选择一行数据!'); }
}
function xjdetail2(){
var row = $('#xjtable').datagrid('getSelected');
if (row) {
var url = 'html/inspectitem/detail/' + row.id
opendg('查看详情',url)
}
else { $.messager.alert('提示', '请选择一行数据!'); }
}
</script>

View File

@ -0,0 +1,104 @@
<div class="easyui-layout" id="result" style="width:100%;height:100%"></div>
<script type="text/html" id="text">
{% verbatim %}
<div data-options="region:'south'" id='southdiv' style="height:50px;text-align:center;padding:5px">
<!-- <a id="exportword" onclick="exportword()" class="easyui-linkbutton" data-options="iconCls: 'fa-download'">导出</a> -->
<a iconCls="fa-close" class="easyui-linkbutton" onclick="closeForm()">关闭</a>
</div>
<div data-options="region:'center'" style="height:100%;padding:15px 15px;">
<!-- <div class="labeldiv">设备概况</div> -->
<table class='detailtable'>
<tr>
<td>当前状态:{{state}}</td>
<td>设备信息:{{inspect__equipment__num + '-' + inspect__equipment__name}}</td>
</tr>
<tr>
<td style="width:50%">检查项目:{{checkitem__name}}</td>
<td>检查内容:{{checkitem__content}}</td>
</tr>
<tr>
<td>巡检人:{{inspect__user__name}}</td>
<td>处理人:{{todouser__name}}</td>
</tr>
<tr>
<td>巡检信息:{{desc}}</td>
<td>处理信息:{{desc2}}</td>
</tr>
<tr>
<td>
<div>异常图片</div>
{{if img}}
<img onclick='bigger(this)' class='tp' width="250" height="200" src='{{img}}' />
{{/if}}
</td>
<td>
<div>处理图片</div>
{{if img2}}
<img onclick='bigger(this)' class='tp' width="250" height="200" src='{{img2}}' />
{{/if}}
</td>
</tr>
</table>
</div>
{% endverbatim %}
</script>
<script type="text/javascript" src="/static/safesite/mystatic/js/template-web.js"></script>
<script>
var html;
var formid = {{ id }};
var formdata
template.defaults.imports.dateFormat = function (date, format) {
date = new Date(date);
var map = {
"M": date.getMonth() + 1, //月份
"d": date.getDate(), //日
"h": date.getHours(), //小时
"m": date.getMinutes(), //分
"s": date.getSeconds(), //秒
"q": Math.floor((date.getMonth() + 3) / 3), //季度
"S": date.getMilliseconds() //毫秒
};
format = format.replace(/([yMdhmsqS])+/g, function (all, t) {
var v = map[t];
if (v !== undefined) {
if (all.length > 1) {
v = '0' + v;
v = v.substr(v.length - 2);
}
return v;
}
else if (t === 'y') {
return (date.getFullYear() + '').substr(4 - all.length);
}
return all;
});
return format;
};
template.defaults.imports.gfilename = function(value){
x = value.split('/').pop();
return x;
}
$.ajax({
type: "get",
url: "api/inspectitem?a=detail",
data: { id: formid },
async: false, // ajax同步使用false
success: function (data) {
html = template('text', data);
}
});
$('#result').html(html);
// function exportword(){
// $.ajax({
// type: "post",
// url: "gchandle?a=exportword",
// contentType:'application/json; charset=utf-8',
// data: JSON.stringify(formdata),
// success: function (data) {
// window.open(data.downloadurl);
// }
// });
// }
</script>

View File

@ -1,3 +1,4 @@
from safesite.views import inspectitem
from django.urls import path,include
from . import views,viewsdrf
from . import datashowview
@ -78,6 +79,8 @@ urlpatterns = [
path('html/equipment',views.equipment),
path('html/inspectitem',views.inspectitem),
path('html/inspect',views.inspect),
path('html/inspect/detail/<int:id>', views.inspectdetail),
path('html/inspectitem/detail/<int:id>', views.inspectitemdetail),
path('html/risk/<int:kind>/',views.risk),
path('html/riskact/add/<int:kind>/',views.riskactadd),
path('html/riskact/edit/<int:id>/',views.riskactedit),

View File

@ -211,9 +211,15 @@ def risk(req, kind):
def inspect(req):
return render(req, 'inspect.html')
def inspectdetail(req, id):
return render(req, 'inspectdetail.html', {'id':id})
def inspectitem(req):
return render(req, 'inspectitem.html')
def inspectitemdetail(req, id):
return render(req, 'inspectitemdetail.html', {'id':id})
def equipment(req):
return render(req, 'equipment.html')
@ -6891,7 +6897,7 @@ def apiinspectitem(req):
else:
startnum, endnum = fenye(req)
objs = objs.order_by('-id')[startnum:endnum]
objs = objs.values('id', 'state', 'inspect', 'checkitem', 'inspect__equipment__name', 'checkitem__name','checkitem__content','inspect__user__name', 'inspect__creattime', 'inspect__equipment__num', 'inspect__type__dickeyname','todouser__name')
objs = objs.values('id', 'state', 'inspect', 'checkitem', 'inspect__equipment__name', 'checkitem__name','checkitem__content','inspect__user__name', 'inspect__creattime', 'inspect__equipment__num', 'inspect__type__dickeyname','todouser__name', 'desc', 'desc2', 'img', 'img2')
return HttpResponse(transjson(total, objs), content_type="application/json")
elif a == 'detail':
id = req.GET.get('id')