|
|
@ -1,13 +1,16 @@ |
|
|
|
<!DOCTYPE html> |
|
|
|
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.w3.org/1999/xhtml"> |
|
|
|
<head> |
|
|
|
<th:block th:include="include :: header('详情客户报价')" /> |
|
|
|
<th:block th:include="include :: header('新增客户报价')" /> |
|
|
|
<th:block th:include="include :: select2-css" /> |
|
|
|
<th:block th:include="include :: bootstrap-editable-css" /> |
|
|
|
<th:block th:include="include :: datetimepicker-css" /> |
|
|
|
<link th:href="@{/ajax/libs/select2/select2.css}" rel="stylesheet"> |
|
|
|
<link th:href="@{/ajax/libs/select2/select2-bootstrap.css}" rel="stylesheet"> |
|
|
|
</head> |
|
|
|
<body class="white-bg"> |
|
|
|
<div class="wrapper wrapper-content animated fadeInRight ibox-content"> |
|
|
|
<form class="form-horizontal m" id="form-customerQuote-detail" th:object="${sysCustomerQuote}"> |
|
|
|
<form class="form-horizontal m" id="form-customerQuote-detail" th:object="${sysCustomerQuote}" > |
|
|
|
<div class="form-group" hidden="hidden"> |
|
|
|
<div class="form-group" hidden="hidden"> |
|
|
|
<label class="col-sm-4 control-label">客户报价ID:</label> |
|
|
@ -15,8 +18,6 @@ |
|
|
|
<input name="id" th:field="*{id}" class="form-control" type="number" readonly> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-4 control-label">客户报价编号:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<input name="supplierCode" th:field="*{supplierCode}" class="form-control" type="text" readonly> |
|
|
@ -25,110 +26,106 @@ |
|
|
|
<div class="form-group" shiro:hasPermission="system:customerQuote:edit"> |
|
|
|
<label class="col-sm-4 control-label">业务员:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<select disabled class="form-control" name="businessMembers" required th:field="*{businessMembers}"> |
|
|
|
<option value="">请选择</option> |
|
|
|
</select> |
|
|
|
<!-- <select class="form-control" name="businessMembers" required>--> |
|
|
|
<!-- <option value="">请选择</option>--> |
|
|
|
<!-- </select>--> |
|
|
|
<input name="businessMembers" class="form-control" type="text" readonly> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-4 control-label">客户编号:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<input class="form-control" th:field="*{customerCode}" name="customerCode" required readonly /> |
|
|
|
<input id="customerCode" readonly class="form-control" th:field="*{customerCode}" name="customerCode" > |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-4 control-label">客户名称:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<input name="customerName" th:field="*{customerName}" class="form-control m-b" type="text" readonly /> |
|
|
|
<input name="customerName" th:field="*{customerName}" class="form-control" type="text" readonly> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="form-group"> |
|
|
|
|
|
|
|
<div class="form-group" id="commonCurrency"> |
|
|
|
<label class="col-sm-4 control-label">报价币种:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<select disabled class="form-control" id="commonCurrency_edit" name="commonCurrency" th:with="dictList=${@dict.getType('sys_common_currency')}" th:field="*{commonCurrency}" required> |
|
|
|
<select class="form-control" id="commonCurrency_add" name="commonCurrency" th:with="dictList=${@dict.getType('sys_common_currency')}" th:field="*{commonCurrency}" disabled> |
|
|
|
<option value="">请选择</option> |
|
|
|
<option th:each="dict : ${dictList}" th:value="${dict.dictValue}" th:text="${dict.dictLabel}" ></option> |
|
|
|
<option th:each="dict : ${dictList}" th:value="${dict.dictValue}" th:text="${dict.dictLabel}"></option> |
|
|
|
</select> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-4 control-label">美元汇率:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<input name="usdTax" th:field="*{usdTax}" id="usdTax_edit" class="form-control" type="number" placeholder="当前未配置美元汇率,请联系总经理" readonly> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-4 control-label is-required">是否含税:</label> |
|
|
|
<label class="col-sm-4 control-label ">是否含税:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<div class="radio-box" th:each="dict : ${@dict.getType('sys_confirm_tax')}"> |
|
|
|
<input required type="radio" th:id="${'confirmTax_' + dict.dictCode}" |
|
|
|
name="confirmTax" th:value="${dict.dictValue}" th:field="*{confirmTax}" th:checked="${dict.isDefault == 'Y' ? true : false}" disabled> |
|
|
|
<input disabled type="radio" th:id="${'confirmTax_' + dict.dictCode}" |
|
|
|
name="confirmTax" th:value="${dict.dictValue}" th:field="*{confirmTax}" th:checked="${dict.isDefault == 'Y' ? true : false}"> |
|
|
|
<label th:for="${'confirmTax_' + dict.dictCode}" th:text="${dict.dictLabel}"></label> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-4 control-label">国内税率:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<div class="input-group"> |
|
|
|
<input name="rmbTax" id="rmbTax_edit" th:field="*{rmbTax}" class="form-control" placeholder="13" disabled/> |
|
|
|
<span class="input-group-addon">%</span> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-4 control-label">订价日期:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<div class="input-group date"> |
|
|
|
<input name="pricingDate" th:field="*{pricingDate}" class="form-control" type="text" disabled> |
|
|
|
<span class="input-group-addon " disabled><i class="fa fa-calendar"></i></span> |
|
|
|
<input name="pricingDate" th:field="*{pricingDate}" class="form-control" placeholder="yyyy-MM-dd" type="text" readonly> |
|
|
|
<span class="input-group-addon"><i class="fa fa-calendar"></i></span> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-4 control-label">备注说明:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<textarea readonly name="remark" th:text="*{remark}" class="form-control"></textarea> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<textarea name="remark" class="form-control" th:text="*{remark}" readonly></textarea> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
<div class="container" style="display: none;"> |
|
|
|
<h4 class="form-header h4">计算</h4> |
|
|
|
<div class="col-xs-12 form-row"> |
|
|
|
<label class="col-sm-2">物料合计:</label><input class="col-sm-4" name="enterprise" id="enterprise_detail" th:field="*{enterprise}" type="text" disabled/> |
|
|
|
<label class="col-sm-2">数量合计:</label><input class="col-sm-4" name="enterpriseSum" id="enterpriseSum_detail" th:field="*{enterpriseSum}" type="number" disabled/> |
|
|
|
<label class=" col-sm-2">物料合计:</label><input class="col-sm-4" name="enterprise" id="enterprise_edit" type="text" readonly/> |
|
|
|
<label class=" col-sm-2">数量合计:</label><input class="col-sm-4" name="enterpriseSum" id="enterpriseSum_edit" type="number" readonly/> |
|
|
|
</div> |
|
|
|
<div class="col-xs-12 form-row"> |
|
|
|
<label class="col-sm-2">不含税单价:</label><input placeholder="RMB" class="col-sm-4" name="noRmb" id="noRmb_detail" th:field="*{noRmb}" type="number" disabled /> |
|
|
|
<label class="col-sm-2">不含税总价:</label><input placeholder="RMB" class="col-sm-4" name="noRmbSum" id="noRmbSum_detail" th:field="*{noRmbSum}" type="number" disabled/> |
|
|
|
<label class="col-sm-2"> 不含税单价:</label><input placeholder="RMB" class="col-sm-4" name="noRmb" id="noRmb_edit" type="number" readonly/> |
|
|
|
<label class="col-sm-2"> 不含税总价:</label><input placeholder="RMB" class="col-sm-4" name="noRmbSum" id="noRmbSum_edit" type="number" readonly/> |
|
|
|
</div> |
|
|
|
<div class="col-xs-12 form-row"> |
|
|
|
<label class="col-sm-2">含税单价:</label><input placeholder="RMB" class="col-sm-4" name="rmb" id="rmb_detail" type="number" th:field="*{rmb}" disabled/> |
|
|
|
<label class="col-sm-2">含税总价:</label><input placeholder="RMB" class="col-sm-4" name="rmbSum" id="rmbSum_detail" th:field="*{rmbSum}" type="number" disabled/> |
|
|
|
<label class="col-sm-2"> 含税单价:</label><input placeholder="RMB" class="col-sm-4" name="rmb" id="rmb_edit" type="number" readonly/> |
|
|
|
<label class="col-sm-2"> 含税总价:</label><input placeholder="RMB" class="col-sm-4" name="rmbSum" id="rmbSum_edit" type="number" readonly/> |
|
|
|
</div> |
|
|
|
<div class="col-xs-12 form-row"> |
|
|
|
<label class="col-sm-2">不含税单价:</label><input placeholder="美元" class="col-sm-4" name="noUsd" id="noUsd_detail" th:field="*{noUsd}" type="number" disabled/> |
|
|
|
<label class="col-sm-2">不含税总价:</label><input placeholder="美元" class="col-sm-4" name="noUsdSum" id="noUsdSum_detail" th:field="*{noUsdSum}" type="number" disabled/> |
|
|
|
<div class="col-xs-12"> |
|
|
|
<label class="col-sm-2">不含税单价:</label><input placeholder="美元" class="col-sm-4" name="noUsd" id="noUsd_edit" type="number" readonly/> |
|
|
|
<label class="col-sm-2">不含税总价:</label><input placeholder="美元" class="col-sm-4" name="noUsdSum" id="noUsdSum_edit" type="number" readonly/> |
|
|
|
</div> |
|
|
|
<div class="col-xs-12 form-row"> |
|
|
|
<label class="col-sm-2">含税单价:</label><input placeholder="美元" class="col-sm-4" name="usd" id="usd_detail" th:field="*{usd}" type="number" disabled/> |
|
|
|
<label class="col-sm-2">含税总价:</label><input placeholder="美元" class="col-sm-4" name="usdSum" id="usdSum_detail" th:field="*{usdSum}" type="number" disabled/> |
|
|
|
<div class="col-xs-12"> |
|
|
|
<label class="col-sm-2">含税单价:</label><input placeholder="美元" class="col-sm-4" name="usd" id="usd_edit" type="number" readonly/> |
|
|
|
<label class="col-sm-2">含税总价:</label><input placeholder="美元" class="col-sm-4" name="usdSum" id="usdSum_edit" type="number" readonly/> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="container"> |
|
|
|
<div class="form-row"> |
|
|
|
<div class="btn-group-sm" id="toolbar" role="group"> |
|
|
|
<span>选择报价信息</span> |
|
|
|
</div> |
|
|
|
|
|
|
|
</form> |
|
|
|
|
|
|
|
|
|
|
|
<div class="container"> |
|
|
|
<div class="form-row"> |
|
|
|
<div class="btn-group-sm" id="toolbar" role="group"> |
|
|
|
<span>选择报价信息</span> |
|
|
|
<a class="btn btn-success" onclick="insertRow()"> |
|
|
|
<i class="fa fa-plus"></i> 添加物料 |
|
|
|
</a> |
|
|
|
<!-- <a class="btn btn-danger multiple" onclick="insertNoMaterialNoRow()">--> |
|
|
|
<!-- <i class="fa fa-remove"></i> 添加无料号物料--> |
|
|
|
<!-- </a>--> |
|
|
|
</div> |
|
|
|
<div class="row"> |
|
|
|
<div class="col-sm-12 select-table table-striped"> |
|
|
|
<table id="bootstrap-table-Quote-child-detail"></table> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="row"> |
|
|
|
<div class="col-sm-12 select-table table-striped"> |
|
|
|
<table id="bootstrap-sub-table-quoteChild"></table> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
</form> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<th:block th:include="include :: footer" /> |
|
|
|
<th:block th:include="include :: bootstrap-table-editable-js" /> |
|
|
@ -140,52 +137,170 @@ |
|
|
|
var sysUnitClassDatas = [[${@dict.getType('sys_unit_class')}]]; |
|
|
|
var processMethodDatas = [[${@dict.getType('processMethod')}]]; |
|
|
|
var userName = [[${@permission.getPrincipalProperty('userName')}]]; |
|
|
|
var loginName = [[${@permission.getPrincipalProperty('loginName')}]]; |
|
|
|
var prefix = ctx + "system/customerQuote"; |
|
|
|
|
|
|
|
var sysCustomerQuote = [[${sysCustomerQuote}]]; |
|
|
|
var prefix = ctx + "system/customerQuote" |
|
|
|
var commonCurrency = $("#commonCurrency_edit option:selected").val(); |
|
|
|
$("#form-customerQuote-edit").validate({focusCleanup: true}); |
|
|
|
//计算 |
|
|
|
$("#form-customerQuote-detail").validate({ |
|
|
|
focusCleanup: true, |
|
|
|
}); |
|
|
|
var customerCode1 = [[${sysCustomerQuote.customerCode}]]; |
|
|
|
|
|
|
|
|
|
|
|
var commonCurrency = $("#commonCurrency_add option:selected").val(); |
|
|
|
$("#form-customerQuote-detail").validate( |
|
|
|
{ |
|
|
|
focusCleanup: true} |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
// 监听客户编号下拉框的变化 |
|
|
|
$('#customerCode').on('change', function() { |
|
|
|
var selectedCustomerCode = $(this).val(); // 获取选中的客户ID |
|
|
|
if (selectedCustomerCode) { |
|
|
|
// 发起Ajax请求获取客户名称 |
|
|
|
$.ajax({ |
|
|
|
type: 'GET', |
|
|
|
url: ctx +'system/customer/getCustomerNameByEnterpriseCode/' + selectedCustomerCode, // 替换为你的实际API路径 |
|
|
|
dataType: 'json', // 假设返回的数据格式是JSON |
|
|
|
success: function(data) { |
|
|
|
console.log(data); |
|
|
|
// 将获取到的客户名称填充到输入框 |
|
|
|
if(data.data == null){ |
|
|
|
// 如果返回的数据有问题,可以给出提示或处理 |
|
|
|
$.modal.alertWarning('未能获取到客户名称!'); |
|
|
|
} |
|
|
|
$('input[name="customerName"]').val(data.data.customerName); |
|
|
|
$("input[name='rmbTax']").val(data.data.taxRate); |
|
|
|
// 根据data.data.confirmTax的值(0或1)来选中对应的单选按钮 |
|
|
|
// if(data.data.confirmTax === '0' || data.data.confirmTax === '1') { |
|
|
|
// console.log("data.data.confirmTax:",data.data.confirmTax) |
|
|
|
// $('input:radio[name="confirmTax"][value="' + data.data.confirmTax + '"]').attr('checked', "checked"); |
|
|
|
// } else { |
|
|
|
// // 如果返回的值不是预期的0或1,可处理异常情况 |
|
|
|
// console.warn("Unexpected confirmTax value:", data.data.confirmTax); |
|
|
|
// } |
|
|
|
|
|
|
|
if (data.data.commonCurrency == '1'){ |
|
|
|
$('input:radio[name="confirmTax"][value="1"]').prop('checked', true); |
|
|
|
}else { |
|
|
|
$('input:radio[name="confirmTax"][value="0"]').prop('checked', true); |
|
|
|
} |
|
|
|
|
|
|
|
$("#commonCurrency_add").val(data.data.commonCurrency).trigger('change'); |
|
|
|
commonCurrency = $("#commonCurrency_add option:selected").val(); |
|
|
|
}, |
|
|
|
error: function(jqXHR, textStatus, errorThrown) { |
|
|
|
console.error('Error:', textStatus, errorThrown); |
|
|
|
$.modal.alertWarning('查询客户名称时发生错误!'); |
|
|
|
} |
|
|
|
}); |
|
|
|
} else { |
|
|
|
// 如果没有选择客户ID,清空客户名称输入框 |
|
|
|
$('input[name="customerName"]').val(''); |
|
|
|
} |
|
|
|
}); |
|
|
|
$(document).ready(function() { |
|
|
|
// 初始化时默认加载客户编号列表 |
|
|
|
loadCustomerIds(); |
|
|
|
}); |
|
|
|
// 假设的加载客户编号列表函数 |
|
|
|
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 = $('#customerCode'); // 获取客户编号下拉框元素 |
|
|
|
// 清空下拉框现有选项 |
|
|
|
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>'); |
|
|
|
}); |
|
|
|
// $('#customerCode').val(customerId); |
|
|
|
} else { |
|
|
|
$.modal.errMsg("数据为空"); |
|
|
|
} |
|
|
|
}, |
|
|
|
error: function(jqXHR, textStatus, errorThrown) { |
|
|
|
console.error('Failed to fetch customer IDs: ' + textStatus + ', ' + errorThrown); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
//添加收款明细 |
|
|
|
function insertNoMaterialNoRow() { |
|
|
|
// 生成一个简单的唯一标识,这里使用时间戳作为示例 |
|
|
|
var uniqueId = new Date().getTime(); |
|
|
|
// 创建一个新行数据模板,这里仅为示例,具体根据表格列来定义 |
|
|
|
var newRow = { |
|
|
|
materialId:uniqueId, |
|
|
|
materialCode: "", |
|
|
|
materialName: "", |
|
|
|
materialType: "", |
|
|
|
describe: "", |
|
|
|
brand: "", |
|
|
|
unit: "", |
|
|
|
processMethod: "", |
|
|
|
photoUrl: "", |
|
|
|
}; |
|
|
|
|
|
|
|
// 使用Bootstrap Table的API插入新行 |
|
|
|
$('#bootstrap-sub-table-quoteChild').bootstrapTable('append', newRow); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$(function() { |
|
|
|
// console.log(loginName); |
|
|
|
$("#form-customerQuote-detail input[name='businessMembers']").val(loginName); |
|
|
|
var options = { |
|
|
|
id: "bootstrap-table-Quote-child-detail", |
|
|
|
id:'bootstrap-sub-table-quoteChild', |
|
|
|
url: ctx + "system/quoteChild/list", |
|
|
|
queryParams: queryParams, |
|
|
|
showColumns: false, |
|
|
|
pagination: false, |
|
|
|
sidePagination: "client", |
|
|
|
clickToSelect: true, |
|
|
|
showExport: true, |
|
|
|
showSearch: false, |
|
|
|
showRefresh: false, |
|
|
|
showToggle: false, |
|
|
|
showColumns: false, |
|
|
|
showPaginationSwitch: false, |
|
|
|
showRefresh:false, |
|
|
|
showSearch:false, |
|
|
|
sidePagination: "client", |
|
|
|
model: "物料报价信息", |
|
|
|
columns: [ |
|
|
|
{checkbox: true}, |
|
|
|
{title: '序号',align: 'center', |
|
|
|
{field: 'index',align: 'center', title: "序号", |
|
|
|
formatter: function (value, row, index) { |
|
|
|
return $.table.serialNumber(index); |
|
|
|
var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index)); |
|
|
|
return columnIndex + $.table.serialNumber(index); |
|
|
|
} |
|
|
|
}, |
|
|
|
{title: '报价子表id',field: 'id',align: 'center',visible: false}, |
|
|
|
{title: '物料报价主表id',field: 'quoteId',align: 'center',visible: false}, |
|
|
|
{title: '物料索引',field: 'materialId',align: 'center',visible: false}, |
|
|
|
{title: '物料索引id',field: 'materialId',align: 'center',visible: false}, |
|
|
|
{title: '料号',field: 'materialCode',align: 'center'}, |
|
|
|
{title: '物料名称',field: 'materialName',align: 'center'}, |
|
|
|
{title: '图片',field: 'photoUrl', |
|
|
|
formatter: function(value, row, index) { |
|
|
|
if(value == null || value == ""){ |
|
|
|
value = ""; |
|
|
|
return "<img src='' herf='' />"; |
|
|
|
} |
|
|
|
return $.table.imageView(value); |
|
|
|
} |
|
|
|
}, |
|
|
|
{title: '物料类型',field: 'materialType',align: 'center', |
|
|
|
formatter: function(value, row, index) { |
|
|
|
$.table.selectCategoryLabel(materialTypeDatas, value); |
|
|
|
return $.table.selectCategoryLabel(materialTypeDatas, value); |
|
|
|
} |
|
|
|
}, |
|
|
|
{ title: '描述',field: 'describe',align: 'center'}, |
|
|
|
{title: '型号',field: 'materialModel',align: 'center'}, |
|
|
|
{title: '品牌',field: 'brand',align: 'center'}, |
|
|
|
{ |
|
|
|
title: '图片', field: 'photoUrl', align: 'center', |
|
|
|
formatter: function (value, row, index) { |
|
|
|
return $.table.imageView(value); |
|
|
|
} |
|
|
|
}, |
|
|
|
{ title: '单位',field: 'unit',align: 'center', |
|
|
|
formatter: function(value, row, index) { |
|
|
|
return $.table.selectDictLabel(sysUnitClassDatas, value); |
|
|
@ -196,8 +311,7 @@ |
|
|
|
return $.table.selectDictLabel(processMethodDatas, value); |
|
|
|
} |
|
|
|
}, |
|
|
|
// { title: '对外售价',field: 'materialSole', |
|
|
|
// }, |
|
|
|
|
|
|
|
{ title: '最新报价(RMB)',field: 'recentQuotationRMB',align: 'center',}, |
|
|
|
{ title: '最新报价(美元)',field: 'recentQuotationUSD',align: 'center',}, |
|
|
|
{ title: '最新报价历史',align: 'center', |
|
|
@ -208,109 +322,379 @@ |
|
|
|
return actions.join(''); |
|
|
|
} |
|
|
|
}, |
|
|
|
// {title: '国内税率',field: 'countTax',align: 'center',}, |
|
|
|
// { title: '美元汇率',field: 'usdTax', align: 'center',}, |
|
|
|
{field: 'materialNum',align: 'center',title: '物料的数量', |
|
|
|
{title: '物料的数量',field: 'materialNum',align: 'center', |
|
|
|
editable:{ |
|
|
|
type : 'text', |
|
|
|
mode: 'inline', |
|
|
|
title : '物料的数量', |
|
|
|
validate : function(value) { |
|
|
|
if (!value) { |
|
|
|
return '用量不能为空'; |
|
|
|
} |
|
|
|
if (isNaN(value)) { |
|
|
|
return '用量必须为数字'; |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ title: '物料的不含税单价(RMB)', |
|
|
|
field: 'materialNoRmb', |
|
|
|
align: 'center', |
|
|
|
editable:{ |
|
|
|
type: 'text', // 使用'text'类型,因为我们需自定义验证小数 |
|
|
|
mode: 'inline', |
|
|
|
enabled: function() { |
|
|
|
return ($("#commonCurrency_add").val() === '1'); // 当货币类型为2时启用 |
|
|
|
}, |
|
|
|
title: '物料的不含税单价(RMB)', |
|
|
|
validate: function(value) { |
|
|
|
// 验证是否为空 |
|
|
|
if (!value) { |
|
|
|
return '金额不能为空'; |
|
|
|
} |
|
|
|
// 尝试转换为浮点数并检查是否成功 |
|
|
|
var num = parseFloat(value); |
|
|
|
if (isNaN(num)) { |
|
|
|
return '请输入有效的数字'; |
|
|
|
} |
|
|
|
// 检查小数点后是否有超过两位的数字 |
|
|
|
var decimalPart = num.toString().split('.')[1]; // 获取小数部分 |
|
|
|
if (decimalPart && decimalPart.length > 2) { |
|
|
|
return '请输入精确到小数点后两位的数字'; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
{ title: '物料的含税单价(RMB)',field: 'materialRmb',align: 'center',}, |
|
|
|
{title: '物料的不含税总价(RMB)',field: 'materialNoRmbSum',align: 'center',}, |
|
|
|
{ title: '物料的含税总价(RMB)',field: 'materialRmbSum',align: 'center',}, |
|
|
|
{title: '物料的不含税单价(美元)', |
|
|
|
field: 'materialNoUsd', |
|
|
|
align: 'center', |
|
|
|
editable: { |
|
|
|
type: 'text', // 使用'text'类型,因为我们需自定义验证小数 |
|
|
|
mode: 'inline', |
|
|
|
enabled: function() { |
|
|
|
return ($("#commonCurrency_add").val() === '2'); // 当货币类型为2时启用 |
|
|
|
}, |
|
|
|
title: '物料的不含税单价(美元)', |
|
|
|
validate: function(value) { |
|
|
|
// 验证是否为空 |
|
|
|
if (!value) { |
|
|
|
return '金额不能为空'; |
|
|
|
} |
|
|
|
// 尝试转换为浮点数并检查是否成功 |
|
|
|
var num = parseFloat(value); |
|
|
|
if (isNaN(num)) { |
|
|
|
return '请输入有效的数字'; |
|
|
|
} |
|
|
|
// 检查小数点后是否有超过两位的数字 |
|
|
|
var decimalPart = num.toString().split('.')[1]; // 获取小数部分 |
|
|
|
if (decimalPart && decimalPart.length > 2) { |
|
|
|
return '请输入精确到小数点后两位的数字'; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
{title: '物料的含税单价(RMB)',field: 'materialRmb',align: 'center'}, |
|
|
|
{title: '物料的含税总价(RMB)',field: 'materialNoRmbSum',align: 'center'}, |
|
|
|
{title: '物料的不含税总价(RMB)',field: 'materialRmbSum',align: 'center'}, |
|
|
|
{title: '物料的含税单价(美元)',field: 'materialUsd',align: 'center'}, |
|
|
|
{title: '物料的含税总价(美元)',field: 'materialUsdSum',align: 'center'}, |
|
|
|
{title: '物料的不含税总价(美元)', field: 'materialNoUsdSum',align: 'center'}, |
|
|
|
{ title: '物料的含税单价(美元)',field: 'materialUsd',align: 'center',}, |
|
|
|
{ title: '物料的含税总价(美元)',field: 'materialUsdSum', align: 'center',}, |
|
|
|
{ title: '物料的不含税总价(美元)',field: 'materialNoUsdSum',align: 'center',}, |
|
|
|
{field: 'createBy', align: 'center',title: '录入人',visible: false}, |
|
|
|
{field: 'createTime',align: 'center',title: '录入时间',visible: false}, |
|
|
|
{field: 'updateBy',align: 'center',title: '更新人',visible: false}, |
|
|
|
{field: 'updateTime',align: 'center',title: '上次更新时间',visible: false}, |
|
|
|
{field: 'remark',align: 'center',title: '备注',visible: false}, |
|
|
|
{field: 'auditStatus',align: 'center',title: '审核状态',visible: false, |
|
|
|
formatter: function(value, row, index) {return $.table.selectDictLabel(auditStatusDatas, value);} |
|
|
|
}, |
|
|
|
|
|
|
|
{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.materialCode + '\')"><i class="fa fa-remove"></i>删除</a> '); |
|
|
|
return actions.join(''); |
|
|
|
} |
|
|
|
} |
|
|
|
], |
|
|
|
onEditableSave:function(field, row, oldValue, $el){ |
|
|
|
commonCurrency = $("#commonCurrency_edit option:selected").val(); |
|
|
|
var rmb1 = $("#rmbTax_edit").val(); |
|
|
|
if (rmb1 =='' || rmb1== null){ |
|
|
|
rmb1 = 0; |
|
|
|
}else{ |
|
|
|
rmb1 = $("#rmbTax_edit").val(); |
|
|
|
} |
|
|
|
var rmb = Number(rmb1).toFixed(2) / 100; |
|
|
|
var usd = $("#usdTax_edit").val(); |
|
|
|
if (usd =='' || usd== null){ |
|
|
|
usd = 0; |
|
|
|
}else{ |
|
|
|
usd = Number(usd).toFixed(2); |
|
|
|
} |
|
|
|
console.log(commonCurrency); |
|
|
|
if(commonCurrency == 1){ |
|
|
|
row.materialRmb = Number(row.materialNoRmb * (1 + rmb)).toFixed(2); |
|
|
|
row.materialNoUsd = Number(row.materialNoRmb / rmb).toFixed(2); |
|
|
|
row.materialNoUsdSum = Number(row.materialNum * row.materialNoUsd).toFixed(2); |
|
|
|
row.materialUsd = Number(usd * row.materialNoUsd).toFixed(2); |
|
|
|
row.materialUsdSum = Number(row.materialNum * row.materialUsd).toFixed(2); |
|
|
|
row.materialNoRmbSum = Number(row.materialNum* row.materialNoRmb).toFixed(2); |
|
|
|
var commonCurrency1 = $("#commonCurrency_add option:selected").val(); |
|
|
|
var rmbRateInput = parseFloat($("#rmbTax_add").val()) || 0; |
|
|
|
var rmbRate = rmbRateInput / 100; |
|
|
|
rmbRate = parseFloat(rmbRate.toFixed(2)); // 确保rmbRate转换为两位小数的浮点数 |
|
|
|
var usdRate = parseFloat($("#usdTax_add").val()) || 0; |
|
|
|
|
|
|
|
var testMaterialNum = parseFloat(row.materialNum) || 0; |
|
|
|
if (commonCurrency1 === '1') { |
|
|
|
// RMB为基准货币 |
|
|
|
row.materialRmb = (parseFloat(row.materialNoRmb) * (1 + rmbRate)).toFixed(2); |
|
|
|
row.materialRmbSum = (parseFloat(row.materialRmb) * testMaterialNum).toFixed(2); |
|
|
|
row.materialNoRmbSum = (parseFloat(row.materialNoRmb) * testMaterialNum).toFixed(2); |
|
|
|
} else if (commonCurrency1 === '2') { |
|
|
|
// USD为基准货币 |
|
|
|
row.materialUsd = row.materialNoUsd |
|
|
|
row.materialUsdSum = (parseFloat(row.materialUsd) * testMaterialNum).toFixed(2); |
|
|
|
row.materialNoUsdSum = (parseFloat(row.materialNoUsd) * testMaterialNum).toFixed(2); |
|
|
|
} |
|
|
|
else if( commonCurrency == 2){ |
|
|
|
row.materialUsd = Number(row.materialNoUsd).toFixed(2); |
|
|
|
row.materialUsdSum = Number(row.materialNum * row.materialUsd).toFixed(2); |
|
|
|
row.materialNoUsdSum = Number(row.materialNoUsd * row.materialNum).toFixed(2); |
|
|
|
row.materialNoRmb = Number(row.materialNoUsd).toFixed(2); |
|
|
|
row.materialRmb = usd * Number(row.materialNoUsd * (1 + rmb)).toFixed(2); |
|
|
|
row.materialNoRmbSum = Number(row.materialNoRmb * row.materialNum).toFixed(2); |
|
|
|
|
|
|
|
// 确保getTotalAmount函数存在且正确引用 |
|
|
|
if (typeof getTotalAmount === 'function') { |
|
|
|
getTotalAmount(); |
|
|
|
} |
|
|
|
getTotalAmount() |
|
|
|
}, |
|
|
|
}; |
|
|
|
$.table.init(options); |
|
|
|
function queryParams(params) { |
|
|
|
var curParams = { |
|
|
|
// 传递参数查询参数 |
|
|
|
pageSize: params.limit, |
|
|
|
pageNum: params.offset / params.limit + 1, |
|
|
|
quoteId: sysCustomerQuote.supplierCode, |
|
|
|
}; |
|
|
|
curParams.quoteId = sysCustomerQuote.supplierCode; |
|
|
|
return curParams; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 初始化表格 |
|
|
|
var bootstrapSubTableQuoteChild = $('#bootstrap-sub-table-quoteChild').bootstrapTable(options); |
|
|
|
// 添加编辑保存事件监听器 |
|
|
|
bootstrapSubTableQuoteChild.on('editable-save.bs.table', function(e, field, row, oldValue, $el) { |
|
|
|
var currencyVal = $("#commonCurrency_add").val(); |
|
|
|
var requiredField = (currencyVal === '1') ? 'materialNoRmb' : 'materialNoUsd'; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
// 初始化时也需要根据当前的货币类型设置一次 |
|
|
|
$("#commonCurrency_add").trigger('change'); |
|
|
|
}); |
|
|
|
function queryParams(params) { |
|
|
|
var curParams = { |
|
|
|
// 传递参数查询参数 |
|
|
|
pageSize: params.limit, |
|
|
|
pageNum: params.offset / params.limit + 1, |
|
|
|
quoteId: sysCustomerQuote.supplierCode, |
|
|
|
|
|
|
|
//监听币种的变化 |
|
|
|
$(document).ready(function() { |
|
|
|
$("#commonCurrency_add").on('change', function() { |
|
|
|
var selectedValue = $(this).val(); |
|
|
|
var $radioTax = $('input:radio[name="confirmTax"][value="1"]'); |
|
|
|
var $radioNo = $('input:radio[name="confirmTax"][value="0"]'); |
|
|
|
// 设置含税单选按钮选中 |
|
|
|
if(selectedValue ==="1"){ |
|
|
|
console.log("1:"+selectedValue); |
|
|
|
$radioNo.removeAttr('checked'); |
|
|
|
$radioTax.prop('checked','checked'); |
|
|
|
|
|
|
|
// $("input[name='confirmFax']").val(1); |
|
|
|
console.log($radioTax.prop('checked')); |
|
|
|
}else if(selectedValue ==="2"){ |
|
|
|
console.log("2:"+selectedValue); |
|
|
|
$radioTax.removeAttr('checked',false); |
|
|
|
$radioNo.prop('checked',true); |
|
|
|
// $radioTax.removeAttr('checked'); |
|
|
|
// $radioNo.attr('checked','checked'); |
|
|
|
console.log($radioNo.prop('checked')); |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
function getBusinessMembers(){ |
|
|
|
/*业务员列表*/ |
|
|
|
$.ajax({ |
|
|
|
url: ctx + 'system/salesOrder/getBinessMembers', |
|
|
|
type: 'get', |
|
|
|
success: function (res) { |
|
|
|
console.log(res) |
|
|
|
if (res.rows.length > 0) { |
|
|
|
var usertData = res.rows; |
|
|
|
//alert(JSON.stringify(data)); |
|
|
|
for (let i in usertData) { |
|
|
|
// console.log(finishProductData[i].finishProductCode) |
|
|
|
$("#form-customerQuote-detail select[name='businessMembers']").append( |
|
|
|
"<option value='" + usertData[i].loginName + "'>" + usertData[i].userName + "</option>"); |
|
|
|
} |
|
|
|
$("#form-customerQuote-detail select[name='businessMembers']").val(loginName).trigger("change"); |
|
|
|
} else { |
|
|
|
$.modal.msgError(res.msg); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//批量插入选择的物料 |
|
|
|
function doSubmit(index, layero, uniqueId) { |
|
|
|
console.log(uniqueId); |
|
|
|
var iframeWin = window[layero.find('iframe')[0]['name']]; |
|
|
|
var selectedRows = iframeWin.$('#bootstrap-select-table').bootstrapTable('getSelections'); |
|
|
|
|
|
|
|
if (selectedRows.length === 0) { |
|
|
|
$.modal.alertError("请选择至少一条物料信息"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
var existingData = $("#bootstrap-sub-table-quoteChild").bootstrapTable('getData'); |
|
|
|
var materialCodesSet = new Set(); // 使用Set来存储物料号 |
|
|
|
|
|
|
|
// 存储所有现有的物料号 |
|
|
|
existingData.forEach(function (row) { |
|
|
|
materialCodesSet.add(row.materialCode); |
|
|
|
}); |
|
|
|
|
|
|
|
// 存储所有即将插入的物料号 |
|
|
|
var newMaterialCodesSet = new Set(); |
|
|
|
|
|
|
|
var promises = selectedRows.map(rowData => { |
|
|
|
// 检查是否已经存在相同的物料 |
|
|
|
if (materialCodesSet.has(rowData.materialNo) || newMaterialCodesSet.has(rowData.materialNo)) { |
|
|
|
$.modal.alertError("不能选择已添加过的相同料号:" + rowData.materialNo); |
|
|
|
return Promise.reject("Duplicate material number: " + rowData.materialNo); |
|
|
|
} |
|
|
|
|
|
|
|
// 标记即将插入的物料号 |
|
|
|
newMaterialCodesSet.add(rowData.materialNo); |
|
|
|
|
|
|
|
return queryRecentQuotation(rowData.materialNo) |
|
|
|
.then(function (quotationData) { |
|
|
|
return { |
|
|
|
materialId: rowData.id, |
|
|
|
materialCode: rowData.materialNo, |
|
|
|
materialName: rowData.materialName, |
|
|
|
materialType: rowData.materialType, |
|
|
|
describe: rowData.describe, |
|
|
|
materialModel: rowData.materialModel, |
|
|
|
unit: rowData.unit, |
|
|
|
brand: rowData.brand, |
|
|
|
processMethod: rowData.processMethod, |
|
|
|
photoUrl: rowData.photoUrl, |
|
|
|
countTax: $("#rmbTax_add").val(), |
|
|
|
usdTax: $("#usdTax_add").val(), |
|
|
|
materialNum: "", |
|
|
|
// materialSole: "", |
|
|
|
recentQuotationRMB: quotationData.data.materialRmb || '', |
|
|
|
recentQuotationUSD: quotationData.data.materialUsd || '', |
|
|
|
materialRmb: "", |
|
|
|
materialNoRmb: "", |
|
|
|
materialNoUsd: "", |
|
|
|
materialUsd: "", |
|
|
|
materialUsdSum: "", |
|
|
|
materialNoUsdSum: "", |
|
|
|
materialNoRmbSum: "", |
|
|
|
materialRmbSum: "", |
|
|
|
createBy: "", |
|
|
|
createTime: "", |
|
|
|
updateBy: "", |
|
|
|
updateTime: "", |
|
|
|
remark: "", |
|
|
|
}; |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
// 使用Promise.all等待所有查询完成,并将结果直接存入 newRows |
|
|
|
Promise.all(promises) |
|
|
|
.then(function (newRows) { |
|
|
|
// 批量插入新行 |
|
|
|
newRows.forEach(function (row) { |
|
|
|
$("#bootstrap-sub-table-quoteChild").bootstrapTable('insertRow', { index: 1, row: row }); |
|
|
|
}); |
|
|
|
|
|
|
|
layer.close(index); |
|
|
|
}) |
|
|
|
.catch(function (error) { |
|
|
|
console.error('Some requests failed:', error); |
|
|
|
layer.close(index); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
// 查找最新的报价数据 |
|
|
|
function queryRecentQuotation(materialNo) { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
// 使用AJAX请求从服务器获取最近的报价信息 |
|
|
|
$.ajax({ |
|
|
|
url: prefix + '/queryLatestRecentQuotation', |
|
|
|
type: 'GET', |
|
|
|
data: { materialNo: materialNo, customerCode: $("#customerCode").val() }, |
|
|
|
success: function (data) { |
|
|
|
resolve(data); // 成功时解析数据 |
|
|
|
}, |
|
|
|
error: function (jqXHR, textStatus, errorThrown) { |
|
|
|
reject(new Error('查找最新报价数据失败')); // 失败时抛出错误 |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function insertRow() { |
|
|
|
var url = ctx + "erp/material/select"; |
|
|
|
var options = { |
|
|
|
title: '选择料号', |
|
|
|
url: url, |
|
|
|
callBack: doSubmit |
|
|
|
}; |
|
|
|
curParams.quoteId = sysCustomerQuote.supplierCode; |
|
|
|
return curParams; |
|
|
|
$.modal.openOptions(options); |
|
|
|
} |
|
|
|
/* 删除指定表格行 */ |
|
|
|
function removeRow(materialCode){ |
|
|
|
$("#bootstrap-sub-table-quoteChild").bootstrapTable('remove', { |
|
|
|
field: 'materialCode', |
|
|
|
values: materialCode |
|
|
|
}); |
|
|
|
getTotalAmount(); |
|
|
|
} |
|
|
|
$("input[name='pricingDate']").datetimepicker({ |
|
|
|
format: "yyyy-mm-dd", |
|
|
|
minView: "month", |
|
|
|
autoclose: true |
|
|
|
}); |
|
|
|
function getTotalAmount() { |
|
|
|
var getData = $("#bootstrap-sub-table-quoteChild").bootstrapTable('getData'); |
|
|
|
var enterprise = 0; |
|
|
|
var enterpriseSum = 0; |
|
|
|
var noRmb = 0; |
|
|
|
var rmb = 0; |
|
|
|
var noRmbSum = 0; |
|
|
|
var rmbSum = 0; |
|
|
|
var noUsd = 0; |
|
|
|
var usd = 0; |
|
|
|
var noUsdSum = 0; |
|
|
|
var usdSum = 0; |
|
|
|
|
|
|
|
// 计算企业数量和物料数量总和 |
|
|
|
enterprise = getData.length; // 直接获取数据长度 |
|
|
|
enterpriseSum = getData.reduce((sum, item) => sum + (parseInt(item.materialNum) || 0), 0); |
|
|
|
|
|
|
|
function getTotalAmount(){ |
|
|
|
// $("#addFinishbomTable").bootstrapTable('refresh'); |
|
|
|
let getData = $("#bootstrap-table-Quote-child-detail").bootstrapTable('getData', true); |
|
|
|
var enterprise = "";let enterpriseSum = 0; let noRmb = 0; |
|
|
|
let rmb = 0;let noRmbSum = 0;let rmbSum = 0;let noUsd = 0; |
|
|
|
let usd = 0;let noUsdSum = 0; let usdSum = 0; |
|
|
|
for(let i=0;i<getData.length;i++){ |
|
|
|
enterprise += getData[i].materialName + ": 数量 :" + getData[i].materialNum +"; "; |
|
|
|
enterpriseSum += Number(getData[i].materialNum); |
|
|
|
noRmb += Number(getData[i].materialNoRmb); |
|
|
|
rmb += Number(getData[i].materialRmb) ; |
|
|
|
noRmbSum += Number(getData[i].materialNoRmbSum); |
|
|
|
rmbSum += Number(getData[i].materialRmbSum); |
|
|
|
noUsd += Number(getData[i].materialNoUsd) ; |
|
|
|
usd += Number(getData[i].materialUsd) ; |
|
|
|
noUsdSum += Number(getData[i].materialNoUsdSum); |
|
|
|
usdSum += Number(getData[i].materialUsdSum); |
|
|
|
// 先累加数值,toFixed在累加后应用以避免精度损失 |
|
|
|
for (let i = 0; i < getData.length; i++) { |
|
|
|
noRmb += parseFloat(getData[i].materialNoRmb) || 0; |
|
|
|
rmb += parseFloat(getData[i].materialRmb) || 0; |
|
|
|
noRmbSum += parseFloat(getData[i].materialNoRmbSum) || 0; |
|
|
|
rmbSum += parseFloat(getData[i].materialRmbSum) || 0; |
|
|
|
noUsd += parseFloat(getData[i].materialNoUsd) || 0; |
|
|
|
usd += parseFloat(getData[i].materialUsd) || 0; |
|
|
|
noUsdSum += parseFloat(getData[i].materialNoUsdSum) || 0; |
|
|
|
usdSum += parseFloat(getData[i].materialUsdSum) || 0; |
|
|
|
} |
|
|
|
$("#enterprise_detail").val(enterprise); |
|
|
|
$("#enterpriseSum_detail").val(enterpriseSum); |
|
|
|
$("#noRmb_detail").val(noRmb); |
|
|
|
$("#rmb_detail").val(rmb); |
|
|
|
$("#noRmbSum_detail").val(noRmbSum); |
|
|
|
$("#rmbSum_detail").val(rmbSum); |
|
|
|
$("#noUsd_detail").val(noUsd); |
|
|
|
$("#usd_detail").val(usd); |
|
|
|
$("#noUsdSum_detail").val(noUsdSum); |
|
|
|
$("#usdSum_detail").val(usdSum); |
|
|
|
|
|
|
|
// 将累加的结果格式化为两位小数 |
|
|
|
noRmb = noRmb.toFixed(2); |
|
|
|
rmb = rmb.toFixed(2); |
|
|
|
noRmbSum = noRmbSum.toFixed(2); |
|
|
|
rmbSum = rmbSum.toFixed(2); |
|
|
|
noUsd = noUsd.toFixed(2); |
|
|
|
usd = usd.toFixed(2); |
|
|
|
noUsdSum = noUsdSum.toFixed(2); |
|
|
|
usdSum = usdSum.toFixed(2); |
|
|
|
|
|
|
|
// 设置表单输入值 |
|
|
|
$("input[name='enterprise']").val(enterprise); |
|
|
|
$("input[name='enterpriseSum']").val(enterpriseSum); |
|
|
|
$("input[name='noRmb']").val(noRmb); |
|
|
|
$("input[name='noRmbSum']").val(noRmbSum); |
|
|
|
$("input[name='rmb']").val(rmb); |
|
|
|
$("input[name='rmbSum']").val(rmbSum); |
|
|
|
$("input[name='noUsd']").val(noUsd); |
|
|
|
$("input[name='noUsdSum']").val(noUsdSum); |
|
|
|
$("input[name='usd']").val(usd); |
|
|
|
$("input[name='usdSum']").val(usdSum); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//最新报价历史 |
|
|
|
function recentQuotationHistory(materialCode){ |
|
|
|
var customerCode = $("#customerCode").val(); |
|
|
|
var queryParams = new URLSearchParams(); |
|
|
@ -320,6 +704,150 @@ |
|
|
|
|
|
|
|
$.modal.open("最新报价历史", url); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(document).ready(function() { |
|
|
|
// 初始化选择框的值 |
|
|
|
initializeCurrencySelection(); |
|
|
|
|
|
|
|
// 选择币种的 change 事件监听器 |
|
|
|
$("#commonCurrency_add").on('change', function() { |
|
|
|
var selectedValue = $(this).val(); |
|
|
|
updateColumnVisibility(selectedValue); |
|
|
|
handleTaxArea(selectedValue); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
function initializeCurrencySelection() { |
|
|
|
var selectedValue = $("#commonCurrency_add").val(); |
|
|
|
updateColumnVisibility(selectedValue); |
|
|
|
handleTaxArea(selectedValue); |
|
|
|
} |
|
|
|
|
|
|
|
function handleTaxArea(selectedValue) { |
|
|
|
var $table = $("#bootstrap-sub-table-quoteChild"); |
|
|
|
|
|
|
|
// 移除现有的税区 |
|
|
|
$('#usdTax, #rmbTax').remove(); |
|
|
|
|
|
|
|
if (selectedValue === "1") { // RMB |
|
|
|
addRmbTaxArea($table); |
|
|
|
} else if (selectedValue === "2") { // USD |
|
|
|
addUsdTaxArea($table); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
function addRmbTaxArea($table) { |
|
|
|
var initialTaxValue = getInitialRmbTaxValue(); // 获取初始税率值的函数 |
|
|
|
|
|
|
|
var $taxArea = $( |
|
|
|
'<div class="form-group" id="rmbTax">\n' + |
|
|
|
' <label class="col-sm-4 control-label">税率:</label>\n' + |
|
|
|
' <div class="col-sm-8">\n' + |
|
|
|
' <div class="input-group">\n' + |
|
|
|
' <input name="rmbTax" id="rmbTax_add" class="form-control" type="number" readonly>\n' + |
|
|
|
' <span class="input-group-addon">%</span>\n' + |
|
|
|
' </div>\n' + |
|
|
|
' </div>\n' + |
|
|
|
'</div>' |
|
|
|
); |
|
|
|
|
|
|
|
$('#commonCurrency').after($taxArea); |
|
|
|
|
|
|
|
// 设置初始值 |
|
|
|
$('#rmbTax_add').val(initialTaxValue); |
|
|
|
|
|
|
|
// 添加 change 事件监听器 |
|
|
|
$taxArea.on('change', '#rmbTax_add', function(event) { |
|
|
|
var taxValue = $(this).val(); |
|
|
|
var data = $table.bootstrapTable('getData'); |
|
|
|
data.forEach(function(row, index) { |
|
|
|
updateColumnValue(index, taxValue, "countTax"); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
// 触发 change 事件以应用初始值 |
|
|
|
$('#rmbTax_add').trigger('change'); |
|
|
|
} |
|
|
|
|
|
|
|
function addUsdTaxArea($table) { |
|
|
|
var initialUsdTaxValue = getInitialUsdTaxValue(); // 获取初始美元汇率值的函数 |
|
|
|
|
|
|
|
var $taxArea = $( |
|
|
|
'<div class="form-group" id="usdTax">' + |
|
|
|
'<label class="col-sm-4 control-label">美元汇率:</label>' + |
|
|
|
'<div class="col-sm-8">' + |
|
|
|
'<input id="usdTax_add" name="usdTax" class="form-control" type="number" placeholder="当前未配置美元汇率,请联系总经理" readonly/>' + |
|
|
|
'</div>' + |
|
|
|
'</div>' |
|
|
|
); |
|
|
|
|
|
|
|
$('#commonCurrency').after($taxArea); |
|
|
|
|
|
|
|
// 设置初始值 |
|
|
|
$('#usdTax_add').val(initialUsdTaxValue); |
|
|
|
|
|
|
|
// 添加 change 事件监听器 |
|
|
|
$taxArea.on('change', '#usdTax_add', function(event) { |
|
|
|
var taxValue = $(this).val(); |
|
|
|
var data = $table.bootstrapTable('getData'); |
|
|
|
data.forEach(function(row, index) { |
|
|
|
updateColumnValue(index, taxValue, "usdTax"); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
// 触发 change 事件以应用初始值 |
|
|
|
$('#usdTax_add').trigger('change'); |
|
|
|
} |
|
|
|
|
|
|
|
// 获取初始税率值的方法 |
|
|
|
function getInitialRmbTaxValue() { |
|
|
|
return sysCustomerQuote.rmbTax; |
|
|
|
} |
|
|
|
|
|
|
|
// 获取初始美元汇率值的方法 |
|
|
|
function getInitialUsdTaxValue() { |
|
|
|
return sysCustomerQuote.usdTax; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 更新列可见性的函数 |
|
|
|
function updateColumnVisibility(currencyType,columnName) { |
|
|
|
var $table = $("#bootstrap-sub-table-quoteChild"); |
|
|
|
var usdColumns = [ 'materialNoUsd', 'materialUsd', 'materialUsdSum', 'materialNoUsdSum']; |
|
|
|
var rmbColumns = [ 'materialNoRmb', 'materialRmb', 'materialNoRmbSum', 'materialRmbSum']; |
|
|
|
if (currencyType === '1') { |
|
|
|
// 隐藏指定的列 |
|
|
|
usdColumns.forEach(function(columnName) { |
|
|
|
$table.bootstrapTable('hideColumn', columnName); |
|
|
|
}); |
|
|
|
// 显示指定的列 |
|
|
|
rmbColumns.forEach(function(columnName) { |
|
|
|
$table.bootstrapTable('showColumn', columnName); |
|
|
|
}); |
|
|
|
var data = $table.bootstrapTable('getData'); |
|
|
|
// data.forEach(function(row, index) { |
|
|
|
// updateColumnValue(index, 0, "usdTax"); |
|
|
|
// }); |
|
|
|
} else { |
|
|
|
// 隐藏指定的列 |
|
|
|
rmbColumns.forEach(function(columnName) { |
|
|
|
$table.bootstrapTable('hideColumn', columnName); |
|
|
|
}); |
|
|
|
// 显示指定的列 |
|
|
|
usdColumns.forEach(function(columnName) { |
|
|
|
$table.bootstrapTable('showColumn', columnName); |
|
|
|
}); |
|
|
|
var data = $table.bootstrapTable('getData'); |
|
|
|
// data.forEach(function(row, index) { |
|
|
|
// updateColumnValue(index, 0, "countTax"); |
|
|
|
// }); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
</script> |
|
|
|
</body> |
|
|
|
</html> |