diff --git a/css/accessory/accessory_store_form.css b/css/accessory/accessory_store_form.css new file mode 100644 index 0000000..3854f54 --- /dev/null +++ b/css/accessory/accessory_store_form.css @@ -0,0 +1,143 @@ +#search-info { + border-width: 1px; + margin-bottom: 10px; +} + +.title { + width: 100%; + height: 30px; + justify-content: start; +} + +.title p { + font-size: 14px; + font-weight: bold; + +} + +span.required { + color: red; + margin-left: 4px; + font-weight: bold; + line-height: 1.8em; + top: 6px; + right: 5px; +} + +.upload-file { + flex-direction: column; + justify-content: space-around; + width: 200px; + height: 120px; +} + +blockquote { + display: flex; + align-items: center; +} + +#test2 { + width: 120px; + height: 100px; + background-color: rgb(240, 240, 240); + display: flex; + align-items: center; + justify-content: center; + cursor: pointer; +} + +.uploader-list { + margin-left: -15px; + max-width: calc(100% - 200px); +} + +.uploader-list .handle { + position: relative; + background-color: red; + color: white; + filter: alpha(Opacity=80); + -moz-opacity: 0.5; + opacity: 1; + /*width: 212px;*/ + text-align: right; + height: 18px; + width: 18px; + border-radius: 18px; + display: flex; + align-items: center; + justify-content: center; + left: 87%; + margin-bottom: -12px; + /*display: none;*/ +} + +.uploader-list .handle p { + font-size: 18px; + color: #fff; + cursor: pointer; +} + +.uploader-list .handle i { + margin-right: 5px; +} + +.uploader-list .handle i:hover { + cursor: pointer; +} + +.uploader-list .file-iteme { + margin: 0 0 0 10px; + padding: 1px; + float: left; +} + +.layui-upload-list { + margin: 0; +} + +.classTable { + width: 100%; + table-layout: fixed; + text-align: center; + border-collapse: collapse; + border-spacing: 1px; + box-sizing: border-box; +} + +.classTable tr td, +.classTable tr th { + height: 50px; + box-sizing: border-box; + border: 1px solid #ddd; + padding: 10px 20px; + text-align: left; +} + +.classTable tr:nth-child(odd) { + background-color: #f2f2f2; +} + +#baseTable tr td, +#baseTable tr th { + text-align: center; +} + +/**自定义滚动条样式 */ +::-webkit-scrollbar { + width: 6px; + height: 6px +} + +::-webkit-scrollbar-track { + background-color: transparent; + -webkit-border-radius: 2em; + -moz-border-radius: 2em; + border-radius: 2em; +} + +::-webkit-scrollbar-thumb { + background-color: #9c9da0; + -webkit-border-radius: 2em; + -moz-border-radius: 2em; + border-radius: 2em +} \ No newline at end of file diff --git a/js/accessory/accessory_store_list.js b/js/accessory/accessory_store_list.js index 2b49576..6001e78 100644 --- a/js/accessory/accessory_store_list.js +++ b/js/accessory/accessory_store_list.js @@ -140,7 +140,7 @@ function initTable() { templet: function (d) { let html = ""; html += "详情"; - html += "
|
发货"; + html += "
|
修改"; return html; }, }, @@ -175,30 +175,11 @@ function exportExcel() { 'status': $('#status').val() } let url = dataUrl + "backstage/export/exportFhList"; - exportExcelUtil(url, '机具公司发货数据', JSON.stringify(params)); + exportExcelUtil(url, '配件入库数据', JSON.stringify(params)); } -// 发货详情 -function deliveryDetail(obj) { - openIframeByParamObj("deliveryDetail", "详情", "../demandPlan/child/delivery_detail_list.html", "92%", "95%", obj); -} - -// 发货 -function sendGoods(obj) { - openIframeByParamObj("sendGoods", "发货", "../demandPlan/child/send_goods_form.html", "92%", "95%", obj); -} - -// type 1.总需求量 2.待发货量 3.已发货量 -function openViewData(type) { - openIframeByParam("viewData", "数据概览", "../demandPlan/child/view_data_list.html", "92%", "95%", type); -} - -// type 1.超库存量 2.计划外量 -function earlyInfo(type) { - openIframeByParam("viewData", "预警信息", "../demandPlan/child/early_info_list.html", "92%", "95%", type); -} - -// 需求计划 -function view_plan(obj) { - openIframeByParamObj("view_plan", "需求计划", "../demandPlan/child/demand_plan_detail_list.html", "92%", "95%", obj); +// 配件入库 +function accessoryStore(type, obj) { + obj.type = type; + openIframeByParamObj("accessory_store", "配件到货入库", "../accessory/child/accessory_store_form.html", "92%", "95%", obj); } \ No newline at end of file diff --git a/js/accessory/child/accessory_store_form.js b/js/accessory/child/accessory_store_form.js new file mode 100644 index 0000000..8947a77 --- /dev/null +++ b/js/accessory/child/accessory_store_form.js @@ -0,0 +1,225 @@ +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(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: '#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); + }); + } + }); + 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 + '

