<!DOCTYPE HTML>
|
<html xmlns:th="http://www.thymeleaf.org">
|
<head>
|
<meta charset="utf-8">
|
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
|
<meta name="renderer" content="webkit|ie-comp|ie-stand">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
<meta name="viewport"
|
content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
|
<meta http-equiv="Cache-Control" content="no-siteapp"/>
|
<!-- 本框架基本脚本和样式 -->
|
<script type="text/javascript"
|
th:src="@{/js/plugin/jquery-2.1.4.min.js}"></script>
|
<script type="text/javascript" th:src="@{/js/systools/MBase.js}"></script>
|
</head>
|
<body>
|
<div class="ibox-content">
|
<form class="form-horizontal" id="dataform"
|
onsubmit="javascripr:return false;">
|
|
<input autocomplete="off" type="hidden" name="id" th:value="${obj?.id}">
|
|
<div class="form-group">
|
<label class="col-offset-1 col-sm-2 control-label">入库类型<span
|
class="text-danger">*</span></label>
|
<div class="col-sm-3">
|
<select class="form-control autoFull" name="instoreType"
|
id="instoreType" data-filed="name" data-value="name"
|
th:data-url="@{/admin/dataDictionary/showDataDictionary}"
|
data-param="{type:'入库类型'}" th:data-def="${obj?.instoreType}"
|
datatype="*" nullmsg="入库类型不能为空">
|
<option value=''>--请选择入库类型--</option>
|
</select>
|
<div class="Validform_checktip"></div>
|
</div>
|
<label class="col-sm-2 control-label">创建时间<span
|
class="text-danger">*</span></label>
|
<div class="col-sm-3">
|
<input autocomplete="off" type="text" class="form-control datetimepicker"
|
name="instoreDate" readonly="readonly"
|
th:value="${#dates.format(obj==null?(new java.util.Date().getTime()):obj?.instoreDate ,'yyyy-MM-dd HH:mm:ss')}"
|
datatype="*" nullmsg="入库日期不能为空" data-formatter="MGrid.getTime">
|
<div class="Validform_checktip"></div>
|
</div>
|
</div>
|
|
<div class="form-group">
|
<label class="col-sm-2 control-label">制单人</label>
|
|
<div class="col-sm-3" th:if="${obj} eq null" >
|
<input autocomplete="off" type="text" th:value="${session.userInfo.suName}" name="makingmanName" class="form-control" readonly="readonly">
|
<input autocomplete="off" type="hidden" th:value="${session.userInfo.suId}" name="makingmanId" id="makingmanId">
|
</div>
|
|
<div class="col-sm-3 " th:if="${obj} ne null " >
|
<input autocomplete="off" type="text" th:value="${obj?.makingmanName}" name="makingmanName" class="form-control " readonly="readonly">
|
<input autocomplete="off" type="hidden" th:value="${obj?.makingmanId}" name="makingmanId" id="makingmanId">
|
</div>
|
|
<label class="col-sm-2 control-label" th:if="${obj} ne null">审核人<span
|
class="text-danger">*</span></label>
|
<div class="col-sm-3" th:if="${obj} ne null">
|
<!-- <select class="form-control autoFull" name="appmanId" id="appmanId"-->
|
<!-- data-filed="suName"-->
|
<!-- th:data-url="@{/admin/getShopStaffByRoleName?roleName=仓储主管}"-->
|
<!-- th:data-value="suId"-->
|
<!-- th:data-def="${obj?.appmanId}"-->
|
<!-- datatype="*" nullmsg="审核人不能为空">-->
|
<!-- <option value=''>--请选择审核人--</option>-->
|
<!-- </select>-->
|
<!-- <div class="Validform_checktip"></div>-->
|
|
<input autocomplete="off" type="text" th:value="${obj?.appmanName}" name="appmanName" class="form-control " readonly="readonly">
|
<input autocomplete="off" type="hidden" th:value="${obj?.appmanId}" name="appmanId" id="appmanId">
|
</div>
|
</div>
|
|
<div class="form-group">
|
<label class="col-sm-2 control-label">往来单位<span
|
class="text-danger">*</span></label>
|
<div class="col-sm-3">
|
<select class="form-control autoFull" name="supplierId"
|
id="supplierId" data-filed="supplName"
|
th:data-url="@{/admin/supplier/all}" th:data-def="${obj?.supplierId}"
|
datatype="*" nullmsg="往来单位不能为空">
|
<option value=''>--请选择往来单位--</option>
|
</select>
|
<div class="Validform_checktip"></div>
|
</div>
|
|
|
</div>
|
|
<div class="form-group">
|
<label class="col-sm-2 control-label">备注</label>
|
<div class="col-sm-3">
|
<textarea type="text" dataType="*1-500" ignore="ignore"
|
class="form-control" name="remark" errormsg="备注不能超过500" th:text="${obj?.remark}"></textarea>
|
<div class="Validform_checktip"></div>
|
</div>
|
</div>
|
<div class="form-group">
|
<label class="col-sm-2 control-label">入库仓库<span
|
class="text-danger">*</span></label>
|
<div class="col-sm-3">
|
<select class="form-control autoFull" data-filed="name"
|
name="storeId" dataType="*" errormsg="请选择入库仓库"
|
th:data-url="@{/admin/warehouse/findSingleShopWarehouse}" th:data-def="${obj?.storeId}">
|
<option value="">-- 请选择所属仓库--</option>
|
</select>
|
</div>
|
|
<label class="col-sm-2 control-label">总价</label>
|
<div class="col-sm-3">
|
<input autocomplete="off" type="text" class="form-control" id="sumall"
|
readonly="readonly" th:value="${obj?.sumall}">
|
<div class="Validform_checktip"></div>
|
</div>
|
</div>
|
<div class="form-group">
|
<label class="col-sm-2 control-label">入库明细 <span
|
class="text-danger">*</span></label>
|
<div class="col-sm-3">
|
<button class="btn btn-success btn-sm" onclick="openPruductList()"
|
type="button">添加明细单
|
</button>
|
</div>
|
</div>
|
<div class="form-group">
|
<div class="col-sm-8 col-md-offset-2">
|
<table class="table table-striped table-hover table-bordered"
|
id="mgrid">
|
<thead>
|
<tr>
|
<th>序号</th>
|
<th>产品编码</th>
|
<th>产品名称</th>
|
<th>产品类型</th>
|
<th>存货单位</th>
|
<th width="120">数量 <span class="text-danger">*</span></th>
|
<th width="120">采购单价 <span class="text-danger">*</span></th>
|
<th>总金额</th>
|
<th>操作</th>
|
</tr>
|
</thead>
|
<tbody id="cpId">
|
|
</tbody>
|
|
</table>
|
</div>
|
</div>
|
|
<div class="form-group ">
|
<div class="col-sm-12 text-center fixed-button">
|
<a href="javascript:;" onclick="myForm.submit()"
|
class="btn btn-success radius"><i class="fa fa-check"></i> 保存</a>
|
<a class="btn btn-danger radius" href="javascript:;"
|
onclick="MTools.closeForm()"><i class="fa fa-close"></i> 关闭</a>
|
</div>
|
</div>
|
</form>
|
</div>
|
</body>
|
|
|
<script type="text/javascript" th:src="@{/js/systools/MJsBase.js}"></script>
|
|
<script>
|
var readInitData=function(){};
|
|
</script>
|
<script th:if="${obj} ne null" th:inline="javascript" >
|
|
//初始化产品列表
|
readInitData=function() {
|
/*<![CDATA[*/
|
var projItems=/*[[${obj.instoreDetails}]]*/
|
/*]]>*/
|
for(var i =0; i<projItems.length; i++){
|
var obj = new Object();
|
var goods = new Object();
|
var projItem=projItems[i];
|
debugger
|
obj.goodsSortName = projItem.goods.goodsSortName;
|
obj.unit = projItem.goods.unit;
|
obj.name = projItem.goods.name;
|
obj.goodsNo = projItem.goods.goodsNo;
|
obj.id = projItem.goods.id;
|
obj.purchsePrice = projItem.price;
|
obj.sum =projItem.amount;
|
obj.totalMoney =projItem.amount;
|
obj.totalMoney = obj.totalMoney*projItem.price;
|
totalGoods[i] = obj;
|
};
|
}
|
|
|
</script>
|
|
<script th:inline="javascript">
|
var goodsAttr = '';
|
var totalGoods = [];
|
//初始化时间格式
|
|
|
$(".datetimepicker").datetimepicker({
|
format: 'yyyy-mm-dd hh:ii',
|
todayBtn: true,
|
autoclose: true,
|
startView: 2,
|
maxView: 3,
|
minView: 0
|
|
})
|
//初始化select
|
MTools.autoFullSelect();
|
//初始化数据
|
readInitData();
|
writeDate();
|
var myForm = MForm.initForm({
|
beforeSubmit: function () {
|
var bodyTrs = $("#cpId").find("tr");
|
if (bodyTrs.length == 0) {
|
layer.msg("请添加明细", {icon: 2});
|
return false;
|
}
|
},
|
invokeUrl: basePath+"/admin/instore/addOrModify",
|
afterSubmit: function () {
|
parent.myGrid.serchData();
|
},
|
});
|
|
|
|
|
//打开产品界面
|
function openPruductList() {
|
//获取所选择 的产品属性,传递给选择页面
|
goodsAttr = $("#instoreType").val();
|
if (goodsAttr == '') {
|
layer.msg("请选择入库类型", {icon: 2});
|
return false;
|
}
|
layer.open({
|
type: 2,
|
title: "选择产品",
|
area: MUI.SIZE_M,
|
content: [basePath+'/admin/redirect/hive/products/select-products-list?goodsAttr=' + encodeURI(goodsAttr)]
|
});
|
}
|
|
//监听所选择的产品类型,切换类型则要清空原来的产品列表
|
$("#instoreType").change(function () {
|
totalGoods = [];
|
$("#cpId").html('');
|
});
|
|
//添加产品回调
|
function callback(arr) {
|
console.log(arr);
|
removeDouble(arr);
|
writeDate();
|
}
|
|
//赋值或者去重复
|
function removeDouble(arr) {
|
if (totalGoods == null) {
|
totalGoods = arr;
|
} else {
|
//去重
|
for (var i = 0; i < arr.length; i++) {
|
var isDouble = false;
|
for (var j = 0; j < totalGoods.length; j++) {
|
if (arr[i].id == totalGoods[j].id) {
|
isDouble = true;
|
break;
|
}
|
}
|
//如果不重复
|
if (!isDouble) {
|
totalGoods[totalGoods.length] = arr[i];
|
}
|
}
|
}
|
}
|
|
//删除选中的元素
|
function delSelectItem(node, id) {
|
//根据列表的id找到元素相应下表的元素
|
for (var i = 0; i < totalGoods.length; i++) {
|
if (totalGoods[i].id == id) {
|
totalGoods.splice(i, 1);
|
break;
|
|
}
|
}
|
//移除tr
|
$(node).closest('tr').remove();
|
$("tbody").find("tr").each(function (i) {
|
$(this).find("td").eq(0).html(i + 1);
|
});
|
}
|
|
//填写数据到html
|
function writeDate() {
|
var html = "";
|
for (var i = 0; i < totalGoods.length; i++) {
|
if (!totalGoods[i].sum) {
|
totalGoods[i].sum = "";
|
}
|
if (!totalGoods[i].purchsePrice) {
|
totalGoods[i].purchsePrice = "";
|
}
|
if (totalGoods[i].totalMoney == null) {
|
totalGoods[i].totalMoney = "0";
|
}
|
html += '<tr>'
|
+ '<td>' + (i + 1) + '</td>'
|
+ '<td>' + totalGoods[i].code + '</td>'
|
+ '<td>' + totalGoods[i].name + '<input autocomplete="off" type="hidden" name="instoreDetails[' + i + '].skuId" value="' + totalGoods[i].id + '"></td>'
|
+ '<td>' + totalGoods[i].goodsSortName + '</td>'
|
+ '<td>' + totalGoods[i].unit + '</td>'
|
+ '<td><input autocomplete="off" id="amount' + i + '" name="instoreDetails[' + i + '].amount" type="text" onblur="calculateTotalPrice(' + i + ')" dataType="n" nullmsg="请填写数量" errormsg="请填写数字" class="form-control moeny" value="' + totalGoods[i].sum + '"><div class="Validform_checktip"></div></td>'
|
+ '<td><input autocomplete="off" id="price' + i + '" name="instoreDetails[' + i + '].price" type="text" onblur="calculateTotalPrice(' + i + ')" dataType="price" nullmsg="请填写成本价" errormsg="请填写数字" class="form-control moeny" value="' + totalGoods[i].purchsePrice + '"><div class="Validform_checktip"></div></td>'
|
+ '<td id="sum' + i + '">' + totalGoods[i].totalMoney + '</td>'
|
+ '<td class="center"><a style="text-decoration: none" class="fa fa-trash" onClick="delSelectItem(this,' + totalGoods[i].id + ')" href="javascript:;" title="删除"></a></td>'
|
+ '</tr>';
|
}
|
$("#cpId").html(html);
|
}
|
|
//自动计算总价
|
function calculateTotalPrice(i) {
|
var totalMoney = Number(0);
|
if ($("#cpId").html() == '') {
|
layer.alert('请先添加明细单', {icon: 5}, function (index) {
|
layer.close(index);
|
});
|
return false;
|
}
|
$("#cpId").find("tr").each(function (i) {
|
|
var p = Number($(this).find("input").eq(1).val());
|
var n = Number($(this).find("input").eq(2).val());
|
if (p != '' && n != '') {
|
totalMoney = totalMoney+(n*p);
|
}
|
});
|
$("#sumall").val(totalMoney);
|
if ($("#amount" + i).val() != '' && $("#price" + i).val() != '') {
|
var n = Number($("#amount" + i).val());
|
var p = Number($("#price" + i).val());
|
$("#sum" + i).text(n*p);
|
}
|
|
}
|
|
</script>
|
</body>
|
</html>
|