后端 springboot 给 vue 提供参数

前端

      /** 发起新增或修改的请求 */
      requestAddOrEdit(formData) {
        debugger
        if(formData.id === undefined) {
          formData.id = ''
        }
        getAction('/material/getNameModelStandard', {
          standard: this.model.standard,
          name: this.model.name,
          model: this.model.model
        }).then((res) => {
          if (res && res.code === 200) {
            console.log(res.data.rows.id,"ididiididiidd");
            formData.id = res.data.rows.id
          }
        });

后端

    /** ycw
     * 查询商品名字 规格型号 存在修改 不存在 新增
     * @param name
     * @param request
     * @return
     * @throws Exception
     */
    @GetMapping(value = "/getNameModelStandard")
    @ApiOperation(value = "单据明细列表")
    public BaseResponseInfo getNameModelStandard(@RequestParam("name") String name,@RequestParam("standard") String standard,
                                        @RequestParam("model") String model,
                                        HttpServletRequest request) throws Exception {
        JSONObject outer = new JSONObject();
        BaseResponseInfo res = new BaseResponseInfo();
        try {
            Material material1 = new Material();
            if (name != null && !name.isEmpty()) {
                material1.setName(name);
            }
            if (standard != null && !standard.isEmpty()) {
                material1.setStandard(standard);
            }
            if (model != null && !model.isEmpty()) {
                material1.setModel(model);
            }

                List<Material> dataList = materialMapper.getNameModelStandard(material1);
                if (dataList != null && dataList.size() > 0) {
                    material1.setId(dataList.get(0).getId());
                    res.code = 200;
                    outer.put("rows", material1);
                    res.data = outer;
                }else {
                    res.code = 500;
                    res.data = "获取数据失败";
                }

        } catch (Exception e) {
            e.printStackTrace();
            res.code = 500;
            res.data = "获取数据失败";
        }
        return res;
    }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值