<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org"
xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
<th:block th:include="include :: header('用户列表')" />
<th:block th:include="include :: layout-latest-css" />
<th:block th:include="include :: ztree-css" />
</head>
<body class="gray-bg">
<div class="ui-layout-west">
<div class="box box-main">
<div class="box-header">
<div class="box-title">
<i class="fa icon-grid"></i> 组织机构
</div>
<div class="box-tools pull-right">
<a type="button" class="btn btn-box-tool" href="#" onclick="dept()" title="管理部门"><i class="fa fa-edit"></i></a>
<button type="button" class="btn btn-box-tool" id="btnExpand" title="展开" style="display:none;"><i class="fa fa-chevron-up"></i></button>
<button type="button" class="btn btn-box-tool" id="btnCollapse" title="折叠"><i class="fa fa-chevron-down"></i></button>
<button type="button" class="btn btn-box-tool" id="btnRefresh" title="刷新部门"><i class="fa fa-refresh"></i></button>
</div>
</div>
<div class="ui-layout-content">
<div id="tree" class="ztree"></div>
</div>
</div>
</div>
<div class="ui-layout-center">
<div class="container-div">
<div class="row">
<div class="ibox-content">
<form id="formId">
<input type="hidden" id="parentId" name="parentId">
<input type="hidden" id="devSiteId" name="devSiteId">
</form>
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" aria-expanded="true"
onclick="queryDevList()">设备列表</a></li>
<li><a data-toggle="tab" aria-expanded="false"
onclick="queryNotice()">设备信息</a></li>
<li><a data-toggle="tab" aria-expanded="false"
onclick="queryNotice()">检修记录</a></li>
</ul>
</div>
<div class="btn-group-sm" id="toolbar" role="group">
<a class="btn btn-success" onclick="$.operate.add()"
shiro:hasPermission="system:devledger:add"> <i
class="fa fa-plus"></i> 添加
</a> <a class="btn btn-danger multiple disabled"
onclick="$.operate.removeAll()"
shiro:hasPermission="system:devledger:remove"> <i
class="fa fa-remove"></i> 删除
</a> <a class="btn btn-warning" onclick="$.table.exportExcel()"
shiro:hasPermission="system:devledger:export"> <i
class="fa fa-download"></i> 导出
</a>
</div>
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table"></table>
</div>
</div>
</div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: layout-latest-js" />
<th:block th:include="include :: ztree-js" />
<script th:inline="javascript">
var addFlag = [[${@permission.hasPermi('system:devledger:add')}]];
var editFlag = [[${@permission.hasPermi('system:devledger:edit')}]];
var removeFlag = [[${@permission.hasPermi('system:devledger:remove')}]];
var prefix = ctx + "system/devledger";
var selectedDeviceId = null;
var detailFlag = [[${@permission.hasPermi('system:devledger:detail')}]];
$(function() {
var panehHidden = false;
if ($(this).width() < 769) {
panehHidden = true;
}
$('body').layout({ initClosed: panehHidden, west__size: 185 });
queryDevList();
queryLocationTree();
});
var ButtonManager = {
templates: {
devlist: `
<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:devledger:add">
<i class="fa fa-plus"></i> 添加
</a>
<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:devledger:remove">
<i class="fa fa-remove"></i> 删除
</a>
<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:devledger:export">
<i class="fa fa-download"></i> 导出
</a>
`,
equit: `
<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:base:add">
<i class="fa fa-plus"></i> 添加
</a>
<a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:base:edit">
<i class="fa fa-edit"></i> 修改
</a>
<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:base:remove">
<i class="fa fa-remove"></i> 删除
</a>
<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:base:export">
<i class="fa fa-download"></i> 导出
</a>
`,
notice: `
`
},
change: function(buttonType) {
if (this.templates[buttonType]) {
$('#toolbar').html(this.templates[buttonType]);
return true;
}
return false;
},
// 切换到设备列表按钮
toDevList: function() {
return this.change('devlist');
},
// 切换到关联设备按钮
toNotice: function() {
return this.change('equit');
},
// 切换到安装历史按钮
toNotice: function() {
return this.change('notice');
}
};
function queryNotice(){
prefix = ctx + "system/devledger";
var options2 = {
id:'bootstrap-table',
url: prefix + "/queryMaintenance/"+selectedDeviceId,
detailUrl: prefix + "/detail/{id}",
modalName: "检修记录",
columns: [{
checkbox: true
},
{
field: 'noticeId',
title: 'NOTICE_ID',
visible: false // 隐藏该列
},
{
field: 'applyPerson',
title: '申请人'
},
{
field: 'applyDept',
title: '申请部门'
/* title: '设备名称',
sortable: true */
},
{
field: 'applyTime',
title: '申请时间'
},
{
field: 'factCost',
title: '检修成本(元)'
},
{
field: 'priority',
title: '紧急程度',
formatter: function (value, row, index) {
return priorityStatus(row);
}
},
{
field: 'status',
title: '工单状态',
formatter: function (value, row, index) {
return noticeStatus(row);
}
},
{
field: 'acceptingTime',
title: '验收时间',
//visible: false // 隐藏该列
},
{
field: 'acceptingPerson',
title: '验收人',
//visible: false // 隐藏该列
},
{
title: '查看明细',
align: 'center',
formatter: function(value, row, index) {
var actions = [];
actions.push('<a class="btn btn-warning btn-xs ' + detailFlag + '" href="javascript:void(0)" onclick="$.operate.detail(\'' + row.noticeId + '\')"><i class="fa fa-search"></i>详细</a>');
return actions.join('');
}
}
]
};
reinitializeTable(options2);
ButtonManager.toNotice(); // 切换回新增按钮
$.table.search();
}
function location_history(){
ButtonManager.toNotice();
}
//销毁table
function reinitializeTable(newOptions) {
var tableId = 'bootstrap-table'; // 你的表格ID
// 方法1:销毁后重新初始化
try {
// 销毁现有表格
$('#' + tableId).bootstrapTable('destroy');
} catch (e) {
console.log('表格销毁失败或表格不存在:', e);
}
// 清空表格容器(可选)
$('#' + tableId).empty();
// 重新初始化
$.table.init(newOptions || options);
}
function queryDevList() {
prefix = ctx + "system/devledger";
var options = {
url: prefix + "/list",
createUrl: prefix + "/add",
/* updateUrl: prefix + "/edit/{id}", */
removeUrl: prefix + "/remove",
exportUrl: prefix + "/export",
modalName: "设备台帐管理",
columns: [{
checkbox: true
},
{
field: 'devCode',
title: '设备编码'
},
{
field: 'devName',
title: '设备名称'
/* title: '设备名称',
sortable: true */
},
{
field: 'devTypeId',
title: '设备类型'//设备类型ID
},
{
field: 'devSpecksId',
title: '设备型号'
},
{
field: 'factory',
title: '生产厂家'
},
{
field: 'assetCode',
title: '固定资产编码'
},
{
field: 'devStatus',
title: '设备状态',
align: 'center',
formatter: function (value, row, index) {
return statusTools(row);
}
},
{
field: 'wzCode',
title: '物资编码',
visible: false // 隐藏该列
},
{
field: 'snCode',
title: 'SN编码',
visible: false // 隐藏该列
},
{
title: '操作',
align: 'center',
visible: false, // 隐藏该列
formatter: function(value, row, index) {
var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="editDevice(' + row.devId + ')"><i class="fa fa-edit"></i>编辑</a> ');
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(' + row.devId + ')"><i class="fa fa-remove"></i>删除</a>');
return actions.join('');
}
}
]
,
onLoadSuccess: function(data) {
// 表格数据加载成功后执行
if (data && data.rows.length > 0) {
// 获取第一行数据
var firstRow = data.rows[0];
selectedDeviceId = firstRow.devId;
console.log("第一行设备ID:", selectedDeviceId);
}
},
// 添加双击行的回调函数
/* onDblClickRow: function (row, $element) {
selectedDeviceId = row.devId;
editDevice(selectedDeviceId);
} */
};
/* $.table.init(options);
ButtonManager.toDevList(); */
reinitializeTable(options);
ButtonManager.toDevList(); // 切换回新增按钮
$.table.search();
}
function queryHistoryList() {
var options = {
url: prefix + "/list",
createUrl: prefix + "/add",
updateUrl: prefix + "/edit/{id}",
removeUrl: prefix + "/remove",
exportUrl: prefix + "/export",
modalName: "安装历史",
columns: [{
checkbox: true
},
{
field: 'locationId',
title: '部门主键seq_gk_equipment_type',
visible: false
},
{
field: 'parentId',
title: '父层级id'
},
{
field: 'locationName',
title: '设备类型名称'
},
{
field: 'status',
title: '设备类型状态'
},
{
field: 'repairdept',
title: '维护部门'
},
{
title: '操作',
align: 'center',
formatter: function(value, row, index) {
var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.locationId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.locationId + '\')"><i class="fa fa-remove"></i>删除</a>');
return actions.join('');
}
}]
};
$.table.init(options);
$.table.search();
}
function queryLocationTree()
{
var url = ctx + "system/devledger/treeData";
var options = {
url: url,
expandLevel: 2,
onClick : zOnClick
};
$.tree.init(options);
function zOnClick(event, treeId, treeNode) {
$("#devSiteId").val(treeNode.id);
//$("#devSiteId").val(treeNode.pId);
//$("#title").val(treeNode.pId);
$.table.search();
}
}
$('#btnExpand').click(function() {
$._tree.expandAll(true);
$(this).hide();
$('#btnCollapse').show();
});
$('#btnCollapse').click(function() {
$._tree.expandAll(false);
$(this).hide();
$('#btnExpand').show();
});
$('#btnRefresh').click(function() {
queryLocationTree();
});
/* 用户管理-部门 */
function dept() {
var url = ctx + "system/type";
$.modal.openTab("设备类型管理", url);
}
/* 设备状态显示 */
function statusTools(row) {
if (row.devStatus == "active") {
return '在用';
} else if (row.devStatus == "tobeinstall") {
return '待安装';
} else if (row.devStatus == "inactive") {
return '停用';
}else if (row.devStatus == "discard") {
return '报废';
//return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="enable(\'' + row.userId + '\')"></i> ';
}
}
/* 检修记录状态显示 */
function noticeStatus(row) {
if (row.status == "09") {
return '审批未通过';
} else if (row.status == "08") {
return '审批通过';
} else if (row.status == "07") {
return '审批中';
}else if (row.status == "06") {
return '已退回';
}else if (row.status == "05") {
return '已结束';
}else if (row.status == "04") {
return '已处理';
}else if (row.status == "03") {
return '处理中';
}else if (row.status == "02") {
return '待处理';
}else if (row.status == "01") {
return '未提交';
}
}
/* 检修记录紧急程度显示 */
function priorityStatus(row) {
if (row.status == "02") {
return '紧急';
} else if (row.status == "01") {
return '一般';
}
}
</script>
</body>
<!-- 导入区域 -->
<script id="importTpl" type="text/template">
<form enctype="multipart/form-data" class="mt20 mb10">
<div class="col-xs-offset-1">
<input type="file" id="file" name="file"/>
<div class="mt10 pt5">
<input type="checkbox" id="updateSupport" name="updateSupport" title="如果登录账户已经存在,更新这条数据。"> 是否更新已经存在的用户数据
<a onclick="$.table.importTemplate()" class="btn btn-default btn-xs"><i class="fa fa-file-excel-o"></i> 下载模板</a>
</div>
<font color="red" class="pull-left mt10">
提示:仅允许导入“xls”或“xlsx”格式文件!
</font>
</div>
</form>
</script>
</html>
点击system:devledger:add打开第二个页签