From 7b0af67c095ad203cc1a50dc4048dc7d260fb060 Mon Sep 17 00:00:00 2001 From: jiang Date: Wed, 16 Jul 2025 21:40:55 +0800 Subject: [PATCH] 1 --- css/aq_demand_plan/send_out_form.css | 11 +- .../child/send_out_unplanned_form.js | 400 ++++++++++++++++++ js/aq_demand_plan/send_out_list.js | 6 + .../child/send_out_unplanned_form.html | 153 +++++++ page/aq_demand_plan/send_out_list.html | 221 +++++----- 5 files changed, 687 insertions(+), 104 deletions(-) create mode 100644 js/aq_demand_plan/child/send_out_unplanned_form.js create mode 100644 page/aq_demand_plan/child/send_out_unplanned_form.html diff --git a/css/aq_demand_plan/send_out_form.css b/css/aq_demand_plan/send_out_form.css index 8d77ec0..fc5d662 100644 --- a/css/aq_demand_plan/send_out_form.css +++ b/css/aq_demand_plan/send_out_form.css @@ -26,6 +26,15 @@ span.required { height: 120px; } + +#no_data_title { + width: 100%; + + flex-direction: column; + justify-content: space-evenly; + margin-top: 2%; +} + blockquote { display: flex; align-items: center; @@ -140,4 +149,4 @@ blockquote { -webkit-border-radius: 2em; -moz-border-radius: 2em; border-radius: 2em -} \ No newline at end of file +} diff --git a/js/aq_demand_plan/child/send_out_unplanned_form.js b/js/aq_demand_plan/child/send_out_unplanned_form.js new file mode 100644 index 0000000..2541fab --- /dev/null +++ b/js/aq_demand_plan/child/send_out_unplanned_form.js @@ -0,0 +1,400 @@ +let objParam, dataObj, fileList = new Array(), imgListUp = new Array(); +let form, laydate, layer, upload, table, util; +let pageNum = 1, tableIns; // 定义分页 +let supplierList = []; // 供应商下拉选 +getProList() +function setParams(obj) { + objParam = JSON.parse(obj); + console.error(objParam); + + $('#proName').html(objParam.proName); + layui.use(['form', 'layer', 'laydate', 'upload', 'table'], function () { + form = layui.form; + layer = layui.layer; + laydate = layui.laydate; + upload = layui.upload; + table = layui.table; + util = layui.util; + var userData = JSON.parse(sessionStorage.getItem("us")); + $('#jbUser').val(userData.username); + laydate.render({ + elem: '#fhDay' + }); + laydate.render({ + elem: '.cjDate' + }); + laydate.render({ + elem: '.jyDate' + }); + + form.verify(); + form.on('submit(formData)', function (data) { + // 提交前确认 + beforeSubmitApply(data); + }); + form.render(); + form.on('select(supplier)', function (data) { + if (data.value) { + let value = $(data.elem).val(); + let item = JSON.parse($(data.elem).find('option:checked').attr('item')); + let modelId = $(data.elem).find('option:checked').attr('modelId'); + // 安全工器具类型、合同ID、厂家ID 进行校验 + let flag = supCheck(modelId, item.contractId, value); + if (!flag) { + $(data.elem).val(''); + return layer.msg('该厂家合同无此工器具,请重新选择', { icon: 7 }); + } + $('.supplier' + modelId + '').each(function (index, item) { + let id = $(this).find('option:checked').val(); + if (id && id === value && !($(data.elem).is($(this)))) { + $(data.elem).val(''); + return layer.msg('请勿重复选择供应商', { icon: 7 }); + } + }) + } + }); + let uploadObj = upload.render({ + elem: '#test2', + multiple: true, + dataType: "json", + exts: 'jpg|png|jpeg|doc|docx|pdf|xlsx|xls', + acceptMime: 'image/jpg,image/png,image/jpeg,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + number: 5, //最大上传数量 + size: 1024 * 10, //最大文件大小,单位k + auto: false, //是否自动上传 ,默认为true + bindAction: '#hideUpload', //绑定的按钮 + choose: function (obj) { + let length = $('.file-iteme').length; + if (length >= 5) { + return layer.msg('最多上传5个发货附件', { icon: 7 }); + } + uploadObj.config.elem.next()[0].value = ''; + let num = 0; + obj.preview(function (index, file, result) { + num ++; + if(num <= (5-length)){ + $('#uploader-list').append( + '
' + + '

