jeecgboot的大屏设计器开发——数据源设计三
之前主要是讲了数据源的录入与数据库测试功能,但保存这块没有说,今天主要讲保存这块。
因为通过online设计表单生成的代码已经有保存功能,所以主要功能不需要修改,只需要修改下面几个方面就可以。
一、保存按钮的修改
主要是增加了两个:
1、新的值包括用户可能编辑的数据重新赋值给model
const newList = {};
this.dataLink.forEach(item => {
newList[item.label] = item.value;
});
this.model.config = JSON.stringify(newList);
2、保存的时候进行检查,需要测试OK后才能保存
if (this.testReplyCode != "200") {
this.$message.error("测试结果为成功后方可保存!");
return;
}
3、具体完整代码如下:
-
submitForm () {
-
const that = this;
-
const newList = {};
-
this.dataLink.forEach(item => {
-
newList[item.label] = item.value;
-
});
-
this.model.config = JSON.stringify(newList);
-
// 触发表单验证
-
this.$refs.form.validate(valid => {
-
if (valid) {
-
if (this.testReplyCode != "200") {
-
this.$message.error("测试结果为成功后方可保存!");
-
return;
-
}
-
that.confirmLoading = true;
-
let httpurl = '';
-
let method = '';
-
if(!this.model.id){
-
httpurl =this.url.add;
-
method = 'post';
-
}else{
-
httpurl =this.url.edit;
-
method = 'put';
-
}
-
httpAction(httpurl,this.model,method).then((res)=>{
-
if(res.success){
-
that.$message.success(res.message);
-
that.$emit('ok');
-
}else{
-
that.$message.warning(res.message);
-
}
-
}).finally(() => {
-
that.confirmLoading = false;
-
})
-
}
-
-
})
-
},
二、编辑的时候处理
1、在edit增加一个初始化
if (record.id) {根据record.id判断新增还是编辑
this.editInit(this.model.type);
}
这里需要区分一下是新增还是编辑,两个不一样。
2、初始化读出的数据
要结合读出的数据与原来type类型的进行更新处理,再显示出来,完整代码如下:
-
edit (record) {
-
this.model = Object.assign({}, record);
-
if (record.id) {根据record.id判断新增还是编辑
-
this.editInit(this.model.type);
-
}
-
this.visible = true;
-
},
-
editInit(type) {
-
const that = this;
-
let url = this.url.queryByCode, method = 'get';
-
let params = {code: type};
-
getAction(url,params).then((res)=>{
-
if(res.success){
-
//that.$message.success(res.message);
-
console.log("onchange res=",res);
-
that.dataLink = JSON.parse(res.result.jsonValue);
-
console.log("onchange that.dataLink=",that.dataLink);
-
let newDataLink = [];
-
newDataLink = that.dataLink;
-
let sourceConfigJson = JSON.parse(that.model.config);
-
for (let i = 0; i < newDataLink.length; i ) {
-
newDataLink[i].value = sourceConfigJson[newDataLink[i].label];
-
}
-
this.dataLink = newDataLink;
-
}else{
-
that.$message.warning(res.message);
-
}
-
}).finally(() => {
-
that.confirmLoading = false;
-
})
-
},
三、效果图
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /boutique/detail/tanhghecga
系列文章
更多
同类精品
更多
-
photoshop保存的图片太大微信发不了怎么办
PHP中文网 06-15 -
《学习通》视频自动暂停处理方法
HelloWorld317 07-05 -
word里面弄一个表格后上面的标题会跑到下面怎么办
PHP中文网 06-20 -
Android 11 保存文件到外部存储,并分享文件
Luke 10-12 -
photoshop扩展功能面板显示灰色怎么办
PHP中文网 06-14 -
微信公众号没有声音提示怎么办
PHP中文网 03-31 -
excel下划线不显示怎么办
PHP中文网 06-23 -
excel打印预览压线压字怎么办
PHP中文网 06-22 -
TikTok加速器哪个好免费的TK加速器推荐
TK小达人 10-01 -
怎样阻止微信小程序自动打开
PHP中文网 06-13