商品信息原先生成的不符合要求,重新生成,包括一个附表商品价格信息表
一、采用TAB主题一对多的模式
因为主键,在online表单配置是灰的,所以不能进行外键管理,只能通过下面数据库进行关联录入,否则online界面上不能录入。
效果如下:
二、生成代码使用页面风格tab风格
三、生成tab风格的代码还是需要进行修改
1、没有详情了,所以ErpGoodsList.vue需要增加
<a-menu-item>
<a @click="handleDetail(record)">详情</a>
</a-menu-item>
同时需要增加下面信息:
增加几个价格信息的列
{
title:'采购价格',
align:"center",
dataIndex: 'purchasePrice'
},
{
title:'销售价格',
align:"center",
dataIndex: 'salePrice'
},
{
title:'零售价格',
align:"center",
dataIndex: 'retailPrice'
},
list修改成如下:
url: {
list: "/goods/erpGoodsDto/list",
同时在ErpGoodsModal.vue文件把按钮要隐藏掉
:okButtonProps="{ class:{'jee-hidden': disableSubmit}
2、ErpGoodsForm.vue增加两个名称显示
<a-col :xs="24" :sm="12">
<a-form-model-item label="类别编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="categoryId">
<j-popup
v-model="model.categoryId"
field="categoryId"
org-fields="id,name"
dest-fields="categoryId,categoryName"
code="SelectorGoodsCategory"
:multi="true"
@input="popupCallback"
/>
<a-input v-model="model.categoryName"></a-input>
</a-form-model-item>
</a-col>
<a-col :xs="24" :sm="12">
<a-form-model-item label="品牌编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="brandId">
<j-popup
v-model="model.brandId"
field="brandId"
org-fields="id,name"
dest-fields="brandId,brandName"
code="SelectorBrand"
:multi="true"
@input="popupCallback"
/>
<a-input v-model="model.brandName"></a-input>
</a-form-model-item>
</a-col>
3、后端增加相关文件
3.1 ErpGoodsDto.java文件
package com.nbcio.modules.erp.goods.dto;
import java.io.Serializable;
import org.jeecg.common.aspect.annotation.Dict;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class ErpGoodsDto implements Serializable {
private static final long serialVersionUID = 1L;
/**ID*/
private java.lang.String id;
/**编号*/
private java.lang.String code;
/**名称*/
private java.lang.String name;
/**SPU编号*/
//private java.lang.String spuId;
/**类别编号*/
private java.lang.String categoryId;
/**类别名称*/
private java.lang.String categoryName;
/**品牌编号*/
private java.lang.String brandId;
/**品牌名称*/
private java.lang.String brandName;
/**规格*/
private java.lang.String spec;
/**单位*/
private java.lang.String unit;
/**采购价格*/
private java.math.BigDecimal purchasePrice;
/**销售价格*/
private java.math.BigDecimal salePrice;
/**零售价格*/
private java.math.BigDecimal retailPrice;
/**税率(%)*/
private java.math.BigDecimal taxRate;
/**销项税率(%)*/
private java.math.BigDecimal saleTaxRate;
/**数量*/
private java.lang.Integer num;
/**总价格*/
private java.math.BigDecimal totalPrice;
/**库存数量*/
private java.lang.Integer stockNum;
@Dict(dicCode = "erp_status")
@ApiModelProperty(value = "状态")
private java.lang.Integer status;
}
3.2 ErpGoodsDtoController.java文件
package com.nbcio.modules.erp.goods.controller;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.jeecg.common.api.vo.Result;
import com.nbcio.modules.erp.goods.dto.ErpGoodsDto;
import com.nbcio.modules.erp.goods.service.IErpGoodsDtoService;
import com.nbcio.modules.erp.goods.vo.QueryGoodsVo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.system.base.controller.JeecgController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.aspect.annotation.AutoLog;
/**
* @Description: erp_goods_dto
* @Author: nbacheng
* @Date: 2023-02-09
* @Version: V1.0
*/
@Api(tags="erp_goods_dto")
@RestController
@RequestMapping("/goods/erpGoodsDto")
@Slf4j
public class ErpGoodsDtoController extends JeecgController<ErpGoodsDto, IErpGoodsDtoService> {
@Autowired
private IErpGoodsDtoService erpGoodsDtoService;
/**
* 分页列表查询
*
* @param erpGoods
* @param pageNo
* @param pageSize
* @param req
* @return
*/
@AutoLog(value = "erp_goods-商品信息列表查询")
@ApiOperation(value="erp_goods-商品信息列表查询", notes="erp_goods-商品信息列表查询")
@GetMapping(value = "/list")
public Result<?> queryGoodsList(QueryGoodsVo queryGoodsvo,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
Page<ErpGoodsDto> page = new Page<ErpGoodsDto>(pageNo, pageSize);
IPage<ErpGoodsDto> pageList = erpGoodsDtoService.queryGoodsList(page, queryGoodsvo);
return Result.OK(pageList);
}
/**
* 通过ids查询
*
* @param ids
* @return
*/
@AutoLog(value = "商品-通过ids查询")
@ApiOperation(value="商品-通过ids查询", notes="商品-通过ids查询")
@GetMapping(value = "/queryByIds")
public Result<?> queryByIds(@RequestParam(name="ids",required=true) String ids) {
List<ErpGoodsDto> listErpGoodsDto = erpGoodsDtoService.queryByIds(ids);
if(listErpGoodsDto.size()==0) {
return Result.error("未找到对应数据");
}
return Result.OK(listErpGoodsDto);
}
}
3.3 ErpGoodsDtoMapper.java文件
package com.nbcio.modules.erp.goods.mapper;
import com.nbcio.modules.erp.goods.dto.ErpGoodsDto;
import com.nbcio.modules.erp.goods.vo.QueryGoodsVo;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
/**
* @Description: erp_goods_dto
* @Author: nbacheng
* @Date: 2023-02-09
* @Version: V1.0
*/
public interface ErpGoodsDtoMapper extends BaseMapper<ErpGoodsDto> {
List<ErpGoodsDto> queryGoodsList(Page<ErpGoodsDto> page, @Param("vo") QueryGoodsVo vo);
public List<ErpGoodsDto> getByIds(@Param("idArray") String[] idArray);
}
3.4 ErpGoodsDtoMapper.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.nbcio.modules.erp.goods.mapper.ErpGoodsDtoMapper">
<resultMap id="ErpGoodsDtoMap" type="com.nbcio.modules.erp.goods.dto.ErpGoodsDto">
<id column="id" property="id"/>
<result column="code" property="code"/>
<result column="name" property="name"/>
<result column="category_id" property="categoryId"/>
<result column="category_name" property="categoryName"/>
<result column="brand_id" property="brandId"/>
<result column="brand_name" property="brandName"/>
<result column="spec" property="spec"/>
<result column="unit" property="unit"/>
<result column="status" property="status"/>
<result column="purchase_price" property="purchasePrice"/>
<result column="sale_price" property="salePrice"/>
<result column="retail_price" property="retailPrice"/>
<result column="tax_rate" property="taxRate"/>
<result column="sale_tax_rate" property="saleTaxRate"/>
<result column="num" property="num"/>
<result column="total_price" property="totalPrice"/>
</resultMap>
<sql id="ErpGoodsDto_sql">
SELECT
a.id,
a.code,
a.name,
c.id AS category_id,
c.name AS category_name,
b.id AS brand_id,
b.name AS brand_name,
a.spec,
a.unit,
a.status,
price.purchase AS purchase_price,
price.sale AS sale_price,
price.retail AS retail_price,
a.tax_rate,
a.sale_tax_rate,
1 as num,
price.sale*1 as total_price
FROM erp_goods AS a
LEFT JOIN erp_goods_price AS price ON price.id = a.id
LEFT JOIN erp_goods_category AS c ON c.id = a.category_id
LEFT JOIN erp_goods_brand AS b ON b.id = a.brand_id
</sql>
<select id="queryGoodsList" resultMap="ErpGoodsDtoMap">
<include refid="ErpGoodsDto_sql"/>
<where>
<if test="vo != null">
<if test="vo.condition != null and vo.condition != ''">
AND (
a.id LIKE CONCAT('%', #{vo.condition}, '%')
OR a.code LIKE CONCAT('%', #{vo.condition}, '%')
OR a.name LIKE CONCAT('%', #{vo.condition}, '%')
)
</if>
<if test="vo.brandId != null and vo.brandId != ''">
AND b.id = #{vo.brandId}
</if>
<if test="vo.categoryId != null and vo.categoryId != ''">
AND (c.id = #{vo.categoryId}
</if>
</if>
AND a.status = '1'
</where>
ORDER BY a.code
</select>
<select id="getByIds" resultType="com.nbcio.modules.erp.goods.dto.ErpGoodsDto">
<include refid="ErpGoodsDto_sql"/>
<where>
a.id IN (
<foreach collection="idArray" item="id" separator=",">
#{id}
</foreach>
)
</where>
order by a.code desc
</select>
</mapper>
3.5 IErpGoodsDtoService.java文件
package com.nbcio.modules.erp.goods.service;
import com.nbcio.modules.erp.goods.dto.ErpGoodsDto;
import com.nbcio.modules.erp.goods.vo.QueryGoodsVo;
import java.util.List;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @Description: erp_goods_dto
* @Author: nbacheng
* @Date: 2023-02-09
* @Version: V1.0
*/
public interface IErpGoodsDtoService extends IService<ErpGoodsDto> {
IPage<ErpGoodsDto> queryGoodsList(Page<ErpGoodsDto> page, QueryGoodsVo queryGoodsVo);
List<ErpGoodsDto> queryByIds(String ids);
}
3.6 ErpGoodsDtoServiceImpl.java文件
package com.nbcio.modules.erp.goods.service.impl;
import com.nbcio.modules.erp.goods.dto.ErpGoodsDto;
import com.nbcio.modules.erp.goods.mapper.ErpGoodsDtoMapper;
import com.nbcio.modules.erp.goods.service.IErpGoodsDtoService;
import com.nbcio.modules.erp.goods.vo.QueryGoodsVo;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
/**
* @Description: erp_goods
* @Author: nbacheng
* @Date: 2023-02-09
* @Version: V1.0
*/
@Service
public class ErpGoodsDtoServiceImpl extends ServiceImpl<ErpGoodsDtoMapper, ErpGoodsDto> implements IErpGoodsDtoService {
@Autowired
private ErpGoodsDtoMapper erpGoodsDtoMapper;
@Override
public IPage<ErpGoodsDto> queryGoodsList(Page<ErpGoodsDto> page, QueryGoodsVo queryGoodsVo) {
List<ErpGoodsDto> erpGoodsDtoLists = this.baseMapper.queryGoodsList(page, queryGoodsVo);
return page.setRecords(erpGoodsDtoLists);
}
@Override
public List<ErpGoodsDto> queryByIds(String ids) {
// TODO Auto-generated method stub
String [] idArray=ids.split(",");
return erpGoodsDtoMapper.getByIds(idArray);
}
}
四、效果图