1、使用Promise,重写red.getJSON /red.post, 解决"回调地狱"问题

2、修改 数据源管理/平台信息管理
This commit is contained in:
2019-04-04 17:47:29 +08:00
parent 3de47eea46
commit 696222fcf0
15 changed files with 283 additions and 38 deletions

View File

@@ -100,13 +100,14 @@
</row>
<script>
let {dbList, dbSave} = plat
var vm = new Vue({
el: ".plat",
data: {
cfg: {
title: "数据中心 管理",
cols: [
{col: "_id", label: "ID"},
{col: "name", label: "数据平台名称"},
{col: "url", label: "数据平台连接地址"},
{col: "user", label: "用户"},
@@ -150,7 +151,11 @@
},
methods: {
findList: function () {
var para = {
dbList().then(res => {
vm.list = res;
})
/*var para = {
doc:"db_plat",
shows: JSON.stringify(["_id", "name", "url", "user", "pwd", "catalogs", "remark", "status"])
};
@@ -159,7 +164,7 @@
json.rows[i]["pulse"] = "";
}
vm.list = json;
})
})*/
},
update: function (kv, row) {
red.post("/meta/save", {
@@ -178,14 +183,20 @@
$('#myModal').modal({moveable: true});
},
save: function (row) {
red.post("/meta/save", {
dbSave({plat: row}).then(() => {
red.showMsg({msg: "操作成功"})
$('#myModal').modal('hide')
vm.findList()
})
/* red.post("/meta/save", {
_id: row._id || "db_plat",
doc: JSON.stringify(row)
}, function (json) {
red.showMsg();
$('#myModal').modal('hide');
vm.findList();
});
}); */
},
loadCatalogs: function () {
vm.catalogs = [];
@@ -198,13 +209,13 @@
});
},
dbPulse: function (row) {
row["check"] = true;
/*row["check"] = true;
$.getJSON("/_db/pulse", {
dbPlatId: row._id
}, function (json) {
row["pulse"] = json.body;
row["check"] = false;
});
});*/
}
},
mounted: function () {

View File

@@ -76,13 +76,14 @@
</row>
<script>
let { platList, platSave } = plat;
var vm = new Vue({
el: ".plat",
data: {
cfg: {
title: "业务平台 管理",
cols: [
{col: "_id", label: "ID"},
{col: "name", label: "业务名称"},
{col: "token", label: "Token"},
{col: "remark", label: "说明"},
@@ -100,15 +101,9 @@
},
methods: {
findList: function () {
var para = {
doc:"sys_plat",
shows: JSON.stringify(["_id", "_key", "name", "token","remark", "status"]),
filter: JSON.stringify([{col:"status",type:"!=",value:-1}]),
};
red.getJSON("/meta/find", para, function (json) {
vm.list = json;
red.setData("sysPlats", json.rows);
findList () {
platList().then(res => {
vm.list = res
})
},
update: function (kv, row) {
@@ -127,14 +122,10 @@
$('#myModal').modal({moveable: true});
},
save: function (row) {
red.post("/meta/save", {
_id: row._id || "sys_plat",
doc: JSON.stringify(row)
}, function (json) {
red.showMsg();
$('#myModal').modal('hide');
vm.findList();
});
platSave({plat: row}).then(() => {
red.showMsg({msg: "操作成功"})
$('#myModal').modal('hide')
})
}
},
mounted: function () {