直接上功能效果展示
一、后端部分(Java)
1.1 Controller层
package com.ruoyi.web.controller.gson.basicinformationmaintenance; import com.alibaba.druid.support.json.JSONUtils; import com.alibaba.fastjson2.JSON; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.enums.ErrCode; import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.exception.SwException; import com.ruoyi.common.utils.ValidUtils; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.system.domain.Cbca; import com.ruoyi.system.domain.dto.BaseSelectDto; import com.ruoyi.system.domain.dto.CbcaDto; import com.ruoyi.system.domain.dto.CbsaDto; import com.ruoyi.system.domain.vo.BaseSelectVo; import com.ruoyi.system.service.ISwJsCustomerService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.exception.ExceptionUtils; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; import java.util.List; import static io.lettuce.core.pubsub.PubSubOutput.Type.message; /** * 客户信息Controller * * @author * @date 2022-06-16 */ @Api( tags = {"客户信息"} ) @Slf4j @RestController @RequestMapping("/system/customer") public class SwJsCustomerController extends BaseController { @Resource private ISwJsCustomerService swJsCustomerService; /** * 新增客户信息 */ @ApiOperation( value ="新增客户信息", notes = "新增客户信息" ) @PostMapping("/SwJsCustomeradd") @PreAuthorize("@ss.hasPermi('system:customer:add')") public AjaxResult SwJsCustomeradd(@Valid @RequestBody CbcaDto cbcaDto, BindingResult bindingResult) { try { ValidUtils.bindvaild(bindingResult); return toAjax(swJsCustomerService.insertSwJsCustomer(cbcaDto)); }catch (SwException e) { return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage()); }catch (ServiceException e) { log.error("【新增客户信息】接口出现异常,参数${}$,异常${}$", JSON.toJSON(cbcaDto), ExceptionUtils.getStackTrace(e)); return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage()); } catch (Exception e) { log.error("【新增客户信息】接口出现异常,参数${}$,异常${}$", JSON.toJSON(cbcaDto), ExceptionUtils.getStackTrace(e)); return AjaxResult.error((int) ErrCode.UNKNOW_ERROR.getErrCode(), "操作失败"); } } /** * 修改客户信息 */ @ApiOperation( value ="修改客户信息", notes = "修改客户信息" ) @PostMapping("/SwJsCustomeredit") @PreAuthorize("@ss.hasPermi('system:customer:edit')") public AjaxResult SwJsCustomeredit(@RequestBody CbcaDto cbcaDto) { try { return toAjax(swJsCustomerService.updateSwJsCustomer(cbcaDto)); }catch (SwException e) { return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage()); } catch (ServiceException e) { log.error("【修改客户信息】接口出现异常,参数${}$,异常${}$", JSON.toJSON(cbcaDto),ExceptionUtils.getStackTrace(e)); return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage()); }catch (Exception e) { log.error("【修改客户信息】接口出现异常,参数${}$,异常${}$", JSON.toJSON(cbcaDto),ExceptionUtils.getStackTrace(e)); return AjaxResult.error((int) ErrCode.UNKNOW_ERROR.getErrCode(), "操作失败"); } } /** * 删除客户信息 */ @ApiOperation( value ="删除客户信息", notes = "删除客户信息" ) @PostMapping("/SwJsGoodsClassifyremove") @PreAuthorize("@ss.hasPermi('system:customer:remove')") public AjaxResult SwJsCustomerremove(@RequestBody CbcaDto cbcaDto) { try { return toAjax(swJsCustomerService.deleteSwJsCustomerById(cbcaDto)); }catch (SwException e) { log.error("【删除客户信息】接口出现异常,参数${},异常${}$", JSON.toJSON(cbcaDto), ExceptionUtils.getStackTrace(e)); return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage()); }catch (ServiceException e) { log.error("【删除客户信息】接口出现异常,参数${},异常${}$", JSON.toJSON(cbcaDto), ExceptionUtils.getStackTrace(e)); return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage()); } catch (Exception e) { log.error("【删除客户信息】接口出现异常,参数${}$,异常${}$", JSON.toJSON(cbcaDto),ExceptionUtils.getStackTrace(e)); return AjaxResult.error((int) ErrCode.UNKNOW_ERROR.getErrCode(), "操作失败"); } } /** * 查询客户信息列表 */ @ApiOperation( value ="查询客户信息列表", notes = "查询客户信息列表" ) @GetMapping("/SwJsCustomerlist") @PreAuthorize("@ss.hasPermi('system:customer:list')") public AjaxResult<TableDataInfo> SwJsCustomerlist(Cbca cbca) { try{ startPage(); List<Cbca> list = swJsCustomerService.selectSwJsCustomerList(cbca); return AjaxResult.success(getDataTable(list)); }catch (SwException e) { return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage()); } catch (ServiceException e) { log.error("【新增商品】接口出现异常,参数${},异常${}$", JSON.toJSON(cbca), ExceptionUtils.getStackTrace(e)); return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage()); }catch (Exception e) { log.error("【查询客户信息列表】接口出现异常,参数${}$,异常${}$", JSON.toJSON(cbca),ExceptionUtils.getStackTrace(e)); return AjaxResult.error((int) ErrCode.UNKNOW_ERROR.getErrCode(), "操作失败"); } } /** * 导出客户信息列表 */ @ApiOperation( value ="导出客户信息列表", notes = "导出客户信息列表" ) @PostMapping("/SwJsCustomerexport") @PreAuthorize("@ss.hasPermi('system:customer:export')") public void export(HttpServletResponse response, Cbca cbca) { List<Cbca> list = swJsCustomerService.selectSwJsCustomerList(cbca); ExcelUtil<Cbca> util = new ExcelUtil<>(Cbca.class); util.exportExcel(response, list, "客户信息数据"); } /** * 导入客户信息列表 */ @ApiOperation( value ="导入客户信息列表", notes = "导入客户信息列表" ) @PostMapping("/importSwJsCustomer") @ResponseBody @PreAuthorize("@ss.hasPermi('system:customer:import')") public AjaxResult importSwJsCustomer(MultipartFile file, boolean updateSupport) { try { ExcelUtil<CbcaDto> util = new ExcelUtil<>(CbcaDto.class); List<CbcaDto> swJsCustomersList = util.importExcel(file.getInputStream()); String operName = getUsername(); String message = swJsCustomerService.importSwJsCustomer(swJsCustomersList, updateSupport, operName); return AjaxResult.success(message); }catch (SwException e) { log.error("【导入客户信息列表】接口参数校验出现异常,参数${}$,异常${}$", JSON.toJSON(message),e.getMessage()); return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage()); } catch (ServiceException e) { log.error("【导入客户信息列表】接口参数校验出现异常,参数${}$,异常${}$", JSON.toJSON(message),e.getMessage()); return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage()); }catch (Exception e) { log.error("【导入客户信息列表】接口出现异常,参数${}$,异常${}$", JSON.toJSON(message),ExceptionUtils.getStackTrace(e)); return AjaxResult.error((int) ErrCode.UNKNOW_ERROR.getErrCode(), "操作失败"); } } /** * 导入客户下载模板 */ @ApiOperation( value ="导入客户下载模板", notes = "导入客户下载模板" ) @PostMapping("/importTemplate") public void importTemplate(HttpServletResponse response) { try { ExcelUtil<CbcaDto> util = new ExcelUtil<CbcaDto>(CbcaDto.class); util.importTemplateExcel(response, "导入客户下载模板"); } catch (SwException e) { log.error("【导入客户下载模板】接口参数校验出现异常,参数${}$,异常${}$", JSON.toJSON(response), e.getMessage()); // return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage()); } catch (ServiceException e) { log.error("【导入客户下载模板】接口出现异常,参数${}$,异常${}$", JSON.toJSON(response), ExceptionUtils.getStackTrace(e)); //return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage()); } catch (Exception e) { log.error("【导入客户下载模板】接口出现异常,参数${}$,异常${}$", JSON.toJSON(response), ExceptionUtils.getStackTrace(e)); } } /** * 客户信息选择框 */ @ApiOperation( value ="客户信息选择框", notes = "客户信息选择框" ) @GetMapping("/SwJsCustomerlistSelect") public AjaxResult<TableDataInfo> SwJsCustomerlistSelect(BaseSelectDto baseSelectDto) { try{ startPage(); List<BaseSelectVo> list = swJsCustomerService.SwJsCustomerlistSelect(baseSelectDto); return AjaxResult.success(getDataTable(list)); }catch (SwException e) { return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage()); } catch (ServiceException e) { log.error("【客户信息选择框】接口出现异常,参数${},异常${}$", JSON.toJSON(baseSelectDto), ExceptionUtils.getStackTrace(e)); return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage()); }catch (Exception e) { log.error("【客户信息选择框】接口出现异常,参数${}$,异常${}$", JSON.toJSON(baseSelectDto),ExceptionUtils.getStackTrace(e)); return AjaxResult.error((int) ErrCode.UNKNOW_ERROR.getErrCode(), "操作失败"); } } /** * 客户信息选择框全部数据 */ @ApiOperation( value ="客户信息选择框全部数据", notes = "客户信息选择框全部数据" ) @GetMapping("/SwJsCustomerlistAll") public AjaxResult<TableDataInfo> SwJsCustomerlistAll(BaseSelectDto baseSelectDto) { try{ List<BaseSelectVo> list = swJsCustomerService.SwJsCustomerlistSelect(baseSelectDto); return AjaxResult.success(getDataTable(list)); }catch (SwException e) { return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage()); } catch (ServiceException e) { log.error("【客户信息选择框】接口出现异常,参数${},异常${}$", JSON.toJSON(baseSelectDto), ExceptionUtils.getStackTrace(e)); return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage()); }catch (Exception e) { log.error("【客户信息选择框】接口出现异常,参数${}$,异常${}$", JSON.toJSON(baseSelectDto),ExceptionUtils.getStackTrace(e)); return AjaxResult.error((int) ErrCode.UNKNOW_ERROR.getErrCode(), "操作失败"); } } /** * 用户信息选择框 */ @ApiOperation( value ="获取用户信息选择框", notes = "获取用户信息选择框" ) @GetMapping("/systemUserSelect") public AjaxResult<TableDataInfo> systemUserSelect(BaseSelectDto baseSelectDto) { try{ startPage(); List<BaseSelectVo> list = swJsCustomerService.systemUserSelect(baseSelectDto); return AjaxResult.success(getDataTable(list)); }catch (SwException e) { return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage()); } catch (ServiceException e) { log.error("【获取用户信息选择框】接口出现异常,参数${},异常${}$", JSON.toJSON(baseSelectDto), ExceptionUtils.getStackTrace(e)); return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage()); }catch (Exception e) { log.error("【获取用户信息选择框】接口出现异常,参数${}$,异常${}$", JSON.toJSON(baseSelectDto),ExceptionUtils.getStackTrace(e)); return AjaxResult.error((int) ErrCode.UNKNOW_ERROR.getErrCode(), "操作失败"); } } /** * 用户信息下拉框(不分页) */ @ApiOperation( value ="用户信息下拉框(不分页)", notes = "用户信息下拉框(不分页)" ) @GetMapping("/systemUserSelectAll") public AjaxResult<TableDataInfo> systemUserSelectAll(BaseSelectDto baseSelectDto) { try{ List<BaseSelectVo> list = swJsCustomerService.systemUserSelect(baseSelectDto); return AjaxResult.success(getDataTable(list)); }catch (SwException e) { return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage()); } catch (ServiceException e) { log.error("【获取用户信息选择框】接口出现异常,参数${},异常${}$", JSON.toJSON(baseSelectDto), ExceptionUtils.getStackTrace(e)); return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage()); }catch (Exception e) { log.error("【获取用户信息选择框】接口出现异常,参数${}$,异常${}$", JSON.toJSON(baseSelectDto),ExceptionUtils.getStackTrace(e)); return AjaxResult.error((int) ErrCode.UNKNOW_ERROR.getErrCode(), "操作失败"); } } /** * 客户信息详情 */ @ApiOperation( value ="客户信息详情", notes = "客户信息详情" ) @GetMapping("/customerDetail") public AjaxResult<CbcaDto> customerDetail(CbcaDto cbcaDto) { try{ CbcaDto res = swJsCustomerService.customerDetail(cbcaDto); return AjaxResult.success(res); }catch (SwException e) { return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage()); } catch (ServiceException e) { log.error("【客户信息详情】接口出现异常,参数${},异常${}$", JSON.toJSON(cbcaDto), ExceptionUtils.getStackTrace(e)); return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage()); }catch (Exception e) { log.error("【客户信息详情】接口出现异常,参数${}$,异常${}$", JSON.toJSON(cbcaDto),ExceptionUtils.getStackTrace(e)); return AjaxResult.error((int) ErrCode.UNKNOW_ERROR.getErrCode(), "操作失败"); } } /** * 客户信息详情 */ @ApiOperation( value ="客户信息详情购物车", notes = "客户信息详情购物车" ) @GetMapping("/customerDetailShop") public AjaxResult<CbcaDto> customerDetailShop(CbcaDto cbcaDto) { try{ CbcaDto res = swJsCustomerService.customerDetailShop(cbcaDto); return AjaxResult.success(res); }catch (SwException e) { return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage()); } catch (ServiceException e) { log.error("【客户信息详情购物车】接口出现异常,参数${},异常${}$", JSON.toJSON(cbcaDto), ExceptionUtils.getStackTrace(e)); return AjaxResult.error((int) ErrCode.SYS_PARAMETER_ERROR.getErrCode(), e.getMessage()); }catch (Exception e) { log.error("【客户信息详情购物车】接口出现异常,参数${}$,异常${}$", JSON.toJSON(cbcaDto),ExceptionUtils.getStackTrace(e)); return AjaxResult.error((int) ErrCode.UNKNOW_ERROR.getErrCode(), "操作失败"); } } }
1.2 Service层
package com.ruoyi.system.service; import com.ruoyi.system.domain.Cbca; import com.ruoyi.system.domain.dto.BaseSelectDto; import com.ruoyi.system.domain.dto.CbcaDto; import com.ruoyi.system.domain.vo.BaseSelectVo; import java.util.List; public interface ISwJsCustomerService { List<Cbca> selectSwJsCustomerList(Cbca cbca); int deleteSwJsCustomerById(CbcaDto cbcaDto); int updateSwJsCustomer(CbcaDto cbcaDto); int insertSwJsCustomer(CbcaDto cbcaDto); String importSwJsCustomer(List<CbcaDto> swJsCustomersList, boolean updateSupport, String operName); List<BaseSelectVo> SwJsCustomerlistSelect(BaseSelectDto baseSelectDto); List<BaseSelectVo> systemUserSelect(BaseSelectDto baseSelectDto); CbcaDto customerDetail(CbcaDto cbcaDto); CbcaDto customerDetailShop(CbcaDto cbcaDto); }
1.2.1 ServiceImpl
package com.ruoyi.framework.web.service.impl; import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.enums.DeleteFlagEnum; import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.exception.SwException; import com.ruoyi.common.utils.BeanCopyUtils; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.system.domain.*; import com.ruoyi.system.domain.Cbca; import com.ruoyi.system.domain.dto.BaseSelectDto; import com.ruoyi.system.domain.dto.CbcaDto; import com.ruoyi.system.domain.dto.GoodsPriceAndSkuDto; import com.ruoyi.system.domain.vo.BaseSelectVo; import com.ruoyi.system.domain.vo.GoodsPriceAndSkuVo; import com.ruoyi.system.mapper.*; import com.ruoyi.system.service.ISwJsCustomerService; import com.ruoyi.system.service.gson.BaseCheckService; import com.ruoyi.system.service.gson.SaleOrderService; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.web.bind.annotation.RequestParam; import javax.annotation.Resource; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Map; @Slf4j @Service public class SwJsCustomerServiceImpl implements ISwJsCustomerService { @Resource private GsSystemUseMapper gsSystemUseMapper; @Resource private CbcaMapper cbcaMapper; @Resource private CbsbMapper cbsbMapper; @Resource private CbpfMapper cbpfMapper; @Resource private SysUserMapper sysUserMapper; @Resource private SaleOrderService saleOrderService; @Resource private CbpbMapper cbpbMapper; @Resource private BaseCheckService baseCheckService; @Override public List<Cbca> selectSwJsCustomerList(Cbca cbca) { return cbcaMapper.selectCBWAList(cbca); } @Override public int deleteSwJsCustomerById(CbcaDto cbcaDto) { Long userid = SecurityUtils.getUserId(); Cbca cbca = BeanCopyUtils.coypToClass(cbcaDto, Cbca.class, null); Date date = new Date(); cbca.setCbca04(date); cbca.setCbca05(Math.toIntExact(userid)); cbca.setCbca06(DeleteFlagEnum.DELETE.getCode()); CbcaCriteria example3=new CbcaCriteria(); example3.createCriteria(). andCbca06EqualTo(DeleteFlagEnum.NOT_DELETE.getCode()) .andCbca01EqualTo(cbcaDto.getCbca01()); // List<Cbpb> cbpbs = cbpbMapper.selectByExample(example3); // List<String> collect = cbpbs.stream().map(Cbpb::getCbpb15).collect(Collectors.toList()); // String[] strs = collect.toArray(new String[]{}); //销售出库单校验 CbsbCriteria use=new CbsbCriteria(); use.createCriteria() .andCbsb09EqualTo(cbcaDto.getCbca01()) .andCbsb06EqualTo(DeleteFlagEnum.NOT_DELETE.getCode()); List<Cbsb> cbsbs = cbsbMapper.selectByExample(use); if(cbsbs.size()>0){ throw new SwException("不可删除在用客户"); } cbca.setCbca06(DeleteFlagEnum.DELETE.getCode()); cbcaMapper.updateByExampleSelective(cbca,example3); return 1; } @Override public int updateSwJsCustomer(CbcaDto cbcaDto) { Long userid = SecurityUtils.getUserId(); Cbca cbca1 = cbcaMapper.selectByPrimaryKey(cbcaDto.getCbca01()); if(cbcaDto.getCbca08()!=null){ CbcaCriteria example = new CbcaCriteria(); example.createCriteria().andCbca08EqualTo(cbcaDto.getCbca08()) .andCbca06EqualTo(DeleteFlagEnum.NOT_DELETE.getCode()); List<Cbca> cbcas = cbcaMapper.selectByExample(example); if(cbcas.size()>0 && !cbca1.getCbca01().equals(cbcas.get(0).getCbca01())){ throw new SwException("客户名称不能重复"); }} Cbca cbca = BeanCopyUtils.coypToClass(cbcaDto, Cbca.class, null); Date date = new Date(); cbca.setCbca04(date); cbca.setCbca05(Math.toIntExact(userid)); cbca.setCbca07(cbcaDto.getCbca07()); cbca.setCbca08(cbcaDto.getCbca08()); cbca.setCbca09(cbcaDto.getCbca09()); cbca.setCbca10(cbcaDto.getCbca10()); cbca.setCbca11(cbcaDto.getCbca11()); cbca.setCbca12(cbcaDto.getCbca12()); cbca.setCbca13(cbcaDto.getCbca13()); cbca.setCbca14(cbcaDto.getCbca14()); cbca.setCbca15(cbcaDto.getCbca15()); cbca.setCbca16(cbcaDto.getCbca16()); cbca.setCbca17(cbcaDto.getCbca17()); cbca.setCbca18(cbcaDto.getCbca18()); cbca.setCbca19(cbcaDto.getCbca19()); cbca.setCbca20(cbcaDto.getCbca20()); cbca.setCbca21(cbcaDto.getCbca21()); cbca.setCbca22(cbcaDto.getCbca22()); cbca.setCbca23(cbcaDto.getCbca23()); cbca.setCbca24(cbcaDto.getCbca24()); cbca.setCbca25(cbcaDto.getCbca25()); cbca.setCbca26(cbcaDto.getCbca26()); cbca.setCbca27(cbcaDto.getCbca27()); cbca.setCbca28(cbcaDto.getCbca28()); CbcaCriteria example1= new CbcaCriteria(); example1.createCriteria().andCbca01EqualTo(cbcaDto.getCbca01()) .andCbca06EqualTo(DeleteFlagEnum.NOT_DELETE.getCode()); cbcaMapper.updateByExampleSelective(cbca,example1); return 1;} @Override public int insertSwJsCustomer(CbcaDto cbcaDto) { Long userid = SecurityUtils.getUserId(); CbcaCriteria example = new CbcaCriteria(); example.createCriteria().andCbca08EqualTo(cbcaDto.getCbca08()) .andCbca06EqualTo(DeleteFlagEnum.NOT_DELETE.getCode()); List<Cbca> cbcas = cbcaMapper.selectByExample(example); if(cbcas.size()>0){ throw new SwException("客户名称不能重复"); } if(cbcaDto.getCbca28()==null){ throw new SwException("客户等级只能为数字"); } if(cbcaDto.getCbca28()<1 || cbcaDto.getCbca28()>10){ throw new SwException("客户等级只能为1-5"); } Cbca cbca = BeanCopyUtils.coypToClass(cbcaDto, Cbca.class, null); Date date = new Date(); cbca.setCbca02(date); cbca.setCbca03(Math.toIntExact(userid)); cbca.setCbca04(date); cbca.setCbca05(Math.toIntExact(userid)); cbca.setCbca06(DeleteFlagEnum.NOT_DELETE.getCode()); cbca.setCbca07(cbcaDto.getCbca07()); cbca.setCbca08(cbcaDto.getCbca08()); cbca.setCbca09(cbcaDto.getCbca09()); cbca.setCbca10(cbcaDto.getCbca10()); cbca.setCbca11(cbcaDto.getCbca11()); cbca.setCbca12(cbcaDto.getCbca12()); cbca.setCbca13(cbcaDto.getCbca13()); cbca.setCbca14(cbcaDto.getCbca14()); cbca.setCbca15(cbcaDto.getCbca15()); cbca.setCbca16(cbcaDto.getCbca16()); cbca.setCbca17(cbcaDto.getCbca17()); cbca.setCbca18(cbcaDto.getCbca18()); cbca.setCbca19(cbcaDto.getCbca19()); cbca.setCbca20(cbcaDto.getCbca20()); cbca.setCbca21(cbcaDto.getCbca21()); cbca.setCbca22(cbcaDto.getCbca22()); cbca.setCbca23(cbcaDto.getCbca23()); if("增值税专用发票".equals(cbcaDto.getCbca24())|| "增值税普通发票".equals(cbcaDto.getCbca24())|| "个人普通发票".equals(cbcaDto.getCbca24())|| "不开发票".equals(cbcaDto.getCbca24()) ) { cbca.setCbca24(cbcaDto.getCbca24()); } else { throw new SwException("发票类型填写错误"); } cbca.setCbca25(cbcaDto.getCbca25()); cbca.setCbca26(cbcaDto.getCbca26()); cbca.setCbca27(cbcaDto.getCbca27()); String s = cbcaDto.getCbca28().toString(); cbca.setCbca28(cbcaDto.getCbca28()); return cbcaMapper.insertSelective(cbca); } @Override public String importSwJsCustomer(List<CbcaDto> swJsCustomersList, boolean updateSupport, String operName) { Long userid = SecurityUtils.getUserId(); if (StringUtils.isNull(swJsCustomersList) || swJsCustomersList.size() == 0) { throw new ServiceException("导入用户数据不能为空!"); } int successNum = 0; int failureNum = 0; StringBuilder successMsg = new StringBuilder(); StringBuilder failureMsg = new StringBuilder(); for ( CbcaDto swJsCustomer : swJsCustomersList) { try { // 验证是否存在这个用户 Cbca u = cbcaMapper.selectByPrimaryKey(swJsCustomer.getCbca03() ); log.info(swJsCustomer.getCbca03()+""); if (StringUtils.isNull(u)) { swJsCustomer.setCbca08(swJsCustomer.getCbca08()); this.insertSwJsCustomer(swJsCustomer); successNum++; successMsg.append("<br/>").append(successNum).append("客户信息列表").append(swJsCustomer.getCbca08()).append(" 导入成功"); } else if (updateSupport) { this.updateSwJsCustomer(swJsCustomer); successNum++; successMsg.append("<br/>").append(successNum).append("客户信息列表 ").append(swJsCustomer.getCbca08()).append(" 更新成功"); } else { failureNum++; failureMsg.append("<br/>").append(failureNum).append("客户信息列表").append(swJsCustomer.getCbca08()).append(" 已存在"); } } catch (Exception e) { failureNum++; String msg = "<br/>" + failureNum + "客户信息列表" + swJsCustomer.getCbca08() + " 导入失败:"; failureMsg.append(msg).append(e.getMessage()); log.error(msg, e); } } if (failureNum > 0) { failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:"); throw new ServiceException(failureMsg.toString()); } else { successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:"); } return successMsg.toString(); } @Override public List<BaseSelectVo> SwJsCustomerlistSelect(BaseSelectDto baseSelectDto) { Cbca cbca=new Cbca(); cbca.setCbca06(DeleteFlagEnum.NOT_DELETE.getCode()); cbca.setCbca07("启用"); cbca.setCbca08(baseSelectDto.getSelectMsg()); List<Cbca> cbcas = cbcaMapper.selectCBWAList(cbca); List<BaseSelectVo> res=new ArrayList<>(); BaseSelectVo bv=null; for (Cbca cbca1 : cbcas) { bv=new BaseSelectVo(); bv.setValue(cbca1.getCbca01()); bv.setLabel(cbca1.getCbca08()); res.add(bv); } return res; } @Override public List<BaseSelectVo> systemUserSelect(BaseSelectDto baseSelectDto) { if(baseSelectDto.getSelectMsg()==null){ baseSelectDto.setSelectMsg(""); } SysUserCriteria example=new SysUserCriteria(); example.createCriteria() .andDelFlagEqualTo(DeleteFlagEnum.NOT_DELETE.getCode().toString()) .andStatusEqualTo("0") .andNickNameLike("%" +baseSelectDto.getSelectMsg()+"%"); List<SysUser> sysUsers = sysUserMapper.selectByExample(example); List<BaseSelectVo> res=new ArrayList<>(); BaseSelectVo bv=null; for (SysUser sysUser : sysUsers) { bv=new BaseSelectVo(); bv.setValue(sysUser.getUserId().intValue()); bv.setLabel(sysUser.getNickName()); res.add(bv); } return res; } @Override public CbcaDto customerDetail(CbcaDto cbcaDto) { if(cbcaDto.getCbca01()==null){ throw new SwException("请选择客户"); } Cbca cbca = cbcaMapper.selectByPrimaryKey(cbcaDto.getCbca01()); if(cbca==null){ throw new SwException("没有查到该客户"); } CbcaDto cbcaDto1 = BeanCopyUtils.coypToClass(cbca, CbcaDto.class,null); return cbcaDto1; } @Override public CbcaDto customerDetailShop(CbcaDto cbcaDto) { if(cbcaDto.getCbca01()==null){ throw new SwException("请选择客户"); } Cbca cbca = cbcaMapper.selectByPrimaryKey(cbcaDto.getCbca01()); if(cbca==null){ throw new SwException("没有查到该客户"); } CbcaDto cbcaDto1 = BeanCopyUtils.coypToClass(cbca, CbcaDto.class,null); Map<Integer, String> brandMap = baseCheckService.brandMap(); for (Integer goodsId : cbcaDto.getGoodsIds()) { GoodsPriceAndSkuDto dto=new GoodsPriceAndSkuDto(); dto.setCustomerId(cbca.getCbca01()); dto.setGoodsId(goodsId); dto.setOrderClass(2); GoodsPriceAndSkuVo goodsPriceAndSkuVo = saleOrderService.goodsPriceAndSku(dto); Cbpb cbpb = cbpbMapper.selectByPrimaryKey(dto.getGoodsId()); if(cbpb!=null){ goodsPriceAndSkuVo.setGoodsMsg(brandMap.get(cbpb.getCbpb10())+"-"+cbpb.getCbpb12()+"-"+cbpb.getCbpb08()); } cbcaDto1.getGoodsres().add(goodsPriceAndSkuVo); } return cbcaDto1; } public int insertSwJsCustomer(Cbca cbca) { return cbcaMapper.insertCBCA(cbca); } public int updateSwJsCustomer(Cbca cbca) { return cbcaMapper.updateCBCA(cbca); } }
1.3 Mapper
package com.ruoyi.system.mapper; import com.ruoyi.system.domain.Cbca; import com.ruoyi.system.domain.CbcaCriteria; import java.util.List; import org.apache.ibatis.annotations.Param; public interface CbcaMapper { long countByExample(CbcaCriteria example); int deleteByExample(CbcaCriteria example); int deleteByPrimaryKey(Integer cbca01); int insert(Cbca record); int insertSelective(Cbca record); List<Cbca> selectByExample(CbcaCriteria example); Cbca selectByPrimaryKey(Integer cbca01); int updateByExampleSelective(@Param("record") Cbca record, @Param("example") CbcaCriteria example); int updateByExample(@Param("record") Cbca record, @Param("example") CbcaCriteria example); int updateByPrimaryKeySelective(Cbca record); int updateByPrimaryKey(Cbca record); int insertCBCA(Cbca cbca); int updateCBCA(Cbca cbca); List<Cbca> selectCBWAList(Cbca cbca); }
<?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.ruoyi.system.mapper.CbcaMapper"> <resultMap id="BaseResultMap" type="com.ruoyi.system.domain.Cbca"> <id column="CBCA01" jdbcType="INTEGER" property="cbca01" /> <result column="CBCA02" jdbcType="TIMESTAMP" property="cbca02" /> <result column="CBCA03" jdbcType="INTEGER" property="cbca03" /> <result column="CBCA04" jdbcType="TIMESTAMP" property="cbca04" /> <result column="CBCA05" jdbcType="INTEGER" property="cbca05" /> <result column="CBCA06" jdbcType="INTEGER" property="cbca06" /> <result column="CBCA07" jdbcType="VARCHAR" property="cbca07" /> <result column="CBCA08" jdbcType="VARCHAR" property="cbca08" /> <result column="CBCA09" jdbcType="VARCHAR" property="cbca09" /> <result column="CBCA10" jdbcType="VARCHAR" property="cbca10" /> <result column="CBCA11" jdbcType="VARCHAR" property="cbca11" /> <result column="CBCA12" jdbcType="VARCHAR" property="cbca12" /> <result column="CBCA13" jdbcType="VARCHAR" property="cbca13" /> <result column="CBCA14" jdbcType="VARCHAR" property="cbca14" /> <result column="CBCA15" jdbcType="VARCHAR" property="cbca15" /> <result column="CBCA16" jdbcType="VARCHAR" property="cbca16" /> <result column="CBCA17" jdbcType="VARCHAR" property="cbca17" /> <result column="CBCA18" jdbcType="VARCHAR" property="cbca18" /> <result column="CBCA19" jdbcType="VARCHAR" property="cbca19" /> <result column="CBCA20" jdbcType="VARCHAR" property="cbca20" /> <result column="CBCA21" jdbcType="VARCHAR" property="cbca21" /> <result column="CBCA22" jdbcType="VARCHAR" property="cbca22" /> <result column="CBCA23" jdbcType="VARCHAR" property="cbca23" /> <result column="CBCA24" jdbcType="VARCHAR" property="cbca24" /> <result column="CBCA25" jdbcType="VARCHAR" property="cbca25" /> <result column="CBCA26" jdbcType="VARCHAR" property="cbca26" /> <result column="CBCA27" jdbcType="VARCHAR" property="cbca27" /> <result column="CBCA28" jdbcType="INTEGER" property="cbca28" /> </resultMap> <sql id="Example_Where_Clause"> <where> <foreach collection="oredCriteria" item="criteria" separator="or"> <if test="criteria.valid"> <trim prefix="(" prefixOverrides="and" suffix=")"> <foreach collection="criteria.criteria" item="criterion"> <choose> <when test="criterion.noValue"> and ${criterion.condition} </when> <when test="criterion.singleValue"> and ${criterion.condition} #{criterion.value} </when> <when test="criterion.betweenValue"> and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} </when> <when test="criterion.listValue"> and ${criterion.condition} <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=","> #{listItem} </foreach> </when> </choose> </foreach> </trim> </if> </foreach> </where> </sql> <sql id="Update_By_Example_Where_Clause"> <where> <foreach collection="example.oredCriteria" item="criteria" separator="or"> <if test="criteria.valid"> <trim prefix="(" prefixOverrides="and" suffix=")"> <foreach collection="criteria.criteria" item="criterion"> <choose> <when test="criterion.noValue"> and ${criterion.condition} </when> <when test="criterion.singleValue"> and ${criterion.condition} #{criterion.value} </when> <when test="criterion.betweenValue"> and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} </when> <when test="criterion.listValue"> and ${criterion.condition} <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=","> #{listItem} </foreach> </when> </choose> </foreach> </trim> </if> </foreach> </where> </sql> <sql id="Base_Column_List"> CBCA01, CBCA02, CBCA03, CBCA04, CBCA05, CBCA06, CBCA07, CBCA08, CBCA09, CBCA10, CBCA11, CBCA12, CBCA13, CBCA14, CBCA15, CBCA16, CBCA17, CBCA18, CBCA19, CBCA20, CBCA21, CBCA22, CBCA23, CBCA24, CBCA25, CBCA26, CBCA27, CBCA28 </sql> <select id="selectByExample" parameterType="com.ruoyi.system.domain.CbcaCriteria" resultMap="BaseResultMap"> select <if test="distinct"> distinct </if> <include refid="Base_Column_List" /> from `CBCA` <if test="_parameter != null"> <include refid="Example_Where_Clause" /> </if> <if test="orderByClause != null"> order by ${orderByClause} </if> </select> <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> select <include refid="Base_Column_List" /> from `CBCA` where CBCA01 = #{cbca01,jdbcType=INTEGER} </select> <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer"> delete from `CBCA` where CBCA01 = #{cbca01,jdbcType=INTEGER} </delete> <delete id="deleteByExample" parameterType="com.ruoyi.system.domain.CbcaCriteria"> delete from `CBCA` <if test="_parameter != null"> <include refid="Example_Where_Clause" /> </if> </delete> <insert id="insert" parameterType="com.ruoyi.system.domain.Cbca"> insert into `CBCA` (CBCA01, CBCA02, CBCA03, CBCA04, CBCA05, CBCA06, CBCA07, CBCA08, CBCA09, CBCA10, CBCA11, CBCA12, CBCA13, CBCA14, CBCA15, CBCA16, CBCA17, CBCA18, CBCA19, CBCA20, CBCA21, CBCA22, CBCA23, CBCA24, CBCA25, CBCA26, CBCA27, CBCA28) values (#{cbca01,jdbcType=INTEGER}, #{cbca02,jdbcType=TIMESTAMP}, #{cbca03,jdbcType=INTEGER}, #{cbca04,jdbcType=TIMESTAMP}, #{cbca05,jdbcType=INTEGER}, #{cbca06,jdbcType=INTEGER}, #{cbca07,jdbcType=VARCHAR}, #{cbca08,jdbcType=VARCHAR}, #{cbca09,jdbcType=VARCHAR}, #{cbca10,jdbcType=VARCHAR}, #{cbca11,jdbcType=VARCHAR}, #{cbca12,jdbcType=VARCHAR}, #{cbca13,jdbcType=VARCHAR}, #{cbca14,jdbcType=VARCHAR}, #{cbca15,jdbcType=VARCHAR}, #{cbca16,jdbcType=VARCHAR}, #{cbca17,jdbcType=VARCHAR}, #{cbca18,jdbcType=VARCHAR}, #{cbca19,jdbcType=VARCHAR}, #{cbca20,jdbcType=VARCHAR}, #{cbca21,jdbcType=VARCHAR}, #{cbca22,jdbcType=VARCHAR}, #{cbca23,jdbcType=VARCHAR}, #{cbca24,jdbcType=VARCHAR}, #{cbca25,jdbcType=VARCHAR}, #{cbca26,jdbcType=VARCHAR}, #{cbca27,jdbcType=VARCHAR}, #{cbca28,jdbcType=INTEGER}) </insert> <insert id="insertSelective" parameterType="com.ruoyi.system.domain.Cbca"> insert into `CBCA` <trim prefix="(" suffix=")" suffixOverrides=","> <if test="cbca01 != null"> CBCA01, </if> <if test="cbca02 != null"> CBCA02, </if> <if test="cbca03 != null"> CBCA03, </if> <if test="cbca04 != null"> CBCA04, </if> <if test="cbca05 != null"> CBCA05, </if> <if test="cbca06 != null"> CBCA06, </if> <if test="cbca07 != null"> CBCA07, </if> <if test="cbca08 != null"> CBCA08, </if> <if test="cbca09 != null"> CBCA09, </if> <if test="cbca10 != null"> CBCA10, </if> <if test="cbca11 != null"> CBCA11, </if> <if test="cbca12 != null"> CBCA12, </if> <if test="cbca13 != null"> CBCA13, </if> <if test="cbca14 != null"> CBCA14, </if> <if test="cbca15 != null"> CBCA15, </if> <if test="cbca16 != null"> CBCA16, </if> <if test="cbca17 != null"> CBCA17, </if> <if test="cbca18 != null"> CBCA18, </if> <if test="cbca19 != null"> CBCA19, </if> <if test="cbca20 != null"> CBCA20, </if> <if test="cbca21 != null"> CBCA21, </if> <if test="cbca22 != null"> CBCA22, </if> <if test="cbca23 != null"> CBCA23, </if> <if test="cbca24 != null"> CBCA24, </if> <if test="cbca25 != null"> CBCA25, </if> <if test="cbca26 != null"> CBCA26, </if> <if test="cbca27 != null"> CBCA27, </if> <if test="cbca28 != null"> CBCA28, </if> </trim> <trim prefix="values (" suffix=")" suffixOverrides=","> <if test="cbca01 != null"> #{cbca01,jdbcType=INTEGER}, </if> <if test="cbca02 != null"> #{cbca02,jdbcType=TIMESTAMP}, </if> <if test="cbca03 != null"> #{cbca03,jdbcType=INTEGER}, </if> <if test="cbca04 != null"> #{cbca04,jdbcType=TIMESTAMP}, </if> <if test="cbca05 != null"> #{cbca05,jdbcType=INTEGER}, </if> <if test="cbca06 != null"> #{cbca06,jdbcType=INTEGER}, </if> <if test="cbca07 != null"> #{cbca07,jdbcType=VARCHAR}, </if> <if test="cbca08 != null"> #{cbca08,jdbcType=VARCHAR}, </if> <if test="cbca09 != null"> #{cbca09,jdbcType=VARCHAR}, </if> <if test="cbca10 != null"> #{cbca10,jdbcType=VARCHAR}, </if> <if test="cbca11 != null"> #{cbca11,jdbcType=VARCHAR}, </if> <if test="cbca12 != null"> #{cbca12,jdbcType=VARCHAR}, </if> <if test="cbca13 != null"> #{cbca13,jdbcType=VARCHAR}, </if> <if test="cbca14 != null"> #{cbca14,jdbcType=VARCHAR}, </if> <if test="cbca15 != null"> #{cbca15,jdbcType=VARCHAR}, </if> <if test="cbca16 != null"> #{cbca16,jdbcType=VARCHAR}, </if> <if test="cbca17 != null"> #{cbca17,jdbcType=VARCHAR}, </if> <if test="cbca18 != null"> #{cbca18,jdbcType=VARCHAR}, </if> <if test="cbca19 != null"> #{cbca19,jdbcType=VARCHAR}, </if> <if test="cbca20 != null"> #{cbca20,jdbcType=VARCHAR}, </if> <if test="cbca21 != null"> #{cbca21,jdbcType=VARCHAR}, </if> <if test="cbca22 != null"> #{cbca22,jdbcType=VARCHAR}, </if> <if test="cbca23 != null"> #{cbca23,jdbcType=VARCHAR}, </if> <if test="cbca24 != null"> #{cbca24,jdbcType=VARCHAR}, </if> <if test="cbca25 != null"> #{cbca25,jdbcType=VARCHAR}, </if> <if test="cbca26 != null"> #{cbca26,jdbcType=VARCHAR}, </if> <if test="cbca27 != null"> #{cbca27,jdbcType=VARCHAR}, </if> <if test="cbca28 != null"> #{cbca28,jdbcType=INTEGER}, </if> </trim> </insert> <select id="countByExample" parameterType="com.ruoyi.system.domain.CbcaCriteria" resultType="java.lang.Long"> select count(*) from `CBCA` <if test="_parameter != null"> <include refid="Example_Where_Clause" /> </if> </select> <update id="updateByExampleSelective" parameterType="map"> update `CBCA` <set> <if test="record.cbca01 != null"> CBCA01 = #{record.cbca01,jdbcType=INTEGER}, </if> <if test="record.cbca02 != null"> CBCA02 = #{record.cbca02,jdbcType=TIMESTAMP}, </if> <if test="record.cbca03 != null"> CBCA03 = #{record.cbca03,jdbcType=INTEGER}, </if> <if test="record.cbca04 != null"> CBCA04 = #{record.cbca04,jdbcType=TIMESTAMP}, </if> <if test="record.cbca05 != null"> CBCA05 = #{record.cbca05,jdbcType=INTEGER}, </if> <if test="record.cbca06 != null"> CBCA06 = #{record.cbca06,jdbcType=INTEGER}, </if> <if test="record.cbca07 != null"> CBCA07 = #{record.cbca07,jdbcType=VARCHAR}, </if> <if test="record.cbca08 != null"> CBCA08 = #{record.cbca08,jdbcType=VARCHAR}, </if> <if test="record.cbca09 != null"> CBCA09 = #{record.cbca09,jdbcType=VARCHAR}, </if> <if test="record.cbca10 != null"> CBCA10 = #{record.cbca10,jdbcType=VARCHAR}, </if> <if test="record.cbca11 != null"> CBCA11 = #{record.cbca11,jdbcType=VARCHAR}, </if> <if test="record.cbca12 != null"> CBCA12 = #{record.cbca12,jdbcType=VARCHAR}, </if> <if test="record.cbca13 != null"> CBCA13 = #{record.cbca13,jdbcType=VARCHAR}, </if> <if test="record.cbca14 != null"> CBCA14 = #{record.cbca14,jdbcType=VARCHAR}, </if> <if test="record.cbca15 != null"> CBCA15 = #{record.cbca15,jdbcType=VARCHAR}, </if> <if test="record.cbca16 != null"> CBCA16 = #{record.cbca16,jdbcType=VARCHAR}, </if> <if test="record.cbca17 != null"> CBCA17 = #{record.cbca17,jdbcType=VARCHAR}, </if> <if test="record.cbca18 != null"> CBCA18 = #{record.cbca18,jdbcType=VARCHAR}, </if> <if test="record.cbca19 != null"> CBCA19 = #{record.cbca19,jdbcType=VARCHAR}, </if> <if test="record.cbca20 != null"> CBCA20 = #{record.cbca20,jdbcType=VARCHAR}, </if> <if test="record.cbca21 != null"> CBCA21 = #{record.cbca21,jdbcType=VARCHAR}, </if> <if test="record.cbca22 != null"> CBCA22 = #{record.cbca22,jdbcType=VARCHAR}, </if> <if test="record.cbca23 != null"> CBCA23 = #{record.cbca23,jdbcType=VARCHAR}, </if> <if test="record.cbca24 != null"> CBCA24 = #{record.cbca24,jdbcType=VARCHAR}, </if> <if test="record.cbca25 != null"> CBCA25 = #{record.cbca25,jdbcType=VARCHAR}, </if> <if test="record.cbca26 != null"> CBCA26 = #{record.cbca26,jdbcType=VARCHAR}, </if> <if test="record.cbca27 != null"> CBCA27 = #{record.cbca27,jdbcType=VARCHAR}, </if> <if test="record.cbca28 != null"> CBCA28 = #{record.cbca28,jdbcType=INTEGER}, </if> </set> <if test="_parameter != null"> <include refid="Update_By_Example_Where_Clause" /> </if> </update> <update id="updateByExample" parameterType="map"> update `CBCA` set CBCA01 = #{record.cbca01,jdbcType=INTEGER}, CBCA02 = #{record.cbca02,jdbcType=TIMESTAMP}, CBCA03 = #{record.cbca03,jdbcType=INTEGER}, CBCA04 = #{record.cbca04,jdbcType=TIMESTAMP}, CBCA05 = #{record.cbca05,jdbcType=INTEGER}, CBCA06 = #{record.cbca06,jdbcType=INTEGER}, CBCA07 = #{record.cbca07,jdbcType=VARCHAR}, CBCA08 = #{record.cbca08,jdbcType=VARCHAR}, CBCA09 = #{record.cbca09,jdbcType=VARCHAR}, CBCA10 = #{record.cbca10,jdbcType=VARCHAR}, CBCA11 = #{record.cbca11,jdbcType=VARCHAR}, CBCA12 = #{record.cbca12,jdbcType=VARCHAR}, CBCA13 = #{record.cbca13,jdbcType=VARCHAR}, CBCA14 = #{record.cbca14,jdbcType=VARCHAR}, CBCA15 = #{record.cbca15,jdbcType=VARCHAR}, CBCA16 = #{record.cbca16,jdbcType=VARCHAR}, CBCA17 = #{record.cbca17,jdbcType=VARCHAR}, CBCA18 = #{record.cbca18,jdbcType=VARCHAR}, CBCA19 = #{record.cbca19,jdbcType=VARCHAR}, CBCA20 = #{record.cbca20,jdbcType=VARCHAR}, CBCA21 = #{record.cbca21,jdbcType=VARCHAR}, CBCA22 = #{record.cbca22,jdbcType=VARCHAR}, CBCA23 = #{record.cbca23,jdbcType=VARCHAR}, CBCA24 = #{record.cbca24,jdbcType=VARCHAR}, CBCA25 = #{record.cbca25,jdbcType=VARCHAR}, CBCA26 = #{record.cbca26,jdbcType=VARCHAR}, CBCA27 = #{record.cbca27,jdbcType=VARCHAR}, CBCA28 = #{record.cbca28,jdbcType=INTEGER} <if test="_parameter != null"> <include refid="Update_By_Example_Where_Clause" /> </if> </update> <update id="updateByPrimaryKeySelective" parameterType="com.ruoyi.system.domain.Cbca"> update `CBCA` <set> <if test="cbca02 != null"> CBCA02 = #{cbca02,jdbcType=TIMESTAMP}, </if> <if test="cbca03 != null"> CBCA03 = #{cbca03,jdbcType=INTEGER}, </if> <if test="cbca04 != null"> CBCA04 = #{cbca04,jdbcType=TIMESTAMP}, </if> <if test="cbca05 != null"> CBCA05 = #{cbca05,jdbcType=INTEGER}, </if> <if test="cbca06 != null"> CBCA06 = #{cbca06,jdbcType=INTEGER}, </if> <if test="cbca07 != null"> CBCA07 = #{cbca07,jdbcType=VARCHAR}, </if> <if test="cbca08 != null"> CBCA08 = #{cbca08,jdbcType=VARCHAR}, </if> <if test="cbca09 != null"> CBCA09 = #{cbca09,jdbcType=VARCHAR}, </if> <if test="cbca10 != null"> CBCA10 = #{cbca10,jdbcType=VARCHAR}, </if> <if test="cbca11 != null"> CBCA11 = #{cbca11,jdbcType=VARCHAR}, </if> <if test="cbca12 != null"> CBCA12 = #{cbca12,jdbcType=VARCHAR}, </if> <if test="cbca13 != null"> CBCA13 = #{cbca13,jdbcType=VARCHAR}, </if> <if test="cbca14 != null"> CBCA14 = #{cbca14,jdbcType=VARCHAR}, </if> <if test="cbca15 != null"> CBCA15 = #{cbca15,jdbcType=VARCHAR}, </if> <if test="cbca16 != null"> CBCA16 = #{cbca16,jdbcType=VARCHAR}, </if> <if test="cbca17 != null"> CBCA17 = #{cbca17,jdbcType=VARCHAR}, </if> <if test="cbca18 != null"> CBCA18 = #{cbca18,jdbcType=VARCHAR}, </if> <if test="cbca19 != null"> CBCA19 = #{cbca19,jdbcType=VARCHAR}, </if> <if test="cbca20 != null"> CBCA20 = #{cbca20,jdbcType=VARCHAR}, </if> <if test="cbca21 != null"> CBCA21 = #{cbca21,jdbcType=VARCHAR}, </if> <if test="cbca22 != null"> CBCA22 = #{cbca22,jdbcType=VARCHAR}, </if> <if test="cbca23 != null"> CBCA23 = #{cbca23,jdbcType=VARCHAR}, </if> <if test="cbca24 != null"> CBCA24 = #{cbca24,jdbcType=VARCHAR}, </if> <if test="cbca25 != null"> CBCA25 = #{cbca25,jdbcType=VARCHAR}, </if> <if test="cbca26 != null"> CBCA26 = #{cbca26,jdbcType=VARCHAR}, </if> <if test="cbca27 != null"> CBCA27 = #{cbca27,jdbcType=VARCHAR}, </if> <if test="cbca28 != null"> CBCA28 = #{cbca28,jdbcType=INTEGER}, </if> </set> where CBCA01 = #{cbca01,jdbcType=INTEGER} </update> <update id="updateByPrimaryKey" parameterType="com.ruoyi.system.domain.Cbca"> update `CBCA` set CBCA02 = #{cbca02,jdbcType=TIMESTAMP}, CBCA03 = #{cbca03,jdbcType=INTEGER}, CBCA04 = #{cbca04,jdbcType=TIMESTAMP}, CBCA05 = #{cbca05,jdbcType=INTEGER}, CBCA06 = #{cbca06,jdbcType=INTEGER}, CBCA07 = #{cbca07,jdbcType=VARCHAR}, CBCA08 = #{cbca08,jdbcType=VARCHAR}, CBCA09 = #{cbca09,jdbcType=VARCHAR}, CBCA10 = #{cbca10,jdbcType=VARCHAR}, CBCA11 = #{cbca11,jdbcType=VARCHAR}, CBCA12 = #{cbca12,jdbcType=VARCHAR}, CBCA13 = #{cbca13,jdbcType=VARCHAR}, CBCA14 = #{cbca14,jdbcType=VARCHAR}, CBCA15 = #{cbca15,jdbcType=VARCHAR}, CBCA16 = #{cbca16,jdbcType=VARCHAR}, CBCA17 = #{cbca17,jdbcType=VARCHAR}, CBCA18 = #{cbca18,jdbcType=VARCHAR}, CBCA19 = #{cbca19,jdbcType=VARCHAR}, CBCA20 = #{cbca20,jdbcType=VARCHAR}, CBCA21 = #{cbca21,jdbcType=VARCHAR}, CBCA22 = #{cbca22,jdbcType=VARCHAR}, CBCA23 = #{cbca23,jdbcType=VARCHAR}, CBCA24 = #{cbca24,jdbcType=VARCHAR}, CBCA25 = #{cbca25,jdbcType=VARCHAR}, CBCA26 = #{cbca26,jdbcType=VARCHAR}, CBCA27 = #{cbca27,jdbcType=VARCHAR}, CBCA28 = #{cbca28,jdbcType=INTEGER} where CBCA01 = #{cbca01,jdbcType=INTEGER} </update> <update id="updateCBCA" parameterType="CBCA"> update CBCA <trim prefix="SET" suffixOverrides=","> <if test="cbca02 != null">CBCA02 = #{cbca02},</if> <if test="cbca03 != null">CBCA03 = #{cbca03},</if> <if test="cbca04 != null">CBCA04 = #{cbca04},</if> <if test="cbca05 != null">CBCA05 = #{cbca05},</if> <if test="cbca06 != null">CBCA06 = #{cbca06},</if> <if test="cbca07 != null">CBCA07 = #{cbca07},</if> <if test="cbca08 != null">CBCA08 = #{cbca08},</if> <if test="cbca09 != null">CBCA09 = #{cbca09},</if> <if test="cbca10 != null">CBCA10 = #{cbca10},</if> <if test="cbca11 != null">CBCA11 = #{cbca11},</if> <if test="cbca12 != null">CBCA12 = #{cbca12},</if> <if test="cbca13 != null">CBCA13 = #{cbca13},</if> <if test="cbca14 != null">CBCA14 = #{cbca14},</if> <if test="cbca15 != null">CBCA15 = #{cbca15},</if> <if test="cbca16 != null">CBCA16 = #{cbca16},</if> <if test="cbca17 != null">CBCA17 = #{cbca17},</if> <if test="cbca18 != null">CBCA18 = #{cbca18},</if> <if test="cbca19 != null">CBCA19 = #{cbca19},</if> <if test="cbca20 != null">CBCA20 = #{cbca20},</if> <if test="cbca21 != null">CBCA21 = #{cbca21},</if> <if test="cbca22 != null">CBCA22 = #{cbca22},</if> <if test="cbca23 != null">CBCA23 = #{cbca23},</if> <if test="cbca24 != null">CBCA24 = #{cbca24},</if> <if test="cbca25 != null">CBCA25 = #{cbca25},</if> <if test="cbca26 != null">CBCA26 = #{cbca26},</if> <if test="cbca27 != null">CBCA27 = #{cbca27},</if> <if test="cbca28 != null">CBCA28 = #{cbca28},</if> </trim> where CBCA01 = #{cbca01} </update> <insert id="insertCBCA" parameterType="CBCA"> insert into CBCA <trim prefix="(" suffix=")" suffixOverrides=","> <if test="cbca01 != null">CBCA01,</if> <if test="cbca02 != null">CBCA02,</if> <if test="cbca03 != null">CBCA03,</if> <if test="cbca04 != null">CBCA04,</if> <if test="cbca05 != null">CBCA05,</if> <if test="cbca06 != null">CBCA06,</if> <if test="cbca07 != null">CBCA07,</if> <if test="cbca08 != null">CBCA08,</if> <if test="cbca09 != null">CBCA09,</if> <if test="cbca10 != null">CBCA10,</if> <if test="cbca11 != null">CBCA11,</if> <if test="cbca12 != null">CBCA12,</if> <if test="cbca13 != null">CBCA13,</if> <if test="cbca14 != null">CBCA14,</if> <if test="cbca15 != null">CBCA15,</if> <if test="cbca16 != null">CBCA16,</if> <if test="cbca17 != null">CBCA17,</if> <if test="cbca18 != null">CBCA18,</if> <if test="cbca19 != null">CBCA19,</if> <if test="cbca20 != null">CBCA20,</if> <if test="cbca21 != null">CBCA21,</if> <if test="cbca22 != null">CBCA22,</if> <if test="cbca23 != null">CBCA23,</if> <if test="cbca24 != null">CBCA24,</if> <if test="cbca25 != null">CBCA25,</if> <if test="cbca26 != null">CBCA26,</if> <if test="cbca27 != null">CBCA27,</if> <if test="cbca28 != null">CBCA28,</if> </trim> <trim prefix="values (" suffix=")" suffixOverrides=","> <if test="cbca01 != null">#{cbca01},</if> <if test="cbca02 != null">#{cbca02},</if> <if test="cbca03 != null">#{cbca03},</if> <if test="cbca04 != null">#{cbca04},</if> <if test="cbca05 != null">#{cbca05},</if> <if test="cbca06 != null">#{cbca06},</if> <if test="cbca07 != null">#{cbca07},</if> <if test="cbca08 != null">#{cbca08},</if> <if test="cbca09 != null">#{cbca09},</if> <if test="cbca10 != null">#{cbca10},</if> <if test="cbca11 != null">#{cbca11},</if> <if test="cbca12 != null">#{cbca12},</if> <if test="cbca13 != null">#{cbca13},</if> <if test="cbca14 != null">#{cbca14},</if> <if test="cbca15 != null">#{cbca15},</if> <if test="cbca16 != null">#{cbca16},</if> <if test="cbca17 != null">#{cbca17},</if> <if test="cbca18 != null">#{cbca18},</if> <if test="cbca19 != null">#{cbca19},</if> <if test="cbca20 != null">#{cbca20},</if> <if test="cbca21 != null">#{cbca21},</if> <if test="cbca22 != null">#{cbca22},</if> <if test="cbca23 != null">#{cbca23},</if> <if test="cbca24 != null">#{cbca24},</if> <if test="cbca25 != null">#{cbca25},</if> <if test="cbca26 != null">#{cbca26},</if> <if test="cbca27 != null">#{cbca27},</if> <if test="cbca28 != null">#{cbca28},</if> </trim> </insert> <resultMap type="CBCA" id="CBCAResult"> <result property="cbca01" column="CBCA01" /> <result property="cbca02" column="CBCA02" /> <result property="cbca03" column="CBCA03" /> <result property="cbca04" column="CBCA04" /> <result property="cbca05" column="CBCA05" /> <result property="cbca06" column="CBCA06" /> <result property="cbca07" column="CBCA07" /> <result property="cbca08" column="CBCA08" /> <result property="cbca09" column="CBCA09" /> <result property="cbca10" column="CBCA10" /> <result property="cbca11" column="CBCA11" /> <result property="cbca12" column="CBCA12" /> <result property="cbca13" column="CBCA13" /> <result property="cbca14" column="CBCA14" /> <result property="cbca15" column="CBCA15" /> <result property="cbca16" column="CBCA16" /> <result property="cbca17" column="CBCA17" /> <result property="cbca18" column="CBCA18" /> <result property="cbca19" column="CBCA19" /> <result property="cbca20" column="CBCA20" /> <result property="cbca21" column="CBCA21" /> <result property="cbca22" column="CBCA22" /> <result property="cbca23" column="CBCA23" /> <result property="cbca24" column="CBCA24" /> <result property="cbca25" column="CBCA25" /> <result property="cbca26" column="CBCA26" /> <result property="cbca27" column="CBCA27" /> <result property="cbca28" column="CBCA28" /> </resultMap> <sql id="selectCBCAVo"> select CBCA01, CBCA02, CBCA03, CBCA04, CBCA05, CBCA06, CBCA07, CBCA08, CBCA09, CBCA10, CBCA11, CBCA12, CBCA13, CBCA14, CBCA15, CBCA16, CBCA17, CBCA18, CBCA19, CBCA20, CBCA21, CBCA22, CBCA23, CBCA24, CBCA25, CBCA26, CBCA27, CBCA28 from CBCA </sql> <select id="selectCBWAList" parameterType="CBCA" resultMap="CBCAResult"> <include refid="selectCBCAVo"/> <where> CBCA06=0 <if test="cbca01 != null "> and CBCA01 = #{cbca01}</if> <if test="cbca02 != null "> and CBCA02 = #{cbca02}</if> <if test="cbca03 != null "> and CBCA03 = #{cbca03}</if> <if test="cbca04 != null "> and CBCA04 = #{cbca04}</if> <if test="cbca05 != null "> and CBCA05 = #{cbca05}</if> <if test="cbca07 != null and cbca07 != ''"> and CBCA07 = #{cbca07}</if> <if test="cbca08 != null and cbca08 != ''"> and CBCA08 like concat('%', #{cbca08}, '%')</if> <if test="cbca09 != null and cbca09 != ''"> and CBCA09 = #{cbca09}</if> <if test="cbca10 != null and cbca10 != ''"> and CBCA10 = #{cbca10}</if> <if test="cbca11 != null and cbca11 != ''"> and CBCA11 = #{cbca11}</if> <if test="cbca12 != null and cbca12 != ''"> and CBCA12 = #{cbca12}</if> <if test="cbca13 != null and cbca13 != ''"> and CBCA13 = #{cbca13}</if> <if test="cbca14 != null and cbca14 != ''"> and CBCA14 = #{cbca14}</if> <if test="cbca15 != null and cbca15 != ''"> and CBCA15 = #{cbca15}</if> <if test="cbca16 != null and cbca16 != ''"> and CBCA16 = #{cbca16}</if> <if test="cbca17 != null and cbca17 != ''"> and CBCA17 = #{cbca17}</if> <if test="cbca18 != null and cbca18 != ''"> and CBCA18 = #{cbca18}</if> <if test="cbca19 != null and cbca19 != ''"> and CBCA19 = #{cbca19}</if> <if test="cbca20 != null and cbca20 != ''"> and CBCA20 = #{cbca20}</if> <if test="cbca21 != null and cbca21 != ''"> and CBCA21 = #{cbca21}</if> <if test="cbca22 != null and cbca22 != ''"> and CBCA22 = #{cbca22}</if> <if test="cbca23 != null and cbca23 != ''"> and CBCA23 = #{cbca23}</if> <if test="cbca24 != null and cbca24 != ''"> and CBCA24 = #{cbca24}</if> <if test="cbca25 != null and cbca25 != ''"> and CBCA25 = #{cbca25}</if> <if test="cbca26 != null and cbca26 != ''"> and CBCA26 = #{cbca26}</if> <if test="cbca27 != null and cbca27 != ''"> and CBCA27 = #{cbca27}</if> <if test="cbca28 != null "> and CBCA28 = #{cbca28}</if> order by CBCA02 desc </where> </select> </mapper>
二、前端部分(Vue)
<template> <div class="app-container"> <el-form ref="form2" :model="form2" label-width="130px" :rules="rules" style=""> <div class="chuangjiancaigous">国内销售订单</div> <!-- 编号:56221589223 --> <el-row :gutter="20" style="margin-top: 20px;"> <el-col :span="8"> <el-form-item label="编号:" prop="orderNo"> <!-- <el-input type="text" v-model="form2.cbpc07" style="width: 60%;" />--> </el-form-item> </el-col> <el-col :span="8"> <el-form-item label="客户单号:" prop="customerNo"> <el-input type="text" v-model="formData.customerNo" style="width: 70%;" /> </el-form-item> </el-col> <el-col :span="8"> <el-form-item label="日期:" prop="orderDate"> <el-date-picker type="date" placeholder="" v-model="formData.orderDate" style="width: 70%;"> </el-date-picker> </el-form-item> </el-col> </el-row> <el-row :gutter="20" style="margin-top: 1px;"> <el-col :span="8"> <el-form-item label="客户:" prop="customerId"> <el-select @change="customerOnChange" v-loadmore="customerloadMore" v-model="formData.customerId" filterable clearable :filter-method="customerdataFilter" placeholder="请选择" style="width: 70%;"> <el-option v-for="item in customeroptions" :key="item.value" :label="item.label" :value="item.value"> </el-option> </el-select> </el-form-item> </el-col> <el-col :span="8"> <el-form-item label="销售人员:" prop="saleUserId"> <el-select v-loadmore="saleUserloadMore" v-model="formData.saleUserId" filterable clearable :filter-method="saleUserdataFilter" placeholder="请选择" style="width: 70%;"> <el-option v-for="item in saleUseroptions" :key="item.value" :label="item.label" :value="item.value"> </el-option> </el-select> </el-form-item> </el-col> <el-col :span="8"> <el-form-item label="结算货币:" prop="currency"> <el-select v-model="formData.currency" clearable placeholder="请选择" style="width: 70%;"> <el-option v-for="item in currencyoptions" :key="item.value" :label="item.label" :value="item.value"> </el-option> </el-select> </el-form-item> </el-col> </el-row> <el-row :gutter="20"> <el-col :span="8"> <el-form-item label="收货人:" prop="receiveName"> <el-input type="text" v-model="formData.receiveName" style="width: 70%;" /> </el-form-item> </el-col> <el-col :span="8"> <el-form-item label="电话:" prop="receivePhone"> <el-input type="text" v-model="formData.receivePhone" style="width: 70%;" /> </el-form-item> </el-col> <el-col :span="8"> <el-form-item label="发票类型:" prop="invoiceType"> <el-select v-model="formData.invoiceType" clearable placeholder="请选择" style="width: 70%;"> <el-option v-for="item in invoiceoptions" :key="item.value" :label="item.label" :value="item.value"> </el-option> </el-select> </el-form-item> </el-col> </el-row> <el-row :gutter="20"> <el-col :span="8"> <el-form-item label="订单类型:" prop="orderTypeMsg"> <el-input type="text" v-model="formData.orderTypeMsg" style="width: 70%;" disabled/> </el-form-item> </el-col> <el-col :span="8"> <el-form-item label="工厂账号:" prop="fcNumber"> <el-input type="text" v-model="formData.fcNumber" style="width: 70%;" /> </el-form-item> </el-col> <el-col :span="8"> <el-form-item label="订单分类:" prop="orderClassMsg"> <el-input type="text" v-model="formData.orderClassMsg" style="width: 70%;" disabled/> </el-form-item> </el-col> </el-row> <el-row :gutter="20"> <el-col :span="8"> <el-form-item label="地址:" prop="address"> <el-input type="text" v-model="formData.address" style="width: 120%;" /> </el-form-item> </el-col> <el-col :span="8"> <el-form-item label="备注:" prop="remark"> <el-input type="text" v-model="formData.remark" style="width: 120%;" /> </el-form-item> </el-col> </el-row> <div> <el-row> <el-col :span="24"> <el-button plain style="float: right;" type="primary" @click="_ly_addFrom">新增一行</el-button> </el-col> </el-row> <el-table :data="tableData" border :span-method="arraySpanMethod" style="width: 100%;margin-top: 10px;"> <el-table-column prop="goodsId" label="品牌" width=""> <template slot-scope="scope"> <sapn> <el-select @change="goodsOnChange(scope.row)" v-loadmore="loadMore" v-model="scope.row.goodsId" filterable clearable :filter-method="dataFilter" placeholder="请选择" style="width: 100%;"> <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"> </el-option> </el-select> </sapn> </template> </el-table-column> <el-table-column label="型号" width="" /> <el-table-column label="描述" width="" /> <el-table-column prop="qty" label="数量" width="150" > <template slot-scope="scope"> <sapn> <el-input @change="goodsQtyChange(scope.row)" v-model="scope.row.qty" placeholder="数量" @input="sum(scope.row)" oninput="value= value.match(/\d+(\.\d{0,2})?/) ? value.match(/\d+(\.\d{0,2})?/)[0] : ''"></el-input> <!-- <el-input :id="scope.row.goodsId" :class="this.qtyclass" v-model="scope.row.qty" placeholder="数量" style="" @input="sum(scope.row)" ></el-input>--> </sapn> </template> </el-table-column> <el-table-column prop="normalPrice" label="标准单价" width="150"> <template slot-scope="scope"> <sapn> <el-input v-model="scope.row.normalPrice" placeholder="标准单价" style="" readonly></el-input> </sapn> </template> </el-table-column> <el-table-column prop="currentPrice" label="本次单价" width="150"> <template slot-scope="scope"> <sapn> <el-input v-model="scope.row.currentPrice" placeholder="本次单价" style="" @input="sum(scope.row)" oninput="value= value.match(/\d+(\.\d{0,2})?/) ? value.match(/\d+(\.\d{0,2})?/)[0] : ''"></el-input> </sapn> </template> </el-table-column> <el-table-column prop="totalPrice" label="金额" width="150"> <template slot-scope="scope"> <sapn> <el-input v-model="scope.row.totalPrice" placeholder="金额" style="" readonly></el-input> </sapn> </template> </el-table-column> <el-table-column prop="canUseSku" label="可用库存" width="150"> <template slot-scope="scope"> <sapn> <el-input v-model="scope.row.canUseSku" placeholder="可用库存" style="" readonly></el-input> </sapn> </template> </el-table-column> <el-table-column prop="remark" label="备注" width=""> <template slot-scope="scope"> <sapn> <el-input v-model="scope.row.remark" type="textarea" placeholder="备注"></el-input> </sapn> </template> </el-table-column> <el-table-column label="操作" align="center" width="80"> <template slot-scope="scope"> <span @click="_ly_delFrom(scope.row)"> <i class="el-icon-error" style="color: red;"></i> </span> </template> </el-table-column> </el-table> </div> </el-form> <div class="tinajia_dingwei"> <!-- <span slot="footer" class="dialog-footer" style="margin-left:2%; padding-top:-2%;"> --> <el-button type="primary" @click="handleAdd">保 存</el-button> <el-button @click="_ly_cancelDialog">取 消</el-button> <!-- </span> --> </div> </div> </template> <script> import { PurchaseinboundAdd, PurchaseinboundAdds,GoodsList01 } from "@/api/Warehousemanagement/PurchaseWarehousing"; import { swJsGoodslistBySelect ,SwJsCustomerlistSelect,systemUserSelect,goodsPriceAndSku,customerDetail,addSaleOrder } from '@/api/saleordermanage' import { getToken } from "@/utils/auth"; //仓库 import kuweixxweihu from "@/components/WarehouseInfoSku"; //供应商 import supplierMaintenance from "@/components/SupplierMaintenance"; //商品信息维护 import Goodsone01 from "@/components/Goodsone"; //供应商 import ListLists from "@/components/ListMaintenance"; // //客户 // import CustomerMainten from "@/components/CustomerMaintenance"; import Vue from 'vue'; Vue.directive('loadmore', { bind(el, binding) { // 获取element-ui定义好的scroll盒子 const SELECTWRAP_DOM = el.querySelector('.el-select-dropdown .el-select-dropdown__wrap'); SELECTWRAP_DOM.addEventListener('scroll', function() { /* * scrollHeight 获取元素内容高度(只读) * scrollTop 获取或者设置元素的偏移值,常用于, 计算滚动条的位置, 当一个元素的容器没有产生垂直方向的滚动条, 那它的scrollTop的值默认为0. * clientHeight 读取元素的可见高度(只读) * 如果元素滚动到底, 下面等式返回true, 没有则返回false: * ele.scrollHeight - ele.scrollTop === ele.clientHeight; */ const CONDITION = this.scrollHeight - this.scrollTop <= this.clientHeight; if(CONDITION) { binding.value(); } }); } }) export default { name: "index", dicts: ['sys_normal_disable', 'sw_js_store_type', 'sys_user_sex', 'sw_js_store_type_manage_mode'], props: { visible: { type: Boolean, default () { return false } } }, components: { kuweixxweihu, supplierMaintenance, ListLists, Goodsone01 }, data() { return { dialogVisible: this.visible, formArr: [], // 表单结构数组 goodsMsg: "", customerId: "", slaeUserId:"", qtyclass: "normQtyclass", infoRules: { // 表单规则 name: [{ required: true, message: '请输入姓名', trigger: 'blur' }, { max: 20, message: '请输入1-20位的字符', trigger: 'blur' } ], nickname: [{ required: true, message: '请输入昵称', trigger: 'blur' }, { max: 20, message: '请输入1-20位的字符', trigger: 'blur' } ], code: [{ required: true, message: '请输入编号', trigger: 'blur' }, { max: 20, message: '请输入1-20位的字符', trigger: 'blur' } ], branch: [{ required: true, message: '请选择部门', trigger: 'blur' }, { message: '请选择部门', trigger: 'blur' } ] }, treeData: [{ // 树状数据 id: 1, label: '一级 1', children: [{ id: 4, label: '二级 1-1', children: [{ id: 9, label: '三级 1-1-1' }, { id: 10, label: '三级 1-1-2' }] }] }, { id: 2, label: '一级 2', children: [{ id: 5, label: '二级 2-1' }, { id: 6, label: '二级 2-2' }] }, { id: 3, label: '一级 3', children: [{ id: 7, label: '二级 3-1' }, { id: 8, label: '二级 3-2' }] }], defaultProps: { children: 'children', label: 'label' }, currentSelectIndex: -1, // 缓存当前操作第几行的select temp: '占位', // 遮罩层 loading: true, tianjiahang: [], // 选中数组 ids: [], shenpiids: [], // 非单个禁用 single: true, // 非多个禁用 multiple: true, // 显示搜索条件 showSearch: false, // 总条数 total: 0, // 用户表格数据 userList: null, // 弹出层标题 title: "", // 部门树选项 deptOptions: undefined, // 是否显示弹出层 open: false, open1: false, open2: false, // 部门名称 deptName: undefined, // 默认密码 initPassword: undefined, // 日期范围 housingTime: [], // 供应商选项 postOptions: [], //库位 KuWeiOptions: [], //商品信息维护品牌 shangponOptions: [], //商品信息维护的型号 XinghaoOptions: [], //仓库信息维护 //商品的品牌型号描述 ponpaixenghaomiaoshu: [], // 日期范围 dateRange: [], postCangKu: [], //修改下拉框首选值 //主副表id zfb: [], //仓库类型 LeixingOptions: [{ value: '1', label: '条码管理' }, { value: '2', label: '数量管理' }], value: '', //货币类型 jiageLeixeng: [{ value: '6', label: 'CNY' }, { value: '5', label: 'USD' }], //发票类型 invoiceoptions: [{ value: '增值税专用发票', label: '增值税专用发票' }, { value: '增值税普通发票', label: '增值税普通发票' },{ value: '个人普通发票', label: '个人普通发票' },{ value: '不开发票', label: '不开发票' }], value: '', //发票类别 fapiaoleix: [{ value: '1', label: '增值税专用发票' }, { value: '2', label: '增值税普通发票' }, { value: '3', label: '个人普通发票' }, { value: '4', label: '不开发票' }], value: '', //状态 ZhuangTaivalue: [{ value: '-1', label: '启用' }, { value: '1', label: '禁用' }], //合格状态 hegezhuangtai: [{ value: '-1', label: '合格' }, { value: '1', label: '不合格' }], value: '', //订单分类 dingdanfelei: [{ value: '1', label: '国内订单' }, { value: '2', label: '国际订单' }], value: '', //扫码状态 saomazhuangtai: [{ value: '-1', label: '已扫码' }, { value: '1', label: '未扫码' }], value: '', //入库状态 rukuzhuangtai: [{ value: '1', label: '待入库' }, { value: '2', label: '已入库' }], value: '', // 角色选项 roleOptions: [], // 表单参数 form: { cbpc07: "", cbpc08: "", cbsa08: "", cbwa09: "", cala08: "", invoiceNumber: "", invoicePhone: "", invoiceTaxpayerNumber: "", invoiceType: "", name: "", phone: "", skuSort: "", telPeople: "", cbpd09: "", cbpd11: "", cbpd12: "", cbpc166: "", cbpc16: "", cbpc01: "" }, formData: { orderType: 10, orderTypeMsg: "销售订单", orderClass: 2, orderClassMsg: '国内订单', receiveName:'', receivePhone: '', address: '' }, form1: { // classifyId: "", // brand: "", // model: "", // upc: "", // description: "", // ifEnabled: "" }, form2: { cbpc07: "", cbpc08: "", cbsa08: "", cbwa09: "", cala08: "", cbpc100: "", cbpc099: "", cbpc166: "", cbpc10: "", cbpc09: "", cbpd09: "", cbpd11: "", cbpd12: "", cbpc16: "", cbpc12: "", cbpc14: "", cbpd08: "", cbph09: "", cbph10: "", cbph11: "", cbpg161: "", cbpc01: "", cbpc000: "", cbpd09: "", cbpd11: "", cbpd12: "" }, defaultProps: { children: "children", label: "label" }, // 用户导入参数 upload: { // 是否显示弹出层(用户导入) open: false, // 弹出层标题(用户导入) title: "", // 是否禁用上传 isUploading: false, // 是否更新已经存在的用户数据 updateSupport: 0, // 设置上传的请求头部 headers: { Authorization: "Bearer " + getToken() }, // 上传的地址 url: process.env.VUE_APP_BASE_API + "/system/barcode/importSwJsSkuBarcode" }, listQuery: { pageNum: 1, pageSize: 10 }, customerListQuery: { pageNum: 1, pageSize: 10 }, saleUserListQuery: { pageNum: 1, pageSize: 10 }, // 查询参数 queryParams: { pageNum: 1, pageSize: 10, total: this.total, cbpc07: undefined, cbsa08: undefined, cbwa09: undefined, dateRange: undefined }, rules: { // orderDate: [ // { required: true, message: '请输入日期', trigger: 'blur' }, // // { type: 'number', message: '优先级必须为数字'} // ], saleUserId: [ { required: true, message: '请输入销售人员', trigger: 'blur' }, ], // goods: [ // { required: true, message: '请选择商品', trigger: 'blur' }, // ], customerId: [ { required: true, message: '请输入客户', trigger: 'blur' }, // { type: 'number', message: '数量必须为数字'} ], }, //表格参数 tableData: [], dataId: 0, options: [], saleUseroptions: [], customeroptions: [], saleUseroptions: [], //选择集合 currencyoptions:[ { value: '6', label: 'CNY' }, { value: '7', label: 'USD' } ], options3: [{ value: '选项1', label: '黄金糕' }, { value: '选项2', label: '双皮奶' }, { value: '选项3', label: '蚵仔煎' }, { value: '选项4', label: '龙须面' }, { value: '选项5', label: '北京烤鸭' }, { value: '选项1', label: '黄金糕' }, { value: '选项2', label: '双皮奶' }, { value: '选项3', label: '蚵仔煎' }, { value: '选项4', label: '龙须面' }, { value: '选项5', label: '北京烤鸭' }], options2: [{ value: '选项1', label: '黄金糕2' }, { value: '选项2', label: '双皮奶2' }, { value: '选项3', label: '蚵仔煎2' }, { value: '选项4', label: '龙须面2' }, { value: '选项5', label: '北京烤鸭2' }], }; }, computed: { dialogTitle() { return '添加' } }, watch: { // 根据名称筛选部门树 deptName(val) { this.$refs.tree.filter(val); }, }, created() { this.getConfigKey("sys.user.initPassword").then(response => { // this.initPassword = response.msg; }); this.getDicts("sw_js_store_type").then(response => { this.form.type = response.rows; }); // this.form.type = this.dict[0].label; // this.userList.housingTime.substring(0, this.userList.housingTime.indexOf("T")); // console.log(this.userList,123456789); this.chen(); this.form2.cbph10 = "20" console.log(this.form.cbpc16, 123456); }, methods: { // 合并单元格 arraySpanMethod({ row, column, rowIndex, columnIndex }) { if (columnIndex === 0) { return [1, 3]; } else if (columnIndex < 3) { return [0, 0]; } }, // 点击右上角关闭弹窗 _ly_closeDialog(done) { console.log('_ly_closeDialog') this.$emit('on-close') }, // 点击【取消】按钮关闭弹窗 _ly_cancelDialog(done) { this.$store.dispatch("tagsView/delView", this.$route) this.$router.push({path: "/Salesmanagement/SaleOrderGn", query: {id: 1}}) }, // 关闭弹窗前,二次询问是否关闭 _ly_beforeClose(done) { this.$confirm('确认关闭?') .then(_ => { done() }) .catch(_ => {}) }, // 点击【保存】按钮后,如果每行的表单验证成功则存储数据 _ly_ok() { let count = this.formArr.length // 记录当前有多少个表单 for (var index in this.formArr) { var form = this.formArr[index] console.log(form) console.log(JSON.stringify(form)) // 通过refs和表单名找到表单对象,通过自带的validate检查表单内容 this.$refs[form.formName][0].validate((valid, obj) => { if (valid) { // 如果检查通过,则对count减1。 // 当count为1时,表示是最后一个表单,则存储数据 PurchaseinboundAdds(JSON.stringify(this.formArr)).then(response => { if (response.code == "200") { this.formArr = [] this.form2 = { cbpc07: "", cbpc08: "", cbsa08: "", cbwa09: "", cala08: "", cbpc100: "", cbpc099: "", cbpc166: "", cbpc10: "", cbpc09: "", cbpd09: "", cbpd11: "", cbpd12: "", cbpc16: "", cbpc12: "", cbpc14: "", cbpd08: "", cbph09: "", cbph10: "", cbph11: "", cbpg161: "", cbpc01: "", cbpc000: "", cbpd09: "", cbpd11: "", cbpd12: "" } } if (count-- === 1) { this._ly_save() } this._ly_addFrom() // this.formArr.cbpg01="1234567"; // this.form.cbpg01=this.formArr.cbpg01; // console.log(this.form.cbpg01,85203); }); } else { console.log(obj) return false } }) } console.log('_ly_ok:' + JSON.stringify(this.formArr)) }, // 存储表单数据 _ly_save() { this.$message.success('添加成功') // 将数据传递给父组件。 // 如果要将数据存储到后台,可在此处自行实现 this.$emit('on-ok', this.formArr) }, // 增加一行表单 _ly_addFrom() { this.tableData.push({ goodsId: '', // normalPrice: '', qty: '', canUseSku: 0, moner: '', province: '', }) this.dataId++ console.log(this.tableData); }, // 删除一行表单 _ly_delFrom(row) { this.tableData.splice(this.tableData.indexOf(row), 1) }, _ly_chooseBefore(index) { console.log('_ly_chooseBefore:' + index) this.currentSelectIndex = index }, _ly_chooseNode(data) { console.log('_ly_chooseNode:' + JSON.stringify(data)) let index = this.currentSelectIndex if (index === -1) { return } this.formArr[index].branch = data.label // 选择后收起下拉框 let formName = this.formArr[index].formName this.$refs[formName + '_select'][0].blur() // myform1648431132399_select }, show() { this.showSearch = !this.showSearch; }, chen(item) { if (item.cbpd09 > 0 && item.cbpd11 > 0) { this.$set(item, 'cbpd12', (parseFloat(item.cbpd09) * parseFloat(item.cbpd11))) } // this.form2.cbpd12 = this.form2.cbpd09 * this.form2.cbpd11; }, //添加模块-仓库 selected01(name) { console.log(name, 123) console.log(name.substring(name.indexOf("-") + 1), 963); this.form2.cbpc100 = name.substring(0, name.indexOf("-")) this.form2.cbpc10 = name.substring(name.indexOf("-") + 1) // this.form2.icon = name; }, //添加模块-货币类型 selected004(name) { console.log(name, 123) console.log(name.substring(name.indexOf("-") + 1), 963); this.form2.cbpc166 = name.substring(0, name.indexOf("-")); this.form2.cbpc16 = name.substring(name.indexOf("-") + 1) // this.form2.icon = name; }, //添加模块-供应商 selected02(name) { console.log(name, 123) console.log(name.substring(name.indexOf("-") + 1), 963); this.form2.cbpc099 = name.substring(0, name.indexOf("-")); this.form2.cbpc09 = name.substring(name.indexOf("-") + 1); this.form.cbsa08 = name.substring(0, name.indexOf("-")); // this.form2.icon = name; }, //查询商品信息维护 selected08(e, index) { console.log(e, 111) console.log(index, 222) this.$set(this.formArr[index], "cbpc000", e) }, //添加行 addData() { this.tianjiahang.push({ tianjiaoname: '', tianjiaogender: '', tianjiaocontact: '' }) }, deletData(index) { this.tianjiahang.splice(index, 1); }, // 取消按钮 cancel() { this.open2 = false; }, //添加的取消按钮 cancel9() { this.open2 = false; this.reset(); }, // 表单重置 reset() { this.form = { classifyName: undefined, classifyNum: undefined }; }, // 表单重置 reset01() { this.$refs["form2"].resetFields(); }, /** 重置按钮操作 */ resetQuery() { this.dateRange = []; this.resetForm("queryForm"); this.handleQuery(); }, /** 数形列表的商品分类按钮**/ submitShangpin() { this.reset(); }, saleUserloadMore(){ const param={ selectMsg: this.saleUserId, pageNum: this.saleUserListQuery.pageNum, pageSize: this.saleUserListQuery.pageSize } SwJsCustomerlistSelect(param).then(response => { if (response.code == "200") { this.saleUserListQuery.pageNum=this.saleUserListQuery.pageNum+1 this.saleUseroptions.push.apply(this.saleUserListQuery,response.data.rows) }else { this.$message.error(response.msg) } }); }, customerloadMore(){ const param={ selectMsg: this.customerId, pageNum: this.customerListQuery.pageNum, pageSize: this.customerListQuery.pageSize } SwJsCustomerlistSelect(param).then(response => { if (response.code == "200") { this.customerListQuery.pageNum=this.customerListQuery.pageNum+1 this.customeroptions.push.apply(this.customeroptions,response.data.rows) }else { this.$message.error(response.msg) } }); }, loadMore() { // console.log("滚动到底部了") // // 这里可以做你想做的任何事 到底执行 // this.options=this.options2 const param={ goodsMsg: this.goodsMsg, pageNum: this.listQuery.pageNum, pageSize: this.listQuery.pageSize } swJsGoodslistBySelect(param).then(response => { if (response.code == "200") { this.listQuery.pageNum=this.listQuery.pageNum+1 // this.options.push.apply(this.options,response.data.rows) this.options.push(...response.data.rows) }else { this.$message.error(response.msg) } }); }, dataFilter(val){ this.listQuery.pageNum=1 this.goodsMsg=val const param={ goodsMsg: this.goodsMsg, pageNum: this.listQuery.pageNum, pageSize: this.listQuery.pageSize } swJsGoodslistBySelect(param).then(response => { if (response.code == "200") { this.listQuery.pageNum=this.listQuery.pageNum+1 this.options=response.data.rows }else { this.$message.error(response.msg) } }); }, saleUserdataFilter(val){ this.saleUserListQuery.pageNum=1 this.saleUserId=val const param={ selectMsg: this.saleUserId, pageNum: this.saleUserListQuery.pageNum, pageSize: this.saleUserListQuery.pageSize } systemUserSelect(param).then(response => { if (response.code == "200") { this.saleUserListQuery.pageNum=this.saleUserListQuery.pageNum+1 this.saleUseroptions=response.data.rows }else { this.$message.error(response.msg) } }); }, customerdataFilter(val){ this.customerListQuery.pageNum=1 this.customerId=val const param={ selectMsg: this.customerId, pageNum: this.customerListQuery.pageNum, pageSize: this.customerListQuery.pageSize } SwJsCustomerlistSelect(param).then(response => { if (response.code == "200") { this.customerListQuery.pageNum=this.customerListQuery.pageNum+1 this.customeroptions=response.data.rows }else { this.$message.error(response.msg) } }); }, selected022(name) { console.log(name, 123) console.log(name.substring(name.indexOf("-") + 1), 963); this.form2.cbpc0999 = name.substring(0, name.indexOf("-")); this.form2.customerId = name.substring(name.indexOf("-") + 1); this.form.cbsa08 = name.substring(0, name.indexOf("-")); // this.form2.icon = name; }, initCustomerSelect(){ const param={} SwJsCustomerlistSelect(param).then(response => { if (response.code == "200") { this.customeroptions=response.data.rows }else { this.$message.error(response.msg) } }); }, goodsQtyChange(row){ if(row.qty>row.canUseSku){ row.qty=0 row.totalPrice=0 this.$message.error("数量不能超过可用库存数量") } }, goodsOnChange(row){ // console.log(this.formData.customer) // console.log("val",val) console.log("val",row) // row.qty=0.5 if(this.formData.customerId==null){ this.$message.error("请先选择客户") return; } //检查goodsid是否存在 if(this.checkRepeat(this.tableData,row.goodsId)){ row.goodsId=null row.normalPrice=0 row.canUseSku=0 this.$message.error("不能添加重复商品") return } const param={ goodsId: row.goodsId, customerId: this.formData.customerId, orderClass: 2, currency: this.formData.currency } // goodsPriceAndSku(param).then(response => { if (response.code == "200") { row.normalPrice=response.data.normalPrice row.canUseSku=response.data.canUseSku }else { row.normalPrice=0.0 row.canUseSku=0.0 this.$message.error(response.msg) } }); }, getQtyStyle(row){ return "color: red" }, checkRepeat(arr,goodsId) { console.log('arr',arr) console.log('goodsId',goodsId) var dupNum=0 arr.forEach((item) => { if (item.goodsId == goodsId) { console.log("重复了") dupNum=dupNum+1; } }); console.log("重复了2") if(dupNum == 1 || dupNum == 0){ return false }else { return true; } }, customerOnChange(val){ if(val=='' ){ return } const param={ cbca01: val, } // customerDetail(param).then(response => { if (response.code == "200") { this.formData.receivePhone=response.data.cbca16 this.formData.receiveName=response.data.cbca14 this.formData.address=response.data.cbca15 }else { this.formData.receivePhone='' this.formData.receiveName='' this.formData.address='' this.$message.error(response.msg) } }); }, initSaleUserSelect(){ const param={} systemUserSelect(param).then(response => { if (response.code == "200") { this.saleUseroptions=response.data.rows }else { this.$message.error(response.msg) } }); }, initSelect(){ const param={ } swJsGoodslistBySelect(param).then(response => { if (response.code == "200") { this.options=response.data.rows }else { this.$message.error(response.msg) } }); }, /** 新增按钮操作 */ handleAdd() { this.formData.goods=this.tableData addSaleOrder(this.formData).then(response => { if (response.code == "200") { this.$message.success("添加成功") this.$store.dispatch("tagsView/delView", this.$route) this.$router.push({path: "/Salesmanagement/SaleOrderGn", query: {id: 1}}) }else { this.$message.error(response.msg) // this.$router.go(-1) } } ) }, /** 返回操作 */ handleChuangJiangone: function(row) { // this.$router.push("/system/user-auth/role/"); this.$router.push("/system/user-cktkfh/role/"); }, sum(row){ if(row.qty!=null && row.currentPrice!=null){ row.totalPrice=row.qty*row.currentPrice; } }, }, mounted() { // 初始化表单数据,至少有一行表单数据 this.formArr = [] this._ly_addFrom() this.initSelect() this.initCustomerSelect() this.initSaleUserSelect() }, watch: { visible(newVal) { this.dialogVisible = newVal if (this.dialogVisible === false) { // 重新打开弹窗时,初始化表单数据,至少有一行表单数据 this.formArr = [] this._ly_addFrom() } } } }; </script> <style src="./PurchaseWarehousingcjcss/index.css"> .normQtyclass { background-color: #00afff; } </style>