<!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/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>
|
<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">
|
<select name="HInitTimeCycle" id="HInitTimeCycle" class="ForFilteringSchemes"
|
lay-filter="HInitTimeCycle" style="width:190px;">
|
</select>
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 85px;">开始日期</label>
|
<div class="layui-input-inline">
|
<input type="date" class="layui-input ForFilteringSchemes" name="HBeginDate"
|
id="HBeginDate" autocomplete="off" model="datetime" dateFormat="yyyy-MM-dd"
|
placeholder="yyyy-MM-dd">
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 85px;">结束日期</label>
|
<div class="layui-input-inline">
|
<input type="date" class="layui-input ForFilteringSchemes" name="HEndDate"
|
id="HEndDate" autocomplete="off" model="datetime" dateFormat="yyyy-MM-dd"
|
placeholder="yyyy-MM-dd">
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label">站别</label>
|
<div class="layui-input-block" style="width:180px;">
|
<select id="Station" name="Station">
|
<option value="0" selected="selected"></option>
|
<option value="AOI1">AOI1</option>
|
<option value="AOI2">AOI2</option>
|
<option value="AOI3">AOI3</option>
|
<option value="AOI4">AOI4</option>
|
<option value="AVI">AVI</option>
|
<option value="电测">电测</option>
|
</select>
|
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label">料号</label>
|
<div class="layui-input-block" style="width:180px;">
|
<select id="MaterialNo" name="MaterialNo"></select>
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label">批次</label>
|
<div class="layui-input-block" style="width:180px;">
|
<input type="text" class="layui-input" id="LotNo" name="LotNo" autocomplete="off">
|
</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-row" style=" margin-top: 10px; margin-left: 70px;">
|
<div class="layui-inline">
|
<label class="layui-form-label">过滤</label>
|
<div class="layui-input-block">
|
<select name="ColName" id="ColName" class="ForFilteringSchemes" lay-filter="ColName" style="width:190px;">
|
</select>
|
</div>
|
</div>
|
<div class="layui-inline">
|
<select name="Comparator" id="Comparator" class="ForFilteringSchemes" lay-filter="Comparator" style="width:190px;">
|
<option value="0" selected="selected"></option>
|
<option value="=">=</option>
|
<option value=">=">>=</option>
|
<option value=">">></option>
|
<option value="<="><=</option>
|
<option value="<"><</option>
|
<option value="<>"><></option>
|
<option value="7">包含</option>
|
<option value="8">左包含</option>
|
<option value="9">右包含</option>
|
<option value="10">不包含</option>
|
</select>
|
</div>
|
<div class="layui-inline">
|
<input type="text" class="layui-input ForFilteringSchemes" value="" name="ColContent" id="ColContent">
|
</div>
|
</div>
|
|
<div class="layui-row" style=" margin-top: 10px; margin-left: 70px;">
|
<div class="layui-inline">
|
<label class="layui-form-label">过滤</label>
|
<div class="layui-input-block">
|
<select name="ColName1" id="ColName1" class="ForFilteringSchemes" lay-filter="ColName1" style="width:190px;">
|
</select>
|
</div>
|
</div>
|
<div class="layui-inline">
|
<select name="Comparator1" id="Comparator1" class="ForFilteringSchemes" lay-filter="Comparator1" style="width:190px;">
|
<option value="0" selected="selected"></option>
|
<option value="=">=</option>
|
<option value=">=">>=</option>
|
<option value=">">></option>
|
<option value="<="><=</option>
|
<option value="<"><</option>
|
<option value="<>"><></option>
|
<option value="7">包含</option>
|
<option value="8">左包含</option>
|
<option value="9">右包含</option>
|
<option value="10">不包含</option>
|
</select>
|
</div>
|
<div class="layui-inline">
|
<input type="text" class="layui-input ForFilteringSchemes" value="" name="ColContent1" id="ColContent1">
|
</div>
|
</div>
|
|
<div class="layui-row" style=" margin-top: 10px; margin-left: 70px;">
|
<div class="layui-inline">
|
<label class="layui-form-label">过滤</label>
|
<div class="layui-input-block">
|
<select name="ColName2" id="ColName2" class="ForFilteringSchemes" lay-filter="ColName2" style="width:190px;">
|
</select>
|
</div>
|
</div>
|
<div class="layui-inline">
|
<select name="Comparator2" id="Comparator2" class="ForFilteringSchemes" lay-filter="Comparator2" style="width:190px;">
|
<option value="0" selected="selected"></option>
|
<option value="=">=</option>
|
<option value=">=">>=</option>
|
<option value=">">></option>
|
<option value="<="><=</option>
|
<option value="<"><</option>
|
<option value="<>"><></option>
|
<option value="7">包含</option>
|
<option value="8">左包含</option>
|
<option value="9">右包含</option>
|
<option value="10">不包含</option>
|
</select>
|
</div>
|
<div class="layui-inline">
|
<input type="text" class="layui-input ForFilteringSchemes" value="" name="ColContent2" id="ColContent2">
|
</div>
|
</div>
|
</div>
|
</div>
|
</div>
|
</div>
|
<div>
|
<div style="width:99.5%;height:calc(70vh);margin-top:10px;">
|
<div id="histogram" style="width:60%;height:calc(70vh);float:left">
|
|
</div>
|
<div id="PieChart" style="width:39%;height:calc(70vh);float:left;margin-left:5px;">
|
|
</div>
|
</div>
|
<div style="width:99%;height:calc(50vh);">
|
<table class="" id="mainTable" lay-filter="mainTable"></table>
|
</div>
|
</div>
|
<script type="text/html" id="toolbarDemo">
|
<div class="layui-btn-container">
|
<button type="button" class="layui-btn layui-btn-sm" lay-event="get_export" id="get_export"><i class="layui-icon layui-icon-export"></i>导出</button>
|
<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>
|
//#region 文本框输入搜索相关数据-变量
|
var childPage = null; //获取子窗口对象,用于操作子窗口的变量和方法
|
var currRowIndex = 0; //用于定位子窗口当前选中的行
|
var childData = null; //用于获取子窗口返回的数据
|
//#endregion
|
|
layui.config({
|
base: '../../../layuiadmin/' //静态资源所在路径
|
}).extend({
|
index: 'lib/index', //主入口模块
|
}).use(['index', 'form', 'table', 'element', 'laypage', 'laydate'], 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
|
//查询条件
|
var sWhere = "";
|
var sWhere_1 = "";
|
var sWhere_2 = "";
|
var option = [];
|
var option_BadReason = [];
|
var option_LotNoList = [];
|
var HModName = "Sc_BarCodeReport";
|
var ins; //用于导出excel
|
var ins1; //用于导出excel
|
//#endregion
|
//#region 进入页面既加载
|
//初始化界面
|
set_ClearBill();
|
|
|
|
//#region 点击事件包括on form事件等
|
//头工具栏事件
|
table.on('toolbar(mainTable)', function (obj) {
|
switch (obj.event) {
|
//导出excel
|
case 'get_export':
|
get_Export();
|
break;
|
//退出
|
case 'btn-exit': Pub_Close(2);
|
break;
|
//隐藏列设置
|
case 'HideColumn':
|
get_HideColumn();
|
break;
|
};
|
});
|
//重置按钮
|
form.on('submit(btnReSearch)', function (data) {
|
set_ClearQuery();
|
});
|
|
//查询按钮
|
form.on('submit(btnSearch)', function (data) {
|
get_FastQuery();
|
});
|
|
//#region 此页面所有的方法
|
//初始化界面
|
function set_ClearBill() {
|
//初始化日期
|
setSelect_HInitTimeCycle();
|
//初始化时间
|
var HInitTimeCycle = $("#HInitTimeCycle").val()*1;
|
if (HInitTimeCycle != -1) {
|
$('#HBeginDate').prop('disabled', true);
|
$('#HEndDate').prop('disabled', true);
|
} else {
|
$('#HBeginDate').prop('disabled', false);
|
$('#HEndDate').prop('disabled', false);
|
}
|
$("#HBeginDate").val(Format(new Date(new Date() - 1000 * 60 * 60 * 24 * HInitTimeCycle), "yyyy-MM-dd"));
|
$("#HEndDate").val(Format(new Date(), "yyyy-MM-dd"));
|
//初始化下拉框
|
initSelects();
|
|
//加载数据到网格
|
set_InitGrid();
|
get_FastQuery();
|
set_Graphics();
|
|
}
|
//初始化表格
|
function set_InitGrid() {
|
option = {
|
elem: '#mainTable'
|
, toolbar: '#toolbarDemo'
|
, height: 'full-320'
|
, page: true
|
, totalRow: true
|
, cellMinWidth: 90
|
, limit: 50
|
, limits: [50, 500, 5000, 20000]
|
|
}
|
}
|
//日期间隔下拉列表监听
|
form.on('select(HInitTimeCycle)', function (data) {
|
var HInitTimeCycle = $("#HInitTimeCycle").val() * 1;
|
//若日期间隔不为 任意间隔,则禁用开始日期与结束日期的选择
|
if (HInitTimeCycle != -1) {
|
$('#HBeginDate').prop('disabled', true);
|
$('#HEndDate').prop('disabled', true);
|
|
$("#HBeginDate").val(Format(new Date(new Date() - 1000 * 60 * 60 * 24 * HInitTimeCycle), "yyyy-MM-dd"));
|
$("#HEndDate").val(Format(new Date(), "yyyy-MM-dd"));
|
|
//执行查询方法
|
get_FastQuery();
|
} else {
|
$('#HBeginDate').prop('disabled', false);
|
$('#HEndDate').prop('disabled', false);
|
}
|
});
|
|
//#region 初始日期间隔 下拉列表
|
function setSelect_HInitTimeCycle() {
|
var valueList = [0, 1, 2, 3, 4, 5, 6, 29, 180, 365]; //valuelist数组包含与时间相关的整数值
|
var titleList = ["今天", "近两天", "近三天", "近四天", "近五天", "近六天", "近七天", "近30天", "近半年", "近一年"]; //itilelist与valuelist值相对于的表,且作为下拉框文本显示
|
|
var HInitTimeCycle_ArrayList = '<option value="-1" selected="selected" >任意间隔</option>';//定义字符串HInitTimeCycle_ArrayList 作用于下拉列的html内容 包含option元素,值为—1,且在下拉框显示任意间隔
|
for (var i = 0; i < valueList.length; i++) { // 遍历valueList 数组 使每一个值生成一个对应option元素
|
HInitTimeCycle_ArrayList += '<option style="color:blue;" value="' + valueList[i] + '">' + titleList[i] + '</option>';// 把生成的option元素添加入HInitTimeCycle_ArrayList字符串中
|
}
|
|
$("#HInitTimeCycle").empty(); //使用jquery的empty方法清空HInitTimeCycle_ArrayList <select>元素的值
|
$("#HInitTimeCycle").append(HInitTimeCycle_ArrayList); //使用append方法构建之前HInitTimeCycle_ArrayList字符串 的内容传入HInitTimeCycle
|
form.render('select'); //调用 重新渲染select元素
|
|
$("#HInitTimeCycle").val("1"); //使用jQuery的val()方法将下拉列表的选中值设置为"29 ,且显示《近三時天》
|
}
|
//#endregion
|
//#region
|
// 初始化下拉
|
function initSelects() {
|
//// 站台、料号下拉可通过AJAX获取
|
//var StationList = '<option value="0" style="color:red;" selected></option>';
|
//$.ajax({
|
// type: "get",
|
// url: GetWEBURL() + "/Gy_BarCodeReportController/Get_Stations",
|
// 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++) {
|
// StationList += '<option style="color:blue;" value="' + data[i].检验工序 + '" >' + data[i].检验工序 + '</option>';
|
// }
|
// $("#Station").append(StationList);
|
// form.render('select');
|
|
// }
|
// layer.closeAll("loading");
|
// }
|
//})
|
var MaterialNoList = '<option value="0" style="color:red;" selected></option>';
|
$.ajax({
|
type: "get",
|
url: GetWEBURL() + "/Gy_BarCodeReportController/GetMaterialNos",
|
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++) {
|
MaterialNoList += '<option style="color:blue;" value="' + data[i].HLayOutName + '" >' + data[i].HLayOutName + '</option>';
|
}
|
$("#MaterialNo").append(MaterialNoList);
|
form.render('select');
|
|
}
|
layer.closeAll("loading");
|
}
|
})
|
}
|
//#endregion
|
function get_BadReasonCount(sWhere) {
|
|
$.ajax({
|
url: GetWEBURL() + '/Gy_BarCodeReportController/GetBadReason_pie',
|
type: "GET",
|
async: false,
|
data: { "sWhere": sWhere, "user": sessionStorage["HUserName"] },
|
success: function (data1) {
|
var col = [];
|
if (data1.count == 1) {
|
var data = [];
|
//给空的数组赋值
|
for (var key in data1.list) {
|
data.push({ "name": data1.list[key].ColmCols, "Type": data1.list[key].ColmType });
|
}
|
/* option_BadReason.cols = [col];*/
|
option_BadReason.data = data1.data;
|
|
/*ins = table.render(option_BadReason);*/
|
|
} else {
|
|
layer.alert(data1.Message, { icon: 5 });
|
}
|
}, error: function () {
|
|
layer.alert("接口请求失败!", { icon: 5 });
|
}
|
});
|
|
}
|
|
function get_LotNoCount(sWhere) {
|
|
$.ajax({
|
url: GetWEBURL() + '/Gy_BarCodeReportController/GetBadReasonTotal_proc',
|
type: "GET",
|
async: false,
|
data: { "sWhere": sWhere, "user": sessionStorage["HUserName"] },
|
success: function (data1) {
|
var col = [];
|
if (data1.count == 1) {
|
var data = [];
|
//给空的数组赋值
|
for (var key in data1.list) {
|
data.push({ "name": data1.list[key].ColmCols, "Type": data1.list[key].ColmType });
|
}
|
/* option_BadReason.cols = [col];*/
|
option_LotNoList.data = data1.data;
|
|
/*ins = table.render(option_BadReason);*/
|
|
} else {
|
|
layer.alert(data1.Message, { icon: 5 });
|
}
|
}, error: function () {
|
|
layer.alert("接口请求失败!", { icon: 5 });
|
}
|
});
|
|
}
|
//加载网格
|
function get_Display(sWhere) {
|
|
var wait = layer.load();//遮罩
|
$.ajax({
|
url: GetWEBURL() + '/Gy_BarCodeReportController/GetBadReason_proc',
|
type: "GET",
|
async: false,
|
data: { "sWhere": sWhere, "user": sessionStorage["HUserName"] },
|
success: function (data1) {
|
var col = [];
|
if (data1.count == 1) {
|
var data = [];
|
data_1 = data1.data[0];
|
//给空的数组赋值
|
for (var key in data1.list) {
|
data.push({ "name": data1.list[key].ColmCols, "Type": data1.list[key].ColmType });
|
}
|
col.push({ type: 'checkbox', fixed: 'left', totalRowText: '汇总' });
|
//判断是否是纯英文
|
var patrn = new RegExp("[\u4E00-\u9FA5]+");
|
for (var i = 0; i < data.length; i++) {
|
if (!patrn.test(data[i].name)) {
|
col.push({ field: data[i].name, title: data[i].name, hide: true }); //隐藏列
|
}
|
else {
|
switch (data[i].Type) {
|
case 'DateTime':
|
col.push({ field: data[i].name, 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')}}</div>", width: 120 });
|
break;
|
default:
|
col.push({ field: data[i].name, title: data[i].name, align: 'center', sort: true, totalRow: true, width: 120 });
|
}
|
}
|
}
|
option.cols = [col];
|
option.data = data_1;
|
ins = table.render(option);
|
layer.close(wait);
|
} else {
|
layer.close(wait);
|
layer.alert(data1.Message, { icon: 5 });
|
}
|
}, error: function () {
|
layer.close(wait);
|
layer.alert("接口请求失败!", { icon: 5 });
|
}
|
});
|
}
|
|
//#region 重置过滤条件方法
|
function set_ClearQuery() {
|
$("#Station").val("0");
|
$("#MaterialNo").val("0");
|
$("#LotNo").val("");
|
$("#HInitTimeCycle").val("-1");
|
$("#HBeginDate").val(Format(new Date(new Date() - 1000 * 60 * 60 * 24 ), "yyyy-MM-dd"));
|
$("#HEndDate").val(Format(new Date(), "yyyy-MM-dd"));
|
form.render('select');
|
get_FastQuery();
|
}
|
//#endregion
|
//快速过滤
|
function get_FastQuery() {
|
var HBeginDate = $("#HBeginDate").val();//起始日期
|
var HEndDate = $("#HEndDate").val();//截止日期
|
var Station = $("#Station").val();//站台号
|
if (Station == 0) Station = "";
|
var MaterialNo = $("#MaterialNo").val();//料号
|
if (MaterialNo == 0) MaterialNo = "";
|
var LotNo = $("#LotNo").val();//批次号
|
sWhere_1 = {
|
HBeginDate: HBeginDate
|
, HEndDate: HEndDate
|
, MaterialNo: MaterialNo
|
, LotNo: LotNo
|
}
|
sWhere_2 = {
|
HBeginDate: HBeginDate
|
, HEndDate: HEndDate
|
, MaterialNo: MaterialNo
|
, Station: Station
|
, LotNo: LotNo
|
}
|
get_Display(JSON.stringify(sWhere_2));
|
get_BadReasonCount(JSON.stringify(sWhere_2));
|
get_LotNoCount(JSON.stringify(sWhere_2));
|
|
//调用接口后清空sWhere缓存
|
sWhere = "";
|
sWhere_1 = "";
|
sWhere_2 = "";
|
set_Graphics();
|
}
|
//隐藏列设置
|
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++) {
|
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 });
|
}
|
})
|
}
|
//#region 【图形】
|
function set_Graphics() {
|
|
|
//#region 【饼图】
|
var chartDom = document.getElementById('PieChart');
|
var myChart = echarts.init(chartDom);
|
var option_BT;
|
//仅对本业务提供的算法
|
// 使用对象进行分组统计
|
var reasonMap = {};
|
|
// 遍历数据,按不良原因分组求和
|
option_BadReason.data.forEach(item => {
|
var reason = item.不良原因;
|
if (!reasonMap[reason]) {
|
reasonMap[reason] = 0;
|
}
|
reasonMap[reason] += item.不良原因数量;
|
});
|
|
// 转换为饼图需要的格式
|
var option_BT_XData = [];
|
Object.keys(reasonMap).forEach(reason => {
|
option_BT_XData.push({
|
value: reasonMap[reason],
|
name: reason
|
});
|
});
|
|
|
//$("#MaterialNo").val()
|
option_BT = {
|
title: {
|
text: '不良原因分布图',
|
left: 'center'
|
},
|
tooltip: {
|
trigger: 'item'
|
},
|
legend: {
|
top: 'bottom'
|
},
|
series: [
|
{
|
name: '不良原因数目',
|
type: 'pie',
|
radius: '50%',
|
data: option_BT_XData,
|
emphasis: {
|
itemStyle: {
|
shadowBlur: 10,
|
shadowOffsetX: 0,
|
shadowColor: 'rgba(0, 0, 0, 0.5)'
|
}
|
}
|
}
|
]
|
};
|
|
option_BT && myChart.setOption(option_BT);
|
//#endregion
|
|
|
//柱状图绑定数据
|
//#region 【柱状图】
|
var app = {};
|
var chartDom = document.getElementById('histogram');
|
var myChart = echarts.init(chartDom);
|
var option_ZZT;
|
//#region [柱状图布局样式]
|
const posList = [
|
'left',
|
'right',
|
'top',
|
'bottom',
|
'inside',
|
'insideTop',
|
'insideLeft',
|
'insideRight',
|
'insideBottom',
|
'insideTopLeft',
|
'insideTopRight',
|
'insideBottomLeft',
|
'insideBottomRight'
|
];
|
app.configParameters = {
|
rotate: {
|
min: -90,
|
max: 90
|
},
|
align: {
|
options: {
|
left: 'left',
|
center: 'center',
|
right: 'right'
|
}
|
},
|
verticalAlign: {
|
options: {
|
top: 'top',
|
middle: 'middle',
|
bottom: 'bottom'
|
}
|
},
|
position: {
|
options: posList.reduce(function (map, pos) {
|
map[pos] = pos;
|
return map;
|
}, {})
|
},
|
distance: {
|
min: 0,
|
max: 100
|
}
|
};
|
app.config = {
|
rotate: 90,
|
align: 'left',
|
verticalAlign: 'middle',
|
position: 'insideBottom',
|
distance: 15,
|
onChange: function () {
|
const labelOption = {
|
rotate: app.config.rotate,
|
align: app.config.align,
|
verticalAlign: app.config.verticalAlign,
|
position: app.config.position,
|
distance: app.config.distance
|
};
|
myChart.setOption({
|
series: [
|
{
|
label: labelOption
|
},
|
{
|
label: labelOption
|
},
|
{
|
label: labelOption
|
|
},
|
{
|
label: labelOption
|
}
|
]
|
});
|
}
|
};
|
const labelOption = {
|
show: true,
|
position: 'top'
|
};
|
//#endregion
|
|
//柱状图绑定数据
|
// 1. 按批次号分组聚合
|
var batchMap = {};
|
option.data.forEach(function (item) {
|
var batchNo = item['lot批次号'] || item['HBatchNo'];
|
if (!batchNo) return;
|
if (!batchMap[batchNo]) {
|
batchMap[batchNo] = {
|
不良数目: 0,
|
总数: 0
|
};
|
|
}
|
batchMap[batchNo].总数 += (parseInt(item['检验数PCS'] || 0));
|
batchMap[batchNo].不良数目 += (parseInt(item['不良数PCS'] || 0));
|
});
|
// 2. 构造柱状图数据
|
var HXTitle = [];
|
var HSourceIssueCount = [];
|
var HSourceIssueCount1 = [];
|
var HSourceIssueCount2 = [];
|
var ZZTColor = [];
|
for (var batchNo in batchMap) {
|
HXTitle.push(batchNo);
|
HSourceIssueCount.push(batchMap[batchNo].不良数目);
|
HSourceIssueCount1.push(batchMap[batchNo].总数);
|
// 不良率 = 不良数目 / 总数
|
var rate = batchMap[batchNo].总数 > 0 ? (batchMap[batchNo].不良数目 / batchMap[batchNo].总数 * 100).toFixed(2) : "0.00";
|
HSourceIssueCount2.push(rate + "%");
|
}
|
|
|
var ZZTColor2 = ['#00FFFF', '#FC2C83', '#FCED2C', '#93FC2C', '#FC2CF0', '#FC892C', '#2C81FC', '#2CC9FC', '#2CFCA7', '#DED3F2', '#F2D8D3', '#F2D3E0', '#D8E052', '#7EE052', '#52E0D8', '#5F52E0', '#E06F52', '#52E09B', '#E052DE', '#E05F52', '#52B2E0', '#E0C452', '#52CEE0', '#648690', '#E5D1D6', '#D8E5D1', '#E5D1E5', '#D8E5D1', '#7C6262', '#76627C', '#81A583', '#81A595'];
|
var ZZTColor3 = ['#00FFFF', '#FC2C83'];
|
|
for (let i = 0; i < option.data.length; i++) {
|
ZZTColor.push({
|
x: 1,
|
y: 0,
|
x2: 0,
|
y2: 0,
|
type: "linear",
|
colorStops: [
|
{ offset: 0, color: "red" },
|
{ offset: 1, color: "blue" },
|
{ offset: 2, color: "green" }
|
]
|
});
|
|
|
|
}
|
option_ZZT = {
|
title: {
|
text: '批次号',
|
left: 'left',
|
textStyle: {
|
color: 'black',
|
fontSize: 18,
|
fontWeight: 'normal'
|
},
|
padding: [5, 0, 0, 65]
|
},
|
tooltip: {
|
trigger: 'axis',
|
axisPointer: {
|
type: 'shadow'
|
}
|
},
|
legend: {
|
data: ['不良数目', '总数', '不良率']
|
},
|
toolbox: {
|
show: true,
|
orient: 'vertical',
|
left: 'right',
|
top: 'center',
|
feature: {
|
mark: { show: true },
|
dataView: { show: true, readOnly: false },
|
magicType: { show: true, type: ['line', 'bar', 'stack'] },
|
restore: { show: true },
|
saveAsImage: { show: true }
|
}
|
},
|
xAxis: [
|
{
|
type: 'category',
|
axisTick: { show: true },
|
data: HXTitle
|
}
|
],
|
yAxis: [
|
{
|
type: 'value'
|
}
|
],
|
series: [
|
{
|
name: '不良数目',
|
type: 'bar',
|
barGap: 0,
|
label: labelOption,
|
emphasis: {
|
focus: 'series'
|
},
|
data: HSourceIssueCount,
|
itemStyle: {
|
color:'#00FFFF'
|
//color: function (params) {
|
// // 动态生成渐变色或者根据条件返回预设的渐变色
|
// const gradientColors = ZZTColor2;
|
// const index = params.dataIndex;
|
// return gradientColors[params.dataIndex];
|
//}
|
}
|
|
},
|
{
|
name: '总数',
|
type: 'bar',
|
barGap: 0,
|
label: labelOption,
|
emphasis: {
|
focus: 'series'
|
},
|
data: HSourceIssueCount1,
|
itemStyle: {
|
color: '#FC2C83'
|
//color: function (params) {
|
// // 动态生成渐变色或者根据条件返回预设的渐变色
|
// const gradientColors = ZZTColor2;
|
|
// return gradientColors[params.dataIndex];
|
//}
|
}
|
},
|
{
|
name: '不良率',
|
type: 'bar',
|
barGap: 0,
|
label: labelOption,
|
emphasis: {
|
focus: 'series'
|
},
|
data: HSourceIssueCount2,
|
itemStyle: {
|
color:"green"
|
//color: function (params) {
|
// // 动态生成渐变色或者根据条件返回预设的渐变色
|
// const gradientColors = ZZTColor2;
|
|
// return gradientColors[params.dataIndex+1];
|
//}
|
}
|
}
|
|
|
]
|
};
|
option_ZZT && myChart.setOption(option_ZZT);
|
//#endregion
|
}
|
|
});
|
|
</script>
|
</body>
|
</html>
|