' + + '
'; + 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) + }); +}); + + +// 根据id 判断对象数组的对象是否存在 如果存在则替换,不存在则添加 +function updateOrAddObject(id, newObject) { + const index = jjDetailArr.findIndex(obj => obj.id === id); + if (index !== -1) { + // 如果对象存在,则替换它 + jjDetailArr[index] = newObject; + } else { + // 如果对象不存在,则添加到数组 + jjDetailArr.push(newObject); + } +} +function saveData2() { + $('#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 '' + value + ""; +} + + +// 提交 +function submitApply(data) { + let list = []; + // 校验发货附件是否上传 + if (fileList.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 }); + } + } + // 添加机具发货数据 + for (let i = 0; i < jjDetailArr.length; i++) { + let obj = jjDetailArr[i]; + if (obj.num > 0 || obj.tzNum > 0) { + list.push(obj); + } + } + // 校验机具发货数量 + if (list.length === 0) { + return layer.msg('未填写发货数量', { icon: 7 }); + } + data.field.proId = idParam; + data.field.list = list; + 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 }) + } + return null; +} + +// 详情 +function openDetail() { + openIframeByParamObj("view_plan", "需求计划", "./demand_plan_detail_list.html", "92%", "95%", objParam); +} + +// 新增需求计划外机具 +function addJjData() { + let params = { + 'proId': idParam + }; + if (jjDataArr && jjDataArr.length > 0) { + params.jjDataArrStr = JSON.stringify(jjDataArr); + } + openIframeByParamObj("addJjData", '新增需求计划外机具', "./add_jj_data.html", '72%', '80%', params); +} + +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.reloadData(); + } + +} \ No newline at end of file diff --git a/page/accessory/accessory_store_list.html b/page/accessory/accessory_store_list.html index 48ba4e4..ad8afe5 100644 --- a/page/accessory/accessory_store_list.html +++ b/page/accessory/accessory_store_list.html @@ -43,7 +43,7 @@ class="layui-icon"> 搜 索 - diff --git a/page/accessory/child/accessory_store_form.html b/page/accessory/child/accessory_store_form.html new file mode 100644 index 0000000..eb7433e --- /dev/null +++ b/page/accessory/child/accessory_store_form.html @@ -0,0 +1,129 @@ + + + + + + + 发货 + + + + + + + + +
+
+
+
+
+ +
+ +
+
+
+ +
+
+ +
+ +
+
+
+
+ +
+ +
+
+ +
+
+
+

附件证明*

+
+
+ +
+

(最多上传5个附件)

+
+
+
+ +

入库配件明细

+
+ +
+ + + + + + + + + + + + + + + + + +
序号序号配件类型配件名称规格型号单位* 本次入库量单价(元)* 配件厂家备注
+
+
+
+ + +
+
+ + + + + + + + + \ No newline at end of file