You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
242 lines
10 KiB
242 lines
10 KiB
11 months ago
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||
|
<head>
|
||
|
<meta 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" />
|
||
|
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
|
||
|
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||
|
<meta name="format-detection" content="telephone=no" />
|
||
|
|
||
|
<link rel="stylesheet" href="../../layui/css/layui.css" media="all" />
|
||
|
<link rel="stylesheet" href="../../css/public.css" media="all" />
|
||
|
<script type="text/javascript" src="../../js/jquery-2.1.3.min.js"></script>
|
||
|
<script type="text/javascript" src="../../js/jq_extend.js"></script>
|
||
|
<style type="text/css">
|
||
|
.lab {
|
||
|
width: 60px;
|
||
|
}
|
||
|
|
||
|
.divVal {
|
||
|
margin-left: 100px;
|
||
|
}
|
||
|
|
||
|
.divDel {
|
||
|
cursor: pointer;
|
||
|
}
|
||
|
</style>
|
||
|
</head>
|
||
|
<body class="childrenBody">
|
||
|
<br />
|
||
|
<form class="layui-form" style="width: 60%;margin-left: 20%">
|
||
|
<input class="layui-input CarNum" type="hidden" />
|
||
|
<input class="layui-input CarId" type="hidden" />
|
||
|
<input class="layui-input OrgId" type="hidden" />
|
||
|
<div id="divTbl">
|
||
|
<div class="layui-row">
|
||
|
<div class="layui-col-xs11">
|
||
|
<div class="layui-col-xs6">
|
||
|
<div class="layui-form-item layui-row layui-col-xs12">
|
||
|
<label class="layui-form-label label-required-next lab">
|
||
|
装备名称
|
||
|
</label>
|
||
|
<div class="layui-input-block divVal">
|
||
|
<select lay-filter="EquList" class="EquList" lay-search="" lay-verify="required">
|
||
|
<option value="">---请选择---</option>
|
||
|
</select>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="layui-col-xs6">
|
||
|
<div class="layui-form-item layui-row layui-col-xs12">
|
||
|
<label class="layui-form-label label-required-next lab">
|
||
|
车载数量
|
||
|
</label>
|
||
|
<div class="layui-input-block divVal">
|
||
|
<input type="number" class="layui-input CZ_NUM" placeholder="车载数量" autocomplete="off" lay-verify="required" value="1" />
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="layui-col-xs1">
|
||
|
<label class="layui-form-label divDel">
|
||
|
<i class="layui-icon layui-icon-close"></i>移除
|
||
|
</label>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="layui-center" style="cursor:pointer; margin:10px 0px 10px 0px;" id="addRowDiv">
|
||
|
<i class="layui-icon layui-icon-add-1"></i>添加一行
|
||
|
</div>
|
||
|
|
||
|
<div class="layui-center">
|
||
|
<a class="layui-btn layui-btn-normal addNews_btn" lay-filter="AddEdit" lay-submit=lay-submit>提交</a>
|
||
|
</div>
|
||
|
</form>
|
||
|
<script type="text/javascript" src="../../layui/layui.js"></script>
|
||
|
<script>
|
||
|
layui.use(['form', 'layer', 'table', 'laydate'], function () {
|
||
|
var form = layui.form,
|
||
|
layer = parent.layer === undefined ? layui.layer : top.layer,
|
||
|
$ = layui.jquery;
|
||
|
var OrgId = JSON.parse(window.sessionStorage.getItem("userInfo")).OrgID;
|
||
|
var org_id = $.getUrlVar("org_id")
|
||
|
if (org_id != null && org_id != "") {
|
||
|
OrgId = org_id;
|
||
|
}
|
||
|
var editOrgId = $(".OrgId").val();
|
||
|
if (editOrgId != null && editOrgId != "") {
|
||
|
OrgId = editOrgId;
|
||
|
}
|
||
|
|
||
|
//消防装备 下拉框
|
||
|
$.ajax({
|
||
|
type: "post",
|
||
|
url: "../../ashx/FireEpuHandler.ashx",
|
||
|
data: {
|
||
|
Action: "getEquipmentListByOrgId",
|
||
|
OrgId: OrgId,
|
||
|
random: new Date().getTime() //随机参数
|
||
|
},
|
||
|
async: false,
|
||
|
dataType: "json",
|
||
|
success: function (res) {
|
||
|
if (res && res.data) {
|
||
|
var EquList = "";
|
||
|
res.data.forEach(function (obj, index, arr) {
|
||
|
EquList += "<option value='" + obj.ID + "'>" + obj.DETAIL_NAME + "(现有库存:" + obj.KC_NUM + ")</option>";
|
||
|
});
|
||
|
$(".EquList").append(EquList);
|
||
|
form.render('select');
|
||
|
}
|
||
|
},
|
||
|
});
|
||
|
|
||
|
//初始化装备数据
|
||
|
var initEpu = function () {
|
||
|
$.ajax({
|
||
|
type: "post",
|
||
|
url: "../../ashx/FireEpuHandler.ashx",
|
||
|
data: {
|
||
|
Action: "getFireEpuipCarListByCarId",
|
||
|
CarId: $(".CarId").val(),
|
||
|
OrgId: OrgId,
|
||
|
random: new Date().getTime() //随机参数
|
||
|
},
|
||
|
dataType: "json",
|
||
|
success: function (res) {
|
||
|
if (res && res.data) {
|
||
|
res.data.forEach(function (obj, index, arr) {
|
||
|
if (index > 0) {
|
||
|
$("#divTbl").append('<div class="layui-row">' + $("#divTbl").children().first().html() + '</div>');
|
||
|
form.render('select');
|
||
|
}
|
||
|
});
|
||
|
setTimeout(function () {
|
||
|
$(".CZ_NUM").each(function (i, n) {
|
||
|
$(this).val(res.data[i].NUM);
|
||
|
$(this).parent().parent().parent().prev().children().first().children().first().next().children().first().val(res.data[i].EPU_ID);
|
||
|
form.render('select');
|
||
|
});
|
||
|
}, 500)
|
||
|
}
|
||
|
},
|
||
|
});
|
||
|
}
|
||
|
setTimeout(initEpu(), 500)
|
||
|
|
||
|
form.on("submit(AddEdit)", function (data) {
|
||
|
//load提交
|
||
|
var msgIndex = layer.msg('数据提交中,请稍候', { icon: 16, time: false, shade: 0.8 });
|
||
|
var addEpu = [];
|
||
|
var carId = $(".CarId").val();
|
||
|
var carNum = $(".CarNum").val();
|
||
|
$(".CZ_NUM").each(function (i, n) {
|
||
|
//装备名称
|
||
|
var czNum = $(this).val();
|
||
|
var obj = $(this).parent().parent().parent();
|
||
|
var epuId = obj.prev().children().first().children().first().next().children().first().find("option:selected").val();
|
||
|
var epuName = obj.prev().children().first().children().first().next().children().first().find("option:selected").text().split("(现有库存:")[0];
|
||
|
addEpu.push({
|
||
|
EPU_ID: epuId,
|
||
|
EPU_NAME: epuName,
|
||
|
NUM: czNum
|
||
|
});
|
||
|
});
|
||
|
|
||
|
//id相同,数量相加
|
||
|
const newArr = addEpu.reduce((accumulator, currentItem) => {
|
||
|
const existingItem = accumulator.find(item => item.EPU_ID === currentItem.EPU_ID);
|
||
|
if (existingItem) {
|
||
|
existingItem.NUM = parseInt(existingItem.NUM) + parseInt(currentItem.NUM);
|
||
|
} else {
|
||
|
accumulator.push({ ...currentItem });
|
||
|
}
|
||
|
return accumulator;
|
||
|
}, []);
|
||
|
|
||
|
var arrStr = JSON.stringify(newArr);
|
||
|
|
||
|
$.post("../../ashx/FireEpuHandler.ashx", {
|
||
|
Action: "AddFireEpuipCar",
|
||
|
carId: carId,
|
||
|
carNum: carNum,
|
||
|
orgId: OrgId,
|
||
|
arrStr: arrStr,
|
||
|
random: new Date().getTime()//随机参数
|
||
|
}, function (res) {
|
||
|
res = $.parseJSON(res);
|
||
|
if (res.code == 1) {
|
||
|
top.layer.msg(res.msg);
|
||
|
var index = parent.layer.getFrameIndex(window.name);
|
||
|
parent.layer.close(index);
|
||
|
} else {
|
||
|
layer.close(msgIndex);
|
||
|
var openIndex = layer.open({
|
||
|
type: 1,
|
||
|
offset: '4',
|
||
|
btn: '关闭窗口',
|
||
|
content: '<div style="padding: 20px">' + res.errorStr + '</div>',
|
||
|
yes: function () {
|
||
|
initEpu();
|
||
|
layer.close(openIndex);
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
});
|
||
|
return false;
|
||
|
})
|
||
|
|
||
|
//删除一行
|
||
|
$(document).on("click", ".divDel", function () {
|
||
|
//console.log($("#divTbl").children().length);
|
||
|
var delObj = $(this).parent().parent();
|
||
|
layer.confirm('是否删除?', {
|
||
|
title: '信息确认',
|
||
|
btn: ['确定', '取消'],
|
||
|
shade: false //不显示遮罩
|
||
|
}, function (index) {
|
||
|
if ($("#divTbl").children().length > 1) {
|
||
|
delObj.remove();
|
||
|
}
|
||
|
layer.close(index);
|
||
|
});
|
||
|
|
||
|
});
|
||
|
//添加一行
|
||
|
$("#addRowDiv").click(function () {
|
||
|
$("#divTbl").append('<div class="layui-row">' + $("#divTbl").children().first().html() + '</div>');
|
||
|
form.render('select');
|
||
|
});
|
||
|
|
||
|
})
|
||
|
</script>
|
||
|
<link rel="stylesheet" href="../../css/right-list.css" media="all" />
|
||
|
<link rel="stylesheet" href="../../css/bulletframebg.css" media="all" />
|
||
|
<link rel="stylesheet" href="../../css/bulletframe.css" media="all" />
|
||
|
|
||
|
</body>
|
||
|
</html>
|