<!DOCTYPE html>
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
<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">
|
<!-- 注意:所有引用路径保持与原项目一致,确保功能完整 -->
|
<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/PubCustom.js"></script>
|
<script src="../../../layuiadmin/zgqCustom/zgqCustom.js"></script>
|
<link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
|
<link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all">
|
<link rel="stylesheet" href="../../../layuiadmin/ext/soulTable.css" media="all">
|
<script src="../../../layuiadmin/layui/layui.js"></script>
|
<script src="../../../layuiadmin/SetColumn.js"></script>
|
</head>
|
<body>
|
<div class="layui-fluid">
|
<div class="layui-col-md12">
|
<div class="layui-card">
|
<div class="layui-card-body">
|
<form class="layui-form" action="" lay-filter="component-form-group" autocomplete="off">
|
<div class="layui-collapse">
|
<div class="layui-colla-item">
|
<div class="layui-colla-title layui-inline">
|
<div class="layui-inline">
|
<span>更多</span>
|
</div>
|
</div>
|
<!-- 生产车间 -->
|
<!--<div class="layui-inline">
|
<label class="layui-form-label">生产车间</label>
|
<div class="layui-input-block">
|
<select name="HDeptID" id="HDeptID" lay-verify="required" lay-search class="layui-input ForFilteringSchemes">-->
|
<!-- 动态渲染车间 -->
|
<!--</select>
|
</div>
|
</div>-->
|
<!-- 物料 -->
|
<div class="layui-inline">
|
<label class="layui-form-label">模具</label>
|
<div class="layui-input-inline">
|
<input type="text" class="layui-input" name="HMouldNumber" id="HMouldNumber" style="float:left;width:150px;">
|
<input type="hidden" class="layui-input" name="HMouldID" id="HMouldID" value="0">
|
<button type="button" lay-submit="" class="layui-btn" lay-filter="HMaterList" style="width:40px;">
|
<i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
|
</button>
|
</div>
|
</div>
|
<!--<div class="layui-inline">
|
<label class="layui-form-label">费用项目</label>
|
<div class="layui-input-inline">
|
<input type="text" class="layui-input" name="HItMoneyName" id="HItMoneyName" style="float:left;width:150px;">
|
<input type="hidden" class="layui-input" name="HItMoneyID" id="HItMoneyID" value="0">
|
<button type="button" lay-submit="" class="layui-btn" lay-filter="HItemMoneyList" style="width:40px;">
|
<i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
|
</button>
|
</div>
|
</div>-->
|
<!--<div class="layui-inline">
|
<label class="layui-form-label">成本对象 </label>
|
<div class="layui-input-inline">
|
<input type="text" class="layui-input" name="HCostObjectName" id="HCostObjectName" style="float:left;width:150px;">
|
<input type="hidden" class="layui-input" name="HCostObjectID" id="HCostObjectID" value="0">
|
<button type="button" lay-submit="" class="layui-btn" lay-filter="HCostobjList" style="width:40px;">
|
<i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
|
</button>
|
</div>
|
</div>-->
|
<!--<div class="layui-inline">
|
<label class="layui-form-label">工序</label>
|
<div class="layui-input-inline">
|
<input type="text" class="layui-input" name="HProcName" id="HProcName" style="float:left;width:150px;">
|
<input type="hidden" class="layui-input" name="HProcID" id="HProcID" value="0">
|
<button type="button" lay-submit="" class="layui-btn" lay-filter="HProcList" style="width:40px;">
|
<i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
|
</button>
|
</div>
|
</div>-->
|
<!-- 开始年月 -->
|
<div class="layui-inline" style="margin-left: 20px;">
|
<label class="layui-form-label">开始年月</label>
|
<div class="layui-input-inline">
|
<input type="text" class="layui-input" id="ID-laydate-start-month" placeholder="选择开始年月" readonly>
|
</div>
|
</div>
|
|
<!-- 结束年月 -->
|
<div class="layui-inline" style="margin-left: 20px;">
|
<label class="layui-form-label">结束年月</label>
|
<div class="layui-input-inline">
|
<input type="text" class="layui-input" id="ID-laydate-end-month" placeholder="选择结束年月" readonly>
|
</div>
|
</div>
|
<!-- 查询按钮 -->
|
<button class="layui-btn layuiadmin-btn-order" type="button" lay-submit="" lay-filter="btnSearch" id="btnSearch">
|
<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">重置</button>
|
</div>
|
</div>
|
</form>
|
<div style="margin-top: 10px;">
|
<table class="" id="mainTable" lay-filter="mainTable"></table>
|
<!-- 表格头工具栏 -->
|
<script type="text/html" id="toolbarDemo">
|
<div class="layui-btn-container">
|
<button type="button" class="layui-btn layui-btn-sm" lay-event="btn-reload2"><i class="layui-icon layui-icon-refresh"></i>刷新</button>
|
<button type="button" class="layui-btn layui-btn-sm" lay-event="get_export2"><i class="layui-icon layui-icon-export"></i>导出</button>
|
<button type="button" class="layui-btn layui-btn-sm" lay-event="set_HideColumn2"><i class="layui-icon layui-icon-form"></i>列设置</button>
|
<button type="button" class="layui-btn layui-btn-sm" lay-event="set_SouceExcel" id="set_SouceExcel"><i class="layui-icon layui-icon-delete"></i>导入</button>
|
</div>
|
</script>
|
</div>
|
</div>
|
</div>
|
</div>
|
</div>
|
|
<script>
|
layui.config({
|
base: '../../../layuiadmin/'
|
}).extend({
|
index: 'lib/index',
|
}).use(['index', 'form', 'table', 'element', 'laydate', 'soulTable', 'tableSelect'], function () {
|
var $ = layui.$,
|
admin = layui.admin,
|
layer = layui.layer,
|
table = layui.table,
|
form = layui.form,
|
element = layui.element,
|
laydate = layui.laydate,
|
soulTable = layui.soulTable,
|
tableSelect = layui.tableSelect;
|
|
// 模块名(用于列设置存储)
|
var HModName = "Sc_MouldMonthUseReport";
|
// 表格选项
|
var option = {
|
elem: '#mainTable',
|
toolbar: '#toolbarDemo',
|
height: 'full-120', // 适当留出底部空间
|
page: true,
|
cellMinWidth: 90,
|
totalRow: true,
|
limit: 500,
|
limits: [50, 500, 5000, 20000],
|
done: function (res, curr, count) {
|
soulTable.render(this);
|
},
|
cols: [[]]
|
};
|
// 启动页面
|
initPage();
|
|
function initPage() {
|
// 渲染车间下拉框
|
loadDeptSelect();
|
|
// 设置默认日期: 开始年月为7个月前,结束年月为今天
|
var currentDate = new Date();
|
var lastMonth = new Date(currentDate);
|
lastMonth.setMonth(currentDate.getMonth() - 6);
|
|
// 新增:渲染开始年月选择器
|
laydate.render({
|
elem: '#ID-laydate-start-month',
|
type: 'month',
|
format: 'yyyy-MM',
|
value: lastMonth,
|
done: function (value, date) {
|
// 可以选择在这里触发查询
|
// getFastQuery(2);
|
}
|
});
|
|
// 新增:渲染结束年月选择器
|
laydate.render({
|
elem: '#ID-laydate-end-month',
|
type: 'month',
|
format: 'yyyy-MM',
|
value: currentDate,
|
done: function (value, date) {
|
// 可以选择在这里触发查询
|
// getFastQuery(2);
|
}
|
});
|
|
getFastQuery(2);
|
// 重新渲染表单元素(select等)
|
form.render('select');
|
}
|
|
// 获取车间下拉
|
function loadDeptSelect() {
|
$.ajax({
|
type: "GET",
|
url: GetWEBURL() + "/Sc_ICMOBill/GetHDeptList",
|
async: false,
|
data: { "HOrgID": sessionStorage["OrganizationID"] || 1 }, // 默认组织1
|
success: function (result) {
|
var html = '<option value="0" style="color:red;" selected>全部车间</option>';
|
if (result.count == 1 && result.data) {
|
var data = result.data;
|
for (var i = 0; i < data.length; i++) {
|
html += '<option style="color:blue;" value="' + data[i].HItemID + '">' + data[i].HName + '</option>';
|
}
|
}
|
$("#HDeptID").html(html);
|
form.render('select');
|
},
|
error: function () {
|
layer.alert('获取车间列表失败', { icon: 2 });
|
}
|
});
|
}
|
|
|
|
// 修改后的getFastQuery函数
|
function getFastQuery(type) {
|
// 修改:从年月选择器获取值,而不是从日期输入框
|
var HStartYearMonth = $("#ID-laydate-start-month").val();
|
var HEndYearMonth = $("#ID-laydate-end-month").val();
|
|
// 新增:验证是否选择了开始年月
|
if (!HStartYearMonth) {
|
layer.msg('请选择开始年月', { icon: 2 });
|
return;
|
}
|
|
// 新增:验证是否选择了结束年月
|
if (!HEndYearMonth) {
|
layer.msg('请选择结束年月', { icon: 2 });
|
return;
|
}
|
|
// 新增:解析开始年月为年和月
|
var startParts = HStartYearMonth.split('-');
|
var HStartYear = startParts[0];
|
var HStartPeriod = startParts[1];
|
|
// 新增:解析结束年月为年和月
|
var endParts = HEndYearMonth.split('-');
|
var HEndYear = endParts[0];
|
var HEndPeriod = endParts[1];
|
|
// 新增:验证年月范围是否有效
|
var startValue = parseInt(HStartYear) * 100 + parseInt(HStartPeriod);
|
var endValue = parseInt(HEndYear) * 100 + parseInt(HEndPeriod);
|
|
if (startValue > endValue) {
|
layer.msg('开始年月不能大于结束年月', { icon: 2 });
|
return;
|
}
|
|
var HCostObjID = $("#HMouldID").val() || '0';
|
var HWorkShopID = $("#HDeptID").val() || '0';
|
var HWorkShopID = $("#HDeptID").val() || '0';
|
var HProcID = $("#HProcID").val() || '0';
|
|
// 修改:存储过程参数改为开始年、开始月、结束年、结束月、车间、物料
|
var spParams = "'" + HStartYear + "','" + HStartPeriod + "','" +
|
HEndYear + "','" + HEndPeriod + "','" +
|
HWorkShopID + "','" + HCostObjID + "'" + ",'" + HProcID+"'";
|
sWhere = spParams;
|
|
if (type == 2) {
|
get_Display(spParams);
|
}
|
}
|
|
// 加载阶梯计件数据
|
function get_Display(params) {
|
var loadIndex = layer.load(1, { shade: false });
|
|
var sql = "exec h_p_CB_ActualItemMoneyCost" + params;
|
|
$.ajax({
|
url: GetWEBURL() + '/CB_ActualItemMoneyCostController/CB_ActualItemMoneyCostList',
|
type: "GET",
|
data: { "sWhere": sql },
|
success: function (data1) {
|
layer.close(loadIndex);
|
if (data1.count == 1) {
|
// 解析列定义
|
var colDefs = []; // 存放 {id, name, Type}
|
if (data1.list && data1.list.length > 0) {
|
for (var k in data1.list) {
|
colDefs.push({
|
id: data1.list[k].ColmCols,
|
name: data1.list[k].ColmCols,
|
Type: data1.list[k].ColmType
|
});
|
}
|
}
|
|
// 构建表格列
|
var cols = [];
|
// 多选框列
|
cols.push({ type: 'checkbox', fixed: 'left', totalRowText: '合计' });
|
|
// 辅助判断日期字段(形如"2025-02-20"),原代码用isValidDate但未定义,简单按字段名是否含横线判断,实际根据业务调整
|
for (var i = 0; i < colDefs.length; i++) {
|
var fieldName = colDefs[i].name;
|
var fieldId = colDefs[i].id;
|
var fieldType = colDefs[i].Type;
|
|
// 针对阶梯报表,有些列可能是动态日期(例如“02-20”),原代码用isValidDate判断,我们简单模拟:如果字段名包含 '-' 且长度<=10 视为日期短列
|
var isShortDate = (fieldName.indexOf('-') > 0 && fieldName.length <= 10);
|
if (isShortDate) {
|
// 显示成 MM-dd 格式,原代码尝试Format但未定义,此处直接显示原字段名
|
cols.push({
|
field: fieldId,
|
title: fieldName, // 原代码: Format(fieldName,'MM-dd') 但Format函数可能未引入,保持原样
|
width: 70,
|
totalRow: true,
|
filter: true,
|
align: 'center'
|
});
|
} else if (fieldType == 'DateTime') {
|
cols.push({
|
field: fieldId,
|
title: fieldName,
|
align: 'center',
|
sort: true,
|
filter: true,
|
templet: "<div>{{ d." + fieldId + " == '' ? '' : layui.util.toDateString(d." + fieldId + ", 'yyyy-MM-dd HH:mm:ss') }}</div>",
|
width: 180
|
});
|
} else {
|
cols.push({
|
field: fieldId,
|
title: fieldName,
|
align: 'center',
|
sort: true,
|
width: 150,
|
filter: true
|
});
|
}
|
}
|
|
// 更新表格配置
|
option.cols = [cols];
|
option.data = data1.data || [];
|
|
// 应用列隐藏设置(如果存在)
|
DisPlay_HideColumn(HModName, sessionStorage["HUserName"] || 'admin', option, []);
|
|
// 渲染表格
|
table.render(option);
|
} else {
|
layer.alert(data1.code + ' ' + data1.Message, { icon: 5 });
|
}
|
},
|
error: function () {
|
layer.close(loadIndex);
|
layer.alert("接口请求失败", { icon: 5 });
|
}
|
});
|
}
|
|
// 重置过滤条件
|
// 修改后的clearQuery函数
|
function clearQuery() {
|
var currentDate = new Date();
|
var lastMonth = new Date(currentDate);
|
lastMonth.setMonth(currentDate.getMonth() - 7);
|
|
// 修改:重新设置开始年月选择器的值
|
laydate.render({
|
elem: '#ID-laydate-start-month',
|
type: 'month',
|
format: 'yyyy-MM',
|
value: lastMonth,
|
show: false // 不显示面板
|
});
|
|
// 修改:重新设置结束年月选择器的值
|
laydate.render({
|
elem: '#ID-laydate-end-month',
|
type: 'month',
|
format: 'yyyy-MM',
|
value: currentDate,
|
show: false // 不显示面板
|
});
|
|
$("#HDeptID").val(0);
|
$("#HMouldID").val("0");
|
$("#HMouldNumber").val("");
|
$("#HProcID").val("0");
|
$("#HProcName").val("");
|
form.render('select');
|
}
|
|
// ---------- 事件绑定 ----------
|
// 查询按钮
|
form.on('submit(btnSearch)', function () {
|
getFastQuery(2);
|
return false;
|
});
|
|
// 重置按钮
|
form.on('submit(btnReSearch)', function () {
|
clearQuery();
|
getFastQuery(2);
|
return false;
|
});
|
|
// 班组弹出框(保留原有弹窗方式,与tableSelect共存,优先使用tableSelect;同时支持弹窗选择)
|
|
// 职员弹出框 HItemMoneyList
|
form.on('submit(HMaterList)', function () {
|
openHMaterDialog();
|
return false;
|
});
|
|
// 打开模具 (原 get_checkEmp)
|
function openHMaterDialog() {
|
layer.open({
|
type: 2,
|
skin: 'layui-layer-rim',
|
title: '职',
|
closeBtn: 1,
|
shift: 2,
|
area: ['80%', '80%'],
|
maxmin: true,
|
content: ['../../模治具管理/模治具管理/Gy_MouldFileList.html?openType=2', 'yes'],
|
btn: ['确定', '取消'],
|
btn1: function (index, layero) {
|
var iframeWindow = window['layui-layer-iframe' + index];
|
var checkStatus = iframeWindow.layui.table.checkStatus('mainTable');
|
if (checkStatus.data.length === 0) {
|
return layer.msg('请选择数据');
|
}
|
$("#HMouldID").val(checkStatus.data[0].hmainid);
|
$("#HMouldNumber").val(checkStatus.data[0].模具名称);
|
layer.close(index);
|
}
|
});
|
}
|
|
// 头工具栏事件 (mainTable)
|
table.on('toolbar(mainTable)', function (obj) {
|
switch (obj.event) {
|
case 'set_HideColumn2':
|
get_HideColumnNoPage(HModName, sessionStorage["HUserName"] || 'admin', option, function () { getFastQuery(2); });
|
break;
|
case 'btn-reload2':
|
getFastQuery(2);
|
break;
|
case 'get_export2':
|
exportExcel();
|
break;
|
//导入
|
case 'set_SouceExcel': set_SouceExcel();
|
break;
|
default:
|
break;
|
}
|
});
|
|
// 导出Excel (原 get_Export2)
|
function exportExcel() {
|
var ModRightNameCheck = "Pay_PaymentEntryReportExcel";
|
$.ajax({
|
type: "GET",
|
url: GetWEBURL() + "/LMES/getReportByModRightNameCheck",
|
data: { "ModRightNameCheck": ModRightNameCheck, "user": sessionStorage["HUserName"] },
|
success: function (result) {
|
if (result.count == 1) {
|
var data = option.data || [];
|
// 清洗数据
|
data.forEach(function (item) {
|
for (var key in item) {
|
if (item[key] == null) item[key] = "";
|
if (typeof item[key] === 'string') {
|
item[key] = item[key].replace(/[\r\n]+/g, '').replace(/,/g, '');
|
}
|
}
|
});
|
table.exportFile("mainTable", data, "xls");
|
} else {
|
layer.alert("当前模块没有导出权限!", { icon: 5 });
|
}
|
},
|
error: function () {
|
layer.alert("接口请求失败!", { icon: 5 });
|
}
|
});
|
}
|
|
//导入
|
function set_SouceExcel() {
|
layer.open({
|
type: 2
|
, area: ['100%', '100%']
|
, title: '资料导入'
|
, shift: 0//弹出动画
|
, content: './Gy_WIPBal_Excel.html?OperationType=dao&HSouceBillType='
|
})
|
}
|
|
// 全局辅助函数 Format (如果不存在,简单定义)
|
if (typeof Format !== 'function') {
|
window.Format = function (date, fmt) {
|
if (!date) return '';
|
var d = new Date(date);
|
var o = {
|
"M+": d.getMonth() + 1,
|
"d+": d.getDate(),
|
"H+": d.getHours(),
|
"m+": d.getMinutes(),
|
"s+": d.getSeconds()
|
};
|
if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (d.getFullYear() + "").substr(4 - RegExp.$1.length));
|
for (var k in o)
|
if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
|
return fmt;
|
};
|
}
|
|
|
});
|
|
// 下面两个方法供弹窗回调使用 (Gy_EmployeeList.html 和 Gy_Group.html 会调用)
|
function GetMouldFileValue(obj) //器具
|
{
|
$("#HMouldID").val(obj[0].hmainid);
|
$("#HMouldNumber").val(obj[0].模具名称);
|
}
|
|
</script>
|
|
</body>
|
</html>
|