基于若依的ruoyi-nbcio流程管理系统一种简单的动态表单模拟测试实现(三)

更多ruoyi-nbcio功能请看演示系统

gitee源代码地址

前后端代码: https://gitee.com/nbacheng/ruoyi-nbcio

演示地址:RuoYi-Nbcio后台管理系统

更多nbcio-boot功能请看演示系统

gitee源代码地址

后端代码: https://gitee.com/nbacheng/nbcio-boot

前端代码:https://gitee.com/nbacheng/nbcio-vue.git

在线演示(包括H5) : http://122.227.135.243:9888

接上一节,之前可以动态列表查询出来后,需要进行动态查询与修改

1、如点击下面的编辑,应该可以进行查询出来进行编辑修改

2、前端做好修改的代码如下:

javascript 复制代码
/** 修改按钮操作 */
    handleUpdate(row) {
      this.loading = true;
      this.reset();
      const id = row[this.primaryKey] || this.ids
      const formData = {
        tableName: this.tableName,
        primaryKey: this.primaryKey,
        id: id
      }
      console.log("handleUpdate formData",formData)
      getDataById(formData).then(response => {
        console.log("getDataById response",response)
        this.loading = false;
        this.form = response.data;
        this.open = true;
      });
    },

3、open打开编辑界面如下:

javascript 复制代码
<!-- 添加或修改online主对话框,需要动态生成 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <div v-for="(item, i) in columnList">
          <el-form-item :label="item.__config__.label" :prop="item.__vModel__">
            <el-input v-model="form[item.__vModel__]" :placeholder="'请输入' + item.__config__.label" />
          </el-form-item>
        </div>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

4、打开界面后如下:

5、后端动态查询接口如下:

java 复制代码
import lombok.Data;

/**
 * @author superfusion
 * @Date 2024/1/22
 * @Description:
 * @Version 1.0
 */
@Data
public class FormDataVo {
	/**
     * 表名
     */
	String tableName;
	/**
     * 主键
     */
	String primaryKey;
	/**
     * 数据id
     */
	String id;
	
	/**
     * 传入要更新的字段名与值
     */
	Map<String,Object> updateMap;
}

/**
     * 根据主表名,关键字和数据动态获取具体一条表数据
     * @param tableName 主表名称
     */
    @SaCheckPermission("workflow:form:query")
    @PostMapping(value = "/getDataById")
    public R<Map> getDataById(@RequestBody FormDataVo formDataVo) {
        return R.ok(formService.getDataById(formDataVo));
    }


@Override
	public Map getDataById(FormDataVo formDataVo) {
		return baseMapper.getDataById(formDataVo.getTableName(), formDataVo.getPrimaryKey(),Long.valueOf(formDataVo.getId()));
	}

@Select("SELECT * FROM ${tableName} where ${primaryKey} = #{id}")
    Map getDataById(@Param("tableName") String tableName, @Param("primaryKey") String primaryKey,
    		        @Param("id") Long id);
相关推荐
诚心呈意共享外卖配送系统2 分钟前
多平台订单聚合系统的技术架构:接 API 只是开始
java·开发语言·架构·系统架构·创业创新
恋猫de小郭6 分钟前
Flutter Android 改动:APK 不再允许通过 Intent 动态修改 Engine 参数
android·前端·flutter
Java爱好狂.7 分钟前
Java小白如何三天速通redis?
java·数据库·redis·架构师·分布式锁·java面试·java程序员
大风起兮云飞扬丶8 分钟前
Java——多线程
java
ck01357913 分钟前
视频转 GIF 的基本流程与文件大小优化
前端·测试工具·html·音视频·视频
郝学胜-神的一滴17 分钟前
Web安全入门:读懂Web世界里的攻防
前端·网络·后端·安全·web安全·hibernate
天若有情67317 分钟前
从零搭建校园二手交易系统:Vue2 + SpringBoot 4.x 全栈实战
java·spring boot·后端
Amos_Web22 分钟前
Rspack 源码解析(二十四):AssetPlugin 如何让图片同时是「URL 字符串」和「真实文件」
前端·rust·前端框架
lexiangqicheng27 分钟前
1,自定义表单通俗理解-PC设计APP渲染
java·前端·javascript
其实防守也摸鱼34 分钟前
Codex 下载与本地部署实战指南
linux·服务器·前端·数据库·算法·ai