From 7447fd56cbad0652b928939409e3c32cbf173ab7 Mon Sep 17 00:00:00 2001 From: cwchen <1048842385@qq.com> Date: Tue, 12 Nov 2024 12:17:43 +0800 Subject: [PATCH] =?UTF-8?q?=E9=85=8D=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/basic/child/fit_type_form.js | 29 ++++++++++++++++++++++---- js/basic/fit_type_list.js | 36 ++++++++++++++++++++++++++------- js/openIframe.js | 4 ++-- 3 files changed, 56 insertions(+), 13 deletions(-) diff --git a/js/basic/child/fit_type_form.js b/js/basic/child/fit_type_form.js index 0fb3eed..b4d6996 100644 --- a/js/basic/child/fit_type_form.js +++ b/js/basic/child/fit_type_form.js @@ -3,10 +3,12 @@ let objParam; function setParams(obj) { objParam = JSON.parse(obj); console.log(objParam); - $('#parentName').val(objParam.context); - $('#parentId').val(objParam.id); - if (objParam.type === 2) { // 新增 + if (objParam.type === 2) { // 修改 $('#id').val(objParam.nodeId); + $('#parentId').val(objParam.parentId); + } else if (objParam.type === 1) { // 新增 + $('#parentName').val(objParam.context); + $('#parentId').val(objParam.nodeId); } console.log(objParam); layui.use(['form', 'layer'], function () { @@ -20,6 +22,25 @@ function setParams(obj) { }); } +// 详情 +function getDetailById() { + let encryptedData = { + id: objParam.nodeId + }; + let url = dataUrl + 'backstage/paType/getTypeDataById?encryptedData=' + encodeURIComponent(JSON.stringify(encryptedData)); + ajaxRequest(url, "GET", null, true, function () { + }, function (result) { + console.log(result); + if (result.code === 200) { + $('#parentName').val(result.data.parentName); + $('#name').val(result.data.name); + $('#unit').val(result.data.unit); + } + }, function (xhr, status, error) { + errorFn(xhr, status, error) + }, null); +} + function saveData2() { $('#formSubmit').trigger('click') } @@ -48,7 +69,7 @@ function submitApply(data) { $('.cancel').removeClass("layui-btn-disabled").attr("disabled", false); if (result.code === 200) { parent.layer.msg(result.msg, { icon: 1 }); - closePage(1); + closePage(1, result.data); } else { layer.msg(result.msg, { icon: 2 }); } diff --git a/js/basic/fit_type_list.js b/js/basic/fit_type_list.js index 3cf7c67..2046c30 100644 --- a/js/basic/fit_type_list.js +++ b/js/basic/fit_type_list.js @@ -12,7 +12,7 @@ layui.config({ dtreeData = getDTreeData(); fitTypeTree = dtree.render({ elem: "#fitTypeTree", - width: "98%", // 指定树的宽度 + width: "30%", // 指定树的宽度 dataFormat: "list", none: "无数据", menubar: true, @@ -29,7 +29,7 @@ layui.config({ if (param.level === '1') { buttons.customEdit = ""; buttons.customDel = ""; - } else if (param.level === '4') { // 三级规格型号 + } else if (param.level === '4') { buttons.customAdd = ""; } return buttons; // 将按钮对象返回 @@ -47,11 +47,8 @@ layui.config({ }, { toolbarId: "customDel", icon: "dtree-icon-roundclose", title: "删除", handler: function (node, $div) { - if (node.level === '2') { // 删除配件 - delAreaData(node.nodeId, node.parentId, '1', $div) - } else if (node.level === '3') { // 删除配件 - delAreaData(node.nodeId, node.parentId, '2', $div) - } + // 删除配件 + delFitType(node.nodeId, $div); } }], done: function (result, $ul, first) { @@ -116,6 +113,31 @@ function queryDtree(type) { } } +// 删除配件 +function delFitType(id, $div) { + layer.confirm("确定删除此条数据吗?", { 'title': '操作提示', move: false }, function () { + let loadingMsg = layer.msg('数据删除中,请稍候...', { icon: 16, scrollbar: false, time: 0 }); + let url = dataUrl + "backstage/paType/deleteTypeData" + let obj = { 'id': id } + let params = { + encryptedData: JSON.stringify(obj) + } + ajaxRequest(url, "POST", params, true, function () { + }, function (result) { + layer.close(loadingMsg); // 关闭提示层 + if (result.code === 200) { + layer.msg(result.msg, { icon: 1 }) + fitTypeTree.partialRefreshDel($div); // 删除节点 + } else { + layer.msg(result.msg, { icon: 2 }) + } + }, function (xhr) { + layer.close(loadingMsg); // 关闭提示层 + error(xhr) + }); + }) +} + // 赋值新增节点 function reloadData(data) { jsonData = data; diff --git a/js/openIframe.js b/js/openIframe.js index a63162b..4d7a9eb 100644 --- a/js/openIframe.js +++ b/js/openIframe.js @@ -101,10 +101,10 @@ function openIframeByDtree(id, title, content, width, height, params, $div) { if (jsonData) { if (params.id) { // 修改节点 - areaTree.partialRefreshEdit($div, jsonData.title); + fitTypeTree.partialRefreshEdit($div, jsonData.title); } else { // 新增节点 - areaTree.partialRefreshAdd($div, jsonData); + fitTypeTree.partialRefreshAdd($div, jsonData); } jsonData = null; }