1、添加metaLink 管理
2、解决arangodb中删除 属性无效问题
This commit is contained in:
@@ -54,19 +54,22 @@
|
|||||||
<div class="col-xs-2 sheet-cell">
|
<div class="col-xs-2 sheet-cell">
|
||||||
<div style="padding-left: 10px;background-color: #ccc;width: 100%"> DB-Table</div>
|
<div style="padding-left: 10px;background-color: #ccc;width: 100%"> DB-Table</div>
|
||||||
<ul class="nav nav-tabs nav-stacked tlist" style="height: 100%">
|
<ul class="nav nav-tabs nav-stacked tlist" style="height: 100%">
|
||||||
<li class="clearfix" v-for="item in tables" >
|
<li class="['clearfix', {'active' == item.alias}]" v-for="item in tables" >
|
||||||
<a href="javascript:;" @click="aliasA=item.alias" data-target="#tab3Content1" data-toggle="tab" v-text="dealTableLabel(item)"></a>
|
<a href="javascript:;" @click="aliasA=item.alias" data-target="#tab3Content1" data-toggle="tab" v-text="dealTableLabel(item)"></a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<!--<p v-show="ckTable && ckTable.length">已选择 <code v-text="ckTable.length||0"></code> 个实体待导入</p>-->
|
<!--<p v-show="ckTable && ckTable.length">已选择 <code v-text="ckTable.length||0"></code> 个实体待导入</p>-->
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xs-8">
|
<div class="col-xs-8">
|
||||||
<button v-for="link in linkInfos" @click="aliasB=link.alias" :class="['btn', {'primary' :aliasB==link.alias}]" v-text="link.comment" style="margin-right: 5px"> </button>
|
|
||||||
|
<!-- 关联表列表 -->
|
||||||
|
<button v-for="link in linkInfos" @click="aliasB=link.alias" :class="['btn', {'btn-primary' :aliasB==link.alias}]" v-text="link.comment" style="margin-right: 5px"> </button>
|
||||||
|
|
||||||
<div class="pull-right">
|
<div class="pull-right">
|
||||||
<button @click="status=1" class="btn">修改关联关系</button>
|
<button @click="status=1" v-show="status==0" class="btn">修改关联关系</button>
|
||||||
<button class="btn">+ 添加关联表</button>
|
<button @click="status=0" v-show="status==1" class="btn">取消修改</button>
|
||||||
<button class="btn btn-primary" style="margin-right: 15px">保存</button>
|
<button @click="addLinkDia()" class="btn">+ 添加关联表</button>
|
||||||
|
<button @click="saveLink()" v-show="status==1" class="btn btn-primary" style="margin-right: 15px">保存</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
|
|
||||||
@@ -74,7 +77,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th v-text="tableInfo[aliasA] && tableInfo[aliasA]['comment']"></th>
|
<th v-text="tableInfo[aliasA] && tableInfo[aliasA]['comment']"></th>
|
||||||
<th v-text="tableInfo[aliasB] && tableInfo[aliasB]['comment']"></th>
|
<th v-text="tableInfo[aliasB] && tableInfo[aliasB]['comment']"></th>
|
||||||
<th>操作</th>
|
<th v-show="status==1">操作</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr v-show="status==0" v-for="(k, v) in linkInfo.link">
|
<tr v-show="status==0" v-for="(k, v) in linkInfo.link">
|
||||||
@@ -82,33 +85,53 @@
|
|||||||
<td v-text="v.startsWith(aliasB + '.') ? v : k"></td>
|
<td v-text="v.startsWith(aliasB + '.') ? v : k"></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr v-show="status==1" v-for="linkItem in link2">
|
<tr v-show="status==1" v-for="(linkItem, index) in link2">
|
||||||
<td>
|
<td>
|
||||||
<select class="form-control" v-model="linkItem.f1">
|
<select class="form-control" v-model="linkItem.f1">
|
||||||
<option></option>
|
<option></option>
|
||||||
<option v-for="item in tableInfoA.items"
|
<option v-for="item in tableInfoA.items"
|
||||||
:value="aliasA + '.' +item.name" v-text="item.name"></option>
|
:value="aliasA + '.' +item.name" v-text="aliasA + '.' +item.name + ' --- '+ item.label"></option>
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<select class="form-control" v-model="linkItem.f2">
|
<select class="form-control" v-model="linkItem.f2">
|
||||||
<option></option>
|
<option></option>
|
||||||
<option v-for="item in tableInfoB.items"
|
<option v-for="item in tableInfoB.items"
|
||||||
|
:value="aliasB + '.' +item.name" v-text="aliasB + '.' +item.name + ' --- '+ item.label">
|
||||||
:value="aliasB + '.' +item.name" v-text="aliasB + '.' +item.name">
|
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
<td style="text-align: center;">
|
<td style="text-align: center;">
|
||||||
<a href="javascript:;">删除</a>
|
<a @click="delLinkField(index)" href="javascript:;">删除</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr v-show="status==1">
|
||||||
<td colspan="3" style="text-align: center"> <a href="javascript:;">+添加更多</a> </td>
|
<td colspan="3" style="text-align: center"> <a @click="addLinkField()" href="javascript:;">+添加更多</a> </td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- 选择关联表 -->
|
||||||
|
<div class="modal fade" id="choseTable">
|
||||||
|
<div class="modal-dialog modal-sm">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">关闭</span></button>
|
||||||
|
<h4 class="modal-title">选择关联表</h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body" style="text-align: center">
|
||||||
|
<select class="form-control" v-model="newLinkTable">
|
||||||
|
<option v-for="x in tables" :value="x" v-text="x.name + ' --- ' + x.comment" :disabled="isDisable(x)"></option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<!--<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>-->
|
||||||
|
<button @click="addLink()" type="button" class="btn btn-primary" data-dismiss="modal">确定</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</row>
|
</row>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@@ -120,28 +143,31 @@
|
|||||||
* 4、点击点击关联后选择,关联表和关联字段 保持建立关联信息
|
* 4、点击点击关联后选择,关联表和关联字段 保持建立关联信息
|
||||||
* 5、已经建立的关联,点击编辑后,进入关联字段编辑状态
|
* 5、已经建立的关联,点击编辑后,进入关联字段编辑状态
|
||||||
*/
|
*/
|
||||||
let {tableLinkList,linkList, linkInfoList, tableInfo} = meta
|
let {tableLinkList,linkList, linkInfoList, tableInfo, linkSave} = meta
|
||||||
let vm = new Vue({
|
let vm = new Vue({
|
||||||
el: ".meta-link",
|
el: ".meta-link",
|
||||||
data: {
|
data: {
|
||||||
status: 1,
|
status: 0,
|
||||||
tables: [], //所有的表数据{name,comment, alias, linkCount}
|
tables: [], //所有的表数据{name,comment, alias, linkCount}
|
||||||
aliasA: '', //选中的主体表别名
|
aliasA: red.getData('aliasA', ''), //选中的主体表别名
|
||||||
tableInfo:{a:{}},
|
tableInfo:{items:{}},
|
||||||
|
|
||||||
links: [], //
|
links: [], //
|
||||||
linkInfos: [],
|
linkInfos: [],
|
||||||
linkInfo: {},
|
linkInfo: {},
|
||||||
link2: [],
|
link2: [],
|
||||||
|
newLinkTable: {},
|
||||||
|
|
||||||
aliasB: '',
|
aliasB: '',
|
||||||
|
|
||||||
tableInfoA: {},
|
tableInfoA: {items:[]},
|
||||||
tableInfoB: {},
|
tableInfoB: {items:[]},
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
aliasA(v) {
|
aliasA(v) {
|
||||||
tableInfo({alias: v}).then(res => this.tableInfoA = res)
|
red.setData('aliasA', v)
|
||||||
|
tableInfo({alias: v}).then(res => {
|
||||||
|
this.tableInfoA = res
|
||||||
linkList({alias: v}).then(res => {
|
linkList({alias: v}).then(res => {
|
||||||
this.links = res
|
this.links = res
|
||||||
this.aliasB = '' // 如果不置空,存在变更主体表,但数据不刷新的异常
|
this.aliasB = '' // 如果不置空,存在变更主体表,但数据不刷新的异常
|
||||||
@@ -152,8 +178,14 @@
|
|||||||
this.aliasB = res[0]['alias']
|
this.aliasB = res[0]['alias']
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
})
|
||||||
},
|
},
|
||||||
aliasB(v) {
|
aliasB(v) {
|
||||||
|
this.tableInfoB = {items:[]}
|
||||||
|
this.linkInfo = {}
|
||||||
|
this.link2 = []
|
||||||
|
|
||||||
|
if (!v) return
|
||||||
tableInfo({alias: v}).then(res => {
|
tableInfo({alias: v}).then(res => {
|
||||||
this.tableInfoB = res
|
this.tableInfoB = res
|
||||||
|
|
||||||
@@ -201,6 +233,76 @@
|
|||||||
dealTableLabel(table) {
|
dealTableLabel(table) {
|
||||||
return `${table.name} [${table.comment}] (${table.linkCount})`
|
return `${table.name} [${table.comment}] (${table.linkCount})`
|
||||||
},
|
},
|
||||||
|
addLinkDia() {
|
||||||
|
this.newLinkTable = ""
|
||||||
|
$('#choseTable').modal()
|
||||||
|
},
|
||||||
|
addLink() {
|
||||||
|
if (!this.newLinkTable) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置当前选中展示的关联表为新增表
|
||||||
|
this.aliasB = this.newLinkTable.alias
|
||||||
|
|
||||||
|
// 给关联表列表中添加 新加的表
|
||||||
|
let linkInfos = this.linkInfos || []
|
||||||
|
linkInfos.push(this.newLinkTable)
|
||||||
|
this.linkInfos = linkInfos
|
||||||
|
this.status = 1
|
||||||
|
|
||||||
|
//打开弹出层
|
||||||
|
//选择一个 未选中的表
|
||||||
|
//改变 alias 的值,构建linkInfo
|
||||||
|
// 添加关联(同修改)
|
||||||
|
// 保存(同修改)
|
||||||
|
},
|
||||||
|
addLinkField() {
|
||||||
|
let link2 = this.link2
|
||||||
|
link2.push({f1: "", f2: ""})
|
||||||
|
this.link2 = link2
|
||||||
|
},
|
||||||
|
delLinkField(index) {
|
||||||
|
let link2 = []
|
||||||
|
for (let i in this.link2) {
|
||||||
|
if (i != index) {
|
||||||
|
link2.push(this.link2[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.link2 = link2
|
||||||
|
},
|
||||||
|
saveLink() {
|
||||||
|
let link = {}
|
||||||
|
for(let i in this.link2) {
|
||||||
|
let item = this.link2[i]
|
||||||
|
if (item['f1'] && item['f2']) {
|
||||||
|
link[item['f1']] = item['f2']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (link.size == 0) {
|
||||||
|
red.showError("请填写完整的关联字段信息")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
let linkInfo = this.linkInfo
|
||||||
|
|
||||||
|
if (!linkInfo['tables']) {
|
||||||
|
linkInfo['tables'] = [this.aliasA, this.aliasB]
|
||||||
|
}
|
||||||
|
linkInfo["link"] = link
|
||||||
|
linkSave({link: linkInfo}).then(res => {
|
||||||
|
red.showOk()
|
||||||
|
})
|
||||||
|
},
|
||||||
|
isDisable(table) { // 是否不可选择的关联表
|
||||||
|
for (let i in this.linkInfos) {
|
||||||
|
if (this.linkInfos[i].alias == table.alias) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return table.alias == this.aliasA
|
||||||
|
},
|
||||||
showInfo() {
|
showInfo() {
|
||||||
$('#f-info').modal({moveable: true})
|
$('#f-info').modal({moveable: true})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ var red = {
|
|||||||
showOk(msg = '操作成功') {
|
showOk(msg = '操作成功') {
|
||||||
red.showMsg({msg})
|
red.showMsg({msg})
|
||||||
},
|
},
|
||||||
|
showError(msg = '操作失败 ') {
|
||||||
|
red.showMsg({type:"error", msg})
|
||||||
|
},
|
||||||
getData: function(key, defaultValue) {
|
getData: function(key, defaultValue) {
|
||||||
var v = localStorage.getItem(key) || defaultValue || "";
|
var v = localStorage.getItem(key) || defaultValue || "";
|
||||||
if (typeof(v) == "string" && v.startsWith("{") && v.endsWith("}")) {
|
if (typeof(v) == "string" && v.startsWith("{") && v.endsWith("}")) {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ public class MetaLink extends Doc<MetaLink> {
|
|||||||
public static MetaLink dao = Doc.dao(MetaLink.class);
|
public static MetaLink dao = Doc.dao(MetaLink.class);
|
||||||
|
|
||||||
private String[] tables;
|
private String[] tables;
|
||||||
private Map link;
|
private Map<String, String> link;
|
||||||
|
|
||||||
//-------------------------------------------
|
//-------------------------------------------
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ public class MetaLink extends Doc<MetaLink> {
|
|||||||
return link;
|
return link;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLink(Map link) {
|
public void setLink(Map<String, String> link) {
|
||||||
this.link = link;
|
this.link = link;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import org.redkale.net.http.RestService;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@@ -279,6 +280,7 @@ public class MetadataService extends BaseService { //arango
|
|||||||
@RestMapping(name = "link_save", comment = "实体关系列表")
|
@RestMapping(name = "link_save", comment = "实体关系列表")
|
||||||
public JBean linkSave(MetaLink link, @RestParam(name = "platToken") String token) {
|
public JBean linkSave(MetaLink link, @RestParam(name = "platToken") String token) {
|
||||||
if (link.getKey() != null) {
|
if (link.getKey() != null) {
|
||||||
|
link.find(String.format("UPDATE '%s' WITH { link:null } IN MetaLink", link.getKey()), Map.class); //避免删除属性无效
|
||||||
link.update();
|
link.update();
|
||||||
} else {
|
} else {
|
||||||
link.save();
|
link.save();
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
#sql("xx")
|
#sql("xx")
|
||||||
select * from user
|
select * from user
|
||||||
#end
|
#end
|
||||||
|
#sql("link.update")
|
||||||
|
UPDATE "#(key)" WITH { link:null } IN Characters
|
||||||
|
#end
|
||||||
|
|||||||
@@ -173,12 +173,12 @@ public class RunTest<T> {
|
|||||||
System.out.println(kv);
|
System.out.println(kv);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
//@Test
|
||||||
public void tplTest() {
|
public void tplTest() {
|
||||||
TplKit use = TplKit.use(true);
|
TplKit use = TplKit.use(true);
|
||||||
//use.addTpl(new File(FileKit.rootPath(), "tpl")); ok
|
//use.addTpl(new File(FileKit.rootPath(), "tpl")); ok
|
||||||
//use.addTpl("/tpl/aql/db.sql"); //ok
|
//use.addTpl("/tpl/aql/db.sql"); //ok
|
||||||
use.addTpl("tpl\\aql\\db.sql"); //ok
|
use.addTpl("tpl\\sql\\db.sql"); //ok
|
||||||
String tpl = use.getTpl("db.table_list", Kv.of("catalogs", asList("redbbs")));
|
String tpl = use.getTpl("db.table_list", Kv.of("catalogs", asList("redbbs")));
|
||||||
System.out.println(tpl);
|
System.out.println(tpl);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user