diff --git a/js/Print.js b/js/Print.js new file mode 100644 index 0000000..a0a9baf --- /dev/null +++ b/js/Print.js @@ -0,0 +1,124 @@ +/* @Print.js + * DH (http://denghao.me) + * 2017-7-14 + */ +(function (window, document) { + var Print = function (dom, options) { + if (!(this instanceof Print)) return new Print(dom, options); + + this.options = this.extend({ + noPrint: '.no-print', + onStart: function () { }, + onEnd: function () { } + }, options); + + if ((typeof dom) === "string") { + this.dom = document.querySelector(dom); + } else { + this.dom = dom; + } + + this.init(); + }; + Print.prototype = { + init: function () { + var content = this.getStyle() + this.getHtml(); + this.writeIframe(content); + }, + extend: function (obj, obj2) { + for (var k in obj2) { + obj[k] = obj2[k]; + } + return obj; + }, + + getStyle: function () { + var str = "", + styles = document.querySelectorAll('style,link'); + for (var i = 0; i < styles.length; i++) { + str += styles[i].outerHTML; + } + str += ""; + + return str; + }, + + getHtml: function () { + var inputs = document.querySelectorAll('input'); + var textareas = document.querySelectorAll('textarea'); + var selects = document.querySelectorAll('select'); + + for (var k in inputs) { + if (inputs[k].type == "checkbox" || inputs[k].type == "radio") { + if (inputs[k].checked == true) { + inputs[k].setAttribute('checked', "checked") + } else { + inputs[k].removeAttribute('checked') + } + } else if (inputs[k].type == "text") { + inputs[k].setAttribute('value', inputs[k].value) + } + } + + for (var k2 in textareas) { + if (textareas[k2].type == 'textarea') { + textareas[k2].innerHTML = textareas[k2].value + } + } + + for (var k3 in selects) { + if (selects[k3].type == 'select-one') { + var child = selects[k3].children; + for (var i in child) { + if (child[i].tagName == 'OPTION') { + if (child[i].selected == true) { + child[i].setAttribute('selected', "selected") + } else { + child[i].removeAttribute('selected') + } + } + } + } + } + + return this.dom.outerHTML; + }, + + writeIframe: function (content) { + var w, doc, iframe = document.createElement('iframe'), + f = document.body.appendChild(iframe); + iframe.id = "myIframe"; + iframe.style = "position:absolute;width:0;height:0;top:-10px;left:-10px;"; + + w = f.contentWindow || f.contentDocument; + doc = f.contentDocument || f.contentWindow.document; + doc.open(); + doc.write(content); + doc.close(); + this.toPrint(w, function () { + document.body.removeChild(iframe) + }); + }, + + toPrint: function (w, cb) { + var _this = this; + w.onload = function () { + try { + setTimeout(function () { + w.focus(); + typeof _this.options.onStart === 'function' && _this.options.onStart(); + if (!w.document.execCommand('print', false, null)) { + w.print(); + } + typeof _this.options.onEnd === 'function' && _this.options.onEnd(); + w.close(); + cb && cb() + }); + } catch (err) { + console.log('err', err); + } + } + } + }; + window.Print = Print; +}(window, document)); \ No newline at end of file diff --git a/js/demandPlan/child/add_jj_data.js b/js/demandPlan/child/add_jj_data.js index 4e1bae5..8888b6b 100644 --- a/js/demandPlan/child/add_jj_data.js +++ b/js/demandPlan/child/add_jj_data.js @@ -4,6 +4,7 @@ function setParams(params) { form = layui.form; layer = layui.layer; }); + getProDevSelected(); if(params!=='-1'){ // 表格数据回显 let dataArr = JSON.parse(params); @@ -23,6 +24,23 @@ function setParams(params) { } } +// 获取需求计划外机具 +function getProDevSelected(){ + let encryptedData = { + 'pId':0 + }; + let url = dataUrl + 'backstage/planOut/getProDevSelected?encryptedData=' + encodeURIComponent(JSON.stringify(encryptedData)); + ajaxRequest(url, "GET", null, true, function () { + }, function (result) { + console.log(result); + if (result.code === 200) { + } else if (result.code === 500) { + } + }, function (xhr, status, error) { + errorFn(xhr, status, error) + }, null); +} + // 保存并继续添加 function addTableData() { let size = $(".pa").length; diff --git a/js/demandPlan/child/send_goods_form.js b/js/demandPlan/child/send_goods_form.js index 6d156d5..bd9b8c7 100644 --- a/js/demandPlan/child/send_goods_form.js +++ b/js/demandPlan/child/send_goods_form.js @@ -1,367 +1,317 @@ -let idParam,objParam,fileList = new Array(), imgListUp = new Array(); -let form,laydate,layer,upload,table,util; +let idParam, objParam, fileList = new Array(), imgListUp = new Array(); +let form, laydate, layer, upload, table, util; +let pageNum = 1, tableIns; // 定义分页 let jjDataArr = []; // 新增需求计划外机具的数据 let jjDetailArr = []; // 机具明细数据 -function setParams(id) { - idParam = id; - 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; +function setParams(obj) { + objParam = JSON.parse(obj); + idParam = objParam.proId; + $('#proName').html(objParam.proName); + $('#planNum').html(objParam.planNum); + 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; laydate.render({ - elem: '#time' - }); + elem: '#createDay' + }); form.verify(); - form.on('submit(formData)', function(data) { - submitApply(data); - }); - form.render(); - 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) { - uploadObj.config.elem.next()[0].value = ''; - obj.preview(function (index, file, result) { - console.log(file); - $('#uploader-list').append( - '
' + - '

x

' + - handleFileType(index, file, result) + - '
' - ); - let map = new Map();//将选择的图片索引和图片写成对象存入集合 - map.index = index; - map.file = file; - fileList.push(map); - }); - } + form.on('submit(formData)', function (data) { + submitApply(data); + }); + form.render(); + 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) { + uploadObj.config.elem.next()[0].value = ''; + obj.preview(function (index, file, result) { + console.log(file); + $('#uploader-list').append( + '
' + + '

x

' + + handleFileType(index, file, result) + + '
' + ); + let map = new Map();//将选择的图片索引和图片写成对象存入集合 + map.index = index; + map.file = file; + fileList.push(map); }); - initTable(); - }); + } + }); + initTable(); + }); } // 设置文件类型 function handleFileType(index, file, result) { - let html = '',img = ''; - 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 +'

' + + let html = '', img = ''; + 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; + 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) - }); + 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 queryTable(type) { + if (type === 1) { + reloadTable(1); + } else if (type === 2) { + $('#name').val(''); + $('#module').val(''); + layui.form.render(); + reloadTable(1); + } +} + +// 重载表格 +function reloadTable(pageNum) { + table.reload("currentTableId", { + page: { + curr: pageNum ? pageNum : 1, + }, + where: { + encryptedData: JSON.stringify({ + 'name': $('#name').val(), + 'module': $('#module').val(), + 'proId': idParam + }), + }, + }, + ); +} + // 表格数据 function initTable() { - let dataList = [ - { - id: "1", - username: "张三", - num: 1, - num2: 1, - status: "部分发货", - progress: 30, - lastSendTime:'2024-11-07 12:00:00', - 'xyl':'1', - 'fhl':'1' - }, - { - id: "2", - username: "李四", - num: 1, - num2: 2, - status: "全部发货", - progress: 150, - lastSendTime:'2024-11-07 12:00:00', - 'xyl':'1', - 'fhl':'1' - }, - { - id: "3", - username: "李四", - num: 1, - num2: 2, - status: "全部发货", - progress: 150, - lastSendTime:'2024-11-07 12:00:00', - 'xyl':'1', - 'fhl':'1' + tableIns = table.render({ + elem: "#currentTableId", + id: 'currentTableId', + height: "full", + headers: { + authorization: sessionStorage.getItem("gz-token"), + }, + url: dataUrl + "backstage/planOut/getPorInfoDetail", + where: { + encryptedData: JSON.stringify({ + 'name': $('#name').val(), + 'module': $('#module').val(), + 'proId': idParam + }), + }, + request: { + pageName: 'pageNum', + limitName: 'pageSize' + }, + parseData: function (res) { // res 即为原始返回的数据 + if (jjDetailArr && res.list) { + $.each(res.list, function (index, item) { + $.each(jjDetailArr, function (index2, item2) { + if (item.id === item2.id) { + item.num = item2.num; + item.tzNum = item2.tzNum; + item.outId = item2.outId; + } + }); + }); + } + return { + "code": 0, // 解析接口状态 + "msg": '获取成功', // 解析提示文本 + "count": res.total, // 解析数据长度 + "data": res.list // 解析数据列表 + }; + }, + cols: [ + [ + { + width: 80, + title: "序号", + align: "center", + templet: function (d) { + return d.LAY_NUM; + }, }, { - id: "4", - username: "李四", - num: 1, - num2: 2, - status: "全部发货", - progress: 150, - lastSendTime:'2024-11-07 12:00:00', - 'xyl':'1', - 'fhl':'1' + field: "type", + width: 150, + title: "物机类型", + unresize: true, + align: "center", }, { - id: "5", - username: "李四", - num: 1, - num2: 2, - status: "全部发货", - progress: 150, - lastSendTime:'2024-11-07 12:00:00', - 'xyl':'1', - 'fhl':'1' + field: "name", + width: 150, + title: "物机名称", + unresize: true, + align: "center", }, { - id: "6", - username: "李四", - num: 1, - num2: 2, - status: "全部发货", - progress: 150, - lastSendTime:'2024-11-07 12:00:00' + field: "module", + width: 120, + title: "规格", + unresize: true, + align: "center", }, { - id: "7", - username: "李四", - num: 1, - num2: 2, - status: "全部发货", - progress: 150, - lastSendTime:'2024-11-07 12:00:00' + field: "unit", + title: "单位", + width: 120, + unresize: true, + align: "center", }, { - id: "8", - username: "李四", - num: 1, - num2: 2, - status: "全部发货", - progress: 150, - lastSendTime:'2024-11-07 12:00:00' + field: "needNum", + width: 120, + title: "需要量", + unresize: true, + align: "center", + templet: function (d) { + return setNumColor(d.needNum, 1); + }, }, { - id: "9", - username: "李四", - num: 1, - num2: 2, - status: "全部发货", - progress: 150, - lastSendTime:'2024-11-07 12:00:00' + field: "fhNum", + width: 120, + title: "已发货量", + unresize: true, + align: "center", + templet: function (d) { + return setNumColor(d.fhNum, 2); + }, }, { - id: "10", - username: "李四", - num: 1, - num2: 2, - status: "全部发货", - progress: 150, - lastSendTime:'2024-11-07 12:00:00' + field: "diff", + width: 120, + title: "差缺量", + unresize: true, + align: "center", + templet: function (d) { + return setNumColor(d.diff, 3); + }, }, { - id: "11", - username: "李四", - num: 1, - num2: 2, - status: "全部发货", - progress: 150, - lastSendTime:'2024-11-07' + field: "num", + width: 150, + title: " * 本次发货量", + unresize: true, + align: "center", + edit: 'text', + style: 'outline: 1px solid #e6e6e6;outline-offset: -5px;' }, { - id: "12", - username: "李四", - num: 1, - num2: 2, - status: "全部发货", - progress: 150, - lastSendTime:'2024-11-07 12:00:00' + field: "tzNum", + width: 150, + title: "调整量", + unresize: true, + align: "center", + edit: 'text', + style: 'outline: 1px solid #e6e6e6;outline-offset: -5px;' }, - ]; - table.render({ - elem: "#currentTableId", - id:'currentTableId', - data: dataList, - height: "full", - // url: "../api/table.json", - parseData: function(res){ - console.error(res); - - }, - cols: [ - [ - { - width: 80, - title: "序号", - align: "center", - templet: function (d) { - return d.LAY_NUM; - }, - }, - { - field: "username", - width: 150, - title: "物机类型", - unresize: true, - align: "center", - }, - { - field: "num", - width: 150, - title: "物机名称", - unresize: true, - align: "center", - templet: function (d) { - // return setNumColor(d.num); - }, - }, - { - field: "num2", - width: 120, - title: "规格 ", - unresize: true, - align: "center", - templet: function (d) { - // return setNumColor(d.num2); - }, - }, - { - field: "unit", - title: "单位", - width: 120, - unresize: true, - align: "center", - }, - { - field: "xyl", - width: 120, - title: "需要量", - unresize: true, - align: "center", - }, - { - field: "yfhl", - width: 120, - title: "已发货量", - unresize: true, - align: "center", - }, - { - field: "cql", - width: 120, - title: "差缺量", - unresize: true, - align: "center", - }, - { - field: "fhl", - width: 150, - title: " * 本次发货量", - unresize: true, - align: "center", - edit:'text', - style: 'outline: 1px solid #e6e6e6;outline-offset: -5px;' - }, - { - field: "tzl", - width: 150, - title: "调整量", - unresize: true, - align: "center", - edit:'text', - style: 'outline: 1px solid #e6e6e6;outline-offset: -5px;' - }, - { - field: "remark", - width: 250, - title: "备注", - unresize: true, - align: "center", - edit:'textarea', - style: 'outline: 1px solid #e6e6e6;outline-offset: -5px;' - }, - - ], + { + field: "outId", + width: 250, + title: "备注", + unresize: true, + align: "center", + edit: 'textarea', + style: 'outline: 1px solid #e6e6e6;outline-offset: -5px;' + }, + ], - limits: [10, 15, 20, 25, 50, 100], - limit: 10, - page: true, - done: function (res, curr, count) { - $("#tips").suspensionTips({"content": "1.如需单个机具进度达到100%,请填写不发货的数量;2.若填写不发货数量,请填写备注不发货原因及附件说明", position:"top", width:300}); - - }, - }); - table.on('edit(currentTableId)', function(obj){ - console.log(obj); - - var field = obj.field; // 得到修改的字段 - var value = obj.value // 得到修改后的值 - var oldValue = obj.oldValue // 得到修改前的值 -- v2.8.0 新增 - var data = obj.data // 得到所在行所有键值 - var col = obj.getCol(); // 得到当前列的表头配置属性 -- v2.8.0 新增 - if(field === 'fhl' || field === 'tzl'){ // 本次发货量/调整量 - if(value){ - const regex = /^(0|[1-9]\d{0,6})$/; - if(!regex.test(value)){ - obj.reedit(); - return layer.msg('格式不正确,最大输入6位数,且为正整数!',{icon:7}) - } - } - }else if(field === 'remark'){ // 备注 - if(value){ - if(value.length > 255){ - obj.reedit(); - return layer.msg('备注最多输入255位!',{icon:7}) - } + ], + limits: [10, 15, 20, 25, 50, 100], + limit: 10, + page: true, + done: function (res, curr, count) { + pageNum = tableIns.config.page.curr; + $("#tips").suspensionTips({ "content": "1.如需单个机具进度达到100%,请填写不发货的数量;2.若填写不发货数量,请填写备注不发货原因及附件说明", position: "top", width: 300 }); + }, + }); + table.on('edit(currentTableId)', function (obj) { + console.log(obj); + var field = obj.field; // 得到修改的字段 + var value = obj.value // 得到修改后的值 + var oldValue = obj.oldValue // 得到修改前的值 -- v2.8.0 新增 + var data = obj.data // 得到所在行所有键值 + var col = obj.getCol(); // 得到当前列的表头配置属性 -- v2.8.0 新增 + if (field === 'num' || field === 'tzNum') { // 本次发货量/调整量 + if (value) { + const regex = /^(0|[1-9]\d{0,6})$/; + if (!regex.test(value)) { + obj.reedit(); + return layer.msg('格式不正确,最大输入6位数,且为正整数!', { icon: 7 }) } } - // 显示 - 仅用于演示 - layer.msg('[ID: '+ data.id +'] ' + field + ' 字段更改值为:'+ util.escape(value)); - let id = obj.data.id; - let fhl = obj.data.fhl; - let tzl = obj.data.tzl; - let remark = obj.data.remark; - let objParam = { - id:id, - fhl:fhl, - tzl:tzl, - remark:remark + } else if (field === 'outId') { // 备注 + if (value) { + if (value.length > 255) { + obj.reedit(); + return layer.msg('备注最多输入255位!', { icon: 7 }) + } } - updateOrAddObject(id,objParam); - }); - } + } + // 显示 - 仅用于演示 + layer.msg('[ID: ' + data.id + '] ' + field + ' 字段更改值为:' + util.escape(value)); + let id = obj.data.id; + let num = obj.data.num; + let tzNum = obj.data.tzNum; + let outId = obj.data.outId; + let type = obj.data.type; + let name = obj.data.name; + let module = obj.data.module; + let objParam = { + id: id, + num: num, + tzNum: tzNum, + outId: outId, + type: type, + name: name, + module: module, + remarks: outId + } + updateOrAddObject(id, objParam); + }); +} // 根据id 判断对象数组的对象是否存在 如果存在则替换,不存在则添加 function updateOrAddObject(id, newObject) { @@ -375,66 +325,113 @@ function updateOrAddObject(id, newObject) { } } function saveData2() { - $('#formSubmit').trigger('click') + $('#formSubmit').trigger('click') +} + +function setNumColor(value, type) { // 1.需要量 2.已发货量 3.差缺量 + let color = '#66b1ff'; + if (type === 1) { + color = '#66b1ff'; + } else if (type === 2) { + color = '#19be6b'; + } else if (type === 3) { + color = '#ff9900'; + } + return '' + setNullValue(value) + ""; } // 提交 function submitApply(data) { - data.field.jjDataArr = jjDetailArr; - data.field.jjDetailArr = jjDetailArr; - let formData = new FormData(); - //遍历最终文件集合 - for (let i = 0; i < fileList.length; i++) { - formData.append("file[]", fileList[i].file) + // 校验发货附件是否上传 + if (fileList.length === 0) { + return layer.msg('请上传发货附件', { icon: 7 }); + } + // 校验机具发货数量 + if (jjDetailArr.length === 0) { + return layer.msg('未填写发货数量', { icon: 7 }); + } + // 校验调整量发生变化是否填写备注 + for (let i = 0; i < jjDetailArr.length; i++) { + let obj = jjDetailArr[i]; + if(obj.tzNum > 0 && !obj.remarks){ + return layer.msg(obj.type+'-' + obj.name+'-' + obj.module + ',已修改调整量,请填写备注', { icon: 7 }); } - formData.append('params',JSON.stringify(data.field)); - /* let loadingMsg = layer.msg('正在提交保存,请稍等...', { - icon : 16, - shade : 0.01, - time : '0' - }); */ - console.log(JSON.stringify(data.field)); - data.field.applyId = idParam; + } + data.field.proId = idParam; + data.field.list = jjDetailArr; + data.field.addList = jjDataArr; + let formData = new FormData(); + //遍历最终文件集合 + for (let i = 0; i < fileList.length; i++) { + formData.append("file[]", fileList[i].file) + } + formData.append('params', JSON.stringify(data.field)); + console.log(JSON.stringify(data.field)); + + let loadingMsg = layer.msg('正在提交保存,请稍等...', { icon: 16, shade: 0.01, time: '0' }); + console.log(JSON.stringify(data.field)); + let url = dataUrl + 'backstage/planOut/insertProOutPutInfo'; + ajaxRequestByUploadFile(url, formData, function () { + $('.save').addClass("layui-btn-disabled").attr("disabled", true); + $('.cancel').addClass("layui-btn-disabled").attr("disabled", true); + }, function (result) { + console.log(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(1); + } 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 handleNum(value){ - if(!value){ - return null; - } - const regex = /^(0|[1-9]\d{0,6})$/; - if(!regex.test(value)){ - return layer.msg('格式不正确,最大输入6位数,且为正整数!',{icon:7}) - } +function handleNum(value) { + if (!value) { return null; + } + const regex = /^(0|[1-9]\d{0,6})$/; + if (!regex.test(value)) { + return layer.msg('格式不正确,最大输入6位数,且为正整数!', { icon: 7 }) + } + return null; } // 详情 -function openDetail(){ - alert('详情'); +function openDetail() { + alert('详情'); } // 新增需求计划外机具 -function addJjData(){ - let params = '-1'; - if(jjDataArr && jjDataArr.length > 0){ - params = JSON.stringify(jjDataArr); - } - openIframeByParam("addJjData", '新增需求计划外机具', "./add_jj_data.html", '72%', '80%',params); +function addJjData() { + let params = '-1'; + if (jjDataArr && jjDataArr.length > 0) { + params = JSON.stringify(jjDataArr); + } + openIframeByParam("addJjData", '新增需求计划外机具', "./add_jj_data.html", '72%', '80%', params); } -function addJjDatas(data){ - console.log('新增的数据:'+data); +function addJjDatas(data) { + console.log('新增的数据:' + data); jjDataArr = JSON.parse(data); } // 关闭页面 function closePage(type) { - let index = parent.layer.getFrameIndex(window.name); // 先得到当前 iframe层的索引 - parent.layer.close(index); // 再执行关闭 - if (type == 1) { - window.parent.closePage(); - } - + let index = parent.layer.getFrameIndex(window.name); // 先得到当前 iframe层的索引 + parent.layer.close(index); // 再执行关闭 + if (type == 1) { + window.parent.reloadData(); + } + } \ No newline at end of file diff --git a/js/demandPlan/child/view_data_list.js b/js/demandPlan/child/view_data_list.js index 6f3b9d8..30dda09 100644 --- a/js/demandPlan/child/view_data_list.js +++ b/js/demandPlan/child/view_data_list.js @@ -1,141 +1,90 @@ -let form, table, element; +let form, table, element,tableIns; let typeParam; -function setParams(type){ +let pageNum = 1; +function setParams(type) { typeParam = type; - layui.use(["form", "table",'element'], function () { + layui.use(["form", "table", 'element'], function () { form = layui.form; table = layui.table; element = layui.element; // tab 切换事件 - element.on('tab(demo-filter-tab)', function(data){ - let auditStatus = $(this).attr('value'); - // $('#auditStatus').val(auditStatus); + element.on('tab(demo-filter-tab)', function (data) { + let value = $(this).attr('value'); + typeParam = value; + reloadTable(1); }); $('.layui-tab-title li').eq(typeParam - 1).addClass('layui-this'); - // initTable(); + initTable(); }); } +// 查询/重置 +function queryTable(type) { + if (type === 1) { + reloadTable(1); + } else if (type === 2) { + $('#name').val(''); + $('#module').val(''); + layui.form.render(); + reloadTable(1); + } +} + +// 刷新页面数据 +function reloadData() { + reloadData(pageNum); +} + +// 重载表格 +function reloadTable(pageNum) { + table.reload("currentTableId", { + page: { + curr: pageNum ? pageNum : 1, + }, + where: { + encryptedData: JSON.stringify({ + 'name': $('#name').val(), + 'module': $('#module').val(), + 'type': typeParam + }), + }, + }, + ); +} + +// 初始化表格 function initTable() { - let dataList = [ - { - id: "1", - username: "张三", - num: 1, - num2: 1, - status: "部分发货", - progress: 30, - lastSendTime:'2024-11-07 12:00:00' - }, - { - id: "2", - username: "李四", - num: 1, - num2: 2, - status: "全部发货", - progress: 150, - lastSendTime:'2024-11-07 12:00:00' - }, - { - id: "2", - username: "李四", - num: 1, - num2: 2, - status: "全部发货", - progress: 150, - lastSendTime:'2024-11-07 12:00:00' - }, - { - id: "2", - username: "李四", - num: 1, - num2: 2, - status: "全部发货", - progress: 150, - lastSendTime:'2024-11-07 12:00:00' - }, - { - id: "2", - username: "李四", - num: 1, - num2: 2, - status: "全部发货", - progress: 150, - lastSendTime:'2024-11-07 12:00:00' - }, - { - id: "2", - username: "李四", - num: 1, - num2: 2, - status: "全部发货", - progress: 150, - lastSendTime:'2024-11-07 12:00:00' - }, - { - id: "2", - username: "李四", - num: 1, - num2: 2, - status: "全部发货", - progress: 150, - lastSendTime:'2024-11-07 12:00:00' - }, - { - id: "2", - username: "李四", - num: 1, - num2: 2, - status: "全部发货", - progress: 150, - lastSendTime:'2024-11-07 12:00:00' - }, - { - id: "2", - username: "李四", - num: 1, - num2: 2, - status: "全部发货", - progress: 150, - lastSendTime:'2024-11-07 12:00:00' - }, - { - id: "2", - username: "李四", - num: 1, - num2: 2, - status: "全部发货", - progress: 150, - lastSendTime:'2024-11-07 12:00:00' - }, - { - id: "2", - username: "李四", - num: 1, - num2: 2, - status: "全部发货", - progress: 150, - lastSendTime:'2024-11-07 12:00:00' - }, - { - id: "2", - username: "李四", - num: 1, - num2: 2, - status: "全部发货", - progress: 150, - lastSendTime:'2024-11-07 12:00:00' - }, - ]; - table.render({ + tableIns = table.render({ elem: "#currentTableId", - data: dataList, - height: "full-350", - // url: "../api/table.json", + id: 'currentTableId', + headers: { + authorization: sessionStorage.getItem("gz-token"), + }, + height: "full-230", + url: dataUrl + "backstage/planOut/getProPlanPage", + where: { + encryptedData: JSON.stringify({ + 'name': $('#name').val(), + 'module': $('#module').val(), + 'type': typeParam + }), + }, + request: { + pageName: 'pageNum', + limitName: 'pageSize' + }, + parseData: function (res) { // res 即为原始返回的数据 + return { + "code": 0, // 解析接口状态 + "msg": '获取成功', // 解析提示文本 + "count": res.total, // 解析数据长度 + "data": res.list // 解析数据列表 + }; + }, cols: [ [ { - width: 120, + width: 80, title: "序号", align: "center", templet: function (d) { @@ -143,124 +92,150 @@ function initTable() { }, }, { - field: "username", - width: 300, - title: "工程名称", + field: "proName", + width: 150, + title: "物机类型 ", unresize: true, align: "center", }, { - field: "num", - width: 180, - title: "需求计划数量", + field: "planNum", + width: 150, + title: "物机名称", unresize: true, align: "center", - templet: function (d) { - return setNumColor(d.num); - }, + /* templet: function (d) { + return setNumColor(d.planNum); + }, */ }, { - field: "num2", - width: 180, - title: "出库单数量 ", + field: "recordNum", + width: 150, + title: "规格 ", unresize: true, align: "center", - templet: function (d) { - return setNumColor(d.num2); - }, + /* templet: function (d) { + return setNumColor(d.recordNum); + }, */ }, { field: "status", - title: "发货状态", - width: 200, + title: "单位", + width: 150, unresize: true, align: "center", - templet: function (d) { + /* templet: function (d) { return setStatusColor(d.status); - }, + }, */ }, { - field: "lastSendTime", - width: 200, - title: "最后发货时间", + field: "status", + title: "需要量", + width: 150, + unresize: true, + align: "center", + /* templet: function (d) { + return setNumColor(d.status); + }, */ + }, + { + field: "status", + title: "已发货量", + width: 150, + unresize: true, + align: "center", + /* templet: function (d) { + return setStatusColor(d.status); + }, */ + }, + { + field: "status", + title: "待发货量", + width: 120, + unresize: true, + align: "center", + /* templet: function (d) { + return setStatusColor(d.status); + }, */ + }, + { + field: "lastDay", + width: 150, + title: "工程数", unresize: true, align: "center", }, { field: "progress", - width: 300, - title: "进度", + width: 150, + title: "需求计划数", unresize: true, align: "center", - templet: schedule, }, { - title: "操作", - minwidth: 180, + title: "来源工程", + minwidth: 200, align: "center", unresize: true, templet: function (d) { let html = ""; - html += "详情"; - html += - "
|
发货"; + html += "查看来源"; return html; }, }, ], ], limits: [10, 15, 20, 25, 50, 100], - limit: 15, + limit: 10, page: true, done: function (res, curr, count) { - element.render(); + pageNum = tableIns.config.page.curr; + element.render(); }, }); } -// 数量颜色 -function setNumColor(value) { - return '' + value + ""; +// 设置字体加粗 +function setFontBold(value) { + return '' + value + ""; } // 发货状态颜色 -function setStatusColor(value) { +function setNumColor(value,type) { let color = "#409Eff"; - if (value === "未发货") { - color = "#f56c6c"; - } else if (value === "部分发货") { - color = "#ff9900"; - } - if (value === "全部发货") { + if (type === 1) { + color = "#409Eff"; + } else if (type === 2) { color = "#19be6b"; + }else if (type === 3) { + color = "#f56c6c"; } return '' + value + ""; } -// 设置进度值 -function schedule(d) { - d.filter == undefined ? d.filter = d.LAY_NUM : d.filter; - d.progress == undefined ? d.progress = 100 : d.progress; - var color = 'layui-bg-orange'; - if (d.progress < 100) { - color = 'layui-bg-orange' - } else if(d.progress === 100){ - color = 'layui-bg-primary' - }else if(d.progress > 100){ - color = 'layui-bg-blue' +// 导出 +function exportExcel() { + let encryptedData = JSON.stringify({ + 'proName': $('#proName').val(), + 'status': $('#status').val() + }); + let url = dataUrl + "backstage/planOut/exportExcel?encryptedData=" + encryptedData; + exportExcelUtil(url, '机具公司发货数据'); +} + +// 打印 +function print() { + Print('#body', { + onStart: function () { + console.log('onStart', new Date()) + }, + onEnd: function () { + console.log('onEnd', new Date()) } - //设置页面进度条 - return '
' + - '
' + - '
' + }) } -// 发货 -function sendGoods(id) { - openIframeByParam("sendGoods", '发货', "./child/send_goods_form.html", '92%', '95%',id); -} - -// type 1.总需求量 2.待发货量 3.已发货量 -function openViewData(type) { - openIframeByParam("viewData", '发货', "./child/view_data_list.html", '92%', '95%',type); +// 查看来源 +function viewSource(id) { + openIframeByParam("viewSource","未发货机具设备超出库存数量-数据来源","./view_resource_list.html","92%","95%",id); } \ No newline at end of file diff --git a/js/demandPlan/child/view_resource_list.js b/js/demandPlan/child/view_resource_list.js new file mode 100644 index 0000000..e69de29 diff --git a/js/demandPlan/delivery_list.js b/js/demandPlan/delivery_list.js index b8d6ae4..f2a1371 100644 --- a/js/demandPlan/delivery_list.js +++ b/js/demandPlan/delivery_list.js @@ -28,17 +28,22 @@ layui.use(["form", "table"], function () { // 查询/重置 function queryTable(type){ if(type === 1){ - reloadData(1); + reloadTable(1); }else if(type === 2){ $('#proName').val(''); $('#status').val('0'); layui.form.render(); - reloadData(1); + reloadTable(1); } } +// 刷新页面数据 +function reloadData() { + reloadData(pageNum); +} + // 重载表格 -function reloadData(pageNum) { +function reloadTable(pageNum) { table.reload("currentTableId",{ page: { curr: pageNum ? pageNum : 1, @@ -70,8 +75,8 @@ function initTable() { }), }, request: { - pageName: 'pageNum', // page - limitName: 'pageSize' // limit + pageName: 'pageNum', + limitName: 'pageSize' }, parseData: function(res){ // res 即为原始返回的数据 return { @@ -151,7 +156,7 @@ function initTable() { templet: function (d) { let html = ""; html += "详情"; - html += "
|
发货"; + html += "
|
发货"; return html; }, }, @@ -179,8 +184,7 @@ function setStatusColor(value) { color = "#f56c6c"; } else if (value === "部分发货") { color = "#ff9900"; - } - if (value === "全部发货") { + }else if (value === "全部发货") { color = "#19be6b"; } return '' + value + ""; @@ -217,8 +221,8 @@ function exportExcel() { } // 发货 -function sendGoods(id) { - openIframeByParam("sendGoods","发货","./child/send_goods_form.html","92%","95%",id); +function sendGoods(obj) { + openIframeByParamObj("sendGoods","发货","./child/send_goods_form.html","92%","95%",obj); } // type 1.总需求量 2.待发货量 3.已发货量 diff --git a/js/openIframe.js b/js/openIframe.js index 9bfa7b7..4746388 100644 --- a/js/openIframe.js +++ b/js/openIframe.js @@ -40,7 +40,7 @@ function openIframeByParamObj(id, title, content, width, height,paramsObj) { let layerIndex = layer.open({ id: id, type: 2, - title: ['
' + title + '
', 'font-size:16px;background-color:#f0f0f0;display: flex;align-items: center;'], + title: ['
' + title + '
', 'font-size:16px;background-color:#f0f0f0;display: flex;align-items: center;'], content: content, shade: 0.3, anim: 2, diff --git a/js/public.js b/js/public.js index be87a11..eb409bc 100644 --- a/js/public.js +++ b/js/public.js @@ -32,6 +32,7 @@ function ajaxRequestByUploadFile(url, data, beforeFn, successFn, errorFn) { }, type: 'POST', dataType: 'json', + contentType: 'multipart/form-data', processData: false, contentType: false, data: data, @@ -109,4 +110,11 @@ const getNowDate = () => { seconds = "0" + seconds; } return year + "-" + month + "-" + day + "-" + hour + sign2 + minutes + sign2 + seconds; +} +// 空值赋值 +function setNullValue(value){ + if(!value){ + return ''; + } + return value; } \ No newline at end of file diff --git a/page/demandPlan/child/add_jj_data.html b/page/demandPlan/child/add_jj_data.html index bccbfbf..c40556e 100644 --- a/page/demandPlan/child/add_jj_data.html +++ b/page/demandPlan/child/add_jj_data.html @@ -78,6 +78,7 @@
+ diff --git a/page/demandPlan/child/send_goods_form.html b/page/demandPlan/child/send_goods_form.html index 7766aa7..1cb992e 100644 --- a/page/demandPlan/child/send_goods_form.html +++ b/page/demandPlan/child/send_goods_form.html @@ -16,9 +16,9 @@
-

220kV奎福变电站工程

+

计划数量:30

+ style="font-weight: bold;color: #409eff;" id="planNum">0

@@ -29,8 +29,8 @@
- +
@@ -39,7 +39,7 @@
-
@@ -47,8 +47,8 @@
- +
- +
+ - - - - \ No newline at end of file diff --git a/page/demandPlan/child/view_data_list.html b/page/demandPlan/child/view_data_list.html index 817412c..6b6c1ba 100644 --- a/page/demandPlan/child/view_data_list.html +++ b/page/demandPlan/child/view_data_list.html @@ -30,28 +30,25 @@
- +
-
- - - +
+
- - + - + +
@@ -63,9 +60,11 @@
+ + \ No newline at end of file diff --git a/page/demandPlan/child/view_resource_list.html b/page/demandPlan/child/view_resource_list.html new file mode 100644 index 0000000..79bebf6 --- /dev/null +++ b/page/demandPlan/child/view_resource_list.html @@ -0,0 +1,11 @@ + + + + + + 查看来源 + + + 查看来源 + + \ No newline at end of file diff --git a/page/demandPlan/delivery_list.html b/page/demandPlan/delivery_list.html index 4a037f6..368601a 100644 --- a/page/demandPlan/delivery_list.html +++ b/page/demandPlan/delivery_list.html @@ -82,7 +82,7 @@
-