|
|
@ -8,128 +8,55 @@ |
|
|
|
<div class="wrapper wrapper-content animated fadeInRight ibox-content"> |
|
|
|
<form class="form-horizontal m" id="form-estimate-add"> |
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-3 control-label">估价单号:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<input name="salesEstimateCode" class="form-control" type="text"> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-3 control-label">用户ID:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<input name="userId" class="form-control" type="text"> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-3 control-label">业务人员:</label> |
|
|
|
<label class="col-sm-4 control-label">业务员:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<input name="businessMembers" class="form-control" type="text"> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-3 control-label">估价状态:</label> |
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-4 control-label">定价日期:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<select name="estimateStatus" class="form-control m-b" th:with="type=${@dict.getType('estimate_status')}"> |
|
|
|
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option> |
|
|
|
</select> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-3 control-label">客户代码id:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<input name="enterpriseCode" class="form-control" type="text"> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-3 control-label">客户名称:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<input name="enterpriseName" class="form-control" type="text"> |
|
|
|
<div class="input-group date"> |
|
|
|
<input name="pricingDate" class="form-control" placeholder="yyyy-MM-dd" type="text"> |
|
|
|
<span class="input-group-addon"><i class="fa fa-calendar"></i></span> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-3 control-label">物料合计:</label> |
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-4 control-label is-required">客户ID:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<input name="materialSum" class="form-control" type="text"> |
|
|
|
<select class="form-control" id="enterpriseCode" name="enterpriseCode" required> |
|
|
|
<!-- 这里动态生成客户编号选项 --> |
|
|
|
</select> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-3 control-label">数量合计:</label> |
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-4 control-label is-required">客户名称:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<input name="enterpriseSum" class="form-control" type="text"> |
|
|
|
<input name="enterpriseName" class="form-control" type="text" readonly required> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-3 control-label">估价币种:</label> |
|
|
|
<label class="col-sm-4 control-label is-required">估价币种:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<select name="commonCurrency" class="form-control m-b" th:with="type=${@dict.getType('sys_common_currency')}"> |
|
|
|
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option> |
|
|
|
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" required></option> |
|
|
|
</select> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-3 control-label">美元汇率:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<input name="usdRate" class="form-control" type="text"> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-3 control-label">不含税单价:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<input name="noTaxRmb" class="form-control" type="text"> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-3 control-label">含税单价:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<input name="taxRmb" class="form-control" type="text"> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-3 control-label">不含税总价:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<input name="allNoTaxRmb" class="form-control" type="text"> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-3 control-label">含税总价:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<input name="allTaxRmb" class="form-control" type="text"> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-3 control-label">含税单价:</label> |
|
|
|
<label class="col-sm-4 control-label is-required">美元汇率:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<input name="taxDollar" class="form-control" type="text"> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-3 control-label">不含税单价:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<input name="noTaxDollar" class="form-control" type="text"> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-3 control-label">含税总价:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<input name="allTaxDollar" class="form-control" type="text"> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-3 control-label">不含税总价:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<input name="allNoTaxDollar" class="form-control" type="text"> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-3 control-label">定价日期:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<div class="input-group date"> |
|
|
|
<input name="pricingDate" class="form-control" placeholder="yyyy-MM-dd" type="text"> |
|
|
|
<span class="input-group-addon"><i class="fa fa-calendar"></i></span> |
|
|
|
<div class="input-group"> |
|
|
|
<input name="usdRate" class="form-control" type="text" required> |
|
|
|
<span class="input-group-addon">%</span> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-3 control-label">备注信息:</label> |
|
|
|
<label class="col-sm-4 control-label">备注信息:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<input name="remark" class="form-control" type="text"> |
|
|
|
</div> |
|
|
@ -175,22 +102,76 @@ |
|
|
|
</div> |
|
|
|
<div class="row"> |
|
|
|
<div class="col-sm-12 select-table table-striped"> |
|
|
|
<table id="bootstrap-sub-table-order"></table> |
|
|
|
<table id="bootstrap-table"></table> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<th:block th:include="include :: footer" /> |
|
|
|
<th:block th:include="include :: datetimepicker-js" /> |
|
|
|
<th:block th:include="include::bootstrap-table-editable-js"/> |
|
|
|
<script th:inline="javascript"> |
|
|
|
var prefix = ctx + "sales/estimate" |
|
|
|
var materialGearPositionDatas = [[${@dict.getType('material_gear_position')}]]; |
|
|
|
var materialTypeDatas = [[${@category.getChildByCode('materialType')}]]; |
|
|
|
var processMethodDatas = [[${@dict.getType('processMethod')}]]; |
|
|
|
|
|
|
|
|
|
|
|
$("#form-estimate-add").validate({ |
|
|
|
focusCleanup: true |
|
|
|
}); |
|
|
|
|
|
|
|
function submitHandler() { |
|
|
|
if ($.validate.form()) { |
|
|
|
$.operate.save(prefix + "/add", $('#form-estimate-add').serialize()); |
|
|
|
// 获取表单数据 |
|
|
|
const estimateData = $("#form-estimate-add").serializeArray().reduce((obj, item) => { |
|
|
|
obj[item.name] = item.value; |
|
|
|
return obj; |
|
|
|
}, {}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 销售估价物料 |
|
|
|
var estimateMaterialTable = $('#bootstrap-table').bootstrapTable('getData'); |
|
|
|
|
|
|
|
|
|
|
|
// 将表数据转换成与estimateData格式一致的数组 |
|
|
|
var estimateMaterialDataList = estimateMaterialTable.map(function(item) { |
|
|
|
// 根据实际字段名调整 |
|
|
|
return { |
|
|
|
"materialNo": item.materialNo, |
|
|
|
"materialName": item.materialName, |
|
|
|
"materialType": item.materialType, |
|
|
|
"materialPhotourl": item.materialPhotourl, |
|
|
|
"materialDescribe": item.materialDescribe, |
|
|
|
"materialBrand": item.materialBrand, |
|
|
|
"materialUnit": item.materialUnit, |
|
|
|
"materialProcessMethod": item.materialProcessMethod, |
|
|
|
"materialGearPosition": item.materialGearPosition, |
|
|
|
"materialNum":item.materialNum, |
|
|
|
"noTaxRmb": item.noTaxRmb, |
|
|
|
"taxRmb": item.taxRmb, |
|
|
|
"allNoTaxRmb": item.allNoTaxRmb, |
|
|
|
"allTaxRmb": item.allTaxRmb, |
|
|
|
"noTaxDollar": item.noTaxDollar, |
|
|
|
"taxDollar": item.taxDollar, |
|
|
|
"allNoTaxDollar": item.allNoTaxDollar, |
|
|
|
"allTaxDollar": item.allTaxDollar, |
|
|
|
"warehouseDept": item.warehouseDept, |
|
|
|
// ...其他字段 |
|
|
|
}; |
|
|
|
}); |
|
|
|
|
|
|
|
const combinedData = Object.assign({}, estimateData, { |
|
|
|
salesEstimateDetailList: estimateMaterialDataList, |
|
|
|
}); |
|
|
|
// 合并表单数据和表格数据 |
|
|
|
console.log(combinedData) |
|
|
|
// 使用 JSON.stringify() 序列化数据 |
|
|
|
const jsonData = JSON.stringify(combinedData); |
|
|
|
// 发送 AJAX 请求到后端接口 |
|
|
|
$.operate.saveJson(prefix + "/add", jsonData); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -202,8 +183,241 @@ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 点击选择物料按钮 |
|
|
|
function insertMaterialRow() { |
|
|
|
var url = prefix + '/estimateMaterialSelect'; |
|
|
|
var options = { |
|
|
|
title: '选择物料', |
|
|
|
url: url, |
|
|
|
callBack: estimateDoSubmit |
|
|
|
}; |
|
|
|
$.modal.openOptions(options); |
|
|
|
} |
|
|
|
|
|
|
|
$(function() { |
|
|
|
var options = { |
|
|
|
modalName: "销售估价详情", |
|
|
|
columns: [{ |
|
|
|
checkbox: true |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '销售估价详情ID', |
|
|
|
field: 'estimateDetailId', |
|
|
|
visible: false |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '料号', |
|
|
|
field: 'materialNo', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '物料名称', |
|
|
|
field: 'materialName', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '物料类型', |
|
|
|
field: 'materialType', |
|
|
|
formatter: function(value, row, index) { |
|
|
|
return $.table.selectCategoryLabel(materialTypeDatas, value); |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '图片地址', |
|
|
|
field: 'materialPhotoUrl', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '物料单位', |
|
|
|
field: 'materialUnit', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '物料品牌', |
|
|
|
field: 'materialBrand', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '物料描述', |
|
|
|
field: 'materialDescribe', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '加工方式', |
|
|
|
field: 'materialProcessMethod', |
|
|
|
formatter: function(value, row, index) { |
|
|
|
return $.table.selectDictLabel(processMethodDatas, value); |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '料号档位', |
|
|
|
field: 'materialGearPosition', |
|
|
|
formatter: function(value, row, index) { |
|
|
|
return $.table.selectDictLabel(materialGearPositionDatas, value); |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '物料数量', |
|
|
|
field: 'materialNum', |
|
|
|
editable: true, |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '不含税单价', |
|
|
|
field: 'noTaxRmb', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '含税单价', |
|
|
|
field: 'taxRmb', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '不含税总价', |
|
|
|
field: 'allNoTaxRmb', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '含税总价', |
|
|
|
field: 'allTaxRmb', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '含税单价', |
|
|
|
field: 'taxDollar', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '不含税单价', |
|
|
|
field: 'noTaxDollar', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '含税总价', |
|
|
|
field: 'allTaxDollar', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '不含税总价', |
|
|
|
field: 'allNoTaxDollar', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '入库部门', |
|
|
|
field: 'warehouseDept', |
|
|
|
visible:false |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '操作', |
|
|
|
align: 'center', |
|
|
|
formatter: function(value, row, index) { |
|
|
|
var actions = []; |
|
|
|
actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="removeMaterialRow(\'' + row.materialNo + '\')"><i class="fa fa-remove"></i>删除</a> '); |
|
|
|
return actions.join(''); |
|
|
|
} |
|
|
|
}] |
|
|
|
}; |
|
|
|
$.table.init(options); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
function estimateDoSubmit(index, layero,uniqueId){ |
|
|
|
console.log(uniqueId); |
|
|
|
var iframeWin = window[layero.find('iframe')[0]['name']]; |
|
|
|
var rowData = iframeWin.$('#bootstrap-estimateMaterialSelect-table').bootstrapTable('getSelections')[0]; |
|
|
|
|
|
|
|
//判断是否重复 |
|
|
|
var rows = $("#bootstrap-table").bootstrapTable('getData').length; |
|
|
|
for(var i=0;i<rows;i++){ |
|
|
|
var data = $("#bootstrap-table").bootstrapTable('getData')[i]; |
|
|
|
|
|
|
|
if(data.materialNo == rowData.materialCode){ |
|
|
|
$.modal.alertError("不能选择已添加过的相同物料"); |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
console.log("rowData: "+rowData); |
|
|
|
$("#bootstrap-table").bootstrapTable('insertRow', { |
|
|
|
index:1, |
|
|
|
row: { |
|
|
|
materialNo:rowData.materialCode, |
|
|
|
materialPhotourl:rowData.photoUrl, |
|
|
|
materialName: rowData.materialName, |
|
|
|
materialType: rowData.materialType, |
|
|
|
materialDescribe: rowData.describe, |
|
|
|
materialBrand: rowData.brand, |
|
|
|
materialUnit: rowData.unit, |
|
|
|
materialProcessMethod: rowData.processMethod, |
|
|
|
materialDeptType: rowData.warehouseDept, |
|
|
|
} |
|
|
|
}) |
|
|
|
layer.close(index); |
|
|
|
} |
|
|
|
|
|
|
|
// 逻辑删除前端的一行数据 |
|
|
|
function removeMaterialRow(materialNo){ |
|
|
|
$("#bootstrap-table").bootstrapTable('remove', { |
|
|
|
field: 'materialNo', |
|
|
|
values: materialNo |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 假设的加载客户编号列表函数 |
|
|
|
function loadCustomerIds() { |
|
|
|
var url = ctx + 'system/customer/getCustomers'; |
|
|
|
|
|
|
|
$.ajax({ |
|
|
|
type: 'GET', // 请求类型 |
|
|
|
url: url, // 后端接口URL |
|
|
|
dataType: 'json', // 预期服务器返回的数据类型 |
|
|
|
success: function(data) { |
|
|
|
if (data && Array.isArray(data)) { |
|
|
|
var selectElement = $('#enterpriseCode'); // 获取客户编号下拉框元素 |
|
|
|
|
|
|
|
// 清空下拉框现有选项 |
|
|
|
selectElement.empty(); |
|
|
|
|
|
|
|
// 添加默认选项(如果需要) |
|
|
|
selectElement.append('<option value="">请选择客户编号</option>'); |
|
|
|
|
|
|
|
// 遍历返回的数据,添加为下拉框的选项 |
|
|
|
$.each(data, function(index, item) { |
|
|
|
// 假设item有id和name两个属性,分别代表客户ID和客户编号 |
|
|
|
selectElement.append('<option value="' + item.customerId + '">' + item.customerId + '</option>'); |
|
|
|
}); |
|
|
|
} else { |
|
|
|
$.modal.errMsg("数据为空"); |
|
|
|
} |
|
|
|
}, |
|
|
|
// error: function(jqXHR, textStatus, errorThrown) { |
|
|
|
// console.error('Failed to fetch customer IDs: ' + textStatus + ', ' + errorThrown); |
|
|
|
// } |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//获取客户信息 |
|
|
|
$(document).ready(function() { |
|
|
|
// 初始化时默认加载客户编号列表 |
|
|
|
loadCustomerIds(); |
|
|
|
|
|
|
|
// 监听客户编号下拉框的变化 |
|
|
|
$('#enterpriseCode').on('change', function() { |
|
|
|
var selectedEnterpriseCode = $(this).val(); // 获取选中的客户ID |
|
|
|
if (selectedEnterpriseCode) { |
|
|
|
// 发起Ajax请求获取客户名称 |
|
|
|
$.ajax({ |
|
|
|
type: 'GET', |
|
|
|
url: ctx +'system/customer/getCustomerNameByEnterpriseCode/' + selectedEnterpriseCode, // 替换为你的实际API路径 |
|
|
|
dataType: 'json', // 假设返回的数据格式是JSON |
|
|
|
success: function(data) { |
|
|
|
console.log(data); |
|
|
|
// 将获取到的客户名称填充到输入框 |
|
|
|
if(data.data == null){ |
|
|
|
// 如果返回的数据有问题,可以给出提示或处理 |
|
|
|
$.modal.msgError("未能获取到客户名称!"); |
|
|
|
} |
|
|
|
$('input[name="enterpriseName"]').val(data.data.customerName); |
|
|
|
}, |
|
|
|
error: function(jqXHR, textStatus, errorThrown) { |
|
|
|
console.error('Error:', textStatus, errorThrown); |
|
|
|
$.modal.msgError("查询客户名称时发生错误!"); |
|
|
|
} |
|
|
|
}); |
|
|
|
} else { |
|
|
|
// 如果没有选择客户ID,清空客户名称输入框 |
|
|
|
$('input[name="enterpriseName"]').val(''); |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
</script> |
|
|
|
</body> |
|
|
|