This commit is contained in:
2019-03-07 10:24:29 +08:00
parent 6c8c683c31
commit e057d613b9
215 changed files with 70917 additions and 118 deletions

24
root/qtask/abc.html Normal file
View File

@@ -0,0 +1,24 @@
<div id="abc">
{{cfg.title}}
<button @click="abc">asf</button>
<button @click="abc">openDia</button>
</div>
<script>
var vm = new Vue({
el: "#abc",
data: {
cfg: {
title: "12"
}
},
methods: {
abc: function () {
console.log("abc");
}
}
});
</script>

143
root/qtask/ddl.html Normal file
View File

@@ -0,0 +1,143 @@
<row class="ddl">
<div class="col-md-6">
<h3>导出数据库表结构(导出后使用wps打开)</h3>
<form>
<div class="input-group">
<span class="input-group-btn">
<button class="btn btn-default" type="button">jdbc.url</button>
</span>
<input id="url" type="text" class="form-control" placeholder="jdbc:mysql://127.0.0.1:3306" v-model="jdbc.url">
</div>
<div class="input-group">
<span class="input-group-btn">
<button class="btn btn-default" type="button">jdbc.user</button>
</span>
<input id="user" type="text" class="form-control" placeholder="请输入数据库用户" v-model="jdbc.user">
</div>
<div class="input-group">
<span class="input-group-btn">
<button class="btn btn-default" type="button">jdbc.pwd</button>
</span>
<input id="pwd" type="text" class="form-control" placeholder="请输入数据库密码" v-model="jdbc.pwd">
</div>
<div class="input-group">
<span class="input-group-btn">
<button class="btn btn-default" type="button">Database</button>
</span>
<input id="database" type="text" class="form-control" placeholder="请输入Database" v-model="jdbc.database">
</div>
<div class="input-group">
<div class="radio">
<label>
<input type="radio" v-model="cate" value="word" checked> 导出表结构到word
</label>
</div>
<div class="radio">
<label>
<input type="radio" v-model="cate" value="excel"> 导出表结构到excel
</label>
</div>
</div>
<button id="export" data-toggle="button" class="btn btn-primary" data-cate="word" type="button">导出表结构</button>
</form>
</div>
<div class="col-md-6" v-show="logs.total">
<h3>最近使用记录 <small>共 {{logs.total}} 条记录</small></h3>
<table class="table-bordered" style="width: 100%">
<thead>
<tr>
<th>IP</th>
<th>最后时间</th>
<th>最后导出数据类型</th>
<th>导出总次数</th>
</tr>
</thead>
<tbody>
<tr v-for="row in logs.rows">
<td v-text="row.remoteAddr"></td>
<td v-text="timeFmt(new Date(row.time*1), 'yyyy-MM-dd HH:mm:ss')"></td>
<td v-text="row.cate"></td>
<td v-text="row.total"></td>
</tr>
<tr style="background-color: #eee">
<td>合计总人数</td>
<td>{{logs.userTotal}}</td>
<td>合计总次数</td>
<td>{{logs.total}}</td>
</tr>
</tbody>
</table>
</div>
</row>
<script>
function getData(key, defaultValue) {
var v = localStorage.getItem(key) || defaultValue || "";
if (typeof(v) == "string" && v.startsWith("{") && v.endsWith("}")) {
v = JSON.parse(v);
} else if (typeof(v) == "string" && v.startsWith("[") && v.endsWith("]")) {
v = JSON.parse(v);
}
return v;
}
var vm = new Vue({
el:".ddl",
data:{
jdbc:getData("jdbc", {url: "jdbc:mysql://192.168.202.11:3306/", user: "root"}),
cate: getData("cate", "word"),
logs: {}
},
watch: {
},
methods: {
loadLog: function() {
$.getJSON("/ddl/logrank",function (json) {
vm.logs = json;
});
},
timeFmt: function (date,fmt){
var o = {
"M+" : date.getMonth()+1, //月份
"d+" : date.getDate(), //日
"H+" : date.getHours(), //小时
"m+" : date.getMinutes(), //分
"s+" : date.getSeconds(), //秒
"q+" : Math.floor((date.getMonth()+3)/3), //季度
"S" : date.getMilliseconds() //毫秒
};
if(/(y+)/.test(fmt))
fmt=fmt.replace(RegExp.$1, (date.getFullYear()+"").substr(4 - RegExp.$1.length));
for(var k in o)
if(new RegExp("("+ k +")").test(fmt))
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));
return fmt;
}
},
mounted: function () {
this.loadLog();
}
});
$("#export").click(function () {
localStorage.setItem("jdbc", JSON.stringify(vm.jdbc));
localStorage.setItem("cate", vm.cate);
$.post("/"+ vm.cate +"/build", {account:JSON.stringify(vm.jdbc)}, function (json) {
console.log(json)
if (json.code == 0) {
location.href = "/"+ vm.cate +"/download";
} else {
alert(json.message);
}
});
});
</script>

