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.
164 lines
5.8 KiB
164 lines
5.8 KiB
var close = new Vue({
|
|
el: '#closeCondition',
|
|
data: {
|
|
info: []
|
|
},
|
|
mounted() {
|
|
|
|
$('#ddlLine').select2({
|
|
placeholder: "线别",
|
|
allowClear: true
|
|
});
|
|
var self = this;
|
|
self.QueryddlWorkshop();
|
|
//车间改变
|
|
$('#ddlWorkshop').on('change', function () {
|
|
$('#ddlLine option').remove();
|
|
self.QueryddlLine($('#ddlWorkshop').val());
|
|
});
|
|
$('#ddlLine').on('select2:select', function () {
|
|
console.log($('#ddlLine').val());
|
|
self.QueryDataAsync($('#ddlWorkshop').val(), $('#ddlLine').val());
|
|
});
|
|
|
|
},
|
|
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);
|
|
});
|
|
},
|
|
QueryddlLine: function (workshop) {
|
|
var line = $.ajax({
|
|
url: '/api/Orders/SearchLine', //'/api/QC/QueryStatus'
|
|
type: 'post',
|
|
cache: true,
|
|
async: true,
|
|
dataType: "json",
|
|
contentType: "application/json; charset=utf-8",
|
|
data: JSON.stringify({ workshop: workshop }),
|
|
});
|
|
line.done(function (r) {
|
|
console.log(r);
|
|
$.each(r, function (index, value) {
|
|
console.log(index);
|
|
|
|
$("#ddlLine").append("<option value='" + value.line_id + "'>" + value.descriptions + "</option>");
|
|
})
|
|
$('#ddlLine').val('');
|
|
$('#ddlLine').select2({
|
|
placeholder: "线别",
|
|
allowClear: true
|
|
});
|
|
});
|
|
line.fail(function (error) {
|
|
console.log(error)
|
|
alert(error);
|
|
});
|
|
|
|
},
|
|
QueryDataAsync: function (workshop, line) {
|
|
var self = this;
|
|
self.requestApi({
|
|
modulename: "SiteCapacityStand",
|
|
funname: "SiteCapacityStand",
|
|
para: { workshop:workshop, line:line },
|
|
success: (res) => {
|
|
console.log(res);
|
|
$('#listcbx input').each(function () {
|
|
var id = $(this).attr('id');
|
|
console.log(id);
|
|
$('#' + id).val(res.result[0][id]);
|
|
});
|
|
},
|
|
fail: (ex) => {
|
|
console.log(ex);
|
|
}
|
|
})
|
|
},
|
|
//请求数据方法
|
|
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) }
|
|
)
|
|
},
|
|
save: function () {
|
|
var self = this;
|
|
console.log($('#ddlWorkshop').val());
|
|
if ($('#ddlWorkshop').val() == null) {
|
|
toastr.warning('请选择车间部门', '', { progressBar: true });
|
|
return;
|
|
}
|
|
if ($('#ddlLine').val() == null) {
|
|
toastr.warning('请选择线别', '', { progressBar: true });
|
|
return;
|
|
}
|
|
var $dayshift = $('#listcbx input');
|
|
var dayValueCount = $dayshift.filter(function () {
|
|
var val = $(this).val();
|
|
console.log(val.length);
|
|
if (val.length == 0) {
|
|
val = '0';
|
|
}
|
|
return val;
|
|
})
|
|
console.log(dayValueCount.length);
|
|
console.log(dayValueCount[0])
|
|
var stand = [$('#ddlWorkshop').val(), $('#ddlLine').val()];
|
|
for (var i = 0; i < dayValueCount.length; i++) {
|
|
if (dayValueCount[i].value == '') {
|
|
dayValueCount[i].value ='0';
|
|
}
|
|
stand[i+2] = dayValueCount[i].value;
|
|
}
|
|
console.log(stand);
|
|
self.requestApi({
|
|
modulename: "Orders",
|
|
funname: "SiteCapacityStand",
|
|
para: { stand: stand },
|
|
success: (res) => {
|
|
console.log(res);
|
|
if (res.result == 'success') {
|
|
toastr.success('站点标准产量保存完成', '', { progressBar: true });
|
|
}
|
|
self.dayMonth = ['day'];
|
|
},
|
|
fail: (ex) => {
|
|
console.log(ex);
|
|
stand = [$('#ddlWorkshop').val(), $('#ddlLine').val()];
|
|
}
|
|
})
|
|
}
|
|
}
|
|
})
|
|
|