Browse Source

[fix] 销售管理

新增销售估价的新增页面
新增销售估价的物料选择页面
销售估价实体类新增 新增估价详情集合
新增 加载新增销售估价 物料选择弹窗 后端接口
新增销售估价 物料选择 后端接口
新增 批量新增销售估价详情后端接口
新增 批量新增销售估价后端接口
修改新增销售估价后端接口,加上对销售估价详情表的处理
dev
liuxiaoxu 4 months ago
parent
commit
bb6b2328c9
  1. 47
      ruoyi-admin/src/main/java/com/ruoyi/sales/controller/SalesEstimateController.java
  2. 17
      ruoyi-admin/src/main/java/com/ruoyi/sales/domain/SalesEstimate.java
  3. 9
      ruoyi-admin/src/main/java/com/ruoyi/sales/mapper/SalesEstimateDetailMapper.java
  4. 8
      ruoyi-admin/src/main/java/com/ruoyi/sales/mapper/SalesEstimateMapper.java
  5. 30
      ruoyi-admin/src/main/java/com/ruoyi/sales/service/impl/SalesEstimateServiceImpl.java
  6. 81
      ruoyi-admin/src/main/resources/mapper/sales/SalesEstimateDetailMapper.xml
  7. 52
      ruoyi-admin/src/main/resources/mapper/sales/SalesEstimateMapper.xml
  8. 412
      ruoyi-admin/src/main/resources/templates/sales/estimate/add.html
  9. 102
      ruoyi-admin/src/main/resources/templates/sales/estimate/estimateMaterialSelect.html

47
ruoyi-admin/src/main/java/com/ruoyi/sales/controller/SalesEstimateController.java

@ -1,15 +1,16 @@
package com.ruoyi.sales.controller;
import java.util.List;
import com.ruoyi.erp.domain.ErpMaterialVo;
import com.ruoyi.erp.service.IErpMaterialService;
import com.ruoyi.system.domain.SysMakeOrder;
import com.ruoyi.system.domain.SysSalesOrderChild;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.sales.domain.SalesEstimate;
@ -34,6 +35,9 @@ public class SalesEstimateController extends BaseController
@Autowired
private ISalesEstimateService salesEstimateService;
@Autowired
private IErpMaterialService materialService;
@RequiresPermissions("sales:estimate:view")
@GetMapping()
public String estimate()
@ -69,7 +73,7 @@ public class SalesEstimateController extends BaseController
}
/**
* 新增销售估价
* 新增销售估价-业务
*/
@GetMapping("/add")
public String add()
@ -78,17 +82,44 @@ public class SalesEstimateController extends BaseController
}
/**
* 新增保存销售估价
* 新增保存销售估价-业务
*/
@RequiresPermissions("sales:estimate:add")
@Log(title = "销售估价", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(SalesEstimate salesEstimate)
public AjaxResult addSave(@RequestBody SalesEstimate salesEstimate)
{
return toAjax(salesEstimateService.insertSalesEstimate(salesEstimate));
}
/**
* 加载新增销售估价 物料选择弹窗
*/
@GetMapping("/estimateMaterialSelect")
public String estimateMaterialSelect()
{
return prefix + "/estimateMaterialSelect";
}
/**
* 新增销售估价 物料选择
*/
@ResponseBody
@PostMapping("/getEstimateMaterialList")
public TableDataInfo getEstimateMaterialList( )
{
startPage();
List<ErpMaterialVo> erpMaterialVos = materialService.selectAllErpMaterialList();
return getDataTable(erpMaterialVos);
}
/**
* 修改销售估价
*/

17
ruoyi-admin/src/main/java/com/ruoyi/sales/domain/SalesEstimate.java

@ -2,6 +2,8 @@ package com.ruoyi.sales.domain;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
@ -88,8 +90,14 @@ public class SalesEstimate extends BaseEntity
private BigDecimal allNoTaxDollar;
/** 定价日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "定价日期")
private Date pricingDate;
/** 销售估价详情集合 */
private List<SalesEstimateDetail> salesEstimateDetailList;
public void setSalesEstimateId(Long salesEstimateId)
{
this.salesEstimateId = salesEstimateId;
@ -271,6 +279,14 @@ public class SalesEstimate extends BaseEntity
return pricingDate;
}
public List<SalesEstimateDetail> getSalesEstimateDetailList() {
return salesEstimateDetailList;
}
public void setSalesEstimateDetailList(List<SalesEstimateDetail> salesEstimateDetailList) {
this.salesEstimateDetailList = salesEstimateDetailList;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
@ -299,6 +315,7 @@ public class SalesEstimate extends BaseEntity
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("remark", getRemark())
.append("salesEstimateDetailList", getSalesEstimateDetailList())
.toString();
}
}

