This commit is contained in:
2019-04-03 18:08:46 +08:00
parent 853ed30ffb
commit fbd7b0afdd
16 changed files with 337 additions and 94 deletions

View File

@@ -23,7 +23,7 @@
<span class="input-group-btn">
<button @click="findList" class="btn btn-primary" type="button"> 查询</button>
<button @click="findList()" class="btn btn-primary" type="button"> 查询</button>
</span>
<span class="input-group-btn" style="padding-left: 10px">
<button @click="exportExcel" class="btn" type="button"> 导出</button>
@@ -32,17 +32,17 @@
</div>
<div class="">
<div class="col-lg-4 col-md-6 col-xs-12" v-for="(x,index) in cfg.filters" v-if="x.checked">
<div class="col-lg-4 col-md-6 col-xs-12" v-for="(filter,index) in cfg.filters" v-if="filter.checked">
<div class="input-group item">
<span class="input-group-addon" style="width: 130px;">{{x.label}}</span>
<select class="form-control" :name="cfg.filters[index].name + '_cate'" style="width: 100px">
<option v-for="t in x.filterType" :value="t.name">{{t.remark}}</option>
<span class="input-group-addon" style="width: 130px;">{{filter.label}}</span>
<select class="form-control" v-model="filter['type']" style="width: 100px">
<option v-for="(t, index) in filter.filterType" :value="t.name" v-text="t.remark"></option>
</select>
<span class="input-group-addon fix-border fix-padding"></span>
<input type="text" class="form-control" v-model="para[cfg.filters[index].name]">
<input type="text" class="form-control" v-model="filter['value']">
<span class="input-group-addon fix-border fix-padding" style="padding: 5px" title="删除过滤条件">
<a href="javascript:;" @click="x.checked = false;"><i class="icon icon-trash"></i></a>
<a href="javascript:;" @click="filter.checked = false;"><i class="icon icon-trash"></i></a>
</span>
</div>
</div>
@@ -67,6 +67,9 @@
</tr>
</tbody>
</table>
<div>
<p v-text="list['rows'][0]"></p>
</div>
</div>
<div>
<ul class="pager pull-right" style="margin: 5px 10px">
@@ -92,6 +95,7 @@
</row>
<script>
let {getServiceList, getCfg, getDataList} = meta;
var vm = new Vue({
el:".data-list",
data: {
@@ -107,50 +111,46 @@
addFilter: "recompany",
para: {},
list: {rows:[], total:0},
list: {rows:[{listSql:"", countSql:""}], total:0},
limit: {pn: 1, ps: 10, total: 0},
order:{col:"id", desc:1}
},
watch: {
addFilter: function (v) {
vm.cfg.filters.forEach(function (f) {
addFilter(v) {
this.cfg.filters.forEach(function (f) {
if (f.name == v) {
f["checked"] = true;
vm.addFilter = "";
}
})
},
table: function () {
vm.loadCfg();
vm.limit = {pn: 1, ps: 10, total: 0};
vm.order = {col:"id", desc:1};
vm.findList();
service() {
this.loadCfg();
this.limit = {pn: 1, ps: 10, total: 0};
this.order = {col:"", desc:1};
this.findList();
},
list: function () {
var limit = vm.limit;
var list = vm.list;
var total = parseInt(list.total/limit.ps) + (list.total%limit.ps > 0 ? 1 : 0);
vm.limit["total"] = total;
list () {
let limit = this.limit;
let list = this.list;
let total = parseInt(list.total/limit.ps) + (list.total%limit.ps > 0 ? 1 : 0);
this.limit["total"] = total;
}
},
methods: {
findList: function () {
var filters = [];
for (i in vm.cfg.filters) {
var f = vm.cfg.filters[i]
if (f.checked && vm.para[f.name] != '') {
var d = {};
d["col"] = f.name;
d["value"] = vm.para[f.name];
d["type"] = $("select[name=" + f.name + "_cate]").val();
filters.push(d);
findList() {
// filters
let filters = [];
//filters.push({col: "status", value: 9, type: "NOTEQUAL"});
for (i in this.cfg.filters) {
let filter = this.cfg.filters[i];
if (filter.checked && filter['value']) {
let {name: col, value, type} = filter;
filters.push({col, value, type});
}
}
filters.push({col: "status", value: 9, type: "NOTEQUAL"});
var orders = [];
// orders
let orders = [];
//截取真实字段名,(考虑如果多表关联情况,是否需要加入真实字段名)
if (vm.order.col) {
var end = vm.order.col.indexOf("\|");
@@ -165,18 +165,20 @@
orders.push({col: col, desc: vm.order.desc});
}
var fbean = {
keyService: vm.table,
// fbean
let fbean = {
name: this.service,
filters: filters,
orders: orders,
limit: vm.limit
}
red.getJSON("/db/list",{fBean: JSON.stringify(fbean)}, function (json) {
json = json || {rows:[], total:0};
limit: vm.limit,
};
getDataList(fbean, json => {
vm.list = json;
})
});
},
exportExcel: function () {
exportExcel() {
var data = [];
for (k in vm.para) {
if (vm.para[k] != '') {
@@ -187,7 +189,7 @@
data.push(d);
}
}
data.push({col: "status", value: 9, type: "NOTEQUAL"});
//data.push({col: "status", value: 9, type: "NOTEQUAL"});
var fBean = {
keyService: vm.table,
@@ -198,18 +200,18 @@
location.href = "/export/data?fBean=" + JSON.stringify(fBean) + "&platToken=" + red.getPlatToken() + "&cate=csv";
return;
},
serviceList: function () {
red.getJSON("/meta/service_list",{}, function (json) {
serviceList() {
getServiceList(json => {
vm.services = json;
vm.service = vm.services[0].name;
vm.service = json[0].name;
});
},
loadCfg: function () {
red.getJSON("/meta/cfg", {key: this.service, platToken: red.getPlatToken()}, function (json) {
loadCfg() {
getCfg({name: this.service}, json => {
vm.cfg = json;
});
},
dealField: function (bean, field) {
dealField(bean, field) {
var str = "";
if (!bean || !field) {
@@ -247,7 +249,7 @@
return str;
},
sortEvent: function (col) {
sortEvent(col) {
if (vm.order.col == col) {
vm.order.desc = -vm.order.desc
} else {
@@ -257,7 +259,7 @@
vm.findList();
}
},
mounted: function () {
mounted() {
this.serviceList();
}
});