Browse Source

[fix]

工程管理 物料信息
修改erp物料实体类,新增委外工序列表字段;
修改添加erp物料页面,新增委外工序表格及相关选择去重回调方法;
修改页面提交函数,拼接为对象发送后台;
修改编辑erp物料页面,补全必填字段,新增委外工序表格定义及相关选择页面跳转、去重回调、插入和删除方法;
修改页面提交函数,拼接主子表信息发送后台;
修改erp物料详情页面,新增加工方法为委外加工时委外工序表格的显示;
修改erp物料controller,新增按料号查询委外物料工序列表接口;
修改erp物料新增和编辑service接口,新增关于委外加工下委外工序的保存;
新增根据erp物料生成委外物料service方法;
dev
王晓迪 2 months ago
parent
commit
626f8ddd7f
  1. 26
      ruoyi-admin/src/main/java/com/ruoyi/erp/controller/ErpMaterialController.java
  2. 12
      ruoyi-admin/src/main/java/com/ruoyi/erp/domain/ErpMaterial.java
  3. 56
      ruoyi-admin/src/main/java/com/ruoyi/erp/service/impl/ErpMaterialServiceImpl.java
  4. 174
      ruoyi-admin/src/main/resources/templates/erp/material/add.html
  5. 63
      ruoyi-admin/src/main/resources/templates/erp/material/detail.html
  6. 225
      ruoyi-admin/src/main/resources/templates/erp/material/edit.html

26
ruoyi-admin/src/main/java/com/ruoyi/erp/controller/ErpMaterialController.java