131
root/qtask/debug.html Normal file
View File

@@ -0,0 +1,131 @@
<row class="qtask-debug">
<div class="col-md-12">
<h3>QTask - [测试用例]</h3>
</div>
<div class="col-md-6">
<div class="input-group">
<span class="input-group-btn">
<a href="javascript:;" class="btn" type="button"> 选择QTask任务</a>
</span>
<select class="form-control" v-model="row">
<option v-for="item in qtasks" :value="item" v-text="item.name"></option>
</select>
</div>
<div class="modal-body">
<form class="form-horizontal">
<div class="form-group">
<label class="col-sm-2">查询ID</label>
<div class="col-md-6 col-sm-10" v-text="row.queryId" style="padding-top: 5px"></div>
</div>
<div class="form-group">
<label class="col-sm-2">业务名称</label>
<div class="col-md-6 col-sm-10" v-text="row.name" style="padding-top: 5px"></div>
</div>
<div class="form-group">
<label class="col-sm-2">说明</label>
<div class="col-md-6 col-sm-10" v-text="row.remark" style="padding-top: 5px"></div>
</div>
<div class="form-group" style="margin-bottom: 0">
<label for="sql" class="col-md-2">SQL</label>
<div class="col-md-10">
<textarea v-model="row.sql" class="form-control layui-code" rows="10" id="sql" placeholder="请输入 SQL (支持jfinal-enjoy模板语法)" > </textarea>
</div>
</div>
<div class="form-group">
<label for="para" class="col-sm-2">查询参数</label>
<div class="col-md-6 col-sm-10">
<input v-model="row.para" class="form-control" id="para" placeholder="请输入 默认查询参数格式: {k:v}">
</div>
</div>
<div class="form-group">
<label for="para" class="col-sm-2">数据平台</label>
<div class="col-md-6">
<select v-model="row.platId" class="form-control">
<option></option>
<option v-for="item in dbPlats" :value="item.key" v-text="item.name"></option>
</select>
</div>
<div class="col-md-4">
<select v-model="row.catalog" class="form-control">
<option></option>
<option v-for="item in catalogs()" :value="item" v-text="item"></option>
</select>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button @click="query(row)" type="button" class="btn btn-primary">RUN</button>
</div>
</div>
<div class="col-md-6">
<h5>查询结果:</h5>
<pre class="layui-code" v-show="result" v-text="result"></pre>
</div>
</row>
<script src="http://www.1216.top/res/layui/layui.js"></script>
<script>
var vm = new Vue({
el: ".qtask-debug",
data: {
qtasks: [],
row: {},
list: {rows:[], total: 0},
dbPlats: [],
result: ""
},
watch: {
qtask: function () {
console.log(this.qtask)
},
"row.key": function () {
//vm.query();
}
},
methods: {
catalogs: function () {
var dbPlats = this.dbPlats;
for (i in dbPlats) {
if (dbPlats[i].key == this.row.platId) {
return dbPlats[i]["catalogs"]
}
}
},
query: function () {
vm.result = "";
red.post("/qtask/test", {qtask: JSON.stringify(vm.row)}, function (json) {
vm.result = json;
red.showMsg({msg: "查询成功"});
});
}
},
mounted: function () {
//qtask 列表初始化
var para = {
pn:1,
ps:120,
doc:"qtask",
clazz:"net.tccn.common.qtask.Qtask",
filter: JSON.stringify([{col:"status",type:"==",value:1},{col:"sysPlatId",type:"==",value:red.getPlatId()}])
};
red.getJSON("/meta/find", para, function (json) {
vm.qtasks = json.rows;
vm.row = vm.qtasks[0];
});
//dbPlats 列表初始化
red.dbPlats(function (json) {
vm.dbPlats = json;
});
setTimeout(function () {
layui.use('code', function(){ //加载code模块
layui.code({title:"",about: false, height: "500"}); //引用code方法
});
}, 200)
}
});
</script>

