From 1e0f4f402b46887c6c318d727c7d883db820898c Mon Sep 17 00:00:00 2001 From: cwchen <1048842385@qq.com> Date: Wed, 13 Nov 2024 10:18:10 +0800 Subject: [PATCH] =?UTF-8?q?=E9=85=8D=E4=BB=B6=E5=85=A5=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/accessory/accessory_store_list.js | 7 +- .../child/accessory_store_edit_form.js | 174 ++++++------------ page/accessory/accessory_store_list.html | 6 +- .../child/accessory_store_edit_form.html | 8 +- 4 files changed, 63 insertions(+), 132 deletions(-) diff --git a/js/accessory/accessory_store_list.js b/js/accessory/accessory_store_list.js index bfd2997..bc50182 100644 --- a/js/accessory/accessory_store_list.js +++ b/js/accessory/accessory_store_list.js @@ -146,8 +146,8 @@ function initTable() { unresize: true, templet: function (d) { let html = ""; - html += "详情"; - html += "
|
修改"; + html += "详情"; + html += "
|
修改"; return html; }, }, @@ -170,6 +170,9 @@ function setStatusColor(value) { let name = '' if (value === '0') { color = "#f56c6c"; + name = '否'; + } else { + name = '是'; } return '' + name + ""; } diff --git a/js/accessory/child/accessory_store_edit_form.js b/js/accessory/child/accessory_store_edit_form.js index 7fa1e6e..8abecb6 100644 --- a/js/accessory/child/accessory_store_edit_form.js +++ b/js/accessory/child/accessory_store_edit_form.js @@ -1,4 +1,4 @@ -let idParam, objParam, fileList = new Array(), imgListUp = new Array(); +let idParam, objParam, fileList = new Array(), imgListUp = new Array(), delImgIdList = []; let form, laydate, layer, upload, table, util; let pageNum = 1, tableIns; // 定义分页 let jjDataArr = []; // 入库配件数据 @@ -64,12 +64,27 @@ function getInputDetails() { }, function (result) { console.error(result); if (result.code === 200) { - + setFormData(); } else { } }, function (xhr, status, error) { errorFn(xhr, status, error) }, null); + + // 表单赋值 + function setFormData(obj) { + layui.form('formInfo', obj); + let flieList = obj.flieList; + for (let i = 0; i < flieList.length; i++) { + let path = fileUrl + flieList[i].fileUrl + '?token=' + sessionStorage.getItem("gz-token"); + let file = { name: flieList[i].fileName, id: fileList[i].id }; + html += '
' + + '

x

' + + handleFileType(i, file, path) + + '
' + } + $('#uploader-list').append(html); + } } // 获取入库配件表格明细 @@ -82,7 +97,8 @@ function getInputDetailList() { }, function (result) { console.log(result); if (result.code === 200) { - + jjDataArr = result.data; + setTableData(jjDataArr); } }, function (xhr, status, error) { errorFn(xhr, status, error) @@ -99,9 +115,9 @@ function handleFileType(index, file, result) { } else if (file.ext === 'pdf') { img = '../../../images/PDF.png'; } else { - return ''; + return ''; } - html += '
' + + html += '
' + '' + '

' + file.name + '

' + '
'; @@ -112,19 +128,26 @@ function handleFileType(index, file, result) { $(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) - }); + let isOld = $(this).next().attr('isOld'); + if (isOld) { + delImgIdList.push(isOld); + console.log(delImgIdList) + $(this).parent().remove(); + } else { + $.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() { @@ -162,6 +185,18 @@ function submitApply(data) { } } data.field.details = list; + data.field.id = objParam.id; + let delId = ''; + if (delImgIdList && delImgIdList.length > 0) { + for (let i = 0; i < delImgIdList.length; i++) { + if (i === delImgIdList.length - 1) { + delId += delImgIdList[i]; + } else { + delId += delImgIdList[i] + '@'; + } + } + } + data.field.delId = delId; let formData = new FormData(); //遍历最终文件集合 for (let i = 0; i < fileList.length; i++) { @@ -216,16 +251,6 @@ function getBaseTableData() { return tableData; } - -// 选择入库配件类型 -function chooseFitType() { - let params = {}; - /* if (jjDataArr && jjDataArr.length > 0) { - params.jjDataArrStr = JSON.stringify(jjDataArr); - } */ - openIframeByParamObj("choose_fit_type", '选择入库配件类型', "./choose_fit_type_list.html", '92%', '95%', params); -} - // 查询 function search() { let keyWord = $('#type').val(); @@ -279,37 +304,6 @@ function resetSearch() { 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) @@ -318,7 +312,6 @@ function setTableData(results) { for (var i = 0; i < results.length; i++) { var l = results[i]; html += ""; - html += ''; html += "" + (i + 1) + ""; html += "" + l.type + ""; @@ -385,67 +378,6 @@ function getVendList() { }, 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(); diff --git a/page/accessory/accessory_store_list.html b/page/accessory/accessory_store_list.html index ef43e14..e65f539 100644 --- a/page/accessory/accessory_store_list.html +++ b/page/accessory/accessory_store_list.html @@ -46,12 +46,8 @@ class="layui-icon layui-icon-refresh"> 重 置 - - + class="layui-icon layui-icon-download-circle"> 导 出
diff --git a/page/accessory/child/accessory_store_edit_form.html b/page/accessory/child/accessory_store_edit_form.html index 8bc9ee0..3ec567e 100644 --- a/page/accessory/child/accessory_store_edit_form.html +++ b/page/accessory/child/accessory_store_edit_form.html @@ -15,7 +15,7 @@
-
+
@@ -94,9 +94,9 @@ - @@ -105,7 +105,7 @@ - +
+ 序号 配件类型 配件名称* 本次入库量 单价(元) * 配件厂家备注备注