north-glass-erp/northglass-erp/src/views/sd/glassPrice/GlassPriceSet.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
north-glass-erp/northglass-erp/src/views/sd/glassPrice/ProducePriceCompute.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
north-glass-erp/northglass-erp/src/views/sd/glassPrice/ProductList.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
north-glass-erp/northglass-erp/src/views/sd/order/CreateOrder.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
north-glass-erp/src/main/java/com/example/erp/controller/sd/GlassPriceBasicController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
north-glass-erp/src/main/java/com/example/erp/entity/sd/GlassPriceBasic.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
north-glass-erp/src/main/java/com/example/erp/mapper/sd/GlassPriceBasicMapper.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
north-glass-erp/src/main/java/com/example/erp/service/sd/GlassPriceBasicService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
north-glass-erp/northglass-erp/src/views/sd/glassPrice/GlassPriceSet.vue
@@ -43,6 +43,14 @@ return } } request.post(`/glassPriceBasic/save`,value).then((res) => { if(res.code==='200' && res.data===true){ ElMessage.success("数据保存成功") }else{ ElMessage.warning("此膜系已经存在,请重新选择") } }) } </script> north-glass-erp/northglass-erp/src/views/sd/glassPrice/ProducePriceCompute.vue
@@ -6,6 +6,7 @@ import {VXETable} from "vxe-table"; import {ElMessage} from "element-plus"; import request from "@/utils/request"; import router from "@/router"; const { t } = useI18n() let dialogVisible = ref(false) const xGrid = ref() @@ -84,7 +85,7 @@ toolbarConfig: { buttons: [ {'code': 'addProducts', 'name': '选择产品',disabled: false}, {'code': 'saveOrder', 'name': '转订单',status: 'primary',icon: 'vxe-icon-save',disabled: false}, {'code': 'reorder', 'name': '转订单',status: 'primary',icon: 'vxe-icon-save',disabled: false}, ], zoom: true, @@ -102,14 +103,35 @@ dialogVisible.value = true break } case 'reorder': { if($grid.getTableData().fullData.length === 0){ ElMessage.warning("请先添加产品") return } router.push({ path: '/main/order/createOrder', query:{ produceList: JSON.stringify($grid.getTableData().fullData) } }) break } } } } } const getChildData = (data) => { alert(1) const getChildData = (data,product) => { data.productId = product.id data.productName =product.productName request.post(`/glassPriceBasic/glassPriceComputed/${product.id}`).then(res => { if (res.code === '200' ) { data.price = res.data xGrid.value.insertAt(data) dialogVisible.value = false } }) } </script> north-glass-erp/northglass-erp/src/views/sd/glassPrice/ProductList.vue
@@ -178,8 +178,7 @@ } } let datas = data.data datas.id = xGrid.value.getRadioRecord().id emit('getChildData',datas) emit('getChildData',datas,xGrid.value.getRadioRecord()) } } @@ -217,9 +216,9 @@ }, formConfig: { data: { name: '', role: '', age: '' width: '', height: '', quantity: '' }, items: [ { field: 'width', title: '宽:', itemRender: { name: 'VxeInput' } }, north-glass-erp/northglass-erp/src/views/sd/order/CreateOrder.vue
@@ -744,6 +744,11 @@ //启用表格拖动选中 addListener(xGrid.value,gridOptions) const productData = JSON.parse(route.query.produceList) if (typeof productData !== 'undefined' || productData !== null || productData !== '' || productData !== '\n' || productData !== '\r'){ xGrid.value.insertAt(productData) } const str = route.query.orderId || history.state.orderId if (typeof str === 'undefined' || str === null || str === '' || str === '\n' || str === '\r'){ gridOptions.menuConfig.body.options[0][11].disabled = true north-glass-erp/src/main/java/com/example/erp/controller/sd/GlassPriceBasicController.java
New file @@ -0,0 +1,38 @@ package com.example.erp.controller.sd; import com.example.erp.common.Result; import com.example.erp.service.sd.GlassPriceBasicService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.Map; /** * 产品价格计算 */ @RestController @RequestMapping("/glassPriceBasic") @Api(value="产品价格controller",tags={"产品价格计算操作接口"}) public class GlassPriceBasicController { private final GlassPriceBasicService glassPriceBasicService; public GlassPriceBasicController(GlassPriceBasicService glassPriceBasicService) { this.glassPriceBasicService = glassPriceBasicService; } @ApiOperation("保存产品价格数据") @PostMapping("/save") public Result save(@RequestBody Map<String,Object> prams ){ return Result.seccess(glassPriceBasicService.save(prams)); } @ApiOperation("计算成品价格") @PostMapping("/glassPriceComputed/{productId}") public Result glassPriceComputed(@PathVariable String productId){ return Result.seccess(glassPriceBasicService.glassPriceComputed(productId)); } } north-glass-erp/src/main/java/com/example/erp/entity/sd/GlassPriceBasic.java
New file @@ -0,0 +1,20 @@ package com.example.erp.entity.sd; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import lombok.Data; import java.time.LocalDate; import java.time.LocalDateTime; @Data public class GlassPriceBasic { @TableId(type = IdType.AUTO) private Integer id; private String type; private Double thickness; private String name; private Double price; private String json; private LocalDateTime createTime; } north-glass-erp/src/main/java/com/example/erp/mapper/sd/GlassPriceBasicMapper.java
New file @@ -0,0 +1,9 @@ package com.example.erp.mapper.sd; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.example.erp.entity.sd.GlassPriceBasic; import org.apache.ibatis.annotations.Mapper; @Mapper public interface GlassPriceBasicMapper extends BaseMapper<GlassPriceBasic> { } north-glass-erp/src/main/java/com/example/erp/service/sd/GlassPriceBasicService.java
New file @@ -0,0 +1,91 @@ package com.example.erp.service.sd; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.TypeReference; import com.baomidou.dynamic.datasource.annotation.DS; import com.example.erp.entity.sd.GlassPriceBasic; import com.example.erp.entity.sd.ProductDetail; import com.example.erp.mapper.sd.GlassPriceBasicMapper; import com.example.erp.mapper.sd.ProductDetailMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import java.util.List; import java.util.Map; import java.util.Objects; @Service @DS("sd") public class GlassPriceBasicService { private final GlassPriceBasicMapper glassPriceBasicMapper; @Autowired private ProductDetailMapper productDetailMapper; public GlassPriceBasicService(GlassPriceBasicMapper glassPriceBasicMapper) { this.glassPriceBasicMapper = glassPriceBasicMapper; } //保存玻璃价格 public Boolean save(Map<String, Object> prams) { GlassPriceBasic glassPriceBasic = new GlassPriceBasic(); glassPriceBasic.setThickness( Double.parseDouble(prams.get("thickness").toString().replaceAll("[^0-9\\.]", "")) ); glassPriceBasic.setPrice(Double.parseDouble(prams.get("price").toString())); glassPriceBasic.setJson(prams.toString()); glassPriceBasic.setType(prams.get("type").toString()); String type = prams.get("type").toString(); //判断 是哪种类型 if(Objects.equals(type, "glass")) { glassPriceBasic.setName(prams.get("thickness").toString() + prams.get("color").toString()); }else if(Objects.equals(type, "hollow")){ glassPriceBasic.setName( prams.get("thickness").toString() + prams.get("gasType").toString() + prams.get("types").toString()); } else if (Objects.equals(type, "interlayer")) { glassPriceBasic.setName( prams.get("thickness").toString() + prams.get("color").toString() + prams.get("types").toString()); } GlassPriceBasic glassPriceBasic1 = glassPriceBasicMapper.selectOne(new QueryWrapper<GlassPriceBasic>().eq("name", glassPriceBasic.getName())); if(glassPriceBasic1 != null){ return false; } return glassPriceBasicMapper.insert(glassPriceBasic)>0; } public Double glassPriceComputed(String productId) { List<ProductDetail> productDetails = productDetailMapper .selectList(new QueryWrapper<ProductDetail>().eq("prod_id", productId)); final Double[] money = {0.0}; productDetails.forEach(productDetail -> { Map<String,String> separation = JSON.parseObject( productDetail.getSeparation(), new TypeReference<Map<String, String>>(){}); String name = ""; switch (productDetail.getDetailType()) { case "glass": name = separation.get("thickness") + separation.get("color"); break; case "hollow": name = separation.get("thickness") + separation.get("gasType") + separation.get("type"); break; case "interlayer": name = separation.get("thickness") + separation.get("color") + separation.get("type"); break; } GlassPriceBasic glassPriceBasic = glassPriceBasicMapper .selectOne(new QueryWrapper<GlassPriceBasic>().eq("name", name)); if(glassPriceBasic == null) { money[0]= 0.0; return; } money[0] += glassPriceBasic.getPrice(); }); return money[0]; } }