Browse Source

[fix] 销售管理

修改客户报价的审批流程,修复驳回调整不可用的问题
按照新版的客户报价新增页面,重写客户报价的详情页面和编辑页面
修改客户报价的恢复后端接口,修复恢复功能报错问题
修改客户报价的相关业务的所有物料合计的数量合计的数据类型为Integer
修改客户报价作废的提示描述为销售订单的问题
新增审核编辑客户报价后端方法
dev
liuxiaoxu 2 months ago
parent
commit
f5b7fe4e73
  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. 15
      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. 2
      ruoyi-admin/src/main/resources/templates/system/customerQuote/customerQuote.html
  9. 838
      ruoyi-admin/src/main/resources/templates/system/customerQuote/detail.html
  10. 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 @ResponseBody
public AjaxResult restore(@PathVariable("id")Long id) public AjaxResult restore(@PathVariable("id")Long id)
{ {
return AjaxResult.success(sysCustomerQuoteService.restoreSysCustomerById(id)); sysCustomerQuoteService.restoreSysCustomerById(id);
return AjaxResult.success();
} }
@RequestMapping("/getCustomerQuoteSelList") @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; private String pricingDate;
/** 物料合计 */ /** 物料合计 */
@Excel(name = "物料合计") @Excel(name = "物料合计")
private String enterprise; private Integer enterprise;
/** 数量合计 */ /** 数量合计 */
@Excel(name = "数量合计") @Excel(name = "数量合计")
private Double enterpriseSum; private Integer enterpriseSum;
/** 报价币种 */ /** 报价币种 */
@Excel(name = "报价币种",dictType = "sys_common_currency") @Excel(name = "报价币种",dictType = "sys_common_currency")
@ -198,12 +198,6 @@ public class SysCustomerQuote extends BaseEntity
this.pricingDate = pricingDate; this.pricingDate = pricingDate;
} }
public void setEnterprise(String enterprise)
{
this.enterprise = enterprise;
}
public String getEnterprise() {return enterprise;}
public String getCommonCurrency() { public String getCommonCurrency() {
return commonCurrency; return commonCurrency;
@ -213,14 +207,22 @@ public class SysCustomerQuote extends BaseEntity
this.commonCurrency = commonCurrency; this.commonCurrency = commonCurrency;
} }
public void setEnterpriseSum(Double enterpriseSum) { public Integer getEnterprise() {
this.enterpriseSum = enterpriseSum; return enterprise;
} }
public Double getEnterpriseSum() { public void setEnterprise(Integer enterprise) {
this.enterprise = enterprise;
}
public Integer getEnterpriseSum() {
return enterpriseSum; return enterpriseSum;
} }
public void setEnterpriseSum(Integer enterpriseSum) {
this.enterpriseSum = enterpriseSum;
}
public BigDecimal getRmbTax() { public BigDecimal getRmbTax() {
return rmbTax; return rmbTax;
} }

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

