提交 c06b9ba7 编写于 作者: doc_wei's avatar doc_wei

feat: 加工单甘特图

上级 a6b58b65
// 已经选择的资产集合key:表格的行trId,value:资产信息
// 改
var allChooseFarm = {};
layui.config({
base: basePath,
version: skyeyeVersion
}).extend({
window: 'js/winui.window'
}).define(['window', 'table','jquery', 'winui', 'form'], function (exports) {
}).define(['window', 'jquery', 'winui', 'form', 'laydate'], function (exports) {
winui.renderColor();
var index = parent.layer.getFrameIndex(window.name);
var $ = layui.$,
form = layui.form,
table = layui.table;
// var selTemplate = getFileContent('tpl/template/select-option.tpl');
let farmId = getNotUndefinedVal(GetUrlParam("id"));
// 改
// let assetMap = {};
laydate = layui.laydate;
var selTemplate = getFileContent('tpl/template/select-option.tpl');
var id = GetUrlParam("id");
initTableChooseUtil.initTable({
id: "arrangeList",
cols: [
{id: 'workshopId', title: '安排车间', formType: 'select', width: '150', verify: 'required',templet: function(d) {
var options = queryWorkshopList();
return '<select name="workshop" class="workshop-select">' + options + '</select>';
}
},
{id: 'taskNumber', title: '安排任务数量', formType: 'input', width: '140', verify: 'required|number'}
],
deleteRowCallback: function (trcusid) {
delete allChooseFarm[trcusid];
},
addRowCallback: function (trcusid) {
// if (!isNull(farmId)) {
// if (isNull(assetMap[farmId])) {
// AjaxPostUtil.request({url: sysMainMation.admBasePath + "queryAssetById", params: {"id": farmId}, type: 'json', method: 'GET', callback: function (json) {
// assetMap[farmId] = json.bean
// }, async: false});
// }
// let chooseAssetMation = assetMap[farmId]
// // 获取表格行号
// var thisRowKey = trcusid.replace("tr", "");
// // 资产名称赋值
// $("#farmId" + thisRowKey).val(chooseAssetMation.name);
// $("#farmId" + thisRowKey).attr(initTableChooseUtil.chooseInputDataIdKey, chooseAssetMation.id);
// // 资产赋值
// allChooseFarm[trcusid] = chooseAssetMation;
// }
},
form: form,
minData: 1
});
//
// var workshopId = "";
// form.on('select(workshopId)', function(data) {
// console.log(555,data)
// // var thisRowValue = data.value;
// // workshopId = isNull(thisRowValue) ? "" : thisRowValue;
// aaa();
// });
// 渲染表格
// function aaa(){
// table.render({
// id: 'arrangeList',//表格
// elem: '#workshopId', //表格里的元素
// method: 'post',
// url: sysMainMation.erpBasePath + 'erpfarm001',
// where: getTableParams(),
// even: true,
// page: true,
// limits: getLimits(),
// limit: getLimit(),
// done: function(json){
// // 表格渲染完成后的回调
// // 在这里添加事件监听
// $('select[name="workshop"]').on('change', function(){
// console.log('Workshop selected', $(this).val());
// // 如果需要,可以在这里打印'123'或进行其他操作
// });
//
// $('input[name="taskNumber"]').on('click', function(){
// console.log('taskNumber input clicked');
// // 打印'123'或其他操作
// });
// }
// // done: function(json){
// // console.log(json)
// // // matchingLanguage();
// // // $('select[name="workshop"]').each(function(){
// // // $(this).empty();
// // // workshopData.forEach(function(item){
// // // $(this).append('<option value="' + item.id + '">' + item.name + '</option>');
// // // }, $(this));
// // // });
// // }
// });
// }
AjaxPostUtil.request({url: sysMainMation.erpBasePath + "queryMachinProcedureById", params: {id: id}, type: 'json', method: 'GET', callback: function (json) {
$("#showForm").html(getDataUseHandlebars($("#beanTemplate").html(), json));
function queryWorkshopList() {
// 假设您有一个函数可以处理Ajax请求
AjaxPostUtil.request({
url: sysMainMation.erpBasePath + "erpfarm001",
params: {page: 1, limit: 30},
type: 'json',
method: "POST",
callback: function(json) {
console.log(666, json);
}
let par = {
workProcedureId: json.bean.procedureId
};
let farmModelHtml = '';
// 根据工序id查询可以执行该工序的车间
AjaxPostUtil.request({url: sysMainMation.erpBasePath + "queryExecuteFarmByWorkProcedureId", params: par, type: 'json', method: 'GET', callback: function (json) {
farmModelHtml = getDataUseHandlebars(selTemplate, json);
}, async: false});
initTableChooseUtil.initTable({
id: "arrangeList",
cols: [
{id: 'farmId', title: '安排车间', formType: 'select', width: '200', verify: 'required', modelHtml: farmModelHtml },
{id: 'targetNum', title: '安排任务数量', formType: 'input', width: '140', verify: 'required|number' },
{id: 'stateName', title: '状态', formType: 'detail', width: '140' }
],
deleteRowCallback: function (trcusid) {},
addRowCallback: function (trcusid) {},
form: form,
minData: 1
});
}
// $("body").on("click", "workshopId", function (e) {
// // 查询车间列表
// AjaxPostUtil.request({url: sysMainMation.erpBasePath + "erpfarm001", params: {page:1,limit:30}, type: 'json', method: "POST", callback: function(json) {
// console.log(666,json)
// // $("#workshopId").html(getDataUseHandlebars(selTemplate, json));
// // form.render('select');
// // initTable();
// }, async: false});
// });
initTableChooseUtil.deleteAllRow('arrangeList');
$.each(json.bean.machinProcedureFarmList, function(i, item) {
item.stateName = skyeyeClassEnumUtil.getEnumDataNameByCodeAndKey("machinProcedureFarmState", 'id', item.state, 'name');
var trcusid = initTableChooseUtil.resetData('arrangeList', item);
var thisRowKey = trcusid.replace("tr", "");
if (item.state != 'waitReceive') {
// 只有【待接收】的任务可以删除
let itemBox = $('input[type="checkbox"][rowId="row' + thisRowKey + '"]');
itemBox.prop('disabled', true);
itemBox.addClass('layui-btn-disabled');
itemBox.next().css("cursor", "not-allowed");
}
});
// var workshopId = "";
// form.on('select(workshopId)', function(data) {
// var thisRowValue = data.value;
// workshopId = isNull(thisRowValue) ? "" : thisRowValue;
// loadTable();
// });
var planStartTime = laydate.render({
elem: '#planStartTime', //指定元素
format: 'yyyy-MM-dd',
theme: 'grid',
done:function(value, date){
planEndTime.config.min = {
year: date.year,
month: date.month - 1,//关键
date: date.date,
hours: date.hours,
minutes: date.minutes,
seconds: date.seconds
};
}
});
// AjaxPostUtil.request({url: sysMainMation.erpBasePath + "erpfarm001", params: {page: page, limit: 15}, type: 'json', method: 'POST', callback: function (json) {
// parent.layer.close(index);
// parent.refreshCode = '0';
// }});
var planEndTime = laydate.render({
elem: '#planEndTime', //指定元素
format: 'yyyy-MM-dd',
theme: 'grid',
done:function(value, date){
planStartTime.config.max = {
year: date.year,
month: date.month - 1,//关键
date: date.date,
hours: date.hours,
minutes: date.minutes,
seconds: date.seconds
}
}
});
matchingLanguage();
form.render();
form.on('submit(formAddBean)', function (data) {
if (winui.verifyForm(data.elem)) {
var result = initTableChooseUtil.getDataList('arrangeList');
if (!result.checkResult) {
return false;
var actualStartTime = laydate.render({
elem: '#actualStartTime', //指定元素
format: 'yyyy-MM-dd',
theme: 'grid',
done:function(value, date){
actualEndTime.config.min = {
year: date.year,
month: date.month - 1,//关键
date: date.date,
hours: date.hours,
minutes: date.minutes,
seconds: date.seconds
};
}
var noError = false;
var tableData = [];
$.each(result.dataList, function(i, item) {
// 获取行编号
var thisRowKey = item["trcusid"].replace("tr", "");
if (parseInt(item.taskNumber) == 0) {
$("#taskNumber" + thisRowKey).addClass("layui-form-danger");
$("#taskNumber" + thisRowKey).focus();
winui.window.msg('数量不能为0', {icon: 2, time: 2000});
noError = true;
return false;
});
var actualEndTime = laydate.render({
elem: '#actualEndTime', //指定元素
format: 'yyyy-MM-dd',
theme: 'grid',
done:function(value, date){
actualStartTime.config.max = {
year: date.year,
month: date.month - 1,//关键
date: date.date,
hours: date.hours,
minutes: date.minutes,
seconds: date.seconds
}
// 车间对象
// 更换下面两个
// assert
// allChooseAsset
// inTableDataArrayByAssetarId
var farm = allChooseFarm["tr" + thisRowKey];
if (inTableDataArrayByAssetarId(farm.id, tableData)) {
winui.window.msg('一张单中不允许出现相同的资产信息.', {icon: 2, time: 2000});
noError = true;
}
});
matchingLanguage();
form.render();
form.on('submit(formAddBean)', function (data) {
if (winui.verifyForm(data.elem)) {
var result = initTableChooseUtil.getDataList('arrangeList');
if (!result.checkResult) {
return false;
}
item["farmId"] = farm.id;
tableData.push(item);
});
if (noError) {
return false;
}
var params = {
list: JSON.stringify(tableData),
};
AjaxPostUtil.request({url: sysMainMation.admBasePath + "insertAssetReport", params: params, type: 'json', method: 'POST', callback: function (json) {
var params = {
id: id,
planStartTime: $("#planStartTime").val(),
planEndTime: $("#planEndTime").val(),
actualStartTime: $("#actualStartTime").val(),
actualEndTime: $("#actualEndTime").val(),
machinProcedureFarmList: JSON.stringify(result.dataList),
};
AjaxPostUtil.request({url: sysMainMation.erpBasePath + "setMachinProcedureById", params: params, type: 'json', method: 'POST', callback: function (json) {
parent.layer.close(index);
parent.refreshCode = '0';
}});
}
return false;
});
// 判断选中的资产是否也在数组中
function inTableDataArrayByAssetarId(farmId, array) {
var isIn = false;
$.each(array, function(i, item) {
if(item.farmId === farmId) {
isIn = true;
return false;
}
return false;
});
return isIn;
}
}});
// 取消
$("body").on("click", "#cancle", function() {
parent.layer.close(index);
});
function loadTable() {
table.reloadData("arrangeList", {where: getTableParams()});
}
function getTableParams() {
var params = {
type: 'farm',
objectId: workshopId
}
return $.extend(true, params, initTableSearchUtil.getSearchValue("messageTable"));
}
});
\ No newline at end of file
......@@ -11,22 +11,25 @@ layui.config({
var id = GetUrlParam("id");
let noteList = [];
// 根据id查询加工单信息
AjaxPostUtil.request({url: sysMainMation.erpBasePath + "queryMachinForGanttById", params: {id: id}, type: 'json', method: 'GET', callback: function (json) {
matchingLanguage();
form.render();
renderPanel();
loadDate();
function loadDate() {
// 根据id查询加工单信息
AjaxPostUtil.request({url: sysMainMation.erpBasePath + "queryMachinForGanttById", params: {id: id}, type: 'json', method: 'GET', callback: function (json) {
matchingLanguage();
form.render();
renderPanel();
gantt.config.start_date = new Date(json.bean.mathinTime.start_time);
gantt.config.end_date = new Date(json.bean.mathinTime.end_time);
gantt.clearAll(); //清空缓存
// 解析
noteList = json.bean.node;
gantt.parse({
data: json.bean.node,
links: json.bean.link
});
}});
gantt.config.start_date = new Date(json.bean.mathinTime.start_date);
gantt.config.end_date = new Date(json.bean.mathinTime.end_date);
gantt.clearAll(); //清空缓存
// 解析
noteList = json.bean.node;
gantt.parse({
data: json.bean.node,
links: json.bean.link
});
}});
}
function renderPanel() {
document.getElementById('device_load').style.cssText = 'height:' + $(window).height() + 'px';
......@@ -100,15 +103,14 @@ layui.config({
// e 参数是点击事件的事件对象
let item = getInPoingArr(noteList, "id", id, null);
if (item.types != "project") {
console.log(item)
_openNewWindows({
url: "../../tpl/departmentMachining/arrange.html?id=" + id,
url: "../../tpl/departmentMachining/arrange.html?id=" + item.data.id,
title: "车间任务安排",
pageId: "workshopTaskArrangement",
area: ['90vw', '90vh'],
callBack: function (refreshCode) {
winui.window.msg(systemLanguage["com.skyeye.successfulOperation"][languageType], {icon: 1, time: 2000});
loadTable();
loadDate();
}});
}
// 返回true以允许默认行为继续,返回false可以阻止默认行为
......
......@@ -6,67 +6,60 @@
<link href="../../assets/lib/winui/css/winui.css" rel="stylesheet" />
</head>
<body>
<div class="time">
<div>
<label for="planned-start">计划开始时间:</label>
<input type="date" id="planned-start" name="planned-start">
</div>
<div>
<label for="planned-end">计划结束时间:</label>
<input type="date" id="planned-end" name="planned-end">
</div>
</div>
<div class="time">
<div>
<label for="actual-start">实际开始时间:</label>
<input type="date" id="actual-start" name="actual-start">
</div>
<div>
<label for="actual-end">实际结束时间:</label>
<input type="date" id="actual-end" name="actual-end">
<div style="margin:0 auto;padding:20px;">
<form class="layui-form" action="" autocomplete="off" id="showForm">
</form>
</div>
</div>
<div style="margin:0 auto;padding:20px;margin-top:40px">
<form class="layui-form" action="" autocomplete="off">
<script type="text/x-handlebars-template" id="beanTemplate">
{{#bean}}
<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">详细安排</label>
<div class="layui-input-block" id="arrangeList">
<span class="hr-title">基本信息</span><hr>
</div>
<div class="layui-form-item layui-col-xs6">
<label class="layui-form-label">计划开始时间<i class="red">*</i></label>
<div class="layui-input-block">
<input type="text" id="planStartTime" name="planStartTime" value="{{planStartTime}}" class="layui-input" win-verify="required"/>
</div>
</div>
<div class="layui-form-item layui-col-xs6">
<label class="layui-form-label">计划结束时间<i class="red">*</i></label>
<div class="layui-input-block">
<input type="text" id="planEndTime" name="planEndTime" value="{{planEndTime}}" class="layui-input" win-verify="required"/>
</div>
</div>
<div class="layui-form-item layui-col-xs6">
<label class="layui-form-label">实际开始时间</label>
<div class="layui-input-block">
<input type="text" id="actualStartTime" name="actualStartTime" value="{{actualStartTime}}" class="layui-input"/>
</div>
</div>
<div class="layui-form-item layui-col-xs6">
<label class="layui-form-label">实际结束时间</label>
<div class="layui-input-block">
<input type="text" id="actualEndTime" name="actualEndTime" value="{{actualEndTime}}" class="layui-input"/>
</div>
</div>
<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">目标任务指标</label>
<div class="layui-input-block" id="arrangeList">
</div>
</div>
<div class="layui-form-item layui-col-xs12">
<div class="layui-input-block">
<button class="winui-btn" id="cancle"><language showName="com.skyeye.cancel"></language></button>
<button class="winui-btn" lay-submit lay-filter="formAddBean"><language showName="com.skyeye.save"></language></button>
</div>
</div>
</form>
</div>
{{/bean}}
</script>
<script src="../../assets/lib/layui/layui.js"></script>
<script src="../../assets/lib/layui/custom.js"></script>
<script type="text/javascript">
layui.config({base : '../../js/departmentMachining/'}).use('arrange');
</script>
<script src="../../assets/lib/layui/layui.js"></script>
<script src="../../assets/lib/layui/custom.js"></script>
<script type="text/javascript">
layui.config({base : '../../js/departmentMachining/'}).use('arrange');
</script>
</body>
<style>
.time {
display: flex;
margin-top: 50px;
}
.time > div {
display: flex;
margin-left: 97px;
align-items: center;
}
.time > div:not(:last-child) {
margin-right: 100px;
}
.time input[type="date"] {
width: 150px;
border: 1px solid #ccc;
padding: 5px;
}
</style>
</html>
\ No newline at end of file
......@@ -30,7 +30,6 @@ layui.config({
let tabIndex = 1;
let supplierIds = [];
$.each(json.bean, function (key, value) {
console.log(value)
if (!isNull(key)) {
supplierIds.push(key)
}
......
......@@ -172,18 +172,6 @@ layui.config({
return false;
});
// 设置最小可选的日期
function minDate(){
var now = new Date();
return now.getFullYear()+"-" + (now.getMonth()+1) + "-" + now.getDate();
}
// 设置最小可选的小时日期
function minHourDate(){
var now = new Date();
return now.getHours() + ':' + now.getMinutes() + ':00';
}
// 取消
$("body").on("click", "#cancle", function() {
parent.layer.close(index);
......
......@@ -531,4 +531,16 @@ function turnTime(time, mm){
minute = minute + mm;
}
return (hour < 10 ? ("0" + hour) : hour) + ":" + (minute < 10 ? (minute + "0") : minute);
}
// 设置最小可选的日期
function minDate(){
var now = new Date();
return now.getFullYear()+"-" + (now.getMonth()+1) + "-" + now.getDate();
}
// 设置最小可选的小时日期
function minHourDate(){
var now = new Date();
return now.getHours() + ':' + now.getMinutes() + ':00';
}
\ No newline at end of file
......@@ -92,6 +92,7 @@
"depotPutState": {"name": "仓库入库单入库状态", "className": "skyeye-erp#com.skyeye.depot.classenum.DepotPutState"},
"generateDepotLevelValType": {"name": "ERP-批量生成仓库级别的值的类型", "className": "skyeye-erp#com.skyeye.depot.classenum.GenerateDepotLevelValType"},
"productionChildFromType": {"name": "生产计划单子单据生产类型", "className": "skyeye-erp#com.skyeye.production.classenum.ProductionChildType"},
"machinProcedureFarmState": {"name": "车间任务状态", "className": "skyeye-erp#com.skyeye.machinprocedure.classenum.MachinProcedureFarmState"},
"skyeyeView": {"name": "视图类型", "className": "skyeye-pro#com.skyeye.common.SkyeyeViewEnum"},
"widthScale": {"name": "宽度比例", "className": "skyeye-pro#com.skyeye.attr.classenum.WidthScale"},
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册