Browse Source

[Refactor][UI] Refactor time display use datatable render function (#11078)

3.1.0-release
Devosend 2 years ago committed by GitHub
parent
commit
594f00512b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      dolphinscheduler-ui/src/views/security/token-manage/components/token-modal.tsx
  2. 10
      dolphinscheduler-ui/src/views/security/token-manage/index.tsx
  3. 30
      dolphinscheduler-ui/src/views/security/token-manage/use-table.ts

10
dolphinscheduler-ui/src/views/security/token-manage/components/token-modal.tsx

@ -15,7 +15,13 @@
* limitations under the License. * limitations under the License.
*/ */
import { defineComponent, getCurrentInstance, PropType, toRefs, watch } from 'vue' import {
defineComponent,
getCurrentInstance,
PropType,
toRefs,
watch
} from 'vue'
import Modal from '@/components/modal' import Modal from '@/components/modal'
import { import {
NForm, NForm,
@ -192,7 +198,7 @@ const TokenModal = defineComponent({
<NFormItem label={t('security.token.token')} path='token'> <NFormItem label={t('security.token.token')} path='token'>
<NSpace> <NSpace>
<NInput <NInput
allowInput={this.trim} allowInput={this.trim}
class='input-token' class='input-token'
style={{ width: '504px' }} style={{ width: '504px' }}
disabled disabled

10
dolphinscheduler-ui/src/views/security/token-manage/index.tsx

@ -15,7 +15,13 @@
* limitations under the License. * limitations under the License.
*/ */
import { defineComponent, getCurrentInstance, onMounted, toRefs, watch } from 'vue' import {
defineComponent,
getCurrentInstance,
onMounted,
toRefs,
watch
} from 'vue'
import { import {
NButton, NButton,
NDataTable, NDataTable,
@ -117,7 +123,7 @@ const tokenManage = defineComponent({
</NButton> </NButton>
<NSpace> <NSpace>
<NInput <NInput
allowInput={this.trim} allowInput={this.trim}
size='small' size='small'
clearable clearable
v-model={[this.searchVal, 'value']} v-model={[this.searchVal, 'value']}

30
dolphinscheduler-ui/src/views/security/token-manage/use-table.ts

@ -17,12 +17,11 @@
import { useAsyncState } from '@vueuse/core' import { useAsyncState } from '@vueuse/core'
import { reactive, h, ref } from 'vue' import { reactive, h, ref } from 'vue'
import { format } from 'date-fns'
import { NButton, NIcon, NPopconfirm, NSpace, NTooltip } from 'naive-ui' import { NButton, NIcon, NPopconfirm, NSpace, NTooltip } from 'naive-ui'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { DeleteOutlined, EditOutlined } from '@vicons/antd' import { DeleteOutlined, EditOutlined } from '@vicons/antd'
import { queryAccessTokenList, deleteToken } from '@/service/modules/token' import { queryAccessTokenList, deleteToken } from '@/service/modules/token'
import { parseTime } from '@/common/common' import { renderTableTime } from '@/common/common'
import type { TokenRes } from '@/service/modules/token/types' import type { TokenRes } from '@/service/modules/token/types'
export function useTable() { export function useTable() {
@ -53,15 +52,18 @@ export function useTable() {
}, },
{ {
title: t('security.token.expiration_time'), title: t('security.token.expiration_time'),
key: 'expireTime' key: 'expireTime',
render: (row: any) => renderTableTime(row.expireTime)
}, },
{ {
title: t('security.token.create_time'), title: t('security.token.create_time'),
key: 'createTime' key: 'createTime',
render: (row: any) => renderTableTime(row.createTime)
}, },
{ {
title: t('security.token.update_time'), title: t('security.token.update_time'),
key: 'updateTime' key: 'updateTime',
render: (row: any) => renderTableTime(row.updateTime)
}, },
{ {
title: t('security.token.operation'), title: t('security.token.operation'),
@ -166,23 +168,7 @@ export function useTable() {
variables.loadingRef = true variables.loadingRef = true
const { state } = useAsyncState( const { state } = useAsyncState(
queryAccessTokenList({ ...params }).then((res: TokenRes) => { queryAccessTokenList({ ...params }).then((res: TokenRes) => {
variables.tableData = res.totalList.map((item, unused) => { variables.tableData = res.totalList as any
item.expireTime = format(
parseTime(item.expireTime),
'yyyy-MM-dd HH:mm:ss'
)
item.createTime = format(
parseTime(item.createTime),
'yyyy-MM-dd HH:mm:ss'
)
item.updateTime = format(
parseTime(item.updateTime),
'yyyy-MM-dd HH:mm:ss'
)
return {
...item
}
}) as any
variables.totalPage = res.totalPage variables.totalPage = res.totalPage
variables.loadingRef = false variables.loadingRef = false
}), }),

Loading…
Cancel
Save