@ -74,7 +74,7 @@ public class SysCustomerQuoteChild extends BaseEntity
/** 物料数量 */ /** 物料数量 */
@Excel(name = "物料数量") @Excel(name = "物料数量")
private BigDecimal materialNum; private Integer materialNum;
@Excel(name = "物料对外售价") @Excel(name = "物料对外售价")
private BigDecimal materialSole; private BigDecimal materialSole;
@ -235,15 +235,16 @@ public class SysCustomerQuoteChild extends BaseEntity
{ {
return usdTax; return usdTax;
} }
public void setMaterialNum(BigDecimal materialNum)
{
this.materialNum = materialNum;
}
public BigDecimal getMaterialNum()
{ public Integer getMaterialNum() {
return materialNum; return materialNum;
} }
public void setMaterialNum(Integer materialNum) {
this.materialNum = materialNum;
}
public void setMaterialRmb(BigDecimal materialRmb) public void setMaterialRmb(BigDecimal materialRmb)
{ {
this.materialRmb = 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; private String pricingDate;
/** 物料合计 */ /** 物料合计 */
@Excel(name = "物料合计") @Excel(name = "物料合计")
private String enterprise; private Integer enterprise;
/** 数量合计 */ /** 数量合计 */
@Excel(name = "数量合计") @Excel(name = "数量合计")
private Double enterpriseSum; private Integer enterpriseSum;
/** 报价币种 */ /** 报价币种 */
@Excel(name = "报价币种",dictType = "sys_common_currency") @Excel(name = "报价币种",dictType = "sys_common_currency")
@ -122,7 +122,7 @@ public class ExportCustomerQuoteDetailVo{
/** 物料数量 */ /** 物料数量 */
@Excel(name = "物料数量") @Excel(name = "物料数量")
private BigDecimal materialNum; private Integer materialNum;
@Excel(name = "物料对外售价") @Excel(name = "物料对外售价")
private BigDecimal materialSole; 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) @Transactional(rollbackFor = Exception.class)
ProcessInstance cancelSysCustomerById(Long id); ProcessInstance cancelSysCustomerById(Long id);
@Transactional(rollbackFor = Exception.class)
ProcessInstance restoreSysCustomerById(Long id); ProcessInstance restoreSysCustomerById(Long id);
public ProcessInstance submitApply(SysCustomerQuote sysCustomerQuote); 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 @Override
public ProcessInstance restoreSysCustomerById(Long id) { public ProcessInstance restoreSysCustomerById(Long id) {
SysCustomerQuoteVo sysCustomerVo = sysCustomerQuoteMapper.selectSysCustomerQuoteById(id); SysCustomerQuoteVo sysCustomerVo = sysCustomerQuoteMapper.selectSysCustomerQuoteById(id);
@ -379,6 +382,7 @@ public class SysCustomerQuoteServiceImpl implements ISysCustomerQuoteService {
* @param sysCustomerQuote * @param sysCustomerQuote
* @return * @return
*/ */
@Transactional(rollbackFor = Exception.class)
@Override @Override
public ProcessInstance submitApply(SysCustomerQuote sysCustomerQuote) { public ProcessInstance submitApply(SysCustomerQuote sysCustomerQuote) {
SysUser user = ShiroUtils.getSysUser(); SysUser user = ShiroUtils.getSysUser();
@ -386,6 +390,8 @@ public class SysCustomerQuoteServiceImpl implements ISysCustomerQuoteService {
sysCustomerQuote.setApplyTime(DateUtils.getNowDate()); sysCustomerQuote.setApplyTime(DateUtils.getNowDate());
if(sysCustomerQuote.getId()==null){ if(sysCustomerQuote.getId()==null){
insertSysCustomerQuote(sysCustomerQuote); insertSysCustomerQuote(sysCustomerQuote);
}else {
updateAuditSysCustomerQuote(sysCustomerQuote);
} }
// 启动流程 // 启动流程
@ -413,6 +419,35 @@ public class SysCustomerQuoteServiceImpl implements ISysCustomerQuoteService {
return processInstance; 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) { private ProcessInstance startProcessInstance(String applyTitle,String instanceType,SysCustomerQuote sysCustomerQuote, SysUser user) {
Long nessKey = sysCustomerQuote.getId(); Long nessKey = sysCustomerQuote.getId();

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

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

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

@ -1,13 +1,16 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.w3.org/1999/xhtml"> <html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.w3.org/1999/xhtml">
<head> <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 :: select2-css" />
<th:block th:include="include :: bootstrap-editable-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> </head>
<body class="white-bg"> <body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content"> <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">
<div class="form-group" hidden="hidden"> <div class="form-group" hidden="hidden">
<label class="col-sm-4 control-label">客户报价ID:</label> <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> <input name="id" th:field="*{id}" class="form-control" type="number" readonly>
</div> </div>
</div> </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"> <div class="col-sm-8">
<input name="supplierCode" th:field="*{supplierCode}" class="form-control" type="text" readonly> <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"> <div class="form-group" shiro:hasPermission="system:customerQuote:edit">
<label class="col-sm-4 control-label">业务员:</label> <label class="col-sm-4 control-label">业务员:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<select disabled class="form-control" name="businessMembers" required th:field="*{businessMembers}"> <!-- <select class="form-control" name="businessMembers" required>-->
<option value="">请选择</option> <!-- <option value="">请选择</option>-->
</select> <!-- </select>-->
<input name="businessMembers" class="form-control" type="text" readonly>
</div> </div>
</div> </div>
<div class="form-group"> <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"> <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> </div>
<div class="form-group"> <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"> <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> </div>
<div class="form-group">
<div class="form-group" id="commonCurrency">
<label class="col-sm-4 control-label">报价币种:</label> <label class="col-sm-4 control-label">报价币种:</label>
<div class="col-sm-8"> <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 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> </select>
</div> </div>
</div> </div>
<div class="form-group"> <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-4 control-label is-required">是否含税:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<div class="radio-box" th:each="dict : ${@dict.getType('sys_confirm_tax')}"> <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}" disabled> 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> <label th:for="${'confirmTax_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
</div> </div>
</div> </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"> <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"> <div class="col-sm-8">
<div class="input-group date"> <div class="input-group date">
<input name="pricingDate" th:field="*{pricingDate}" class="form-control" type="text" disabled> <input name="pricingDate" th:field="*{pricingDate}" class="form-control" placeholder="yyyy-MM-dd" type="text" readonly>
<span class="input-group-addon " disabled><i class="fa fa-calendar"></i></span> <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
</div> </div>
</div> </div>
</div> </div>
<div class="form-group"> <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"> <div class="col-sm-8">
<textarea readonly name="remark" th:text="*{remark}" class="form-control"></textarea> <textarea name="remark" class="form-control" th:text="*{remark}" readonly></textarea>
</div> </div>
</div> </div>
<div class="container" style="display: none;"> <div class="container" style="display: none;">
<h4 class="form-header h4">计算</h4> <h4 class="form-header h4">计算</h4>
<div class="col-xs-12 form-row"> <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="enterprise" id="enterprise_edit" type="text" readonly/>
<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="enterpriseSum" id="enterpriseSum_edit" type="number" readonly/>
</div> </div>
<div class="col-xs-12 form-row"> <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="noRmb" id="noRmb_edit" type="number" readonly/>
<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="noRmbSum" id="noRmbSum_edit" type="number" readonly/>
</div> </div>
<div class="col-xs-12 form-row"> <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="rmb" id="rmb_edit" type="number" readonly/>
<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="rmbSum" id="rmbSum_edit" type="number" readonly/>
</div> </div>
<div class="col-xs-12 form-row"> <div class="col-xs-12">
<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="noUsd" id="noUsd_edit" type="number" readonly/>
<label class="col-sm-2">不含税总价:</label><input placeholder="美元" class="col-sm-4" name="noUsdSum" id="noUsdSum_detail" th:field="*{noUsdSum}" type="number" disabled/> <label class="col-sm-2">不含税总价:</label><input placeholder="美元" class="col-sm-4" name="noUsdSum" id="noUsdSum_edit" type="number" readonly/>
</div> </div>
<div class="col-xs-12 form-row"> <div class="col-xs-12">
<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="usd" id="usd_edit" type="number" readonly/>
<label class="col-sm-2">含税总价:</label><input placeholder="美元" class="col-sm-4" name="usdSum" id="usdSum_detail" th:field="*{usdSum}" type="number" disabled/> <label class="col-sm-2">含税总价:</label><input placeholder="美元" class="col-sm-4" name="usdSum" id="usdSum_edit" type="number" readonly/>
</div> </div>
</div> </div>
<div class="container">
<div class="form-row"> </form>
<div class="btn-group-sm" id="toolbar" role="group">
<span>选择报价信息</span>
</div> <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>
<div class="row"> </div>
<div class="col-sm-12 select-table table-striped"> <div class="row">
<table id="bootstrap-table-Quote-child-detail"></table> <div class="col-sm-12 select-table table-striped">
</div> <table id="bootstrap-sub-table-quoteChild"></table>
</div> </div>
</div> </div>
</div>
</form>
</div> </div>
<th:block th:include="include :: footer" /> <th:block th:include="include :: footer" />
<th:block th:include="include :: bootstrap-table-editable-js" /> <th:block th:include="include :: bootstrap-table-editable-js" />
@ -140,52 +137,170 @@
var sysUnitClassDatas = [[${@dict.getType('sys_unit_class')}]]; var sysUnitClassDatas = [[${@dict.getType('sys_unit_class')}]];
var processMethodDatas = [[${@dict.getType('processMethod')}]]; var processMethodDatas = [[${@dict.getType('processMethod')}]];
var userName = [[${@permission.getPrincipalProperty('userName')}]]; var userName = [[${@permission.getPrincipalProperty('userName')}]];
var loginName = [[${@permission.getPrincipalProperty('loginName')}]];
var prefix = ctx + "system/customerQuote";
var sysCustomerQuote = [[${sysCustomerQuote}]]; var sysCustomerQuote = [[${sysCustomerQuote}]];
var prefix = ctx + "system/customerQuote" var prefix = ctx + "system/customerQuote"
var commonCurrency = $("#commonCurrency_edit option:selected").val(); 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() { $(function() {
// console.log(loginName);
$("#form-customerQuote-detail input[name='businessMembers']").val(loginName);
var options = { var options = {
id: "bootstrap-table-Quote-child-detail", id:'bootstrap-sub-table-quoteChild',
url: ctx + "system/quoteChild/list", url: ctx + "system/quoteChild/list",
queryParams: queryParams, queryParams: queryParams,
showColumns: false,
pagination: false, pagination: false,
sidePagination: "client",
clickToSelect: true,
showExport: true,
showSearch: false,
showRefresh: false,
showToggle: false, showToggle: false,
showColumns: false, showRefresh:false,
showPaginationSwitch: false, showSearch:false,
sidePagination: "client",
model: "物料报价信息", model: "物料报价信息",
columns: [ columns: [
{checkbox: true}, {checkbox: true},
{title: '序号',align: 'center', {field: 'index',align: 'center', title: "序号",
formatter: function (value, row, index) { 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: 'materialId',align: 'center',visible: false},
{title: '物料报价主表id',field: 'quoteId',align: 'center',visible: false},
{title: '物料索引',field: 'materialId',align: 'center',visible: false},
{title: '料号',field: 'materialCode',align: 'center'}, {title: '料号',field: 'materialCode',align: 'center'},
{title: '物料名称',field: 'materialName',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', {title: '物料类型',field: 'materialType',align: 'center',
formatter: function(value, row, index) { formatter: function(value, row, index) {
$.table.selectCategoryLabel(materialTypeDatas, value); return $.table.selectCategoryLabel(materialTypeDatas, value);
} }
}, },
{ title: '描述',field: 'describe',align: 'center'}, { title: '描述',field: 'describe',align: 'center'},
{title: '型号',field: 'materialModel',align: 'center'}, {title: '型号',field: 'materialModel',align: 'center'},
{title: '品牌',field: 'brand',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', { title: '单位',field: 'unit',align: 'center',
formatter: function(value, row, index) { formatter: function(value, row, index) {
return $.table.selectDictLabel(sysUnitClassDatas, value); return $.table.selectDictLabel(sysUnitClassDatas, value);
@ -196,8 +311,7 @@
return $.table.selectDictLabel(processMethodDatas, value); return $.table.selectDictLabel(processMethodDatas, value);
} }
}, },
// { title: '对外售价',field: 'materialSole',
// },
{ title: '最新报价(RMB)',field: 'recentQuotationRMB',align: 'center',}, { title: '最新报价(RMB)',field: 'recentQuotationRMB',align: 'center',},
{ title: '最新报价(美元)',field: 'recentQuotationUSD',align: 'center',}, { title: '最新报价(美元)',field: 'recentQuotationUSD',align: 'center',},
{ title: '最新报价历史',align: 'center', { title: '最新报价历史',align: 'center',
@ -208,109 +322,379 @@
return actions.join(''); return actions.join('');
} }
}, },
// {title: '国内税率',field: 'countTax',align: 'center',}, {title: '物料的数量',field: 'materialNum',align: 'center',
// { title: '美元汇率',field: 'usdTax', align: 'center',}, editable:{
{field: 'materialNum',align: 'center',title: '物料的数量', type : 'text',
mode: 'inline',
title : '物料的数量',
validate : function(value) {
if (!value) {
return '用量不能为空';
}
if (isNaN(value)) {
return '用量必须为数字';
}
}
},
}, },
{ title: '物料的不含税单价(RMB)', { title: '物料的不含税单价(RMB)',
field: 'materialNoRmb', field: 'materialNoRmb',
align: 'center', 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: '物料的不含税单价(美元)', {title: '物料的不含税单价(美元)',
field: 'materialNoUsd', field: 'materialNoUsd',
align: 'center', 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: '物料的含税单价(美元)',field: 'materialUsd',align: 'center',},
{title: '物料的含税总价(RMB)',field: 'materialNoRmbSum',align: 'center'}, { title: '物料的含税总价(美元)',field: 'materialUsdSum', align: 'center',},
{title: '物料的不含税总价(RMB)',field: 'materialRmbSum',align: 'center'}, { title: '物料的不含税总价(美元)',field: 'materialNoUsdSum',align: 'center',},
{title: '物料的含税单价(美元)',field: 'materialUsd',align: 'center'}, {field: 'createBy', align: 'center',title: '录入人',visible: false},
{title: '物料的含税总价(美元)',field: 'materialUsdSum',align: 'center'}, {field: 'createTime',align: 'center',title: '录入时间',visible: false},
{title: '物料的不含税总价(美元)', field: 'materialNoUsdSum',align: 'center'}, {field: 'updateBy',align: 'center',title: '更新人',visible: false},
{field: 'updateTime',align: 'center',title: '上次更新时间',visible: false},
{field: 'remark',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){ onEditableSave:function(field, row, oldValue, $el){
commonCurrency = $("#commonCurrency_edit option:selected").val(); var commonCurrency1 = $("#commonCurrency_add option:selected").val();
var rmb1 = $("#rmbTax_edit").val(); var rmbRateInput = parseFloat($("#rmbTax_add").val()) || 0;
if (rmb1 =='' || rmb1== null){ var rmbRate = rmbRateInput / 100;
rmb1 = 0; rmbRate = parseFloat(rmbRate.toFixed(2)); // 确保rmbRate转换为两位小数的浮点数
}else{ var usdRate = parseFloat($("#usdTax_add").val()) || 0;
rmb1 = $("#rmbTax_edit").val();
} var testMaterialNum = parseFloat(row.materialNum) || 0;
var rmb = Number(rmb1).toFixed(2) / 100; if (commonCurrency1 === '1') {
var usd = $("#usdTax_edit").val(); // RMB为基准货币
if (usd =='' || usd== null){ row.materialRmb = (parseFloat(row.materialNoRmb) * (1 + rmbRate)).toFixed(2);
usd = 0; row.materialRmbSum = (parseFloat(row.materialRmb) * testMaterialNum).toFixed(2);
}else{ row.materialNoRmbSum = (parseFloat(row.materialNoRmb) * testMaterialNum).toFixed(2);
usd = Number(usd).toFixed(2); } else if (commonCurrency1 === '2') {
} // USD为基准货币
console.log(commonCurrency); row.materialUsd = row.materialNoUsd
if(commonCurrency == 1){ row.materialUsdSum = (parseFloat(row.materialUsd) * testMaterialNum).toFixed(2);
row.materialRmb = Number(row.materialNoRmb * (1 + rmb)).toFixed(2); row.materialNoUsdSum = (parseFloat(row.materialNoUsd) * testMaterialNum).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);
} }
else if( commonCurrency == 2){
row.materialUsd = Number(row.materialNoUsd).toFixed(2); // 确保getTotalAmount函数存在且正确引用
row.materialUsdSum = Number(row.materialNum * row.materialUsd).toFixed(2); if (typeof getTotalAmount === 'function') {
row.materialNoUsdSum = Number(row.materialNoUsd * row.materialNum).toFixed(2); getTotalAmount();
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()
}, },
}; };
$.table.init(options); $.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 = { //监听币种的变化
// 传递参数查询参数 $(document).ready(function() {
pageSize: params.limit, $("#commonCurrency_add").on('change', function() {
pageNum: params.offset / params.limit + 1, var selectedValue = $(this).val();
quoteId: sysCustomerQuote.supplierCode, 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; $.modal.openOptions(options);
return curParams; }
/* 删除指定表格行 */
function removeRow(materialCode){
$("#bootstrap-sub-table-quoteChild").bootstrapTable('remove', {
field: 'materialCode',
values: materialCode
});
getTotalAmount();
} }
$("input[name='pricingDate']").datetimepicker({ $("input[name='pricingDate']").datetimepicker({
format: "yyyy-mm-dd", format: "yyyy-mm-dd",
minView: "month", minView: "month",
autoclose: true 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(){ // 先累加数值,toFixed在累加后应用以避免精度损失
// $("#addFinishbomTable").bootstrapTable('refresh'); for (let i = 0; i < getData.length; i++) {
let getData = $("#bootstrap-table-Quote-child-detail").bootstrapTable('getData', true); noRmb += parseFloat(getData[i].materialNoRmb) || 0;
var enterprise = "";let enterpriseSum = 0; let noRmb = 0; rmb += parseFloat(getData[i].materialRmb) || 0;
let rmb = 0;let noRmbSum = 0;let rmbSum = 0;let noUsd = 0; noRmbSum += parseFloat(getData[i].materialNoRmbSum) || 0;
let usd = 0;let noUsdSum = 0; let usdSum = 0; rmbSum += parseFloat(getData[i].materialRmbSum) || 0;
for(let i=0;i<getData.length;i++){ noUsd += parseFloat(getData[i].materialNoUsd) || 0;
enterprise += getData[i].materialName + ": 数量 :" + getData[i].materialNum +"; "; usd += parseFloat(getData[i].materialUsd) || 0;
enterpriseSum += Number(getData[i].materialNum); noUsdSum += parseFloat(getData[i].materialNoUsdSum) || 0;
noRmb += Number(getData[i].materialNoRmb); usdSum += parseFloat(getData[i].materialUsdSum) || 0;
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);
} }
$("#enterprise_detail").val(enterprise);
$("#enterpriseSum_detail").val(enterpriseSum); // 将累加的结果格式化为两位小数
$("#noRmb_detail").val(noRmb); noRmb = noRmb.toFixed(2);
$("#rmb_detail").val(rmb); rmb = rmb.toFixed(2);
$("#noRmbSum_detail").val(noRmbSum); noRmbSum = noRmbSum.toFixed(2);
$("#rmbSum_detail").val(rmbSum); rmbSum = rmbSum.toFixed(2);
$("#noUsd_detail").val(noUsd); noUsd = noUsd.toFixed(2);
$("#usd_detail").val(usd); usd = usd.toFixed(2);
$("#noUsdSum_detail").val(noUsdSum); noUsdSum = noUsdSum.toFixed(2);
$("#usdSum_detail").val(usdSum); 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){ function recentQuotationHistory(materialCode){
var customerCode = $("#customerCode").val(); var customerCode = $("#customerCode").val();
var queryParams = new URLSearchParams(); var queryParams = new URLSearchParams();
@ -320,6 +704,150 @@
$.modal.open("最新报价历史", url); $.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> </script>
</body> </body>
</html> </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 :: header('新增客户报价')" />
<th:block th:include="include :: select2-css" /> <th:block th:include="include :: select2-css" />
<th:block th:include="include :: bootstrap-editable-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> </head>
<body class="white-bg"> <body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content"> <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">
<div class="form-group" hidden="hidden"> <div class="form-group" hidden="hidden">
<label class="col-sm-4 control-label">客户报价ID:</label> <label class="col-sm-4 control-label">客户报价ID:</label>
@ -23,75 +26,61 @@
<div class="form-group" shiro:hasPermission="system:customerQuote:edit"> <div class="form-group" shiro:hasPermission="system:customerQuote:edit">
<label class="col-sm-4 control-label">业务员:</label> <label class="col-sm-4 control-label">业务员:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<!-- <select class="form-control" name="businessMembers" th:field="*{businessMembers}" readonly required>--> <!-- <select class="form-control" name="businessMembers" required>-->
<!-- <option value="">请选择</option>--> <!-- <option value="">请选择</option>-->
<!-- </select>--> <!-- </select>-->
<input name="businessMembers" th:field="*{businessMembers}" class="form-control" type="text" readonly required> <input name="businessMembers" class="form-control" type="text" readonly>
</div> </div>
</div> </div>
<div class="form-group"> <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"> <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> </div>
<div class="form-group"> <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"> <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> </div>
<div class="form-group">
<div class="form-group" id="commonCurrency">
<label class="col-sm-4 control-label">报价币种:</label> <label class="col-sm-4 control-label">报价币种:</label>
<div class="col-sm-8"> <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 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> </select>
</div> </div>
</div> </div>
<div class="form-group"> <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"> <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')}"> <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}"> 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> <label th:for="${'confirmTax_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
</div> </div>
</div> </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"> <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"> <div class="col-sm-8">
<div class="input-group date"> <div class="input-group date">
<input name="pricingDate" th:field="*{pricingDate}" class="form-control" type="text" disabled> <input name="pricingDate" th:field="*{pricingDate}" class="form-control" placeholder="yyyy-MM-dd" type="text">
<span class="input-group-addon" disabled><i class="fa fa-calendar"></i></span> <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
</div> </div>
</div> </div>
</div> </div>
<div class="form-group"> <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"> <div class="col-sm-8">
<textarea readonly name="remark" th:text="*{remark}" class="form-control"></textarea> <textarea name="remark" class="form-control" th:text="*{remark}"></textarea>
</div> </div>
</div> </div>
<div class="container" style="display: none;"> <div class="container" style="display: none;">
<h4 class="form-header h4">计算</h4> <h4 class="form-header h4">计算</h4>
<div class="col-xs-12 form-row"> <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/> <label class="col-sm-2">含税总价:</label><input placeholder="美元" class="col-sm-4" name="usdSum" id="usdSum_edit" type="number" readonly/>
</div> </div>
</div> </div>
<input type="hidden" name="customerQuoteChildList" >
</form> </form>
<div class="other container">
<div class="container">
<div class="form-row"> <div class="form-row">
<div class="btn-group-sm" id="toolbar" role="group"> <div class="btn-group-sm" id="toolbar" role="group">
<span>选择报价信息</span> <span>选择报价信息</span>
<a class="btn btn-success" onclick="insertRow()"> <a class="btn btn-success" onclick="insertRow()">
<i class="fa fa-plus"></i> 添加物料 <i class="fa fa-plus"></i> 添加物料
</a> </a>
<!-- <a class="btn btn-danger multiple disabled" onclick="insertNRow()">--> <!-- <a class="btn btn-danger multiple" onclick="insertNoMaterialNoRow()">-->
<!-- <i class="fa fa-remove"></i> 添加无料号物料--> <!-- <i class="fa fa-remove"></i> 添加无料号物料-->
<!-- </a>--> <!-- </a>-->
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-sm-12 select-table table-striped"> <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> </div>
</div> </div>
@ -147,6 +138,8 @@
var processMethodDatas = [[${@dict.getType('processMethod')}]]; var processMethodDatas = [[${@dict.getType('processMethod')}]];
var userName = [[${@permission.getPrincipalProperty('userName')}]]; var userName = [[${@permission.getPrincipalProperty('userName')}]];
var loginName = [[${@permission.getPrincipalProperty('loginName')}]]; var loginName = [[${@permission.getPrincipalProperty('loginName')}]];
var prefix = ctx + "system/customerQuote";
var sysCustomerQuote = [[${sysCustomerQuote}]]; var sysCustomerQuote = [[${sysCustomerQuote}]];
var prefix = ctx + "system/customerQuote" var prefix = ctx + "system/customerQuote"
var commonCurrency = $("#commonCurrency_edit option:selected").val(); var commonCurrency = $("#commonCurrency_edit option:selected").val();
@ -154,60 +147,173 @@
focusCleanup: true, focusCleanup: true,
}); });
var customerCode1 = [[${sysCustomerQuote.customerCode}]]; var customerCode1 = [[${sysCustomerQuote.customerCode}]];
$(function() {
// $("input[name='customerFax']").val([sysCustomerQuote.customerFax]);
// $("input[name='rmbTax']").val([sysCustomerQuote.taxRate]); var commonCurrency = $("#commonCurrency_add option:selected").val();
// $("input[name='customerFax']").change(function () { $("#form-customerQuote-edit").validate(
// if ($("input[name='customerFax']").val() == "1") { {
// $("input[name='rmbTax']").val(sysCustomerQuote.taxRate); focusCleanup: true}
// } else { );
// $("input[name='rmbTax']").val(0); function submitHandler() {
// } if ($.validate.form()) {
// }); var formData = $("#form-customerQuote-edit").serializeArray();
$("#commonCurrency_edit").val(sysCustomerQuote.commonCurrency).trigger('change'); 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() { $(function() {
// console.log(loginName);
$("#form-customerQuote-edit input[name='businessMembers']").val(loginName); $("#form-customerQuote-edit input[name='businessMembers']").val(loginName);
var options = { var options = {
id: "bootstrap-table-Quote-child-edit1", id:'bootstrap-sub-table-quoteChild',
url: ctx + "system/quoteChild/list", url: ctx + "system/quoteChild/list",
queryParams: queryParams, queryParams: queryParams,
showColumns: false,
pagination: false, pagination: false,
sidePagination: "client",
clickToSelect: true,
showExport: true,
showSearch: false,
showRefresh: false,
showToggle: false, showToggle: false,
showColumns: false, showRefresh:false,
showPaginationSwitch: false, showSearch:false,
sidePagination: "client",
model: "物料报价信息", model: "物料报价信息",
columns: [ columns: [
{checkbox: true}, {checkbox: true},
{title: '序号',align: 'center', {field: 'index',align: 'center', title: "序号",
formatter: function (value, row, index) { 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: 'materialId',align: 'center',visible: false},
{title: '物料报价主表id',field: 'quoteId',align: 'center',visible: false},
{title: '物料索引',field: 'materialId',align: 'center',visible: false},
{title: '料号',field: 'materialCode',align: 'center'}, {title: '料号',field: 'materialCode',align: 'center'},
{title: '物料名称',field: 'materialName',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', {title: '物料类型',field: 'materialType',align: 'center',
formatter: function(value, row, index) { formatter: function(value, row, index) {
$.table.selectCategoryLabel(materialTypeDatas, value); return $.table.selectCategoryLabel(materialTypeDatas, value);
} }
}, },
{ title: '描述',field: 'describe',align: 'center'}, { title: '描述',field: 'describe',align: 'center'},
{title: '型号',field: 'materialModel',align: 'center'}, {title: '型号',field: 'materialModel',align: 'center'},
{title: '品牌',field: 'brand',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', { title: '单位',field: 'unit',align: 'center',
formatter: function(value, row, index) { formatter: function(value, row, index) {
return $.table.selectDictLabel(sysUnitClassDatas, value); return $.table.selectDictLabel(sysUnitClassDatas, value);
@ -218,21 +324,7 @@
return $.table.selectDictLabel(processMethodDatas, value); 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: '最新报价(RMB)',field: 'recentQuotationRMB',align: 'center',},
{ title: '最新报价(美元)',field: 'recentQuotationUSD',align: 'center',}, { title: '最新报价(美元)',field: 'recentQuotationUSD',align: 'center',},
{ title: '最新报价历史',align: 'center', { title: '最新报价历史',align: 'center',
@ -243,9 +335,7 @@
return actions.join(''); return actions.join('');
} }
}, },
// {title: '国内税率',field: 'countTax',align: 'center',}, {title: '物料的数量',field: 'materialNum',align: 'center',
// { title: '美元汇率',field: 'usdTax', align: 'center',},
{field: 'materialNum',align: 'center',title: '物料的数量',
editable:{ editable:{
type : 'text', type : 'text',
mode: 'inline', 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: '物料的不含税单价(美元)', {title: '物料的不含税单价(美元)',
field: 'materialNoUsd', field: 'materialNoUsd',
align: 'center', align: 'center',
@ -316,86 +409,126 @@
} }
} }
}, },
{title: '物料的含税单价(RMB)',field: 'materialRmb',align: 'center'}, { title: '物料的含税单价(美元)',field: 'materialUsd',align: 'center',},
{title: '物料的含税总价(RMB)',field: 'materialNoRmbSum',align: 'center'}, { title: '物料的含税总价(美元)',field: 'materialUsdSum', align: 'center',},
{title: '物料的不含税总价(RMB)',field: 'materialRmbSum',align: 'center'}, { title: '物料的不含税总价(美元)',field: 'materialNoUsdSum',align: 'center',},
{title: '物料的含税单价(美元)',field: 'materialUsd',align: 'center'}, {field: 'createBy', align: 'center',title: '录入人',visible: false},
{title: '物料的含税总价(美元)',field: 'materialUsdSum',align: 'center'}, {field: 'createTime',align: 'center',title: '录入时间',visible: false},
{title: '物料的不含税总价(美元)', field: 'materialNoUsdSum',align: 'center'}, {field: 'updateBy',align: 'center',title: '更新人',visible: false},
{field: 'updateTime',align: 'center',title: '上次更新时间',visible: false},
{field: 'remark',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', {title: '操作', align: 'center',
formatter: function (value, row, index) { formatter: function (value, row, index) {
var actions = []; 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(''); return actions.join('');
} }
} }
], ],
onEditableSave:function(field, row, oldValue, $el){ onEditableSave:function(field, row, oldValue, $el){
var commonCurrency1 = $("#commonCurrency_edit option:selected").val(); var commonCurrency1 = $("#commonCurrency_add option:selected").val();
var rmb1 = $("#rmbTax_edit").val(); var rmbRateInput = parseFloat($("#rmbTax_add").val()) || 0;
if (rmb1 =='' || rmb1== null){ var rmbRate = rmbRateInput / 100;
rmb1 = 0; rmbRate = parseFloat(rmbRate.toFixed(2)); // 确保rmbRate转换为两位小数的浮点数
}else{ var usdRate = parseFloat($("#usdTax_add").val()) || 0;
rmb1 = $("#rmbTax_edit").val();
} var testMaterialNum = parseFloat(row.materialNum) || 0;
var rmb = Number(rmb1).toFixed(2) / 100; if (commonCurrency1 === '1') {
var usd = $("#usdTax_edit").val(); // RMB为基准货币
if (usd =='' || usd== null){ row.materialRmb = (parseFloat(row.materialNoRmb) * (1 + rmbRate)).toFixed(2);
usd = 0; row.materialRmbSum = (parseFloat(row.materialRmb) * testMaterialNum).toFixed(2);
}else{ row.materialNoRmbSum = (parseFloat(row.materialNoRmb) * testMaterialNum).toFixed(2);
usd = Number(usd).toFixed(2); } else if (commonCurrency1 === '2') {
} // USD为基准货币
console.log(commonCurrency1); row.materialUsd = row.materialNoUsd
if(commonCurrency1 == 1){ row.materialUsdSum = (parseFloat(row.materialUsd) * testMaterialNum).toFixed(2);
row.materialRmb = Number(row.materialNoRmb * Number(1 + rmb)); row.materialNoUsdSum = (parseFloat(row.materialNoUsd) * testMaterialNum).toFixed(2);
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);
} }
else if(commonCurrency1 == 2){
row.materialUsd = Number(row.materialNoUsd).toFixed(2); // 确保getTotalAmount函数存在且正确引用
row.materialUsdSum = Number(row.materialNum * row.materialUsd).toFixed(2); if (typeof getTotalAmount === 'function') {
row.materialNoUsdSum = Number(row.materialNoUsd * row.materialNum).toFixed(2); getTotalAmount();
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()
}, },
}; };
$.table.init(options); $.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 = { //监听币种的变化
// 传递参数查询参数 $(document).ready(function() {
pageSize: params.limit, $("#commonCurrency_add").on('change', function() {
pageNum: params.offset / params.limit + 1, var selectedValue = $(this).val();
quoteId: sysCustomerQuote.supplierCode, var $radioTax = $('input:radio[name="confirmTax"][value="1"]');
}; var $radioNo = $('input:radio[name="confirmTax"][value="0"]');
curParams.quoteId = sysCustomerQuote.supplierCode; // 设置含税单选按钮选中
return curParams; if(selectedValue ==="1"){
} console.log("1:"+selectedValue);
function submitHandler() { $radioNo.removeAttr('checked');
if ($.validate.form()) { $radioTax.prop('checked','checked');
var formData = $("#form-customerQuote-edit").serializeArray();
console.log("formData",formData); // $("input[name='confirmFax']").val(1);
var tableData = $("#bootstrap-table-Quote-child-edit1").bootstrapTable('getData'); console.log($radioTax.prop('checked'));
console.log("tableData",JSON.stringify(tableData)); }else if(selectedValue ==="2"){
var rows = tableData.length; console.log("2:"+selectedValue);
if(rows==0){ $radioTax.removeAttr('checked',false);
$.modal.alertWarning("子表数据不能为空!"); $radioNo.prop('checked',true);
}else{ // $radioTax.removeAttr('checked');
formData.push({"name": "sysCustomerQuoteChildList", "value": tableData}); // $radioNo.attr('checked','checked');
var jsonData = $.common.formDataToJson(formData); console.log($radioNo.prop('checked'));
$.operate.saveJson(prefix + "/edit", jsonData);
} }
} });
});
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) { function doSubmit(index, layero, uniqueId) {
console.log(uniqueId); console.log(uniqueId);
@ -436,12 +569,13 @@
materialName: rowData.materialName, materialName: rowData.materialName,
materialType: rowData.materialType, materialType: rowData.materialType,
describe: rowData.describe, describe: rowData.describe,
brand: rowData.brand, materialModel: rowData.materialModel,
unit: rowData.unit, unit: rowData.unit,
brand: rowData.brand,
processMethod: rowData.processMethod, processMethod: rowData.processMethod,
photoUrl: rowData.photoUrl, photoUrl: rowData.photoUrl,
countTax: '', countTax: $("#rmbTax_add").val(),
usdTax: '', usdTax: $("#usdTax_add").val(),
materialNum: "", materialNum: "",
// materialSole: "", // materialSole: "",
recentQuotationRMB: quotationData.data.materialRmb || '', recentQuotationRMB: quotationData.data.materialRmb || '',
@ -498,7 +632,6 @@
} }
function insertRow() { function insertRow() {
var url = ctx + "erp/material/select"; var url = ctx + "erp/material/select";
var options = { var options = {
@ -509,10 +642,10 @@
$.modal.openOptions(options); $.modal.openOptions(options);
} }
/* 删除指定表格行 */ /* 删除指定表格行 */
function removeRow(rowData){ function removeRow(materialCode){
$.table.bootstrapTable('remove', { $("#bootstrap-sub-table-quoteChild").bootstrapTable('remove', {
field: 'id', field: 'materialCode',
values: rowData.id values: materialCode
}); });
getTotalAmount(); getTotalAmount();
} }
@ -521,40 +654,56 @@
minView: "month", minView: "month",
autoclose: true autoclose: true
}); });
//计算 function getTotalAmount() {
function getTotalAmount(){ var getData = $("#bootstrap-sub-table-quoteChild").bootstrapTable('getData');
let getData = $("#bootstrap-table-Quote-child-edit1").bootstrapTable('getData', true);
var enterprise = 0; var enterprise = 0;
let enterpriseSum = 0; var enterpriseSum = 0;
let noRmb = 0;let rmb = 0;let noRmbSum = 0; var noRmb = 0;
let rmbSum = 0;let noUsd = 0;let usd = 0; var rmb = 0;
let noUsdSum = 0;let usdSum = 0; var noRmbSum = 0;
for(var i=0;i<getData.length;i++){ var rmbSum = 0;
enterprise += 1; var noUsd = 0;
enterpriseSum = parseInt(enterprise + getData[i].materialNum).toFixed(0); var usd = 0;
noRmb = parseFloat(noRmb + getData[i].materialNoRmb).toFixed(2); var noUsdSum = 0;
rmb = parseFloat(rmb + getData[i].materialRmb).toFixed(2) ; var usdSum = 0;
noRmbSum = parseFloat(noRmbSum + getData[i].materialNoRmbSum).toFixed(2);
rmbSum = parseFloat(rmbSum + getData[i].materialRmbSum).toFixed(2); // 计算企业数量和物料数量总和
noUsd = parseFloat(noUsd + getData[i].materialNoUsd).toFixed(2) ; enterprise = getData.length; // 直接获取数据长度
usd = parseFloat(usd + getData[i].materialUsd).toFixed(2) ; enterpriseSum = getData.reduce((sum, item) => sum + (parseInt(item.materialNum) || 0), 0);
noUsdSum = parseFloat(noUsdSum + getData[i].materialNoUsdSum).toFixed(2);
usdSum = parseFloat(usdSum + getData[i].materialUsdSum).toFixed(2); // 先累加数值,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); noRmb = noRmb.toFixed(2);
$("#rmb_edit").val(rmb); rmb = rmb.toFixed(2);
$("#noRmbSum_edit").val(noRmbSum); noRmbSum = noRmbSum.toFixed(2);
$("#rmbSum_edit").val(rmbSum); rmbSum = rmbSum.toFixed(2);
$("#noUsd_edit").val(noUsd); noUsd = noUsd.toFixed(2);
$("#usd_edit").val(usd); usd = usd.toFixed(2);
$("#noUsdSum_edit").val(noUsdSum); noUsdSum = noUsdSum.toFixed(2);
$("#usdSum_edit").val(usdSum); usdSum = usdSum.toFixed(2);
}
// 结算金额 // 设置表单输入值
function toPercentage(numerator, denominator) { $("input[name='enterprise']").val(enterprise);
return (numerator / denominator) * 100 + '%'; $("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); $.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> </script>
</body> </body>
</html> </html>
Loading…
Cancel
Save