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.
377 lines
16 KiB
377 lines
16 KiB
2 years ago
|
var close = new Vue({
|
||
|
el: '#productionPlan',
|
||
|
data: {
|
||
|
year:null,
|
||
|
month: null,
|
||
|
day: null,
|
||
|
days:[],
|
||
|
day01: null,
|
||
|
night01:null,
|
||
|
dayMonth: ['day'],//存储拼柜勾选的条件
|
||
|
nightMonth: ['night'] //存储入库勾选的条件
|
||
|
},
|
||
|
mounted() {
|
||
|
|
||
|
var self = this;
|
||
|
self.QueryddlWorkshop();
|
||
|
//获取月份
|
||
|
var time = new Date();
|
||
|
self.month = time.getMonth() + 1;
|
||
|
self.year = time.getFullYear();
|
||
|
$('.month').val(self.month+'月');
|
||
|
$('.month').select2({
|
||
|
allowClear: true
|
||
|
});
|
||
|
console.log(self.year);
|
||
|
console.log(self.month);
|
||
|
self.day = self.mGetDate(self.year, self.month);
|
||
|
console.log(self.day);
|
||
|
for (var i = 1; i < self.day+1;i++) {
|
||
|
self.daycreateElement(i,self.month);
|
||
|
self.nightcreateElement(i,self.month);
|
||
|
}
|
||
|
var dayid = $($('#daylist').children("div").get(0)).children('input').attr('id');
|
||
|
console.log(dayid);
|
||
|
setTimeout("document.getElementById(\"" + dayid + "\").focus()", 50);
|
||
|
var nightid = $($('#nightlist').children("div").get(0)).children('input').attr('id');
|
||
|
console.log(nightid);
|
||
|
|
||
|
//白班第一个input回车后面的input值都等于第一个
|
||
|
$($('#daylist').children("div").get(0)).children('input').keypress(function (event) {
|
||
|
if (event.which == 13 || event.KeyCode == 13) {
|
||
|
event.preventDefault();
|
||
|
var value = $($('#daylist').children("div").get(0)).children('input').val();
|
||
|
$('#daylist input').each(function () {
|
||
|
$(this).val(value);
|
||
|
})
|
||
|
}
|
||
|
});
|
||
|
//晚班第一个input回车后面的input值都等于第一个
|
||
|
$($('#nightlist').children("div").get(0)).children('input').keypress(function (event) {
|
||
|
if (event.which == 13 || event.KeyCode == 13) {
|
||
|
event.preventDefault();
|
||
|
var value = $($('#nightlist').children("div").get(0)).children('input').val();
|
||
|
$('#nightlist input').each(function () {
|
||
|
$(this).val(value);
|
||
|
})
|
||
|
}
|
||
|
});
|
||
|
//车间改变
|
||
|
$('#ddlWorkshop').on('select2:select', function () {
|
||
|
var dayInfo = {
|
||
|
workshop: $('#ddlWorkshop').val(),
|
||
|
class: 'day',
|
||
|
year: self.year,
|
||
|
month: $('#dayshift').val()
|
||
|
}
|
||
|
var nightInfo = {
|
||
|
workshop: $('#ddlWorkshop').val(),
|
||
|
class: 'night',
|
||
|
year: self.year,
|
||
|
month: $('#nightshift').val()
|
||
|
}
|
||
|
self.requestApi({
|
||
|
modulename: "ProductionPlan",
|
||
|
funname: "SearchMonthPlan",
|
||
|
para: { dayInfo: dayInfo, nightInfo: nightInfo },
|
||
|
success: (res) => {
|
||
|
if (res.day.length != 0) {
|
||
|
self.dayMonth = res.day;
|
||
|
console.log(self.dayMonth);
|
||
|
for (var i = 0; i < 31; i++) {
|
||
|
var monthes = 'month' + (i + 1);
|
||
|
$('#daylist>div').eq(i).children('input').val(self.dayMonth[0][monthes].substr(self.dayMonth[0][monthes].lastIndexOf("_")).substr(1));
|
||
|
}
|
||
|
self.dayMonth = ['day'];
|
||
|
}
|
||
|
if (res.night.length != 0) {
|
||
|
self.nightMonth = res.night;
|
||
|
console.log(self.nightMonth);
|
||
|
for (var i = 0; i < 31; i++) {
|
||
|
var monthes = 'month' + (i + 1);
|
||
|
$('#nightlist>div').eq(i).children('input').val(self.nightMonth[0][monthes].substr(self.nightMonth[0][monthes].lastIndexOf("_")).substr(1));
|
||
|
}
|
||
|
self.dayMonth = ['night'];
|
||
|
}
|
||
|
},
|
||
|
fail: (ex) => {
|
||
|
console.log(ex);
|
||
|
}
|
||
|
})
|
||
|
});
|
||
|
$('#dayshift').on('select2:select', function () {
|
||
|
let months = $(this).val();
|
||
|
console.log(months);
|
||
|
self.monthChange('day', months);
|
||
|
//白班第一个input回车后面的input值都等于第一个
|
||
|
$($('#daylist').children("div").get(0)).children('input').keypress(function (event) {
|
||
|
if (event.which == 13 || event.KeyCode == 13) {
|
||
|
event.preventDefault();
|
||
|
var value = $($('#daylist').children("div").get(0)).children('input').val();
|
||
|
$('#daylist input').each(function () {
|
||
|
$(this).val(value);
|
||
|
})
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
$('#nightshift').on('select2:select', function () {
|
||
|
let months = $(this).val();
|
||
|
console.log(months);
|
||
|
self.monthChange('night', months);
|
||
|
//晚班第一个input回车后面的input值都等于第一个
|
||
|
$($('#nightlist').children("div").get(0)).children('input').keypress(function (event) {
|
||
|
if (event.which == 13 || event.KeyCode == 13) {
|
||
|
event.preventDefault();
|
||
|
var value = $($('#nightlist').children("div").get(0)).children('input').val();
|
||
|
$('#nightlist input').each(function () {
|
||
|
$(this).val(value);
|
||
|
})
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
|
||
|
},
|
||
|
methods: {
|
||
|
//车间
|
||
|
QueryddlWorkshop: function () {
|
||
|
var promiseweld = $.ajax({
|
||
|
url: '/api/Orders/QueryWorkshop', //'/api/QC/QueryStatus'
|
||
|
type: 'post',
|
||
|
cache: true,
|
||
|
async: true,
|
||
|
});
|
||
|
promiseweld.done(function (r) {
|
||
|
console.log(r);
|
||
|
$.each(r.info, function (index, value) {
|
||
|
console.log(index);
|
||
|
$("#ddlWorkshop").append("<option value='" + value.area_code + "'>" + value.descriptions + "</option>");
|
||
|
})
|
||
|
$('#ddlWorkshop').val('');
|
||
|
$('#ddlWorkshop').select2({
|
||
|
placeholder: "车间",
|
||
|
allowClear: true
|
||
|
});
|
||
|
});
|
||
|
promiseweld.fail(function (error) {
|
||
|
console.log(error)
|
||
|
alert(error);
|
||
|
});
|
||
|
},
|
||
|
//请求数据方法
|
||
|
requestApi: function (config) {//modulename, funname, para, success, fail) {
|
||
|
fetch("/api/" + config.modulename + "/" + config.funname + "", {
|
||
|
method: "post",
|
||
|
headers: {
|
||
|
"Accept": "application/json, text/plain, */*",
|
||
|
"Content-Type": "application/json"
|
||
|
},
|
||
|
body: JSON.stringify(config.para)
|
||
|
}).then(
|
||
|
(res) => { return res.json() }
|
||
|
).then(
|
||
|
(res) => { config.success(res) }
|
||
|
).catch(
|
||
|
(ex) => { config.fail(ex) }
|
||
|
)
|
||
|
},
|
||
|
//点击白班月
|
||
|
dayshift: function () {
|
||
|
$($('#daylist').children("div").get(0)).children('input').focus();
|
||
|
},
|
||
|
//点击晚班月
|
||
|
nightshift: function () {
|
||
|
$($('#nightlist').children("div").get(0)).children('input').focus();
|
||
|
},
|
||
|
//白、晚班月份改变
|
||
|
monthChange: function (classes, months) {
|
||
|
var self = this;
|
||
|
console.log(months);
|
||
|
|
||
|
if (months.length == 2) {
|
||
|
var months = months.substr(0, 1);
|
||
|
} else {
|
||
|
var months = months.substr(0, 2);
|
||
|
}
|
||
|
var days = self.mGetDate(self.year, months);
|
||
|
console.log(days);
|
||
|
if (classes == 'day') {
|
||
|
$('#daylist').empty();
|
||
|
for (var i = 1;i < days+1;i++) {
|
||
|
self.daycreateElement(i,months);
|
||
|
}
|
||
|
$($('#daylist').children("div").get(0)).children('input').focus();
|
||
|
}
|
||
|
if (classes == 'night') {
|
||
|
$('#nightlist').empty();
|
||
|
for (var i = 1; i < days+1; i++) {
|
||
|
self.nightcreateElement(i,months);
|
||
|
}
|
||
|
$($('#nightlist').children("div").get(0)).children('input').focus();
|
||
|
}
|
||
|
},
|
||
|
//白班创建元素的方法
|
||
|
daycreateElement: function (i,month) {
|
||
|
var self = this;
|
||
|
var $div = $("<div class='test col-xs-6 col-sm-4 col-md-3 col-lg-2'></div>");
|
||
|
$('#daylist').append($div);
|
||
|
var $span = $("<span id='day" + i + "'></span>");
|
||
|
//$div.append($span.text(self.month + '月' + i + '日 : '));
|
||
|
//console.log(typeof(self.month));
|
||
|
if (month.toString().length == 1) {
|
||
|
if (i.toString().length == 1) {
|
||
|
if (i == 1) {
|
||
|
var $input = $("<input type='text' v-model='day01' id='day" + "0" + month + "0" + i + "' />");
|
||
|
} else {
|
||
|
var $input = $("<input type='text' id='day" + "0" + month + "0" + i + "' />");
|
||
|
}
|
||
|
$div.append($span.text('\xa0\xa0'+ month + '月' + i + '日 : '));
|
||
|
} else {
|
||
|
var $input = $("<input type='text' id='day" + "0" + month + i + "' />");
|
||
|
$div.append($span.text(month + '月' + i + '日 : '));
|
||
|
}
|
||
|
} else {
|
||
|
var $input = $("<input type='text' id='day" + month + i + "' />");
|
||
|
if (i.toString().length == 1) {
|
||
|
$div.append($span.text('\xa0\xa0' + month + '月' + i + '日 : '));
|
||
|
} else {
|
||
|
$div.append($span.text(month + '月' + i + '日 : '));
|
||
|
}
|
||
|
}
|
||
|
//var $input = $("<input type='text' id='" + self.month + i + "' />");
|
||
|
$div.append($input);
|
||
|
|
||
|
},
|
||
|
//晚班创建元素的方法
|
||
|
nightcreateElement: function (i,month) {
|
||
|
var self = this;
|
||
|
var $div = $("<div class='test col-xs-6 col-sm-4 col-md-3 col-lg-2'></div>");
|
||
|
$('#nightlist').append($div);
|
||
|
var $span = $("<span id='day" + i + "'></span>");
|
||
|
//$div.append($span.text(self.month + '月' + i + '日 : '));
|
||
|
console.log(typeof (month));
|
||
|
if (month.toString().length == 1) {
|
||
|
if (i.toString().length == 1) {
|
||
|
if (i == 1) {
|
||
|
var $input = $("<input type='text' v-model='night01' id='night" + "0" + month + "0" + i + "' />");
|
||
|
} else {
|
||
|
var $input = $("<input type='text' id='night" + "0" + month + "0" + i + "' />");
|
||
|
}
|
||
|
|
||
|
$div.append($span.text('\xa0\xa0' + month + '月' + i + '日 : '));
|
||
|
} else {
|
||
|
var $input = $("<input type='text' id='night" + "0" + month + i + "' />");
|
||
|
$div.append($span.text(month + '月' + i + '日 : '));
|
||
|
}
|
||
|
} else {
|
||
|
var $input = $("<input type='text' id='night" + month + i + "' />");
|
||
|
if (i.toString().length == 1) {
|
||
|
$div.append($span.text('\xa0\xa0' + month + '月' + i + '日 : '));
|
||
|
} else {
|
||
|
$div.append($span.text(month + '月' + i + '日 : '));
|
||
|
}
|
||
|
}
|
||
|
//var $input = $("<input type='text' id='" + self.month + i + "' />");
|
||
|
$div.append($input);
|
||
|
//$('#nightlist').append($div);
|
||
|
},
|
||
|
//获取月份天数
|
||
|
mGetDate:function(year, month){
|
||
|
var d = new Date(year, month, 0);
|
||
|
return d.getDate();
|
||
|
},
|
||
|
//存储月份计划
|
||
|
saveMonthPlan: function () {
|
||
|
var self = this;
|
||
|
var $dayshift = $('#daylist input');
|
||
|
var dayValueCount = $dayshift.filter(function () {
|
||
|
return $(this).val();
|
||
|
})
|
||
|
console.log(dayValueCount);
|
||
|
console.log($($('#daylist').children("div").get(0)).children('input').val());
|
||
|
console.log(dayValueCount.length);
|
||
|
if (dayValueCount.length != 0) {
|
||
|
//白班月计划
|
||
|
self.dayMonth.unshift($('#ddlWorkshop').val());
|
||
|
self.dayMonth.push(self.year);
|
||
|
self.dayMonth.push($('#dayshift').val());
|
||
|
var daydays = self.mGetDate(self.year, $('#dayshift').val().substr(0, 1));
|
||
|
for (var i = 0; i < daydays; i++) {
|
||
|
self.dayMonth.push($("#daylist").find('input').eq(i).attr('id').substr(3, 4) + '_' + $("#daylist").find('input').eq(i).val());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
var $nightshift = $('#nightlist input');
|
||
|
var nightValueCount = $nightshift.filter(function () {
|
||
|
return $(this).val();
|
||
|
})
|
||
|
console.log(nightValueCount.length);
|
||
|
if (nightValueCount.length != 0) {
|
||
|
//晚班月计划
|
||
|
self.nightMonth.unshift($('#ddlWorkshop').val());
|
||
|
self.nightMonth.push(self.year);
|
||
|
self.nightMonth.push($('#nightshift').val());
|
||
|
var daydays = self.mGetDate(self.year, $('#nightshift').val().substr(0, 1));
|
||
|
for (var i = 0; i < daydays; i++) {
|
||
|
self.nightMonth.push($("#nightlist").find('input').eq(i).attr('id').substr(5, 4) + '_' + $("#nightlist").find('input').eq(i).val());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
},
|
||
|
//编辑按钮
|
||
|
//compile: function () {
|
||
|
// //$('input').removeAttr('disabled');
|
||
|
// //toastr.success("请进行条件选择", { progressBar: true });
|
||
|
//},
|
||
|
//保存按钮
|
||
|
save: function () {
|
||
|
var self = this;
|
||
|
console.log($('#ddlWorkshop').val());
|
||
|
if ($('#ddlWorkshop').val() == null) {
|
||
|
toastr.warning('请选择车间部门', '', { progressBar: true });
|
||
|
self.dayMonth = ['day'];
|
||
|
self.nightMonth = ['night'];
|
||
|
return;
|
||
|
}
|
||
|
self.saveMonthPlan();
|
||
|
console.log(self.dayMonth);
|
||
|
console.log(self.nightMonth);
|
||
|
if (self.dayMonth.length != 1) {
|
||
|
self.requestApi({
|
||
|
modulename: "ProductionPlan",
|
||
|
funname: "DayProductionPlan",
|
||
|
para: { dayMonth: self.dayMonth },
|
||
|
success: (res) => {
|
||
|
console.log(res);
|
||
|
if (res.result == 'success') {
|
||
|
toastr.success('白班'+self.dayMonth[2]+'计划保存完成', '', { progressBar: true });
|
||
|
}
|
||
|
self.dayMonth = ['day'];
|
||
|
},
|
||
|
fail: (ex) => {
|
||
|
console.log(ex);
|
||
|
self.dayMonth = ['day'];
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
if (self.nightMonth.length != 1) {
|
||
|
self.requestApi({
|
||
|
modulename: "ProductionPlan",
|
||
|
funname: "NightProductionPlan",
|
||
|
para: { nightMonth: self.nightMonth },
|
||
|
success: (res) => {
|
||
|
console.log(res);
|
||
|
if (res.result == 'success') {
|
||
|
toastr.success('晚班' + self.nightMonth[2] + '计划保存完成', '', { progressBar: true });
|
||
|
}
|
||
|
self.nightMonth = ['night'];
|
||
|
},
|
||
|
fail: (ex) => {
|
||
|
console.log(ex);
|
||
|
self.nightMonth = ['night'];
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
})
|