Index: ssts-web/src/main/webapp/disinfectsystem/touchScreen/recycle/recyclingDamage.js
===================================================================
diff -u
--- ssts-web/src/main/webapp/disinfectsystem/touchScreen/recycle/recyclingDamage.js (revision 0)
+++ ssts-web/src/main/webapp/disinfectsystem/touchScreen/recycle/recyclingDamage.js (revision 32950)
@@ -0,0 +1,382 @@
+function add(row) {
+ var totalCount = parseInt($('#totalCount' + row).html(), 10);
+ var errorAmount = parseInt($('#errorAmount' + row).html(), 10)
+ var errorCount = parseInt($('#errorCount' + row).val());
+ var unconfirmedAmount = parseInt($('#unconfirmedAmount' + row).val());
+ if (errorAmount < totalCount) {
+ $('#errorAmount' + row).html(errorAmount + 1);
+ $('#unconfirmedAmount' + row).val(errorAmount - errorCount);
+ }
+}
+
+function reduce(row) {
+ var totalCount = parseInt($('#totalCount' + row).html(), 10);
+ var errorCount = parseInt($('#errorCount' + row).val());
+ var unconfirmedAmount = parseInt($('#unconfirmedAmount' + row).val());
+ var errorAmount = parseInt($('#errorAmount' + row).html(), 10);
+ var status = parseInt($('#status' + row).val(), 10);
+ if (errorAmount > 0) {
+ $('#errorAmount' + row).html(errorAmount - 1);
+ $('#unconfirmedAmount' + row).val(unconfirmedAmount - 1)
+ }
+}
+
+function closeLayer() {
+ if (typeof parent.closeLayer == 'function') {
+ //统一到父窗口
+ parent.closeLayer();
+ } else if (parent.LAYER) {
+ //layer库1.4版本的
+ var index = parent.LAYER.getFrameIndex();
+ parent.LAYER.close(index);
+ } else if (parent.layer) {
+ //新版本的layer库
+ var index = parent.layer.getFrameIndex(window.name);
+ parent.layer.close(index);
+ }
+}
+
+function newArray(arr) {
+ var newArr = [];
+ var map = {}, dest = [];
+ var newArr2 = [];
+ var map2 = {}, dest2 = [];
+ for (var i = 0; i < arr.length; i++) {
+ var ai = arr[i];
+ if (ai.status !== 2) {
+ newArr.push(arr[i])
+ } else {
+ if (!map[ai.materialDefinitionId]) {
+ dest.push(ai);
+ map[ai.materialDefinitionId] = ai;
+ } else {
+ for (var j = 0; j < dest.length; j++) {
+ var dj = dest[j];
+ if (dj.materialDefinitionId == ai.materialDefinitionId) {
+ var amount = parseInt(ai.amount);
+ dj.amount += amount;
+ }
+ }
+ }
+ }
+ }
+ for (var i = 0; i < newArr.length; i++) {
+ var ai = newArr[i];
+ if (!map2[ai.materialDefinitionId]) {
+ dest2.push(ai);
+ map2[ai.materialDefinitionId] = ai;
+ } else {
+ for (var j = 0; j < dest2.length; j++) {
+ var dj = dest2[j];
+ if (dj.materialDefinitionId == ai.materialDefinitionId) {
+ var amount = parseInt(ai.amount);
+ dj.amount += amount;
+ }
+ }
+ }
+ }
+ for (var i = 0, k = 0; i < dest.length; i++) {
+ if (dest[i].amount !== 0) {
+ newArr2[k] = dest[i];
+ k++
+ }
+ }
+ for (var i = 0; i < dest2.length; i++) {
+ for (var j = 0; j < newArr2.length; j++) {
+ if (dest2[i].materialDefinitionId == newArr2[j].materialDefinitionId) {
+ dest2[i].unconfirmedAmount += newArr2[j].amount;
+ newArr2.splice(j, 1);
+ }
+ }
+ }
+ dest2 = dest2.concat(newArr2);
+ return dest2;
+}
+
+var btSave = false;
+function submit() {
+ var isErrorExist = false;
+ var newJsonArray = new Array();
+ var newErrorJsonArray = [];
+
+ var recyclingDamageJson = window.parent.getTousseItemRecyclingDamage(row);
+ var recyclingErrorJson = window.parent.getTousseItemRecyclingError(row);
+ var isErrorAmountZero = true;
+ if (recyclingDamageJson != "") {
+ newJsonArray = JSON.parse(recyclingDamageJson);
+ }
+ if (recyclingErrorJson != "") {
+ newErrorJsonArray = JSON.parse(recyclingErrorJson);
+ }
+ var length = $("#recyclingDamageTable tbody tr").length;
+ for (var i = 0; i < length; i++) {
+ if ($('#errorAmount' + i).html() != '0') {
+ isErrorExist = true;
+ isErrorAmountZero = false;
+ }
+ var amountSum = parseInt($('#errorAmount' + i).html());
+ var errorCount = parseInt($('#errorCount' + i).val());
+ var tousseBarcode = $('#tousseBarcode' + i).val();
+ var materialDefinitionId = $('#materialDefinitionId' + i).attr('value');
+ var materialName = $('#materialName' + i).attr('value');
+ var detailId = $('#detailId' + i).val();
+ var unconfirmedAmount = parseInt($('#unconfirmedAmount' + i).val());
+ var amountPerTousse = $('#amountPerTousse' + i).val();
+ var exist = false;
+ var amountNotNull = false;
+ var newUnconfirmedAmount = 0;
+ for (var j = 0; j < newJsonArray.length; j++) {
+ if (newJsonArray[j].materialDefinitionId == materialDefinitionId) {
+ newUnconfirmedAmount += newJsonArray[j].amount;
+ }
+ }
+ if (amountSum !== newUnconfirmedAmount) {
+ var item = {
+ detailId: "",
+ tousseDefinitionID: parseInt(tousseDefinitionID),
+ materialDefinitionId: parseInt(materialDefinitionId),
+ materialName: materialName,
+ status: 2,
+ tousseBarcode: tousseBarcode,
+ amount: amountSum - newUnconfirmedAmount,
+ errorDamageQmKey: errorDamageQmKey,
+ unconfirmedAmount: 0,
+ intoBasketAmount: 0,
+ amountPerTousse: amountPerTousse
+ };
+ newJsonArray.push(item);
+ }
+ }
+ if (isErrorExist) {
+ window.parent.document.getElementById('showTousseName' + row).className = 'input-a-brown';
+ window.parent.document.getElementById('recyclingDamageButton' + row).className = 'btn-c-edit';
+ } else {
+ var sumAmount = 0;
+ if (newErrorJsonArray.length > 0) {
+ for (var i = 0; i < newErrorJsonArray.length; i++) {
+ sumAmount += newErrorJsonArray[i].amount;
+ }
+ }
+ if (sumAmount == 0) {
+ window.parent.document.getElementById('showTousseName' + row).className = 'input-a';
+ } else {
+ window.parent.document.getElementById('showTousseName' + row).className = 'input-a-yellow';
+ }
+ window.parent.document.getElementById('recyclingDamageButton' + row).className = 'btn-c';
+ }
+ if (isErrorAmountZero && $("#damageRemark").val() != "") {
+ alert("填写了备注,请选择报损的材料!");
+ return;
+ }
+ window.parent.setTousseItemRecyclingDamage(row, JSON.stringify(newJsonArray), $('#damageRemark').val());
+ closeLayer();
+}
+//获取报损的材料信息,添加质量监测用
+function getMaterialMsg() {
+ var retArray = new Array();
+ var length = $("#recyclingDamageTable tbody tr").length;
+ for (var i = 0; i < length; i++) {
+ var amount = parseInt($('#errorAmount' + i).html());
+ var tousseBarcode = $('#tousseBarcode' + i).val();
+ var materialDefinitionId = $('#materialDefinitionId' + i).attr('value');
+ var materialName = $('#sourceMaterialName' + i).attr('value');
+ if (amount > 0) {
+ var item = {
+ materialName: materialName,
+ amount: amount
+ };
+ retArray.push(item);
+ }
+ }
+ return retArray;
+}
+//添加质量监测记录
+function addQM() {
+
+ var width = 780;
+ var height = 650;
+ var designedTousseWidth = 1080;
+ var designedTousseHeight = 770;
+ var designedWidth = 1920;
+ var designedHeight = 1080;
+ var actualWidth = window.screen.availWidth;
+ var actualHeight = window.screen.availHeight;
+ var offsetTop = 100;
+ var heightExtra = 10;
+ if (resolution == '1980') {
+ width = 1380;
+ height = 830;
+ }
+ var zoomRatio = calculateZoomRatio(designedWidth, designedHeight, actualWidth, actualHeight);
+ var size = calculateSizeAfterZoom(designedTousseWidth, designedTousseHeight, zoomRatio);
+
+ width = size.width;
+ height = size.height;
+
+ offsetTop = offsetTop * zoomRatio;
+ var mMsg = getMaterialMsg();
+ parent.setMaterialMsg(mMsg);
+ var url = 'addQualityMonitoring.jsp?resolution=' + resolution + '&width=' + width + '&height=' + height + '&errorDamageQmKey=' + errorDamageQmKey + '&tousseName=' + tousseName
+ + '&depart=' + depart + '&recyclingUser=' + recyclingUser + '&circuitNurse=' + circuitNurse + '&operationRoom=' + operationRoom
+ var index = parent.layer.open({
+ type: 2,
+ title: ['添加质量监测记录', true],
+ content: encodeURI(url),
+ area: [width + 'px', height + heightExtra + 'px'],
+ border: [5, 0.3, '#fff', true],
+ closeBtn: [2, true],
+ offset: [offsetTop + 'px', '']
+ });
+ parent.setQmLayerIndex(index);
+}
+function openMaterialImage(materialName, materialDefinitionId) {
+ $.ajax({
+ type: 'get',
+ url: WWWROOT + '/disinfectSystem/baseData/materialDefinitionAction!getMaterialPictureAmount.do',
+ data: 'name=' + encodeURIComponent(materialName),
+ dataType: 'text',
+ success: function (msg) {
+ var amount = parseInt(msg, 10);
+ var items = new Array();
+ if (amount <= 0) {
+ items.push({
+ src: 'tousseImage.jsp?materialName=' + encodeURIComponent(materialName) + '&materialDefinitionId=' + materialDefinitionId + "&number=" + 1,
+ type: 'iframe'
+ });
+ } else {
+ for (var i = 0; i < amount; i++) {
+ items.push({
+ src: 'tousseImage.jsp?materialName=' + encodeURIComponent(materialName) + '&materialDefinitionId=' + materialDefinitionId + "&number=" + (i + 1),
+ type: 'iframe'
+ });
+ }
+ }
+
+ window.parent.$.magnificPopup.open({
+ items: items,
+ mainClass: 'materialPicClass',
+ tClose: '关闭(Esc)',
+ gallery: {
+ enabled: true,
+ tPrev: '上一页 (左箭头)', // Alt text on left arrow
+ tNext: '下一页 (右箭头)'
+ },
+ image: {
+ verticalFit: true
+ },
+ type: 'image' // this is default type
+ });
+ },
+ error: function (XMLHttpRequest, textStatus, errorThrown) {
+ }
+ });
+}
+
+function closeErrorWin(returnValue) {
+ if (returnValue == '') {
+ return;
+ }
+
+ if (!isUndefinedOrNullOrEmpty(returnValue)) {
+ $('#damageRemark').val(returnValue);
+ } else if (returnValue == "") {
+ $('#damageRemark').val("");
+ }
+
+ layer.close(damageIndex);
+}
+
+function buildTableTR(amontPerTousse, materialDefinitionId, materialName, totalCount, errorCount, tousseBarcode, unconfirmedAmount, detailId, status) {
+ var i = $("#recyclingDamageTable tbody tr").length;
+ var sourceMaterialName = materialName;
+ if (tousseBarcode != "") {
+ materialName += "
" + tousseBarcode;
+ }
+ unconfirmedAmount = parseInt(unconfirmedAmount || 0);
+ errorCount = parseInt(errorCount || 0);
+ var trColor = (errorCount + unconfirmedAmount == 0) ? '' : 'brown';
+ var errorElement = $('
' +
+ '' +
+ '' +
+ '' +
+ '' +
+ '' +
+ '' +
+ '' +
+ '' +
+ '' +
+ '' +
+ '' + materialName + ' | ' +
+ '' + totalCount + ' | ' +
+ '' + (errorCount + unconfirmedAmount) + ' | ' +
+ ' | ' +
+ '
');
+ $("#recyclingDamageTable").append(errorElement);
+}
+
+var damageIndex = null;
+$(document).ready(function () {
+ $.ajax({
+ type: 'post',
+ url: WWWROOT + '/disinfectSystem/recyclingRecordAction!getRecyclingErrorJson.do',
+ data: { tousseDefinitionID: tousseDefinitionID, tousseAmount: tousseCount, type: 'recyclingDamage' },
+ dataType: 'json',
+ success: function (msg) {
+ var recyclingDamageJson = window.parent.getTousseItemRecyclingDamage(row);
+ var json = [];
+ if (recyclingDamageJson != "") {
+ json = JSON.parse(recyclingDamageJson);
+ json = newArray(json);
+ }
+ for (var i = 0; i < msg.length; i++) {
+ //缺失数量
+ var errorCount = 0;
+ var unconfirmedAmount = 0;
+ //有丢失的器械包数量
+ var totalCount = msg[i].totalCount;
+ for (var j = 0; j < json.length; j++) {
+ if (msg[i].materialDefinitionId == json[j].materialDefinitionId) {
+ if (json[j].tousseBarcode != "" || json[j].status == 0) {
+ buildTableTR(msg[i].amontPerTousse, msg[i].materialDefinitionId, msg[i].name, totalCount, json[j].amount, json[j].tousseBarcode, json[j].unconfirmedAmount, json[j].id, json[j].status);
+ totalCount = 0;
+ } else {
+ errorCount += json[j].amount;
+ unconfirmedAmount += json[j].unconfirmedAmount;
+ }
+ }
+ }
+ if (totalCount > 0) {
+ buildTableTR(msg[i].amontPerTousse, msg[i].materialDefinitionId, msg[i].name, totalCount, errorCount, "", unconfirmedAmount, '', 2);
+ }
+ }
+ },
+ error: function () {
+ }
+ });
+ $('#damageRemark').val(damageRemark);
+ if (!sstsConfig.enableRecycleMaterialErrorDamageRemark) {
+ $('#damageRemarkBox').hide();
+ }
+ //实现对字符码的截获,keypress中屏蔽了这些功能按键
+ document.onkeypress = banBackSpace;
+ //对功能按键的获取
+ document.onkeydown = banBackSpace;
+ $('#damageRemark').click(function () {
+ if (params_recordType != 'history') {
+ var width = document.body.clientWidth - 100;
+ var height = document.body.clientHeight - 100;
+ var offsetTop = 50;
+
+ var url = WWWROOT + '/disinfectsystem/recyclingApplication/selectEndCause.jsp?time=' + new Date().getTime() + '&optionType=error';
+ damageIndex = layer.open({
+ type: 2,
+ title: ['报损备注', true],
+ content: url,
+ area: [width + 'px', height + 'px'],
+ border: [5, 0.3, '#fff', true],
+ closeBtn: [2, true],
+ offset: [offsetTop + 'px', '']
+ });
+ }
+ });
+})
\ No newline at end of file