x

' + + handleFileType(index, file, result) + + '
' + ); + let map = new Map();//将选择的图片索引和图片写成对象存入集合 + map.index = index; + map.file = file; + fileList.push(map); + } + }); + } + }); + }); + getSupplierList(); + +} +// 设置文件类型 +function handleFileType(index, file, result) { + let html = '', img = ''; + if(file.ext){ + file.ext = file.ext.toLowerCase(); + } + if(file.name){ + file.name = file.name.toLowerCase(); + } + if (file.ext === 'doc' || file.ext === 'docx') { + img = '../../../images/docx.png'; + } else if (file.ext === 'xls' || file.ext === 'xlsx') { + img = '../../../images/xlsx.png'; + } else if (file.ext === 'pdf') { + img = '../../../images/pdf.png'; + } else { + return ''; + } + html += '
' + + '' + + '

' + file.name + '

' + + '
'; + return html; +} + +// 删除文件 +$(document).on("click", ".file-iteme .handle", function (event) { + imgListUp.splice(0, imgListUp.length); + let index = $(this).next().attr('data-index'); + $.each(fileList, function (inx, ele) { + //对比删除文件索引 + //将未删除的存入新集合 + if (index != ele.index) { + imgListUp.push(ele); + } + }); + $(this).parent().remove(); + //将新文件集合替换老集合 + fileList.splice(0, fileList.length); + $.each(imgListUp, function (inx, ele) { + fileList.push(ele) + }); +}); + +function saveData2() { + $('#formSubmit').trigger('click') +} + +// 提交前确认 +function beforeSubmitApply() { + // 校验发货附件是否上传 + if (fileList.length === 0) { + return layer.msg('请上传发货附件', { icon: 7 }); + } + let dataList = getBaseTableData(); + // 校验 发货明细数据 + for (let i = 0; i < dataList.length; i++) { + let o = dataList[i]; + let list = o.supList; + let cgNum = 0,lkNum = 0; // 采购量、利库量 + for (let j = 0; j < list.length; j++) { + let l = list[j]; + cgNum += (l.cgNum ? parseInt(l.cgNum) : 0); + lkNum += (l.lkNum ? parseInt(l.lkNum) : 0); + if (!l.supId) { + return layer.msg('序号为' + (i + 1) + '的数据,未选择供应商', { icon: 7 }); + } + } + } + openIframeByParamObj("quickAddForm", "采购发货确认", "./send_out_confirm.html", "92%", "92%", dataList); +} + +// 提交 +function submitApply() { + let data = form.val('formInfo'); // form 表单的值 + let dataList = getBaseTableData(); + data.detailsList = (dataList || []).map(obj => { + const newObj = {}; + for (let key in obj) { + newObj[key] = obj[key] === undefined ? "" : obj[key]; + } + return newObj; + }); + + let formData = new FormData(); + //遍历最终文件集合 + for (let i = 0; i < fileList.length; i++) { + formData.append("file[]", fileList[i].file) + } + console.log(data); + formData.append('params', JSON.stringify(data)); + let loadingMsg = layer.msg('正在提交保存,请稍等...', { icon: 16, shade: 0.01, time: '0' }); + let url = dataUrl + 'backstage/purchase/addUnplannedPurchaseData'; + ajaxRequestByUploadFile(url, formData, function () { + $('.save').addClass("layui-btn-disabled").attr("disabled", true); + $('.cancel').addClass("layui-btn-disabled").attr("disabled", true); + }, function (result) { + layer.close(loadingMsg); + $('.save').removeClass("layui-btn-disabled").attr("disabled", false); + $('.cancel').removeClass("layui-btn-disabled").attr("disabled", false); + if (result.code === 200) { + parent.layer.msg(result.msg, { icon: 1 }); + closePage(result.data); + } else { + layer.msg(result.msg, { icon: 2 }); + } + }, function (xhr, status, error) { + layer.close(loadingMsg); // 关闭提示层 + layer.msg('服务异常,请稍后重试', { icon: 16, scrollbar: false, time: 2000 }); + $('.save').removeClass("layui-btn-disabled").attr("disabled", false); + $('.cancel').removeClass("layui-btn-disabled").attr("disabled", false); + errorFn(xhr, status, error) + }, null); +} + +// 供应商下拉选 +function getSupplierList() { + supplierList.splice(0, supplierList.length); + let encryptedData = {}; + let url = dataUrl + 'backstage/sup/getSelected?encryptedData=' + encodeURIComponent(JSON.stringify(encryptedData)); + ajaxRequest(url, "GET", null, false, function () { + }, function (result) { + if (result.code === 200) { + supplierList = result.data; + } + }, function (xhr, status, error) { + errorFn(xhr, status, error) + }, null); +} + + + +// 工程下拉选赋值 +function setSelectProData(proList) { + let html = ''; + $.each(proList, function (index, item) { + html += '' + }) + $('#projectId').empty().append(html); + layui.form.render(); +} + + +// 发货明细 +function getOutApplyDetails() { + let params = { + encryptedData: JSON.stringify({ + 'id': objParam.id + }) + }; + let url = dataUrl + 'backstage/purchase/getOutApplyDetails'; + ajaxRequest(url, "POST", params, true, function () { + }, function (result) { + if (result.code === 200) { + dataObj = result.data.data; + setBaseTable(result.data.list); + } + }, function (xhr, status, error) { + errorFn(xhr, status, error) + }, null); +} + +// 厂家校验 +function supCheck(modelId, contractId, value) { + let flag = false; + let params = { + encryptedData: JSON.stringify({ + 'supId': value, + 'contractId': contractId, + 'modelId': modelId + }) + }; + let url = dataUrl + 'backstage/sup/supCheck'; + ajaxRequest(url, "POST", params, false, function () { + }, function (result) { + if (result.code === 200) { + flag = true; + } + }, function (xhr, status, error) { + errorFn(xhr, status, error) + }, null); + return flag; +} + +// 库存数量校验 进行合同校验 +function maTypeCheck(modelId) { + let num = 0; + let params = { + encryptedData: JSON.stringify({ + 'modelId': modelId + }) + }; + let url = dataUrl + 'backstage/maType/maTypeCheck'; + ajaxRequest(url, "POST", params, false, function () { + }, function (result) { + if (result.code === 200) { + num = result.data; + } + }, function (xhr, status, error) { + errorFn(xhr, status, error) + }, null); + return num; +} + +function addFitDatas(params,pageSource){ + let data = JSON.parse(params) + data.map(item => { + item.unit = item.unitName + item.modelId = item.id + }) + setBaseTable(data); +} + +// 获取发货明细数据 +function getBaseTableData() { + let dataList = []; + $('#baseTable tbody tr.mainTr').each(function () { + let obj = {}; + // 基本信息 + let modelId = $(this).attr('id'); + let planId = $(this).attr('planId'); + let detailId = $(this).attr('detailId'); + let type = $(this).find('td').eq(2).html(); + let name = $(this).find('td').eq(3).html(); + let model = $(this).find('td').eq(4).html(); + let unit = $(this).find('td').eq(5).html(); + let needNum = $(this).find('td').eq(6).html(); + // 表格表单数据 + let formList = []; + let idx = $('.model' + modelId).length; + for (let i = 0; i < idx; i++) { + let formObj = {}; + let num = $('.num' + modelId).eq(i).val(); + let lkNum = $('.lkNum' + modelId).eq(i).val(); + let supplier = $('.supplier' + modelId).eq(i).val(); + let supplierName = $('.supplier' + modelId).eq(i).find('option:checked').text(); + let contractId = ''; + if (supplier) { + // 合同ID + let item = JSON.parse($('.supplier' + modelId).eq(i).find('option:checked').attr('item')); + contractId = item.contractId; + } + let cjDate = $('.cjDate' + modelId).eq(i).val(); + let jyDate = $('.jyDate' + modelId).eq(i).val(); + let remark = $('.remark' + modelId).eq(i).val(); + formObj.cgNum = num; + formObj.lkNum = lkNum; + formObj.supId = supplier; + formObj.supName = supplierName; + formObj.ccDay = cjDate; + formObj.jyDay = jyDate; + formObj.remark = remark; + formObj.detailId = detailId; + formObj.planId = planId; + formObj.modelId = modelId; + formObj.contractId = contractId; + formList.push(formObj); + } + obj.modelId = modelId; + obj.planId = planId; + obj.detailId = detailId; + obj.type = type; + obj.name = name; + obj.model = model; + obj.unit = unit; + obj.needNum = needNum; + obj.supList = formList; + dataList.push(obj); + }) + return dataList; +} + +// 关闭页面 +function closePage(data) { + let index = parent.layer.getFrameIndex(window.name); // 先得到当前 iframe层的索引 + if (data) { + let obj = { + resultData:data.resultData, + resultData2:data.resultData2, + id:data.planId + }; + let frameId = parent.document.getElementById('sendOutProDetail').getElementsByTagName("iframe")[0]; + frameId.contentWindow.sendOutSuccess(JSON.stringify(obj)); + } + parent.layer.close(index); // 再执行关闭 +} + + +// 工程下拉选 +function getProList() { + let url = dataUrl + 'backstage/planApply/getProSelect'; + ajaxRequest(url, "POST", null, false, function () { + }, function (result) { + if (result.code === 200) { + setSelectProData(result.data); + } + }, function (xhr, status, error) { + errorFn(xhr, status, error) + }, null); +} + + +// 选择需求计划--安全工器具 +function chooseFitTypeTwo() { + let params = {}; + openIframeByParamObj("choose_type_two", '选择需求计划安全工器具类型', "./choose_type_list.html", '92%', '95%', params); +} diff --git a/js/aq_demand_plan/send_out_list.js b/js/aq_demand_plan/send_out_list.js index cee8a0f..04788d6 100644 --- a/js/aq_demand_plan/send_out_list.js +++ b/js/aq_demand_plan/send_out_list.js @@ -370,3 +370,9 @@ function exportExcel() { function sendOutProDetail(obj) { openIframeByParamObj("sendOutProDetail", "工程详情", "./child/send_out_pro_detail.html", "92%", "95%", obj, 1); } + + +// 申请 +function applyPlan(obj) { + openIframeByParamObj("apply_plan", "计划外发货", "./child/send_out_unplanned_form.html", "92%", "95%", obj); +} diff --git a/page/aq_demand_plan/child/send_out_unplanned_form.html b/page/aq_demand_plan/child/send_out_unplanned_form.html new file mode 100644 index 0000000..bd890a3 --- /dev/null +++ b/page/aq_demand_plan/child/send_out_unplanned_form.html @@ -0,0 +1,153 @@ + + + + + + + 采购发货 + + + + + + + +
+
+
+
+ +

