前端问题优化
This commit is contained in:
parent
84fa51f115
commit
4796a44e6c
|
|
@ -278,7 +278,8 @@ function addFitDatas(data) {
|
|||
$.each(newJjDataArr, function (index, item) {
|
||||
updateOrAddObject(item.id, item);
|
||||
});
|
||||
setTableData(jjDataArr);
|
||||
goOnAddData();
|
||||
// setTableData(jjDataArr);
|
||||
} else { // 第一次添加数据
|
||||
jjDataArr = JSON.parse(data);
|
||||
if (jjDataArr && jjDataArr.length > 0) {
|
||||
|
|
@ -322,7 +323,7 @@ function setTableData(results) {
|
|||
html += "</tr>";
|
||||
}
|
||||
} else {
|
||||
html += "<tr><td colspan='12' class='center'>没有相关数据</td></tr>";
|
||||
html += "<tr><td colspan='7' class='center'>没有相关数据</td></tr>";
|
||||
}
|
||||
$("#baseTable tbody").empty().append(html);
|
||||
layui.form.render();
|
||||
|
|
@ -390,17 +391,60 @@ function delFitType() {
|
|||
}
|
||||
}
|
||||
}
|
||||
delIdArr.splice(0, delIdArr.length);
|
||||
|
||||
if (jjDataArr.length === 0) {
|
||||
$('#no_data_title').removeAttr('style');
|
||||
$('#search-info').css({ 'display': 'none' });
|
||||
$('#table-box').css({ 'display': 'none' });
|
||||
} else {
|
||||
setTableData(jjDataArr);
|
||||
// setTableData(jjDataArr);
|
||||
handleDelTableData(delIdArr);
|
||||
}
|
||||
|
||||
delIdArr.splice(0, delIdArr.length);
|
||||
});
|
||||
let list = getBaseTableData();
|
||||
}
|
||||
|
||||
// 删除表格数据
|
||||
function handleDelTableData(delIdArr) {
|
||||
if (delIdArr.length > 0) {
|
||||
$.each(delIdArr, function (index, item) {
|
||||
$('#baseTable tbody tr').each(function () {
|
||||
let id = $(this).attr('id');
|
||||
if (parseInt(id) === item) {
|
||||
$(this).remove();
|
||||
return false;
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
$('#baseTable tbody tr').each(function (index, item) {
|
||||
$(this).find('td').eq(1).html(index + 1);
|
||||
})
|
||||
}
|
||||
|
||||
// 继续添加数据
|
||||
function goOnAddData() {
|
||||
if (jjDataArr.length > 0) {
|
||||
$.each(jjDataArr, function (index, item) {
|
||||
$('#baseTable tbody tr').each(function () {
|
||||
let id = $(this).attr('id');
|
||||
if (parseInt(id) === parseInt(item.id)) {
|
||||
let num = $(this).find('td').eq(6).find('input[name="num"]').val(),
|
||||
remark = $(this).find('td').eq(7).find('input[name="remark"]').val();
|
||||
if (!item.num || parseInt(item.num) === 0) {
|
||||
item.num = num;
|
||||
}
|
||||
if (!item.remark) {
|
||||
item.remark = remark;
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
setTableData(jjDataArr);
|
||||
$('#baseTable tbody tr').each(function (index, item) {
|
||||
$(this).find('td').eq(1).html(index + 1);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 校验手机号
|
||||
|
|
|
|||
|
|
@ -266,7 +266,8 @@ function addFitDatas(data) {
|
|||
$.each(newJjDataArr, function (index, item) {
|
||||
updateOrAddObject(item.id, item);
|
||||
});
|
||||
setTableData(jjDataArr);
|
||||
// setTableData(jjDataArr);
|
||||
goOnAddData();
|
||||
} else { // 第一次添加数据
|
||||
jjDataArr = JSON.parse(data);
|
||||
if (jjDataArr && jjDataArr.length > 0) {
|
||||
|
|
@ -281,6 +282,8 @@ function addFitDatas(data) {
|
|||
const index = jjDataArr.findIndex(obj => obj.id === parseInt(id));
|
||||
if (index !== -1) {
|
||||
// 如果对象存在,则替换它
|
||||
let oldData = jjDataArr[index];
|
||||
newObject.dataId = oldData.dataId;
|
||||
jjDataArr[index] = newObject;
|
||||
} else {
|
||||
// 如果对象不存在,则添加到数组
|
||||
|
|
@ -381,18 +384,67 @@ function delFitType() {
|
|||
}
|
||||
}
|
||||
}
|
||||
delIdArr.splice(0, delIdArr.length);
|
||||
|
||||
if (jjDataArr.length === 0) {
|
||||
$('#no_data_title').removeAttr('style');
|
||||
$('#search-info').css({ 'display': 'none' });
|
||||
$('#table-box').css({ 'display': 'none' });
|
||||
} else {
|
||||
setTableData(jjDataArr);
|
||||
// setTableData(jjDataArr);
|
||||
handleDelTableData(delIdArr);
|
||||
}
|
||||
|
||||
delIdArr.splice(0, delIdArr.length);
|
||||
});
|
||||
}
|
||||
|
||||
// 删除表格数据
|
||||
function handleDelTableData(delIdArr) {
|
||||
if (delIdArr.length > 0) {
|
||||
$.each(delIdArr, function (index, item) {
|
||||
$('#baseTable tbody tr').each(function () {
|
||||
let id = $(this).attr('id');
|
||||
if (parseInt(id) === item) {
|
||||
$(this).remove();
|
||||
return false;
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
$('#baseTable tbody tr').each(function (index, item) {
|
||||
$(this).find('td').eq(1).html(index + 1);
|
||||
})
|
||||
}
|
||||
|
||||
// 继续添加数据
|
||||
function goOnAddData() {
|
||||
if (jjDataArr.length > 0) {
|
||||
$.each(jjDataArr, function (index, item) {
|
||||
$('#baseTable tbody tr').each(function () {
|
||||
let id = $(this).attr('id');
|
||||
if (parseInt(id) === parseInt(item.id)) {
|
||||
let times = $(this).find('td').eq(7).find('input[name="times"]').val(),
|
||||
needNum = $(this).find('td').eq(6).find('input[name="needNum"]').val(),
|
||||
remarks = $(this).find('td').eq(8).find('input[name="remarks"]').val();
|
||||
if (!item.times || parseInt(item.times) === 0) {
|
||||
item.times = times;
|
||||
}
|
||||
if (!item.needNum || parseInt(item.needNum) === 0) {
|
||||
item.needNum = needNum;
|
||||
}
|
||||
if (!item.remarks) {
|
||||
item.remarks = remarks;
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
setTableData(jjDataArr);
|
||||
$('#baseTable tbody tr').each(function (index, item) {
|
||||
$(this).find('td').eq(1).html(index + 1);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 校验数据
|
||||
function checkValue(that, type, name) {
|
||||
let value = $(that).val();
|
||||
|
|
|
|||
|
|
@ -174,7 +174,8 @@ function addFitDatas(data) {
|
|||
$.each(newJjDataArr, function (index, item) {
|
||||
updateOrAddObject(item.id, item);
|
||||
});
|
||||
setTableData(jjDataArr);
|
||||
// setTableData(jjDataArr);
|
||||
goOnAddData();
|
||||
} else { // 第一次添加数据
|
||||
jjDataArr = JSON.parse(data);
|
||||
if (jjDataArr && jjDataArr.length > 0) {
|
||||
|
|
@ -289,18 +290,65 @@ function delFitType() {
|
|||
}
|
||||
}
|
||||
}
|
||||
delIdArr.splice(0,delIdArr.length);
|
||||
if (jjDataArr.length === 0) {
|
||||
$('#no_data_title').removeAttr('style');
|
||||
$('#search-info').css({ 'display': 'none' });
|
||||
$('#table-box').css({ 'display': 'none' });
|
||||
} else {
|
||||
setTableData(jjDataArr);
|
||||
// setTableData(jjDataArr);
|
||||
handleDelTableData(delIdArr);
|
||||
}
|
||||
|
||||
delIdArr.splice(0,delIdArr.length);
|
||||
});
|
||||
}
|
||||
|
||||
// 删除表格数据
|
||||
function handleDelTableData(delIdArr) {
|
||||
if (delIdArr.length > 0) {
|
||||
$.each(delIdArr, function (index, item) {
|
||||
$('#baseTable tbody tr').each(function () {
|
||||
let id = $(this).attr('id');
|
||||
if (parseInt(id) === item) {
|
||||
$(this).remove();
|
||||
return false;
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
$('#baseTable tbody tr').each(function (index, item) {
|
||||
$(this).find('td').eq(1).html(index + 1);
|
||||
})
|
||||
}
|
||||
|
||||
// 继续添加数据
|
||||
function goOnAddData() {
|
||||
if (jjDataArr.length > 0) {
|
||||
$.each(jjDataArr, function (index, item) {
|
||||
$('#baseTable tbody tr').each(function () {
|
||||
let id = $(this).attr('id');
|
||||
if (parseInt(id) === parseInt(item.id)) {
|
||||
let times = $(this).find('td').eq(7).find('input[name="times"]').val(),
|
||||
needNum = $(this).find('td').eq(6).find('input[name="needNum"]').val(),
|
||||
remarks = $(this).find('td').eq(8).find('input[name="remarks"]').val();
|
||||
if (!item.times || parseInt(item.times) === 0) {
|
||||
item.times = times;
|
||||
}
|
||||
if (!item.needNum || parseInt(item.needNum) === 0) {
|
||||
item.needNum = needNum;
|
||||
}
|
||||
if (!item.remarks) {
|
||||
item.remarks = remarks;
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
setTableData(jjDataArr);
|
||||
$('#baseTable tbody tr').each(function (index, item) {
|
||||
$(this).find('td').eq(1).html(index + 1);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 校验数据
|
||||
function checkValue(that, type, name) {
|
||||
let value = $(that).val();
|
||||
|
|
|
|||
|
|
@ -276,7 +276,8 @@ function addFitDatas(data) {
|
|||
$.each(newJjDataArr, function (index, item) {
|
||||
updateOrAddObject(item.id, item);
|
||||
});
|
||||
setTableData(jjDataArr);
|
||||
// setTableData(jjDataArr);
|
||||
goOnAddData();
|
||||
} else { // 第一次添加数据
|
||||
jjDataArr = JSON.parse(data);
|
||||
if (jjDataArr && jjDataArr.length > 0) {
|
||||
|
|
@ -324,7 +325,7 @@ function setTableData(results) {
|
|||
html += "</tr>";
|
||||
}
|
||||
} else {
|
||||
html += "<tr><td colspan='12' class='center'>没有相关数据</td></tr>";
|
||||
html += "<tr><td colspan='11' class='center'>没有相关数据</td></tr>";
|
||||
}
|
||||
$("#baseTable tbody").empty().append(html);
|
||||
setNumAndPrice(jjDataArr);
|
||||
|
|
@ -337,8 +338,8 @@ function setNumAndPrice(list) {
|
|||
let inventoryProfit = 0, inventoryDeficit = 0, addPrice = 0; subPrice = 0;
|
||||
$.each(list, function (index, item) {
|
||||
// let price = item.price ? item.price : 2;
|
||||
inventoryProfit += parseInt(item.inventoryProfit);
|
||||
inventoryDeficit += parseInt(item.inventoryDeficit);
|
||||
inventoryProfit += parseInt(item.inventoryProfit ? item.inventoryProfit : 0);
|
||||
inventoryDeficit += parseInt(item.inventoryDeficit? item.inventoryDeficit : 0);
|
||||
// addPrice += parseInt(item.inventoryProfit) * parseFloat(price);
|
||||
// subPrice += parseInt(item.inventoryDeficit) * parseFloat(price);
|
||||
});
|
||||
|
|
@ -411,18 +412,69 @@ function delFitType() {
|
|||
}
|
||||
}
|
||||
}
|
||||
delIdArr.splice(0, delIdArr.length);
|
||||
if (jjDataArr.length === 0) {
|
||||
$('#no_data_title').removeAttr('style');
|
||||
$('#search-info').css({ 'display': 'none' });
|
||||
$('#table-box').css({ 'display': 'none' });
|
||||
} else {
|
||||
setTableData(jjDataArr);
|
||||
// setTableData(jjDataArr);
|
||||
handleDelTableData(delIdArr);
|
||||
}
|
||||
|
||||
delIdArr.splice(0,delIdArr.length);
|
||||
let list = getBaseTableData();
|
||||
setNumAndPrice(list);
|
||||
});
|
||||
let list = getBaseTableData();
|
||||
setNumAndPrice(list);
|
||||
}
|
||||
|
||||
// 删除表格数据
|
||||
function handleDelTableData(delIdArr) {
|
||||
if (delIdArr.length > 0) {
|
||||
$.each(delIdArr, function (index, item) {
|
||||
$('#baseTable tbody tr').each(function () {
|
||||
let id = $(this).attr('id');
|
||||
if (parseInt(id) === item) {
|
||||
$(this).remove();
|
||||
return false;
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
$('#baseTable tbody tr').each(function (index, item) {
|
||||
$(this).find('td').eq(1).html(index + 1);
|
||||
})
|
||||
}
|
||||
|
||||
// 继续添加数据
|
||||
function goOnAddData() {
|
||||
if (jjDataArr.length > 0) {
|
||||
$.each(jjDataArr, function (index, item) {
|
||||
$('#baseTable tbody tr').each(function () {
|
||||
let id = $(this).attr('id');
|
||||
if (parseInt(id) === parseInt(item.id)) {
|
||||
let quantityOfThisInventory = $(this).find('td').eq(7).find('input[name="quantityOfThisInventory"]').val(),
|
||||
inventoryProfit = $(this).find('td').eq(8).html(),
|
||||
inventoryDeficit = $(this).find('td').eq(9).html(),
|
||||
remark = $(this).find('td').eq(10).find('input[name="remark"]').val();
|
||||
if (!item.quantityOfThisInventory || parseInt(item.quantityOfThisInventory) === 0) {
|
||||
item.quantityOfThisInventory = quantityOfThisInventory;
|
||||
}
|
||||
if (!item.inventoryProfit || parseInt(item.inventoryProfit) === 0) {
|
||||
item.inventoryProfit = inventoryProfit;
|
||||
}
|
||||
if (!item.inventoryDeficit || parseInt(item.inventoryDeficit) === 0) {
|
||||
item.inventoryDeficit = inventoryDeficit;
|
||||
}
|
||||
if (!item.remark) {
|
||||
item.remark = remark;
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
setTableData(jjDataArr);
|
||||
$('#baseTable tbody tr').each(function (index, item) {
|
||||
$(this).find('td').eq(1).html(index + 1);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 校验数据
|
||||
|
|
|
|||
|
|
@ -135,6 +135,9 @@ function initTable() {
|
|||
unresize: true,
|
||||
align: "center",
|
||||
sort:true,
|
||||
templet: function (d) {
|
||||
return "<a style='color:#409eff;' onclick='viewPlanDetail(" + JSON.stringify(d) + ")'>" + d.planCode + "</a>";
|
||||
},
|
||||
},
|
||||
{
|
||||
field: "supName",
|
||||
|
|
@ -334,6 +337,14 @@ function saveData2(params) {
|
|||
}
|
||||
}
|
||||
|
||||
// 需求计划详情
|
||||
function viewPlanDetail(obj) {
|
||||
console.error(obj);
|
||||
obj.id = obj.planId,obj.code = obj.planCode;
|
||||
let content = '../../aq_demand_plan/child/apply_plan_detail.html';
|
||||
openIframeByParamObj2("viewPlanDetail4", "需求计划详情", content, "92%", "95%", obj);
|
||||
}
|
||||
|
||||
function closePage(type, params,outIdArr) {
|
||||
let index = parent.layer.getFrameIndex(window.name); // 先得到当前 iframe层的索引
|
||||
if (type == 1) {
|
||||
|
|
|
|||
|
|
@ -268,7 +268,7 @@ function initTable() {
|
|||
},
|
||||
{
|
||||
field: "name",
|
||||
width: '10%',
|
||||
width: '8%',
|
||||
title: "名称",
|
||||
unresize: true,
|
||||
align: "center",
|
||||
|
|
@ -292,7 +292,7 @@ function initTable() {
|
|||
},
|
||||
{
|
||||
field: "price",
|
||||
width: '8%',
|
||||
width: '10%',
|
||||
title: "单价(元)",
|
||||
unresize: true,
|
||||
align: "center",
|
||||
|
|
@ -371,6 +371,14 @@ function initTable() {
|
|||
});
|
||||
}
|
||||
|
||||
// 需求计划详情
|
||||
function openPlanDetail(obj) {
|
||||
console.error(obj);
|
||||
|
||||
obj.id = obj.planId;
|
||||
openIframeByParamObj2("planDetail", "安全工器具需求计划", "../aq_demand_plan/child/apply_plan_detail.html", "92%", "95%", obj);
|
||||
}
|
||||
|
||||
// 关闭页面
|
||||
function closePage(type) {
|
||||
let index = parent.layer.getFrameIndex(window.name); // 先得到当前 iframe层的索引
|
||||
|
|
|
|||
|
|
@ -245,6 +245,7 @@ function initTable() {
|
|||
width: '10%',
|
||||
align: "center",
|
||||
unresize: true,
|
||||
sort:true,
|
||||
templet: function (d) {
|
||||
if (d.remark) {
|
||||
if (d.remark.length > 60) {
|
||||
|
|
@ -263,6 +264,7 @@ function initTable() {
|
|||
width: '10%',
|
||||
align: "center",
|
||||
unresize: true,
|
||||
sort:true,
|
||||
templet: function (d) {
|
||||
let html = "";
|
||||
html += "<a onclick='openPlanDetail(" + JSON.stringify(d) + ")'>" + d.planCode + "</a>";
|
||||
|
|
@ -275,6 +277,7 @@ function initTable() {
|
|||
width: '10%',
|
||||
align: "center",
|
||||
unresize: true,
|
||||
sort:true,
|
||||
},
|
||||
],
|
||||
],
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@
|
|||
<tr>
|
||||
<th colspan="4">计划说明</th>
|
||||
</tr>
|
||||
<tr style="height: 100px;">
|
||||
<tr>
|
||||
<td colspan="4" id="remark"></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
|
|
|||
Loading…
Reference in New Issue