后端 springboot 给 vue 提供参数

前端

c 复制代码
      /** 发起新增或修改的请求 */
      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
          }
        });

后端

c 复制代码
    /** 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;
    }
相关推荐
章豪Mrrey nical4 小时前
前后端分离工作详解Detailed Explanation of Frontend-Backend Separation Work
后端·前端框架·状态模式
派大鑫wink5 小时前
【JAVA学习日志】SpringBoot 参数配置:从基础到实战,解锁灵活配置新姿势
java·spring boot·后端
我是小路路呀5 小时前
element级联选择器:已选中一个二级节点,随后又点击了一个一级节点(仅浏览,未确认选择),此时下拉框失去焦点并关闭
javascript·vue.js·elementui
程序员爱钓鱼5 小时前
Node.js 编程实战:文件读写操作
前端·后端·node.js
xUxIAOrUIII5 小时前
【Spring Boot】控制器Controller方法
java·spring boot·后端
Dolphin_Home5 小时前
从理论到实战:图结构在仓库关联业务中的落地(小白→中级,附完整代码)
java·spring boot·后端·spring cloud·database·广度优先·图搜索算法
zfj3215 小时前
go为什么设计成源码依赖,而不是二进制依赖
开发语言·后端·golang
weixin_462446236 小时前
使用 Go 实现 SSE 流式推送 + 打字机效果(模拟 Coze Chat)
开发语言·后端·golang
JIngJaneIL6 小时前
基于springboot + vue古城景区管理系统(源码+数据库+文档)
java·开发语言·前端·数据库·vue.js·spring boot·后端
澄江静如练_6 小时前
列表渲染(v-for)
前端·javascript·vue.js