| | |
| | | |
| | | |
| | | //保存数据 |
| | | function saveScanPrintData(rows) { |
| | | layer.confirm("已扫描" + rows.length + "条数据,确认入库?", { |
| | | icon: 3, |
| | | title: '提示' |
| | | }, function (index) { |
| | | wcp.ui.setBusy("body", wcp.ajax({ |
| | | url: 'scanPrintController/saveScanPrintData?printType=' + '${printType}' + '&viewId=' + '${viewId}', |
| | | data: JSON.stringify(rows), |
| | | }).done(function (result) { |
| | | params.callBack(); |
| | | //关闭窗口 |
| | | closeWindow(); |
| | | })); |
| | | }) |
| | | } |
| | | <%--function saveScanPrintData(rows) {--%> |
| | | <%-- layer.confirm("已扫描" + rows.length + "条数据,确认入库?", {--%> |
| | | <%-- icon: 3,--%> |
| | | <%-- title: '提示'--%> |
| | | <%-- }, function (index) {--%> |
| | | <%-- wcp.ui.setBusy("body", wcp.ajax({--%> |
| | | <%-- url: 'scanPrintController/saveScanPrintData?printType=' + '${printType}' + '&viewId=' + '${viewId}',--%> |
| | | <%-- data: JSON.stringify(rows),--%> |
| | | <%-- }).done(function (result) {--%> |
| | | <%-- params.callBack();--%> |
| | | <%-- //关闭窗口--%> |
| | | <%-- closeWindow();--%> |
| | | <%-- }));--%> |
| | | <%-- })--%> |
| | | <%--}--%> |
| | | |
| | | <%--//保存数据--%> |
| | | <%--function saveScanPrintData(rows) {--%> |
| | | <%-- // getBoxNum(rows);--%> |
| | | <%-- layer.prompt({--%> |
| | | <%-- formType: 2,--%> |
| | | <%-- value: '',--%> |
| | | <%-- title: '请添加盒号'--%> |
| | | <%-- }, function (value, index, elem) {--%> |
| | | <%-- wcp.ui.setBusy("body", wcp.ajax({--%> |
| | | <%-- url: 'scanPrintController/saveScanPrintData?printType=' + '${printType}' + '&viewId=' + '${viewId}' + '&boxNum=' + value,--%> |
| | | <%-- data: JSON.stringify(rows),--%> |
| | | <%-- }).done(function (result) {--%> |
| | | <%-- params.callBack();--%> |
| | | <%-- //关闭窗口--%> |
| | | <%-- closeWindow();--%> |
| | | <%-- }));--%> |
| | | <%-- });--%> |
| | | <%--}--%> |
| | | |
| | | //保存数据 |
| | | function saveScanPrintData(rows) { |
| | | layer.prompt({ |
| | | formType: 2, |
| | | value: '', |
| | | title: '请添加盒号' |
| | | }, function (value, index, elem) { |
| | | wcp.ui.setBusy("body", wcp.ajax({ |
| | | url: 'scanPrintController/saveScanPrintData?printType=' + '${printType}' + '&viewId=' + '${viewId}' + '&boxNum=' + value, |
| | | data: JSON.stringify(rows), |
| | | }).done(function (result) { |
| | | params.callBack(); |
| | | //关闭窗口 |
| | | closeWindow(); |
| | | })); |
| | | // 首先获取已存在的盒号 |
| | | wcp.ui.setBusy("body", wcp.ajax({ |
| | | url: 'scanPrintController/getBoxNum', |
| | | data: JSON.stringify(rows), |
| | | }).done(function (result) { |
| | | debugger; |
| | | var boxNumList = result || []; // 假设AjaxResponse的data字段包含实际数据 |
| | | var existingBoxNum = boxNumList.length > 0 ? boxNumList[0] : ''; // 取第一个盒号或空字符串 |
| | | |
| | | |
| | | layer.prompt({ |
| | | formType: 2, |
| | | title: '请添加盒号' |
| | | }, function (inputBoxNum, index, elem) { |
| | | // 如果已存在盒号且与输入的盒号不同,则提示用户确认 |
| | | if (existingBoxNum && existingBoxNum !== inputBoxNum) { |
| | | layer.confirm('当前档案已存在盒号 "' + existingBoxNum + '",您输入的是 "' + inputBoxNum + '",是否要更改盒号?', { |
| | | icon: 3, |
| | | title: '确认更改盒号' |
| | | }, function (confirmIndex) { |
| | | // 确认更改,执行保存 |
| | | performSave(inputBoxNum, rows); |
| | | layer.close(confirmIndex); |
| | | }, function () { |
| | | // 取消更改,重新打开输入框 |
| | | layer.close(index); |
| | | }); |
| | | } else { |
| | | // 盒号相同或不存在已存在的盒号,直接保存 |
| | | performSave(inputBoxNum, rows); |
| | | } |
| | | }); |
| | | })).fail(function () { |
| | | // 获取盒号失败时,直接让用户输入 |
| | | layer.prompt({ |
| | | formType: 2, |
| | | value: '', |
| | | title: '请添加盒号' |
| | | }, function (value, index, elem) { |
| | | wcp.ui.setBusy("body", wcp.ajax({ |
| | | url: 'scanPrintController/saveScanPrintData?printType=' + '${printType}' + '&viewId=' + '${viewId}' + '&boxNum=' + value, |
| | | data: JSON.stringify(rows), |
| | | }).done(function (result) { |
| | | params.callBack(); |
| | | //关闭窗口 |
| | | closeWindow(); |
| | | })); |
| | | }); |
| | | }); |
| | | } |
| | | |
| | | |
| | | // 执行保存操作的辅助函数 |
| | | function performSave(boxNum, rows) { |
| | | wcp.ui.setBusy("body", wcp.ajax({ |
| | | url: 'scanPrintController/saveScanPrintData?printType=' + '${printType}' + '&viewId=' + '${viewId}' + '&boxNum=' + boxNum, |
| | | data: JSON.stringify(rows), |
| | | }).done(function (result) { |
| | | params.callBack(); |
| | | //关闭窗口 |
| | | closeWindow(); |
| | | })); |
| | | } |
| | | |
| | | function getBoxNum(rows) { |
| | | wcp.ui.setBusy("body", wcp.ajax({ |
| | | url: 'scanPrintController/getBoxNum', |
| | | data: JSON.stringify(rows), |
| | | }).done(function (result) { |
| | | console.log(result); |
| | | })); |
| | | } |
| | | </script> |
| | | </html> |