更多ruoyi-nbcio功能請看演示系統(tǒng)
gitee源代碼地址
前后端代碼: https://gitee.com/nbacheng/ruoyi-nbcio
演示地址:RuoYi-Nbcio后臺管理系統(tǒng)
更多nbcio-boot功能請看演示系統(tǒng)
gitee源代碼地址
后端代碼: https://gitee.com/nbacheng/nbcio-boot
前端代碼:https://gitee.com/nbacheng/nbcio-vue.git
在線演示(包括H5) : http://122.227.135.243:9888
?
接上一節(jié),今天講動態(tài)更新數(shù)據(jù)的方法
1、后端動態(tài)更新代碼如下:
/**
* 根據(jù)主表名,關鍵字和數(shù)據(jù)動態(tài)更新一條記錄
* @param tableName 主表名稱
*/
@SaCheckPermission("workflow:form:edit")
@PostMapping(value = "/updateDataById")
public R<?> updateDataById(@RequestBody FormDataVo formDataVo) {
return R.ok(formService.updateDataById(formDataVo));
}
@Override
public int updateDataById(FormDataVo formDataVo) {
return baseMapper.updateDataById(formDataVo.getTableName(), formDataVo.getPrimaryKey(),Long.valueOf(formDataVo.getId()),formDataVo.getUpdateMap());
}
int updateDataById(@Param("tableName") String tableName, @Param("primaryKey") String primaryKey,
@Param("id") Long id, @Param("updateMap") Map<String,Object> updateMap);
<update id="updateDataById">
UPDATE ${tableName} SET
<foreach collection="updateMap" item="val" index="key" separator=",">
${key} = #{val}
</foreach>
WHERE ${primaryKey} = #{id}
</update>
2、前端代碼如下:
/** 提交按鈕 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
this.buttonLoading = true;
console.log("submitForm this.form",this.form)
const id = this.form[this.primaryKey] || this.ids
const formData = {
tableName: this.tableName,
primaryKey: this.primaryKey,
id: id,
updateMap: this.form
}
console.log("submitForm formData",formData)
if (id != null) {
updateDataById(formData).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
}).finally(() => {
this.buttonLoading = false;
});
}
}
});
},
3、效果圖如下:
文章來源:http://www.zghlxwxcb.cn/news/detail-818554.html
文章來源地址http://www.zghlxwxcb.cn/news/detail-818554.html
到了這里,關于基于若依的ruoyi-nbcio流程管理系統(tǒng)一種簡單的動態(tài)表單模擬測試實現(xiàn)(四)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!