refactor(project): 重构产品列表删除逻辑并优化行业类型选择- 移除产品列表的删除功能

- 解除行业类型选择框的只读限制
- 更新产品列表的索引重置逻辑
- 修正产品选择和显示相关问题
- 优化订单信息保存逻辑,更新项目BG属性和行业类型
master
chenhao 2025-07-02 16:41:42 +08:00
parent 87663d3f4b
commit dc31d20a6c
6 changed files with 131 additions and 94 deletions

View File

@ -98,21 +98,44 @@
const FOLD_ON_FOLD = 0.988;
document.addEventListener("DOMContentLoaded", function () {
// 初始化删除逻辑等
$('.productTable .delRow').on('click', function () {
let ele = $(this);
$.modal.confirm('是否确认删除', function () {
$(ele).parent().parent().remove();
updateIndices();
});
});
// $('.productTable .delRow').on('click', function () {
// let ele = $(this);
// $.modal.confirm('是否确认删除', function () {
// $(ele).parent().parent().remove();
// updateIndices();
// });
// });
function updateIndices() {
$('#productTable tbody tr').each(function (index) {
$(this).find('.indexBox').text(index + 1);
});
}
});
function delProductRow(that){
top.layer.confirm('是否确认删除', {
icon: 3,
id:'delProductRow'+Math.random(),
title: "系统提示",
btn: ['确认', '取消']
}, function (index) {
$.modal.close(index);
$(that).parent().parent().remove();
updateIndices();
});
}
function updateIndices() {
$('.productTable').each(function () {
$(this).find("tbody tr").each(function(index){
$(this).find('.indexBox').text(index + 1);
$(this).find('input, textarea').each(function() {
let name = $(this).attr('name');
if (name && name.includes("ProductInfoList")) {
// 替换名称中的索引值为新的索引
let newName = name.replace(/ProductInfoList\[\d+\]/, 'ProductInfoList[' + index + ']');
$(this).attr('name', newName);
}
});
})
});
}
function setOrderPriceData(){
let allPrice=0.00;
$('#productTable tbody').find('tr').find('.allPrice').each(function (index) {
@ -140,8 +163,8 @@
let tr = $(`
<tr>
<td style="text-align: center;" class="indexBox">${length + 1}</td>
<td> <input type="hidden" name="softwareProjectProductInfoList[${length}].id" value="${data.id || ''}"><input class="form-control productBomCode" type="text" onclick="selectProduct('1','终端产品',this)" value="${data.productBomCode || ''}" name="softwareProjectProductInfoList[${length}].productBomCode"></td>
<td><input readonly class="form-control model" type="text" onclick="selectProduct('1','终端产品',this)" value="${data.model || ''}" name="softwareProjectProductInfoList[${length}].model"></td>
<td> <input type="hidden" name="softwareProjectProductInfoList[${length}].id" value="${data.id || ''}"><input class="form-control productBomCode" type="text" onclick="selectProduct('1','软件产品',this)" value="${data.productBomCode || ''}" name="softwareProjectProductInfoList[${length}].productBomCode"></td>
<td><input readonly class="form-control model" type="text" onclick="selectProduct('1','软件产品',this)" value="${data.model || ''}" name="softwareProjectProductInfoList[${length}].model"></td>
<td><textarea name="softwareProjectProductInfoList[${length}].productDesc" required class="form-control productDesc" placeholder="自动带入" readonly>${data.productDesc || ''}</textarea></td>
<td><input value="${data.quantity || ''}" name="softwareProjectProductInfoList[${length}].quantity" type="number" class="form-control quantity" step="1" required></td>
<td>
@ -169,11 +192,11 @@
<input type="text" value="${data.catalogueAllPriceFormmat || ''}" class="form-control catalogueAllPrice-formmat" placeholder="自动计算" required readonly>
</td>
<td><input value="${data.remark || ''}" name="softwareProjectProductInfoList[${length}].remark" type="text" class="form-control" ></td>
<td><span style="cursor:pointer;color: #ff5722" class="delRow">删除</span></td>
<td><span style="cursor:pointer;color: #ff5722" onclick="delProductRow(this)" class="delRow">删除</span></td>
</tr>`)
$('#productTable tbody').append(tr)
initSearchProduct('1')
// initSearchProduct('1')
initPrice()
}
@ -186,8 +209,8 @@
let tr = $(`
<tr>
<td style="text-align: center;" class="indexBox">${length + 1}</td>
<td> <input type="hidden" name="hardwareProjectProductInfoList[${length}].id" value="${data.id || ''}"><input class="form-control productBomCode" type="text" onclick="selectProduct('2','软件产品',this)" value="${data.productBomCode || ''}" name="hardwareProjectProductInfoList[${length}].productBomCode"></td>
<td><input readonly class="form-control model" type="text" onclick="selectProduct('2','软件产品',this)" value="${data.model || ''}" name="hardwareProjectProductInfoList[${length}].model"></td>
<td> <input type="hidden" name="hardwareProjectProductInfoList[${length}].id" value="${data.id || ''}"><input class="form-control productBomCode" type="text" onclick="selectProduct('2','终端产品',this)" value="${data.productBomCode || ''}" name="hardwareProjectProductInfoList[${length}].productBomCode"></td>
<td><input readonly class="form-control model" type="text" onclick="selectProduct('2','终端产品',this)" value="${data.model || ''}" name="hardwareProjectProductInfoList[${length}].model"></td>
<td><textarea name="hardwareProjectProductInfoList[${length}].productDesc" required class="form-control productDesc" placeholder="自动带入" readonly>${data.productDesc || ''}</textarea></td>
<td><input value="${data.quantity || ''}" name="hardwareProjectProductInfoList[${length}].quantity" type="number" class="form-control quantity" step="1" required></td>
<td>
@ -215,11 +238,11 @@
<input type="text" value="${data.catalogueAllPriceFormmat || ''}" class="form-control catalogueAllPrice-formmat" placeholder="自动计算" required readonly>
</td>
<td><input value="${data.remark || ''}" name="hardwareProjectProductInfoList[${length}].remark" type="text" class="form-control" ></td>
<td><span style="cursor:pointer;color: #ff5722" class="delRow">删除</span></td>
<td><span style="cursor:pointer;color: #ff5722" onclick="delProductRow(this)" class="delRow">删除</span></td>
</tr>`)
$('#productTable2 tbody').append(tr)
initSearchProduct('2')
// initSearchProduct('2')
initPrice()
}
@ -264,11 +287,11 @@
<input type="text" value="${data.catalogueAllPriceFormmat || ''}" class="form-control catalogueAllPrice-formmat" placeholder="自动计算" required readonly>
</td>
<td><input value="${data.remark || ''}" name="maintenanceProjectProductInfoList[${length}].remark" type="text" class="form-control" ></td>
<td><span style="cursor:pointer;color: #ff5722" class="delRow">删除</span></td>
<td><span style="cursor:pointer;color: #ff5722" onclick="delProductRow(this)" class="delRow">删除</span></td>
</tr>`)
$('#productTable3 tbody').append(tr)
initSearchProduct('11,22,99')
// initSearchProduct('11,22,99')
initPrice()
}
function getData(that,name){

View File

@ -540,22 +540,22 @@
}
function initSearchProduct(type) {
$('.productTable .delRow').on('click', function () {
let ele = $(this)
$.modal.confirm('是否确认删除', function () {
$(ele).parent().parent().remove()
$('#productTable tbody tr').each((index, item) => {
$(item).find('.indexBox').text(index + 1)
})
$('#productTable2 tbody tr').each((index, item) => {
$(item).find('.indexBox').text(index + 1)
})
$('#productTable3 tbody tr').each((index, item) => {
$(item).find('.indexBox').text(index + 1)
})
});
})
// $('.productTable .delRow').on('click', function () {
// let ele = $(this)
// $.modal.confirm('是否确认删除', function () {
// $(ele).parent().parent().remove()
// $('#productTable tbody tr').each((index, item) => {
// $(item).find('.indexBox').text(index + 1)
// })
// $('#productTable2 tbody tr').each((index, item) => {
// $(item).find('.indexBox').text(index + 1)
// })
// $('#productTable3 tbody tr').each((index, item) => {
// $(item).find('.indexBox').text(index + 1)
// })
//
// });
// })
}

View File

@ -616,22 +616,22 @@
}
function initSearchProduct(type) {
$('.productTable .delRow').on('click', function () {
let ele = $(this)
$.modal.confirm('是否确认删除', function () {
$(ele).parent().parent().remove()
$('#productTable tbody tr').each((index, item) => {
$(item).find('.indexBox').text(index + 1)
})
$('#productTable2 tbody tr').each((index, item) => {
$(item).find('.indexBox').text(index + 1)
})
$('#productTable3 tbody tr').each((index, item) => {
$(item).find('.indexBox').text(index + 1)
})
});
})
// $('.productTable .delRow').on('click', function () {
// let ele = $(this)
// $.modal.confirm('是否确认删除', function () {
// $(ele).parent().parent().remove()
// $('#productTable tbody tr').each((index, item) => {
// $(item).find('.indexBox').text(index + 1)
// })
// $('#productTable2 tbody tr').each((index, item) => {
// $(item).find('.indexBox').text(index + 1)
// })
// $('#productTable3 tbody tr').each((index, item) => {
// $(item).find('.indexBox').text(index + 1)
// })
//
// });
// })
}

View File

@ -637,22 +637,22 @@
}
function initSearchProduct() {
$('.productTable .delRow').on('click', function () {
let ele = $(this)
$.modal.confirm('是否确认删除', function () {
$(ele).parent().parent().remove()
$('#productTable tbody tr').each((index, item) => {
$(item).find('.indexBox').text(index + 1)
})
$('#productTable2 tbody tr').each((index, item) => {
$(item).find('.indexBox').text(index + 1)
})
$('#productTable3 tbody tr').each((index, item) => {
$(item).find('.indexBox').text(index + 1)
})
});
})
// $('.productTable .delRow').on('click', function () {
// let ele = $(this)
// $.modal.confirm('是否确认删除', function () {
// $(ele).parent().parent().remove()
// $('#productTable tbody tr').each((index, item) => {
// $(item).find('.indexBox').text(index + 1)
// })
// $('#productTable2 tbody tr').each((index, item) => {
// $(item).find('.indexBox').text(index + 1)
// })
// $('#productTable3 tbody tr').each((index, item) => {
// $(item).find('.indexBox').text(index + 1)
// })
//
// });
// })
}

View File

@ -73,9 +73,9 @@
position: relative;
}
[name="bgProperty"], #industryTypeBox select {
pointer-events: none;
}
/*[name="bgProperty"], #industryTypeBox select {*/
/* pointer-events: none;*/
/*}*/
#projectNameBox {
margin-left: 20px;
@ -139,8 +139,8 @@
<td>BG<span class="is-required">*</span></td>
<td>
<select name="bgProperty" class="form-control" th:field="*{bgProperty}"
th:with="type=${@dict.getType('bg_type')}"
readonly required>
th:with="type=${@dict.getType('bg_type')}" onchange="changeBg()"
required>
<option value="">请选择BG</option>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}"
th:value="${dict.dictValue}"></option>
@ -149,7 +149,7 @@
<td>行业<span class="is-required">*</span></td>
<td id="industryTypeBox">
<select name="industryType" class="form-control"
required readonly>
required >
<option value="">请先选择BG</option>
</select>
</td>
@ -673,22 +673,22 @@
}
function initSearchProduct() {
$('.productTable .delRow').on('click', function () {
let ele = $(this)
$.modal.confirm('是否确认删除', function () {
$(ele).parent().parent().remove()
$('#productTable tbody tr').each((index, item) => {
$(item).find('.indexBox').text(index + 1)
})
$('#productTable2 tbody tr').each((index, item) => {
$(item).find('.indexBox').text(index + 1)
})
$('#productTable3 tbody tr').each((index, item) => {
$(item).find('.indexBox').text(index + 1)
})
});
})
// $('.productTable .delRow').on('click', function () {
// let ele = $(this)
// $.modal.confirm('是否确认删除', function () {
// $(ele).parent().parent().remove()
// $('#productTable tbody tr').each((index, item) => {
// $(item).find('.indexBox').text(index + 1)
// })
// $('#productTable2 tbody tr').each((index, item) => {
// $(item).find('.indexBox').text(index + 1)
// })
// $('#productTable3 tbody tr').each((index, item) => {
// $(item).find('.indexBox').text(index + 1)
// })
//
// });
// })
}
@ -701,7 +701,7 @@
str += `<option value="${ele.dictValue}">${ele.dictLabel}</option> `
})
$('#industryTypeBox').html(`
<select name="industryType" class="form-control" readonly required>
<select name="industryType" class="form-control" required>
<option value="">请选择行业</option>
${str}
</select>
@ -713,7 +713,7 @@
str += `<option value="${ele.dictValue}">${ele.dictLabel}</option> `
})
$('#industryTypeBox').html(`
<select name="industryType" class="form-control" required readonly>
<select name="industryType" class="form-control" required >
<option value="">请选择行业</option>
${str}
</select>

View File

@ -29,6 +29,7 @@ import com.ruoyi.sip.domain.*;
import com.ruoyi.sip.dto.HomepageQueryDto;
import com.ruoyi.sip.dto.OrderExcelNumStaticsDto;
import com.ruoyi.sip.dto.StatisticsDetailDto;
import com.ruoyi.sip.mapper.ProjectInfoMapper;
import com.ruoyi.sip.service.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.*;
@ -37,6 +38,8 @@ import org.springframework.stereotype.Service;
import com.ruoyi.sip.mapper.ProjectOrderInfoMapper;
import com.ruoyi.common.core.text.Convert;
import javax.annotation.Resource;
import static com.ruoyi.sip.service.impl.ProjectInfoServiceImpl.INDUSTRY_TYPE_DICT_TYPE;
import static com.ruoyi.sip.service.impl.ProjectInfoServiceImpl.INDUSTRY_TYPE_YYS_DICT_TYPE;
@ -58,6 +61,8 @@ public class ProjectOrderInfoServiceImpl implements IProjectOrderInfoService {
private IProjectProductInfoService productInfoService;
@Autowired
private ICnareaService cnareaService;
@Resource
private ProjectInfoMapper projectInfoMapper;
private static final List<String> MAINTENANCE_SERVICES = Arrays.asList("8813A3YA", "8813A3YB", "8813A7U4", "8813A7U2");
private static final List<String> DEPLOY_SERVICES = Arrays.asList("8814A0BT");
@ -210,6 +215,15 @@ public class ProjectOrderInfoServiceImpl implements IProjectOrderInfoService {
// String orderNumber = generateOrderNumber(projectOrderInfo.getProjectId());
// projectOrderInfo.setOrderCode(orderNumber);
// }
//更新BG属性
ProjectInfo projectInfo = new ProjectInfo();
projectInfo.setId(projectOrderInfo.getProjectId());
projectInfo.setBgProperty(projectOrderInfo.getBgProperty());
projectInfo.setIndustryType(projectOrderInfo.getIndustryType());
projectInfo.setUpdateBy(ShiroUtils.getUserId().toString());
projectInfo.setUpdateTime(DateUtils.getNowDate());
projectInfoMapper.updateProjectInfo(projectInfo);
//不更新订单编号
projectOrderInfo.setOrderCode(null);
projectOrderInfo.setUpdateBy(ShiroUtils.getUserId().toString());