From 6ca121f3a527751bfa967a6af85d301f79de090f Mon Sep 17 00:00:00 2001 From: cwchen <1048842385@qq.com> Date: Wed, 13 Nov 2024 15:40:51 +0800 Subject: [PATCH] =?UTF-8?q?=E9=85=8D=E4=BB=B6=E9=80=80=E6=96=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/accessory/accessory_return_list.js | 44 +- js/accessory/child/accessory_return_form.js | 443 ++++++++++++++++++ .../child/choose_return_fit_type_list.js | 379 +++++++++++++++ page/accessory/accessory_return_list.html | 4 +- .../child/accessory_return_form.html | 140 ++++++ .../child/choose_return_fit_type_list.html | 97 ++++ 6 files changed, 1078 insertions(+), 29 deletions(-) create mode 100644 js/accessory/child/accessory_return_form.js create mode 100644 js/accessory/child/choose_return_fit_type_list.js create mode 100644 page/accessory/child/accessory_return_form.html create mode 100644 page/accessory/child/choose_return_fit_type_list.html diff --git a/js/accessory/accessory_return_list.js b/js/accessory/accessory_return_list.js index 1db452b..2be5245 100644 --- a/js/accessory/accessory_return_list.js +++ b/js/accessory/accessory_return_list.js @@ -80,7 +80,7 @@ function initTable() { cols: [ [ { - width: '5%', + width: '9.9%', title: "序号", align: "center", templet: function (d) { @@ -90,54 +90,51 @@ function initTable() { { field: "code", width: '15%', - title: "入库编号", + title: "退料单编号", unresize: true, align: "center", }, { field: "inputUser", width: '10%', - title: "入库人", + title: "退用数量", unresize: true, align: "center", }, { field: "inputNum", width: '10%', - title: "入库数量", + title: "接收人", unresize: true, align: "center", }, { field: "allPrice", width: '10%', - title: "成本价格(元)", + title: "退料人", unresize: true, align: "center", }, { field: "inputDay", width: '10%', - title: "入库时间", + title: "联系电话", unresize: true, align: "center", }, { field: "remark", - width: '19.9%', - title: "备注", + width: '10%', + title: "退料时间", unresize: true, align: "center", }, { field: "isFlag", - width: '10%', - title: "单价是否录入", + width: '15%', + title: "备注", unresize: true, align: "center", - templet: function (d) { - return setStatusColor(d.isFlag); - }, }, { title: "操作", @@ -146,8 +143,7 @@ function initTable() { unresize: true, templet: function (d) { let html = ""; - html += "详情"; - html += "
|
修改"; + html += "详情"; return html; }, }, @@ -187,18 +183,12 @@ function exportExcel() { exportExcelUtil(url, '配件入库数据', JSON.stringify(params)); } -// 配件入库 -function accessoryStore(type, obj) { - obj.type = type; - openIframeByParamObj("accessory_store", "配件到货入库", "../accessory/child/accessory_store_form.html", "92%", "95%", obj); +// 配件退料入库 +function accessoryReturn(obj){ + openIframeByParamObj("accessory_return", "配件退料入库", "../accessory/child/accessory_return_form.html", "92%", "95%", obj); } -// 配件入库详情 -function accessoryStoreDetail(obj) { - openIframeByParamObj("accessory_store_detail", "配件到货入库", "../accessory/child/accessory_store_detail.html", "92%", "95%", obj); +// 配件退回详情 +function accessoryReturnDetail(obj) { + // openIframeByParamObj("accessory_return_detail", "详情", "../accessory/child/accessory_store_form.html", "92%", "95%", obj); } - -// 配件入库编辑 -function accessoryStoreEdit(obj) { - openIframeByParamObj("accessory_store_edit", "配件到货入库编辑", "../accessory/child/accessory_store_edit_form.html", "92%", "95%", obj); -} \ No newline at end of file diff --git a/js/accessory/child/accessory_return_form.js b/js/accessory/child/accessory_return_form.js new file mode 100644 index 0000000..9c7b616 --- /dev/null +++ b/js/accessory/child/accessory_return_form.js @@ -0,0 +1,443 @@ +let idParam, objParam, fileList = new Array(), imgListUp = new Array(); +let form, laydate, layer, upload, table, util; +let pageNum = 1, tableIns; // 定义分页 +let jjDataArr = []; // 入库配件数据 +let cjList = []; // 厂家下拉选 +let delIdArr = []; +function setParams(obj) { + objParam = JSON.parse(obj); + 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: '#inputDay' + }); + 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) { + let length = $('.file-iteme').length; + if (length >= 5) { + return layer.msg('最多上传5个附件证明', { icon: 7 }); + } + 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); + }); + } + }); + }); + getVendList(); +} +// 设置文件类型 +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) + }); +}); + +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 = getBaseTableData(); + // 校验附件证明是否上传 + if (fileList.length === 0) { + return layer.msg('请上传附件证明', { icon: 7 }); + } + // 校验配件入库数量 + if (list.length === 0) { + return layer.msg('未填写配件入库数量', { icon: 7 }); + } + for (let i = 0; i < list.length; i++) { + + if (!list[i].inputNum || list[i].inputNum === '0') { + return layer.msg('入库配件明细,第' + (i + 1) + '行,未填写配件入库数量', { icon: 7 }); + } + } + data.field.details = list; + 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/partInput/addInputData'; + 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 getBaseTableData() { + let tableData = []; + $('#baseTable tbody tr').each(function (index, item) { + let price = $(this).find('td').eq(7).find('input[name="price"]').val(); + let num = $(this).find('td').eq(6).find('input[name="num"]').val(); + tableData.push({ + partId: $(this).attr('id'), + partType: $(this).find('td').eq(2).html(), + partName: $(this).find('td').eq(3).html(), + partModel: $(this).find('td').eq(4).html(), + partUnit: $(this).find('td').eq(5).html(), + inputNum: num ? num : 0, + partPrice: price ? price : 0, + vendId: $(this).find('td').eq(8).find('select[name="manufacturer"]').val(), + vendName: $(this).find('td').eq(8).find('select[name="manufacturer"]').find('option:checked').text(), + remark: $(this).find('td').eq(9).find('input[name="remarks"]').val(), + }) + }) + return tableData; +} + + +// 选择退回配件类型 +function chooseFitType() { + let userId = $('#inputUser').val() + if (!userId) { + return layer.msg('请选择退料人', { icon: 7 }); + } + let params = { userId: userId }; + openIframeByParamObj("choose_return_fit_type", '选择退回配件类型(只可选择该人员已领用过的配件)', "./choose_return_fit_type_list.html", '92%', '95%', params); +} + +// 查询 +function search() { + let keyWord = $('#type').val(); + let keyWord2 = $('#name').val(); + let keyWord3 = $('#model').val(); + if (!keyWord && !keyWord2 && !keyWord3) { + setTableData(jjDataArr); + } else if (keyWord && !keyWord2 && !keyWord3) { + let dataList = jjDataArr.filter(item => { + return item.type.indexOf(keyWord) > -1; + }) + setTableData(dataList); + } else if (!keyWord && keyWord2 && !keyWord3) { + let dataList = jjDataArr.filter(item => { + return item.name.indexOf(keyWord2) > -1; + }) + setTableData(dataList); + } else if (!keyWord && !keyWord2 && keyWord3) { + let dataList = jjDataArr.filter(item => { + return item.model.indexOf(keyWord3) > -1; + }) + setTableData(dataList); + } else if (keyWord && keyWord2 && !keyWord3) { + let dataList = jjDataArr.filter(item => { + return item.type.indexOf(keyWord) > -1 && item.name.indexOf(keyWord2) > -1; + }) + setTableData(dataList); + } else if (keyWord && !keyWord2 && keyWord3) { + let dataList = jjDataArr.filter(item => { + return item.type.indexOf(keyWord) > -1 && item.model.indexOf(keyWord3) > -1; + }) + setTableData(dataList); + } else if (!keyWord && keyWord2 && keyWord3) { + let dataList = jjDataArr.filter(item => { + return item.name.indexOf(keyWord2) > -1 && item.model.indexOf(keyWord3) > -1; + }) + setTableData(dataList); + } else if (keyWord && keyWord2 && keyWord3) { + let dataList = jjDataArr.filter(item => { + return item.type.indexOf(keyWord) > -1 && item.name.indexOf(keyWord2) > -1 && item.model.indexOf(keyWord3) > -1; + }) + setTableData(dataList); + } +} + +// 重置 +function resetSearch() { + $('#type').val(''); + $('#name').val(''); + $('#model').val(''); + setTableData(jjDataArr); +} + +// 子页面回调数据 +function addFitDatas(data) { + console.log('新增的数据:' + data); + if (jjDataArr.length > 0) { // 继续添加数据 + let newJjDataArr = JSON.parse(data); + $.each(newJjDataArr, function (index, item) { + updateOrAddObject(item.id, item); + }); + setTableData(jjDataArr); + } else { // 第一次添加数据 + jjDataArr = JSON.parse(data); + if (jjDataArr && jjDataArr.length > 0) { + $('#no_data_title').css({ 'display': 'none' }); + $('#search-info').removeAttr('style'); + $('#table-box').removeAttr('style'); + setTableData(jjDataArr); + } + } + + function updateOrAddObject(id, newObject) { + const index = jjDataArr.findIndex(obj => obj.id === id); + if (index !== -1) { + // 如果对象存在,则替换它 + jjDataArr[index] = newObject; + } else { + // 如果对象不存在,则添加到数组 + jjDataArr.push(newObject); + } + } +} + +// 入库配件明细表格赋值 +function setTableData(results) { + $('#allCheck').prop('checked', false) + var html = ""; + if (results && results.length > 0) { + for (var i = 0; i < results.length; i++) { + var l = results[i]; + html += ""; + html += ''; + html += "" + + (i + 1) + ""; + html += "" + l.type + ""; + html += "" + l.name + ""; + html += "" + l.model + ""; + html += "" + l.unit + ""; + html += "" + setFormInput(l.num, 1) + ""; + html += "" + setFormInput(l.price, 2) + ""; + html += "" + setFormInput(l.manufacturer, 3) + ""; + html += "" + setFormInput(l.remarks, 4) + ""; + html += ""; + } + } else { + html += "没有相关数据"; + } + $("#baseTable tbody").empty().append(html); + layui.form.render(); +} + +function setFormInput(value, type) { + let html = '
'; + if (type === 1) { // 入库量 + html += ''; + } else if (type === 2) { // 单价 + html += ''; + } else if (type === 3) { // 厂家 + html += ''; + } else if (type === 4) { // 备注 + html += ''; + } + html += '
'; + return html; + +} + +function setSelectData(value) { + let html = ''; + $.each(cjList, function (index, item) { + if (item.id === value) { + html += '' + } else { + html += '' + } + + }) + return html; +} + +// 厂家下拉选 +function getVendList() { + cjList.splice(0, cjList.length); + let encryptedData = {}; + let url = dataUrl + 'backstage/paType/getVendList?encryptedData=' + encodeURIComponent(JSON.stringify(encryptedData)); + ajaxRequest(url, "GET", null, false, function () { + }, function (result) { + console.log(result); + if (result.code === 200) { + cjList = result.data; + } + }, function (xhr, status, error) { + errorFn(xhr, status, error) + }, null); +} + +// 复选框全选 +function selectAll(selectStatus) {//传入参数(全选框的选中状态) + if (selectStatus) { + $("input[name='check']").each(function (i, n) { + n.checked = true; + }); + $.each(jjDataArr, function (index, item) { + delIdArr.push(item.id); + }) + } else { + $("input[name='check']").each(function (i, n) { + n.checked = false; + }); + delIdArr.splice(0, delIdArr.length); + } +} + +// 单个选中 +function sel(selectStatus, that, id) { + if (selectStatus) { + $(that).prop('checked', true); + delIdArr.push(id); + } else { + $(that).prop('checked', false); + for (let i = 0; i < delIdArr.length; i++) { + if (delIdArr[i] == id) { + arr.splice(i, 1); + break; + } + } + } +} + +// 删除选中 +function delFitType() { + if (delIdArr.length == 0) { + layer.msg('请先选择需要删除的数据!', { icon: 7 }) + return; + } + let layerIndex = layer.confirm('
确定要删除选中数据吗!
', { title: '操作提示' }, function () { + layer.close(layerIndex); + for (let i = 0; i < delIdArr.length; i++) { + for (let j = 0; j < jjDataArr.length; j++) { + let id = jjDataArr[j].id; + if (delIdArr[i] == id) { + jjDataArr.splice(j, 1); + break; + } + } + } + if (jjDataArr.length === 0) { + $('#no_data_title').removeAttr('style'); + $('#search-info').css({ 'display': 'none' }); + $('#table-box').css({ 'display': 'none' }); + } else { + setTableData(jjDataArr); + } + + }); +} + +// 校验数据 +function checkValue(that, type) { + let value = $(that).val(); + if (type === 1) { // 入库量 + const regex = /^(0|[1-9]\d{0,6})$/; + if (!regex.test(value) && value) { + layer.msg('入库量输入不合法,请重新输入!', { icon: 5 }) + $(that).val(''); + } + } else if (type === 2) { // 单价 + const regex = /^(?:1(?:\d{0,8}|[0-9]*\.\d{1,2})|(?:[1-9]\d{0,7}|[1-9]\d{0,6}\.\d{1,2}|[1-9]\d{1,7}\.\d{2}|100000000(?:\.00)?))$/; + if (!regex.test(value) && value) { + layer.msg('单价输入不合法,请重新输入!', { icon: 5 }) + $(that).val(''); + } + } +} + +// 关闭页面 +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/js/accessory/child/choose_return_fit_type_list.js b/js/accessory/child/choose_return_fit_type_list.js new file mode 100644 index 0000000..15b4577 --- /dev/null +++ b/js/accessory/child/choose_return_fit_type_list.js @@ -0,0 +1,379 @@ +let objParam; +let form, table, element, tableIns, layer, util; +let pageNum = 1; +let quanju = new Array();//全局 +let huancun = new Array();//缓存 +let huancunObj = new Array();//缓存2 +let cjList = []; +let jjDetailArr = []; // 入库配件类型数据 +function setParams(obj) { + objParam = JSON.parse(obj); + console.log(objParam); + layui.use(["form", "table", 'element', 'layer', 'util'], function () { + form = layui.form; + table = layui.table; + element = layui.element; + layer = layui.layer; + util = layui.util; + getVendList(); + initTable(); + }); +} + +// 厂家下拉选 +function getVendList() { + cjList.splice(0, cjList.length); + let encryptedData = {}; + let url = dataUrl + 'backstage/paType/getVendList?encryptedData=' + encodeURIComponent(JSON.stringify(encryptedData)); + ajaxRequest(url, "GET", null, false, function () { + }, function (result) { + console.log(result); + if (result.code === 200) { + cjList = result.data; + } + }, function (xhr, status, error) { + errorFn(xhr, status, error) + }, null); +} + +// 查询/重置 +function queryTable(type) { + if (type === 1) { + reloadTable(1); + } else if (type === 2) { + $('#name').val(''); + $('#module').val(''); + $('#type').val(''); + layui.form.render(); + reloadTable(1); + } +} + +// 重载表格 +function reloadTable(pageNum) { + table.reload("currentTableId", { + page: { + curr: pageNum ? pageNum : 1, + }, + where: { + encryptedData: JSON.stringify({ + 'name': $('#name').val(), + 'model': $('#model').val(), + 'type': $('#type').val(), + }), + }, + }, + ); +} + + +// 表格数据 +function initTable() { + tableIns = table.render({ + elem: "#currentTableId", + id: 'currentTableId', + height: "full-200", + headers: { + authorization: sessionStorage.getItem("gz-token"), + }, + url: dataUrl + "backstage/paType/findByPage", + where: { + encryptedData: JSON.stringify({ + 'type': $('#type').val(), + 'name': $('#name').val(), + 'model': $('#model').val(), + }), + }, + 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.price = item2.price; + item.remarks = item2.remarks; + item.manufacturer = item2.manufacturer; + } + }); + }); + } + return { + "code": 0, // 解析接口状态 + "msg": '获取成功', // 解析提示文本 + "count": res.total, // 解析数据长度 + "data": res.list // 解析数据列表 + }; + }, + cols: [ + [ + { type: 'checkbox', width: '5%' }, + { + width: '6%', + title: "序号", + align: "center", + templet: function (d) { + return d.LAY_NUM; + }, + }, + { + field: "type", + width: '11.8%', + title: "配件类型", + unresize: true, + align: "center", + }, + { + field: "name", + width: '12%', + title: "配件名称", + unresize: true, + align: "center", + }, + { + field: "model", + width: '10%', + title: "规格型号", + unresize: true, + align: "center", + }, + { + field: "unit", + title: "单位", + width: '8%', + unresize: true, + align: "center", + }, + { + field: "num", + width: '10%', + title: " * 本次入库量", + unresize: true, + align: "center", + edit: 'text', + style: 'outline: 1px solid #e6e6e6;outline-offset: -5px;' + }, + { + field: "price", + width: '9.8%', + title: "单价(元)", + unresize: true, + align: "center", + edit: 'text', + style: 'outline: 1px solid #e6e6e6;outline-offset: -5px;' + }, + { + field: "manufacturer", + width: '15%', + title: " * 配件厂家", + unresize: true, + align: "center", + templet: '#TPL-select-demo' + }, + { + field: "remarks", + width: '12%', + 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) { + var options = this; + table.resize("currentTableId"); + pageNum = tableIns.config.page.curr; + form.on('select(select-demo)', function (obj) { + console.log(obj); + var value = obj.value; // 获取选中项 value + // 获取当前行数据(如 id 等字段,以作为数据修改的索引) + var data = table.getRowData(options.id, obj.elem); + // 更新数据中对应的字段 + data.manufacturer = value; + updateOrAddObject(data.id, data); + }); + // 获取当前行数据 - 自定义方法 + table.getRowData = function (tableId, elem) { + var index = $(elem).closest('tr').data('index'); + return table.cache[tableId][index] || {}; + }; + + //设置全部数据到全局变量 + quanju = res.data; + for (var i = 0; i < res.data.length; i++) { + for (var j = 0; j < huancun.length; j++) { + //数据id和要勾选的id相同时checkbox选中 + if (res.data[i].id === huancun[j]) { + //这里才是真正的有效勾选 + res.data[i]["LAY_CHECKED"] = 'true'; + //找到对应数据改变勾选样式,呈现出选中效果 + var index = res.data[i]['LAY_INDEX']; + $('.layui-table tr[data-index=' + index + '] input[type="checkbox"]').prop('checked', true); + $('.layui-table tr[data-index=' + index + '] input[type="checkbox"]').next().addClass('layui-form-checked'); + } + } + } + //设置全选checkbox的选中状态,只有改变LAY_CHECKED的值, table.checkStatus才能抓取到选中的状态 + let checkStatus = table.checkStatus('currentTableId');//这里的lightTable是指分页中的id + if (checkStatus.isAll) {//是否全选 + //layTableAllChoose + $('.layui-table th[data-field="0"] input[type="checkbox"]').prop('checked', true);//data-field值默认为0,如果在分页部分自定义了属性名,则需要改成对应的属性名 + $('.layui-table th[data-field="0"] input[type="checkbox"]').next().addClass('layui-form-checked');//data-field值默认为0,如果在分页部分自定义了属性名,则需要改成对应的属性名 + } + }, + }); + table.on('edit(currentTableId2)', function (obj) { + var field = obj.field; // 得到修改的字段 + var value = obj.value // 得到修改后的值 + if (field === 'num') { // 本次入库量 + 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 === 'price') { + const regex = /^(?:1(?:\d{0,8}|[0-9]*\.\d{1,2})|(?:[1-9]\d{0,7}|[1-9]\d{0,6}\.\d{1,2}|[1-9]\d{1,7}\.\d{2}|100000000(?:\.00)?))$/; + if (!regex.test(value)) { + obj.reedit(); + return layer.msg('单价格式不正确!', { icon: 7 }) + } + } else if (field === 'remarks') { // 备注 + if (value) { + if (value.length > 255) { + obj.reedit(); + return layer.msg('备注最多输入255位!', { icon: 7 }) + } + } + } + // 显示 - 仅用于演示 + // layer.msg('[ID: ' + data.id + '] ' + field + ' 字段更改值为:' + util.escape(value)); + let id = obj.data.id; + updateOrAddObject(id, obj.data); + }); + //复选框选中监听,将选中的id 设置到缓存数组,或者删除缓存数组 + table.on('checkbox(currentTableId2)', function (obj) { + if (obj.checked === true) { + if (obj.type === 'one' && huancun.indexOf(obj.data.id) === -1) { + huancun.push(obj.data.id); + huancunObj.push(obj.data); + } else { + for (let i = 0; i < quanju.length; i++) { + if (huancun.indexOf(quanju[i].id) === -1) { + huancun.push(quanju[i].id); + huancunObj.push(quanju[i]); + } + } + } + } else { + if (obj.type === 'one') { + for (let i = 0; i < huancun.length; i++) { + if (huancun[i] === obj.data.id) { + removeByValue(huancun, huancun[i]);//调用自定义的根据值移除函数 + removeByValue(huancunObj, huancunObj[i]);//调用自定义的根据值移除函数 + } + } + } else { + for (let i = 0; i < quanju.length; i++) { + for (let j = 0; j < huancun.length; j++) { + if (huancun[j] === quanju[i].id) { + removeByValue(huancun, +huancun[j]);//调用自定义的根据值移除函数 + removeByValue(huancunObj, +huancunObj[j]);//调用自定义的根据值移除函数 + } + } + } + } + } + }); +} + +// 根据id 判断对象数组的对象是否存在 如果存在则替换,不存在则添加 +function updateOrAddObject(id, newObject) { + const index = jjDetailArr.findIndex(obj => obj.id === id); + if (index !== -1) { + // 如果对象存在,则替换它 + jjDetailArr[index] = newObject; + } else { + // 如果对象不存在,则添加到数组 + jjDetailArr.push(newObject); + } +} + + +//自定义方法,根据值去移除 +function removeByValue(arr, val) { + for (let i = 0; i < arr.length; i++) { + if (arr[i] == val) { + arr.splice(i, 1); + break; + } + } + for (let i = 0; i < huancunObj.length; i++) { + if (huancunObj[i].id == val) { + huancunObj.splice(i, 1); + break; + } + } +} + +// 保存数据 +function saveData2(params) { + let dataArr = []; + if (huancun.length === 0) { + return layer.msg('未添加数据', { icon: 7 }); + } else { + $.each(huancunObj, function (index, item) { + dataArr.push(item); + }) + for (let i = 0; i < huancun.length; i++) { + const id = huancun[i]; + for (let j = 0; j < jjDetailArr.length; j++) { + const obj = jjDetailArr[j]; + if (id === obj.id) { + updateOrAddObject2(id, obj); + } + } + } + } + console.log(dataArr); + let layerIndex = layer.confirm('
数据即将被添加,请仔细检查数据是否有错误!
', { title: '操作提示' }, function () { + layer.close(layerIndex); + closePage(1, JSON.stringify(dataArr)); + }); + // 替换对象 + function updateOrAddObject2(id, newObject) { + const index = dataArr.findIndex(obj => obj.id === id); + if (index !== -1) { + // 如果对象存在,则替换它 + dataArr[index] = newObject; + } else { + // 如果对象不存在,则添加到数组 + dataArr.push(newObject); + } + } +} + + +// 配件类型 +function addFitTypeData() { + openIframeByParamObj2("add_fit_type_data", "配件类型", "../../../page/basic/fit_type_list.html", "92%", "95%", {}); +} + +function closePage(type,params) { + let index = parent.layer.getFrameIndex(window.name); // 先得到当前 iframe层的索引 + parent.layer.close(index); // 再执行关闭 + if (type == 1) { + window.parent.addFitDatas(params); + } + +} \ No newline at end of file diff --git a/page/accessory/accessory_return_list.html b/page/accessory/accessory_return_list.html index d46e528..421dfc7 100644 --- a/page/accessory/accessory_return_list.html +++ b/page/accessory/accessory_return_list.html @@ -44,8 +44,8 @@ class="layui-icon"> 搜 索 - + diff --git a/page/accessory/child/accessory_return_form.html b/page/accessory/child/accessory_return_form.html new file mode 100644 index 0000000..faa0569 --- /dev/null +++ b/page/accessory/child/accessory_return_form.html @@ -0,0 +1,140 @@ + + + + + + + 发货 + + + + + + + +
+
+
+
+
+ +
+ +
+
+
+ +
+
+ +
+ +
+
+
+
+ +
+ +
+
+ +
+
+
+

附件证明*

+
+
+ +
+

(最多上传5个附件)

+
+
+
+ +

退料配件明细

+
+ +
+ 无数据 +

您还没选择退料配件类型

+

需要添加配件类型后才能执行退料入库操作

+

只可退回选择的维修人员已经领用过的配件类型

+ +
+ + +
+
+ + +
+
+ + + + + + + + \ No newline at end of file diff --git a/page/accessory/child/choose_return_fit_type_list.html b/page/accessory/child/choose_return_fit_type_list.html new file mode 100644 index 0000000..e847cb4 --- /dev/null +++ b/page/accessory/child/choose_return_fit_type_list.html @@ -0,0 +1,97 @@ + + + + + + + 需求计划 + + + + + + + +
+
+
+ 搜索信息 +
+
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+ + +
+
+
+
+
+
+
+
+
+ + +
+
+
+ + + + + + + + + + \ No newline at end of file