万材erp项目
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.
 
 
 
 

756 lines
31 KiB

<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('新增交货排程')" />
<th:block th:include="include :: bootstrap-editable-css"/>
<th:block th:include="include :: datetimepicker-css" />
<link th:href="@{/ajax/libs/select2/select2.css}" rel="stylesheet">
<link th:href="@{/ajax/libs/select2/select2-bootstrap.css}" rel="stylesheet">
<style>
.other-container {
width: 90%;
height: 200px;
margin: auto;
}
h4 {
display: inline-block;
margin-right: 20px;
}
.modal-body{
height: 550px;
}
iframe{
width: 100%;
height: 500px;
frameborder: 0;
border: 0;
display: inline-block;
}
</style>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-deliveryProgressInfo-add">
<div class="form-group">
<label class="col-sm-3 control-label is-required">排程编号:</label>
<div class="col-sm-8">
<input name="deliveryProgressCode" class="form-control" type="text" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">计划天数:</label>
<div class="col-sm-8">
<input name="planDays" class="form-control" type="text" readonly>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">制作日期:</label>
<div class="col-sm-8">
<div class="input-group date">
<input name="produceDate" class="form-control" placeholder="yyyy-MM-dd" type="text">
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">客户代码:</label>
<div class="col-sm-8">
<select name="enterpriseCode" id="enterpriseCode" class="form-control m-b" required>
<option value="">所有</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">客户名称:</label>
<div class="col-sm-8">
<input name="enterpriseName" id="enterpriseName" class="form-control m-b" type="text" required readonly>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">交货厂区:</label>
<div class="col-sm-8">
<input name="deliveryFactory" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">开始日期:</label>
<div class="col-sm-8">
<div class="input-group date">
<input name="beginningDate" class="form-control" placeholder="yyyy-MM-dd" type="text">
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">截止日期:</label>
<div class="col-sm-8">
<div class="input-group date">
<input name="endingDate" class="form-control" placeholder="yyyy-MM-dd" type="text">
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">交货地点:</label>
<div class="col-sm-8">
<input name="deliveryAddress" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">备注内容:</label>
<div class="col-sm-8">
<textarea name="deliveryProgressRemark" class="form-control"></textarea>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">业务人员:</label>
<div class="col-sm-8">
<input name="businessMembers" class="form-control" type="text">
</div>
</div>
<!--<div class="form-group">
<label class="col-sm-3 control-label">确认否:</label>
<div class="col-sm-8">
<select name="confirmOrNot" class="form-control m-b" th:with="type=${@dict.getType('sys_whether')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">确认人:</label>
<div class="col-sm-8">
<input name="confirmPerson" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">确认时间:</label>
<div class="col-sm-8">
<input name="confirmTime" class="form-control" type="text">
</div>
</div>-->
</form>
</div>
<div class="other-container">
<div class="other">
<br>
<hr>
<h4>选择产品信息</h4>
<a class="btn btn-primary" onclick="showProductModal()"><i class="fa fa-plus"></i>&nbsp;选择产品</a>
<a class="btn btn-primary" onclick="showDateAndNumModal()"><i class="fa fa-plus"></i>&nbsp;日期及数量</a>
<div class="col-sm-12 select-table table-striped">
<table id="addProductTable" style="white-space:nowrap"></table>
</div>
</div>
<div class="modal inmodal" id="productInfoModal"
role="dilog" aria-hidden="true">
<!-- 查询成品资料-->
<div class="modal-dialog" style="width: 1000px;background-color: #FFFFFF">
<div class="modal-content" style="background-color: #FFFFFF">
<div class="modal-body">
<div class="container-div">
<div class="row">
<div class="col-sm-12 search-collapse">
<form id="productFormId">
<div class="select-list">
<ul>
<li>
<label>成品代码:</label>
<input type="text" name="finishProductCode"/>
</li>
<li>
<label>成品名称:</label>
<input type="text" name="finishProductName"/>
</li>
<li>
<label>客户代码:</label>
<input type="text" name="enterpriseCode"/>
</li>
<li>
<label>客户名称:</label>
<input type="text" name="enterpriseName"/>
</li>
<li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search('productFormId','productTable')"><i
class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset('productFormId','productTable')"><i
class="fa fa-refresh"></i>&nbsp;重置</a>
</li>
</ul>
</div>
</form>
</div>
<div class="col-sm-12 select-table table-striped">
<table id="productTable" style="white-space:nowrap"></table>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<a class="btn btn-warning btn-rounded" onclick="addProductToTable()">确认添加</a>
<a class="btn btn-primary btn-rounded" onclick="closeProductModal()">关闭</a>
</div>
</div>
</div>
</div>
</div>
<!-- <div class="modal inmodal" id="dateAndNumModal"-->
<!-- role="dilog" aria-hidden="true">-->
<!-- <div class="modal-dialog" style="width: 1000px;background-color: #FFFFFF">-->
<!-- <div class="modal-content" style="background-color: #FFFFFF">-->
<!-- <div class="modal-body">-->
<!-- <div class="col-sm-12 search-collapse">-->
<!-- <form class="form-horizontal m" id="form-dateAndNum-add">-->
<!-- <label class="col-sm-3 control-label is-required">排程编号:</label>-->
<!-- <div class="col-sm-8">-->
<!-- <input name="deliveryProgressCode" class="form-control" type="text" required>-->
<!-- </div>-->
<!-- </form>-->
<!-- </div>-->
<!--&lt;!&ndash; <div class="col-sm-12 select-table table-striped">&ndash;&gt;-->
<!--&lt;!&ndash; <table id="dateAndNumTable" style="white-space:nowrap"></table>&ndash;&gt;-->
<!--&lt;!&ndash; </div>&ndash;&gt;-->
<!-- </div>-->
<!-- <div class="modal-footer">-->
<!-- <a class="btn btn-warning btn-rounded" onclick="addProductToTable()">确认添加</a>-->
<!-- <a class="btn btn-primary btn-rounded" onclick="closeProductModal()">关闭</a>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
<th:block th:include="include :: footer" />
<th:block th:include="include :: select2-js"/>
<th:block th:include="include :: datetimepicker-js"/>
<th:block th:include="include :: bootstrap-table-editable-js"/>
<script th:inline="javascript">
var prefix = ctx + "deliveryProgress/deliveryProgressInfo"
var prefixCustomer = ctx + 'system/customer';
var prefixfinishproduct = ctx + "system/finishproduct";
var inventoryUnitDatas = [[${@dict.getType('sys_unit_class')}]];
var whetherStopDatas = [[${@dict.getType('sys_whether')}]];
var productionCategoryDatas = [[${@dict.getType('sys_production_category')}]];
var finishProductCategoryDatas = [[${@dict.getType('sys_finish_product_category')}]];
var commonCurrencyDatas = [[${@dict.getType('sys_common_currency')}]];
var customerListData = [];
var daysListData = [];
var columnsListData = [];
$("#form-deliveryProgressInfo-add").validate({
focusCleanup: true
});
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/add", $('#form-deliveryProgressInfo-add').serialize());
}
}
$("input[name='produceDate']").datetimepicker({
format: "yyyy-mm-dd",
minView: "month",
autoclose: true,
todayBtn: true
});
$("input[name='beginningDate']").datetimepicker({
format: "yyyy-mm-dd",
minView: "month",
autoclose: true,
todayBtn: true
});
$("input[name='endingDate']").datetimepicker({
format: "yyyy-mm-dd",
minView: "month",
autoclose: true,
todayBtn: true
});
$("input[name='produceDate']").datetimepicker('setDate',new Date())
$("input[name='beginningDate']").datetimepicker('setDate',new Date())
$("input[name='endingDate']").datetimepicker('setDate',new Date(getLaterDate(15,new Date())))
//某日期之后几天的日期
function getLaterDate(dayNum, dateTime = null) {
// 如果为null,则格式化当前时间为时间戳
if (!dateTime) dateTime = +new Date();
// 如果dateTime长度为10或者13,则为秒和毫秒的时间戳,如果超过13位,则为其他的时间格式
if (dateTime.toString().length == 10) dateTime *= 1000;
const timestamp = +new Date(Number(dateTime));
const one_day = 86400000; // 24 * 60 * 60 * 1000;
const addVal = dayNum * one_day + timestamp;
//x天后的日期
const date = new Date(addVal);
//格式化日期
const filters = n => {
return n < 10 ? (n = '0' + n) : n;
};
const month = filters(date.getMonth() + 1);
const day = filters(date.getDate());
const hours = filters(date.getHours());
const minutes = filters(date.getMinutes());
const seconds = filters(date.getSeconds());
const lastTime = `${date.getFullYear()}/${month}/${day} ${hours}:${minutes}:${seconds}`;
return lastTime;
}
$(function () {
//初始化添加产品表
initAddProductTable();
//显示产品信息
showProductData();
//计划天数的显示
getPlanDays();
})
//客户信息
$.ajax({
url: prefixCustomer + '/list',
type: "post",
success: function (res) {
if (res.rows.length > 0) {
customerListData = res.rows;
for (let i in customerListData) {
$("select[name='enterpriseCode']").append("<option value='" + customerListData[i].enterpriseCode + "'>" + customerListData[i].enterpriseCode + "</option>");
// $("select[name='enterpriseName']").append("<option value='" + customerListData[i].enterpriseName + "'>" + customerListData[i].enterpriseName + "</option>");
}
} else {
$.modal.msgError(res.msg);
}
},
error: function () {
$.modal.msgError("后台出错啦!");
}
})
//填入客户信息
$("select[name='enterpriseCode']").change(function () {
var enterpriseCode = $(this).val();
for (i = 0; i < customerListData.length; i++) {
if (customerListData[i].enterpriseCode === enterpriseCode) {
$("#enterpriseName").val(customerListData[i].enterpriseName)
$("input[name='deliveryAddress']").val(customerListData[i].deliveryAddress)
}
}
})
var userName = [[${@permission.getPrincipalProperty('userName')}]];
$("input[name='businessMembers']").val(userName)
//计划天数的显示
function getPlanDays() {
var beginningDate = $("input[name='beginningDate']").val()
var endingDate = $("input[name='endingDate']").val()
$("input[name='planDays']").val(getDaysMinus(beginningDate,endingDate))
}
$("input[name='beginningDate']").change(function (){
let beginningDate = $("input[name='beginningDate']").val()
let endingDate = $("input[name='endingDate']").val()
let days = getDaysMinus(beginningDate,endingDate)
$("input[name='planDays']").val(days)
getDuringDate();
getDateColumns(daysListData);
$("#addProductTable").bootstrapTable('refresh');
})
$("input[name='endingDate']").change(function (){
let beginningDate = $("input[name='beginningDate']").val()
let endingDate = $("input[name='endingDate']").val()
let days = getDaysMinus(beginningDate,endingDate)
$("input[name='planDays']").val(days)
getDuringDate();
getDateColumns(daysListData);
console.log(columnsListData)
$("#addProductTable").bootstrapTable('refresh');
})
//计算时间差的天数
function getDaysMinus(beginningDate,endingDate) {
let time = (new Date(endingDate)).getTime() - (new Date(beginningDate)).getTime()
let days = parseInt(time/(1000 * 60 * 60 * 24))
return days+1
}
//转换时间方法
function getDate(date){
//date是传过来的时间戳,注意需为13位,10位需*1000
//也可以不传,获取的就是当前时间
var time = new Date(date);
var year= time.getFullYear() //年
var month = ("0" + (time.getMonth() + 1)).slice(-2); //月
var day = ("0" + time.getDate()).slice(-2); //日
var mydate = year + "-" + month + "-" + day;
return mydate
}
//初始化添加产品表
function initAddProductTable() {
getDuringDate();
console.log(daysListData)
getDateColumns(daysListData);
console.log(columnsListData)
$('#addProductTable').bootstrapTable({
pagination: true,
pageNumber: 1,
pageSize: 10,
showToggle: false, // 是否显示详细视图和列表视图的切换按钮
cardView: false, // 是否显示详细视图
detailView: false, // 是否显示父子表
smartDisplay: false, // 加了这个才显示每页显示的行数
showExport: false, // 是否显示导出按钮
clickToSelect: true,//点击行选中
paginationDetailHAlign: ' hiddenDetailInfo',
height: 250,
uniqueId: 'finishProductCode',
queryParams: function (params) {
//console.log("123");
var curParams = {
// 传递参数查询参数
pageSize: params.limit,
pageNum: params.offset / params.limit + 1,
// enterpriseCode: data[0].enterpriseCode
};
// console.log(data[0].enterpriseCode)
return curParams
},
columns: columnsListData
})
}
//获取开始-截止时间的日期list
function getDuringDate() {
var dateListData = []
getPlanDays();
var totalDate = $("input[name='planDays']").val()
for (var i = 0;i<totalDate;i++){
dateListData.push(getDate(new Date(getLaterDate(i,new Date()))))
}
daysListData = [...dateListData]
}
//表内日期列获取
function getDateColumns(daysListData) {
var columnsList = []
columnsList.push({
field: 'finishProductCode',
title: '成品代码'
});
columnsList.push({
field: 'finishProductName',
title: '成品名称'
});
columnsList.push({
field: 'specificationModel',
title: '规格型号'
});
columnsList.push({
field: 'typeMachine',
title: '机种'
});
columnsList.push({
field: 'inventoryUnit',
title: '单位',
formatter: function (value, row, index) {
return $.table.selectDictLabel(inventoryUnitDatas, value);
}
});
for (let i = 0;i<daysListData.length;i++) {
columnsList.push({
field: 'date',
title: daysListData[i]
// editable: {
// type: 'text',
// title: '数量',
// emptytext: '数量',
// validate: function (v) {
// if (isNaN(v)) return '数量必须是数字';
// var ex = /^[1-9]\d*$/;
// if (!ex.test(v)) return '数量必须是正整数';
// }
// }
})
}
columnsListData = [...columnsList]
}
//显示产品信息
function showProductData() {
var options = {
id: 'productTable',
url: prefixfinishproduct + "/list",
showRefresh: false,
showToggle: false,
clickToSelect: true,
modalName: "产品资料",
columns: [{
checkbox: true
},
{
field: 'finishProductId',
title: '成品id',
visible: false
},
{
field: 'customerNumber',
title: '客户料号'
},
{
field: 'typeMachine',
title: '机种'
},
{
field: 'finishProductName',
title: '成品名称'
},
{
field: 'enterpriseCode',
title: '客户代码'
},
{
field: 'enterpriseName',
title: '客户名称'
},
{
field: 'inventoryUnit',
title: '库存单位',
formatter: function(value, row, index) {
return $.table.selectDictLabel(inventoryUnitDatas, value);
},
visible: false
},
{
field: 'versionNumber',
title: '版本号'
},
{
field: 'finishProductCode',
title: '成品代码'
},
{
field: 'safetyStock',
title: '安全库存',
visible: false
},
{
field: 'stockUnitWeight',
title: '单位重量',
visible: false
},
{
field: 'gpItemSelection',
title: 'GP项选择',
formatter: function(value, row, index) {
return $.table.selectDictLabel(gpItemSelectionDatas, value);
},
visible: false
},
{
field: 'inPlantCode',
title: '厂内编码'
},
{
field: 'whetherStop',
title: '料号是否停用',
formatter: function(value, row, index) {
return $.table.selectDictLabel(whetherStopDatas, value);
}
},
{
field: 'createrName',
title: '创建人',
visible: false
},
{
field: 'ordinalName',
title: '半成品对应完工工序名',
visible: false
},
{
field: 'originalNumber',
title: '原成品料号',
visible: false
},
{
field: 'customsName',
title: '海关名称',
visible: false
},
{
field: 'defaultWarehouse',
title: '默认仓库'
},
{
field: 'materialCategory',
title: '类别',
formatter: function(value, row, index) {
return $.table.selectDictLabel(materialCategoryDatas, value);
},
visible: false
},
{
field: 'productionCategory',
title: '生产类别',
formatter: function(value, row, index) {
return $.table.selectDictLabel(productionCategoryDatas, value);
}
},
{
field: 'finishProductCategory',
title: '所属类别',
formatter: function(value, row, index) {
return $.table.selectDictLabel(finishProductCategoryDatas, value);
}
},
{
field: 'specificationModel',
title: '规格型号'
},
{
field: 'customerEngineer',
title: '客户工程师'
},
{
field: 'productDescription',
title: '产品描述',
visible: false
},
{
field: 'maximumInventory',
title: '最高库存',
visible: false
},
{
field: 'productPrice',
title: '产品售价',
visible: false
},
{
field: 'componentName',
title: '组件名称',
visible: false
},
{
field: 'createrTime',
title: '创建日期',
visible: false
},
{
field: 'ordinalNumber',
title: '半成品对应完工工序号',
visible: false
},
{
field: 'defaultLocation',
title: '默认位置',
visible: false
},
{
field: 'hsNumber',
title: 'HS号',
visible: false
},
{
field: 'kesNumber',
title: '科恩仕料号'
}]
};
$.table.init(options);
}
/*产品内容*/
//点击按钮显示产品信息模态框
function showProductModal() {
if ($.validate.form()) {
$("#productInfoModal").modal("show");
} else {
$.modal.alertWarning("请填写必填项");
}
}
//关闭产品信息模态框
function closeProductModal() {
$("#productInfoModal").modal("hide");
}
//表中添加选中的产品信息
function addProductToTable() {
var data = $("#productTable").bootstrapTable("getSelections");
var count = $('#addProductTable').bootstrapTable('getData').length;
var deliveryProgressCode = $("input[name='deliveryProgressCode']").val();
var enterpriseCode = $("input[name='enterpriseCode']").val();
var enterpriseName = $("input[name='enterpriseName']").val();
for (i = 0; i < data.length; i++) {
let finishProduct = $('#addProductTable').bootstrapTable('getRowByUniqueId', data[i].finishProductCode);
if (finishProduct != null) {
alert(finishProduct.finishProductName + "已存在,不可重复添加!");
continue;
}
$("#addProductTable").bootstrapTable('insertRow', {
index: count + i,
row: {
deliveryProgressCode: deliveryProgressCode,
enterpriseCode: enterpriseCode,
enterpriseName: enterpriseName,
finishProductCode: data[i].finishProductCode,
finishProductName: data[i].finishProductName,
specificationModel: data[i].specificationModel,
typeMachine: data[i].typeMachine,
inventoryUnit: data[i].inventoryUnit
}
});
}
$("#productTable").bootstrapTable("uncheckAll");
closeProductModal();
}
function showDateAndNumModal() {
$("#dateAndNumModal").modal("show");
}
</script>
</body>
</html>