safesite/safesite/templates/equipment.html

463 lines
21 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<div class="easyui-layout" style="width:100%;height:100%;">
<div data-options="region:'west',split:true,border:false" style="width:240px;" title="区域">
<ul id="qytree" data-options="animate:true"></ul>
</div>
<div data-options="region:'center',title:'设备',split:true,border:false" >
<div id="sbbar" style="padding:5px;height:auto">
<div>
{% load myfilter %}
{% if request|has_permission:'b_equipment_add' %}
<a onclick="addsb()" class="easyui-linkbutton" data-options="iconCls:'fa-plus',plain:true">新增设备</a>
<a id="b_equipment_add"></a>
{% endif %}
{% if request|has_permission:'b_equipment_import' %}
<a onclick="javascript:$('#drsbdg').dialog('open').window('center');" class="easyui-linkbutton"
data-options="iconCls:'fa-upload',plain:true">导入设备</a>
{% endif %}
<!-- <a onclick="exportsbexcel" class="easyui-linkbutton"
data-options="iconCls:'fa-download',plain:true">导出</a> -->
{% if request|has_permission:'b_equipment_del' %}
<a id="delsb" onclick="delsb()" class="easyui-linkbutton"
data-options="iconCls:'fa-trash',plain:true">删除</a>
{% endif %}
<a id="bindjcb" onclick="javascript:$('#bindjcbdg').dialog('open')" class="easyui-linkbutton"
data-options="iconCls:'fa-plug',plain:true">批量绑定检查表</a>
<a id="setChecknum" onclick="javascript:$('#setChecknumdg').dialog('open')" class="easyui-linkbutton"
data-options="iconCls:'fa-plug',plain:true">批量设定每班检查次数</a>
<!-- <a id="bindfxd" onclick="bindfxd()" class="easyui-linkbutton"
data-options="iconCls:'fa-plug',plain:true">批量绑定风险点</a> -->
</div>
<div>
<form id='searchsbff'>
<label>类别</label>
<input id="scate" name="cate" editable=false class="easyui-combobox"
data-options="url:'getdickey?dicclass=47&a=combobox'" />
<label>运行状态</label><select name='state' id='sstate' class="easyui-combobox" editable=false>
<option value="">请选择</option>
<option value="1">正常</option>
<option value="0">异常</option>
</select>
<label>设备名称</label><input name='name' id='sname' class="easyui-textbox">
<a id="sbsearch" onclick="sbsearch()" class="easyui-linkbutton"
data-options="iconCls: 'fa-search',plain:true">查询</a>
{% if request|has_permission:'b_equipment_exportxls' %}
<a id="exportsbexcel" onclick="exportsbexcel()" class="easyui-linkbutton"
data-options="iconCls: 'fa-download',plain:true">导出Excel</a>
{% endif %}
{% if request|has_permission:'b_equipment_change' %}
<a id="b_equipment_change"></a>
{% endif %}
</form>
</div>
</div>
<table id="sbtable" style="height:100%;width:100%"></table>
</div>
<div data-options="region:'south',split:true,border:false" style="height:40%;">
<div style="float: left;">
<form id='sbff'>
<input hidden=true name="id" id="sbid"></input>
<table style="margin:10px;">
<tr>
<td><label>设备编号:</label><input id="num" class="easyui-textbox" name="num" required=true /></td>
<td><label>特种设备:</label><input id="istz" type="checkbox" name="istz" value="1" /></td>
<td><label>主设备:</label><input id="iskey" type="checkbox" name="iskey" value="1" /></td>
</tr>
<tr>
<td><label>设备名称:</label><input id="name" class="easyui-textbox" name="name" required=true />
</td>
<td><label>设备类别:</label><input id="cate" class="easyui-combobox" name="cate" required=true
data-options="url:'getdickey?dicclass=47&a=combobox'" editable=false /></td>
<td><label>所属区域:</label><input id="area" class="easyui-combotree" name="area" required=true
editable=false /></td>
</tr>
<tr>
<td><label>规格型号:</label><input id="type" class="easyui-textbox" name="type" /></td>
<td><label>生产厂家:</label><input id="oem" class="easyui-textbox" name="oem" required=true /></td>
<td><label>出厂编号:</label><input id="fnum" class="easyui-textbox" name="fnum" /></td>
</tr>
<tr>
<td><label>出厂日期:</label><input id="fdate" class="easyui-datebox" name="fdate" editable=false />
</td>
<td><label>投用日期:</label><input id="udate" class="easyui-datebox" name="udate" editable=false />
</td>
<td><label>具体位置:</label><input id="place" class="easyui-textbox" name="place" /></td>
</tr>
<tr>
<td><label>责任部门:</label><input id="zrbm" name="zrbm" /></td>
<td><label>责任人员:</label><input id="zrr" class="easyui-combobox" name="zrr" editable=false />
</td>
<td><label>关联风险点</label><a onclick="choosefxd()" class="easyui-linkbutton">选择</a>
<span style="color: blue;" id="fxdspan"></span>
<input type=hidden id="fxdinput" name="riskact">
</td>
</tr>
<tr>
<td colspan="3"><label>技术参数:</label><input id="parameter" class="easyui-textbox"
name="parameter" style="height:80px;width:90%" data-options="multiline:true" /></td>
</tr>
<tr>
<td>
<a id="savesb" onclick="savesb()" class="easyui-linkbutton"
data-options="iconCls: 'fa-save'">保存</a>
</td>
</tr>
</table>
</form>
</div>
<div style="float: left;width:200px;text-align: center;margin-top:10px;">
<div>设备图片</div>
</div>
<div style="float: left;width:200px;text-align: center;margin-top:10px;margin-left:10px">
<div>二维码</div>
<img id="qrimg" width=200 height=200></img>
</div>
</div>
<div id="drsbdg" class="easyui-dialog" title="导入设备" style="width:400px;height:200px;"
data-options="iconCls:'fa-upload',resizable:true,modal:true,closed:true,border:false">
<p style="color:red;margin-left: 10px">请按模板录入后导入</p>
<p style="margin-left: 10px"><a href="/static/safesite/muban/equipment.xlsx" target="_blank">点击下载模板</a></p>
<p style="margin-left: 10px">录入完成后点击下方按钮上传文件</p>
<input type="file" id="drfile" name="" accept=".xls,.xlsx" style="margin-left: 10px" />
</div>
<div id="bindjcbdg" class="easyui-dialog" title="绑定检查表" style="width:400px;height:200px;padding: 10px;"
data-options="resizable:true,modal:true,closed:true,border:false,buttons:'#dlg-buttons'">
<input id="checkform" class="easyui-combobox" data-options="label:'检查表'" required=true style="width:100%"
editable=false></input>
</div>
<div id="setChecknumdg" class="easyui-dialog" title="设定每班检查次数" style="width:400px;height:200px;padding: 10px;"
data-options="resizable:true,modal:true,closed:true,border:false,buttons:'#dlg-buttons2'">
<input id="checknum" class="easyui-numberbox" value="2" data-options="min:1,precision:0,label:'检查次数'" required=true style="width:100%"
></input>
</div>
<div id="dlg-buttons">
<a class="easyui-linkbutton" onclick="savejcb()">保存</a>
<a class="easyui-linkbutton" onclick="javascript:$('#bindjcbdg').dialog('close')">取消</a>
</div>
<div id="dlg-buttons2">
<a class="easyui-linkbutton" onclick="setChecknum()">保存</a>
<a class="easyui-linkbutton" onclick="javascript:$('#setChecknumdg').dialog('close')">取消</a>
</div>
</div>
<script>
$.get('api/equipmentcheckform', function (res) {
let data = res.rows;
$('#checkform').combobox({
data: data,
valueField: 'id',
textField: 'name',
})
})
if ($('#b_equipment_add').length) {
$('#savesb').show()
} else {
$('#savesb').hide()
}
$('#zrbm').combotree({
url: 'parthandle?a=tree', loadFilter: function (rows) { return convert(rows); }, onSelect: function (node) {
$('#zrr').combobox({ url: 'getuser?partid=' + node.id + '&a=combobox', })
}
})
$.get('api/area?a=tree', function (res) {
$('#qytree').tree({
data: res,
animate: true,
loadFilter: function (rows) {
return convert(rows);
},
formatter: function (node) {
var s = node.text;
if (node.children) {
s += '&nbsp;<span style=\'color:blue\'>(' + node.children.length + ')</span>';
}
return s;
},
onSelect: function (row) {
$("#sbtable").datagrid({
url: 'api/equipment?a=listall&area=' + row.id,
});
}
});
$('#area').combotree({ data: res, loadFilter: function (rows) { return convert(rows); }, })
})
$('#sbtable').datagrid({
url: 'api/equipment?a=listall',
rownumbers: true,
fitColumns: true,
striped: true,
method: 'get',
toolbar: '#sbbar',
pagination: 'true',
pageSize: 20,
columns: [[
{ field: 'ck', checkbox: true, },
{ field: 'id', title: 'ID', hidden: true },
{ field: 'num', title: '编号', width: 100 },
{ field: 'cate__dickeyname', title: '类别', width: 80 },
{ field: 'name', title: '名称', width: 100 },
{ field: 'type', title: '规格型号', width: 80 },
{
field: 'istz', title: '特种设备', width: 50, styler: function (value, row, index) {
if (value == 1) {
return 'background-color:green;';
}
}, formatter: function (value, row, index) {
if (value == 1) {
return '是';
}
}
},
{
field: 'iskey', title: '主设备', width: 50, styler: function (value, row, index) {
if (value == 1) {
return 'background-color:green;';
}
}, formatter: function (value, row, index) {
if (value == 1) {
return '是';
}
}
},
{ field: 'oem', title: '生产厂家', width: 100 },
{ field: 'udate', title: '投用日期', width: 80 },
{ field: 'place', title: '所属地点', width: 80 },
{ field: 'area__name', title: '区域', width: 80 },
{
field: 'state', title: '运行状态', width: 50, styler: function (value, row, index) {
if (value == 1) {
return 'background-color:green;color:white';
} else { return 'background-color:red;'; }
}, formatter: function (value, row, index) {
if (value == 1) {
return '正常';
} else { return '异常' }
}
},
{ field: 'checkform__name', title: '检查表', width: 80 },
{ field: 'checknum', title: '每班检查次数', width: 40 },
]],
onSelect: function (index, data) {
if ($('#b_equipment_change').length) {
$('#savesb').show()
} else {
$('#savesb').hide()
}
$('#qrimg').empty()
$.get('api/equipment?a=detail&id=' + data.id, function (res) {
$('#sbid').val(res.id)
$('#parameter').textbox('setValue', res.parameter)
$('#num').textbox('setValue', res.num)
$('#name').textbox('setValue', res.name)
$('#type').textbox('setValue', res.type)
$('#oem').textbox('setValue', res.oem)
$('#fnum').textbox('setValue', res.fnum)
$('#fdate').textbox('setValue', res.fdate)
$('#udate').textbox('setValue', res.udate)
$('#place').textbox('setValue', res.place)
$('#cate').combobox('setValue', res.cate__dickeyid)
$('#area').combotree('setValue', res.area__id)
$('#zrbm').combotree('setValue', res.zrbm__partid)
$('#fxdinput').val(res.riskact__id)
$('#fxdspan').css('color', 'blue')
$('#fxdspan').html(' ' + res.riskact__name)
if (res.riskact__name == undefined) {
$('#fxdspan').css('color', 'red')
$('#fxdspan').html(' 未绑定')
}
$('#zrr').combobox({ url: 'getuser?partid=' + res.zrbm__partid + '&a=combobox', }).combobox('setValue', res.zrr__userid)
if (res.iskey == 1) {
$('#iskey').prop("checked", true);
} else { $('#iskey').prop("checked", false); }
if (res.istz == 1) {
$('#istz').prop("checked", true);
} else { $('#istz').prop("checked", false); }
// $('#qrimg').qrcode({
// "render": "canvas",
// "size": 200,
// "text": 'https://safeyun.ctcshe.com/miniprogram/equipmentdetail?id='+res.id.toString()
// });
$('#qrimg').attr('src', res.qrcode)
})
}
});
//ajax接收的才是js对象
function delsb() {
var row = $('#sbtable').datagrid('getSelections');
let ids = []
for (i = 0; i < row.length; i++) {
ids.push(row[i].id)
}
if (ids.length) {
$.messager.confirm('提示', '确定删除吗?', function (r) {
if (r) {
$.ajax({
type: "POST",
url: 'api/equipment?a=del',
data: JSON.stringify({ ids: ids }),
datatype: "json",
beforeSend: function () { },
contentType: "application/json;charset=utf-8",
success: function (data) {
if (data.code == 1) {
$("#sbtable").datagrid('reload');
} else {
$.messager.alert('提示', '您无权删除!');
}
},
complete: function (XMLHttpRequest, textStatus) {
},
error: function () {
}
});
}
}
);
}
else {
$.messager.alert('提示', '未选择数据!');
}
}
function sbsearch() {
var querydata = $('#searchsbff').serializeJSON();
//let url = 'api/miss?a=exportexcel&'+parseParams(querydata)
$('#sbtable').datagrid('load', querydata);
//$('<form method="post" action="' + url + '"></form>').appendTo('body').submit().remove();
}
function exportsbexcel() {
var querydata = $('#searchsbff').serializeJSON();
let url = 'api/equipment?a=listall&b=exportexcel&' + parseParams(querydata)
$('<form method="post" action="' + url + '"></form>').appendTo('body').submit().remove();
}
function addsb() {
$('#sbff').form('clear')
$('#sbtable').datagrid('clearSelections');
$('#qrimg').attr('src', '')
}
function savesb() {
var data = $('#sbff').serializeJSON();
$.ajax({
type: "POST",
url: 'api/equipment?a=update',
data: JSON.stringify(data),
datatype: "json",
processData: false,
contentType: "application/json;charset=utf-8",
beforeSend: function () {
var bo = $('#sbff').form('validate')
if (bo == false) {
return bo
} else {
$('#savesb').linkbutton('disable');
}
},
success: function (data) {
if (data.code == 1) {
$('#sbtable').datagrid('reload');
} else { $.messager.alert('提示', '失败!'); }
$('#savesb').linkbutton('enable');
},
});
}
document.getElementById('drfile').onchange = function () {
var fileObj = this.files[0];
var url = 'drapi?a=equipment'
var form = new FormData();
form.append("upfile", fileObj); // 文件对象
xhr = new XMLHttpRequest(); // XMLHttpRequest 对象
xhr.open("post", url, true); //post方式url为服务器请求地址true 该参数规定请求是否异步处理。
xhr.send(form)
$('#drsbdg').dialog('close')
loading('导入中。。');
xhr.onload = function (evt) { //服务断接收完文件返回的结果
var data = JSON.parse(evt.target.responseText);
removeLoading();
if (data.code == 1) {
$.messager.alert('提示', data.msg, 'info', function () {
$("#main").panel({ href: 'html/equipment', title: '设备设施' });
});
}
else if (data.code == 2) {
$.messager.alert('提示', data.msg + data.info, 'info', function () {
$("#main").panel({ href: 'html/equipment', title: '用户' });
});
}
else {
$.messager.alert('提示', data.msg);
}
document.getElementById('drfile').value = '';
}; //请求完成
xhr.onerror = function (evt) { $.messager.alert('提示', '失败!文件内容有误'); document.getElementById('drfile').value = ''; }; //请求失败
}
function choosefxd() {
var myh = screen.availHeight * 0.8;
var area = $('#area').combotree('getValue')
opendg('选择风险点', 'html/riskact/chose?area=' + area, myh)
}
function savejcb() {
var row = $('#sbtable').datagrid('getSelections');
let ids = []
for (i = 0; i < row.length; i++) {
ids.push(row[i].id)
}
if (ids.length) {
let form = $('#checkform').combobox('getValue')
let data = { 'ids': ids, 'form': form }
$.ajax({
type: "POST",
url: 'api/equipment?a=bindjcb',
data: JSON.stringify(data),
datatype: "json",
processData: false,
contentType: "application/json;charset=utf-8",
beforeSend: function () {
},
success: function (data) {
$("#sbtable").datagrid('reload');
$('#bindjcbdg').dialog('close')
},
});
} else {
$.messager.alert('提示', '未选择数据');
}
}
function setChecknum() {
var row = $('#sbtable').datagrid('getSelections');
let ids = []
for (i = 0; i < row.length; i++) {
ids.push(row[i].id)
}
if (ids.length) {
let checknum= $('#checknum').numberbox('getValue')
let data = { 'ids': ids, 'checknum': checknum }
$.ajax({
type: "POST",
url: 'api/equipment?a=setchecknum',
data: JSON.stringify(data),
datatype: "json",
processData: false,
contentType: "application/json;charset=utf-8",
beforeSend: function () {
},
success: function (data) {
$("#sbtable").datagrid('reload');
$('#setChecknumdg').dialog('close')
},
});
} else {
$.messager.alert('提示', '未选择数据');
}
}
</script>