<!DOCTYPE html>
|
<html>
|
<head>
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
<title>SPC检验单分析</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/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>
|
<script src='../../../layuiadmin/lib/extend/echarts.min.js'></script>
|
<script src="../../../layuiadmin/soulTable.slim.js"></script>
|
<style type="text/css">
|
input.layui-input.layui-unselect {
|
padding-right: 0;
|
}
|
</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-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">
|
<input type="date" class="layui-input" id="HBeginDate" style="width:160px;">
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label">结束日期</label>
|
<div class="layui-input-block">
|
<input type="date" class="layui-input" id="HEndDate" style="width:160px;">
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label">部门</label>
|
<div class="layui-input-block">
|
<select name="HDeptName" id="HDeptName" lay-verify="required" lay-search class="layui-input">
|
<!--动态渲染车间-->
|
</select>
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label">样本数</label>
|
<div class="layui-input-block">
|
<select name="limit" id="limit" lay-verify="required" lay-search class="layui-input">
|
<!--动态渲染车间-->
|
</select>
|
</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 class="layui-colla-content" style="padding: 0px; margin-left: 6%;">
|
<div class="layui-row" style="margin-top:10px;">
|
<!--其他条件-->
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 85px;padding: 9px 18px;">物料代码</label>
|
<div class="layui-input-block" style="margin-left: 120px;">
|
<input type="hidden" class="layui-input" lay-verify="HMaterID" name="HMaterID" id="HMaterID" value="0">
|
<input type="text" class="layui-input" name="HMaterNumber" id="HMaterNumber" style="background-color:#efefef4d;width: 60%;display: inline-block;" readonly>
|
<button class="layui-btn layuiadmin-btn-order" type="button" lay-submit="" lay-filter="btnHMaterID" id="btnHMaterID" style="padding: 0 10px; margin-right: 3px;">
|
<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
|
</button>
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 85px;">物料名称</label>
|
<div class="layui-input-block" style="margin-left: 120px;">
|
<input type="text" class="layui-input" name="HMaterName" id="HMaterName" style="background-color:#efefef4d;" readonly>
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 85px;">规格型号</label>
|
<div class="layui-input-block" style="margin-left: 120px;">
|
<input type="text" class="layui-input" name="HMaterModel" id="HMaterModel" style="background-color:#efefef4d;" readonly>
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 85px;">上限</label>
|
<div class="layui-input-block" style="margin-left: 120px;">
|
<input type="text" class="layui-input" name="HUpLimit" id="HUpLimit" style="background-color:#efefef4d;" readonly>
|
</div>
|
</div>
|
</div>
|
<div class="layui-row" style="margin-top:5px;">
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 85px;padding: 9px 18px;">检验项目</label>
|
<div class="layui-input-block" style="margin-left: 120px;">
|
<input type="hidden" class="layui-input" lay-verify="HQCCheckItemID" name="HQCCheckItemID" id="HQCCheckItemID" value="0">
|
<input type="text" class="layui-input" name="HQCCheckItemNumber" id="HQCCheckItemNumber" style="background-color:#efefef4d;width: 60%;display: inline-block;" readonly>
|
<button class="layui-btn layuiadmin-btn-order" type="button" lay-submit="" lay-filter="btnHQCCheckItemID" id="btnHQCCheckItemID" style="padding: 0 10px;margin-right: 3px;">
|
<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
|
</button>
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 85px;">穴号</label>
|
<div class="layui-input-block" style="margin-left: 120px;">
|
<input type="text" class="layui-input" id="HMouldNum" name="HMouldNum">
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 85px;">标准值</label>
|
<div class="layui-input-block" style="margin-left: 120px;">
|
<input type="text" class="layui-input" name="HTargetVal" id="HTargetVal">
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 85px;">下限</label>
|
<div class="layui-input-block" style="margin-left: 120px;">
|
<input type="text" class="layui-input" name="HDownLimit" id="HDownLimit" style="background-color:#efefef4d;" readonly>
|
</div>
|
</div>
|
</div>
|
<div class="layui-row" style="margin-top:5px;">
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 85px;">控制上限</label>
|
<div class="layui-input-block" style="margin-left: 120px;">
|
<input type="text" class="layui-input" name="HControlUpperLimit_X" id="HControlUpperLimit_X">
|
</div>
|
</div>
|
<div class="layui-inline" style="margin-left: 48px;">
|
<label class="layui-form-label" style="width: 85px;">控制下限</label>
|
<div class="layui-input-block" style="margin-left: 120px;">
|
<input type="text" class="layui-input" name="HControlLowerLimit_X" id="HControlLowerLimit_X">
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 85px;">X中心线</label>
|
<div class="layui-input-block" style="margin-left: 120px;">
|
<input type="text" class="layui-input" name="HCenterline_X" id="HCenterline_X">
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 85px;">PPK</label>
|
<div class="layui-input-block" style="margin-left: 120px;">
|
<input type="text" class="layui-input" name="HPPK" id="HPPK" style="background-color:#efefef4d;" readonly>
|
</div>
|
</div>
|
</div>
|
<div class="layui-row" style="margin-top:5px;">
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 85px;">控制上限</label>
|
<div class="layui-input-block" style="margin-left: 120px;">
|
<input type="text" class="layui-input" name="HControlUpperLimit_S" id="HControlUpperLimit_S">
|
</div>
|
</div>
|
<div class="layui-inline" style="margin-left: 48px;">
|
<label class="layui-form-label" style="width: 85px;">控制下限</label>
|
<div class="layui-input-block" style="margin-left: 120px;">
|
<input type="text" class="layui-input" name="HControlLowerLimit_S" id="HControlLowerLimit_S">
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 85px;">S中心线</label>
|
<div class="layui-input-block" style="margin-left: 120px;">
|
<input type="text" class="layui-input" name="HCenterline_S" id="HCenterline_S">
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 85px;">C P K</label>
|
<div class="layui-input-block" style="margin-left: 120px;">
|
<input type="text" class="layui-input" id="HCPK" name="HCPK" style="background-color:#efefef4d;" readonly>
|
</div>
|
</div>
|
</div>
|
</div>
|
</div>
|
</div>
|
<div>
|
<table class="" id="mainTable" lay-filter="mainTable"></table>
|
<div id="histogram_Avg" style="width:99.5%;height:calc(100vh);margin-top:5px;">
|
|
</div>
|
<div id="histogram_Diff" style="width:99.5%;height:calc(100vh);margin-top:15px;">
|
|
</div>
|
</div>
|
<script type="text/html" id="toolbarDemo">
|
<div class="layui-btn-container">
|
<button type="button" class="layui-btn layui-btn-sm" lay-event="btn-exit"><i class="layui-icon layui-icon-return"></i>退出</button>
|
<button type="button" class="layui-btn layui-btn-sm" lay-event="HideColumn"><i class="layui-icon layui-icon-form"></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'], 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
|
, util = layui.util
|
, soulTable = layui.soulTable
|
//查询条件
|
var sWhere = "";
|
var option = [];
|
var HModName = "QC_InspectionFormReport";
|
var optionAVG = [];
|
var optionS = [];
|
//#endregion
|
|
//#region 进入页面既加载
|
|
//初始化界面
|
set_ClearBill();
|
|
//#endregion
|
|
|
|
//#region 点击事件包括on form事件等
|
//头工具栏事件
|
table.on('toolbar(mainTable)', function (obj) {
|
switch (obj.event) {
|
//退出
|
case 'btn-exit': Pub_Close(2);
|
break;
|
//隐藏列设置
|
case 'HideColumn':
|
get_HideColumn();
|
break;
|
};
|
});
|
|
//#region 产品编码
|
form.on('submit(btnHMaterID)', function (data) {
|
btnHMaterID();
|
});
|
//#endregion
|
|
//#region 检验项目
|
form.on('submit(btnHQCCheckItemID)', function (data) {
|
btnHQCCheckItemID();
|
});
|
//#endregion
|
|
//重置按钮
|
form.on('submit(btnReSearch)', function (data) {
|
set_ClearQuery();
|
});
|
//查询按钮
|
form.on('submit(btnSearch)', function (data) {
|
get_FastQuery();
|
});
|
|
//车间弹窗
|
form.on('submit(HWorkShopList)', function () {
|
//页面层-自定义
|
layer.open({
|
type: 2,
|
skin: 'layui-layer-rim', //加上边框
|
title: '车间列表',
|
closeBtn: 1,
|
shift: 2,
|
area: ['80%', '80%'],
|
maxmin: true,
|
content: ['../../基础资料/公用基础资料/Gy_DepartmentList.html', 'yes'],
|
btn: ['确定', '取消']
|
, btn1: function (index, layero) {
|
|
//按钮【按钮一】的回调
|
var iframeWindow = window['layui-layer-iframe' + index] //获取弹框页面
|
var checkStatus = iframeWindow.layui.table.checkStatus('mainTable');//获取table的elem:"#test"
|
if (checkStatus.data.length === 0) {
|
return layer.msg('请选择数据');
|
}
|
$("#HWorkShopName").val(checkStatus.data[0].部门名称);
|
$("#HWorkShopID").val(checkStatus.data[0].HItemID);
|
layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
|
}
|
, btn2: function (index, layero) {
|
//按钮【按钮二】的回调
|
//return false 开启该代码可禁止点击该按钮关闭
|
},
|
end: function () {
|
|
},
|
success: function (layero, index) {
|
|
}
|
});
|
});
|
|
//#endregion
|
|
//#region 此页面所有的方法
|
|
//初始化界面
|
function set_ClearBill() {
|
get_Dept();
|
get_Limit();
|
//初始化时间
|
$("#HBeginDate").val(Format(new Date(new Date() - 1000 * 60 * 60 * 24 * 10), "yyyy-MM-dd"));//开始日期
|
$("#HEndDate").val(Format(new Date(), "yyyy-MM-dd"));//结束日期
|
//初始化表格
|
set_InitGrid();
|
//get_FastQuery();
|
DisPlay_HideColumn();
|
set_Line();
|
}
|
|
//初始化表格
|
function set_InitGrid() {
|
var columns = [];
|
|
//columns.push({ type: 'numbers', title: '序号' });
|
columns.push({ field:"Id", title: "序号", width: 70 });
|
|
//获取两个月期之间的相差
|
var time1 = Date.parse(new Date($("#HBeginDate").val()));//开始时间
|
var time2 = Date.parse(new Date($("#HEndDate").val()));//结束时间
|
var Days = Math.abs(parseInt((time2 - time1) / 1000 / 3600 / 24));
|
//获取年
|
var yyyy = new Date($("#HBeginDate").val()).getFullYear();
|
//获取月份
|
var MM = new Date($("#HBeginDate").val()).getMonth() + 1;
|
//获取开始月份的最大天数
|
var SumMonth = new Date(yyyy, MM, 0).getDate(); //动态两月之差
|
//获取开始日期的天数
|
var HBEGINDATE = new Date(new Date($("#HBeginDate").val())).getDate(); //获取开始日期天数
|
|
var k = 0;//收集循环次数
|
for (var j = 0; j <= (Days - k); j++) {
|
columns.push({ field: Format(yyyy + '/' + MM + '/' + (HBEGINDATE + j), 'yyyy-MM-dd'), title: Format(yyyy + '/' + MM + '/' + (HBEGINDATE + j), 'MM.dd'), width: 120 })
|
//跨年的话 会从一月一号开始
|
if (MM == 12 && (HBEGINDATE + j) == 31) {
|
yyyy += 1;
|
MM = 1;
|
SumMonth = new Date(yyyy, MM, 0).getDate();
|
HBEGINDATE = 0;
|
k += j;
|
j = 0;
|
} else if ((HBEGINDATE + j) == SumMonth) { //跨月 月数加一 天数从一开始
|
HBEGINDATE = 0;
|
MM += 1;
|
SumMonth = new Date(yyyy, MM, 0).getDate();
|
k += j;
|
j = 0;
|
}
|
}
|
|
option = {
|
elem: '#mainTable'
|
, toolbar: '#toolbarDemo'
|
, height: 'full-50'
|
, cellMinWidth: 90
|
, limit: 500
|
, loading: false
|
, cols: [columns]
|
, done: function (res, curr, count) {
|
soulTable.render(this);
|
}
|
};
|
table.render(option);
|
}
|
|
//加载网格
|
function get_Display(sWhere) {
|
var wait = layer.load();//遮罩
|
$.ajax({
|
url: GetWEBURL() + '/QC_CustomerAppealReport/QC_InspectionFormReport',
|
type: "GET",
|
async: false,
|
data: { "sWhere": sWhere, "user": sessionStorage["HUserName"] },
|
success: function (data1) {
|
if (data1.count == 1) {
|
layer.close(wait);
|
var limit = parseInt($("#limit").val());//样本数
|
if (limit > data1.data.length - 3) {
|
layer.msg("取样数量超过实际数量!", { icon: 5 });
|
} else {
|
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 });//从每个对象中提取数据
|
}
|
for (var i = 0; i < data.length; i++) {//遍历data数组重的数据
|
col.push({ field: data[i].id, title: data[i].name, align: 'center', sort: true, width: 120 });
|
}
|
|
option.cols = [col];
|
option.data = data1.data;
|
optionAVG[0] = data1.data[limit + 1];
|
optionS[0] = data1.data[limit + 2];
|
table.render(option);
|
set_Line();
|
set_PPK();
|
set_CPK();
|
}
|
|
} else {
|
layer.close(wait);
|
layer.alert(data1.Message, { icon: 5 });
|
}
|
}, error: function () {
|
layer.close(wait);
|
layer.alert("接口请求失败!", { icon: 5 });
|
}
|
});
|
}
|
|
//PPK计算 x
|
function set_PPK() {
|
var x_AVG =0;
|
var x_SUM = 0;
|
var x_PPK = 0;
|
var numCount = 0
|
var c4 = [0.7979, 0.8862, 0.9213, 0.9400, 0.9515, 0.9594, 0.9650, 0.9693, 0.9727, 0.9754, 0.9776, 0.9794, 0.9810, 0.9823, 0.9835, 0.9845, 0.9854, 0.9862, 0.9869, 0.9876, 0.9882, 0.9887, 0.9892, 0.9896];
|
|
for (var j = 1; j < option.cols[0].length; j++) {
|
if (optionAVG.length != 0 || optionS.length != 0) {
|
x_AVG = calc(x_AVG, parseFloat(optionAVG[0][option.cols[0][j].field]), "+");
|
}
|
}
|
x_AVG = calc(x_AVG, (option.cols[0].length - 1), "/");
|
x_AVG = $("#HCenterline_X").val() == "" ? x_AVG : parseFloat($("#HCenterline_X").val());
|
$("#HCenterline_X").val(x_AVG);
|
|
for (var i = 1; i < option.cols[0].length; i++) {
|
for (var j = 0; j < option.data.length - 3; j++) {
|
numCount += 1;
|
x_SUM = calc(x_SUM, parseFloat(((parseFloat(option.data[j][option.cols[0][i].field]) - x_AVG) ** 2).toFixed(6)), "+")
|
|
}
|
}
|
|
x_PPK = Math.sqrt(calc(x_SUM, (numCount - 1), "/"));
|
|
var limit = $("#limit").val();
|
if (parseInt(limit) >= 9) {
|
$("#HCenterline_S").val(x_PPK.toFixed(4));
|
}
|
|
|
//上限
|
if ($("#HUpLimit").val() != "" && $("#HDownLimit").val() == "") {
|
var HUpLimit = calc(calc(calc(parseFloat($("#HUpLimit").val()), parseFloat($("#HTargetVal").val()), "+"), x_AVG, "-"), calc(calc(3, x_PPK, "*"), c4[option.data.length - 4], "/"), "/");
|
$("#HPPK").val(HUpLimit.toFixed(4));
|
}
|
//下限
|
else if ($("#HDownLimit").val() != "" && $("#HUpLimit").val() == "") {
|
var HDownLimit = calc(calc(x_AVG, calc(parseFloat($("#HDownLimit").val()), parseFloat($("#HTargetVal").val()), "+"), "-"), calc(calc(3, x_PPK, "*"), c4[option.data.length - 4], "/"), "/");
|
$("#HPPK").val(HDownLimit.toFixed(4));
|
} else {
|
var HUpLimit = calc(calc(calc(parseFloat($("#HUpLimit").val()), parseFloat($("#HTargetVal").val()), "+"), x_AVG, "-"), calc(calc(3, x_PPK, "*"), c4[option.data.length - 4], "/"), "/");
|
var HDownLimit = (x_AVG - calc(parseFloat($("#HDownLimit").val()), parseFloat($("#HTargetVal").val()), "+")) / ((3 * x_PPK) / c4[option.data.length - 4]);
|
$("#HPPK").val(HUpLimit > HDownLimit ? HDownLimit.toFixed(4) : HUpLimit.toFixed(4));
|
}
|
}
|
|
//CPK计算 s
|
function set_CPK() {
|
var x_AVG = 0;
|
var s_AVG = 0;
|
var s_CPK = 0;
|
var d2 = [1.128, 1.693, 2.059, 2.326, 2.534, 2.704, 2.847, 3.078, 3.173, 3.258, 3.336, 3.407, 3.472, 3.532, 3.588, 3.640, 3.689, 3.735, 3.778, 3.819, 3.858, 3.895, 3.931];
|
|
for (var j = 1; j < option.cols[0].length; j++) {
|
if (optionAVG.length != 0 || optionS.length != 0) {
|
s_AVG = calc(s_AVG, parseFloat(optionS[0][option.cols[0][j].field]), "+");
|
}
|
}
|
s_AVG = calc(s_AVG, (option.cols[0].length - 1), "/")
|
s_AVG = $("#HCenterline_S").val() == "" || "0" ? s_AVG : parseFloat($("#HCenterline_S").val());
|
$("#HCenterline_S").val(s_AVG);
|
|
var limit = $("#limit").val();
|
if (parseInt(limit) < 9) {
|
$("#HCenterline_S").val(s_AVG.toFixed(4));
|
}
|
|
for (var j = 1; j < option.cols[0].length; j++) {
|
if (optionAVG.length != 0 || optionS.length != 0) {
|
x_AVG = calc(x_AVG, parseFloat(optionAVG[0][option.cols[0][j].field]), "+");
|
}
|
}
|
x_AVG = calc(x_AVG, (option.cols[0].length - 1), "/");
|
x_AVG = $("#HCenterline_X").val() == "" ? x_AVG : parseFloat($("#HCenterline_X").val());
|
$("#HCenterline_X").val(x_AVG);
|
|
s_CPK = calc(s_AVG, d2[option.data.length - 4], "/");
|
|
//上限
|
if ($("#HUpLimit").val() != "" && $("#HDownLimit").val() == "") {
|
var HUpLimit = calc(calc(calc(parseFloat($("#HUpLimit").val()), parseFloat($("#HTargetVal").val()),"+"), s_AVG, "-"), (3 * s_CPK), "/");
|
$("#HCPK").val(HUpLimit.toFixed(4));
|
}
|
//下限
|
else if ($("#HDownLimit").val() != "" && $("#HUpLimit").val() == "") {
|
var HDownLimit = calc(calc(s_AVG, calc(parseFloat($("#HDownLimit").val()), parseFloat($("#HTargetVal").val()), "+"), "-"), (3 * s_CPK), "/");
|
$("#HCPK").val(HDownLimit.toFixed(4));
|
} else {
|
var HUpLimit = calc(calc(calc(parseFloat($("#HUpLimit").val()), parseFloat($("#HTargetVal").val()), "+"), s_AVG, "-"), (3 * s_CPK), "/");
|
var HDownLimit = calc(calc(s_AVG, calc(parseFloat($("#HDownLimit").val()), parseFloat($("#HTargetVal").val()), "+"), "-"), (3 * s_CPK), "/");
|
if (s_CPK == 0) {
|
$("#HCPK").val(0);
|
} else {
|
$("#HCPK").val(HUpLimit > HDownLimit ? HDownLimit.toFixed(4) : HUpLimit.toFixed(4));
|
}
|
|
}
|
}
|
|
function calc(num1, num2, calcStr) {
|
var str1, // 转换为字符串的数字
|
str2,
|
ws1 = 0,// ws1,ws2 用来存储传入的num的小数点后的数字的位数
|
ws2 = 0,// 赋默认值,解决当整数和小数运算时倍数计算错误导致的结果误差
|
bigger,// bigger和smaller用于加,减,除法找出小的那个数字,给后面补0,解决位数不对从而造成的计算错误的问题;乘法需要将结果除两个数字的倍数之和
|
smaller,// 例如:加减除法中1.001 + 2.03 ,如果不给2.03进行补0,最后会变成1001+203,数字错位导致结果错误;乘法中1.12*1.1会放大为112*11,所以结果需要除以1000才会是正确的结果,112*11/1000=1.232
|
zeroCount, // 需要补充0的个数
|
isExistDot1, // 传入的数字是否存在小数点
|
isExistDot2,
|
sum,
|
beishu = 1;
|
// 将数字转换为字符串
|
str1 = num1.toString();
|
str2 = num2.toString();
|
// 是否存在小数点(判断需要计算的数字是不是包含小数)
|
isExistDot1 = str1.indexOf('.') != -1 ? true : false;
|
isExistDot2 = str2.indexOf('.') != -1 ? true : false;
|
// 取小数点后面的位数
|
if (isExistDot1) {
|
ws1 = str1.split('.')[1].length;
|
}
|
|
if (isExistDot2) {
|
ws2 = str2.split('.')[1].length;
|
}
|
// 如ws1 和 ws2 无默认值,如果num1 或 num2 不是小数的话则 ws1 或 ws2 的值将为 undefined
|
// bigger 和 smaller 的值会和预期不符
|
bigger = ws1 > ws2 ? ws1 : ws2;
|
smaller = ws1 < ws2 ? ws1 : ws2;
|
|
switch (calcStr) {
|
// 加减法找出小的那个数字,给后面补0,解决位数不对从而造成的计算错误的问题
|
// 例如:1.001 + 2.03 ,如果不给2.03进行补0,最后会变成1001+203,数字错位导致结果错误
|
case "+":
|
case "-":
|
case "/":
|
zeroCount = bigger - smaller;
|
for (var i = 0; i < zeroCount; i++) {
|
if (ws1 == smaller) {
|
str1 += "0";
|
}
|
else {
|
str2 += "0";
|
}
|
}
|
break;
|
case "*":
|
// 乘法需要将结果除两个数字的倍数之和
|
bigger = bigger + smaller;
|
break;
|
default:
|
return "暂不支持的计算类型,现已支持的有加法、减法、乘法、除法";
|
break;
|
}
|
|
// 去除数字中的小数点
|
str1 = str1.replace('.', '');
|
str2 = str2.replace('.', '');
|
|
// 计算倍数,例如:1.001小数点后有三位,则需要乘 1000 变成 1001,变成整数后精度丢失问题则不会存在
|
for (var i = 0; i < bigger; i++) {
|
beishu *= 10; // 等价于beishu = beishu * 10;
|
}
|
num1 = parseInt(str1);
|
num2 = parseInt(str2);
|
// 进行最终计算并除相应倍数
|
switch (calcStr) {
|
case "+":
|
sum = (num1 + num2) / beishu;
|
break;
|
case "-":
|
sum = (num1 - num2) / beishu;
|
break;
|
case "*":
|
sum = (num1 * num2) / beishu;
|
break;
|
case "/":
|
sum = num1 / num2;
|
/* 除数与被除数同时放大一定倍数,不影响结果,
|
所以对数字进行放大对应倍数并进行补0操作后不用另对倍数做处理 */
|
break;
|
default:
|
return "暂不支持的计算类型,现已支持的有加法、减法、乘法、除法";
|
}
|
|
return sum;
|
}
|
|
//折线图
|
function set_Line() {
|
//#region【折线图】
|
//平均值
|
var chartDom = document.getElementById('histogram_Avg');
|
var myChart = echarts.init(chartDom);
|
var option_ZXT_Avg;
|
|
let H_X = [];//x轴标题
|
let HAvg = [];//平均值
|
let HDifference = [];//差值
|
|
for (var j = 1; j < option.cols[0].length; j++) {
|
if (optionAVG.length != 0 || optionS.length != 0) {
|
HAvg.push(optionAVG[0][option.cols[0][j].field]);
|
HDifference.push(optionS[0][option.cols[0][j].field]);
|
} else {
|
HAvg.push(0);
|
HDifference.push(0);
|
}
|
}
|
|
for (let i = 1; i < option.cols[0].length; i++) {
|
H_X.push(option.cols[0][i].field);
|
}
|
|
option_ZXT_Avg = {
|
title: {
|
text: '平均值',
|
left: 'center'
|
},
|
grid: {
|
x: '3%', //相当于距离左边效果:padding-left
|
//y: '5%', //相当于距离上边效果:padding-top
|
bottom: '5%',
|
containLabel: true
|
},
|
xAxis: {
|
type: 'category',
|
data: H_X
|
},
|
yAxis: {
|
type: 'value',
|
min: parseFloat($("#HDownLimit").val()) != 0 ? calc((parseFloat($("#HTargetVal").val()), calc(parseFloat($("#HDownLimit").val()), 1.3), "*"), "+") : 0, // 设置最小值
|
max: calc(parseFloat($("#HTargetVal").val()), calc(parseFloat($("#HUpLimit").val()), 1.3, "*"), "+"), // 设置最大值
|
interval: calc(calc(parseFloat($("#HUpLimit").val()), parseFloat($("#HDownLimit").val()), "-"), 10, "/"), // 设置间距
|
},
|
series: [
|
{
|
data: HAvg,
|
type: 'line',
|
areaStyle: {//填充的颜色
|
color: {//线性渐变前四个参数分别是 x0, y0, x2, y2, 范围从 0 - 1,相当于在图形包围盒中的百分比,如果 globalCoord 为 `true`,则该四个值是绝对的像素位置
|
type: 'linear',
|
x: 0,
|
y: 1,
|
x2: 0,
|
y2: 0,
|
colorStops: [{
|
offset: 0, color: 'rgba(232,247,247)' // 0% 处的颜色
|
}, {
|
offset: 1, color: 'rgba(183,252,252)' // 100% 处的颜色
|
}],
|
globalCoord: false// 缺省为 false
|
}
|
},
|
itemStyle: { normal: { label: { show: true } } },
|
markLine: {
|
symbol: 'none',//去掉箭头
|
data: [
|
{ yAxis: parseFloat($("#HTargetVal").val()) + parseFloat($("#HUpLimit").val()), lineStyle: { color: '#FF1D00' }, label: { color: '#FF1D00', fontSize: 10 } },
|
{
|
yAxis: parseFloat($("#HTargetVal").val()) + parseFloat($("#HDownLimit").val()), lineStyle: { color: '#FF1D00' }, label: { color: '#FF1D00', fontSize: 10 }
|
},
|
{
|
yAxis: parseFloat($("#HControlUpperLimit_X").val()), lineStyle: { color: '#2cb615' }, label: { color: '#2cb615', fontSize: 10 }
|
},
|
{
|
yAxis: parseFloat($("#HControlLowerLimit_X").val()), lineStyle: { color: '#2cb615' }, label: { color: '#2cb615', fontSize: 10 }
|
}
|
,
|
{
|
yAxis: parseFloat($("#HCenterline_X").val()), lineStyle: { color: '#6dadf0' }, label: { color: '#6dadf0', fontSize: 10 }
|
}
|
]
|
},
|
}
|
]
|
};
|
option_ZXT_Avg && myChart.setOption(option_ZXT_Avg);
|
|
//差值
|
var chartDom = document.getElementById('histogram_Diff');
|
var myChart = echarts.init(chartDom);
|
var option_ZXT_Diff;
|
|
option_ZXT_Diff = {
|
title: {
|
text: '差值',
|
left: 'center'
|
},
|
grid: {
|
x: '3%', //相当于距离左边效果:padding-left
|
//y: '5%', //相当于距离上边效果:padding-top
|
bottom: '5%',
|
containLabel: true
|
},
|
xAxis: {
|
type: 'category',
|
data: H_X
|
},
|
yAxis: {
|
type: 'value'
|
},
|
series: [
|
{
|
data: HDifference,
|
type: 'line',
|
areaStyle: {//填充的颜色
|
color: {//线性渐变前四个参数分别是 x0, y0, x2, y2, 范围从 0 - 1,相当于在图形包围盒中的百分比,如果 globalCoord 为 `true`,则该四个值是绝对的像素位置
|
type: 'linear',
|
x: 0,
|
y: 1,
|
x2: 0,
|
y2: 0,
|
colorStops: [{
|
offset: 0, color: 'rgba(255,240,170,0)' // 0% 处的颜色
|
}, {
|
offset: 1, color: 'rgba(255,240,170,1)' // 100% 处的颜色
|
}],
|
globalCoord: false// 缺省为 false
|
}
|
},
|
itemStyle: { normal: { label: { show: true } } },
|
markLine: {
|
symbol: 'none',//去掉箭头
|
data: [
|
{
|
yAxis: parseFloat($("#HControlUpperLimit_S").val()) , lineStyle: { color: '#2cb615' }, label: { color: '#2cb615', fontSize: 10 }
|
},
|
{
|
yAxis: parseFloat($("#HControlLowerLimit_S").val()), lineStyle: { color: '#2cb615' }, label: { color: '#2cb615', fontSize: 10 }
|
}
|
,
|
{
|
yAxis: parseFloat($("#HCenterline_S").val()), lineStyle: { color: '#6dadf0' }, label: { color: '#6dadf0', fontSize: 10 }
|
}
|
]
|
},
|
}
|
]
|
};
|
option_ZXT_Diff && myChart.setOption(option_ZXT_Diff);
|
|
//#endregion
|
|
}
|
|
//生产车间
|
function get_Dept() {
|
//获取车间列
|
var HDeptName = '<option value="0" style="color:red;" selected>全部车间</option>';
|
$.ajax({
|
type: "get",
|
url: GetWEBURL() + "/Sc_ICMOBill/GetHDeptList",
|
async: false,
|
data: { "HOrgID": sessionStorage["OrganizationID"] },
|
success: function (result) {
|
if (result.count == 1) { // 说明验证成功了,
|
var data = result.data;
|
for (var i = 0; i < data.length; i++) {
|
HDeptName += '<option style="color:blue;" value="' + data[i].HItemID + '" >' + data[i].HName + '</option>';
|
}
|
|
$("#HDeptName").append(HDeptName);
|
form.render('select');
|
}
|
layer.closeAll("loading");
|
}
|
})
|
}
|
|
//样本数量
|
function get_Limit() {
|
var limit = "";
|
for (var i = 1; i <= 50; i++) {
|
limit += '<option style="color:blue;" value="' + i + '" >' + i + '</option>';
|
}
|
$("#limit").append(limit);
|
form.render('select');
|
}
|
|
//快速过滤
|
function get_FastQuery() {
|
var HBeginDate = $("#HBeginDate").val();//下达日期 开始日期
|
var HEndDate = $("#HEndDate").val();//结束日期
|
var HDeptID = $("#HDeptName").val();//车间
|
var limit = $("#limit").val();//样本数
|
var HMaterID = $("#HMaterID").val();//物料
|
var HQCCheckItemID = $("#HQCCheckItemID").val();//检验项目
|
var HMouldNum = $("#HMouldNum").val();//穴号
|
|
if (limit == 0) {
|
return layer.msg("样本数量不能为0!");
|
}
|
|
if (HMaterID == 0) {
|
return layer.msg("物料不能为空!");
|
}
|
|
if (HQCCheckItemID == 0) {
|
return layer.msg("检验项目不能为空!");
|
}
|
|
sWhere = {
|
HBeginDate: HBeginDate
|
, HEndDate: HEndDate
|
, HDeptID: HDeptID
|
, limit: limit
|
, HMaterID: HMaterID
|
, HQCCheckItemID: HQCCheckItemID
|
, HMouldNum: HMouldNum
|
}
|
//初始化表格
|
set_InitGrid();
|
get_Display(JSON.stringify(sWhere));
|
//调用接口后清空sWhere缓存
|
sWhere = "";
|
}
|
|
//物料列表
|
function btnHMaterID() {
|
layer.open({
|
type: 2 //类型
|
, skin: 'layui-layer-rim'//加上边框
|
, area: ['90%', '90%']//大小
|
, title: '物料列表'//标题
|
, shift: 2//弹出动画
|
, content: ['../../基础资料/公用基础资料/Gy_Material.html', 'yes']
|
, btn: ['确定', '取消']
|
, btn1: function (index, layero) {//按钮【按钮一】的回调
|
var iframeWindow = window['layui-layer-iframe' + index] //获取弹框页面
|
var checkStatus = iframeWindow.layui.table.checkStatus('mainTable');//获取table的elem:"#test"
|
if (checkStatus.data.length === 0) {
|
return layer.msg('请选择数据');
|
}
|
//获取数据
|
$("#HMaterID").val(checkStatus.data[0].HItemID);
|
$("#HMaterNumber").val(checkStatus.data[0].物料代码);
|
$("#HMaterName").val(checkStatus.data[0].物料名称);
|
$("#HMaterModel").val(checkStatus.data[0].规格型号);
|
layer.close(index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
|
}
|
, btn2: function (index, layero) { }
|
})
|
}
|
|
//检验项目列表
|
function btnHQCCheckItemID() {
|
layer.open({
|
type: 2 //类型
|
, skin: 'layui-layer-rim'//加上边框
|
, area: ['90%', '90%']//大小
|
, title: '检验项目列表'//标题
|
, shift: 2//弹出动画
|
, content: ['../../基础资料/公用基础资料/Gy_CheckItem.html', 'yes']
|
, btn: ['确定', '取消']
|
, btn1: function (index, layero) {//按钮【按钮一】的回调
|
var iframeWindow = window['layui-layer-iframe' + index] //获取弹框页面
|
var checkStatus = iframeWindow.layui.table.checkStatus('mainTable');//获取table的elem:"#test"
|
if (checkStatus.data.length === 0) {
|
return layer.msg('请选择数据');
|
}
|
//获取数据
|
$("#HQCCheckItemID").val(checkStatus.data[0].HItemID);
|
$("#HQCCheckItemNumber").val(checkStatus.data[0].代码);
|
|
btnCheckProjectList();
|
|
layer.close(index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
|
}
|
, btn2: function (index, layero) { }
|
})
|
}
|
|
//检验方案
|
function btnCheckProjectList() {
|
var sWheres = " and 检验项目代码='" + $("#HQCCheckItemNumber").val() + "'";
|
var wait = layer.load();//遮罩
|
$.ajax({
|
url: GetWEBURL() + '/QC_Management/MES_QC_CheckProjectListProjectDetaiList',
|
type: "GET",
|
async: false,
|
data: { "sWhere": sWheres, "user": sessionStorage["HUserName"] },
|
success: function (data1) {
|
if (data1.count == 1) {
|
layer.close(wait);
|
$("#HUpLimit").val(data1.data[0].上限值);
|
$("#HDownLimit").val(data1.data[0].下限值);
|
$("#HTargetVal").val(data1.data[0].目标值);
|
//$("#HControlUpperLimit").val(data1.data[0].控制上限);
|
//$("#HControlLowerLimit").val(data1.data[0].控制下限);
|
} else {
|
layer.close(wait);
|
layer.alert(data1.Message, { icon: 5 });
|
}
|
}, error: function () {
|
layer.close(wait);
|
layer.alert("接口请求失败!", { icon: 5 });
|
}
|
});
|
}
|
|
//重置过滤条件
|
function set_ClearQuery() {
|
$("#HBeginDate").val(Format(new Date(new Date() - 1000 * 60 * 60 * 24 * 10), "yyyy-MM-dd"));//开始日期
|
$("#HEndDate").val(Format(new Date(), "yyyy-MM-dd"));//结束日期
|
$("#HICMOBillNo").val("");
|
$("#HProcExchBillNo").val("");
|
$("#HName").val("");
|
$("#HBillNo").val("");
|
$("#HMaterNumber").val("");
|
$("#F_BSV_WYID").val("");
|
$("#HState").val("0")
|
$("#ColContent").val("");
|
$("#ColName").val("0");
|
$("#Comparator").val("0");
|
$("input[name='checkWRuku']").prop("checked", false);
|
form.render()
|
sWhere = "";
|
}
|
|
//隐藏列设置
|
function get_HideColumn() {
|
var colName = "";
|
for (var i = 1; i < option.cols[0].length - 1; i++) {
|
colName += option.cols[0][i]["title"] + ",";
|
}
|
|
colName = encodeURI(colName.substring(0, colName.length - 1));//对 URI 进行编码
|
layer.open({
|
type: 2
|
, skin: "layui-layer-rim" //加上边框
|
, title: "隐藏列设置" //标题
|
, closeBtn: 1 //窗体右上角关闭 的 样式
|
, shift: 2 //弹出动画
|
, area: ["50%", "90%"] //窗体大小
|
, maxmin: true //设置最大最小按钮是否显示
|
, content: ['../../基础资料/隐藏列设置/Gy_GridView_Hide.html?HModName=' + HModName + '&colName=' + colName, "yes"]
|
, btn: ["确定", "取消"]
|
, btn1: function (index, laero) {
|
//刷新表格数据
|
DisPlay_HideColumn();
|
//更新表格缓存的数据
|
layer.close(index);//关闭弹窗
|
}
|
})
|
}
|
|
//显示列数据
|
function DisPlay_HideColumn() {
|
$.ajax({
|
url: GetWEBURL() + '/Xt_grdAlignment_WMES/grdAlignmentWMESList',
|
type: "GET",
|
data: { "HModName": HModName, "user": sessionStorage["HUserName"] },
|
success: function (data1) {
|
if (data1.data.length != 0) {
|
|
var dataCol = [];//数据库查询出的列数据
|
var titleData = [];//不需要显示的字段 可扩展
|
|
dataCol = data1.data[0].HGridString.split(',');
|
|
for (var i = 0; i < option.cols[0].length - 2; i++) {
|
if (dataCol[i]) {
|
var dataCols = dataCol[i].split('|');
|
}
|
//隐藏列
|
if (dataCols[1] == 1) {
|
option.cols[0][i + 1]["hide"] = true;
|
}
|
//设置内容字体大小
|
if (data1.data[0].HFontSize != 0) {
|
option.cols[0][i + 1]["style"] = "font-size:" + data1.data[0].HFontSize + "px;";
|
} else {
|
option.cols[0][i + 1]["style"] = "font-size:100%";
|
}
|
//设置列宽
|
if (dataCols[3] > 0) {
|
option.cols[0][i + 1]["width"] = dataCols[3];
|
}
|
//显示列
|
if (dataCols[1] == 0 && $.inArray(option.cols[0][i + 1]["title"], titleData) == -1) {
|
option.cols[0][i + 1]["hide"] = false;
|
}
|
//字体所在位置(左 居中 右)
|
switch (dataCols[2]) {
|
case "L":
|
option.cols[0][i + 1]["align"] = "left";
|
break;
|
case "M":
|
option.cols[0][i + 1]["align"] = "center";
|
break;
|
case "R":
|
option.cols[0][i + 1]["align"] = "right";
|
break;
|
}
|
}
|
|
//取消冻结列
|
for (var i = 1; i < option.cols[0].length - 1; i++) {
|
if (option.cols[0][i]["fixed"] != null) {
|
option.cols[0][i]["fixed"] = null;
|
}
|
else {
|
break;
|
}
|
}
|
//冻结列
|
if (data1.data[0].HFixCols != 0) {
|
for (var i = 0; i < data1.data[0].HFixCols; i++) {
|
if ($.inArray(option.cols[0][i + 1]["title"], titleData) != -1) {
|
data1.data[0].HFixCols += 1;
|
}
|
option.cols[0][i + 1]["fixed"] = "left";
|
}
|
}
|
table.render(option);
|
} else {
|
table.render(option);
|
}
|
}, error: function () {
|
layer.alert("接口请求失败!", { icon: 5 });
|
}
|
})
|
}
|
|
//列明显示下拉框
|
function ColFilter() {
|
var Organization = '<option value="0" selected="selected" ></option>';
|
for (var i = 1; i < option.cols[0].length; i++) {
|
if (option.cols[0][i].hide != true) {
|
Organization += '<option style="color:blue;" value="' + option.cols[0][i].field + '">' + option.cols[0][i].field + '</option>';
|
}
|
}
|
$("#ColName").empty();
|
$("#ColName").append(Organization);
|
form.render('select');
|
}
|
|
|
//#endregion
|
});
|
</script>
|
</body>
|
</html>
|