<!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" style="padding: 0;">
|
<div class="layui-card" style="padding: 2px;background-color: #efefef;">
|
<div class="layui-card-body" style="padding: 1px;">
|
<form class="layui-form" action="" lay-filter="formData" style="background-color:white;">
|
<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-tab" lay-filter="tab-POStockInBill">
|
<div class="layui-tab-content">
|
<!--基本信息-->
|
<div class="layui-tab-item layui-show">
|
<div class="layui-form-item" style="padding-top: 10px;">
|
<div class="layui-row">
|
<div class="layui-inline">
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 85px;">单据日期</label>
|
<div class="layui-input-block" style="margin-left: 120px;">
|
<input type="date" class="layui-input" lay-verify="HDate" name="HDate" id="HDate" style="padding-left: 75px;">
|
</div>
|
</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: 185px;">
|
<select name="HOrderType" id="HOrderType" lay-verify="HOrderType">
|
<option value="生产订单">生产订单</option>
|
<option value="委外订单">委外订单</option>
|
</select>
|
</div>
|
</div>
|
<div class="layui-inline">
|
<div class="layui-inline">
|
<div class="layui-input-block" style="margin-left: 120px;">
|
<input type="hidden" name="HPRDORGID" id="HPRDORGID" lay-verify="HPRDORGID">
|
</div>
|
</div>
|
</div>
|
</div>
|
</div>
|
</div>
|
</div>
|
</div>
|
<table class="" id="mainTable" lay-filter="mainTable"></table>
|
</form>
|
</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>
|
|
layui.config({
|
base: '../../../layuiadmin/' //静态资源所在路径
|
}).extend({
|
index: 'lib/index' //主入口模块
|
}).use(['index', 'form', 'laydate', 'table', 'element', 'upload'], function () {
|
|
//#region 公共变量
|
|
var $ = layui.$
|
, admin = layui.admin
|
, layer = layui.layer
|
, table = layui.table
|
, form = layui.form
|
, laydate = layui.laydate
|
, excel = layui.excel
|
, upload = layui.upload
|
, element = layui.element;
|
|
var option = [];
|
//#endregion
|
|
//#region 进入页面即加载
|
|
var params = getUrlVars();
|
var OperationType = params[params[0]]; //从参数中获取 数据类型 添加 保存
|
|
//初始化界面
|
set_ClearBill();
|
|
//#endregion
|
|
//#region 触发事件:包括form.on(){}格式的所有点击事件、选择事件等
|
|
//行内事件
|
table.on('tool(mainTable)', function (obj) {
|
set_GridDelete(obj); //行内删除
|
set_GridCellCheck(obj);//行内快捷键筛选
|
//#region 修改时间
|
var data = obj.data;
|
//日计划生产日期
|
if (obj.event == 'HPlanEndDate') {
|
var field = $(this).data('field');
|
laydate.render({
|
elem: this.firstChild
|
, show: true //直接显示
|
, closeStop: this
|
, done: function (nowDate) {
|
//时间选择完成,行数据更新
|
data[field] = nowDate;
|
obj.update(data);
|
}
|
});
|
}
|
//#endregion
|
|
});
|
|
//文件上传
|
upload.render({
|
elem: '#UpLoad',
|
url: GetWEBURL() + '/JIT_DayPlanPlatFormImport/JIT_DayPlanPlatFormImport_SS',
|
contentType: 'application/json',
|
exts: 'xls|xlsx', //允许上传的类型
|
before: function (data) {
|
loadIndex = layer.load(2);
|
},
|
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 () {
|
if (OperationType == 1) {
|
Pub_Close(1);
|
}
|
else {
|
Pub_Close(2);
|
}
|
})
|
|
//导入 保存数据
|
form.on('submit(btnSave)', function (data) {
|
if (table.cache["mainTable"] != null) {
|
set_AddNew(data);
|
}
|
else {
|
layer.msg("无数据,请先导入数据!");
|
}
|
})
|
|
|
//#endregion
|
|
//#region 此页面所有的方法
|
|
//#region 初始化界面
|
function set_ClearBill() {
|
//初始化日期间隔、开始日期、结束日期
|
setSelect_HInitTimeCycle();
|
//初始化表格
|
set_InitGrid();
|
}
|
|
//#endregion
|
|
//初始化表格
|
function set_InitGrid() {
|
var columns = [];
|
|
columns.push({ type: 'checkbox', fixed: 'left' });
|
columns.push({ field: 'HMaterID', title: 'HMaterID', width: 150, hide: true });
|
columns.push({ field: 'hmainid', title: 'hmainid', width: 150, hide: true });
|
columns.push({ field: 'ICMOBillHInterID', title: 'ICMOBillHInterID', width: 150, hide: true });
|
columns.push({ field: 'ICMOBillHEntryID', title: 'ICMOBillHEntryID', width: 150, hide: true });
|
columns.push({ field: '生产订单号', title: '生产订单号', width: 150, edit: true, hide: true });
|
columns.push({ field: '物料编码', title: '物料编码', width: 150, edit: true });
|
columns.push({ field: '客户订单号', title: '客户订单号', width: 200, edit: true });
|
columns.push({ field: '计划结束日期', title: '计划结束日期', width: 150, event: "HPlanEndDate", edit: true});
|
|
columns.push({ fixed: 'right', title: '操作', toolbar: '#barDemo' });
|
|
option = {
|
elem: '#mainTable'
|
, toolbar: '#toolbarDemo'
|
, height: 'full-190'
|
, page: true
|
, cellMinWidth: 90
|
, limit: 50
|
, limits: [50, 500, 5000, 20000]
|
, loading: false
|
, cols: [columns]
|
};
|
|
//渲染页面
|
table.render(option);
|
}
|
|
//导入(保存)
|
function set_AddNew(data) {
|
|
var num = [];
|
|
//判断是否有导入权限,如果有则将总装车间之前的日计划工单作废
|
if (!set_ModCheck("Sc_WorkBillSortBill_Edit")) {
|
layer.msg("导入失败!无导入权限!", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
|
return;
|
}
|
|
var HDataSub = [];
|
var index = layer.load();
|
//JIT导入计划,每次导入100行数据,可修改i的自增值决定每次循环导入的行数
|
for (var i = 0; i < option.data.length; i += 100) {
|
HDataSub = option.data.slice(i, i + 100)
|
|
data.field.HPRDORGID = sessionStorage["OrganizationID"];//组织
|
var sMainStr = JSON.stringify(data.field);
|
var sSubStr = JSON.stringify(HDataSub);
|
var sMainSub = sMainStr + ';' + sSubStr + ';' + sessionStorage["HUserName"];
|
var index = layer.load();
|
|
$.ajax({
|
type: "POST",
|
url: GetWEBURL() + "/JIT_DayPlanPlatFormImport/JIT_DayPlanPlatFormImport_btnSave_SS",
|
async: false,
|
data: { "sMainSub": sMainSub },
|
dataType: "json",
|
success: function (data) {
|
if (data.count == 1) {
|
layer.close(index);
|
$('#btnSave').addClass("layui-btn-disabled").attr("disabled", true);
|
layer.msg("提交成功");
|
}
|
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: "温馨提示" });
|
}
|
});
|
}
|
layer.close(index);
|
}
|
|
//行内删除
|
function set_GridDelete(obj) {
|
var rowIndex = $(obj.tr).attr("data-index");
|
if (obj.event === 'del') {
|
layer.confirm('真的删除行吗?', function (index) {
|
obj.del();
|
table.cache["mainTable"].splice(rowIndex, 1); //②彻底移除元素,从缓存里移除这一行
|
option.data = table.cache["mainTable"];//将数据绑定到data上
|
table.reload(option);
|
layer.close(index);
|
});
|
}
|
}
|
|
//行内删除快捷键
|
function set_GridCellCheck(obj) {
|
$(document).off('keydown', ".layui-table-edit").on('keydown', '.layui-table-edit', function (e) {
|
if (event.key == "F7") {
|
//生产资源
|
if (obj.event == "HSourceID") {
|
layer.open({
|
type: 2
|
, skin: "layui-layer-rim" //加上边框
|
, title: "生产资源列表" //标题
|
, closeBtn: 1 //窗体右上角关闭 的 样式
|
, shift: 2 //弹出动画
|
, area: ["90%", "90%"] //窗体大小
|
, maxmin: true //设置最大最小按钮是否显示
|
, content: ["../../基础资料/生产基础资料/Gy_Source.html", "yes"]
|
, btn: ["确定", "取消"]
|
, btn1: function (index, laero) {
|
//按钮一 的回调
|
var iframeWindow = window["layui-layer-iframe" + index];//获取弹框页面
|
var checkStatus = iframeWindow.layui.table.checkStatus("mainTable");//获取选中的数据
|
|
if (checkStatus.data.length != 1) {
|
return layer.msg("请选择一条数据");
|
}
|
//更新表格缓存的数据
|
obj.update({
|
"HSourceID": checkStatus.data[0].HItemID
|
, "生产资源编码*": checkStatus.data[0].生产资源代码
|
})
|
layer.close(index);//关闭弹窗
|
}
|
})
|
}
|
obj.event = "";
|
return false;
|
}
|
|
})
|
}
|
|
//获取参数
|
function getUrlVars() {
|
var vars = [], hash;
|
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
|
for (var i = 0; i < hashes.length; i++) {
|
hash = hashes[i].split('=');
|
vars.push(hash[0]);
|
vars[hash[0]] = hash[1];
|
}
|
return vars;
|
}
|
|
//#region 权限判定
|
function set_ModCheck(ModRightNameCheck) {
|
var Permission = false;
|
$.ajax({
|
type: "GET",
|
url: GetWEBURL() + "/LMES/getReportByModRightNameCheck", //方法所在页面和方法名
|
async: false,
|
data: { "ModRightNameCheck": ModRightNameCheck, "user": sessionStorage["HUserName"] },
|
success: function (result) {
|
if (result.count == 1) {
|
Permission = true;
|
} else {
|
//layer.alert("当前模块没有查询权限!", { icon: 5 });
|
}
|
}, error: function (e) {
|
layer.alert("接口请求失败!", { icon: 5 });
|
}
|
});
|
return Permission;
|
}
|
//#endregion
|
|
//#endregion
|
|
});
|
|
</script>
|