<!DOCTYPE html>
|
<html>
|
<head>
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
<title>设备履历查询</title>
|
<meta name="renderer" content="webkit">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
<link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
|
<link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all">
|
<script src="../../../layuiadmin/layui/layui.js"></script>
|
<script src="../../../layuiadmin/layui/layui1.js"></script>
|
<script src="../../../layuiadmin/PubCustom.js"></script>
|
<script src="../../../layuiadmin/Scripts/json2.js"></script>
|
<script src="../../../layuiadmin/Scripts/jquery-1.4.1.js"></script>
|
<script src="../../../layuiadmin/Scripts/webConfig.js"></script>
|
<script src="../../../layuiadmin/layui/lay/modules/table.js"></script>
|
<style>
|
/*树状图点击高亮变色*/
|
.layui-tree-set-active > .layui-tree-entry .layui-tree-main {
|
background: #aef0f7;
|
}
|
|
.my-btn-container {
|
min-width: 380px; /* 设置最小宽度 */
|
/* 其他需要的样式 */
|
}
|
</style>
|
</head>
|
<body>
|
<div class="layui-fluid">
|
<div class="layui-col-md12">
|
<div class="layui-card" style="padding: 1px">
|
<div class="layui-card-body" style="padding: 1px;">
|
<form class="layui-form" action="" lay-filter="component-form-group">
|
<div class="layui-row" style="padding:0px 0">
|
<div class="layui-col-xs2 layui-inline" style="">
|
<div id="TreeTable" class="demo-tree demo-tree-box" style=""></div>
|
</div>
|
<div class="layui-col-xs3 layui-inline" style="padding-left: 10px;">
|
<div class="layui-collapse">
|
<div class="layui-colla-item">
|
<div class="layui-inline">
|
<label class="layui-form-label">设备编码</label>
|
<div class="layui-input-block">
|
<input type="text" class="layui-input" name="HNumber" id="HNumber">
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label">设备名称</label>
|
<div class="layui-input-block">
|
<input type="text" class="layui-input" name="HName" id="HName">
|
</div>
|
</div>
|
<button class="layui-btn layuiadmin-btn-order" type="button" lay-submit="" lay-filter="btnSearch" id="btnSearch" style="margin-top:-45px;">
|
<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
|
</button>
|
<button class="layui-btn layuiadmin-btn-order" type="button" lay-submit="" lay-filter="btnReSearch" id="btnReSearch" style="padding: 0 5px;margin-top:-45px;">重置</button>
|
|
</div>
|
</div>
|
<div>
|
<table class="" id="mainTable" lay-filter="mainTable"></table>
|
</div>
|
</div>
|
<div class="layui-col-xs7 layui-inline">
|
<table class="" id="mainTableResume" lay-filter="mainTableResume"></table>
|
</div>
|
</div>
|
<script type="text/html" id="toolbarDemo" >
|
<div class="layui-btn-container my-btn-container">
|
<button type="button" class="layui-btn layui-btn-sm" lay-event="get_Refresh"><i class="layui-icon layui-icon-refresh-3"></i>刷新</button>
|
<button type="button" class="layui-btn layui-btn-sm" lay-event="get_Exit"><i class="layui-icon layui-icon-logout"></i>退出</button>
|
<button type="button" class="layui-btn layui-btn-sm" lay-event="get_Search"><i class="layui-icon layui-icon-search"></i>查询履历</button>
|
</div>
|
</script>
|
</form>
|
</div>
|
</div>
|
</div>
|
</div>
|
<script>
|
layui.config({
|
base: '../../../layuiadmin/' //静态资源所在路径
|
}).extend({
|
index: 'lib/index', //主入口模块
|
}).use(['index', 'form', 'table', 'element', 'laypage', 'laydate', 'soulTable', 'tree'], function () {
|
//#region 公共变量
|
var $ = layui.$
|
, admin = layui.admin
|
, layer = layui.layer
|
, table = layui.table
|
, form = layui.form
|
, element = layui.element
|
, laypage = layui.laypage
|
, laydate = layui.laydate
|
, soulTable = layui.soulTable
|
, tree = layui.tree
|
var sWhere = "";
|
var HNumber = "";
|
var HName = "";
|
var option = [];
|
var optionResume = [];
|
var titleData = ["HInterID", "HBillType"];
|
var treeId;
|
//获取参数
|
var params = getUrlVars();
|
var OperationType = params[params[0]]; //从参数中获取 数据类型 1添加 保存 2复制 3 编辑
|
var linterid = params[params[1]]; //从参数中获取 单据内码
|
HNumber = params[params[2]]; //从参数中获取
|
HName = params[params[3]]; //从参数中获取
|
HNumber = decodeURI(HNumber);
|
HName = decodeURI(HName);
|
//#endregion
|
|
//#region 进入页面即加载
|
//初始化表格
|
set_ClearBill();
|
//#endregion
|
|
//#region 页面按钮点检事件触发
|
table.on('toolbar(mainTable)', function (obj) {
|
switch (obj.event) {
|
//刷新
|
case 'get_Refresh': get_Refresh();
|
break;
|
//退出按钮
|
case 'get_Exit': get_Exit();
|
break;
|
//退出按钮
|
case 'get_Search': get_DisplayResume();
|
break;
|
};
|
});
|
//查询按钮
|
form.on('submit(btnSearch)', function (data) {
|
get_FastQuery();
|
});
|
|
//重置按钮
|
form.on('submit(btnReSearch)', function (data) {
|
get_Refresh();
|
$(".layui-tree-set").removeClass('layui-tree-set-active');
|
treeId = "0";
|
});
|
|
//#region 双击返回数据
|
table.on('rowDouble(mainTable)', function (obj) {
|
var data = [];
|
data.push(obj.data);
|
parent.GetEquipFileValue(data);
|
var index = parent.layer.getFrameIndex(window.name);
|
parent.layer.close(index);
|
});
|
//#endregion
|
|
//设备编号回车方法
|
$('#HNumber').on('keydown', function (event) {
|
if (event.keyCode == 13) {
|
get_FastQuery();
|
}
|
});
|
//设备名称回车方法
|
$('#HName').on('keydown', function (event) {
|
if (event.keyCode == 13) {
|
get_FastQuery();
|
}
|
});
|
|
//#endregion
|
|
//初始化表格
|
function set_ClearBill() {
|
//初始化表格
|
set_InitGrid();
|
if (OperationType == 3) {
|
$("#HNumber").val(HNumber);
|
$("#HName").val(HName);
|
get_FastQuery();
|
get_DisplayResume(linterid)
|
} else {
|
//查询
|
get_Display(sWhere);
|
}
|
//查询设备分类
|
get_Display_Tree();
|
}
|
|
//初始化表格
|
function set_InitGrid()
|
{
|
option = {
|
elem: '#mainTable'
|
, toolbar: '#toolbarDemo'
|
, height: 'full-50'
|
, page: true
|
, totalRow: true
|
, limits: [50, 500, 5000, 20000]
|
, limit: 50 //每页默认显示的数量
|
, cellMinWidth: 200
|
, done: function (res, curr, count) {
|
soulTable.render(this);
|
}
|
, cols: [[
|
{ type: 'checkbox', fixed: 'left', totalRowText: '合计行' }
|
, { field: 'hmainid', title: 'hmainid', sort: true, hide: true }
|
, { field: '日期', title: '日期', templet: "<div>{{d.日期 ==null ?'':layui.util.toDateString(d.日期, 'yyyy-MM-dd')}}</div>", sort: true ,width:120}
|
, { field: '设备编码', title: '设备编码', sort: true, width: 120 }
|
, { field: '设备名称', title: '设备名称', sort: true, width: 120 }
|
, { field: '设备规格', title: '设备规格', sort: true }
|
, { field: '设备型号', title: '设备型号', sort: true }
|
, { field: '条形码', title: '条码编号', sort: true }
|
, { field: 'HMaterID', title: 'HMaterID', hide: true, sort: true }
|
, { field: '物料名称', title: '物料名称', sort: true }
|
, { field: '设备代码', title: '设备代码', sort: true }
|
, { field: 'HUnitID', title: 'HUnitID', hide: true, sort: true }
|
, { field: '单位', title: '单位', sort: true }
|
, { field: '设备出厂日期', title: '设备出厂日期', templet: "<div>{{d.设备出厂日期 ==null ?'':layui.util.toDateString(d.设备出厂日期, 'yyyy-MM-dd')}}</div>", sort: true }
|
, { field: '设备出厂编号', title: '设备出厂编号', sort: true }
|
, { field: 'HDeptID', title: 'HDeptID', hide: true, sort: true }
|
, { field: '使用部门', title: '使用部门', sort: true }
|
, { field: 'HUseEmpID', title: 'HUseEmpID', hide: true, sort: true }
|
, { field: '使用负责人', title: '使用负责人', sort: true }
|
, { field: 'HRepairEmpID', title: 'HRepairEmpID', hide: true, sort: true }
|
, { field: '维护负责人', title: '维护负责人', sort: true }
|
, { field: '安装地点', title: '安装地点', sort: true }
|
, { field: '安装日期', title: '安装日期', templet: "<div>{{d.安装日期 ==null ?'':layui.util.toDateString(d.安装日期, 'yyyy-MM-dd')}}</div>", sort: true }
|
, { field: '运行开始日期', title: '运行开始日期', templet: "<div>{{d.运行开始日期 ==null ?'':layui.util.toDateString(d.运行开始日期, 'yyyy-MM-dd')}}</div>", sort: true }
|
, { field: '当前状态', title: '当前状态', sort: true }
|
, { field: 'HEquipFileTypeID', title: 'HEquipFileTypeID', hide: true, sort: true }
|
, { field: '设备类型', title: '设备类型', sort: true }
|
, { field: '工程编码', title: '工程编码', sort: true }
|
, { field: '产品', title: '产品', sort: true }
|
, { field: '品牌', title: '品牌', sort: true }
|
, { field: 'HSellSupID', title: 'HSellSupID', hide: true, sort: true }
|
, { field: '供应商', title: '供应商', sort: true }
|
, { field: 'HMakeSupID', title: 'HMakeSupID', hide: true, sort: true }
|
, { field: '制造商', title: '制造商', sort: true }
|
, { field: '制单人', title: '制单人', sort: true }
|
, { field: '制单日期', title: '制单日期', templet: "<div>{{d.制单日期 ==null ?'':layui.util.toDateString(d.制单日期, 'yyyy-MM-dd')}}</div>", sort: true }
|
, { field: '审核人', title: '审核人', sort: true }
|
, { field: '审核日期', title: '审核日期', templet: "<div>{{d.审核日期 ==null ?'':layui.util.toDateString(d.审核日期, 'yyyy-MM-dd')}}</div>", sort: true }
|
, { field: '修改人', title: '修改人', sort: true }
|
, { field: '修改日期', title: '修改日期', templet: "<div>{{d.修改日期 ==null ?'':layui.util.toDateString(d.修改日期, 'yyyy-MM-dd')}}</div>", sort: true }
|
, { field: '关闭人', title: '关闭人', sort: true }
|
, { field: '关闭日期', title: '关闭日期', templet: "<div>{{d.关闭日期 ==null ?'':layui.util.toDateString(d.关闭日期, 'yyyy-MM-dd')}}</div>", sort: true }
|
, { field: 'hbilltype', title: 'hbilltype', hide: true, sort: true }
|
, { field: '单据号', title: '单据号', sort: true }
|
, { field: '单据类型', title: '单据类型', sort: true }
|
, { field: 'HMoudType', title: 'HMoudType', hide: true, sort: true }
|
, { field: 'hsubid', title: 'hsubid', hide: true, sort: true }
|
]]
|
};
|
optionResume = {
|
elem: '#mainTableResume'
|
, height: 'full-50'
|
, page: true
|
, totalRow: true
|
, cellMinWidth: 90
|
, limit: 50
|
, limits: [50, 500, 5000, 20000]
|
, cellMinWidth: 100
|
, done: function (res, curr, count) {
|
soulTable.render(this);
|
}
|
}
|
}
|
|
|
//#region 点击行选中高亮
|
table.on('row(mainTable)', function (obj) {
|
//选中行改变颜色
|
var flag = !obj.tr.find(':checkbox:first').prop('checked');
|
obj.tr.find(':checkbox').prop('checked', flag);
|
if (flag) {
|
obj.tr.find('.layui-form-checkbox').addClass('layui-form-checked'); //设置复选框选中样式
|
$(".layui-col-xs3").find(obj.tr.selector).attr({ "style": "background:#ceedfa;color:black" });//改变当前tr背景颜色和字体颜色
|
} else {
|
obj.tr.find('.layui-form-checkbox').removeClass('layui-form-checked');//取消复选框选中样式
|
$(".layui-col-xs3").find(obj.tr.selector).attr({ "style": "background:" });//取消当前tr颜色
|
}
|
//mainTable 为表格ID 注意此处如果ID不正确将导致你在监听复选框时获取不到你选择的数据,前面的只是添加或删除选中未选中样式以及设置背景色,字体颜色
|
layui.each(table.cache.mainTable, function (i, l) {
|
if (obj.tr.index() == l.LAY_TABLE_INDEX) {
|
l.LAY_CHECKED = flag;
|
}
|
});
|
})
|
//#endregion
|
|
//查询设备
|
function get_Display(sWhere) {
|
var index = layer.load(0, { shade: false });
|
//进入页面显示的缓存列表
|
$.ajax({
|
url: GetWEBURL() + '/Gy_EquipFileMain/GetList',
|
type: "GET",
|
data: { "sWhere": sWhere, "user": sessionStorage["HUserName"]},
|
success: function (data1) {
|
if (data1.count == 1) {
|
option.data = data1.data;
|
table.render(option);
|
layer.close(index);
|
} else {
|
layer.close(index);
|
layer.alert(data1.code + data1.Message, { icon: 5 });
|
}
|
}, error: function () {
|
layer.close(index);
|
layer.alert("接口请求失败!", { icon: 5 });
|
}
|
});
|
}
|
|
//查询履历
|
function get_DisplayResume(HInterID) {
|
var checkStatus = table.checkStatus('mainTable')
|
, data = checkStatus.data;
|
if (OperationType!=3) {
|
if (checkStatus.data.length === 1) {
|
var HInterID = data[0].hmainid.toString();
|
} else {
|
layer.msg('请选择一行数据查询!');
|
return;
|
}
|
}
|
var ajaxLoad = layer.load();
|
$.ajax({
|
url: GetWEBURL() + '/Gy_EquipFileMain/GetResumeList',
|
type: "GET",
|
data: { "HInterID": HInterID, "user": sessionStorage["HUserName"] },
|
success: function (data1) {
|
if (data1.count == 1) {
|
var data = [];
|
var col = [];
|
var totalArray = ["数量", "关联数量", "未关联数量", "打印条码数量", "未打印条码数量", "实收数量", "金额", "计划金额"];
|
//给空的数组赋值
|
for (var key in data1.list) {
|
data.push({ "id": data1.list[key].ColmCols, "name": data1.list[key].ColmCols, "Type": data1.list[key].ColmType });
|
}
|
//在列表左边添加勾选框
|
col.push({ type: 'checkbox', fixed: 'left', totalRowText: '合计' });
|
for (var i = 0; i < data.length; i++) {
|
// if (data[i].name == 'HInterID' || data[i].name == 'HBillType' || data[i].name == 'hmainid') {
|
if ($.inArray(data[i].name, titleData) > -1) {
|
col.push({ field: data[i].id, title: data[i].name, align: 'center', hide: true }); //隐藏id列
|
}
|
else if ($.inArray(data[i].name, totalArray) > -1) { //添加计算列
|
col.push({ field: data[i].id, title: data[i].name, align: 'center', sort: true, totalRow: true, width: 120 });
|
} else {
|
switch (data[i].Type) {
|
//int
|
case 'DateTime':
|
col.push({ field: data[i].id, title: data[i].name, align: 'center', sort: true, templet: "<div>{{d." + data[i].name + " == null ?'':layui.util.toDateString(d." + data[i].name + ", 'yyyy-MM-dd HH:mm:ss')}}</div>", width: 200 });
|
break;
|
default:
|
col.push({ field: data[i].id, title: data[i].name, align: 'center', sort: true, width: 200 });
|
}
|
}
|
}
|
optionResume.cols = [col];
|
optionResume.data = data1.data;
|
|
table.render(optionResume);
|
layer.close(ajaxLoad);
|
//layer.alert("查询成功", { icon: 1 });
|
} else {
|
layer.close(ajaxLoad);
|
layer.alert(data1.code + data1.Message, { icon: 5 });
|
}
|
}, error: function () {
|
layer.close(ajaxLoad);
|
layer.alert("接口请求失败!", { icon: 5 });
|
}
|
});
|
|
}
|
|
//快速过滤
|
function get_FastQuery() {
|
var HNumber = $("#HNumber").val();
|
var HName = $("#HName").val();
|
if (HNumber) {
|
sWhere += " and 设备编码 like '%" + HNumber + "%'";
|
}
|
if (HName) {
|
sWhere += " and 设备名称 like '%" + HName + "%'";
|
}
|
if (treeId != "0" && treeId != null) {
|
sWhere += " and HEquipFileTypeID='" + treeId + "'";
|
}
|
get_Display(sWhere);
|
sWhere = "";//调用接口后清空sWhere缓存
|
}
|
|
// 树状图查询
|
function get_Display_Tree() {
|
var ajaxLoad = layer.load();
|
$.ajax({
|
url: GetWEBURL() + '/Gy_EquipFileMain/TreeGetList',
|
type: "GET",
|
data: { "sWhere": sWhere, "user": sessionStorage["HUserName"] },
|
success: function (data1) {
|
if (data1.count == 1) {
|
layer.close(ajaxLoad);
|
var data = JSON.parse(data1.data);
|
MenuMain(data);
|
} else {
|
layer.close(ajaxLoad);
|
layer.alert(data1.code + data1.Message, { icon: 5 });
|
}
|
}, error: function () {
|
layer.close(ajaxLoad);
|
layer.alert("接口请求失败!", { icon: 5 });
|
}
|
});
|
}
|
|
//遍历生成主菜单
|
function MenuMain(data) {
|
var liStr = '[';
|
//遍历生成主菜单
|
for (var i = 0; i < data.length; i++) {
|
// 判断是否存在子菜单
|
if (data[i].children != null && data[i].children.length > 0) {
|
liStr += '{"title": "' + data[i].id + "-" + data[i].title + '", "id": "' + data[i].id + '","spread":true, "children":[ ';
|
// 遍历获取子菜单
|
for (var k = 0; k < data[i].children.length; k++) {
|
liStr += getChildMenu(data[i].children[k], 0);
|
}
|
liStr = liStr.substring(0, liStr.length - 1);
|
liStr += ']},';
|
} else {
|
liStr += '{"title": "' + data[i].id + "-" + data[i].title + '", "id": "' + data[i].id + '"},';
|
}
|
};
|
liStr = liStr.substring(0, liStr.length - 1);
|
liStr += "]";
|
var treeTable = JSON.parse(liStr);
|
tree.render({
|
elem: '#TreeTable' //默认是点击节点可进行收缩
|
, data: treeTable
|
, click: function (obj) {
|
//高亮变色
|
$(".layui-tree-set").removeClass('layui-tree-set-active');
|
obj.elem.addClass('layui-tree-set-active');
|
var HNumber = $("#HNumber").val();
|
var HName = $("#HName").val();
|
var sql = "";
|
if (HNumber) {
|
sql += " and 设备编码 like '%" + HNumber + "%'";
|
}
|
if (HName) {
|
sql += " and 设备名称 like '%" + HName + "%'";
|
}
|
var data = obj.data; //获取当前点击的节点数据
|
treeId = data.id;
|
if (data.id == "0") {
|
sql += "";
|
} else {
|
sql += " and HEquipFileTypeID='" + data.id + "' ";
|
}
|
get_Display(sql);
|
}
|
});
|
}
|
|
// 递归生成子菜单
|
function getChildMenu(subMenu, num) {
|
num++;
|
var subStr = '';
|
if (subMenu.children != null && subMenu.children.length > 0) {
|
subStr += '{"title": "' + subMenu.id + "-" + subMenu.title + '", "id": "' + subMenu.id + '", "children":[';
|
for (var j = 0; j < subMenu.children.length; j++) {
|
subStr += getChildMenu(subMenu.children[j], num);
|
if (j + 1 == subMenu.children.length) {
|
subStr = subStr.substring(0, subStr.length - 1);
|
}
|
}
|
subStr += ']},';
|
} else {
|
subStr += '{"title": "' + subMenu.id + "-" + subMenu.title + '", "id": "' + subMenu.id + '"},';
|
}
|
return subStr;
|
}
|
|
//刷新
|
function get_Refresh() {
|
$("#HNumber").val("");
|
$("#HName").val("");
|
$("#btnSearch").click();
|
}
|
|
//退出
|
function get_Exit() {
|
if (OperationType != 3) {
|
Pub_Close(2);
|
} else {
|
Pub_Close(1);
|
}
|
}
|
|
//#region 获取参数
|
function getUrlVars() {
|
var vars = [], hash;
|
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
|
for (var i = 0; i < hashes.length; i++) {
|
hash = hashes[i].split('=');
|
vars.push(hash[0]);
|
vars[hash[0]] = hash[1];
|
}
|
return vars;
|
}
|
//#endregion
|
//以上是layui模块
|
});
|
|
|
|
|
</script>
|
|
</body>
|
</html>
|