forked from zaaksam/dproxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
476 additions
and
420 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
"sourceMap": true | ||
}, | ||
"include": [ | ||
"./types/**/*", | ||
"./ts/**/*", | ||
"./vue/**/*" | ||
], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,93 +1,130 @@ | ||
<template> | ||
<div> | ||
<Row> | ||
<Col span="24"> | ||
<MyPage :total="table.list.total" :pageIndex="table.list.pageIndex" :pageSize="table.list.pageSize" @onLoad="onLoad"></MyPage> | ||
</Col> | ||
<Row type="flex" style="margin-top: 10px; margin-bottom:15px"> | ||
类型: | ||
<Select v-model="query.type" style="width: 120px"> | ||
<Option value="All"></Option> | ||
<Option value="Info"></Option> | ||
<Option value="Debug"></Option> | ||
<Option value="Error"></Option> | ||
<Option value="Warning"></Option> | ||
<Option value="Critical"></Option> | ||
</Select> | ||
指定时间: | ||
<Date-picker type="datetime" placement="bottom" placeholder="删除指定时间之前数据" style="width: 170px" @on-change="onDatetimeChange"></Date-picker> | ||
内容: | ||
<Input v-model="query.content" placeholder="模糊关键字" style="width: 160px"></Input> | ||
| ||
<Button type="primary" @click="onDel">删除指定</Button> | ||
</Row> | ||
<p> </p> | ||
<Table stripe border :columns="table.columns" :data="table.list.items"> | ||
<Table stripe border :columns="tableColumns" :data="tableData.items"> | ||
</Table> | ||
<MyPage :total="tableData.total" :pageIndex="tableData.pageIndex" :pageSize="tableData.pageSize" @onChange="onLoad"></MyPage> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import Vue from 'vue' | ||
import VueRouter from 'vue-router' | ||
import { Component } from 'vue-property-decorator' | ||
import { Vue, Component } from 'vue-property-decorator' | ||
import _ from 'lodash' | ||
import moment from 'moment' | ||
import Axios, { AxiosResponse, AxiosError } from 'axios' | ||
import MyPage from './page.vue' | ||
import API from '../ts/api' | ||
interface listModel extends BaseListModel { | ||
items: LogModel[] | ||
} | ||
interface tableModel { | ||
columns: any[] | ||
list: listModel | ||
} | ||
@Component({ | ||
components: { | ||
MyPage | ||
} | ||
}) | ||
export default class MyLog extends Vue { | ||
table: tableModel = { | ||
list: { | ||
total: 0, | ||
pageIndex: 1, | ||
pageSize: 10, | ||
pageCount: 0, | ||
items: <LogModel[]>[], | ||
query: Model.Log = { | ||
type: 'All', | ||
content: '', | ||
created: 0 | ||
} | ||
tableData: APIListModel<Model.Log> = { | ||
pageIndex: 1, | ||
pageSize: 10, | ||
pageCount: 0, | ||
total: 0, | ||
items: [] | ||
} | ||
tableColumns: any[] = <any>[ | ||
{ | ||
title: '类型', | ||
key: 'type' | ||
}, | ||
{ | ||
title: '内容', | ||
key: 'content' | ||
}, | ||
columns: <any[]>[ | ||
{ | ||
title: '类型', | ||
key: 'type' | ||
}, | ||
{ | ||
title: '内容', | ||
key: 'content' | ||
}, | ||
{ | ||
title: '记录时间', | ||
key: 'created', | ||
render: (h: Vue.CreateElement, params: any): Vue.VNode => { | ||
return h('span', moment.unix(params.row.created).format('YYYY-MM-DD HH:mm:ss')) | ||
} | ||
{ | ||
title: '记录时间', | ||
key: 'created', | ||
render: (h: Vue.CreateElement, params: any) => { | ||
return h('span', moment.unix(params.row.created).format('YYYY-MM-DD HH:mm:ss')) | ||
} | ||
] | ||
} | ||
} | ||
] | ||
mounted() { | ||
this.onLoad() | ||
} | ||
onLoad() { | ||
async onLoad() { | ||
let pi = _.parseInt(this.$route.query.pi) | ||
let ps = _.parseInt(this.$route.query.ps) | ||
if (_.isNaN(pi)) { | ||
pi = this.table.list.pageIndex | ||
pi = this.tableData.pageIndex | ||
} | ||
if (_.isNaN(ps)) { | ||
ps = this.table.list.pageSize | ||
ps = this.tableData.pageSize | ||
} | ||
let pms = new URLSearchParams() | ||
pms.set('pageIndex', pi.toString()) | ||
pms.set('pageSize', ps.toString()) | ||
let result = await API.get<Model.Logs>('/log/list/?' + pms.toString()) | ||
if (result.code === 10000) { | ||
this.tableData = result.data!.list | ||
} else { | ||
this.$Message.error({ duration: 5, content: result.msg + '(' + result.code.toString() + ')' }) | ||
} | ||
} | ||
async onDel() { | ||
if (this.query.created <= 0) { | ||
this.$Message.error({ duration: 5, content: '指定时间必须选择' }) | ||
return | ||
} | ||
let pms = new URLSearchParams() | ||
pms.set('created', this.query.created.toString()) | ||
if (this.query.type != 'All') { | ||
pms.set('type', this.query.type) | ||
} | ||
if (this.query.content != '') { | ||
pms.set('content', this.query.content) | ||
} | ||
Axios.get(API.initURL('/api/log/list'), { params: { pageIndex: pi, pageSize: ps } }) | ||
.then((res: AxiosResponse) => { | ||
this.table.list = <listModel>res.data.data.list | ||
let result = await API.delete<any>('/log/?' + pms.toString()) | ||
if (result.code === 10000) { | ||
this.onLoad() | ||
} else { | ||
this.$Message.error({ duration: 5, content: result.msg + '(' + result.code.toString() + ')' }) | ||
} | ||
} | ||
if (res.data.code === 90000) { | ||
this.$Message.error({ duration: 5, content: res.data.msg + '(' + res.data.code.toString() + ')' }) | ||
} | ||
}) | ||
.catch((err: AxiosError) => { | ||
this.$Message.error({ duration: 5, content: err.message + '(' + err.code + ')' }) | ||
}) | ||
onDatetimeChange(expiredStr: string) { | ||
let unix = moment(expiredStr, 'YYYY-MM-DD HH:mm:ss').unix() | ||
if (_.isNaN(unix)) { | ||
this.query.created = 0 | ||
} else { | ||
this.query.created = unix | ||
} | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.