'新增业务添加'

This commit is contained in:
2019-04-18 18:33:58 +08:00
parent feba7cdc7b
commit 423e0854fd
6 changed files with 137 additions and 22 deletions

View File

@@ -7,6 +7,9 @@ const meta = {
red.getJSON("/meta/tableinfo",{name}, json => callback(json));
},*/
serviceSave({service}) {
return red.postX('/meta/service_save', {service: JSON.stringify(service)})
},
getServiceList(callback) {
red.getJSON("/meta/service_list",{}, json => {
json = red.replacePoint(json);

View File

@@ -50,30 +50,29 @@
</div>
</div>
<div class="clearfix" style="padding-top: 5px"></div>
<div class="clearfix"></div>
<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%"> 实体表(Meta-Table)</div>
<ul class="nav nav-tabs nav-stacked tlist" style="height: 100%">
<li class="['clearfix', {'active' == item.alias}]" v-for="item in tables" >
<li :class="['clearfix', {'active': aliasA == 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>
</li>
</ul>
<!--<p v-show="ckTable && ckTable.length">已选择 <code v-text="ckTable.length||0"></code> 个实体待导入</p>-->
</div>
<div class="col-xs-8">
<div class="col-xs-10">
<div style="padding-left: 10px;background-color: #ccc;width: 100%"> 关联关系管理 </div>
<!-- 关联表列表 -->
<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>
<button v-for="link in linkInfos" @click="aliasB=link.alias" :class="['btn', {'btn-primary' :aliasB==link.alias}]" v-text="link.comment" style="margin: 5px"> </button>
<div class="pull-right">
<button @click="status=1" v-show="status==0" class="btn">修改关联关系</button>
<div class="pull-right" style="margin: 5px;">
<button @click="status=1" v-show="status==0 && aliasB" class="btn">修改关联关系</button>
<button @click="status=0" v-show="status==1" class="btn">取消修改</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 class="clearfix"></div>
<table class="table-bordered" style="width: 100%; margin-top: 10px">
<table class="table-bordered" style="width: 100%;">
<tr>
<th v-text="tableInfo[aliasA] && tableInfo[aliasA]['comment']"></th>
<th v-text="tableInfo[aliasB] && tableInfo[aliasB]['comment']"></th>
@@ -110,6 +109,11 @@
</tr>
</table>
<div v-show="!linkInfos || linkInfos.length == 0" style="text-align: center">
<img src="../res/img/none.png">
<p>暂无关联表</p>
</div>
</div>
<!-- 选择关联表 -->
@@ -149,7 +153,7 @@
data: {
status: 0,
tables: [], //所有的表数据{name,comment, alias, linkCount}
aliasA: red.getData('aliasA', ''), //选中的主体表别名
aliasA: '', //选中的主体表别名
tableInfo:{items:{}},
links: [], //
@@ -165,12 +169,15 @@
},
watch: {
aliasA(v) {
red.setData('aliasA', v)
//red.setData('aliasA', v)
this.links = []
this.linkInfoA = {}
this.aliasB = '' // 如果不置空,存在变更主体表,但数据不刷新的异常
tableInfo({alias: v}).then(res => {
this.tableInfoA = res
linkList({alias: v}).then(res => {
this.links = res
this.aliasB = '' // 如果不置空,存在变更主体表,但数据不刷新的异常
})
linkInfoList({alias: v}).then(res => {
this.linkInfos = res

View File

@@ -68,7 +68,7 @@
</select>
<span class="input-group-btn pull-left" style="padding-left: 20px">
<button @click="tipShow('开发中')" :class="['btn']" type="button"> 新建业务</button>
<button @click="createService()" :class="['btn']" type="button"> 新建业务</button>
</span>
@@ -260,12 +260,54 @@
<div class="clearfix"></div>
<!-- 新建业务 -->
<div class="modal fade" id="createServiceDia">
<div class="modal-dialog">
<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">
<form class="form-horizontal">
<div class="form-group">
<label class="col-sm-3">选择业务主表</label>
<div class="col-sm-6">
<select class="form-control" v-model="createRow.table">
<option v-for="x in tables" :value="x.alias" v-text="x.name + ' --- ' + x.comment"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3">业务名称</label>
<div class="col-sm-6">
<input v-model="createRow.comment" class="form-control" placeholder="请输入 业务名称">
</div>
</div>
<div class="form-group">
<label class="col-sm-3">业务标识码</label>
<div class="col-sm-6">
<input v-model="createRow.name" class="form-control" placeholder="请输入 业务标识码,如:user_service">
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
<button @click="saveService()" type="button" class="btn btn-primary">确定</button>
</div>
</div>
</div>
</div>
</row>
<script>
//import { login } from '../api/user.js'
//import { getServiceInfo, getServiceDetail, getServiceList } from '/api/meta.js'
let { getServiceInfo, getServiceDetail, getServiceList } = meta;
let { getServiceInfo, getServiceDetail, getServiceList, tableLinkList, serviceSave } = meta;
let { showOk } = red
var vm = new Vue({
@@ -309,13 +351,16 @@
table: "",//表别名
filterArr:[],
filterMap:{},
createRow: {},
tables: [],
},
watch: {
status: function (v) {
this.setMove(v)
},
services: function (v) {
if(v.length > 0) {
if(v.length > 0 && !vm.service) {
vm.service = v[0]["name"];
}
},
@@ -555,8 +600,25 @@
red.showMsg();
}
},
tipShow() {
red.showMsg({msg: '开发中'})
createService() {
this.createRow = {}
if (this.tables.length == 0) {
tableLinkList().then(res => {
this.tables = res
})
}
$('#createServiceDia').modal()
},
saveService() {
serviceSave({service: this.createRow}).then(res => {
red.showOk("创建成功, 请对业务进行配置")
$('#createServiceDia').modal('hide')
this.service = this.createRow.name
getServiceList(json => {
vm.services = json;
})
})
},
showInfo() {
$('#f-info').modal({moveable: true})

View File

@@ -54,7 +54,7 @@
</div>
<!-- 实体表信息 -->
<div class="col-md-5">
<div class="col-md-10" v-show="status!=7 && status!=8">
<div style="padding-left: 10px;background-color: #ccc;width: 100%"> 实体字段信息</div>
<table :class="[{'table':status!=2},'table-bordered']" style="width: 100%">
<tr style="background-color: #f1f1f1">
@@ -96,10 +96,10 @@
</table>
</div>
<div class="col-md-5">
<div class="col-md-10">
<!-- baseInfo -->
<div class="panel" v-show="status==7">
<div class="panel" v-show="status==7 ">
<div style="padding-left: 10px;background-color: #ccc;width: 100%"> 基本属性配置</div>
<!--<div class="panel-heading">基本属性配置</div>-->
<div class="panel-body" style="overflow:auto;">
@@ -140,6 +140,12 @@
</form>
</div>
</div>
<div class="panel" v-show="status==8">
<div style="padding-left: 10px;background-color: #ccc;width: 100%"> 实体关系</div>
<p style="padding: 5px">整理中,【实体关系】放到此处维护</p>
</div>
</div>
</row>
@@ -159,7 +165,7 @@
items: [],
},//完整的元数据数据,
move: false,
status: 7, //页面默认状态
status: 0, //页面默认状态
table: "", //页面选择的table表名称
alias: "", //页面选择的table表别名
metaTable: {},

BIN
root/res/img/none.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -126,6 +126,43 @@ public class MetadataService extends BaseService { //arango
return jBean.setBody(metaTable);
}
@RestMapping(name = "service_save", comment = "service信息保存")
public JBean serviceSave(@RestParam(name = "platToken") String token, @RestParam(name = "service") String serviceBean) {
JBean jBean = new JBean();
MetaService service = gson.fromJson(serviceBean, MetaService.class);
do {
// 标识码非空校验
if (isEmpty.test(service.getTable())) {
jBean.set(-1, "请选择业务主表");
break;
}
// 标识码非空校验
if (isEmpty.test(service.getName())) {
jBean.set(-1, "业务标识码无效");
break;
}
// 标识码重复校验
MetaService metaService = MetaKit.getMetaService(service.getName());
if (metaService != null && !metaService.getKey().equals(service.getKey())) {
jBean.set(-1, "业务标识码被占用,修改业务标识码重试");
break;
}
if (service.getKey() != null) {
service.update();
} else {
service.save();
}
MetaKit.reload(MetaService.class);
} while (false);
return jBean;
}
@RestMapping(name = "service_info", comment = "service基本信息")
public JBean serviceInfo(@RestParam(name = "platToken") String token, String name) {
MetaService metaService = MetaKit.getMetaService(name);