237
root/qtask/list.html Normal file
View File

@@ -0,0 +1,237 @@
<row class="qtask-list">
<div class="col-md-12">
<h3 v-text="cfg.title"></h3>
</div>
<div class="col-md-12 ">
<!--<div class="col-md-2" style="padding-left: 0">
<div class="input-group">
<span class="input-group-btn">
<button class="btn btn-default" type="button">选择业务平台</button>
</span>
<select class="form-control">
<option>sdfa</option>
<option>sadf</option>
</select>
</div>
</div>-->
<div class="input-group pull-right">
<button @click="openDia({})" class="btn btn-primary" type="button"> 添加QTask</button>
<!--<button @click="openDia({})" class="btn btn-primary" type="button" style="margin-left: 5px"> 添加QTask</button>-->
</div>
</div>
<div class="col-md-12" style="padding-top: 10px;overflow:auto;">
<table class="table table-bordered table-hover" style="width: 100%">
<thead>
<tr>
<th v-for="field in cfg.cols" v-text="field.label"></th>
<th>状态</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<tr v-for="row in list.rows">
<td v-for="field in cfg.cols" v-title="row[field.col]" v-text="row[field.col]"></td>
<td v-text="dealStatus(row.status)"></td>
<td>
<a @click="openDia(row)" href="javascript:;">编辑</a>|
<a @click="row['status']=1;qsave(row);" v-show="row.status != 1" href="javascript:;">启用</a>
<a @click="row['status']=0;qsave(row);" v-show="row.status == 1" href="javascript:;">不启用</a> |
<a @click="row['status']=-1;comfirmDel(row);" href="javascript:;">删除</a>
</td>
</tr>
</tbody>
</table>
</div>
<!-- modal-tpl -->
<div class="col-md-12">
<!-- 对话框触发按钮 -->
<!-- 对话框HTML -->
<div class="modal fade" id="myModal">
<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">QTask - [编辑]</h4>
</div>
<div class="modal-body">
<form class="form-horizontal">
<div class="form-group">
<label for="queryId" class="col-sm-2">查询ID</label>
<div class="col-md-6 col-sm-10">
<input v-model="row.queryId" :readonly="row.key" class="form-control" id="queryId" placeholder="请输入queryId">
</div>
</div>
<div class="form-group">
<label for="name" class="col-sm-2">业务名称</label>
<div class="col-md-6 col-sm-10">
<input v-model="row.name" class="form-control" id="name" placeholder="请输入 业务名称">
</div>
</div>
<div class="form-group">
<label for="para" class="col-sm-2">任务类型</label>
<div class="col-md-6">
<select v-model="row.cate" class="form-control">
<option v-for="item in cfg.cates" :value="item" v-text="item"></option>
</select>
</div>
</div>
<div class="form-group">
<label for="name" class="col-sm-2">说明</label>
<div class="col-md-6 col-sm-10">
<input v-model="row.remark" class="form-control" id="remark" placeholder="请输入 说明">
</div>
</div>
<div class="form-group" style="margin-bottom: 0">
<label for="sql" class="col-md-2">SQL</label>
<div class="col-md-10">
<textarea v-model="row.sql" class="form-control layui-code" rows="10" id="sql" placeholder="请输入 SQL (支持jfinal-enjoy模板语法)" > </textarea>
</div>
</div>
<div class="form-group">
<label for="para" class="col-sm-2">默认查询参数</label>
<div class="col-sm-10">
<input v-model="row.para" class="form-control" id="para" placeholder="请输入 默认查询参数格式: {k:v}">
</div>
</div>
<div class="form-group">
<label for="para" class="col-sm-2">数据平台</label>
<div class="col-md-6">
<select v-model="row.platId" class="form-control">
<option></option>
<option v-for="item in dbPlats" :value="item.key" v-text="item.name"></option>
</select>
</div>
<div class="col-md-4">
<select v-model="row.catalog" class="form-control">
<option></option>
<option v-for="item in catalogs()" :value="item" v-text="item"></option>
</select>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
<button @click="qsave(row)" type="button" class="btn btn-primary">确定</button>
</div>
</div>
</div>
</div>
<!-- 小对话框 -->
<!--<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#mySmModal">小对话框</button>-->
<div class="modal fade" id="mySmModal">
<div class="modal-dialog modal-sm">
<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-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
<button @click="qsave(row);$('#mySmModal').modal('hide');" type="button" class="btn btn-primary">确定</button>
</div>
</div>
</div>
</div>
</row>
<script src="http://www.1216.top/res/layui/layui.js"></script>
<script>
var vm = new Vue({
el: ".qtask-list",
data: {
sysPlat: red.getData("sysPlat"),
cfg: {
title: "QTask 管理",
cols: [
{col: "queryId", label: "查询id",},
{col: "name", label: "业务名称",},
{col: "remark", label: "说明"}
],
filters: [],
cates: ["find","update"]
},
list: {rows:[], total: 0},
row: {},
dbPlats: [],
sysPlats: [{name: "工控系统"}]
},
watch: {
},
methods: {
loadList: function () {
var para = {
pn:1,
ps:120,
doc:"qtask",
clazz:"net.tccn.common.qtask.Qtask",
filter: JSON.stringify([{col:"status",type:"!=",value:-1},{col:"sysPlatId",type:"==",value:this.sysPlat._key}])
};
red.getJSON("/meta/find", para, function (json) {
vm.list = json;
});
},
openDia: function (row) {
vm.row = row;
$('#myModal').modal({moveable: true});
if (this.dbPlats.length == 0) {
var para = {
doc:"db_plat",
clazz:"net.tccn.common.qtask.DbPlat",
};
red.getJSON("/meta/find", para, function (json) {
vm.dbPlats = json.rows;
});
}
},
qsave: function (row) {
row = row || vm.row;
if (!row["sysPlatId"]) {//设置平台id
row["sysPlatId"] = red.getPlatId();
}
red.post("/qtask/qsave", {qtask: JSON.stringify(row)}, function (json) {
vm.row = {};
$('#myModal').modal('hide');
vm.loadList();
red.showMsg();
});
},
dealStatus: function (n) {
var arr = {"0":"未启用", "1":"启用", "-1":"删除",}
return arr[n+""] || "";
},
comfirmDel: function (row) {
vm.row = row;
$('#mySmModal').modal({});
},
abc: function () {
$(".container-fixed").load("abc.html");
},
catalogs: function () {
var dbPlats = this.dbPlats;
for (i in dbPlats) {
if (dbPlats[i].key == this.row.platId) {
return dbPlats[i]["catalogs"]
}
}
}
},
mounted: function () {
this.loadList();
setTimeout(function () {
layui.use('code', function(){ //加载code模块
layui.code(/*{skin: 'notepad'}*/); //引用code方法
});
}, 500)
}
});
</script>