From 3b97fc694b712be7d41218532b09d8bc7fa4d395 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E4=B8=89=E7=82=AE?= <15856818120@163.com> Date: Mon, 9 Feb 2026 13:37:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8D=E5=8F=91=E8=B4=A7=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E7=BC=96=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/aq_demand_plan/child/send_out_detail.js | 105 +++-- .../child/send_out_detail_print.js | 368 ++++++++++++++++++ .../child/send_out_unplanned_form_table.js | 9 + .../child/send_out_detail_print.html | 247 ++++++++++++ 4 files changed, 695 insertions(+), 34 deletions(-) create mode 100644 js/aq_demand_plan/child/send_out_detail_print.js create mode 100644 page/aq_demand_plan/child/send_out_detail_print.html diff --git a/js/aq_demand_plan/child/send_out_detail.js b/js/aq_demand_plan/child/send_out_detail.js index 93ce8b9..a467471 100644 --- a/js/aq_demand_plan/child/send_out_detail.js +++ b/js/aq_demand_plan/child/send_out_detail.js @@ -38,39 +38,41 @@ function getPurchaseDetails() { }, function (xhr, status, error) { errorFn(xhr, status, error) }, null); + // 基本数据表格赋值 function setTableData(obj) { - const $dataBody = $('#dataBody'); - $dataBody.empty(); - - if(obj.length > 0){ - for (let i = 0; i < obj.length; i++) { - const dataList = obj[i]; - const trHtml = ` + const $dataBody = $('#dataBody'); + $dataBody.empty(); + + if (obj.outPlanVoList.length > 0) { + for (let i = 0; i < obj.outPlanVoList.length; i++) { + const dataList = obj.outPlanVoList[i]; + console.log("aaa=",dataList.cgNum) + const trHtml = ` - ${dataList.planCode || '--'} - ${dataList.cgNum || '--'} - ${formatMoney(dataList.money)} - ${dataList.lkNum || '--'} - ${dataList.fhDay || '--'} - ${dataList.jbUser || '--'} - ${dataList.address || '--'} + ${obj.planCode || '--'} + ${dataList.cgNum } + ${formatMoney(obj.money)} + ${dataList.lkNum } + ${obj.fhDay || '--'} + ${obj.jbUser || '--'} + ${obj.address || '--'} - + `; - $dataBody.append(trHtml); - } - - $('#remark').html(obj[0].remark); - }else{ - const trHtml = ` + $dataBody.append(trHtml); + } + + $('#remark').html(obj.remark); + } else { + const trHtml = ` ${obj.planCode || '--'} - ${obj.cgNum || '--'} + ${obj.cgNum} ${formatMoney(obj.money)} - ${obj.lkNum || '--'} + ${obj.lkNum} ${obj.fhDay || '--'} ${obj.jbUser || '--'} ${obj.address || '--'} @@ -79,16 +81,16 @@ function getPurchaseDetails() { `; - $dataBody.append(trHtml); - // $('#planCode').html(obj.planCode); - // $('#cgNum').html(obj.cgNum); - // $('#money').html(formatMoney(obj.money)); - // $('#lkNum').html(obj.lkNum); - // $('#fhDay').html(obj.fhDay); - // $('#jbUser').html(obj.jbUser); - // $('#address').html(obj.address); - $('#remark').html(obj.remark); - } + $dataBody.append(trHtml); + // $('#planCode').html(obj.planCode); + // $('#cgNum').html(obj.cgNum); + // $('#money').html(formatMoney(obj.money)); + // $('#lkNum').html(obj.lkNum); + // $('#fhDay').html(obj.fhDay); + // $('#jbUser').html(obj.jbUser); + // $('#address').html(obj.address); + $('#remark').html(obj.remark); + } // 供应商信息 setSubInfos(obj.supInfoList); // 附件文档 @@ -120,7 +122,7 @@ function getPurchaseDetailsList() { if (result.code === 200) { dataObj = result.data; // 新增:处理批次数据并生成标签 - console.log("数据:",result.data) + console.log("数据:", result.data) handleBatchData(result.data); // 默认显示第一批次数据 if (currentBatch) { @@ -392,3 +394,38 @@ function print() { deferred: $.Deferred() }); } + +function printHtml(uuid) { + let id = objParam.id; + + let paramsObj = { + id:id, // 保留原有参数 + uuid: uuid // 新增打印所需的uuid + }; + + let layerIndex = parent.layer.open({ + id: 'printSuccess', + type: 2, + title: ['
采购发货单打印
', 'font-size:16px;background-color:#f0f0f0;display: flex;align-items: center;'], + content: '../aq_demand_plan/child/send_out_detail_print.html', + shade: 0.3, + anim: 2, + shadeClose: false, + area: ['92%', '95%'], + move: false, + success: function () { + if (paramsObj) { + let iframeWin = parent.window["layui-layer-iframe" + layerIndex]; + iframeWin.setParams(JSON.stringify(paramsObj)); + + // setTimeout(() => { + // // 方式1:调用子页面的print方法(推荐,子页面控制打印逻辑) + // iframeWin.print(); + // }, 8000); // 延迟800ms,确保子页面数据渲染完成 + } + }, + cancel: function () { }, + end: function () { } + }); + +} diff --git a/js/aq_demand_plan/child/send_out_detail_print.js b/js/aq_demand_plan/child/send_out_detail_print.js new file mode 100644 index 0000000..8adcd94 --- /dev/null +++ b/js/aq_demand_plan/child/send_out_detail_print.js @@ -0,0 +1,368 @@ +let objParam, dataObj; +let batchData = {}; +let currentBatch = ''; +let form, table, upload, tableIns, layer; +let pageNum = 1; + +function setParams(params) { + objParam = JSON.parse(params); + console.error(objParam); + + $('#code').html(objParam.planCode); + $('#titleName').html(objParam.proName); + layui.use(["form", "table", 'upload', 'layer'], function () { + form = layui.form; + table = layui.table; + upload = layui.upload; + layer = layui.layer; + getPurchaseDetails(); + getPurchaseDetailsList(); + }); +} + +// 采购详情 +function getPurchaseDetails() { + let params = { + encryptedData: JSON.stringify({ + 'id': objParam.id, + 'uuid': objParam.uuid + }) + }; + let url = dataUrl + 'backstage/purchase/getPurchaseDetail'; + ajaxRequest(url, "POST", params, true, function () { + }, function (result) { + console.error(result); + if (result.code === 200) { + setTableData(result.data); + } else { + } + }, function (xhr, status, error) { + errorFn(xhr, status, error) + }, null); + + // 基本数据表格赋值 + function setTableData(obj) { + const $dataBody = $('#dataBody'); + $dataBody.empty(); + + const trHtml = ` + + ${obj.planCode || '--'} + ${obj.cgNum} + ${formatMoney(obj.money)} + ${obj.lkNum} + ${obj.fhDay || '--'} + ${obj.jbUser || '--'} + ${obj.address || '--'} + + `; + $dataBody.append(trHtml); + $('#remark').html(obj.remark); + // 供应商信息 + setSubInfos(obj.supInfoList); + // 附件文档 + setFileTable(obj.fileList); + } +} + +function formatMoney(value) { + // 第一步:处理空值/异常值,转为0 + let num = 0; + if (value !== null && value !== undefined && value !== '' && !isNaN(Number(value))) { + num = Number(value); + } + // 第二步:保留2位小数,返回带¥的格式化字符串 + return '¥ ' + num.toFixed(2); +} + +// 采购发货明细 +function getPurchaseDetailsList() { + let params = { + encryptedData: JSON.stringify({ + 'id': objParam.id, + 'uuid': objParam.uuid + }) + }; + let url = dataUrl + 'backstage/purchase/getPurchaseDetailsListBatch'; + ajaxRequest(url, "POST", params, true, function () { + }, function (result) { + console.error(result); + if (result.code === 200) { + dataObj = result.data; + // 新增:处理批次数据并生成标签 + console.log("数据:", result.data) + handleBatchData(result.data); + // 默认显示第一批次数据 + if (currentBatch) { + setBaseTable(batchData[currentBatch]); + } else { + let allData = mergeAllBatchData(result.data); + setBaseTable(allData); + } + } + }, function (xhr, status, error) { + errorFn(xhr, status, error) + }, null); +} + +// 新增:处理批次数据,生成批次标签 +function handleBatchData(data) { + // 1. 批次按外层数组索引区分(第1批次、第2批次...) + let batchCount = data.length; + if (batchCount === 0) { + $('#batch-tabs').html('
暂无批次数据
'); + return; + } + + // 2. 构建批次数据映射(key:批次号,value:该批次的batchList数据) + batchData = {}; + data.forEach((item, index) => { + let batchNum = index + 1; // 批次号从1开始 + batchData[batchNum] = item.batchList || []; + }); + + // 3. 生成批次标签HTML + let tabHtml = ''; + for (let i = 1; i <= batchCount; i++) { + let batchName = `第${i}批次`; + let isActive = i === 1 ? 'active' : ''; // 默认选中第一个批次 + if (i === 1) { + currentBatch = i; // 默认选中第一个批次 + } + tabHtml += `
${batchName}
`; + } + + // 4. 渲染标签并绑定点击事件 + $('#batch-tabs').html(tabHtml); + $('.batch-tab').click(function () { + // 切换激活状态 + $('.batch-tab').removeClass('active'); + $(this).addClass('active'); + // 获取选中的批次 + currentBatch = $(this).data('batch'); + // 筛选对应批次的数据并渲染表格 + setBaseTable(batchData[currentBatch] || []); + // 重置搜索框 + resetSearch(); + }); +} + +// 新增:合并所有批次数据(用于无批次选中时显示) +function mergeAllBatchData(data) { + let allData = []; + data.forEach(item => { + if (item.batchList && item.batchList.length > 0) { + allData = allData.concat(item.batchList); + } + }); + return allData; +} + +// 新增:根据批次筛选数据 +function filterDataByBatch(originalData, batch) { + if (!batch || !originalData || originalData.length === 0) { + return mergeAllBatchData(originalData); + } + // 返回指定批次的batchList数据 + let batchIndex = batch - 1; // 转换为数组索引 + return originalData[batchIndex]?.batchList || []; +} + +// 供应商信息赋值 +function setSubInfos(list) { + $('#supplier-table-box tbody tr:not(:first)').remove(); + let html = ''; + if (list && list.length > 0) { + $.each(list, function (index, item) { + html += '' + + '' + item.supName + '' + + '' + item.cgNum + '' + + ' ¥ ' + (item.money ? item.money : 0) + '' + + ''; + }) + } else { + html = '暂无数据'; + } + $('#supplier-table tbody').after(html); +} + +// 附件文档赋值 +function setFileTable(fileList) { + $('#file-table tbody tr:not(:first)').remove(); + let html = ''; + if (fileList && fileList.length > 0) { + $.each(fileList, function (index, item) { + html += '' + + '' + handleFileType(item.fileName) + item.fileName + '' + + '' + (item.type ? item.type : '入库附件') + '' + + '' + item.createName + '' + + '' + item.createTime + '' + + '预览' + + '下载' + + '' + + ''; + }) + } else { + html = '暂无数据'; + } + $('#file-table tbody').after(html); +} + +// 处理文件类型 +function handleFileType(value) { + value = value.toLowerCase(); + let src = ''; + if (value.indexOf('docx') > -1 || value.indexOf('doc') > -1) { + src = '../../../images/docx.png' + } else if (value.indexOf('xls') > -1 || value.indexOf('xlsx') > -1) { + src = '../../../images/xlsx.png' + } else if (value.indexOf('pdf') > -1) { + src = '../../../images/pdf.png' + } else if (value.indexOf('png') > -1 || value.indexOf('jpg') > -1 || value.indexOf('jpeg') > -1) { + src = '../../../images/img_icon.png' + } + return '' +} + +// 查询 +function search() { + let keyWord = $('#name').val().trim(); + let keyWord2 = $('#model').val().trim(); + // 获取当前批次的数据源 + let currentData = currentBatch ? filterDataByBatch(dataObj, currentBatch) : mergeAllBatchData(dataObj); + + if (!keyWord && !keyWord2) { + setBaseTable(currentData); + return; + } + + // 筛选逻辑(适配batchList中的字段) + let filteredList = currentData.filter(item => { + let nameMatch = true; + let modelMatch = true; + + if (keyWord && item.name) { + nameMatch = item.name.indexOf(keyWord) > -1; + } + if (keyWord2 && item.model) { + modelMatch = item.model.indexOf(keyWord2) > -1; + } + + return nameMatch && modelMatch; + }); + + setBaseTable(filteredList); +} + +// 重置 +function resetSearch() { + $('#name').val(''); + $('#model').val(''); + // 重置时显示当前批次的完整数据 + let currentData = currentBatch ? filterDataByBatch(dataObj, currentBatch) : mergeAllBatchData(dataObj); + setBaseTable(currentData); +} + + +function setBaseTable(results) { + let html = ""; + if (results && results.length > 0) { + results.forEach((item, index) => { + html += ""; + html += "" + (index + 1) + ""; + html += "" + (item.type || '') + ""; + html += "" + (item.name || '') + ""; + html += "" + (item.model || '') + ""; + html += "" + (item.unit || '') + ""; + html += "" + (item.needNum || '') + ""; + html += "" + (item.cgNum || '') + ""; + html += "" + (item.lkNum || '') + ""; + html += "" + (item.supName || '') + ""; // 无数据则显示空 + html += "" + (item.ccDay || '') + ""; + html += "" + (item.jyDay || '') + ""; + html += "" + (item.remark || '') + ""; + html += ""; + }); + } else { + html += "没有相关数据"; + } + $("#baseTable tbody").empty().append(html); +} + +// 二维码 +function qrCode() { + openIframeByParamObj("downLoadQrCode", "二维码", "./send_out_qrcode.html", "92%", "95%", objParam); +} + +// 导出 +function exportExcel() { + let params = { + 'name': $('#name').val(), + 'model': $('#model').val(), + 'id': objParam.id, + 'batch': currentBatch // 传递当前选中批次 + } + let url = dataUrl + "backstage/purchase/exportDetailsList"; + exportExcelUtil(url, '采购发货明细', JSON.stringify(params)); +} + +// 打印 +function print() { + Print('#table-box', { + onStart: function () { + console.log('onStart', new Date()) + }, + onEnd: function () { + console.log('onEnd', new Date()) + } + }) +} + +// 预览文件 +function viewFile(obj) { + let fileName = obj.fileName.toLowerCase(); + if (fileName.indexOf('png') > -1 || fileName.indexOf('jpg') > -1 || fileName.indexOf('jpeg') > -1) { + layer.photos({ + shade: 0.5, + photos: { + "title": "图片预览", + "start": 0, + "data": [ + { + "alt": "layer", + "pid": 1, + "src": fileUrl + obj.fileUrl + '?token=' + sessionStorage.getItem("gz-token"), + } + ] + } + }); + } else { + // 调用公司的预览文件的服务 + commonViewFile(obj.fileUrl); + } +} + +// 下载文件 +function downLoadFile(obj) { + let url = dataUrl + "sys/file/download?fileId=" + obj.id; + downLoadFileUtil(url, obj.fileName, null); +} + +// 打印 +function print() { + $("#main-box").print({ + globalStyles: true, + mediaPrint: false, + stylesheet: '../../../css/aq_demand_plan/apply_plan_detail.css', + noPrintSelector: ".no-print", + iframe: true, + append: '', + prepend: '
【领料发货单】
', + manuallyCopyFormValues: true, + deferred: $.Deferred() + }); +} + +function printHtml(uuid) { + +} diff --git a/js/aq_demand_plan/child/send_out_unplanned_form_table.js b/js/aq_demand_plan/child/send_out_unplanned_form_table.js index ce83a03..a66fdf3 100644 --- a/js/aq_demand_plan/child/send_out_unplanned_form_table.js +++ b/js/aq_demand_plan/child/send_out_unplanned_form_table.js @@ -66,6 +66,15 @@ function setSelectData(modelId) { // 校验数据 function checkValue(that, type) { let value = $(that).val(); + + // 核心改动1:统一处理前置0(保留纯0的情况) + let processedValue = value.replace(/^0+(?=\d)/, ''); + if (processedValue === '') { + processedValue = '0'; // 输入全是0的情况(如0000)转为0 + } + // 先更新输入框值为处理后的值 + $(that).val(processedValue); + value = processedValue; // 后续校验使用处理后的值 if (type === 1) { // 采购量 const regex = /^(0|[1-9]\d{0,6})$/; if (!regex.test(value) && value) { diff --git a/page/aq_demand_plan/child/send_out_detail_print.html b/page/aq_demand_plan/child/send_out_detail_print.html new file mode 100644 index 0000000..7c57c29 --- /dev/null +++ b/page/aq_demand_plan/child/send_out_detail_print.html @@ -0,0 +1,247 @@ + + + + + + + 采购发货详情 + + + + + + + + +
+
+
+ +
+

+

+
+
+
+ +
+
+
+
+ +

采购发货资料

+
+
+ + + + + + + + + + + + + + + + + + + + + + +
需求计划编号采购数量采购金额利库数量采购发货时间经办人收货地址
备注
+
+
+
+
+ +

供货供应商信息

+
+
+ + + + + + +
供应商名称采购数量采购金额
+
+
+
+
+ +

附件文档

+
+
+ + + + + + + + +
文件名文件类型上传人员上传时间操作
+
+
+
+
+ +

采购发货明细

+
+ +
+
+
+ 搜索信息 +
+
+
+
+
+ +
+
+
+
+ +
+
+
+ + + + +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + +
序号类型名称规格单位需要量采购量利库量供应商出厂日期检验日期备注
+
+
+
+
+ +
+
+ +

签字确认

+
+
+ + + + + + + +
+
记账人
+
+
+
领料人
+
+
+
制单人
+
+
+
审核人
+
+
+
+
+
+ + + + + + + + + +