@ -9,6 +9,7 @@ import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.erp.domain.ErpBom;
import com.ruoyi.erp.domain.ErpMaterial;
import com.ruoyi.erp.domain.ErpMaterialVo;
import com.ruoyi.erp.domain.vo.ErpMaterialPurchaseHistoryVo;
@ -16,10 +17,8 @@ import com.ruoyi.erp.domain.vo.ErpMaterialSalesHistoryVo;
import com.ruoyi.erp.mapper.ErpMaterialMapper;
import com.ruoyi.erp.service.IErpMaterialService;
import com.ruoyi.process.general.service.IProcessService;
import com.ruoyi.system.domain.SysCustomer;
import com.ruoyi.system.domain.SysCustomerOper;
import com.ruoyi.system.domain.SysErpMaterialSysTechnicalTeam;
import com.ruoyi.system.domain.SysPost;
import com.ruoyi.system.domain.*;
import com.ruoyi.system.mapper.OutsourceMaterialMapper;
import com.ruoyi.system.service.*;
import com.ruoyi.warehouse.controller.WarehouseInventoryInquiryController;
import com.ruoyi.warehouse.service.IWarehouseInventoryInquiryService;
@ -73,6 +72,10 @@ public class ErpMaterialController extends BaseController
@Autowired
private ErpMaterialMapper erpMaterialMapper;
@Autowired
private OutsourceMaterialMapper outsourceMaterialMapper;
@Autowired
private ISysUserService sysUserService;
@ -162,7 +165,7 @@ public class ErpMaterialController extends BaseController
@Log(title = "物料信息", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(ErpMaterial erpMaterial)
public AjaxResult addSave(@RequestBody ErpMaterial erpMaterial)
{
SysUser sysUser = ShiroUtils.getSysUser();
List<SysPost> sysPostsList = sysPostService.selectPostsByUserId(sysUser.getUserId());
@ -301,7 +304,7 @@ public class ErpMaterialController extends BaseController
@Log(title = "物料信息", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(ErpMaterial erpMaterial)
public AjaxResult editSave(@RequestBody ErpMaterial erpMaterial)
{
SysUser sysUser = ShiroUtils.getSysUser();
List<SysPost> sysPostsList = sysPostService.selectPostsByUserId(sysUser.getUserId());
@ -537,4 +540,15 @@ public class ErpMaterialController extends BaseController
return getDataTable(list);
}
/**
* 查询bom一阶列表
*/
@PostMapping("/processList")
@ResponseBody
public TableDataInfo oneLevelList(OutsourceMaterial outsourceMaterial)
{
startPage();
List<OutsourceMaterial> list = outsourceMaterialMapper.selectOutsourceMaterialList(outsourceMaterial);
return getDataTable(list);
}
}

12
ruoyi-admin/src/main/java/com/ruoyi/erp/domain/ErpMaterial.java

@ -2,6 +2,7 @@ package com.ruoyi.erp.domain;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.system.domain.OutsourceProcess;
import com.ruoyi.system.domain.SysTechnicalTeam;
import org.apache.commons.lang.builder.ToStringBuilder;
@ -132,6 +133,9 @@ public class ErpMaterial extends BaseEntity
}
private List<SysTechnicalTeam> technicalTeams;
private List<OutsourceProcess> processList;
public void setId(Long id)
{
this.id = id;
@ -436,6 +440,14 @@ public class ErpMaterial extends BaseEntity
this.bomId = bomId;
}
public List<OutsourceProcess> getProcessList() {
return processList;
}
public void setProcessList(List<OutsourceProcess> processList) {
this.processList = processList;
}
@Override
public String toString() {
return new ToStringBuilder(this)

56
ruoyi-admin/src/main/java/com/ruoyi/erp/service/impl/ErpMaterialServiceImpl.java

@ -5,6 +5,7 @@ import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.page.PageDomain;
import com.ruoyi.common.core.page.TableSupport;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.exception.BusinessException;
import com.ruoyi.common.service.ICommonService;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ShiroUtils;
@ -24,6 +25,7 @@ import com.ruoyi.purchase.mapper.PurchaseOrderMapper;
import com.ruoyi.purchase.mapper.PurchasePlanChildMapper;
import com.ruoyi.system.domain.*;
import com.ruoyi.system.domain.Vo.ExportCustomerQuoteChildVo;
import com.ruoyi.system.mapper.OutsourceMaterialMapper;
import com.ruoyi.system.mapper.SysSalesOrderChildMapper;
import com.ruoyi.system.mapper.SysSalesOrderMapper;
import com.ruoyi.system.mapper.SysUserMapper;
@ -101,6 +103,9 @@ public class ErpMaterialServiceImpl implements IErpMaterialService
@Autowired
private ISysCustomerOperService sysCustomerOperService;
@Autowired
private OutsourceMaterialMapper outsourceMaterialMapper;
private final static String RMB = "1"; //RMB
/**
@ -247,9 +252,36 @@ public class ErpMaterialServiceImpl implements IErpMaterialService
List<String> fileIdList = Arrays.asList(fileIdStr.split(";"));
attachFileService.updateAttachIdByIdList(attachId,fileIdList);
}
if(erpMaterial.getProcessMethod().equals("2")){
OutsourceMaterial outsourceMaterial = createOutsourceMaterial(erpMaterial);
List<OutsourceProcess> processes = erpMaterial.getProcessList();
if(processes.size()<=0){
throw new BusinessException("委外物料工序列表为空!");
}
int insertResult = 0;
for (OutsourceProcess process: processes) {
outsourceMaterial.setOutsourceProcessNo(process.getOutsourceProcessNo());
outsourceMaterial.setOutsourceProcessName(process.getOutsourceProcessName());
insertResult += outsourceMaterialMapper.insertOutsourceMaterial(outsourceMaterial);
}
if(insertResult<=0){
throw new BusinessException("插入委外物料信息失败!");
}
}
return result;
}
// 根据物料信息生成委外物料对象
public OutsourceMaterial createOutsourceMaterial(ErpMaterial erpMaterial){
OutsourceMaterial outMaterial = new OutsourceMaterial();
outMaterial.setMaterialNo(erpMaterial.getMaterialNo());
outMaterial.setMaterialName(erpMaterial.getMaterialName());
outMaterial.setMaterialType(erpMaterial.getMaterialType());
outMaterial.setProcessMethod(erpMaterial.getProcessMethod());
outMaterial.setUnit(erpMaterial.getUnit());
outMaterial.setBrand(erpMaterial.getBrand());
outMaterial.setDescription(erpMaterial.getDescribe());
return outMaterial;
}
/**
* 修改物料信息
*
@ -283,7 +315,25 @@ public class ErpMaterialServiceImpl implements IErpMaterialService
}
attachFileService.updateAttachIdByIdList(photoAttachId, fileIdList);
}
return erpMaterialMapper.updateErpMaterial(erpMaterial);
int updateResult = erpMaterialMapper.updateErpMaterial(erpMaterial);
if(erpMaterial.getProcessMethod().equals("2")){
List<OutsourceProcess> processes = erpMaterial.getProcessList();
if(processes.size()<=0){
throw new BusinessException("委外物料工序列表为空!");
}
outsourceMaterialMapper.deleteOutsourceMaterialByNo(erpMaterial.getMaterialNo());
OutsourceMaterial outsourceMaterial = createOutsourceMaterial(erpMaterial);
int insertResult = 0;
for (OutsourceProcess process: processes) {
outsourceMaterial.setOutsourceProcessNo(process.getOutsourceProcessNo());
outsourceMaterial.setOutsourceProcessName(process.getOutsourceProcessName());
insertResult += outsourceMaterialMapper.insertOutsourceMaterial(outsourceMaterial);
}
if(insertResult<=0){
throw new BusinessException("插入委外物料信息失败!");
}
}
return updateResult;
}
/**
@ -362,6 +412,8 @@ public class ErpMaterialServiceImpl implements IErpMaterialService
erpMaterial.setApplyTime(DateUtils.getNowDate());
if(erpMaterial.getId() == null){
insertErpMaterial(erpMaterial);
}else{
updateErpMaterial(erpMaterial);
}
// 启动流程
String applyTitle = user.getUserName()+"发起了物料信息提交审批-"+DateUtils.dateTimeNow();

174
ruoyi-admin/src/main/resources/templates/erp/material/add.html

@ -37,13 +37,6 @@
<select name="processMethod" class="form-control m-b" th:with="type=${@dict.getType('processMethod')}" required>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
<div id="add-weiwai">
<label class="col-sm-3 control-label">委外工序:</label>
<div class="col-sm-8">
<a class="btn btn-primary" onclick="insertRowWai()">添加委外工序</a>
</div>
<table class="bootstrap-table-sub-2"></table>
</div>
</div>
</div>
<div class="form-group">
@ -81,8 +74,11 @@
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">照片:</label>
<div class="col-sm-10">
</div>
<div class="form-group">
<label class="col-sm-3 control-label">照片:</label>
<div class="col-sm-9">
<el-upload
:action="fileUploadUrl"
:on-success="uploadSuccess"
@ -100,6 +96,17 @@
</div>
<input id="fileIdStr" type="text" name="fileIdStr" hidden>
</div>
<div class="form-group" id="add-process-text" style="margin-bottom: 0px">
<label class="col-sm-3 control-label is-required">委外工序:</label>
<div class="col-sm-8">
<a class="btn btn-success" onclick="insertRowWai()" ><i class="fa fa-plus"></i> 添加委外工序</a>
</div>
<div class="col-xs-10" id="add-process" style="margin-left: 80px;">
<div class="col-sm-10 select-table table-striped">
<table id="bootstrap-table-process"></table>
</div>
</div>
</div>
</form>
</div>
<th:block th:include="include :: footer" />
@ -172,9 +179,53 @@
var loginName = [[${@permission.getPrincipalProperty('loginName')}]];
//获取工程员
$(function(){
var options = {
id: "bootstrap-table-process",
pagination: false,
showSearch: false,
showRefresh: false,
showToggle: false,
showColumns: false,
striped: false,
sidePagination: "client",
columns: [
{
field: 'outsourceProcessId',
align: 'center',
title: '委外工序主键',
visible: false,
},
{
field: 'outsourceProcessCode',
align: 'center',
title: '委外工序ID',
visible: false,
},
{
field: 'outsourceProcessNo',
align: 'center',
title: '委外工序编号',
},
{
field: 'outsourceProcessName',
align: 'center',
title: '委外工序名称',
},
{
title: '操作',
align: 'center',
formatter: function (value, row, index) {
var actions = [];
actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="removeRow(\'' + row.outsourceProcessNo + '\')"><i class="fa fa-remove"></i>删除</a> ');
return actions.join('');
}
}]
};
$.table.init(options);
$("#businessMembers_add").val(loginName);
engineer();
$("#add-weiwai").hide();
$("#add-process-text").hide();
$("#add-process").hide();
})
function engineer(){
@ -253,22 +304,107 @@
$("#selectWarehouseDept").removeAttr("disabled");
var materialType = $('#selectMaterialType').select2('val');
$('#materialType').val(materialType);
$.operate.save(prefix + "/add", $('#form-material-add').serialize());
// console.log($('#form-material-add').serialize());
// 获取表单数据
const erpMaterialData = $("#form-material-add").serializeArray().reduce((obj, item) => {
obj[item.name] = item.value;
return obj;
}, {});
var erpMaterial = {
materialNo: erpMaterialData.materialNo,
materialName: erpMaterialData.materialName,
materialType: erpMaterialData.materialType,
processMethod: erpMaterialData.processMethod,
unit: erpMaterialData.unit,
brand: erpMaterialData.brand,
describe: erpMaterialData.describe,
warehouseDept: erpMaterialData.warehouseDept,
businessMembers: erpMaterialData.businessMembers,
fileIdStr: erpMaterialData.fileIdStr,
processList:[]
}
if(erpMaterialData.processMethod === "2"){
var processDatas = $("#bootstrap-table-process").bootstrapTable('getData');
if(processDatas.length === 0){
$.modal.alertWarning("请至少添加一条委外工序再保存!");
return;
}else{
for(var i = 0; i<processDatas.length; i++){
var process = {
outsourceProcessNo: processDatas[i].outsourceProcessNo,
outsourceProcessName: processDatas[i].outsourceProcessName,
}
erpMaterial.processList.push(process);
}
}
}
console.log(erpMaterial);
$.operate.saveJson(prefix + "/add", JSON.stringify(erpMaterial));
}
}
function insertRowWai() {
var html = '<tr>' +
'<td><input type="text" name="weiwai" class="form-control" required></td>' +
'<td><a class="btn btn-danger" onclick="removeRowWai(this)">删除</a></td>' +
'</tr>';
$(".bootstrap-table-sub-2").append(html);
// var html = '<tr>' +
// '<td><input type="text" name="weiwai" class="form-control" required></td>' +
// '<td><a class="btn btn-danger" onclick="removeRowWai(this)">删除</a></td>' +
// '</tr>';
// $(".bootstrap-table-sub-2").append(html);
var url = "/system/outsource_quote/processadd";
var options = {
title: '选择委外工序',
height: "500",
url: url,
callBack: doSubmit
};
$.modal.openOptions(options);
}
// 插入工序信息
function insertTable(rowData) {
var newRow = {
outsourceProcessNo: rowData.outsourceProcessNo,
// outsourceProcessCode: rowData.outsourceProcessCode,
outsourceProcessName: rowData.outsourceProcessName,
};
// 将新行追加到表格末尾
$("#bootstrap-table-process").bootstrapTable('append', newRow);
}
/* 选择委外工序回调 */
function doSubmit(index, layero){
// // 这里取到的是多行的
var rowData = layero.find("iframe")[0].contentWindow.getSelections();
//判断是否重复
var data = $("#bootstrap-table-process").bootstrapTable('getData');
var rows = data.length;
if(rows>0){
for(var i=0;i<rows;i++){
for(var j=0;j<rowData.length;j++){
if(data[i].outsourceProcessNo===rowData[j].outsourceProcessNo){
$.modal.alertError("不能选择已添加过的相同工序");
rowData.split(j,1);
break;
}
}
};
}
for(i=0;i<rowData.length;i++){
insertTable(rowData[i]);
}
layer.close(index);
}
function removeRow(outsourceProcessNo){
$("#bootstrap-table-process").bootstrapTable('remove', {
field: 'outsourceProcessNo',
values: outsourceProcessNo
})
}
$("select[name='processMethod']").on("select2:select", function (e) {
data = e.params.data;
if (data.dictLabel == '委外加工') {
$("#add-weiwai").show();
// console.log(data);
if (data.text == '委外加工') {
$("#add-process-text").show();
$("#add-process").show();
} else {
$("#add-weiwai").hide();
$("#add-process-text").hide();
$("#add-process").hide();
}
});

63
ruoyi-admin/src/main/resources/templates/erp/material/detail.html

@ -76,6 +76,9 @@
<div class="col-sm-8">
<input name="businessMembers" th:field="*{businessMembers}" id="businessMembers_edit" class="form-control m-b" disabled required >
</div>
</div>
<div class="form-group">
</div>
<div class="form-group">
<label class="col-sm-3 control-label" >照片:</label>
@ -96,6 +99,14 @@
<input id="fileIdStr" readonly type="text" name="fileIdStr" th:field="*{fileIdStr}" hidden>
<input id="removeFileIdStr" readonly type="text" name="removeFileIdStr" hidden>
</div>
<div class="form-group" id="add-process-text">
<label class="col-sm-3 control-label is-required">委外工序:</label>
<div class="col-xs-10" id="add-process" style="margin-left: 80px;">
<div class="col-sm-10 select-table table-striped">
<table id="bootstrap-table-process"></table>
</div>
</div>
</div>
</form>
<div class="addressList sh">
<div class="col-sm-12 select-table table-striped">
@ -129,7 +140,7 @@
<script th:inline="javascript">
var commonCurrencyDatas = [[${@dict.getType('sys_common_currency')}]];
var erpMaterial = [[${erpMaterial}]]
new Vue({
el: '#app',
data: function() {
@ -236,6 +247,56 @@
})
var prefix = ctx + "erp/material";
$(function(){
var materialNo = erpMaterial.materialNo;
var optionProcess = {
id: "bootstrap-table-process",
url: prefix + "/processList",
method: 'post',
contentType: "application/x-www-form-urlencoded",
queryParams : {
materialNo: materialNo
},
pagination: false,
showSearch: false,
showRefresh: false,
showToggle: false,
showColumns: false,
striped: false,
sidePagination: "client",
columns: [
{
field: 'outsourceProcessId',
align: 'center',
title: '委外工序主键',
visible: false,
},
{
field: 'outsourceProcessCode',
align: 'center',
title: '委外工序ID',
visible: false,
},
{
field: 'outsourceProcessNo',
align: 'center',
title: '委外工序编号',
},
{
field: 'outsourceProcessName',
align: 'center',
title: '委外工序名称',
},
]
};
$.table.init(optionProcess);
if (erpMaterial.processMethod === "2") {
$("#add-process-text").show();
$("#add-process").show();
} else {
$("#add-process-text").hide();
$("#add-process").hide();
}
var materialType = $("#materialType").val();
$("#selectMaterialType").val(materialType).trigger("change");
var id = $("#id").val();

225
ruoyi-admin/src/main/resources/templates/erp/material/edit.html

@ -72,13 +72,15 @@
<div class="form-group">
<label class="col-sm-3 control-label is-required">工程员:</label>
<div class="col-sm-8">
<select name="businessMembers" id="businessMembers_edit" class="form-control m-b" disabled required >
</select>
<input name="businessMembers" th:field="*{businessMembers}" id="businessMembers_edit" class="form-control m-b" disabled required >
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">照片:</label>
<div class="col-sm-10">
</div>
<div class="form-group">
<label class="col-sm-3 control-label">照片:</label>
<div class="col-sm-9">
<el-upload
:action="fileUploadUrl"
:on-success="uploadSuccess"
@ -96,6 +98,17 @@
<input id="photoAttachId" name = "photoAttachId" hidden th:field="*{photoAttachId}" />
<input id="removeFileIdStr" type="text" name="removeFileIdStr" hidden />
</div>
<div class="form-group" id="add-process-text">
<label class="col-sm-3 control-label is-required">委外工序:</label>
<div class="col-sm-8">
<a class="btn btn-success" onclick="insertRowWai()" ><i class="fa fa-plus"></i> 添加委外工序</a>
</div>
<div class="col-xs-10" id="add-process" style="margin-left: 80px;">
<div class="col-sm-10 select-table table-striped">
<table id="bootstrap-table-process"></table>
</div>
</div>
</div>
</form>
</div>
<th:block th:include="include :: footer" />
@ -127,9 +140,9 @@
var that = this;
// 页面渲染完成,可以执行需要的操作
console.log('页面已渲染完成');
console.log($("#id").val());
console.log($("#photoAttachId").val());
// console.log('页面已渲染完成');
// console.log($("#id").val());
// console.log($("#photoAttachId").val());
var attachId = $("#photoAttachId").val();
if(attachId){
$.ajax({
@ -244,37 +257,197 @@
focusCleanup: true
});
$(function(){
var materialNo = erpMaterial.materialNo;
var options = {
id: "bootstrap-table-process",
url: prefix + "/processList",
method: 'post',
contentType: "application/x-www-form-urlencoded",
queryParams : {
materialNo: materialNo
},
pagination: false,
showSearch: false,
showRefresh: false,
showToggle: false,
showColumns: false,
striped: false,
sidePagination: "client",
columns: [
{
field: 'outsourceProcessId',
align: 'center',
title: '委外工序主键',
visible: false,
},
{
field: 'outsourceProcessCode',
align: 'center',
title: '委外工序ID',
visible: false,
},
{
field: 'outsourceProcessNo',
align: 'center',
title: '委外工序编号',
},
{
field: 'outsourceProcessName',
align: 'center',
title: '委外工序名称',
},
{
title: '操作',
align: 'center',
formatter: function (value, row, index) {
var actions = [];
actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="removeRow(\'' + row.outsourceProcessNo + '\')"><i class="fa fa-remove"></i>删除</a> ');
return actions.join('');
}
}]
};
$.table.init(options);
var materialType = $("#materialType").val();
$("#selectMaterialType").val(materialType);
engineer();
// engineer();
if (erpMaterial.processMethod === "2") {
$("#add-process-text").show();
$("#add-process").show();
} else {
$("#add-process-text").hide();
$("#add-process").hide();
}
})
//获取工程员
function engineer() {
var engineerSelect = $("#form-material-edit select[name='businessMembers']");
$.ajax({
url: ctx + 'erp/material/getEngineerList',
type: 'get',
success: function (res) {
if (res.rows.length > 0) {
var usertData = res.rows;
for (let i in usertData) {
engineerSelect.append(
"<option value='" + usertData[i].loginName + "'>" + usertData[i].userName + "</option>");
// function engineer() {
// var engineerSelect = $("#form-material-edit select[name='businessMembers']");
// $.ajax({
// url: ctx + 'erp/material/getEngineerList',
// type: 'get',
// success: function (res) {
// if (res.rows.length > 0) {
// var usertData = res.rows;
// for (let i in usertData) {
// engineerSelect.append(
// "<option value='" + usertData[i].loginName + "'>" + usertData[i].userName + "</option>");
// }
// engineerSelect.val(loginName);
// } else {
// $.modal.msgError(res.msg);
// }
// }
// });
// }
function insertRowWai() {
// var html = '<tr>' +
// '<td><input type="text" name="weiwai" class="form-control" required></td>' +
// '<td><a class="btn btn-danger" onclick="removeRowWai(this)">删除</a></td>' +
// '</tr>';
// $(".bootstrap-table-sub-2").append(html);
var url = "/system/outsource_quote/processadd";
var options = {
title: '选择委外工序',
height: "500",
url: url,
callBack: doSubmit
};
$.modal.openOptions(options);
}
// 插入工序信息
function insertTable(rowData) {
var newRow = {
outsourceProcessNo: rowData.outsourceProcessNo,
// outsourceProcessCode: rowData.outsourceProcessCode,
outsourceProcessName: rowData.outsourceProcessName,
};
// 将新行追加到表格末尾
$("#bootstrap-table-process").bootstrapTable('append', newRow);
}
/* 选择委外工序回调 */
function doSubmit(index, layero){
// // 这里取到的是多行的
var rowData = layero.find("iframe")[0].contentWindow.getSelections();
//判断是否重复
var data = $("#bootstrap-table-process").bootstrapTable('getData');
var rows = data.length;
if(rows>0){
for(var i=0;i<rows;i++){
for(var j=0;j<rowData.length;j++){
if(data[i].outsourceProcessNo===rowData[j].outsourceProcessNo){
$.modal.alertError("不能选择已添加过的相同工序");
rowData.split(j,1);
break;
}
engineerSelect.val(loginName);
} else {
$.modal.msgError(res.msg);
}
}
});
};
}
for(i=0;i<rowData.length;i++){
insertTable(rowData[i]);
}
layer.close(index);
}
//获取供应商
function removeRow(outsourceProcessNo){
$("#bootstrap-table-process").bootstrapTable('remove', {
field: 'outsourceProcessNo',
values: outsourceProcessNo
})
}
$("select[name='processMethod']").on("select2:select", function (e) {
data = e.params.data;
// console.log(data);
if (data.text == '委外加工') {
$("#add-process-text").show();
$("#add-process").show();
} else {
$("#add-process-text").hide();
$("#add-process").hide();
}
});
function submitHandler() {
if ($.validate.form()) {
$("#businessMembers_edit").removeAttr("disabled");
$("input[name='materialNo']").removeAttr("disabled");
$("input[name='materialName']").removeAttr("disabled");
var materialType = $('#selectMaterialType').select2('val');
$('#materialType').val(materialType);
$.operate.save(prefix + "/edit", $('#form-material-edit').serialize());
// 获取表单数据
const erpMaterialData = $("#form-material-edit").serializeArray().reduce((obj, item) => {
obj[item.name] = item.value;
return obj;
}, {});
var erpMaterial = {
id: erpMaterialData.id,
materialNo: erpMaterialData.materialNo,
materialName: erpMaterialData.materialName,
materialType: erpMaterialData.materialType,
processMethod: erpMaterialData.processMethod,
unit: erpMaterialData.unit,
brand: erpMaterialData.brand,
describe: erpMaterialData.describe,
warehouseDept: erpMaterialData.warehouseDept,
businessMembers: erpMaterialData.businessMembers,
fileIdStr: erpMaterialData.fileIdStr,
processList:[]
}
if(erpMaterialData.processMethod === "2"){
var processDatas = $("#bootstrap-table-process").bootstrapTable('getData');
if(processDatas.length === 0){
$.modal.alertWarning("请至少添加一条委外工序再保存!");
return;
}else{
for(var i = 0; i<processDatas.length; i++){
var process = {
outsourceProcessNo: processDatas[i].outsourceProcessNo,
outsourceProcessName: processDatas[i].outsourceProcessName,
}
erpMaterial.processList.push(process);
}
}
}
console.log(erpMaterial);
$.operate.saveJson(prefix + "/edit", JSON.stringify(erpMaterial));
// $.operate.save(prefix + "/edit", $('#form-material-edit').serialize());
}
}

Loading…
Cancel
Save