mirror of
https://github.com/jumpserver/lina.git
synced 2026-01-13 19:35:24 +00:00
perf: 优化 datepicker 时间
This commit is contained in:
@@ -40,16 +40,17 @@ import LeftSide from './LeftSide'
|
||||
import RightSide from './RightSide'
|
||||
import AutoDataSearch from '@/components/AutoDataSearch'
|
||||
import DatetimeRangePicker from '@/components/FormFields/DatetimeRangePicker'
|
||||
import { getDaysAgo, getDaysFuture } from '@/utils/common'
|
||||
|
||||
const defaultTrue = { type: Boolean, default: true }
|
||||
const defaultFalse = { type: Boolean, default: false }
|
||||
export default {
|
||||
name: 'TableAction',
|
||||
components: {
|
||||
AutoDataSearch,
|
||||
LeftSide,
|
||||
DatetimeRangePicker,
|
||||
RightSide
|
||||
RightSide,
|
||||
AutoDataSearch,
|
||||
DatetimeRangePicker
|
||||
},
|
||||
props: {
|
||||
hasLeftActions: defaultTrue,
|
||||
@@ -58,7 +59,10 @@ export default {
|
||||
hasDatePicker: defaultFalse,
|
||||
datePicker: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
default: () => ({
|
||||
dateStart: getDaysAgo(7).toISOString(),
|
||||
dateEnd: getDaysFuture(1).toISOString()
|
||||
})
|
||||
},
|
||||
searchConfig: {
|
||||
type: Object,
|
||||
|
||||
@@ -29,6 +29,7 @@ import IBox from '../IBox'
|
||||
import TableAction from './TableAction'
|
||||
import Emitter from '@/mixins/emitter'
|
||||
import AutoDataTable from '../AutoDataTable'
|
||||
import { getDayEnd, getDaysAgo } from '@/utils/common'
|
||||
|
||||
export default {
|
||||
name: 'ListTable',
|
||||
@@ -51,10 +52,21 @@ export default {
|
||||
}
|
||||
},
|
||||
data() {
|
||||
let extraQuery = {}
|
||||
if (this.headerActions.hasDatePicker) {
|
||||
extraQuery = {
|
||||
start_time: getDaysAgo(7).toISOString(),
|
||||
end_time: getDayEnd().toISOString()
|
||||
}
|
||||
this.headerActions.datePicker = Object.assign({
|
||||
dateStart: extraQuery.start_time,
|
||||
dateEnd: extraQuery.end_time
|
||||
}, this.headerActions.datePicker)
|
||||
}
|
||||
return {
|
||||
selectedRows: [],
|
||||
init: false,
|
||||
extraQuery: {}
|
||||
extraQuery: extraQuery
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
||||
@@ -977,7 +977,7 @@
|
||||
},
|
||||
"perms": {
|
||||
"": "",
|
||||
"AccountsHelp": "所有账号: 资产上添加的账号; 指定账号:指定账号的用户名;手动输入: 用户名/密码 手动输入; 同名账号: 和账号使用者用户名相同的账号;",
|
||||
"AccountsHelp": "所有账号: 资产上添加的账号; 指定账号:指定账号的用户名;手动输入: 用户名/密码 手动输入; 同名账号: 与被授权人用户名相同的账号;",
|
||||
"AllAccounts": "所有账号",
|
||||
"ManualInput": "手动输入",
|
||||
"SameAccount": "同名账号",
|
||||
|
||||
@@ -186,7 +186,7 @@ export function getDayEnd(now) {
|
||||
if (!now) {
|
||||
now = new Date()
|
||||
}
|
||||
const zoneTime = moment(now).utc().endOf('month').format('YYYY-MM-DD HH:mm:ss')
|
||||
const zoneTime = moment(now).utc().endOf('day').format('YYYY-MM-DD HH:mm:ss')
|
||||
return moment(zoneTime).utc().toDate()
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
<script type="text/jsx">
|
||||
import GenericListPage from '@/layout/components/GenericListPage'
|
||||
import { getDaysAgo, getDaysFuture } from '@/utils/common'
|
||||
import { ActionsFormatter } from '@/components/TableFormatters'
|
||||
import { openTaskPage } from '@/utils/jms'
|
||||
|
||||
@@ -15,9 +14,6 @@ export default {
|
||||
GenericListPage
|
||||
},
|
||||
data() {
|
||||
const now = new Date()
|
||||
const dateFrom = getDaysAgo(7, now).toISOString()
|
||||
const dateTo = getDaysFuture(1, now).toISOString()
|
||||
return {
|
||||
tableConfig: {
|
||||
url: '/api/v1/audits/job-logs/',
|
||||
@@ -95,10 +91,6 @@ export default {
|
||||
date_start: {
|
||||
width: '160px'
|
||||
}
|
||||
},
|
||||
extraQuery: {
|
||||
date_to: dateTo,
|
||||
date_from: dateFrom
|
||||
}
|
||||
},
|
||||
headerActions: {
|
||||
@@ -120,10 +112,6 @@ export default {
|
||||
value: 'run_as__username'
|
||||
}
|
||||
]
|
||||
},
|
||||
datePicker: {
|
||||
dateStart: dateFrom,
|
||||
dateEnd: dateTo
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,16 +4,12 @@
|
||||
|
||||
<script>
|
||||
import GenericListPage from '@/layout/components/GenericListPage'
|
||||
import { getDaysAgo, getDaysFuture } from '@/utils/common'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
GenericListPage
|
||||
},
|
||||
data() {
|
||||
const now = new Date()
|
||||
const dateFrom = getDaysAgo(7, now).toISOString()
|
||||
const dateTo = getDaysFuture(1, now).toISOString()
|
||||
return {
|
||||
tableConfig: {
|
||||
permissions: {
|
||||
@@ -51,20 +47,12 @@ export default {
|
||||
datetime: {
|
||||
width: '160px'
|
||||
}
|
||||
},
|
||||
extraQuery: {
|
||||
date_to: dateTo,
|
||||
date_from: dateFrom
|
||||
}
|
||||
},
|
||||
headerActions: {
|
||||
hasLeftActions: false,
|
||||
hasImport: false,
|
||||
hasDatePicker: true,
|
||||
datePicker: {
|
||||
dateStart: dateFrom,
|
||||
dateEnd: dateTo
|
||||
},
|
||||
searchConfig: {
|
||||
getUrlQuery: true
|
||||
}
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
<template>
|
||||
<GenericListPage :header-actions="headerActions" :table-config="tableConfig" />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import GenericListPage from '@/layout/components/GenericListPage'
|
||||
import { getDaysAgo, getDaysFuture } from '@/utils/common'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
GenericListPage
|
||||
},
|
||||
data() {
|
||||
const now = new Date()
|
||||
const dateFrom = getDaysAgo(7, now).toISOString()
|
||||
const dateTo = getDaysFuture(1, now).toISOString()
|
||||
return {
|
||||
tableConfig: {
|
||||
permissions: {
|
||||
app: 'audits',
|
||||
resource: 'userloginlog'
|
||||
},
|
||||
columnsExclude: ['backend'],
|
||||
columnsShow: {
|
||||
min: ['username', 'type'],
|
||||
default: [
|
||||
'username', 'type', 'backend_display', 'ip', 'city',
|
||||
'user_agent', 'mfa', 'reason_display', 'status', 'datetime'
|
||||
]
|
||||
},
|
||||
url: '/api/v1/audits/login-logs/',
|
||||
columnsMeta: {
|
||||
user_agent: {
|
||||
width: '150px'
|
||||
},
|
||||
actions: {
|
||||
has: false
|
||||
},
|
||||
ip: {
|
||||
width: '140px'
|
||||
},
|
||||
city: {
|
||||
width: '90px'
|
||||
},
|
||||
mfa: {
|
||||
width: '80px'
|
||||
},
|
||||
type: {
|
||||
width: '110px'
|
||||
},
|
||||
datetime: {
|
||||
width: '160px'
|
||||
}
|
||||
},
|
||||
extraQuery: {
|
||||
date_to: dateTo,
|
||||
date_from: dateFrom
|
||||
}
|
||||
},
|
||||
headerActions: {
|
||||
hasLeftActions: false,
|
||||
hasImport: false,
|
||||
hasDatePicker: true,
|
||||
datePicker: {
|
||||
dateStart: dateFrom,
|
||||
dateEnd: dateTo
|
||||
},
|
||||
searchConfig: {
|
||||
getUrlQuery: true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
<script>
|
||||
import GenericListPage from '@/layout/components/GenericListPage'
|
||||
import { getDaysAgo, getDaysFuture } from '@/utils/common'
|
||||
import { ActionsFormatter } from '@/components/TableFormatters'
|
||||
import DiffDetail from '@/components/Dialog/DiffDetail'
|
||||
|
||||
@@ -22,9 +21,6 @@ export default {
|
||||
},
|
||||
data() {
|
||||
const vm = this
|
||||
const now = new Date()
|
||||
const dateFrom = getDaysAgo(7, now).toISOString()
|
||||
const dateTo = getDaysFuture(1, now).toISOString()
|
||||
return {
|
||||
url: '/api/v1/audits/operate-logs/',
|
||||
rowObj: {
|
||||
@@ -83,20 +79,12 @@ export default {
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
extraQuery: {
|
||||
date_to: dateTo,
|
||||
date_from: dateFrom
|
||||
}
|
||||
},
|
||||
headerActions: {
|
||||
hasLeftActions: false,
|
||||
hasImport: false,
|
||||
hasDatePicker: true,
|
||||
datePicker: {
|
||||
dateStart: dateFrom,
|
||||
dateEnd: dateTo
|
||||
}
|
||||
hasDatePicker: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,16 +4,12 @@
|
||||
|
||||
<script>
|
||||
import GenericListPage from '@/layout/components/GenericListPage'
|
||||
import { getDaysAgo, getDaysFuture } from '@/utils/common'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
GenericListPage
|
||||
},
|
||||
data() {
|
||||
const now = new Date()
|
||||
const dateFrom = getDaysAgo(7, now).toISOString()
|
||||
const dateTo = getDaysFuture(1, now).toISOString()
|
||||
return {
|
||||
tableConfig: {
|
||||
url: '/api/v1/audits/password-change-logs/',
|
||||
@@ -31,20 +27,12 @@ export default {
|
||||
actions: {
|
||||
has: false
|
||||
}
|
||||
},
|
||||
extraQuery: {
|
||||
date_to: dateTo,
|
||||
date_from: dateFrom
|
||||
}
|
||||
},
|
||||
headerActions: {
|
||||
hasLeftActions: false,
|
||||
hasImport: false,
|
||||
hasDatePicker: true,
|
||||
datePicker: {
|
||||
dateStart: dateFrom,
|
||||
dateEnd: dateTo
|
||||
}
|
||||
hasDatePicker: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
<script>
|
||||
import GenericTreeListPage from '@/layout/components/GenericTreeListPage/index'
|
||||
import { getDaysAgo, getDaysFuture, toSafeLocalDateStr } from '@/utils/common'
|
||||
import { getDayEnd, getDaysAgo, toSafeLocalDateStr } from '@/utils/common'
|
||||
import { OutputExpandFormatter } from './formatters'
|
||||
import { DetailFormatter } from '@/components/TableFormatters'
|
||||
import isFalsey from '@/components/DataTable/compenents/el-data-table/utils/is-falsey'
|
||||
@@ -29,13 +29,12 @@ export default {
|
||||
},
|
||||
data() {
|
||||
const vm = this
|
||||
const now = new Date()
|
||||
const dateFrom = getDaysAgo(7, now).toISOString()
|
||||
const dateTo = getDaysFuture(1, now).toISOString()
|
||||
const dateFrom = getDaysAgo(7).toISOString()
|
||||
const dateTo = getDayEnd().toISOString()
|
||||
return {
|
||||
query: {
|
||||
date_from: getDaysAgo(7, now).toISOString(),
|
||||
date_to: getDaysFuture(1, now).toISOString()
|
||||
date_from: dateFrom,
|
||||
date_to: dateTo
|
||||
},
|
||||
loading: true,
|
||||
tableConfig: {
|
||||
@@ -116,6 +115,10 @@ export default {
|
||||
hasImport: false,
|
||||
hasExport: this.$hasPerm('terminal.view_command'),
|
||||
hasDatePicker: true,
|
||||
datePicker: {
|
||||
dateStart: dateFrom,
|
||||
dateEnd: dateTo
|
||||
},
|
||||
canExportSelected: true,
|
||||
exportOptions: {
|
||||
// Todo: 优化这里,和抽象组件重复了
|
||||
@@ -143,10 +146,6 @@ export default {
|
||||
a.click()
|
||||
window.URL.revokeObjectURL(url + queryStr)
|
||||
}
|
||||
},
|
||||
datePicker: {
|
||||
dateStart: dateFrom,
|
||||
dateEnd: dateTo
|
||||
}
|
||||
},
|
||||
treeSetting: {
|
||||
|
||||
@@ -4,16 +4,12 @@
|
||||
|
||||
<script>
|
||||
import GenericListPage from '@/layout/components/GenericListPage'
|
||||
import { getDaysAgo, getDaysFuture } from '@/utils/common'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
GenericListPage
|
||||
},
|
||||
data() {
|
||||
const now = new Date()
|
||||
const dateFrom = getDaysAgo(7, now).toISOString()
|
||||
const dateTo = getDaysFuture(1, now).toISOString()
|
||||
return {
|
||||
tableConfig: {
|
||||
url: '/api/v1/audits/ftp-logs/',
|
||||
@@ -30,20 +26,12 @@ export default {
|
||||
actions: {
|
||||
has: false
|
||||
}
|
||||
},
|
||||
extraQuery: {
|
||||
date_to: dateTo,
|
||||
date_from: dateFrom
|
||||
}
|
||||
},
|
||||
headerActions: {
|
||||
hasLeftActions: false,
|
||||
hasImport: false,
|
||||
hasDatePicker: true,
|
||||
datePicker: {
|
||||
dateStart: dateFrom,
|
||||
dateEnd: dateTo
|
||||
}
|
||||
hasDatePicker: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
<template>
|
||||
<ListTable :table-config="tableConfig" :header-actions="headerActions" />
|
||||
<ListTable :header-actions="headerActions" :table-config="tableConfig" />
|
||||
</template>
|
||||
|
||||
<script type="text/jsx">
|
||||
import ListTable from '@/components/ListTable'
|
||||
import { timeOffset, getDaysAgo, getDaysFuture } from '@/utils/common'
|
||||
import { timeOffset } from '@/utils/common'
|
||||
import { ActionsFormatter } from '@/components/TableFormatters'
|
||||
|
||||
export default {
|
||||
name: 'BaseList',
|
||||
components: {
|
||||
@@ -22,9 +23,6 @@ export default {
|
||||
}
|
||||
},
|
||||
data() {
|
||||
const now = new Date()
|
||||
const dateFrom = getDaysAgo(7, now).toISOString()
|
||||
const dateTo = getDaysFuture(1, now).toISOString()
|
||||
return {
|
||||
tableConfig: {
|
||||
url: this.url,
|
||||
@@ -124,20 +122,12 @@ export default {
|
||||
extraActions: this.extraActions
|
||||
}
|
||||
}
|
||||
},
|
||||
extraQuery: {
|
||||
date_to: dateTo,
|
||||
date_from: dateFrom
|
||||
}
|
||||
},
|
||||
headerActions: {
|
||||
hasLeftActions: false,
|
||||
hasImport: false,
|
||||
hasDatePicker: true,
|
||||
datePicker: {
|
||||
dateEnd: dateTo,
|
||||
dateStart: dateFrom
|
||||
},
|
||||
searchConfig: {
|
||||
getUrlQuery: false,
|
||||
exclude: ['is_finished']
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<Dialog
|
||||
:title="$tc('common.OfflineUpload')"
|
||||
v-bind="$attrs"
|
||||
@cancel="onCancel"
|
||||
@confirm="onSubmit"
|
||||
v-on="$listeners"
|
||||
>
|
||||
@@ -13,15 +14,15 @@
|
||||
>
|
||||
<el-upload
|
||||
ref="upload"
|
||||
drag
|
||||
action="string"
|
||||
list-type="text/csv"
|
||||
:limit="1"
|
||||
:auto-upload="false"
|
||||
upload-files="uploadFiles"
|
||||
:on-change="onFileChange"
|
||||
:before-upload="beforeUpload"
|
||||
:limit="1"
|
||||
:on-change="onFileChange"
|
||||
accept=".zip"
|
||||
action="string"
|
||||
drag
|
||||
list-type="text/csv"
|
||||
upload-files="uploadFiles"
|
||||
>
|
||||
<i class="el-icon-upload" />
|
||||
<div class="el-upload__text">
|
||||
@@ -41,6 +42,7 @@
|
||||
|
||||
<script>
|
||||
import { Dialog } from '@/components'
|
||||
|
||||
export default {
|
||||
name: 'UploadDialog',
|
||||
components: {
|
||||
@@ -62,6 +64,9 @@ export default {
|
||||
},
|
||||
beforeUpload(file) {
|
||||
},
|
||||
onCancel() {
|
||||
this.$emit('update:visible', false)
|
||||
},
|
||||
onSubmit() {
|
||||
if (!this.file) {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user