基于若依的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);
相关推荐
打工人小夏几秒前
使用finalshell在新服务器上部署前端页面
linux·服务器·前端·vue.js
lvrongbao2 分钟前
互联网大厂Java面试场景:从Spring到Redis的技术问答解析
java·redis·spring·微服务·分布式事务
霸道流氓气质3 分钟前
Spring AI Advisor 完全指南:拦截器机制与实战全解
java·人工智能·spring
恋猫de小郭3 分钟前
2026 Android I/O ,全新 AI 手机、 Android PC 和车载驾驶
android·前端·flutter
XiYang-DING3 分钟前
【Java EE】 HTTPS协议
java·https·java-ee
yqcoder3 分钟前
突破性能瓶颈:深入理解 JavaScript TypedArray
java·开发语言·javascript
yqcoder4 分钟前
JS 中的“空”之双雄:null vs undefined
开发语言·前端·javascript
ch.ju4 分钟前
Java Programming Chapter 3——Traversal of array
java·开发语言
he___H5 分钟前
子串----
java·数据结构·算法·leetcode
counting money7 分钟前
MavenServlet项目文件上传
java·后端