<!DOCTYPE html>
|
<html>
|
<head>
|
<meta charset="utf-8" />
|
<title>工艺路线数据导入</title>
|
<link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
|
<link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all">
|
<script src="../../../layuiadmin/zgqCustom/zgqCustom.js"></script>
|
<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>
|
</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 style="padding: 10px; ">
|
<button class="layui-btn layui-btn-normal" style="margin-left: 0px" type="button" lay-submit="" lay-filter="btnSave" id="btnSave">导入数据</button>
|
<button class="layui-btn layui-btn-normal" style="margin-left: 0px" type="button" lay-submit="" lay-filter="Cancel" id="Cancel">退出</button>
|
<button class="layui-btn layui-btn-normal" style="margin-left: 0px" type="button" lay-submit="" lay-filter="UpLoad" id="UpLoad">文件上传</button>
|
</div>
|
<div class="layui-collapse">
|
<div class="layui-colla-item">
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 85px;">会计年</label>
|
<div class="layui-input-block" style="margin-left: 120px; width: 85px;">
|
<select name="HYear" id="HYear" lay-verify="HYear">
|
<!--动态渲染组织-->
|
</select>
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 85px;">会计月</label>
|
<div class="layui-input-block" style="margin-left: 120px; width: 85px;">
|
<select name="HPeriod" id="HPeriod" lay-verify="HPeriod">
|
<!--动态渲染组织-->
|
</select>
|
</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="WorkBookName" id="WorkBookName" value="Sheet1">
|
</div>
|
</div>
|
<div class="layui-inline">
|
<div class="layui-input-block" style="margin-left: 10px;min-height:0px">
|
<input type="checkbox" name="DataAppend" id="DataAppend" lay-skin="primary" lay-filter="DataAppend" title="追加">
|
<input type="hidden" name="HOrgID" id="HOrgID" lay-verify="HOrgID">
|
</div>
|
</div>
|
<div class="layui-inline">
|
<div class="layui-input-block" style="margin-left: 10px;min-height:0px">
|
<input type="checkbox" name="SqlAppend" id="SqlAppend" lay-skin="primary" lay-filter="SqlAppend" title="数据库添加">
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 85px;">是否转工序</label>
|
<div class="layui-input-block" style="margin-left: 120px; width: 85px;">
|
<select name=" HTProcessFlag" id="HTProcessFlag">
|
<option value="1">是</option>
|
<option value="0">否</option>
|
</select>
|
</div>
|
</div>
|
</div>
|
</div>
|
<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="set_DeleteBill"><i class="layui-icon layui-icon-delete"></i>删除</button>
|
<button type="button" class="layui-btn layui-btn-sm" lay-event="set_HideColumn"><i class="layui-icon layui-icon-form"></i>列设置</button>
|
</div>
|
</script>
|
</form>
|
</div>
|
</div>
|
</div>
|
</div>
|
</body>
|
</html>
|
<script type="text/html" id="barDemo">
|
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
|
</script>
|
<script>
|
var treeCkData = { id: 0 };
|
var TagId = "";
|
var TagParentId = "";
|
layui.config({
|
base: '../../../layuiadmin/' //静态资源所在路径
|
}).extend({
|
index: 'lib/index', //主入口模块
|
}).use(['tree', 'index', 'form', 'table', 'element', 'laypage', 'laydate', 'util', 'upload'], 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
|
, tree = layui.tree
|
, util = layui.util
|
, upload = layui.upload
|
|
var HModName = "Gy_RoutingBillimport";
|
//#endregion
|
|
//#region 进入页面即加载
|
|
//初始化界面
|
set_ClearBill();
|
//#endregion
|
|
//#region 头工具栏事件
|
table.on('toolbar(mainTable)', function (obj) {
|
switch (obj.event) {
|
//列设置
|
case 'set_HideColumn': get_HideColumn();
|
break;
|
};
|
});
|
|
//#region 触发事件:包括form.on(){}格式的所有点击事件、选择事件等
|
|
//行内事件
|
table.on('tool(mainTable)', function (obj) {
|
set_GridDelete(obj); //行内删除
|
});
|
|
//文件上传
|
upload.render({
|
elem: '#UpLoad',
|
url: GetWEBURL() + '/Gy_RoutingBill/Gy_RoutingBillimport',
|
contentType: 'application/json',
|
exts: 'xls|xlsx', //允许上传的类型
|
data: {
|
"WorkBookName": function () {
|
return $("#WorkBookName").val();
|
},
|
"HOrgID": function () {
|
return sessionStorage["OrganizationID"];
|
}
|
},
|
before: function (data) {
|
loadIndex = layer.load(2);
|
this.data = {
|
"WorkBookName": $("#WorkBookName").val(),
|
"HOrgID": sessionStorage["OrganizationID"]
|
|
}
|
},
|
done: function (data1) {
|
if (data1.count == 1) {
|
option.data = data1.data;
|
table.render(option);
|
layer.close(loadIndex);
|
} else {
|
layer.close(loadIndex);
|
layer.alert(data1.code + data1.Message, { icon: 5 });
|
}
|
},
|
error: function (err) {
|
debugger
|
layer.alert('导入出现异常', { icon: 2 });
|
}
|
});
|
|
//退出
|
form.on('submit(Cancel)', function () {
|
Pub_Close(2);
|
})
|
|
//导入 保存数据
|
form.on('submit(btnSave)', function (data) {
|
|
if ($("input[name='SqlAppend']").prop("checked")) {
|
set_AddNew(data);
|
}
|
else {
|
if (table.cache["mainTable"] != null) {
|
set_AddNew(data);
|
}
|
else {
|
layer.msg("无数据,请先导入数据!");
|
}
|
}
|
})
|
//#endregion
|
|
//#region 本页面被调用的所有方法
|
|
//会计年
|
function Year() {
|
var yyyy = new Date().getFullYear();
|
var YearOption = "";
|
for (var i = 0; i <= 10; i++) {
|
YearOption += '<option style="color:blue;" value="' + (yyyy - 5 + i) + '">' + (yyyy - 5 + i) + '</option>';
|
}
|
$("#HYear").append(YearOption);
|
$("#HYear").val(yyyy)
|
form.render('select');
|
}
|
|
//会计月
|
function Month() {
|
var MM = new Date().getMonth() + 1;
|
var MonthOption = "";
|
for (var i = 1; i <= 12; i++) {
|
MonthOption += '<option style="color:blue;" value="' + i + '">' + i + '</option>';
|
}
|
$("#HPeriod").append(MonthOption);
|
$("#HPeriod").val(MM)
|
form.render('select');
|
}
|
|
//#region 初始化界面
|
function set_ClearBill() {
|
Year();
|
Month();
|
//初始化表格
|
set_InitGrid();
|
}
|
//#endregion
|
|
//初始化表格
|
function set_InitGrid() {
|
option = {
|
elem: '#mainTable'
|
, toolbar: '#toolbarDemo'
|
, height: 'full-120'
|
, page: true
|
, cellMinWidth: 90
|
, limit: 50
|
, limits: [50, 500, 5000, 20000]
|
, loading: false
|
, cols: [[
|
{ type: 'checkbox', fixed: 'left' }
|
, { field: '产品代码', title: '产品代码', width: 120 }
|
, { field: '产品名称', title: '产品名称', width: 120 }
|
, { field: '规格型号', title: '规格型号', width: 120 }
|
, { field: '单位', title: '单位', width: 120 }
|
, { field: '工艺路线名称', title: '工艺路线名称', width: 120 }
|
, { field: '物料分类', title: '物料分类', width: 120 }
|
, { field: '工序序号', title: '工序序号', width: 120 }
|
, { field: '工序代码', title: '工序代码', width: 120 }
|
, { field: '工序', title: '工序', width: 120 }
|
, { field: '工作中心代码', title: '工作中心代码', width: 120 }
|
, { field: '工作中心', title: '工作中心', width: 120 }
|
, { field: '时间单位', title: '时间单位', width: 120 }
|
, { field: '加工数量', title: '加工数量', width: 120 }
|
, { field: '班产定额', title: '班产定额', width: 120 }
|
, { field: '工序工价', title: '工序工价', width: 120 }
|
, { field: '不合格单价', title: '不合格单价', width: 120 }
|
, { field: '报废单价', title: '报废单价', width: 120 }
|
, { field: '本道固定开工天数', title: '本道固定开工天数', width: 120 }
|
, { field: '本道开工余量', title: '本道开工余量', width: 120 }
|
, { field: '上道等待天数', title: '上道等待天数', width: 120 }
|
, { field: '上道循环周期', title: '上道循环周期', width: 120 }
|
, { field: '自动转移', title: '自动转移', width: 120 }
|
, { field: '外协标记', title: '外协标记', width: 120 }
|
, { field: '供应商代码', title: '供应商代码', width: 120 }
|
, { field: '供应商', title: '供应商', width: 120 }
|
, { field: '工艺参数', title: '工艺参数', width: 120 }
|
, { field: '图纸编号', title: '图纸编号', width: 120 }
|
, { field: '本工序确认记录', title: '本工序确认记录', width: 120 }
|
, { field: '良率', title: '良率', width: 120 }
|
, { field: '备注', title: '备注', width: 120 }
|
, { field: '图号版本', title: '图号版本', width: 120 }
|
, { field: '总装图号', title: '总装图号', width: 120 }
|
, { field: '材质', title: '材质', width: 120 }
|
, { field: '成品编号', title: '成品编号', width: 120 }
|
, { field: '版本', title: '版本', width: 120 }
|
, { field: '模具编号', title: '模具编号', width: 120 }
|
, { field: '程序号', title: '程序号', width: 120 }
|
, { fixed: 'right', title: '操作', toolbar: '#barDemo' }
|
]]
|
};
|
|
//渲染页面
|
table.render(option);
|
DisPlay_HideColumn();
|
}
|
|
//行内删除
|
function set_GridDelete(obj) {
|
if (obj.event === 'del') {
|
layer.confirm('真的删除行吗?', function (index) {
|
obj.del();
|
option.data = table.cache["mainTable"];//将数据绑定到data上
|
table.reload(option);
|
layer.close(index);
|
});
|
}
|
}
|
|
//导入(保存)
|
function set_AddNew(data) {
|
//var num = [];
|
//for (var i = 0; i < table.cache["mainTable"].length; i++) {
|
// if (table.cache["mainTable"][i] != "") {
|
// table.cache["mainTable"][i].LAY_TABLE_INDEX = i;
|
// num.push(table.cache["mainTable"][i])
|
// }
|
//}
|
data.field.HOrgID = sessionStorage["OrganizationID"];//组织
|
var sMainStr = JSON.stringify(data.field);
|
var sSubStr = '1';//JSON.stringify(num)
|
var sMainSub = sMainStr + ';' + sSubStr + ';' + sessionStorage["HUserName"];
|
var index = layer.load();
|
|
$.ajax({
|
type: "POST",
|
url: GetWEBURL() + "/Gy_RoutingBill/Gy_RoutingBill_btnSave",
|
async: true,
|
data: { "sMainSub": sMainSub },
|
dataType: "json",
|
success: function (data) {
|
if (data.count == 1) {
|
layer.close(index);
|
layer.msg(data.Message);
|
option.data = null;
|
table.cache["mainTable"] = null;
|
table.render(option);
|
}
|
else {
|
layer.close(index);
|
layer.msg(data.Message, { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
|
}
|
},
|
error: function (err) {
|
layer.close(index);
|
layer.msg("错误:" + err, { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
|
}
|
});
|
}
|
|
//隐藏列设置
|
function get_HideColumn() {
|
var colName = "";
|
var contentUrl = "";
|
for (var i = 1; i < option.cols[0].length - 1; i++) {
|
colName += option.cols[0][i]["title"] + ",";
|
}
|
var urlStr = window.document.location.pathname;//获取文件路径
|
var urlLen = urlStr.split('/');
|
for (var i = 0; i < urlLen.length - 4; i++) {
|
contentUrl += "../";
|
}
|
colName = encodeURI(colName.substring(0, colName.length - 1));//对 URI 进行编码
|
|
contentUrl += '基础资料/隐藏列设置/Gy_GridView_Hide.html?HModName=' + HModName + '&colName=' + colName;
|
|
layer.open({
|
type: 2
|
, skin: "layui-layer-rim" //加上边框
|
, title: "隐藏列设置" //标题
|
, closeBtn: 1 //窗体右上角关闭 的 样式
|
, shift: 2 //弹出动画
|
, area: ["50%", "90%"] //窗体大小
|
, maxmin: true //设置最大最小按钮是否显示
|
, content: [contentUrl, "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 = ["单据ID", "HMouldID", "hsubid", "HManagerID", "源单主内码", "源单子内码"];//不需要显示的字段 可扩展
|
|
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 (dataCols[3] > 0) {
|
option.cols[0][i + 1]["width"] = dataCols[3];
|
}
|
//设置内容字体大小
|
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 (data1.data[0].HColumnWidth != 0) {
|
// option.cols[0][i + 1]["width"] = data1.data[0].HColumnWidth + "px;";
|
//} else {
|
// option.cols[0][i + 1]["width"] = "";
|
//}
|
//显示列
|
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 });
|
}
|
})
|
}
|
|
//#endregion
|
//以上是layui模块
|
});
|
</script>
|