@ -4,232 +4,308 @@
< th:block th:include = "include :: header('修改委外报价')" / >
< / head >
< body class = "white-bg" >
< div class = "wrapper wrapper-content animated fadeInRight ibox-content" >
< form class = "form-horizontal m" id = "form-outsource_quote-edit" th:object = "${outsourceQuote}" >
< h4 class = "form-header h4" > 委外报价信息< / h4 >
< input name = "outsourceQuoteId" th:field = "*{outsourceQuoteId}" type = "hidden" >
< div class = "col-xs-12" >
< div class = "form-group" >
< label class = "col-sm-3 control-label is-required" > 委外报价单号:< / label >
< div class = "col-sm-8" >
< input name = "outsourceQuoteCode" th:field = "*{outsourceQuoteCode}" class = "form-control" type = "text" required >
< / div >
< div class = "wrapper wrapper-content animated fadeInRight ibox-content" >
< form class = "form-horizontal m" id = "form-outsource_quote-edit" th:object = "${outsourceQuote}" >
< h4 class = "form-header h4" > 委外报价信息< / h4 >
< input name = "outsourceQuoteId" th:field = "*{outsourceQuoteId}" type = "hidden" >
< div class = "col-xs-12" >
< div class = "form-group" >
< label class = "col-sm-3 control-label is-required" > 委外报价单号:< / label >
< div class = "col-sm-8" >
< input name = "outsourceQuoteCode" th:field = "*{outsourceQuoteCode}" class = "form-control" type = "text" required >
< / div >
< / div >
< / div >
< div class = "col-xs-12" >
< div class = "form-group" >
< label class = "col-sm-3 control-label" > 供应商编号:< / label >
< div class = "col-sm-8" >
< input name = "supplierQuoteCode" th:field = "*{supplierQuoteCode}" class = "form-control" type = "text" >
< / div >
< div class = "col-xs-12" >
< div class = "form-group" >
< label class = "col-sm-3 control-label" > 供应商编号:< / label >
< div class = "col-sm-8" >
< input name = "supplierQuoteCode" th:field = "*{supplierQuoteCode}" class = "form-control" type = "text" >
< / div >
< / div >
< div class = "col-xs-12" >
< div class = "form-group " >
< label class = "col-sm-3 control-label " > 供应商名称:< / label >
< div class = "col-sm-8 " >
< input name = "supplierName" th:field = "*{supplierName}" class = "form-control" type = "text " >
< / div >
< / div >
< div class = "col-xs-12 " >
< div class = "form-group ">
< label class = "col-sm-3 control-label "> 供应商名称:< / label >
< div class = "col-sm-8 ">
< input name = "supplierName" th:field = "*{supplierName}" class = "form-control" type = "text" >
< / div >
< / div >
< div class = "col-xs-12" >
< div class = "form-group " >
< label class = "col-sm-3 control-label " > 工序合计:< / label >
< div class = "col-sm-8 " >
< input name = "processAmount" th:field = "*{processAmount}" class = "form-control" type = "text " >
< / div >
< / div >
< div class = "col-xs-12 " >
< div class = "form-group ">
< label class = "col-sm-3 control-label "> 工序合计:< / label >
< div class = "col-sm-8 ">
< input name = "processAmount" th:field = "*{processAmount}" class = "form-control" type = "text" >
< / div >
< / div >
< div class = "col-xs-12" >
< div class = "form-group " >
< label class = "col-sm-3 control-label " > 税率:< / label >
< div class = "col-sm-8 " >
< input name = "taxRate" th:field = "*{taxRate}" class = "form-control" type = "text " >
< / div >
< / div >
< div class = "col-xs-12 " >
< div class = "form-group ">
< label class = "col-sm-3 control-label "> 税率:< / label >
< div class = "col-sm-8 ">
< input name = "taxRate" th:field = "*{taxRate}" class = "form-control" type = "text" >
< / div >
< / div >
< div class = "col-xs-12" >
< div class = "form-group " >
< label class = "col-sm-3 control-label " > 定价日期:< / label >
< div class = "col-sm-8 " >
< input name = "pricingDate" th:field = "*{pricingDate}" class = "form-control" type = "text " >
< / div >
< / div >
< div class = "col-xs-12 " >
< div class = "form-group ">
< label class = "col-sm-3 control-label "> 定价日期:< / label >
< div class = "col-sm-8 ">
< input name = "pricingDate" th:field = "*{pricingDate}" class = "form-control" type = "text" >
< / div >
< / div >
< div class = "col-xs-12" >
< div class = "form-group " >
< label class = "col-sm-3 control-label " > 审核状态:< / label >
< div class = "col-sm-8 " >
< select name = "auditStatus" class = "form-control" th:with = "type=${@dict.getType('audit_status')} " >
< option th:each = "dict : ${type}" th:text = "${dict.dictLabel}" th:value = "${dict.dictValue}" th:field = "*{auditStatus}" > < / option >
< / s elect>
< / div >
< / div >
< div class = "col-xs-12 " >
< div class = "form-group ">
< label class = "col-sm-3 control-label "> 审核状态:< / label >
< div class = "col-sm-8 ">
< select name = "auditStatus" class = "form-control" th:with = "type=${@dict.getType('audit_status')}" >
< option th:each = "dict : ${type}" th:text = "${dict.dictLab el}" th:valu e= "${di ct.dictValue}" th:field = "*{auditStatus}" > < / option >
< / select >
< / div >
< / div >
< div class = "col-xs-12" >
< div class = "form-group " >
< label class = "col-sm-3 control-label " > 备注:< / label >
< div class = "col-sm-8 " >
< input name = "remark" th:field = "*{remark}" class = "form-control" type = "text " >
< / div >
< / div >
< div class = "col-xs-12 " >
< div class = "form-group ">
< label class = "col-sm-3 control-label "> 备注:< / label >
< div class = "col-sm-8 ">
< input name = "remark" th:field = "*{remark}" class = "form-control" type = "text" >
< / div >
< / div >
< h4 class = "form-header h4" > 委外报价工序信息< / h4 >
< div class = "row " >
< div class = "col-sm-12 " >
< button type = "button" class = "btn btn-blue btn-sm" onclick = "processadd()" > < i class = "fa fa-plus " > 增加< / i > < / button >
< div class = "col-sm-12 select-table table-striped " >
< table id = "bootstrap-table" > < / table >
< / div >
< / div >
< h4 class = "form-header h4 "> 委外报价工序信息< / h4 >
< div class = "row " >
< div class = "col-sm-12 ">
< button type = "button" class = "btn btn-blue btn-sm" onclick = "processadd()" > < i class = "fa fa-plus "> 增加< / i > < / button >
< div class = "col-sm-12 select-table table-striped" >
< table id = "bootstrap-table-process" > < / table >
< / div >
< / div >
< / form >
< / div >
< th:block th:include = "include :: footer" / >
< script th:inline = "javascript" >
var prefix = ctx + "system/outsource_quote";
$("#form-outsource_quote-edit").validate({
focusCleanup: true
});
// 保存信息 刷新表格
function saveJson(url, data, callback) {
var config = {
url: url,
type: "post",
dataType: "json",
contentType: "application/json;charset=utf-8",
data: data,
beforeSend: function () {
$.modal.loading("正在处理中,请稍后...");
$.modal.disable();
},
success: function(result) {
if (typeof callback == "function") {
callback(result);
}
$.operate.successCallback(result);
< / div >
< / form >
< / div >
< th:block th:include = "include :: footer" / >
< script th:inline = "javascript" >
var prefix = ctx + "system/outsource_quote";
$("#form-outsource_quote-edit").validate({
focusCleanup: true
});
// 保存信息 刷新表格
function saveJson(url, data, callback) {
var config = {
url: url,
type: "post",
dataType: "json",
contentType: "application/json;charset=utf-8",
data: data,
beforeSend: function () {
$.modal.loading("正在处理中,请稍后...");
$.modal.disable();
},
success: function(result) {
if (typeof callback == "function") {
callback(result);
}
} ;
$.ajax(config)
$.operate.successCallback(result) ;
}
};
$.ajax(config)
};
function submitHandler() {
if ($.validate.form()) {
var url = prefix + "/edit";
if ($.validate.form()) {
// 获取表单数据
const outsourceQuoteData = $("#form-outsource_quote-edit").serializeArray().reduce((obj, item) => {
obj[item.name] = item.value;
return obj;
}, {});
// console.log(outsourceQuoteData);
// 获取bootstrap-table的数据,这里假设你使用bootstrap-table的API获取所有数据
var rows = $('#bootstrap-table').bootstrapTable('getData');
// console.log(JSON.stringify(rows));
// 检查表格数据是否为空
if (rows.length === 0) {
$.modal.alertWarning("请至少添加一条委外工序再保存!");
return;
}
// 将表数据转换成与qualityReportData格式一致的数组
var outsourceQuoteChildList = rows.map(function (item) {
// 根据实际字段名调整
return {
"outsourceProcessCode": item.outsourceProcessCode,
"outsourceProcessNo": item.outsourceProcessNo,
"chargeUnit": item.chargeUnit,
"materialRmb": item.materialRmb,
"materialNormb": item.materialNormb,
function submitHandler() {
var url = prefix + "/edit";
var outsourceQuote = {
// ...其他字段
};
});
const combinedData = Object.assign({}, outsourceQuoteData,
{
outsourceQuoteChildList: outsourceQuoteChildList,
},
);
// 合并表单数据和表格数据
// const combinedData = Object.assign({}, ...complaintNoticeData.array(item => ({ [item.name]: item.value })), ...materialData);
console.log(combinedData)
// 使用 JSON.stringify() 序列化数据
const jsonData = JSON.stringify(combinedData);
// 发送 AJAX 请求到后端接口
saveJson(prefix + "/edit", jsonData);
};
if ($.validate.form()) {
var outsourceQuoteChildList = [];
// 获取表单数据
const outsourceQuoteData = $("#form-outsource_quote-edit").serializeArray().reduce((obj, item) => {
obj[item.name] = item.value;
return obj;
}, {});
console.log(outsourceQuoteData);
outsourceQuote = {
outsourceQuoteId: outsourceQuoteData.outsourceQuoteId,
outsourceQuoteCode: outsourceQuoteData.outsourceQuoteCode,
supplierQuoteCode: outsourceQuoteData.supplierCode,
supplierName: outsourceQuoteData.supplierName,
pricingDate: outsourceQuoteData.pricingDate,
taxRate: outsourceQuoteData.taxRate,
remark: outsourceQuoteData.remark,
processAmount: 0,
outsourceQuoteChildList: []
}
// 获取bootstrap-table的数据,这里假设你使用bootstrap-table的API获取所有数据
var rows = $('#bootstrap-table-process').bootstrapTable('getData');
// 检查表格数据是否为空
if (rows.length === 0) {
$.modal.alertWarning("请至少添加一条委外工序再保存!");
return;
}else{
console.log(rows);
outsourceQuote.processAmount = rows.length;
var unit = getUnit();
var noRmb = getNoRmb();
var rmb = getRmb();
for(var i=0;i< rows.length ; i + + ) {
var quoteChild = {
outsourceProcessCode: rows[i].outsourceProcessCode,
outsourceProcessNo: rows[i].outsourceProcessNo,
outsourceProcessName: rows[i].outsourceProcessName,
chargeUnit:unit[i],
materialNormb: noRmb[i],
materialRmb: rmb[i],
};
outsourceQuote.outsourceQuoteChildList.push(quoteChild);
}
console.log(outsourceQuote);
}
};
function processadd() {
var url = prefix + "/processadd";
var options = {
title: '选择委外工序',
height: "500",
url: url,
callBack: doSubmit
};
$.modal.openOptions(options);
saveJson(prefix + "/edit", JSON.stringify(outsourceQuote));
}
/* 选择委外工序回调 */
function doSubmit(index, layero){
// // 这里取到的是多行的
var rowData = layero.find("iframe")[0].contentWindow.getSelections();
//判断是否重复
var rows = $("#bootstrap-table").bootstrapTable('getData').length;
if(rows>0){
for(var i=0;i< rows ; i + + ) {
var data = $("#bootstrap-table").bootstrapTable('getData')[i];
for(var j=0;j< rowData.length ; j + + ) {
if(data.outsourceProcessCode==rowData[j].outsourceProcessCode){
$.modal.alertError("不能选择已添加过的相同工序");
return;
}
}
function processadd() {
var url = prefix + "/processadd";
var options = {
title: '选择委外工序',
height: "500",
url: url,
callBack: doSubmit
};
$.modal.openOptions(options);
}
/* 选择委外工序回调 */
function doSubmit(index, layero){
// // 这里取到的是多行的
var rowData = layero.find("iframe")[0].contentWindow.getSelections();
//判断是否重复
var rows = $("#bootstrap-table-process").bootstrapTable('getData').length;
if(rows>0){
for(var i=0;i< rows ; i + + ) {
var data = $("#bootstrap-table-process").bootstrapTable('getData')[i];
for(var j=0;j< rowData.length ; j + + ) {
if(data.outsourceProcessNo==rowData[j].outsourceProcessNo){
$.modal.alertError("不能选择已添加过的相同工序");
return;
}
sub.addRow(rowData[i]);
};
}else{
for(i=0;i< rowData.length ; i + + ) {
sub.addRow(rowData[i]);
insertTable(rowData[i]);
}
};
}else{
for(i=0;i< rowData.length ; i + + ) {
insertTable(rowData[i]);
}
layer.closeAll();
}
$(function() {
var options = {
data: [[${outsourceQuote.outsourceQuoteChildList}]],
pagination: false,
showSearch: false,
showRefresh: false,
showToggle: false,
showColumns: false,
sidePagination: "client",
columns: [
layer.closeAll();
}
function insertTable(rowData) {
$("#bootstrap-table-process").bootstrapTable('insertRow', {
index: 1,
row: {
outsourceProcessNo: rowData.outsourceProcessNo,
outsourceProcessCode: rowData.outsourceProcessCode,
outsourceProcessName: rowData.outsourceProcessName,
materialNoRmb: 0.00,
materialRmb: 0.00,
}
});
}
function getUnit(){
var selectElements = $('#bootstrap-table-process').find('select[id^="chargeUnit"]');
// 遍历每个下拉框
var unit = [];
selectElements.each(function() {
// 获取当前下拉框的值
var selectedValue = $(this).val();
unit.push(selectedValue);
});
console.log(unit);
return unit;
}
function getNoRmb(){
var selectElements = $('#bootstrap-table-process').find('input[id^="materialNormb"]');
// 遍历每个下拉框
var noRmb = [];
selectElements.each(function() {
// 获取当前下拉框的值
var selectedValue = $(this).val();
noRmb.push(selectedValue);
});
// console.log(noRmb);
return noRmb;
};
function getRmb(){
var selectElements = $('#bootstrap-table-process').find('input[id^="materialRmb"]');
// 遍历每个输入框
var rmb = [];
selectElements.each(function() {
// 获取当前输入框的值
var selectedValue = $(this).val();
rmb.push(selectedValue);
});
// console.log(rmb);
return rmb;
};
function initTable(data,index){
$("#bootstrap-table-process").bootstrapTable('insertRow', {
index:1,
row: {
outsourceProcessNo: data.outsourceProcessNo,
outsourceProcessCode: data.outsourceProcessCode,
outsourceProcessName: data.outsourceProcessName,
}
});
$('#bootstrap-table-process').find('select[id="chargeUnit'+index+'"]').val(data.chargeUnit);
$('#bootstrap-table-process').find('input[id="materialNormb'+index+'"]').val(data.materialNormb);
$('#bootstrap-table-process').find('input[id="materialRmb'+index+'"]').val(data.materialRmb);
};
$(function() {
var options = {
id: "bootstrap-table-process",
pagination: false,
showSearch: false,
showRefresh: false,
showToggle: false,
showColumns: false,
sidePagination: "client",
data: [[${outsourceQuote.outsourceQuoteChildList}]],
columns: [
{
field: 'outsourceProcessId',
align: 'center',
title: '委外工序主键',
visible: false,
formatter: function(value, row, index) {
var html = $.common.sprintf("< input class = 'form-control' type = 'text' readonly = 'readonly' name = 'outsourceQuoteChildList[%s].outsourceProcessId' value = '%s' > ", index, value);
return html;
}
},
{
field: 'outsourceProcessNo',
align: 'center',
title: '委外工序编号',
formatter: function(value, row, index) {
var html = $.common.sprintf("< input class = 'form-control' type = 'text' name = 'outsourceQuoteChildList[%s].outsourceProcessNo' value = '%s' > ", index, value);
return html;
}
},
{
field: 'outsourceProcessName',
align: 'center',
title: '委外工序名称',
},
{
field: 'chargeUnit',
align: 'center',
title: '计价单位',
width: 120,
// overflow: visible,
formatter: function(value, row, index) {
var html = $.common.sprintf("< input class = 'form-control' type = 'text' name = 'outsourceQuoteChildList[%s].outsourceProcessName' value = '%s' > ", index, value);
var html = $.common.sprintf("< select class = 'form-control' id = 'chargeUnit" + index + "' data-first-title = '请选择' > " +
"< option value = '' > 请选择< / option > " +
"< option value = '0' > 按重量计< / option > " +
"< option value = '1' > 按数量计< / option > " +
"< option value = '2' > 按面积计< / option > " +
"< / select > ", index, value);
return html;
}
},
@ -238,7 +314,7 @@
align: 'center',
title: '工序的不含税单价(RMB) ',
formatter: function(value, row, index) {
var html = $.common.sprintf("< input class = 'form-control' type = 'text' name = 'outsourceQuoteChildList[%s].materialNormb' value = '%s '> ", index, value);
var html = $.common.sprintf("< input class = 'form-control' type = 'text' id = 'materialNormb" + index + " '> ", index, value);
return html;
}
},
@ -247,7 +323,7 @@
align: 'center',
title: '工序的含税单价(RMB)',
formatter: function(value, row, index) {
var html = $.common.sprintf("< input class = 'form-control' type = 'text' name = 'outsourceQuoteChildList[%s].materialRmb' value = '%s '> ", index, value);
var html = $.common.sprintf("< input class = 'form-control' type = 'text' id = 'materialRmb" + index + " '> ", index, value);
return html;
}
},
@ -259,32 +335,22 @@
return '< a class = "btn btn-danger btn-xs" href = "javascript:void(0)" onclick = "sub.delRowByIndex(\'' + value + '\')" > < i class = "fa fa-remove" > < / i > 删除< / a > ';
}
}]
};
// console.log(options.data);
$.table.init(options);
};
$.table.init(options);
var quoteDetail = options.data;
$.each(quoteDetail, function(index, item) {
// 设置下拉框的值
$('#chargeUnit' + index).val(item.chargeUnit);
// 设置不含税单价输入框的值
$('#materialNormb' + index).val(item.materialNormb);
// 设置含税单价输入框的值
$('#materialRmb' + index).val(item.materialRmb);
});
function addRow() {
var count = $("#" + table.options.id).bootstrapTable('getData').length;
var row = {
index: $.table.serialNumber(count),
outsourceQuoteCode: "",
outsourceProcessNo: "",
outsourceProcessName: "",
remark: "",
taxRate: "",
materialRmb: "",
materialNormb: "",
supplierCode: "",
supplierName: "",
createBy: "",
createTime: "",
updateBy: "",
updateTime: "",
auditStatus: "",
}
sub.addRow(row);
};
< / script >
});
< / script >
< / body >
< / html >