Browse Source

Merge remote-tracking branch 'origin/dev' into dev

dev
王晓迪 2 months ago
parent
commit
8138358f4c
  1. 3
      ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysCustomerQuoteController.java
  2. 24
      ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysCustomerQuote.java
  3. 17
      ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysCustomerQuoteChild.java
  4. 2
      ruoyi-admin/src/main/java/com/ruoyi/system/domain/Vo/ExportCustomerQuoteChildVo.java
  5. 6
      ruoyi-admin/src/main/java/com/ruoyi/system/domain/Vo/ExportCustomerQuoteDetailVo.java
  6. 2
      ruoyi-admin/src/main/java/com/ruoyi/system/service/ISysCustomerQuoteService.java
  7. 35
      ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysCustomerQuoteServiceImpl.java
  8. 8
      ruoyi-admin/src/main/resources/templates/erp/material/material.html
  9. 2
      ruoyi-admin/src/main/resources/templates/system/customerQuote/customerQuote.html
  10. 838
      ruoyi-admin/src/main/resources/templates/system/customerQuote/detail.html
  11. 672
      ruoyi-admin/src/main/resources/templates/system/customerQuote/edit.html

3
ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysCustomerQuoteController.java

@ -357,7 +357,8 @@ public class SysCustomerQuoteController extends BaseController
@ResponseBody
public AjaxResult restore(@PathVariable("id")Long id)
{
return AjaxResult.success(sysCustomerQuoteService.restoreSysCustomerById(id));
sysCustomerQuoteService.restoreSysCustomerById(id);
return AjaxResult.success();
}
@RequestMapping("/getCustomerQuoteSelList")

24
ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysCustomerQuote.java

