This commit is contained in:
lxy
2020-05-10 23:18:59 +08:00
parent 707e9ee680
commit 68eea7b27d
42 changed files with 5969 additions and 361 deletions

View File

@@ -27,7 +27,7 @@
<div style="padding-left: 10px;background-color: #ccc;width: 100%"> 业务列表(Meta-Service)</div>
<ul class="nav nav-tabs nav-stacked tlist" style="height: 100%">
<li :class="['clearfix',{'active':service==item.alias}]" v-for="item in services" >
<a @click="service=item.name" :title="`${item.name}`" v-text="`${item.name} [${item.comment}]`" href="javascript:;"></a>
<a @click="service=item.name" :title="`${item.name}`" v-text="`${item.comment}`" href="javascript:;"></a>
</li>
</ul>
</div>
@@ -55,9 +55,9 @@
<!-- 过滤条件 -->
<div class="col-lg-4 col-md-6" v-for="(filter,index) in cfg.filters" v-if="filter.checked">
<div class="input-group item">
<span class="input-group-addon" style="width: 130px;">{{filter.label}}</span>
<select class="form-control" v-model="filter['type']" style="width: 100px">
<div class="input-group item" style="padding-top: 3px">
<span class="input-group-addon" style="max-width: 130px;">{{filter.label}}</span>
<select class="form-control" v-model="filter['type']" style="width: 95px;">
<option v-for="(t, i) in filter.filterType" :value="t.name" v-text="t.remark"></option>
</select>
<span class="input-group-addon fix-border fix-padding"></span>
@@ -236,7 +236,7 @@
let {getServiceList, getCfg, getDataList, exportData, dataDel, dataSave} = meta
let {showOk} = red
var vm = new Vue({
let vm = new Vue({
el:".data-list",
data: {
cfg: {
@@ -252,7 +252,7 @@
addFilter: "",
para: {},
list: {rows: [], total: 0},
limit: {pn: 1, ps: 10, total: 0},
limit: {pn: 1, ps: 20, total: 0},
order: {col: "id", desc: 1},
pk: "",
detailData: {}
@@ -268,7 +268,7 @@
},
service() {
this.loadCfg();
this.limit = {pn: 1, ps: 10, total: 0};
this.limit = {pn: 1, ps: 20, total: 0};
this.order = {col:"", desc:1};
this.findList();
},
@@ -301,7 +301,7 @@
},
loadCfg() {
getCfg({name: this.service}).then(res => {
res['type'] = res.filters[0]['name']
// res['type'] = res.filters[0]['name']
for (i in res["filters"]) {
res["filters"][i]['type'] = res["filters"][i]['filterType'][0]['name']
@@ -311,59 +311,28 @@
},
dealFieldFmt(bean, colFmt) { //处理字典数据 及 自定义函数处理数据
let v = ""
let v = bean[colFmt["col"]]
if (colFmt.inType == "DICT") {
// 取字典值返回
v = bean[colFmt["col"]]
}
else if (colFmt.inType == "INPUT_DAY") {
v = bean[colFmt["col"]]
}
else if (colFmt.inType == "INPUT_TIME") {
v = bean[colFmt["col"]]
// 时间戳格式化
return red.timeFmt(new Date(v))
}
else if (colFmt.inType == "INPUT_FUNC") {
v = bean[colFmt["col"]]
}
else if (colFmt.inType == "FILE" && v) {
return '<a href="{0}" target="_blank">查看</a>'.format(v)
}
else {
v = bean[colFmt["col"]]
}
if (colFmt.inType && colFmt.inType != "INPUT") {
v += " -> "+colFmt.inType
}
return v
/*if (colFmt["fmt"]) {
let fmt = colFmt["fmt"]
let cate = ""
if (fmt.indexOf("|") > 0) {
cate = fmt.split("|")[0]
fmt = fmt.split("|")[1]
}
if (cate == "Dict") {
//console.log(`Dict:${fmt}-${bean[colFmt["col"]]}`)
}
else {
//console.log(`func:${fmt}-${bean[colFmt["col"]]}`)
let evl = `${fmt}(${JSON.stringify(bean)},'${bean[colFmt["col"]]}')`
//console.log("evl", evl)
return (new Function("","return "+ evl))()
}
return bean[colFmt["col"]];
} else {
//console.log(`k-v:${colFmt["col"]}-${bean[colFmt["col"]]}`)
return bean[colFmt["col"]]
}*/
},
dealField(bean, field) {
let str = "";
@@ -438,12 +407,12 @@
let orders = [];
//截取真实字段名,(考虑如果多表关联情况,是否需要加入真实字段名)
if (vm.order.col) {
var end = vm.order.col.indexOf("\|");
let end = vm.order.col.indexOf("\|");
if (end < 0) {
end = vm.order.col.indexOf("=")
}
var col = vm.order.col;
let col = vm.order.col;
if (end > 0) {
col = vm.order.col.substring(0, end);
}
@@ -497,4 +466,4 @@
this.serviceList();
}
});
</script>
</script>

View File

@@ -527,7 +527,7 @@
EQUAL:"等于", NOTEQUAL:"不等于", IN: "包含", NOTIN:"不包含", LIKE: "模糊查询", RANGE: "范围"
},
findTypes: ["INPUT", "DICT", "CHECKBOX", "RADIO", "DAY", "TIME"],
inTypes: ["INPUT", "DICT", "INPUT_DAY", "INPUT_TIME", "FUNC", "QTASK", "HIDDEN"],
inTypes: ["INPUT", "DICT", "INPUT_DAY", "INPUT_TIME", "FUNC", "QTASK", "HIDDEN", "FILE"],
ckTypes: [{label:"必填", name: "NOTNULL"},{label:"IP", name: "IP"},{label:"IPv4", name: "IPv4"},{label:"电话号码", name: "phone"}],
dataTypes: ["bigint(20)", "varchar(255)", "varchar(64)", "varchar(32)", "varchar(16)", "int(11)", "int(3)", "int(2)", "datetime"],
filterCate: ["EQUAL", "NOTEQUAL", "LIKE", "IN"],
@@ -1102,4 +1102,4 @@
}
});
</script>
</script>

View File

@@ -60,45 +60,50 @@
</ul>
</div>
<!-- 实体表信息 -->
<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">
<td v-show="status==3 || status==4 || status==5 || status==6"><input type="checkbox"></td>
<th v-show="status==1"></th>
<th>字段名</th>
<th>中文</th>
<th>数据类型</th>
<!--
<th>输入类型</th>
<th>附加属性</th>
-->
<th>主键</th>
</tr>
<tr v-for="(item, index) in meta.items" class="item">
<td v-show="status==1" class="icon icon-move"></td>
<td v-show="status!=2" v-text="item.name" style="background-color: rgb(235, 235, 228);"></td>
<td v-show="status!=2" v-text="item.label"></td>
<td v-show="status!=2" v-text="item.type"></td>
<!--
<td v-show="status!=2" v-text="item.inType"></td>
<td v-show="status!=2" v-text="item.inExt"></td>
-->
<td v-show="status!=2">
<i v-if="item.pk" class="icon icon-check"></i>
</td>
<div class="col-md-10">
<!-- 实体属性列表 -->
<div class="panel" 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">
<td v-show="status==3 || status==4 || status==5 || status==6"><input type="checkbox"></td>
<th v-show="status==1"></th>
<th>字段</th>
<th>中文名</th>
<th>数据类型</th>
<!--
<th>输入类型</th>
<th>附加属性</th>
-->
<th>非空</th>
<th>主键</th>
</tr>
<tr v-for="(item, index) in meta.items" class="item">
<td v-show="status==1" class="icon icon-move"></td>
<td v-show="status!=2" v-text="item.name" style="background-color: rgb(235, 235, 228);"></td>
<td v-show="status!=2" v-text="item.label"></td>
<td v-show="status!=2" v-text="item.type"></td>
<!--
<td v-show="status!=2" v-text="item.inType"></td>
<td v-show="status!=2" v-text="item.inExt"></td>
-->
<td v-show="status!=2">
<i v-if="item.notNull" class="icon icon-check"></i>
</td>
<td v-show="status!=2">
<i v-if="item.pk" class="icon icon-check"></i>
</td>
<td v-show="status==2">
<input type="hidden" name="item" :value="JSON.stringify(item)">
<input v-model="item" type="hidden">
<input :value="item.name" disabled class="form-control">
<input v-model="item.name" type="hidden">
<input name="name" type="hidden" :value="item.name">
</td>
<td v-show="status==2"><input v-model="item.label" class="form-control"></td>
<td v-show="status==2"><input v-model="item.type" class="form-control"></td>
<!--
<td v-show="status==2">
<input type="hidden" name="item" :value="JSON.stringify(item)">
<input v-model="item" type="hidden">
<input :value="item.name" disabled class="form-control">
<input v-model="item.name" type="hidden">
<input name="name" type="hidden" :value="item.name">
</td>
<td v-show="status==2"><input v-model="item.label" class="form-control"></td>
<td v-show="status==2"><input v-model="item.type" class="form-control"></td>
<!--
<td v-show="status==2">
<select v-model="item.inType" class="form-control" style="width: 130px">
<option></option>
@@ -107,16 +112,19 @@
</td>
<td v-show="status==2"><input v-model="item.inExt" class="form-control"></td>
-->
<td v-show="status==2" style="text-align: center">
<label>
<input v-model="item.pk" type="checkbox">
</label>
</td>
</tr>
</table>
</div>
<div class="col-md-10">
<td v-show="status==2" style="text-align: center">
<label>
<input v-model="item.notNull" type="checkbox">
</label>
</td>
<td v-show="status==2" style="text-align: center">
<label>
<input v-model="item.pk" type="checkbox">
</label>
</td>
</tr>
</table>
</div>
<!-- baseInfo -->
<div class="panel" v-show="status==7 ">
@@ -166,6 +174,12 @@
<p style="padding: 5px">整理中,【实体关系】放到此处维护</p>
</div>
<textarea class="form-control layui-code" v-model="upsql" rows="10" id="content" placeholder="/* 没有提交要执行的查询 */" />
</div>
<div class="col-md-10">
</div>
</row>
@@ -175,10 +189,10 @@
let {showOk} = red
let {dbList} = plat
var vm = new Vue({
let vm = new Vue({
el: ".meta-list",
data: {
inTypes: ["INPUT", "SELECT_EXT", "INPUT_DT", "FMT_FUN"],
inTypes: ["INPUT", "SELECT_EXT", "INPUT_DT", "FMT_FUN", "FILE"],
dataTypes: ["bigint(20)", "varchar(255)", "varchar(64)", "varchar(32)", "varchar(16)", "int(11)", "int(3)", "int(2)", "datetime"],
filterCate: ["EQUAL", "NOTEQUAL", "LIKE", "IN"],
tables: [],//所有的业务类型,【测试用】
@@ -199,6 +213,8 @@
dbPlats:[],
row: {key: "", platId: "", dbPlatId:"", catalog: "", name:"", comment:"", alias: ""},
filter: {db: "", catalog: "", name: ""},//tableList 过滤条件
upsql: "", // 需要执行的 sql语句
},
watch: {
metaTable(v) {
@@ -207,6 +223,7 @@
},
status: function (v) {
this.setMove(v)
this.upsql = ''
},
alias: function () {
this.loadDetail();
@@ -217,7 +234,7 @@
let itemOv = this.oldItems || [];
if (itemOv.length == 0) return;
let attr = ["label", "name", "pk", "type", "inType","inExt"];
let attr = ["label", "name", "pk", "type", "inType","inExt", 'notNull'];
let itemEdit = [];
a:for (let i = 0; i < itemOv.length; i++) {
for (let j = 0; j < attr.length; j++) {
@@ -243,6 +260,33 @@
//vm.table = v[0]["name"];
}
},
// 基础信息变更 sql
row: {
handler: function (row) {
//console.log(vm.metaTable.name, " -> ",v.name)
vm.upsql = ''
if (vm.metaTable.name != row.name) {
vm.upsql += 'RENAME TABLE `{0}`.`{1}` TO `{2}`.`{3}`;\n'.format(vm.metaTable.catalog, vm.metaTable.name, vm.metaTable.catalog, row.name)
}
if (vm.metaTable.comment != row.comment) {
vm.upsql += 'ALTER TABLE `{0}`.`{1}` COMMENT=\'{2}\';\n'.format(vm.metaTable.catalog, vm.metaTable.name, row.comment)
}
},
deep: true
},
// 属性表更 sql
itemEdit: {
handler: function (items) {
// vm.upsql = 'ALTER TABLE `{0}`.`{1}'.format()
/*`
CHANGE `rankcate` `rankcate` VARCHAR(64) CHARSET utf8 COLLATE utf8_general_ci DEFAULT '' NOT NULL COMMENT '[排行类型]',
CHANGE `remark` `remark1` VARCHAR(128) CHARSET utf8 COLLATE utf8_general_ci DEFAULT '' NOT NULL COMMENT '[说明]';*/
},
deep: true
},
meta: function (v) {
this.row = {key:v.key, dbPlatId: v.dbPlatId, catalog: v.catalog, name:v.name, comment:v.comment, alias: v.alias};
let oldItems = v['items'] || []
@@ -253,6 +297,7 @@
methods: {
loadDetail() {
tableInfo({alias: this.alias}).then(res => {
this.metaTable = res
let row = res;
vm.meta = row;
let oldItems = [];
@@ -422,14 +467,22 @@
},
showInfo() {
$('#f-info').modal({moveable: true})
}
},
buildSql() {
}
},
mounted: function (){
dbList().then(res => {
this.dbPlats = res.rows;
})
this.tableList();
/*setTimeout(function () {
layui.use('code', function(){ //加载code模块
layui.code({title:"",about: false, height: "500"}); //引用code方法
});
}, 300)*/
}
});
</script>