338 lines
18 KiB
HTML
338 lines
18 KiB
HTML
<!DOCTYPE html>
|
||
<html>
|
||
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<title>layui</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="../../../lib/layui-v2.5.5/css/layui.css" media="all">
|
||
<link rel="stylesheet" href="../../../css/public.css" media="all">
|
||
<style>
|
||
body {
|
||
background-color: #ffffff;
|
||
}
|
||
</style>
|
||
</head>
|
||
|
||
<body>
|
||
<div class="layui-form layuimini-form">
|
||
|
||
<div class="layui-form-item">
|
||
<label class="layui-form-label required">设计总成图号</label>
|
||
<div class="layui-input-block">
|
||
<input type="text" name="designAssyNum" required lay-verify="required" lay-reqtext="设计总成图号不能为空"
|
||
placeholder="请输入设计总成图号" value="" class="layui-input">
|
||
</div>
|
||
</div>
|
||
|
||
<div class="layui-form-item">
|
||
<label class="layui-form-label required">BOM名称</label>
|
||
<div class="layui-input-block">
|
||
<input type="text" name="name" required lay-verify="required" lay-reqtext="BOM名称不能为空"
|
||
placeholder="请输入BOM名称" value="" class="layui-input">
|
||
</div>
|
||
</div>
|
||
|
||
<div class="layui-form-item">
|
||
<label class="layui-form-label">备注</label>
|
||
<div class="layui-input-block">
|
||
<input type="text" name="remark" placeholder="请输入备注" value="" class="layui-input">
|
||
</div>
|
||
</div>
|
||
|
||
<div class="layui-form-item">
|
||
|
||
<script type="text/html" id="toolbar">
|
||
<div class="layui-btn-container">
|
||
<button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="addLine">添加</button>
|
||
<button class="layui-btn layui-btn-sm layui-btn-danger data-delete-btn" lay-event="deleteLine">删除</button>
|
||
</div>
|
||
</script>
|
||
|
||
<table class="layui-hide" id="addBOMDetailsList_Production" lay-filter="addBOMDetailsList_Production"></table>
|
||
</div>
|
||
|
||
<div class="layui-form-item">
|
||
<div class="layui-input-block">
|
||
<button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<script src="../../../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
|
||
<script src="../../../js/PublicParameters/PublicParameters.js" charset="utf-8"></script>
|
||
<script>
|
||
layui.use(['form', 'table'], function () {
|
||
var form = layui.form,
|
||
layer = layui.layer,
|
||
table = layui.table;
|
||
$ = layui.$;
|
||
|
||
|
||
table.render({
|
||
elem: '#addBOMDetailsList_Production',
|
||
skin: 'row', //边框风格
|
||
even: true, //开启隔行背景
|
||
data: [],
|
||
toolbar: '#toolbar',
|
||
defaultToolbar: [],
|
||
cols: [[
|
||
{ type: "checkbox", width: 50 },
|
||
{ type: "numbers", title: '序号', width: 50 },
|
||
{ field: 'accessoryCode', width: 150, title: '配件代号', sort: true, align: "center", edit: "text" },
|
||
{ field: 'nameAndSpecs', width: 200, title: '名称及规格', align: "left", edit: "text" },
|
||
{ field: 'materials', width: 150, title: '材料', align: "left", edit: "text" },
|
||
{ field: 'suppliersName', width: 150, title: '供应商', align: "left", edit: "text" },
|
||
{ field: 'amountOfUnit', width: 100, title: '单台用量', align: "center", edit: "text" },
|
||
{ field: 'unit', width: 60, title: '单位', align: "center", edit: "text" },
|
||
{ field: 'price', width: 60, title: '单价', align: "center", edit: "text" },
|
||
{ field: 'amount', width: 80, title: '金额', align: "center", edit: "text" },
|
||
{ field: 'borrowings', width: 150, title: '借用件(共用属性)', align: "left", edit: "text" },
|
||
{ field: 'remark', width: 275, title: '备注', align: "left", edit: "text" },
|
||
]],
|
||
limit: 999,
|
||
page: false,
|
||
skin: 'line'
|
||
});
|
||
|
||
/**
|
||
* toolbar监听事件
|
||
*/
|
||
table.on('toolbar(addBOMDetailsList_Production)', function (obj) {
|
||
if (obj.event === 'addLine') { // 监听添加操作
|
||
var Data = table.cache["addBOMDetailsList_Production"];
|
||
var datas = {
|
||
"accessoryCode": "", "nameAndSpecs": "", "materials": "", "suppliersName": "", "amountOfUnit": "",
|
||
"unit": "", "price": "", "amount": "", "borrowings": "", "remark": ""
|
||
}
|
||
Data.push(datas);
|
||
table.reload('addBOMDetailsList_Production', {
|
||
data: Data
|
||
});
|
||
|
||
$(window).on("resize", function () {
|
||
layer.full(index);
|
||
});
|
||
} else if (obj.event === 'deleteLine') { // 监听删除操作
|
||
var checkStatus = table.checkStatus('addBOMDetailsList_Production');
|
||
if (checkStatus.data.length == 0) {
|
||
layer.alert('请选择至少一条数据!');
|
||
return false;
|
||
}
|
||
|
||
var tableDT = table.cache["addBOMDetailsList_Production"];
|
||
var tableArr = [];
|
||
for (var i = 0; i < tableDT.length; i++) {//遍历表格缓存数组
|
||
var btnObj = tableDT[i];
|
||
if (btnObj.LAY_CHECKED) {//条件:选中
|
||
tableDT.splice(i, 1);//移除后后造成数组下标索引发生变化,所以下面需要i--
|
||
i--;
|
||
}
|
||
}
|
||
tableArr = tableDT;
|
||
|
||
table.reload("addBOMDetailsList_Production", {
|
||
data: tableArr // 将新数据重新载入表格
|
||
});
|
||
}
|
||
});
|
||
|
||
|
||
//监听提交
|
||
form.on('submit(saveBtn)', function (data) {
|
||
layer.confirm('确认保存吗?', function () {
|
||
var apiUrl = GetWebApiUrl();
|
||
var CurrUserInfo = layui.sessionData('CurrUserInfo');
|
||
|
||
$.ajax({
|
||
url: apiUrl + "/api/services/app/BOM_Production/CheckBOM_Production", //请求的url地址
|
||
dataType: "json", //返回格式为json
|
||
//async: false,//请求是否异步,默认为异步,这也是ajax重要特性
|
||
contentType: 'application/json',
|
||
data: JSON.stringify({
|
||
designAssyNum: data.field.designAssyNum,
|
||
name: data.field.name,
|
||
remark: data.field.remark,
|
||
createTime: getDatetime(),
|
||
createUserID: CurrUserInfo.data.userid,
|
||
createUserName: CurrUserInfo.data.userName,
|
||
isAnnex: 0,
|
||
isDelete: 0
|
||
}), //参数值
|
||
type: "POST", //请求方式
|
||
success: function (req) {
|
||
//请求成功时处理
|
||
if (req.result.code != 1) {
|
||
layer.msg("设计总成图号存在重复,请修改后再保存!");
|
||
return false;
|
||
}
|
||
},
|
||
error: function () {
|
||
/*错误信息处理*/
|
||
layer.msg("验证BOM信息失败,请重试!");
|
||
return false;
|
||
},
|
||
});
|
||
|
||
|
||
var addBOMDetailsList_ProductionData = table.cache["addBOMDetailsList_Production"];
|
||
for (let index = 0; index < addBOMDetailsList_ProductionData.length; index++) {
|
||
|
||
$.ajax({
|
||
url: apiUrl + "/api/services/app/BOMDetails_Production/CheckBOMDetails_Production", //请求的url地址
|
||
dataType: "json", //返回格式为json
|
||
//async: false,//请求是否异步,默认为异步,这也是ajax重要特性
|
||
contentType: 'application/json',
|
||
data: JSON.stringify({
|
||
accessoryCode: addBOMDetailsList_ProductionData[index].accessoryCode,
|
||
|
||
isAnnex: 0,
|
||
isDelete: 0
|
||
}), //参数值
|
||
type: "POST", //请求方式
|
||
success: function (req) {
|
||
//请求成功时处理
|
||
if (req.result.code != 1) {
|
||
layer.msg("序号:" + index + " 的配件代号重复,请修改后再保存!");
|
||
return false;
|
||
}
|
||
},
|
||
error: function () {
|
||
/*错误信息处理*/
|
||
layer.msg("保存失败,请重试!1");
|
||
return false;
|
||
},
|
||
});
|
||
|
||
}
|
||
|
||
$.ajax({
|
||
url: apiUrl + "/api/services/app/BOM_Production/CreateBOM_Production", //请求的url地址
|
||
dataType: "json", //返回格式为json
|
||
//async: false,//请求是否异步,默认为异步,这也是ajax重要特性
|
||
contentType: 'application/json',
|
||
data: JSON.stringify({
|
||
designAssyNum: data.field.designAssyNum,
|
||
name: data.field.name,
|
||
remark: data.field.remark,
|
||
createTime: getDatetime(),
|
||
createUserID: CurrUserInfo.data.userid,
|
||
createUserName: CurrUserInfo.data.userName,
|
||
isAnnex: 0,
|
||
isDelete: 0
|
||
}), //参数值
|
||
type: "POST", //请求方式
|
||
success: function (req) {
|
||
//请求成功时处理
|
||
if (req.result.code == 1) {
|
||
if (addBOMDetailsList_ProductionData.length > 0) {
|
||
//获取已保存的BOM主数据ID
|
||
$.ajax({
|
||
url: apiUrl + "/api/services/app/BOM_Production/GetAllBOM_Production", //请求的url地址
|
||
dataType: "json", //返回格式为json
|
||
//async: false,//请求是否异步,默认为异步,这也是ajax重要特性
|
||
data: { DesignAssyNum: data.field.designAssyNum }, //参数值
|
||
type: "GET", //请求方式
|
||
success: function (req) {
|
||
//请求成功时处理
|
||
var BOM_ProductionID = req.result.data[0].id;
|
||
for (let index = 0; index < addBOMDetailsList_ProductionData.length; index++) {
|
||
$.ajax({
|
||
url: apiUrl + "/api/services/app/BOMDetails_Production/CreateBOMDetails_Production", //请求的url地址
|
||
dataType: "json", //返回格式为json
|
||
//async: false,//请求是否异步,默认为异步,这也是ajax重要特性
|
||
contentType: 'application/json',
|
||
data: JSON.stringify({
|
||
boM_ProductionID: BOM_ProductionID,
|
||
accessoryCode: addBOMDetailsList_ProductionData[index].accessoryCode,
|
||
nameAndSpecs: addBOMDetailsList_ProductionData[index].nameAndSpecs,
|
||
materials: addBOMDetailsList_ProductionData[index].materials,
|
||
suppliersName: addBOMDetailsList_ProductionData[index].suppliersName,
|
||
amountOfUnit: addBOMDetailsList_ProductionData[index].amountOfUnit,
|
||
unit: addBOMDetailsList_ProductionData[index].unit,
|
||
price: addBOMDetailsList_ProductionData[index].price,
|
||
amount: addBOMDetailsList_ProductionData[index].amount,
|
||
borrowings: addBOMDetailsList_ProductionData[index].borrowings,
|
||
remark: addBOMDetailsList_ProductionData[index].remark,
|
||
createTime: getDatetime(),
|
||
createUserID: CurrUserInfo.data.userid,
|
||
createUserName: CurrUserInfo.data.userName,
|
||
isAnnex: 0,
|
||
isDelete: 0
|
||
}), //参数值
|
||
type: "POST", //请求方式
|
||
success: function (req) {
|
||
//请求成功时处理
|
||
if (req.result.code == 1) {
|
||
layer.msg('保存成功', { time: 1000 }, function () {
|
||
// 关闭弹出层
|
||
var iframeIndex = parent.layer.getFrameIndex(window.name);
|
||
// 刷新父页面
|
||
window.parent.location.reload();
|
||
parent.layer.close(iframeIndex);
|
||
});
|
||
}
|
||
else if (req.result.code == 2) {
|
||
layer.msg(req.result.msg);
|
||
return false;
|
||
}
|
||
else {
|
||
layer.msg(req.result.msg);
|
||
return false;
|
||
}
|
||
|
||
},
|
||
error: function () {
|
||
/*错误信息处理*/
|
||
layer.msg("BOM子表数据保存失败,请重试!");
|
||
return false;
|
||
},
|
||
});
|
||
|
||
}
|
||
},
|
||
error: function () {
|
||
/*错误信息处理*/
|
||
layer.msg("获取BOM主信息ID失败,请重试!");
|
||
return false;
|
||
},
|
||
});
|
||
}
|
||
else {
|
||
layer.msg('保存成功', { time: 1000 }, function () {
|
||
// 关闭弹出层
|
||
var iframeIndex = parent.layer.getFrameIndex(window.name);
|
||
// 刷新父页面
|
||
window.parent.location.reload();
|
||
parent.layer.close(iframeIndex);
|
||
});
|
||
}
|
||
}
|
||
else if (req.result.code == 2) {
|
||
layer.msg(req.result.msg);
|
||
return false;
|
||
}
|
||
else {
|
||
layer.msg(req.result.msg);
|
||
return false;
|
||
}
|
||
|
||
},
|
||
error: function () {
|
||
/*错误信息处理*/
|
||
layer.msg("保存失败,请重试!2");
|
||
return false;
|
||
},
|
||
});
|
||
return false;
|
||
});
|
||
return false;
|
||
});
|
||
|
||
});
|
||
</script>
|
||
</body>
|
||
|
||
</html> |