9
ruoyi-admin/src/main/java/com/ruoyi/sales/mapper/SalesEstimateDetailMapper.java

@ -35,6 +35,15 @@ public interface SalesEstimateDetailMapper
*/
public int insertSalesEstimateDetail(SalesEstimateDetail salesEstimateDetail);
/**
* 批量新增销售估价详情
*
* @param salesEstimateDetails 销售估价详情集合
* @return 结果
*/
public int batchInsertSalesEstimateDetails(List<SalesEstimateDetail> salesEstimateDetails);
/**
* 修改销售估价详情
*

8
ruoyi-admin/src/main/java/com/ruoyi/sales/mapper/SalesEstimateMapper.java

@ -35,6 +35,14 @@ public interface SalesEstimateMapper
*/
public int insertSalesEstimate(SalesEstimate salesEstimate);
/**
* 批量新增销售估价
*
* @param salesEstimates 销售估价集合
* @return 结果
*/
public int batchInsertSalesEstimates(List<SalesEstimate> salesEstimates);
/**
* 修改销售估价
*

30
ruoyi-admin/src/main/java/com/ruoyi/sales/service/impl/SalesEstimateServiceImpl.java

@ -1,8 +1,13 @@
package com.ruoyi.sales.service.impl;
import java.util.Date;
import java.util.List;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.sales.domain.SalesEstimateDetail;
import com.ruoyi.sales.mapper.SalesEstimateDetailMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.sales.mapper.SalesEstimateMapper;
@ -22,6 +27,12 @@ public class SalesEstimateServiceImpl implements ISalesEstimateService
@Autowired
private SalesEstimateMapper salesEstimateMapper;
@Autowired
private SalesEstimateDetailMapper salesEstimateDetailMapper;
@Autowired
private RedisCache redisCache;
/**
* 查询销售估价
*
@ -56,8 +67,25 @@ public class SalesEstimateServiceImpl implements ISalesEstimateService
public int insertSalesEstimate(SalesEstimate salesEstimate)
{
String loginName = ShiroUtils.getLoginName();
String salesEstimateCode = redisCache.generateBillNo("GJ");
salesEstimate.setCreateBy(loginName);
salesEstimate.setCreateTime(DateUtils.getNowDate());
salesEstimate.setCreateTime(new Date());
salesEstimate.setSalesEstimateCode(salesEstimateCode);
List<SalesEstimateDetail> salesEstimateDetailList = salesEstimate.getSalesEstimateDetailList();
if (salesEstimateDetailList != null && salesEstimateDetailList.size() > 0) {
for (SalesEstimateDetail salesEstimateDetail : salesEstimateDetailList) {
salesEstimateDetail.setSalesEstimateCode(salesEstimateCode);
salesEstimateDetail.setCreateBy(loginName);
salesEstimateDetail.setCreateTime(new Date());
}
salesEstimateDetailMapper.batchInsertSalesEstimateDetails(salesEstimateDetailList);
}
return salesEstimateMapper.insertSalesEstimate(salesEstimate);
}

81
ruoyi-admin/src/main/resources/mapper/sales/SalesEstimateDetailMapper.xml

@ -139,6 +139,87 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
</insert>
<insert id="batchInsertSalesEstimateDetails" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="estimateDetailId">
INSERT INTO sales_estimate_detail
(
sales_estimate_code,
material_gear_position,
usd_rate,
profit_rate,
material_no,
material_name,
material_type,
material_photo_url,
material_unit,
material_brand,
material_describe,
material_process_method,
material_num,
no_tax_rmb,
tax_rmb,
all_no_tax_rmb,
all_tax_rmb,
tax_dollar,
no_tax_dollar,
all_tax_dollar,
all_no_tax_dollar,
no_tax_shipping_costs,
no_tax_service_costs,
no_tax_develop_costs,
no_tax_labor_costs,
no_tax_promotional_costs,
no_tax_business_costs,
no_tax_manages_costs,
no_tax_material_costs,
no_tax_operating_costs,
tax_operating_costs,
create_by,
create_time
)
VALUES
<foreach collection="list" item="item" index="index" open="(" close=")" separator="),(">
#{item.salesEstimateCode},
#{item.materialGearPosition},
#{item.usdRate},
#{item.profitRate},
#{item.materialNo},
#{item.materialName},
#{item.materialType},
#{item.materialPhotoUrl},
#{item.materialUnit},
#{item.materialBrand},
#{item.materialDescribe},
#{item.materialProcessMethod},
#{item.materialNum},
#{item.noTaxRmb},
#{item.taxRmb},
#{item.allNoTaxRmb},
#{item.allTaxRmb},
#{item.taxDollar},
#{item.noTaxDollar},
#{item.allTaxDollar},
#{item.allNoTaxDollar},
#{item.noTaxShippingCosts},
#{item.noTaxServiceCosts},
#{item.noTaxDevelopCosts},
#{item.noTaxLaborCosts},
#{item.noTaxPromotionalCosts},
#{item.noTaxBusinessCosts},
#{item.noTaxManagesCosts},
#{item.noTaxMaterialCosts},
#{item.noTaxOperatingCosts},
#{item.taxOperatingCosts},
#{item.createBy},
#{item.createTime}
</foreach>
</insert>
<update id="updateSalesEstimateDetail" parameterType="SalesEstimateDetail">
update sales_estimate_detail
<trim prefix="SET" suffixOverrides=",">

52
ruoyi-admin/src/main/resources/mapper/sales/SalesEstimateMapper.xml

@ -109,6 +109,58 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
</insert>
<insert id="batchInsertSalesEstimates" parameterType="SalesEstimate" useGeneratedKeys="true" keyProperty="salesEstimateId">
INSERT INTO sales_estimate
(
sales_estimate_code,
business_members,
estimate_status,
enterprise_code,
enterprise_name,
material_sum,
enterprise_sum,
common_currency,
usd_rate,
no_tax_rmb,
tax_rmb,
all_no_tax_rmb,
all_tax_rmb,
tax_dollar,
no_tax_dollar,
all_tax_dollar,
all_no_tax_dollar,
pricing_date,
create_by,
create_time,
remark
)
VALUES
<foreach collection="list" item="item" index="index" open="(" close=")" separator="),(">
#{item.salesEstimateCode},
#{item.businessMembers},
#{item.estimateStatus},
#{item.enterpriseCode},
#{item.enterpriseName},
#{item.materialSum},
#{item.enterpriseSum},
#{item.commonCurrency},
#{item.usdRate},
#{item.noTaxRmb},
#{item.taxRmb},
#{item.allNoTaxRmb},
#{item.allTaxRmb},
#{item.taxDollar},
#{item.noTaxDollar},
#{item.allTaxDollar},
#{item.allNoTaxDollar},
#{item.pricingDate},
#{item.createBy},
#{item.createTime},
#{item.remark}
</foreach>
</insert>
<update id="updateSalesEstimate" parameterType="SalesEstimate">
update sales_estimate
<trim prefix="SET" suffixOverrides=",">

412
ruoyi-admin/src/main/resources/templates/sales/estimate/add.html

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

102
ruoyi-admin/src/main/resources/templates/sales/estimate/estimateMaterialSelect.html

@ -0,0 +1,102 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
<th:block th:include="include :: header('选择物料信息列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
<div class="row">
<div class="col-sm-12 search-collapse">
<form id="formId">
<div class="select-list">
<ul>
<li>
<label>料号:</label>
<input type="text" name="materialNo"/>
</li>
<li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
</li>
</ul>
</div>
</form>
</div>
<div class="row">
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-estimateMaterialSelect-table"></table>
</div>
</div>
</div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
var prefix = ctx + "sales/estimate";
var materialTypeDatas = [[${@category.getChildByCode('materialType')}]];
var processMethodDatas = [[${@dict.getType('processMethod')}]];
$(function() {
var options = {
id: 'bootstrap-estimateMaterialSelect-table',
showSearch: false,
showRefresh: false,
showToggle: false,
clickToSelect: true, // 点击选中行
singleSelect: true, // 单选
url: prefix + "/getEstimateMaterialList",
modalName: "物料信息",
columns: [{
checkbox: true
},
{
title: '料号',
field: 'materialNo',
},
{
title: '图片',
field: 'materialPhotourl',
},
{
title: '物料名称',
field: 'materialName',
},
{
title: '物料类型',
field: 'materialType',
formatter: function(value, row, index) {
return $.table.selectCategoryLabel(materialTypeDatas, value);
}
},
{
title: '描述',
field: 'describe',
},
{
title: '品牌',
field: 'brand',
},
{
title: '单位',
field: 'unit',
},
{
title: '加工方式',
field: 'processMethod',
formatter: function(value, row, index) {
return $.table.selectDictLabel(processMethodDatas, value);
}
},
{
title: '入库部门',
field: 'warehouseDept',
visible:false
}
]
};
$.table.init(options);
});
</script>
</body>
</html>
Loading…
Cancel
Save