This repo is archived. You can view files and clone it, but cannot push or open issues or pull requests.
SXS20240115/SRC/iMES_PAD/module/moduleWIP/program/mrs-eqp/mrs03/mrs03.js
2024-01-24 16:47:50 +08:00

658 lines
21 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

define(["moment",
"module/moduleWIP/program/dialog/keyinattrib/keyinattrib",
'module/moduleWIP/program/dialog/wp03_e_runcard_info/wp03_e_runcard_info'],
function (moment) {
return ["$scope", "$filter", "$stateParams", "config", "DashboardService", "MMWService", "keyinattrib", 'RouterExtendProvider', "$rootScope",
"mrs00Service", "wp03_e_runcard_info",
function ($scope, $filter, $stateParams, config, $DashboardService, $MMWService, $keyinattrib, $RouterExtendProvider, $rootScope,
$mrs00Service, $wp03_e_runcard_info) {
var bln_triggerop = false;
var arymarterial = [];
var lotstamp;
var equipment_chk;
var now_plot; //20200528 雋辰,卡控點擊特性輸入
$scope.eqp_material_list;
$scope.cimtldbcheck = false;
$scope.viewAttribList = []; //20200526 雋辰,前端顯示
$scope.calAttrib = [];
var inAttribList = [];
var selectequipmentlist = [];
$scope.scan = true;
$scope.init = function () {
//init_Layout();
$rootScope.EQPCheck_ModuleWIP(config.cache.workStation, function (data) {
init_Layout();
});
}
$scope.barcodeScan = function () {
if (event.keyCode == 13) {
var target;
if (event) {
target = event.currentTarget
target.blur();
}
$scope.search(target);
}
}
$scope.scanQrcode = function () {
$scope.$root.OpenScanner({
after: function (result) {
$scope.plot_no = result.text;
$scope.search();
},
exception: function () {
//目前裝置無法使用相機
$scope.$root.showAlert($filter('translate')('common.msg.camera_not_support'));
},
orientation: "landscape"
});
}
$rootScope.change_machine = function (options) {
var bln_EQP_binding;
if (config.setting.equipment == '') {
bln_EQP_binding = false;
}
else {
bln_EQP_binding = true;
}
$mrs00Service.init({
Binding: bln_EQP_binding,
callback: function (confirm) {
if (confirm) {
if (!bln_EQP_binding) {
$rootScope.menuList = $scope.menu_temp;
$rootScope.bindingEQP = config.setting.equipment;
}
getEquipmentStatus(config.setting.equipment, function (data) {
data = JSON.parse(data.ResultJson);
$scope.$root.machine_info = data.machine_info[0];
});
init_Layout();
}
}
});
}
function getEquipmentStatus(equipment, callback, isLoading) {
if (isLoading == undefined) {
isLoading = false;
}
$MMWService.sendToEAISrv({
uri: 'KMI.machine_status_get_json',
content: {
machine_no: equipment,
StationNo: config.setting.workStation,
num_of_days:7
},
success: function (data) {
if (callback)
callback(data);
},
error: function (data) {
$rootScope.showAlert(data.Exception);
}
}, isLoading);
}
function init_Layout() {
clearControl();
$rootScope.work_machine = config.cache.equipment;
if (config.cache.dashboard == "eqp") {
$scope.equipment = config.cache.equipment;
$scope.workStation = config.cache.workStation;
} else {
$scope.equipment = "";
$scope.workStation = config.cache.op;
}
$scope.dashboard = $DashboardService.dashboard;
//20170411 modify by Dustdusk for data 傳入參數後調整判斷
if ($stateParams.data.plot_no) {
//20170410 modify by megabytes for data傳入修改
$scope.plot_no = $stateParams.data.plot_no;
//if($stateParams.data.sft_op_seq != undefined && $stateParams.data.sft_op_seq != undefined
// && $stateParams.data.sft_op_no != ''&& $stateParams.data.sft_op_no != ''){
// $scope.plot_no += ';'+$stateParams.data.sft_op_seq+';'+$stateParams.data.sft_op_no;
//}
//$scope.plot_no += ';'+$scope.workStation;
$scope.search();
} else {
$scope.$root.focusById('plot_no');
}
//2020-05-011 yenru add.
//UCD Layout Right Top Menu Button;
$scope.$root.btnList = [
{
//20201201 雋辰,ERunCard
name: "button_eruncard",
icon_scr: 'image/icons/runcard.png',
class: [], //按鈕額外的class
disabled: false,
click: function () {
if (now_plot !== undefined && now_plot != '')
$wp03_e_runcard_info.init({ LOTNO: now_plot });
}
},
{
//特性輸入
name: "button_attrib",
icon_scr: 'image/iMES_icon/icon_exception@1.png',
class: [], //按鈕額外的class
disabled: false,
click: function () {
if (!now_plot)
return;
//按鈕點擊
$keyinattrib.init({
keyinattribList: inAttribList.slice(),
br: 'ci',
callback: function (lotno, attrib) {
for (var i = 0; i < inAttribList.length; i++) {
for (var j = 0 ; j < attrib.length ; j++) {
if (inAttribList[i].attrib_no == attrib[j].attrib_no) {
inAttribList[i] = attrib[j];
}
}
}
}
});
}
}
];
$scope.eqp_material_list = $scope.dashboard['workMaterial'].materials_detail;
}
function clearControl() {
if (bln_triggerop) {
plot_reverse_triggerop_process();
};
$scope.plot = undefined;
$scope.equipmentList = undefined;
selectequipmentlist = [];
//20200526 雋辰,區分兩種attrib
$scope.viewAttribList = [];
inAttribList = [];
$scope.calAttrib = [];
//20200528 雋辰,完成進站&搜尋不到plot不應該可以進行回復triggerop
bln_triggerop = false;
//20200528 雋辰,只有成功搜尋才可以開啟特性輸入
now_plot = "";
$scope.calAttrib = [];
}
$scope.search = function (target) {
//if($scope.plot_no && $scope.plot_no!='' && ($scope.plot)?($scope.plot_no != $scope.plot.PlotNo):true){
if ($scope.plot_no && $scope.plot_no != '') {
if ($scope.plot_no.indexOf(';') == -1) {
//$scope.plot_no = $scope.plot_no + ';' + $scope.workStation;
}
//20170410 modify by megabytes for 新增sft-seq & no 參數
getPlotInfo($scope.plot_no, $scope.workStation, '1', function (data, plotInfo) {
$stateParams.data = {};
//data = JSON.parse(data.Result);
//if(data.Result != 'fail'){
var result = JSON.parse(data.ResultJson);
if (data.Code === '0') {
//console.log(result);
console.log(result.plot_info_get[0]);
if (result.CheckInQty != 0) {
$scope.arytemp = {
materials_no: '', marterial_name: '', std_use_qty: ''
, actual_use_qty: '', materials_unit: '',
substitutematerialno: '', marterial_lot: '', qty: '', useqty: ''
};
equipment_chk = true;
$scope.plot = result.plot_info_get[0];
materials_list = result.plot_info_get[0].material_list;
equipment_chk = result.plot_info_get[0].available_equipment_chk
if (equipment_chk == 'false') {
$scope.$root.showAlert($filter('translate')('mrs03.msg.noneqp'), function () {
});
}
lotstamp = result.plot_info_get[0]['plot_stamp'];
//config.cache.plotno = result.plot_info_get[0].attrib_list[0].lot_no;
//config.cache.material_detail = result.plot_info_get[0].material_detail;
//console.log(config.cache.material_detail);
//console.log(config.cache.plotno);
$scope.plot.originalString = $scope.plot_no;
//$scope.plot.Qty = result.plot_info_get[0].check_in_qty;
$scope.plot.Qty = parseFloat(result.plot_info_get[0].cur_qty);
$scope.plot.Nowime = moment(result.plot_info_get[0].now_time, 'YYYY/MM/DD HH:mm:ss').toDate();
$scope.plot.PlanDateE = moment(result.plot_info_get[0].plan_date_e, 'YYYYY/MM/DD HH:mm:ss').toDate();
$scope.plot.CurQty = parseFloat(result.plot_info_get[0].cur_qty);
$scope.plot.SysQty = parseFloat(result.plot_info_get[0].sys_qty);
$scope.plot.CurUnitNo = result.plot_info_get[0].cur_unitno;
$scope.plot.SysUnitNo = result.plot_info_get[0].sys_unitno;
$scope.plot.Priority = result.plot_info_get[0].priority;
$scope.equipmentList = result.plot_info_get[0].available_equipment;
$scope.scan = false;
for (var item in $scope.equipmentList) {
$scope.chooseeqp = false;
if ($scope.equipment == $scope.equipmentList[item].machine_no) {
$scope.equipmentList[item].isEnable = true;
$scope.equipmentList[item].isSelect = true;
}
else {
$scope.equipmentList[item].isEnable = false;
$scope.equipmentList[item].isSelect = false;
}
};
$scope.accessoryList = result.plot_info_get[0].accessory;
for (var item in $scope.equipmentList) {
//掛上模治具資訊。
var index_temp;
var ary_accessoryList = [];
for (var item_accessory in $scope.accessoryList) {
var ary_accessory;
if ($scope.accessoryList[item_accessory].equipmentno == $scope.equipmentList[item].machine_no) {
ary_accessory = {
isSelect: false,
accessory_no: $scope.accessoryList[item_accessory].accessoryno,
acc_show: $scope.accessoryList[item_accessory].accessorytype + ' / ' + parseInt($scope.accessoryList[item_accessory].accumulateqty) +
' / ' + ($scope.accessoryList[item_accessory].repaircycle === '' ? "NON" : $scope.accessoryList[item_accessory].repaircycle)
};
ary_accessoryList.push(ary_accessory);
}
}
if (ary_accessoryList.length > 0) {
$scope.equipmentList[item].accessory = ary_accessoryList;
}
}
abc = [];
abc.length = 0;
if (result.plot_info_get[0].material_detail.length > 0) {
var arytemp = {
materials_no: '', marterial_name: '', std_use_qty: '', actual_use_qty: ''
, materials_unit: '',
substitutematerialno: '', marterial_lot: '', qty: '', useqty: ''
};
abc.push(arytemp);
}
if ($scope.plot_no.indexOf(';') != -1) {
$scope.plot.PlotNo = $scope.plot_no.split(';')[0] + '';
} else {
$scope.plot.PlotNo = $scope.plot_no + '';
}
if ($scope.plot.attrib_list) {
//20200916 諺儒修正無calculator問題。
$scope.viewAttribList = [];
inAttribList = [];
$scope.calAttrib = [];
//20200526 雋辰,特型基礎數值處理,從keyinattrib.js init()移至此處理
for (var index in $scope.plot.attrib_list) {
var item = $scope.plot.attrib_list[index];
if (!item.attrib_value) {
if (item.attrib_default)
item.attrib_value = item.attrib_default;
else if (item.attrib_default && item.data_type == "3")
item.attrib_value_date = item.attrib_default;
else if (item.data_type == "4")
item.attrib_value = false;
}
//暫時找不到同.NET ValueList做法先增加一個data_type_name作為顯示用
switch (item.data_type) {
case '0':
item.data_type_name = $filter('translate')('dialog.keyinattrib.attrib_type_int');
break;
case '1':
item.data_type_name = $filter('translate')('dialog.keyinattrib.attrib_type_str');
break;
case '2':
item.data_type_name = $filter('translate')('dialog.keyinattrib.attrib_type_percent');
break;
case '3':
item.data_type_name = $filter('translate')('dialog.keyinattrib.attrib_type_time');
//因無日期+時間選擇的套件,日期用套件選擇,時間改用數值輸入。
if (item.attrib_value == '' || item.attrib_value == null) {
item.attrib_value = null;
item.attrib_value_date = null;
item.attrib_value_h = '0';
item.attrib_value_m = '0';
item.attrib_value_s = '0';
}
else {
item.attrib_value_date = moment(item.attrib_value);
item.attrib_value_h = moment(item.attrib_value_date).format("HH")
item.attrib_value_m = moment(item.attrib_value_date).format("mm")
item.attrib_value_s = moment(item.attrib_value_date).format("ss")
}
break;
case '4':
item.data_type_name = $filter('translate')('dialog.keyinattrib.attrib_type_boolean');
break;
}
switch (item.attrib_phase) {
case '1':
case '99':
item.data_show = '1';
if (item.attrib_source == '1') { item.data_show = '0'; }
break;
case '2':
item.data_show = '0';
break;
default:
item.data_show = '0';
break;
}
}
for (i = 0; i < $scope.plot.attrib_list.length; i++) {
var source = $scope.plot.attrib_list[i].attrib_source;
if ($scope.plot.attrib_list[i].data_show != '1')
continue;
if (source) {
switch (source) {
case "0":
inAttribList.push($scope.plot.attrib_list[i]);
break;
case "1":
$scope.calAttrib.push($scope.plot.attrib_list[i]);
break;
case "2":
case "3":
$scope.viewAttribList.push($scope.plot.attrib_list[i]);
break;
}
}
}
}
$scope.$root.focusById('eqpinp');
} else {
$scope.$root.showAlert(
$filter('translate')('mrs03.prodPatchNo_' + $scope.$root.servicePlatform)
+ $scope.plot_no
+ $filter('translate')('mrs03.msg.cantTrackIn'), function () {
if (target) {
$scope.plot_no = '';
target.focus();
}
});
}
now_plot = plotInfo;
//$scope.plot_no = '';
} else {
//$scope.$root.showAlert(
// 'Code : ' + data.Code + '<br>' + data.Message, function () {
// if (target) {
// $scope.plot_no = '';
// target.focus();
// }
// });
if ($scope.plot ? ($scope.plot_no != $scope.plot.PlotNo) : true) clearControl();
}
$scope.plot_no = '';
});
} else {
//$scope.plot = undefined;
if (!$scope.plot_no)
$scope.$root.showAlert($filter('translate')('mrs03.msg.flotNoEmpty_' + $scope.$root.servicePlatform), function () {
if (target) {
$scope.plot_no = '';
target.focus();
}
});
}
}
//20170411 modify by megabytes for 新增傳入sft-seq & no 參數
$scope.confirm = function () {
if (equipment_chk == 'false') {
$scope.$root.showAlert($filter('translate')('mrs03.msg.noneqp'), function () { });
}
else {
selectequipmentlist = [];
for (var item in $scope.equipmentList) {
if ($scope.equipmentList[item].isSelect == true) selectequipmentlist.push($scope.equipmentList[item]);
};
selectAccessory = [];
$scope.equipmentList.forEach(function (item, index) {
if (typeof (item.accessory) !== "undefined") {
item.accessory.forEach(function (jtem, jndex) {
if ($scope.equipmentList[index].accessory[jndex].isSelect == true) {
$scope.accessoryList.forEach(function (ktem, kndex) {
if (ktem.accessoryno == $scope.equipmentList[index].accessory[jndex].accessory_no) {
selectAccessory.push(ktem);
}
});
//selectAccessory.push($scope.equipmentList[index].accessory[jndex].accessory_no);
}
});
}
});
if (checkPlot($scope.plot)) {
trackInPlot($scope.plot, $scope.workStation, function (data) {
//data = JSON.parse(data.Result);
var result = JSON.parse(data.ResultJson);
if (data.Code === '0') {
//2020/10/23 Grace Mantis 80387 增加異常單開立功能, 改呼叫共用BRTransferLot 去執行
$rootScope.BRTransferLot($scope.plot.PlotNo, config.cache.account, result.linkname, result.erftype,
result.ruleno, null, result.erfmsg, true, 'moduleEQP');
bln_triggerop = false;
clearControl();
/*
$rootScope.showAlert({
title: $filter('translate')('common.msg.checkin_lot'),
item: $filter('translate')('common.lotno'),
message: $scope.plot.PlotNo
});
bln_triggerop = false;
clearControl();
//$RouterExtendProvider.goToProgram($rootScope.modules[0].childs[0]);
$scope.$root.changeProgram('moduleEQP', true);
*/
}
})
}
}
}
$scope.cancel = function () {
clearControl();
}
//20170410 modify by megabytes for 新增sft-seq & no 參數 & MoId串接
function getPlotInfo(plotInfo, workStation, ReturnType, callback) {
bln_triggerop = true;
$MMWService.sendToEAISrv({
uri: 'KMI.plot.info.get.json',
content: {
//MoId : plotInfo,
//ReturnType : ReturnType
//machine_no : (config.cache.postingmode == 'eqp')?($scope.equipment):('1') ;
machine_no: $scope.equipment || null,
op_no: workStation,
plot_no: plotInfo,
login_employee_no: config.cache.account,
return_type: ReturnType,
query_mode: config.cache.dashboard
},
success: function (data) {
if (callback)
callback(data, plotInfo);
}
});
}
//20170411 modify by megabytes for 新增接收sft-seq & no 參數 &MoId 串接
function trackInPlot(plot, workStation, callback) {
var tmpinAttribList = [];
var i = 0;
for (i = 0; i < inAttribList.length; i++) {
if (inAttribList[i].data_show == '1')
tmpinAttribList.push(inAttribList[i]);
}
for (i = 0; i < $scope.calAttrib.length; i++) {
tmpinAttribList.push($scope.calAttrib[i]);
}
for (i = 0; i < $scope.viewAttribList.length; i++) {
if ($scope.viewAttribList[i].data_show == '1') tmpinAttribList.push($scope.viewAttribList[i]);
}
$MMWService.sendToEAISrv({
uri: 'KMI.plot.check.in.process.lot.json',
content: {
//machine_no : $scope.equipment,
plot_no: plot.PlotNo,
plot_stamp: plot.plot_stamp,
qty: plot.Qty,
//NowDateTime:moment(plot.Nowime).format('YYYY-MM-DD HH:mm:ss'),
login_employee_no: config.cache.account,
op_no: plot.op_no,
selectequipment: selectequipmentlist,
attribkeyin: tmpinAttribList,
accessory: selectAccessory
},
success: function (data) {
if (callback)
callback(data);
}
});
}
function checkPlot(plot) {
var validate = true;
if (plot) {
// if(!plot.Qty || plot.Qty == ''){
// validate = false;
// $scope.$root.showAlert($filter('translate')('mrs03.msg.incomeEmpty'));
// }
if ($scope.equipmentList.length > 0 && selectequipmentlist.length == 0) {
validate = false;
$scope.$root.showAlert($filter('translate')('mrs03.msg.pleaseselectequip'));
}
if ($scope.plot.MachineRecordList && $scope.plot.MachineRecordList.length > 0) {
var isWarn = false;
$scope.plot.MachineRecordList.forEach(function (detail) {
isWarn = isWarn || (detail.need_alert === 'Y');
});
if (isWarn) {
validate = false;
$scope.$root.showAlert($filter('translate')('mrs03.msg.needAlert'));
}
}
if (!$DashboardService.dashboard['workOperator'].work_member_detail
|| $DashboardService.dashboard['workOperator'].work_member_detail.length <= 0) {
validate = false;
$scope.$root.showAlert($filter('translate')('mrs03.msg.noOperator'));
}
} else {
validate = false;
$scope.$root.showAlert($filter('translate')('mrs03.msg.flotEmpty'));
}
return validate;
}
function plot_reverse_triggerop_process(callback) {
$MMWService.sendToEAISrv({
uri: 'KMI.plot.reverse.triggerop.process',
content: {
plot: $scope.plot.PlotNo,
userno: config.cache.account,
lotstamp: lotstamp
},
success: function (data) {
if (callback)
callback(data);
}
});
}
$scope.$on('$stateChangeStart', function (event) {
if (bln_triggerop) {
plot_reverse_triggerop_process();
};
});
}
]
});