后端 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;
    }

猜你喜欢

转载自blog.csdn.net/weixin_48616345/article/details/132331474
今日推荐