+
@@ -62,8 +62,9 @@
// var subTableFormArray = [];
$(function(){
+ sessionStorage.clear();
var options = {
- url: ctx + "system/orderChild/list",
+ url: ctx + "system/makeorderbom/list",
id: 'bootstrap-sub-table-1',
showSearch: false,
showRefresh: false,
@@ -94,7 +95,7 @@
visible: false
},
{
- field: 'materialCode',
+ field: 'materialNo',
align: 'center',
title: '料号'
},
@@ -143,7 +144,7 @@
title: '客户期望交付时间'
},
{
- field: 'materialNum',
+ field: 'orderNum',
align: 'center',
title: '订单数量'
},
@@ -176,7 +177,7 @@
queryParams : {
makeNo: $("#makeNo").val(),
salesOrderCode: $("#saleNo").val(),
- salesOrderMaterialNo: parentRow.materialCode
+ salesOrderMaterialNo: parentRow.materialNo
},
columns: [{
field: 'id',
@@ -186,6 +187,7 @@
{
field: 'level',
title: '阶层',
+ align: 'center',
formatter: function(value, row, index) {
return $.table.selectDictLabel(levelDatas, value);
}
@@ -193,6 +195,7 @@
{
field: 'bomNo',
title: 'BOM号',
+ align: 'center',
formatter:function (value,row,index){
if (value == null || value == ''){
return '/';
@@ -203,6 +206,7 @@
},
{
field: 'materialNo',
+ align: 'center',
title: '料号',
formatter: function (value,row,index){
var curIndex = row.sortNo-1;
@@ -211,6 +215,7 @@
},
{
field: 'photoUrl',
+ align: 'center',
title: '图片',
formatter: function(value, row, index) {
return $.table.imageView(value);
@@ -218,6 +223,7 @@
},
{
field: 'materialName',
+ align: 'center',
title: '物料名称',
formatter: function (value,row,index){
if (value == null || value == ''){
@@ -229,13 +235,20 @@
},
{
field: 'materialType',
+ align: 'center',
title: '物料类型',
formatter: function(value, row, index) {
return $.table.selectCategoryLabel(materialTypeDatas, value);
}
},
+ {
+ field: 'materialModel',
+ align: 'center',
+ title: '型号',
+ },
{
field: 'describe',
+ align: 'center',
title: '描述',
formatter: function (value,row,index){
if (value == null || value == ''){
@@ -247,6 +260,7 @@
},
{
field: 'brand',
+ align: 'center',
title: '品牌',
formatter: function (value,row,index){
if (value == null || value == ''){
@@ -258,6 +272,7 @@
},
{
field: 'unit',
+ align: 'center',
title: '单位',
formatter: function (value,row,index){
if (value == null || value == ''){
@@ -273,7 +288,7 @@
align: 'center',
formatter: function(value, row, index) {
var label = $.table.selectDictLabel(processMethodDatas, value);
- if (value === '2') {
+ if (value === '2'||value === '4') {
var button = '
委外工序(' + row.processNum + ')';
return label + ' ' + button;
} else {
@@ -283,6 +298,7 @@
},
{
field: 'useNum',
+ align: 'center',
title: '用量',
formatter: function (value,row,index){
if (value == null || value == ''){
@@ -294,6 +310,7 @@
},
{
field: 'lossRate',
+ align: 'center',
title: '损耗率',
},
{
@@ -302,24 +319,28 @@
visible: false,
},
{
- field: 'materialNum',
+ field: 'orderNum',
+ align: 'center',
title: '订单用量',
formatter: function (value,row,index){
- return parentRow.materialNum * row.useNum;
+ return parentRow.orderNum * row.useNum;
}
},
{
field: 'hasOutNum',
+ align: 'center',
title: '已委外数量',
},
{
field: 'outsourceNum',
+ align: 'center',
title: '本次委外数量',
formatter: function (value,row,index){
var processMethod = row.processMethod;
- if(processMethod === "2"){
+ //加工方式为2委外加工或4委外加工或采购
+ if(processMethod === "2"||processMethod === "4"){
var curIndex = row.sortNo-1;
- return '
';
+ return '
';
}
return " ";
}
@@ -346,22 +367,26 @@
}],
// 当所有数据被加载时触发
onLoadSuccess: function(data) {
-
+ var childRows = data.rows;
+ childRows.forEach(function (materialData){
+ var materialNo = materialData.materialNo;
+ var key = childTableId + '_' + materialNo + '_outNum';
+ var outNum = sessionStorage.getItem(key);
+ if (outNum) {
+ $("#outsourceNum_"+childTableId+'_'+materialNo).val(outNum);
+ }
+ })
},
});
};
function queryParams(params) {
var curParams = {
- // 传递参数查询参数
- // pageSize: params.limit,
- // pageNum: params.offset / params.limit + 1,
- // searchValue: params.search,
- // orderByColumn: params.sort,
- // isAsc: params.order
+
};
// 额外传参
- curParams.quoteId = $("#saleNo").val();
+ curParams.makeNo = $("#makeNo").val();
+ curParams.level = 0;
return curParams;
}
@@ -369,6 +394,24 @@
focusCleanup: true
});
+ function saveOutNum(materialNo,childid,event){
+ var outNum = event.target.value;
+ if (isNaN(outNum)) {
+ $.modal.msgError('请输入有效的数字');
+ return;
+ }
+ if (outNum < 0) {
+ $.modal.msgError('委外数必须大于0');
+ return;
+ }
+ if (outNum % 1 !== 0) {
+ $.modal.msgError('委外数不能为小数');
+ return;
+ }
+ var key = childid + '_' + materialNo + '_outNum';
+ sessionStorage.setItem(key,outNum);
+ }
+
function submitHandler() {
var makeNo = $("#makeNo").val();
var sales = $("input[name='Salesman']").val();
@@ -380,9 +423,11 @@
var hasValue = false;
childTableIdList.forEach(function (tableId,index){
var processDatas = $("#" + tableId).bootstrapTable('getData');
- processDatas.forEach(function (data,i){
- if(data.processNum != 0 && data.processMethod === "2"){
- var outNum = $('#' + tableId ).find('input[name="outsourceNum_'+i+'"]').val();
+ processDatas.forEach(function (data){
+ if(data.processNum != 0 && (data.processMethod == "2"||data.processMethod == "4")){
+ var key = tableId + '_' + data.materialNo + '_outNum';
+ var outNum = sessionStorage.getItem(key);
+
if(outNum === null||outNum === ""){
return;
}
diff --git a/ruoyi-admin/src/main/resources/templates/system/makeorder/addProduceInbound.html b/ruoyi-admin/src/main/resources/templates/system/makeorder/addProduceInbound.html
index c6c12058..57775430 100644
--- a/ruoyi-admin/src/main/resources/templates/system/makeorder/addProduceInbound.html
+++ b/ruoyi-admin/src/main/resources/templates/system/makeorder/addProduceInbound.html
@@ -59,12 +59,13 @@
var materialTypeDatas = [[${@category.getChildByCode('materialType')}]];
var levelDatas = [[${@dict.getType('bomLevel')}]];
var processMethodDatas = [[${@dict.getType('processMethod')}]];
+ var equipmentResumeList = {}
// var subTableFormArray = [];
$(function(){
var options = {
- url: ctx + "system/orderChild/list",
+ url: ctx + "system/makeorderbom/list",
id: 'bootstrap-sub-table-1',
showSearch: false,
showRefresh: false,
@@ -101,7 +102,7 @@
visible: false
},
{
- field: 'materialCode',
+ field: 'materialNo',
align: 'center',
title: '料号',
// formatter: function (value,row,index){
@@ -122,6 +123,11 @@
return $.table.selectCategoryLabel(materialTypeDatas, value);
}
},
+ {
+ field: 'materialModel',
+ align: 'center',
+ title: '型号',
+ },
{
field: 'unit',
align: 'center',
@@ -154,20 +160,34 @@
title: '客户期望交付时间'
},
{
- field: 'materialNum',
+ field: 'orderNum',
align: 'center',
title: '订单数量'
},
{
- field: 'completedNum',
+ field: 'finishNum',
align: 'center',
- title: '已完成数'
+ title: '已完成数',
+ formatter: function(value, row, index) {
+ if(!value){
+ return 0;
+ }else{
+ return value;
+ }
+ }
+ },
+ {
+ field: 'currentNum',
+ align: 'center',
+ title: '本次完成数',
+ formatter: function(value, row, index) {
+ if (row.materialType != 'chcpsb') {
+ return '
';
+ } else {
+ return value?value:0;
+ }
+ }
},
- {
- field: 'currentNum',
- title: '本次完成数',
- editable:true
- },
{
title: '操作',
align: 'center',
@@ -175,9 +195,8 @@
var actions = [];
// 物料类型是成品,添加设备履历表
if(row.materialType == 'chcpsb'){
- actions.push('
添加设备履历 ');
+ actions.push('
添加设备履历 ');
}
-
return actions.join('');
}
}
@@ -202,7 +221,7 @@
queryParams : {
makeNo: $("#makeNo").val(),
salesOrderCode: $("#saleNo").val(),
- salesOrderMaterialNo: parentRow.materialCode
+ salesOrderMaterialNo: parentRow.materialNo
},
columns: [{
field: 'id',
@@ -211,6 +230,7 @@
},
{
field: 'level',
+ align: 'center',
title: '阶层',
formatter: function(value, row, index) {
return $.table.selectDictLabel(levelDatas, value);
@@ -218,21 +238,24 @@
},
{
field: 'bomNo',
+ align: 'center',
title: 'BOM号',
formatter:function (value,row,index){
if (value == null || value == ''){
return '/';
}else{
- return value
+ return value;
}
}
},
{
field: 'materialNo',
+ align: 'center',
title: '料号'
},
{
field: 'photoUrl',
+ align: 'center',
title: '图片',
formatter: function(value, row, index) {
return $.table.imageView(value);
@@ -240,6 +263,7 @@
},
{
field: 'materialName',
+ align: 'center',
title: '物料名称',
formatter: function (value,row,index){
if (value == null || value == ''){
@@ -251,13 +275,20 @@
},
{
field: 'materialType',
+ align: 'center',
title: '物料类型',
formatter: function(value, row, index) {
return $.table.selectCategoryLabel(materialTypeDatas, value);
}
},
+ {
+ field: 'materialModel',
+ align: 'center',
+ title: '型号',
+ },
{
field: 'describe',
+ align: 'center',
title: '描述',
formatter: function (value,row,index){
if (value == null || value == ''){
@@ -269,6 +300,7 @@
},
{
field: 'brand',
+ align: 'center',
title: '品牌',
formatter: function (value,row,index){
if (value == null || value == ''){
@@ -280,6 +312,7 @@
},
{
field: 'unit',
+ align: 'center',
title: '单位',
formatter: function (value,row,index){
if (value == null || value == ''){
@@ -292,13 +325,15 @@
{
field: 'processMethod',
- title: '半成品类型',
+ align: 'center',
+ title: '加工方式',
formatter: function(value, row, index) {
return $.table.selectDictLabel(processMethodDatas, value);
}
},
{
field: 'useNum',
+ align: 'center',
title: '用量',
formatter: function (value,row,index){
if (value == null || value == ''){
@@ -310,13 +345,15 @@
},
{
field: 'lossRate',
+ align: 'center',
title: '损耗率',
},
{
field: 'materialNum',
+ align: 'center',
title: '订单用量',
formatter: function (value,row,index){
- return parentRow.materialNum * row.useNum;
+ return parentRow.orderNum * row.useNum;
}
},
{
@@ -348,21 +385,93 @@
function queryParams(params) {
var curParams = {
- // 传递参数查询参数
- // pageSize: params.limit,
- // pageNum: params.offset / params.limit + 1,
- // searchValue: params.search,
- // orderByColumn: params.sort,
- // isAsc: params.order
+
};
// 额外传参
- curParams.quoteId = $("#saleNo").val();
+ curParams.makeNo = $("#makeNo").val();
+ curParams.level = 0;
return curParams;
}
- function addEquipmentResume(curIndex,materialCode){
- var url = prefix + "/addEquipmentResume?makeNo="+$("#makeNo").val()+"&saleNo="+$("#saleNo").val()+"&materialNo="+materialCode+"&curIndex="+curIndex;
- $.modal.open("设备履历表",url);
+ function addEquipmentResume(curIndex,materialNo){
+ var url = prefix + "/addEquipmentResume?makeNo="+$("#makeNo").val()+"&saleNo="+$("#saleNo").val()+"&materialNo="+materialNo+"&curIndex="+curIndex;
+ var options = {
+ title: '添加设备履历',
+ url: url,
+ callBack: doSubmit
+ };
+ $.modal.openOptions(options);
+ }
+
+ function doSubmit(index, layero){
+ var iframeWin = window[layero.find('iframe')[0]['name']];
+ // 获取表单数据
+ const equipMaterialData = iframeWin.$("#form-equipMaterial-add").serializeArray().reduce((obj, item) => {
+ obj[item.name] = item.value;
+ return obj;
+ }, {});
+ var curIndex = iframeWin.$("#curIndex").val();
+ const selectedRows = iframeWin.$("#form-equipMaterialDetail-add").bootstrapTable('getSelections');
+ if (selectedRows.length===0){
+ $.modal.alertWarning("请至少选择一条数据后再保存!");
+ return;
+ }
+ var equipDetailDataList = selectedRows.map(function(item) {
+ return {
+ "equipmentId": item.equipmentId,
+ "equipmentModel": item.equipmentModel,
+ "serialNo": item.serialNo,
+ "producePic": item.producePic,
+ "startMakeTime": item.startMakeTime,
+ "endMakeTime": item.endMakeTime,
+ "addProcessIssueRecordFlag": item.addProcessIssueRecordFlag,
+ // ...其他字段
+ };
+ });
+
+ // 合并表单数据和表格数据
+ const combinedData = Object.assign({}, equipMaterialData, { sysEquipDetailDtos: equipDetailDataList });
+ const jsonData = JSON.stringify(combinedData);
+ saveEquipment(curIndex,jsonData);
+ layer.close(index);
+ }
+
+
+ // 保存设备履历信息 刷新表格
+ function saveEquipment(curIndex,data) {
+ var config = {
+ url: prefix + "/addEquipmentResumeSave",
+ type: "post",
+ dataType: "json",
+ contentType: "application/json;charset=utf-8",
+ data: data,
+ beforeSend: function () {
+ $.modal.loading("正在处理中,请稍后...");
+ $.modal.disable();
+ },
+ success: function(result) {
+ $.modal.closeLoading();
+ $.modal.enable();
+ console.log(result);
+ groupByMaterialNo(curIndex,result.data);
+ }
+ };
+ $.ajax(config)
+ };
+
+ function groupByMaterialNo(curIndex,data) {
+ var materialNo = data[0].materialNo;
+ equipmentResumeList[materialNo] = [];
+ data.forEach(item => {
+ equipmentResumeList[materialNo].push(item);
+ });
+ var newRowData = {
+ currentNum: data.length,
+ }
+ $("#bootstrap-sub-table-1").bootstrapTable('updateRow', {
+ index: curIndex,
+ row: newRowData
+ });
}
$("#form-makeorder-edit").validate({
@@ -388,12 +497,31 @@
}, {});
// 获取bootstrap-table的数据,这里假设你使用bootstrap-table的API获取所有数据
var table = $('#bootstrap-sub-table-1').bootstrapTable('getData');
- //获取选中复选框行的数据
+ var hasValue = false;
+ var tableData = [];
+ table.forEach(function(row, index) {
+ if (row.materialType != 'chcpsb') {
+ var currentInput = $('#'+row.materialNo).val();
+ if(currentInput!=''&¤tInput!=undefined&¤tInput!=null&¤tInput!=0){
+ row.currentNum = currentInput;
+ tableData.push(row);
+ hasValue = true;
+ }
+ }else if(row.currentNum!=0){
+ tableData.push(row);
+ hasValue = true;
+ }
+ });
+ console.log(tableData);
+ if(!hasValue){
+ $.model.msgError("至少添加一条有效入库物料!");
+ return;
+ }
// 将表数据转换成与complaintNoticeData格式一致的数组
- var materialDataList = table.map(function(item) {
+ var materialDataList = tableData.map(function(item) {
// 根据实际字段名调整
return {
- "materialNo":item.materialCode,
+ "materialNo":item.materialNo,
"materialName": item.materialName,
"unit": item.unit,
"brand": item.brand,
@@ -402,23 +530,20 @@
"deliveryTime":item.deliveryTime,
"materialNum":item.materialNum,
"currentNum": item.currentNum,
- "completedNum": item.completedNum,
-
+ "completedNum": item.finishNum,
+ "salesShippingDeviceList": equipmentResumeList[item.materialNo],
// ...其他字段
};
});
-
// 合并表单数据和表格数据
const combinedData = Object.assign({}, makeorderData, { inboundDetails: materialDataList });
- console.log(combinedData)
// 使用 JSON.stringify() 序列化数据
const jsonData = JSON.stringify(combinedData);
// 发送 AJAX 请求到后端接口
$.operate.saveJson(prefix + "/addProduceInboundSave", jsonData);
}
-