@ -42,11 +42,11 @@ public class SysCustomerQuote extends BaseEntity
private String pricingDate;
/** 物料合计 */
@Excel(name = "物料合计")
private String enterprise;
private Integer enterprise;
/** 数量合计 */
@Excel(name = "数量合计")
private Double enterpriseSum;
private Integer enterpriseSum;
/** 报价币种 */
@Excel(name = "报价币种",dictType = "sys_common_currency")
@ -198,12 +198,6 @@ public class SysCustomerQuote extends BaseEntity
this.pricingDate = pricingDate;
}
public void setEnterprise(String enterprise)
{
this.enterprise = enterprise;
}
public String getEnterprise() {return enterprise;}
public String getCommonCurrency() {
return commonCurrency;
@ -213,14 +207,22 @@ public class SysCustomerQuote extends BaseEntity
this.commonCurrency = commonCurrency;
}
public void setEnterpriseSum(Double enterpriseSum) {
this.enterpriseSum = enterpriseSum;
public Integer getEnterprise() {
return enterprise;
}
public Double getEnterpriseSum() {
public void setEnterprise(Integer enterprise) {
this.enterprise = enterprise;
}
public Integer getEnterpriseSum() {
return enterpriseSum;
}
public void setEnterpriseSum(Integer enterpriseSum) {
this.enterpriseSum = enterpriseSum;
}
public BigDecimal getRmbTax() {
return rmbTax;
}

17
ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysCustomerQuoteChild.java

@ -74,7 +74,7 @@ public class SysCustomerQuoteChild extends BaseEntity
/** 物料数量 */
@Excel(name = "物料数量")
private BigDecimal materialNum;
private Integer materialNum;
@Excel(name = "物料对外售价")
private BigDecimal materialSole;
@ -235,16 +235,17 @@ public class SysCustomerQuoteChild extends BaseEntity
{
return usdTax;
}
public void setMaterialNum(BigDecimal materialNum)
{
this.materialNum = materialNum;
}
public BigDecimal getMaterialNum()
{
public Integer getMaterialNum() {
return materialNum;
}
public void setMaterialRmb(BigDecimal materialRmb)
public void setMaterialNum(Integer materialNum) {
this.materialNum = materialNum;
}
public void setMaterialRmb(BigDecimal materialRmb)
{
this.materialRmb = materialRmb;
}

2
ruoyi-admin/src/main/java/com/ruoyi/system/domain/Vo/ExportCustomerQuoteChildVo.java

@ -16,7 +16,7 @@ public class ExportCustomerQuoteChildVo {
/** 物料的数量 */
private BigDecimal materialNum;
private Integer materialNum;
/** 物料的含税单价 */

6
ruoyi-admin/src/main/java/com/ruoyi/system/domain/Vo/ExportCustomerQuoteDetailVo.java

@ -37,11 +37,11 @@ public class ExportCustomerQuoteDetailVo{
private String pricingDate;
/** 物料合计 */
@Excel(name = "物料合计")
private String enterprise;
private Integer enterprise;
/** 数量合计 */
@Excel(name = "数量合计")
private Double enterpriseSum;
private Integer enterpriseSum;
/** 报价币种 */
@Excel(name = "报价币种",dictType = "sys_common_currency")
@ -122,7 +122,7 @@ public class ExportCustomerQuoteDetailVo{
/** 物料数量 */
@Excel(name = "物料数量")
private BigDecimal materialNum;
private Integer materialNum;
@Excel(name = "物料对外售价")
private BigDecimal materialSole;

2
ruoyi-admin/src/main/java/com/ruoyi/system/service/ISysCustomerQuoteService.java

@ -83,7 +83,7 @@ public interface ISysCustomerQuoteService
@Transactional(rollbackFor = Exception.class)
ProcessInstance cancelSysCustomerById(Long id);
@Transactional(rollbackFor = Exception.class)
ProcessInstance restoreSysCustomerById(Long id);
public ProcessInstance submitApply(SysCustomerQuote sysCustomerQuote);

35
ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysCustomerQuoteServiceImpl.java

@ -347,6 +347,9 @@ public class SysCustomerQuoteServiceImpl implements ISysCustomerQuoteService {
}
@Transactional(rollbackFor = Exception.class)
@Override
public ProcessInstance restoreSysCustomerById(Long id) {
SysCustomerQuoteVo sysCustomerVo = sysCustomerQuoteMapper.selectSysCustomerQuoteById(id);
@ -379,6 +382,7 @@ public class SysCustomerQuoteServiceImpl implements ISysCustomerQuoteService {
* @param sysCustomerQuote
* @return
*/
@Transactional(rollbackFor = Exception.class)
@Override
public ProcessInstance submitApply(SysCustomerQuote sysCustomerQuote) {
SysUser user = ShiroUtils.getSysUser();
@ -386,6 +390,8 @@ public class SysCustomerQuoteServiceImpl implements ISysCustomerQuoteService {
sysCustomerQuote.setApplyTime(DateUtils.getNowDate());
if(sysCustomerQuote.getId()==null){
insertSysCustomerQuote(sysCustomerQuote);
}else {
updateAuditSysCustomerQuote(sysCustomerQuote);
}
// 启动流程
@ -413,6 +419,35 @@ public class SysCustomerQuoteServiceImpl implements ISysCustomerQuoteService {
return processInstance;
}
/**
* 审核编辑客户报价
* */
private int updateAuditSysCustomerQuote(SysCustomerQuote sysCustomerQuote) {
String loginName = ShiroUtils.getLoginName();
sysCustomerQuote.setUpdateBy(loginName);
sysCustomerQuote.setUpdateTime(DateUtils.getNowDate());
List<SysCustomerQuoteChild> sysCustomerQuoteChild = sysCustomerQuote.getSysCustomerQuoteChildList();
int s = sysCustomerQuoteChild.size();
if (s > 0){
for(SysCustomerQuoteChild sysCustomerQuoteChild1 : sysCustomerQuoteChild){
if (sysCustomerQuoteChild1.getId() == null || sysCustomerQuoteChild1.getId() == 0L){
sysCustomerQuoteChild1.setQuoteId(sysCustomerQuote.getSupplierCode());
sysCustomerQuoteChild1.setCreateBy(loginName);
sysCustomerQuoteChild1.setCreateTime(DateUtils.getNowDate());
sysCustomerQuoteChildMapper.insertSysCustomerQuoteChild(sysCustomerQuoteChild1);
}else {
sysCustomerQuoteChild1.setUpdateBy(loginName);
sysCustomerQuoteChild1.setUpdateTime(DateUtils.getNowDate());
sysCustomerQuoteChildMapper.updateSysCustomerQuoteChild(sysCustomerQuoteChild1);
}
}
}
int allMaterialNum = sysCustomerQuoteChild.stream().mapToInt(SysCustomerQuoteChild::getMaterialNum).sum();
sysCustomerQuote.setEnterpriseSum(allMaterialNum);
int updateResult = sysCustomerQuoteMapper.updateSysCustomerQuote(sysCustomerQuote);
return updateResult;
}
private ProcessInstance startProcessInstance(String applyTitle,String instanceType,SysCustomerQuote sysCustomerQuote, SysUser user) {
Long nessKey = sysCustomerQuote.getId();

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

@ -190,10 +190,10 @@
},
{title: '料号',field: 'materialNo',align: 'center'},
{title: '物料名称',field: 'materialName',align: 'center'},
{title: '描述',field: 'describe',align: 'center',
formatter: function(value, row, index) {
return $.table.tooltip(value, 10, "open");
}
{title: '描述',field: 'describe',align: 'center'
// formatter: function(value, row, index) {
// return $.table.tooltip(value, 10, "open");
// }
},
{title: '型号',field: 'materialModel',align: 'center',
// formatter: function(value, row, index) {

2
ruoyi-admin/src/main/resources/templates/system/customerQuote/customerQuote.html

@ -302,7 +302,7 @@
// 作废
function cancel(id) {
$.modal.confirm("确定作废该销售订单吗?", function() {
$.modal.confirm("确定作废该客户报价单吗?", function() {
var url = prefix + "/cancel/" + id;
$.modal.open("作废", url);
})

838
ruoyi-admin/src/main/resources/templates/system/customerQuote/detail.html

@ -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>

672
ruoyi-admin/src/main/resources/templates/system/customerQuote/edit.html

@ -4,10 +4,13 @@
<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-edit" th:object="${sysCustomerQuote}">
<form class="form-horizontal m" id="form-customerQuote-edit" th:object="${sysCustomerQuote}" >
<div class="form-group" hidden="hidden">
<div class="form-group" hidden="hidden">
<label class="col-sm-4 control-label">客户报价ID:</label>
@ -23,75 +26,61 @@
<div class="form-group" shiro:hasPermission="system:customerQuote:edit">
<label class="col-sm-4 control-label">业务员:</label>
<div class="col-sm-8">
<!-- <select class="form-control" name="businessMembers" th:field="*{businessMembers}" readonly required>-->
<!-- <option value="">请选择</option>-->
<!-- </select>-->
<input name="businessMembers" th:field="*{businessMembers}" class="form-control" type="text" readonly required>
<!-- <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 readonly class="form-control" th:field="*{customerCode}" name="customerCode" required >
<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 redonly 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 class="form-control" id="commonCurrency_edit" th:field="*{commonCurrency}" th:with="dictList=${@dict.getType('sys_common_currency')}" name="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>
<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-6 control-label is-required">是否含税:</label>
<div class="col-sm-6">
<div class="radio-box" th:each="dict : ${@dict.getType('sys_confirm_tax')}">
<input required type="radio" th:id="${'confirmTax_' + dict.dictCode}"
<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" />
<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">
<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}"></textarea>
</div>
</div>
<div class="container" style="display: none;">
<h4 class="form-header h4">计算</h4>
<div class="col-xs-12 form-row">
@ -115,23 +104,25 @@
<label class="col-sm-2">含税总价:</label><input placeholder="美元" class="col-sm-4" name="usdSum" id="usdSum_edit" type="number" readonly/>
</div>
</div>
<input type="hidden" name="customerQuoteChildList" >
</form>
<div class="other container">
<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 disabled" onclick="insertNRow()">-->
<!-- <i class="fa fa-remove"></i> 添加无料号物料-->
<!-- </a>-->
<!-- <a class="btn btn-danger multiple" onclick="insertNoMaterialNoRow()">-->
<!-- <i class="fa fa-remove"></i> 添加无料号物料-->
<!-- </a>-->
</div>
</div>
<div class="row">
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table-Quote-child-edit1"></table>
<table id="bootstrap-sub-table-quoteChild"></table>
</div>
</div>
</div>
@ -147,6 +138,8 @@
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();
@ -154,60 +147,173 @@
focusCleanup: true,
});
var customerCode1 = [[${sysCustomerQuote.customerCode}]];
$(function() {
// $("input[name='customerFax']").val([sysCustomerQuote.customerFax]);
// $("input[name='rmbTax']").val([sysCustomerQuote.taxRate]);
// $("input[name='customerFax']").change(function () {
// if ($("input[name='customerFax']").val() == "1") {
// $("input[name='rmbTax']").val(sysCustomerQuote.taxRate);
// } else {
// $("input[name='rmbTax']").val(0);
// }
// });
$("#commonCurrency_edit").val(sysCustomerQuote.commonCurrency).trigger('change');
var commonCurrency = $("#commonCurrency_add option:selected").val();
$("#form-customerQuote-edit").validate(
{
focusCleanup: true}
);
function submitHandler() {
if ($.validate.form()) {
var formData = $("#form-customerQuote-edit").serializeArray();
var tableData = $("#bootstrap-sub-table-quoteChild").bootstrapTable('getData');
var rows = tableData.length;
if(rows==0){
$.modal.alertWarning("子表数据不能为空!");
}else{
formData.push({"name": "sysCustomerQuoteChildList", "value": tableData});
var jsonData = $.common.formDataToJson(formData);
$.operate.saveJson(prefix + "/edit", jsonData);
}
}
}
// 监听客户编号下拉框的变化
$('#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-edit input[name='businessMembers']").val(loginName);
var options = {
id: "bootstrap-table-Quote-child-edit1",
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);
@ -218,21 +324,7 @@
return $.table.selectDictLabel(processMethodDatas, value);
}
},
// { title: '对外售价',field: 'materialSole',
// editable: {
// type: 'number',
// mode: 'inline',
// title: '对外售价',
// validate: function (value) {
// if (!value) {
// return '对外售价不能为空';
// }
// if (isNaN(value)) {
// return '对外售价必须为数字';
// }
// }
// }
// },
{ title: '最新报价(RMB)',field: 'recentQuotationRMB',align: 'center',},
{ title: '最新报价(美元)',field: 'recentQuotationUSD',align: 'center',},
{ title: '最新报价历史',align: 'center',
@ -243,9 +335,7 @@
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',
@ -288,6 +378,9 @@
}
}
},
{ title: '物料的含税单价(RMB)',field: 'materialRmb',align: 'center',},
{title: '物料的不含税总价(RMB)',field: 'materialNoRmbSum',align: 'center',},
{ title: '物料的含税总价(RMB)',field: 'materialRmbSum',align: 'center',},
{title: '物料的不含税单价(美元)',
field: 'materialNoUsd',
align: 'center',
@ -316,86 +409,126 @@
}
}
},
{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.id + '\')"><i class="fa fa-remove"></i>删除</a> ');
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){
var commonCurrency1 = $("#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(commonCurrency1);
if(commonCurrency1 == 1){
row.materialRmb = Number(row.materialNoRmb * Number(1 + rmb));
row.materialNoRmbSum = Number(row.materialNum * Number(row.materialNoRmb)).toFixed(2);
row.materialRmbSum = Number(row.materialRmb * row.materialNum).toFixed(2);
row.materialNoUsd = Number(row.materialNoRmb / usd).toFixed(2);
row.materialNoUsdSum = Number(row.materialNum) * Number(row.materialNoUsd);
row.materialUsd = Number(row.materialNoUsd).toFixed(2)
row.materialUsdSum = Number(row.materialNum * Number(row.materialUsd)).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(commonCurrency1 == 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 * usd).toFixed(2);
row.materialRmb = Number(row.materialNoRmb * (1 + rmb)).toFixed(2);
row.materialNoRmbSum = Number(row.materialNoRmb * row.materialNum).toFixed(2);
row.materialRmbSum = Number(row.materialRmb * 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,
};
curParams.quoteId = sysCustomerQuote.supplierCode;
return curParams;
}
function submitHandler() {
if ($.validate.form()) {
var formData = $("#form-customerQuote-edit").serializeArray();
console.log("formData",formData);
var tableData = $("#bootstrap-table-Quote-child-edit1").bootstrapTable('getData');
console.log("tableData",JSON.stringify(tableData));
var rows = tableData.length;
if(rows==0){
$.modal.alertWarning("子表数据不能为空!");
}else{
formData.push({"name": "sysCustomerQuoteChildList", "value": tableData});
var jsonData = $.common.formDataToJson(formData);
$.operate.saveJson(prefix + "/edit", jsonData);
//监听币种的变化
$(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-edit select[name='businessMembers']").append(
"<option value='" + usertData[i].loginName + "'>" + usertData[i].userName + "</option>");
}
$("#form-customerQuote-edit select[name='businessMembers']").val(loginName).trigger("change");
} else {
$.modal.msgError(res.msg);
}
}
});
}
//批量插入选择的物料
function doSubmit(index, layero, uniqueId) {
console.log(uniqueId);
@ -436,12 +569,13 @@
materialName: rowData.materialName,
materialType: rowData.materialType,
describe: rowData.describe,
brand: rowData.brand,
materialModel: rowData.materialModel,
unit: rowData.unit,
brand: rowData.brand,
processMethod: rowData.processMethod,
photoUrl: rowData.photoUrl,
countTax: '',
usdTax: '',
countTax: $("#rmbTax_add").val(),
usdTax: $("#usdTax_add").val(),
materialNum: "",
// materialSole: "",
recentQuotationRMB: quotationData.data.materialRmb || '',
@ -498,7 +632,6 @@
}
function insertRow() {
var url = ctx + "erp/material/select";
var options = {
@ -509,10 +642,10 @@
$.modal.openOptions(options);
}
/* 删除指定表格行 */
function removeRow(rowData){
$.table.bootstrapTable('remove', {
field: 'id',
values: rowData.id
function removeRow(materialCode){
$("#bootstrap-sub-table-quoteChild").bootstrapTable('remove', {
field: 'materialCode',
values: materialCode
});
getTotalAmount();
}
@ -521,40 +654,56 @@
minView: "month",
autoclose: true
});
//计算
function getTotalAmount(){
let getData = $("#bootstrap-table-Quote-child-edit1").bootstrapTable('getData', true);
function getTotalAmount() {
var getData = $("#bootstrap-sub-table-quoteChild").bootstrapTable('getData');
var enterprise = 0;
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(var i=0;i<getData.length;i++){
enterprise += 1;
enterpriseSum = parseInt(enterprise + getData[i].materialNum).toFixed(0);
noRmb = parseFloat(noRmb + getData[i].materialNoRmb).toFixed(2);
rmb = parseFloat(rmb + getData[i].materialRmb).toFixed(2) ;
noRmbSum = parseFloat(noRmbSum + getData[i].materialNoRmbSum).toFixed(2);
rmbSum = parseFloat(rmbSum + getData[i].materialRmbSum).toFixed(2);
noUsd = parseFloat(noUsd + getData[i].materialNoUsd).toFixed(2) ;
usd = parseFloat(usd + getData[i].materialUsd).toFixed(2) ;
noUsdSum = parseFloat(noUsdSum + getData[i].materialNoUsdSum).toFixed(2);
usdSum = parseFloat(usdSum + getData[i].materialUsdSum).toFixed(2);
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);
// 先累加数值,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_edit").val(enterprise);
$("#enterpriseSum_edit").val(enterpriseSum);
$("#noRmb_edit").val(noRmb);
$("#rmb_edit").val(rmb);
$("#noRmbSum_edit").val(noRmbSum);
$("#rmbSum_edit").val(rmbSum);
$("#noUsd_edit").val(noUsd);
$("#usd_edit").val(usd);
$("#noUsdSum_edit").val(noUsdSum);
$("#usdSum_edit").val(usdSum);
}
// 结算金额
function toPercentage(numerator, denominator) {
return (numerator / denominator) * 100 + '%';
// 将累加的结果格式化为两位小数
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);
}
@ -569,6 +718,149 @@
$.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>
Loading…
Cancel
Save