采购发货资料填写

+
+
+
+ +
+ +
+
+
+ +
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ +
+ +
+
+ +
+
+
+

发货附件*

+
+
+ +
+
+

必传项:请上传出门条

+

可选项: 领料单、装卸货照片、车牌号

+
+
+
+
+ +

发货明细

+
+
+ 搜索信息 +
+
+
+
+
+ +
+
+
+
+ +
+
+
+ + + +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + +
+ + 序号类型名称规格单位需要量*采购量*利库量*供应商出厂日期检验日期备注
+
+
+
+ + +
+
+ + + + + + + + + diff --git a/page/aq_demand_plan/send_out_list.html b/page/aq_demand_plan/send_out_list.html index d290f9e..7424e49 100644 --- a/page/aq_demand_plan/send_out_list.html +++ b/page/aq_demand_plan/send_out_list.html @@ -14,118 +14,133 @@ -
-
-
- 数据预览 -
-
-
-
-

总需求计划

-

0

(条)
-
-
- +
+
+
+ 数据预览 +
+
+
+
+

总需求计划

+

0

(条)
-
-
-
-
-

待发货

-

0

(条)
- -
-
- -
-
-
-
-
-
-

已发货

-

0

(条)
- -
-
- -
-
-
-
-

采购发货信息

-
-

采购数量

-

0

-
-
-

利库数量

-

0

-
-
-

采购金额

-

¥ 0

+
+
-
-
- 搜索信息 -
-
-
-
-
- -
-
-
-
- - - -
-
-
-
- -
-
-
-
- -
-
-
- - - -
+
+
+
+

待发货

+

0

(条)
+
- +
+ +
+
+
+
+
+
+

已发货

+

0

(条)
+ +
+
+ +
+
+
+
+

采购发货信息

+
+

采购数量

+

+ 0

+
+
+

利库数量

+

+ 0

+
+
+

采购金额

+

¥ + 0

+
-
-
-
+
+
+ 搜索信息 +
+
+
+
+
+ +
+
+
+
+ + + +
+
+
+
+ +
+
-
+
+ +
+
+
+ + + + +
+
+
+
+
+
+
- - - - - +
+ + + + + - \ No newline at end of file +