diff --git a/js/aq_demand_plan/child/choose_crane_type_list.js b/js/aq_demand_plan/child/choose_crane_type_list.js index b71451f..2405bfc 100644 --- a/js/aq_demand_plan/child/choose_crane_type_list.js +++ b/js/aq_demand_plan/child/choose_crane_type_list.js @@ -25,7 +25,7 @@ function queryTable(type) { let flag = checkValue(pName); if (flag) { $('#pName').val(''); - return layer.msg('物机名称查询包含特殊字符,请重新输入', { icon: 2 }); + return layer.msg('物资名称查询包含特殊字符,请重新输入', { icon: 2 }); } let name = $('#name').val(); let flag2 = checkValue(name); @@ -45,54 +45,22 @@ function queryTable(type) { // 重载表格 function reloadTable(pageNum) { table.reload("currentTableId", { - page: { - curr: pageNum ? pageNum : 1, + page: { + curr: pageNum ? pageNum : 1, + }, + where: { + encryptedData: JSON.stringify({ + 'pName': $('#pName').val(), + 'name': $('#name').val(), + }), + }, }, - where: { - encryptedData: JSON.stringify({ - 'pName': $('#pName').val(), - 'name': $('#name').val(), - }), - }, - }, ); } // 表格数据 function initTable() { - const fakeData = [ - { - id: 1, - ppName: "物机类型1", - pName: "物机名称1", - name: "规格1", - unit: "单位1", - needNum: 10, - times: 5, - remarks: "备注1" - }, - { - id: 2, - ppName: "物机类型2", - pName: "物机名称2", - name: "规格2", - unit: "单位2", - needNum: 20, - times: 3, - remarks: "备注2" - }, - { - id: 3, - ppName: "物机类型3", - pName: "物机名称3", - name: "规格3", - unit: "单位3", - needNum: 30, - times: 2, - remarks: "备注3" - }, - ]; tableIns = table.render({ elem: "#currentTableId", id: 'currentTableId', @@ -100,8 +68,7 @@ function initTable() { headers: { authorization: sessionStorage.getItem("gz-token"), }, - data: fakeData, - // url: dataUrl + "backstage/planApplication/getTypeList", + url: dataUrlCar + "backstage/carType/getCarSelected", where: { encryptedData: JSON.stringify({ 'pName': $('#pName').val(), @@ -148,7 +115,7 @@ function initTable() { { field: "ppName", width: '10%', - title: "物机类型", + title: "车辆类型", unresize: true, align: "center", sort:true, @@ -156,7 +123,7 @@ function initTable() { { field: "pName", width: '10%', - title: "物机名称", + title: "车辆名称", unresize: true, align: "center", sort:true, @@ -189,7 +156,7 @@ function initTable() { { field: "times", width: '15%', - title: " * 需用天数", + title: "退还日期", unresize: true, align: "center", edit: 'text', @@ -211,42 +178,8 @@ function initTable() { limit: 10, page: true, done: function (res, curr, count) { - const fakeData = [ - { - id: 1, - ppName: "物机类型1", - pName: "物机名称1", - name: "规格1", - unit: "单位1", - needNum: 10, - times: 5, - remarks: "备注1" - }, - { - id: 2, - ppName: "物机类型2", - pName: "物机名称2", - name: "规格2", - unit: "单位2", - needNum: 20, - times: 3, - remarks: "备注2" - }, - { - id: 3, - ppName: "物机类型3", - pName: "物机名称3", - name: "规格3", - unit: "单位3", - needNum: 30, - times: 2, - remarks: "备注3" - }, - ]; table.resize("currentTableId"); - // pageNum = tableIns.config.page.curr; //设置全部数据到全局变量 - res.data = fakeData; quanju = res.data; for (var i = 0; i < res.data.length; i++) { for (var j = 0; j < huancun.length; j++) { @@ -300,8 +233,10 @@ function initTable() { if (obj.type === 'one' && huancun.indexOf(obj.data.id) === -1) { huancun.push(obj.data.id); huancunObj.push(obj.data); - } else { + } else if (obj.type === 'all') { + // 全选时,添加当前页的所有数据 for (let i = 0; i < quanju.length; i++) { + // 避免重复添加 if (huancun.indexOf(quanju[i].id) === -1) { huancun.push(quanju[i].id); huancunObj.push(quanju[i]); @@ -313,15 +248,16 @@ function initTable() { for (let i = 0; i < huancun.length; i++) { if (huancun[i] === obj.data.id) { removeByValue(huancun, huancun[i]);//调用自定义的根据值移除函数 - removeByValue(huancunObj, huancunObj[i]);//调用自定义的根据值移除函数 + break; // 找到并移除后立即退出循环 } } - } else { + } else if (obj.type === 'all') { + // 取消全选时,移除当前页的所有数据 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]);//调用自定义的根据值移除函数 + removeByValue(huancun, huancun[j]);//调用自定义的根据值移除函数 + j--; // 因为删除了元素,所以索引需要减1 } } } @@ -331,7 +267,7 @@ function initTable() { }); } -// 根据id 判断对象数组的对象是否存在 如果存在则替换,不存在则添加 +// 根据id 判断对象数组的对象是否存在 如果存在则替换,不存在则添加 function updateOrAddObject(id, newObject) { const index = jjDetailArr.findIndex(obj => obj.id === id); if (index !== -1) { @@ -352,6 +288,7 @@ function removeByValue(arr, val) { break; } } + // 同步移除huancunObj中对应的对象 for (let i = 0; i < huancunObj.length; i++) { if (huancunObj[i].id == val) { huancunObj.splice(i, 1); diff --git a/js/aq_demand_plan/child/choose_tool_type_list.js b/js/aq_demand_plan/child/choose_tool_type_list.js index 09ce8ea..27953d2 100644 --- a/js/aq_demand_plan/child/choose_tool_type_list.js +++ b/js/aq_demand_plan/child/choose_tool_type_list.js @@ -25,7 +25,7 @@ function queryTable(type) { let flag = checkValue(pName); if (flag) { $('#pName').val(''); - return layer.msg('物机名称查询包含特殊字符,请重新输入', { icon: 2 }); + return layer.msg('物资名称查询包含特殊字符,请重新输入', { icon: 2 }); } let name = $('#name').val(); let flag2 = checkValue(name); @@ -61,38 +61,6 @@ function reloadTable(pageNum) { // 表格数据 function initTable() { - const fakeData = [ - { - id: 1, - ppName: "物机类型1", - pName: "物机名称1", - name: "规格1", - unit: "单位1", - needNum: 10, - times: 5, - remarks: "备注1" - }, - { - id: 2, - ppName: "物机类型2", - pName: "物机名称2", - name: "规格2", - unit: "单位2", - needNum: 20, - times: 3, - remarks: "备注2" - }, - { - id: 3, - ppName: "物机类型3", - pName: "物机名称3", - name: "规格3", - unit: "单位3", - needNum: 30, - times: 2, - remarks: "备注3" - }, - ]; tableIns = table.render({ elem: "#currentTableId", id: 'currentTableId', @@ -100,8 +68,7 @@ function initTable() { headers: { authorization: sessionStorage.getItem("gz-token"), }, - data: fakeData, // 使用假数据 - // url: dataUrl + "backstage/planApplication/getTypeList", + url: dataUrlDevice + "backstage/planApplication/getTypeList", where: { encryptedData: JSON.stringify({ 'pName': $('#pName').val(), @@ -148,7 +115,7 @@ function initTable() { { field: "ppName", width: '10%', - title: "物机类型", + title: "物资类型", unresize: true, align: "center", sort:true, @@ -156,7 +123,7 @@ function initTable() { { field: "pName", width: '10%', - title: "物机名称", + title: "物资名称", unresize: true, align: "center", sort:true, @@ -189,7 +156,7 @@ function initTable() { { field: "times", width: '15%', - title: " * 需用天数", + title: " * 退还日期", unresize: true, align: "center", edit: 'text', @@ -211,42 +178,7 @@ function initTable() { limit: 10, page: true, done: function (res, curr, count) { - const fakeData = [ - { - id: 1, - ppName: "物机类型1", - pName: "物机名称1", - name: "规格1", - unit: "单位1", - needNum: 10, - times: 5, - remarks: "备注1" - }, - { - id: 2, - ppName: "物机类型2", - pName: "物机名称2", - name: "规格2", - unit: "单位2", - needNum: 20, - times: 3, - remarks: "备注2" - }, - { - id: 3, - ppName: "物机类型3", - pName: "物机名称3", - name: "规格3", - unit: "单位3", - needNum: 30, - times: 2, - remarks: "备注3" - }, - ]; - res.data = fakeData; - console.log("ggggggggggggggggggggg",res.data) table.resize("currentTableId"); - // pageNum = tableIns.config.page.curr; //设置全部数据到全局变量 quanju = res.data; for (var i = 0; i < res.data.length; i++) { @@ -301,8 +233,10 @@ function initTable() { if (obj.type === 'one' && huancun.indexOf(obj.data.id) === -1) { huancun.push(obj.data.id); huancunObj.push(obj.data); - } else { + } else if (obj.type === 'all') { + // 全选时,添加当前页的所有数据 for (let i = 0; i < quanju.length; i++) { + // 避免重复添加 if (huancun.indexOf(quanju[i].id) === -1) { huancun.push(quanju[i].id); huancunObj.push(quanju[i]); @@ -314,15 +248,16 @@ function initTable() { for (let i = 0; i < huancun.length; i++) { if (huancun[i] === obj.data.id) { removeByValue(huancun, huancun[i]);//调用自定义的根据值移除函数 - removeByValue(huancunObj, huancunObj[i]);//调用自定义的根据值移除函数 + break; // 找到并移除后立即退出循环 } } - } else { + } else if (obj.type === 'all') { + // 取消全选时,移除当前页的所有数据 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]);//调用自定义的根据值移除函数 + removeByValue(huancun, huancun[j]);//调用自定义的根据值移除函数 + j--; // 因为删除了元素,所以索引需要减1 } } } @@ -332,7 +267,7 @@ function initTable() { }); } -// 根据id 判断对象数组的对象是否存在 如果存在则替换,不存在则添加 +// 根据id 判断对象数组的对象是否存在 如果存在则替换,不存在则添加 function updateOrAddObject(id, newObject) { const index = jjDetailArr.findIndex(obj => obj.id === id); if (index !== -1) { @@ -353,6 +288,7 @@ function removeByValue(arr, val) { break; } } + // 同步移除huancunObj中对应的对象 for (let i = 0; i < huancunObj.length; i++) { if (huancunObj[i].id == val) { huancunObj.splice(i, 1); diff --git a/js/aq_demand_plan/child/choose_vehicle_type_list.js b/js/aq_demand_plan/child/choose_vehicle_type_list.js index f86923f..8824f5b 100644 --- a/js/aq_demand_plan/child/choose_vehicle_type_list.js +++ b/js/aq_demand_plan/child/choose_vehicle_type_list.js @@ -25,7 +25,7 @@ function queryTable(type) { let flag = checkValue(pName); if (flag) { $('#pName').val(''); - return layer.msg('物机名称查询包含特殊字符,请重新输入', { icon: 2 }); + return layer.msg('物资名称查询包含特殊字符,请重新输入', { icon: 2 }); } let name = $('#name').val(); let flag2 = checkValue(name); @@ -45,16 +45,16 @@ function queryTable(type) { // 重载表格 function reloadTable(pageNum) { table.reload("currentTableId", { - page: { - curr: pageNum ? pageNum : 1, + page: { + curr: pageNum ? pageNum : 1, + }, + where: { + encryptedData: JSON.stringify({ + 'pName': $('#pName').val(), + 'name': $('#name').val(), + }), + }, }, - where: { - encryptedData: JSON.stringify({ - 'pName': $('#pName').val(), - 'name': $('#name').val(), - }), - }, - }, ); } @@ -64,8 +64,8 @@ function initTable() { const fakeData = [ { id: 1, - ppName: "物机类型1", - pName: "物机名称1", + ppName: "DD物资类型1", + pName: "物资名称1", name: "规格1", unit: "单位1", needNum: 10, @@ -74,8 +74,8 @@ function initTable() { }, { id: 2, - ppName: "物机类型2", - pName: "物机名称2", + ppName: "物资类型2", + pName: "物资名称2", name: "规格2", unit: "单位2", needNum: 20, @@ -84,8 +84,8 @@ function initTable() { }, { id: 3, - ppName: "物机类型3", - pName: "物机名称3", + ppName: "物资类型3", + pName: "物资名称3", name: "规格3", unit: "单位3", needNum: 30, @@ -148,7 +148,7 @@ function initTable() { { field: "ppName", width: '10%', - title: "物机类型", + title: "物资类型", unresize: true, align: "center", sort:true, @@ -156,7 +156,7 @@ function initTable() { { field: "pName", width: '10%', - title: "物机名称", + title: "物资名称", unresize: true, align: "center", sort:true, @@ -214,8 +214,8 @@ function initTable() { const fakeData = [ { id: 1, - ppName: "物机类型1", - pName: "物机名称1", + ppName: "物资类型1", + pName: "物资名称1", name: "规格1", unit: "单位1", needNum: 10, @@ -224,8 +224,8 @@ function initTable() { }, { id: 2, - ppName: "物机类型2", - pName: "物机名称2", + ppName: "物资类型2", + pName: "物资名称2", name: "规格2", unit: "单位2", needNum: 20, @@ -234,8 +234,8 @@ function initTable() { }, { id: 3, - ppName: "物机类型3", - pName: "物机名称3", + ppName: "物资类型3", + pName: "物资名称3", name: "规格3", unit: "单位3", needNum: 30, @@ -331,7 +331,7 @@ function initTable() { }); } -// 根据id 判断对象数组的对象是否存在 如果存在则替换,不存在则添加 +// 根据id 判断对象数组的对象是否存在 如果存在则替换,不存在则添加 function updateOrAddObject(id, newObject) { const index = jjDetailArr.findIndex(obj => obj.id === id); if (index !== -1) { diff --git a/page/aq_demand_plan/child/choose_crane_type_list.html b/page/aq_demand_plan/child/choose_crane_type_list.html index fd30c0e..5a88ab5 100644 --- a/page/aq_demand_plan/child/choose_crane_type_list.html +++ b/page/aq_demand_plan/child/choose_crane_type_list.html @@ -4,7 +4,7 @@
-