Browse Source

[Feature][UI Next] Add project list. (#7961)

3.0.0/version-upgrade
songjianet 3 years ago committed by GitHub
parent
commit
455cede28e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      dolphinscheduler-ui-next/src/layouts/content/components/navbar/index.module.scss
  2. 1
      dolphinscheduler-ui-next/src/layouts/content/components/sidebar/index.tsx
  3. 25
      dolphinscheduler-ui-next/src/locales/modules/en_US.ts
  4. 25
      dolphinscheduler-ui-next/src/locales/modules/zh_CN.ts
  5. 2
      dolphinscheduler-ui-next/src/router/modules/projects.ts
  6. 1
      dolphinscheduler-ui-next/src/service/modules/monitor/types.ts
  7. 14
      dolphinscheduler-ui-next/src/service/modules/projects/index.ts
  8. 38
      dolphinscheduler-ui-next/src/service/modules/projects/types.ts
  9. 2
      dolphinscheduler-ui-next/src/views/home/types.ts
  10. 2
      dolphinscheduler-ui-next/src/views/home/use-process-state.ts
  11. 2
      dolphinscheduler-ui-next/src/views/home/use-table.ts
  12. 2
      dolphinscheduler-ui-next/src/views/home/use-task-state.ts
  13. 4
      dolphinscheduler-ui-next/src/views/monitor/servers/master/index.tsx
  14. 6
      dolphinscheduler-ui-next/src/views/monitor/servers/worker/index.tsx
  15. 2
      dolphinscheduler-ui-next/src/views/monitor/servers/worker/use-worker.ts
  16. 53
      dolphinscheduler-ui-next/src/views/project/list/index.module.scss
  17. 196
      dolphinscheduler-ui-next/src/views/project/list/index.tsx
  18. 111
      dolphinscheduler-ui-next/src/views/project/list/project-modal.tsx
  19. 145
      dolphinscheduler-ui-next/src/views/project/list/table-action.tsx
  20. 58
      dolphinscheduler-ui-next/src/views/project/list/use-form.ts
  21. 112
      dolphinscheduler-ui-next/src/views/project/list/use-table.ts
  22. 8
      dolphinscheduler-ui-next/src/views/security/tenant/components/tenant-modal.tsx
  23. 45
      dolphinscheduler-ui-next/src/views/security/tenant/index.tsx
  24. 79
      dolphinscheduler-ui-next/src/views/security/tenant/use-table.ts

2
dolphinscheduler-ui-next/src/layouts/content/components/navbar/index.module.scss

@ -20,7 +20,7 @@
align-items: center;
width: 100%;
height: 64px;
border-bottom: 1px solid var(--border-color);
border-bottom: 1px solid var(--n-border-color);
.nav {
margin-left: 12px;

1
dolphinscheduler-ui-next/src/layouts/content/components/sidebar/index.tsx

@ -38,7 +38,6 @@ const Sidebar = defineComponent({
const { handleMenuClick } = useMenuClick()
return { collapsedRef, defaultExpandedKeys, handleMenuClick }
},
render() {

25
dolphinscheduler-ui-next/src/locales/modules/en_US.ts

@ -151,6 +151,30 @@ const monitor = {
},
}
const project = {
list: {
create_project: 'Create Project',
project_list: 'Project List',
project_tips: 'Please enter your project',
description_tips: 'Please enter your description',
username_tips: 'Please enter your username',
project_name: 'Project Name',
project_description: 'Project Description',
owned_users: 'Owned Users',
workflow_define_count: 'Workflow Define Count',
process_instance_running_count: 'Process Instance Running Count',
description: 'Description',
create_time: 'Create Time',
update_time: 'Update Time',
operation: 'Operation',
edit: 'Edit',
delete: 'Delete',
confirm: 'Confirm',
cancel: 'Cancel',
delete_confirm: 'Delete?',
},
}
export default {
login,
modal,
@ -161,4 +185,5 @@ export default {
password,
profile,
monitor,
project,
}

25
dolphinscheduler-ui-next/src/locales/modules/zh_CN.ts

@ -149,6 +149,30 @@ const monitor = {
},
}
const project = {
list: {
create_project: '创建项目',
project_list: '项目列表',
project_tips: '请输入项目名称',
description_tips: '请输入项目描述',
username_tips: '请输入所属用户',
project_name: '项目名称',
project_description: '项目描述',
owned_users: '所属用户',
workflow_define_count: '工作流定义数',
process_instance_running_count: '正在运行的流程数',
description: '描述',
create_time: '创建时间',
update_time: '更新时间',
operation: '操作',
edit: '编辑',
delete: '删除',
confirm: '确定',
cancel: '取消',
delete_confirm: '确定删除吗?',
},
}
export default {
login,
modal,
@ -159,4 +183,5 @@ export default {
password,
profile,
monitor,
project,
}

2
dolphinscheduler-ui-next/src/router/modules/projects.ts

@ -32,7 +32,7 @@ export default {
{
path: '/projects/list',
name: 'projects-list',
component: components['home'],
component: components['list'],
meta: {
title: '项目',
},

1
dolphinscheduler-ui-next/src/service/modules/monitor/types.ts

@ -25,7 +25,6 @@ interface DatabaseRes {
date: string
}
interface MasterRes {
id: number
host: string

14
dolphinscheduler-ui-next/src/service/modules/projects/index.ts

@ -16,13 +16,7 @@
*/
import { axios } from '@/service/service'
import {
ListReq,
ProjectsReq,
UserIdReq,
CodeReq,
UpdateProjectsReq,
} from './types'
import { ListReq, ProjectsReq, UserIdReq, UpdateProjectsReq } from './types'
export function queryProjectListPaging(params: ListReq): any {
return axios({
@ -70,14 +64,14 @@ export function queryUnauthorizedProject(params: UserIdReq): any {
})
}
export function queryProjectByCode(code: CodeReq): any {
export function queryProjectByCode(code: number): any {
return axios({
url: `/projects/${code}`,
method: 'get',
})
}
export function updateProject(data: UpdateProjectsReq, code: CodeReq): any {
export function updateProject(data: UpdateProjectsReq, code: number): any {
return axios({
url: `/projects/${code}`,
method: 'put',
@ -85,7 +79,7 @@ export function updateProject(data: UpdateProjectsReq, code: CodeReq): any {
})
}
export function deleteProject(code: CodeReq): any {
export function deleteProject(code: number): any {
return axios({
url: `/projects/${code}`,
method: 'delete',

38
dolphinscheduler-ui-next/src/service/modules/projects/types.ts

@ -23,19 +23,45 @@ interface ListReq {
interface ProjectsReq {
description?: string
projectName?: string
projectName: string
}
interface UserIdReq {
userId?: number
}
interface CodeReq {
code: number
}
interface UpdateProjectsReq extends ProjectsReq {
userName?: string
}
export { ListReq, ProjectsReq, UserIdReq, CodeReq, UpdateProjectsReq }
interface ProjectList {
id: number
userId: number
userName: string
code: any
name: string
description: string
createTime: string
updateTime: string
perm: number
defCount: number
instRunningCount: number
}
interface ProjectRes {
totalList: ProjectList[]
total: number
totalPage: number
pageSize: number
currentPage: number
start: number
}
export {
ListReq,
ProjectsReq,
UserIdReq,
UpdateProjectsReq,
ProjectRes,
ProjectList,
}

2
dolphinscheduler-ui-next/src/views/home/types.ts

@ -21,7 +21,7 @@ interface DefinitionChartData {
}
interface StateTableData {
id: number
index: number
number: number
state: string
}

2
dolphinscheduler-ui-next/src/views/home/use-process-state.ts

@ -31,7 +31,7 @@ export function useProcessState() {
}).then((res: TaskStateRes): StateData => {
const table = res.taskCountDtos.map((item, index) => {
return {
id: index + 1,
index: index + 1,
state: item.taskStateType,
number: item.count,
}

2
dolphinscheduler-ui-next/src/views/home/use-table.ts

@ -22,7 +22,7 @@ export function useTable() {
const { t } = useI18n()
const columnsRef: TableColumns<any> = [
{ title: '#', key: 'id' },
{ title: '#', key: 'index' },
{ title: t('home.number'), key: 'number' },
{ title: t('home.state'), key: 'state' },
]

2
dolphinscheduler-ui-next/src/views/home/use-task-state.ts

@ -31,7 +31,7 @@ export function useTaskState() {
}).then((res: TaskStateRes): StateData => {
const table = res.taskCountDtos.map((item, index) => {
return {
id: index + 1,
index: index + 1,
state: item.taskStateType,
number: item.count,
}

4
dolphinscheduler-ui-next/src/views/monitor/servers/master/index.tsx

@ -35,7 +35,7 @@ const master = defineComponent({
const { getMaster } = useMaster()
const masterRef: Ref<Array<MasterRes>> = ref(getMaster())
const columnsRef: TableColumns<any> = [
{ title: '#', key: 'id' },
{ title: '#', key: 'index' },
{ title: t('monitor.master.directory'), key: 'directory' },
]
@ -121,7 +121,7 @@ const master = defineComponent({
masterRef[0] && (
<NDataTable
columns={columnsRef}
data={[{ id: 1, directory: masterRef[0].zkDirectory }]}
data={[{ index: 1, directory: masterRef[0].zkDirectory }]}
striped
size={'small'}
/>

6
dolphinscheduler-ui-next/src/views/monitor/servers/worker/index.tsx

@ -35,7 +35,7 @@ const master = defineComponent({
const { getWorker } = useWorker()
const workerRef: Ref<Array<WorkerRes>> = ref(getWorker())
const columnsRef: TableColumns<any> = [
{ title: '#', key: 'id' },
{ title: '#', key: 'index' },
{ title: t('monitor.worker.directory'), key: 'directory' },
]
@ -121,7 +121,9 @@ const master = defineComponent({
workerRef[0] && (
<NDataTable
columns={columnsRef}
data={workerRef[0].zkDirectories.map((item, index) => { return {id: index + 1, directory: item} })}
data={workerRef[0].zkDirectories.map((item, index) => {
return { index: index + 1, directory: item }
})}
striped
size={'small'}
/>

2
dolphinscheduler-ui-next/src/views/monitor/servers/worker/use-worker.ts

@ -16,7 +16,7 @@
*/
import { useAsyncState } from '@vueuse/core'
import {listWorker} from '@/service/modules/monitor'
import { listWorker } from '@/service/modules/monitor'
export function useWorker() {
const getWorker = () => {

53
dolphinscheduler-ui-next/src/views/project/list/index.module.scss

@ -0,0 +1,53 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
.search-card {
display: flex;
justify-content: space-between;
align-items: center;
.box {
display: flex;
justify-content: flex-end;
align-items: center;
width: 300px;
button {
margin-left: 10px;
}
}
}
.table-card {
margin-top: 8px;
.pagination {
margin-top: 20px;
display: flex;
justify-content: center;
}
}
.links {
color: #2080f0;
text-decoration: none;
cursor: pointer;
&:hover {
text-decoration: underline;
}
}

196
dolphinscheduler-ui-next/src/views/project/list/index.tsx

@ -0,0 +1,196 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { defineComponent, onMounted, ref, toRefs, reactive } from 'vue'
import {
NCard,
NButton,
NInput,
NIcon,
NDataTable,
NPagination,
} from 'naive-ui'
import { SearchOutlined } from '@vicons/antd'
import { useI18n } from 'vue-i18n'
import { useTable } from './use-table'
import styles from './index.module.scss'
import Card from '@/components/card'
import ProjectModal from './project-modal'
const list = defineComponent({
name: 'list',
setup() {
const showModalRef = ref(false)
const modelStatusRef = ref(0)
const { t } = useI18n()
const { variables, getTableData } = useTable()
let updateProjectData = reactive({
code: 0,
projectName: '',
description: '',
})
const requestData = () => {
getTableData({
pageSize: variables.pageSize,
pageNo: variables.page,
searchVal: variables.searchVal,
})
}
const onCancel = () => {
showModalRef.value = false
}
const onConfirm = () => {
showModalRef.value = false
updateProjectData = {
code: 0,
projectName: '',
description: '',
}
resetTableData()
}
const onOpen = () => {
modelStatusRef.value = 0
showModalRef.value = true
}
const resetTableData = () => {
getTableData({
pageSize: variables.pageSize,
pageNo: variables.page,
searchVal: variables.searchVal,
})
}
const onUpdatePageSize = () => {
variables.page = 1
resetTableData()
}
const updateProjectItem = (
code: number,
projectName: string,
description: string
) => {
modelStatusRef.value = 1
showModalRef.value = true
updateProjectData.code = code
updateProjectData.projectName = projectName
updateProjectData.description = description
}
onMounted(() => {
requestData()
})
return {
t,
showModalRef,
...toRefs(variables),
onCancel,
onConfirm,
onOpen,
updateProjectItem,
resetTableData,
onUpdatePageSize,
updateProjectData,
modelStatusRef,
}
},
render() {
const {
t,
showModalRef,
onCancel,
onConfirm,
onOpen,
updateProjectItem,
resetTableData,
onUpdatePageSize,
updateProjectData,
modelStatusRef,
} = this
const { columns } = useTable(updateProjectItem, resetTableData)
return (
<div>
<NCard>
<div class={styles['search-card']}>
<div>
<NButton size='small' type='primary' onClick={onOpen}>
{t('project.list.create_project')}
</NButton>
</div>
<div class={styles.box}>
<NInput
size='small'
v-model:value={this.searchVal}
placeholder={t('project.list.project_tips')}
/>
<NButton size='small' type='primary' onClick={resetTableData}>
{{
icon: () => (
<NIcon>
<SearchOutlined />
</NIcon>
),
}}
</NButton>
</div>
</div>
</NCard>
<Card
title={t('project.list.project_list')}
class={styles['table-card']}
>
<NDataTable
columns={columns}
size={'small'}
data={this.tableData}
striped
/>
<div class={styles.pagination}>
<NPagination
v-model:page={this.page}
v-model:page-size={this.pageSize}
page-count={this.totalPage}
show-size-picker
page-sizes={[10, 30, 50]}
show-quick-jumper
onUpdatePage={resetTableData}
onUpdatePageSize={onUpdatePageSize}
/>
</div>
</Card>
{showModalRef && (
<ProjectModal
show={showModalRef}
onCancel={onCancel}
onConfirm={onConfirm}
data={updateProjectData}
status={modelStatusRef}
/>
)}
</div>
)
},
})
export default list

111
dolphinscheduler-ui-next/src/views/project/list/project-modal.tsx

@ -0,0 +1,111 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { defineComponent, PropType, toRefs, onMounted } from 'vue'
import { NForm, NFormItem, NInput } from 'naive-ui'
import { useForm } from './use-form'
import Modal from '@/components/modal'
import { createProject, updateProject } from '@/service/modules/projects'
const props = {
show: {
type: Boolean as PropType<boolean>,
default: false,
},
data: {
type: Object as PropType<any>,
},
status: {
type: Number as PropType<number>,
default: 0,
},
}
const ProjectModal = defineComponent({
name: 'ProjectModal',
props,
emits: ['confirm', 'cancel'],
setup(props, { emit }) {
const { state, t } = useForm()
onMounted(() => {
if (props.status === 1) {
state.projectForm.projectName = props.data.projectName
state.projectForm.description = props.data.description
}
})
const onConfirm = () => {
;(props.status === 1
? updateProject(state.projectForm, props.data.code)
: createProject(state.projectForm)
).then(() => {
emit('confirm')
})
}
const onCancel = () => {
state.projectForm.projectName = ''
state.projectForm.description = ''
state.projectForm.userName = ''
emit('cancel')
}
return { ...toRefs(state), t, onConfirm, onCancel }
},
render() {
const { t, onConfirm, onCancel, show } = this
return (
<Modal
title={t('project.list.create_project')}
show={show}
onConfirm={onConfirm}
onCancel={onCancel}
confirmDisabled={
!this.projectForm.projectName || !this.projectForm.userName
}
>
<NForm rules={this.rules} ref='projectFormRef'>
<NFormItem label={t('project.list.project_name')} path='projectName'>
<NInput
v-model={[this.projectForm.projectName, 'value']}
placeholder={t('project.list.project_tips')}
/>
</NFormItem>
<NFormItem label={t('project.list.owned_users')} path='userName'>
<NInput
v-model={[this.projectForm.userName, 'value']}
placeholder={t('project.list.username_tips')}
/>
</NFormItem>
<NFormItem
label={t('project.list.project_description')}
path='description'
>
<NInput
v-model={[this.projectForm.description, 'value']}
type='textarea'
placeholder={t('project.list.description_tips')}
/>
</NFormItem>
</NForm>
</Modal>
)
},
})
export default ProjectModal

145
dolphinscheduler-ui-next/src/views/project/list/table-action.tsx

@ -0,0 +1,145 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { defineComponent, PropType } from 'vue'
import { useI18n } from 'vue-i18n'
import { NSpace, NTooltip, NButton, NIcon, NPopconfirm } from 'naive-ui'
import { DeleteOutlined, EditOutlined, InfoCircleFilled } from '@vicons/antd'
import { deleteProject } from '@/service/modules/projects'
import type { ProjectList } from '@/service/modules/projects/types'
interface ProjectRow extends ProjectList {
index: number
}
const props = {
row: {
type: Object as PropType<ProjectRow>,
default: {},
},
}
const TableAction = defineComponent({
name: 'TableAction',
props,
emits: ['resetTableData', 'updateProjectItem'],
setup(props, { emit }) {
const { t } = useI18n()
const handleEditProject = (
code: number,
projectName: string,
description: string
) => {
emit('updateProjectItem', code, projectName, description)
}
const handleDeleteProject = (code: number) => {
deleteProject(code).then(() => {
emit('resetTableData')
})
}
return { t, handleEditProject, handleDeleteProject }
},
render() {
const { t, handleEditProject, handleDeleteProject } = this
return (
<NSpace>
<NTooltip trigger={'hover'}>
{{
default: () => t('project.list.edit'),
trigger: () => (
<NButton
size='small'
type='info'
tag='div'
onClick={() =>
handleEditProject(
this.row.code,
this.row.name,
this.row.description
)
}
circle
>
<NIcon>
<EditOutlined />
</NIcon>
</NButton>
),
}}
</NTooltip>
<NTooltip trigger={'hover'}>
{{
default: () => t('project.list.edit'),
trigger: () => (
<NButton
size='small'
type='info'
tag='div'
onClick={() =>
handleEditProject(
this.row.code,
this.row.name,
this.row.description
)
}
circle
>
<NIcon>
<EditOutlined />
</NIcon>
</NButton>
),
}}
</NTooltip>
<NTooltip trigger={'hover'}>
{{
default: () => t('project.list.delete'),
trigger: () => (
<NButton size='small' type='error' circle>
<NPopconfirm
positive-text={t('project.list.confirm')}
negative-text={t('project.list.cancel')}
onPositiveClick={() => handleDeleteProject(this.row.code)}
>
{{
default: () => t('project.list.delete_confirm'),
icon: () => (
<NIcon>
<InfoCircleFilled />
</NIcon>
),
trigger: () => (
<NIcon>
<DeleteOutlined />
</NIcon>
),
}}
</NPopconfirm>
</NButton>
),
}}
</NTooltip>
</NSpace>
)
},
})
export default TableAction

58
dolphinscheduler-ui-next/src/views/project/list/use-form.ts

@ -0,0 +1,58 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { useI18n } from 'vue-i18n'
import { reactive, ref } from 'vue'
import { useUserStore } from '@/store/user/user'
import type { FormRules } from 'naive-ui'
import type { UserInfoRes } from '@/service/modules/users/types'
export function useForm() {
const { t } = useI18n()
const userStore = useUserStore()
const state = reactive({
projectFormRef: ref(),
projectForm: {
projectName: '',
description: '',
userName: (userStore.getUserInfo as UserInfoRes).userName,
},
rules: {
projectName: {
required: true,
trigger: ['input', 'blur'],
validator() {
if (state.projectForm.projectName === '') {
return new Error(t('project.list.project_tips'))
}
},
},
userName: {
required: true,
trigger: ['input', 'blur'],
validator() {
if (state.projectForm.userName === '') {
return new Error(t('project.list.username_tips'))
}
},
},
} as FormRules,
})
return { state, t }
}

112
dolphinscheduler-ui-next/src/views/project/list/use-table.ts

@ -0,0 +1,112 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { h, reactive, ref } from 'vue'
import { useI18n } from 'vue-i18n'
import { useAsyncState } from '@vueuse/core'
import { queryProjectListPaging } from '@/service/modules/projects'
import { format } from 'date-fns'
import TableAction from './table-action'
import styles from './index.module.scss'
import type { TableColumns } from 'naive-ui/es/data-table/src/interface'
import type { ProjectRes } from '@/service/modules/projects/types'
export function useTable(
updateProjectItem = (
code: number,
name: string,
description: string
): void => {},
resetTableData = () => {}
) {
const { t } = useI18n()
const columns: TableColumns<any> = [
{ title: '#', key: 'index' },
{
title: t('project.list.project_name'),
key: 'name',
render: (row) =>
h(
'a',
{
class: styles.links,
onClick: () => {},
},
{
default: () => {
return row.name
},
}
),
},
{ title: t('project.list.owned_users'), key: 'userName' },
{ title: t('project.list.workflow_define_count'), key: 'defCount' },
{
title: t('project.list.process_instance_running_count'),
key: 'instRunningCount',
},
{ title: t('project.list.description'), key: 'description' },
{ title: t('project.list.create_time'), key: 'createTime' },
{ title: t('project.list.update_time'), key: 'updateTime' },
{
title: t('project.list.operation'),
key: 'actions',
render: (row: any) =>
h(TableAction, {
row,
onResetTableData: () => resetTableData(),
onUpdateProjectItem: (code, name, description) =>
updateProjectItem(code, name, description),
}),
},
]
const variables = reactive({
tableData: [],
page: ref(1),
pageSize: ref(10),
searchVal: ref(null),
totalPage: ref(1),
})
const getTableData = (params: any) => {
const { state } = useAsyncState(
queryProjectListPaging(params).then((res: ProjectRes) => {
variables.totalPage = res.totalPage
variables.tableData = res.totalList.map((item, index) => {
item.createTime = format(
new Date(item.createTime),
'yyyy-MM-dd HH:mm:ss'
)
item.updateTime = format(
new Date(item.updateTime),
'yyyy-MM-dd HH:mm:ss'
)
return {
index: index + 1,
...item,
}
}) as any
}),
{}
)
return state
}
return { getTableData, variables, columns }
}

8
dolphinscheduler-ui-next/src/views/security/tenant/components/tenant-modal.tsx

@ -39,21 +39,19 @@ const TenantModal = defineComponent({
showModalRef: {
type: Boolean as PropType<boolean>,
default: false,
}
},
},
render() {
return (
<div>
<Modal
title="创建租户"
title='创建租户'
show={this.showModalRef}
onCancel={this.cancelModal}
onConfirm={this.confirmModal}
>
{{
default: () => (
<div></div>
),
default: () => <div></div>,
}}
</Modal>
</div>

45
dolphinscheduler-ui-next/src/views/security/tenant/index.tsx

@ -16,7 +16,14 @@
*/
import { defineComponent, toRefs, onMounted } from 'vue'
import { NButton, NInput, NIcon, NDataTable, NPagination, NCard } from 'naive-ui'
import {
NButton,
NInput,
NIcon,
NDataTable,
NPagination,
NCard,
} from 'naive-ui'
import styles from './index.module.scss'
import { useTable } from './use-table'
import { SearchOutlined } from '@vicons/antd'
@ -31,7 +38,7 @@ const tenementManage = defineComponent({
getTableData({
pageSize: variables.pageSize,
pageNo: variables.page,
searchVal: variables.searchVal
searchVal: variables.searchVal,
})
}
@ -50,8 +57,14 @@ const tenementManage = defineComponent({
onMounted(() => {
requestData()
})
return { ...toRefs(variables), requestData, handleModalChange, onCancelModal, onConfirmModal }
return {
...toRefs(variables),
requestData,
handleModalChange,
onCancelModal,
onConfirmModal,
}
},
render() {
return (
@ -59,11 +72,23 @@ const tenementManage = defineComponent({
<NCard>
<div class={styles.header}>
<div>
<NButton size="small" onClick={this.handleModalChange}></NButton>
<NButton size='small' onClick={this.handleModalChange}>
</NButton>
</div>
<div class={styles.search}>
<NInput size="small" v-model={[this.searchVal, 'value']} on-input={this.requestData} placeholder="请输入关键词" clearable />
<NButton size="small"><NIcon><SearchOutlined /></NIcon></NButton>
<NInput
size='small'
v-model={[this.searchVal, 'value']}
on-input={this.requestData}
placeholder='请输入关键词'
clearable
/>
<NButton size='small'>
<NIcon>
<SearchOutlined />
</NIcon>
</NButton>
</div>
</div>
</NCard>
@ -82,7 +107,11 @@ const tenementManage = defineComponent({
onUpdatePageSize={this.requestData}
/>
</div>
<TenantModal showModalRef={this.showModalRef} onCancelModal={this.onCancelModal} onConfirmModal={this.onConfirmModal}></TenantModal>
<TenantModal
showModalRef={this.showModalRef}
onCancelModal={this.onCancelModal}
onConfirmModal={this.onConfirmModal}
></TenantModal>
</div>
)
},

79
dolphinscheduler-ui-next/src/views/security/tenant/use-table.ts

@ -20,14 +20,12 @@ import { queryTenantListPaging } from '@/service/modules/tenants'
import { reactive, h, ref } from 'vue'
import { NButton } from 'naive-ui'
import { useI18n } from 'vue-i18n'
import {
DeleteOutlined, EditOutlined
} from '@vicons/antd'
import { DeleteOutlined, EditOutlined } from '@vicons/antd'
export function useTable() {
const { t } = useI18n()
const handleEdit= (row: any) => {
const handleEdit = (row: any) => {
console.log('click', row)
}
@ -39,59 +37,60 @@ export function useTable() {
return [
{
title: '编号',
key: 'num'
key: 'num',
},
{
title: '操作系统租户',
key: 'tenantCode'
key: 'tenantCode',
},
{
title: '描述',
key: 'description'
key: 'description',
},
{
title: '队列',
key: 'queueName'
key: 'queueName',
},
{
title: '创建时间',
key: 'createTime'
key: 'createTime',
},
{
title: '更新时间',
key: 'updateTime'
key: 'updateTime',
},
{
title: '操作',
key: 'actions',
render (row: any) {
return h(
'div',
null, [
h(
NButton,
{
size: 'small',
onClick: () => { handleEdit(row) }
render(row: any) {
return h('div', null, [
h(
NButton,
{
size: 'small',
onClick: () => {
handleEdit(row)
},
{
icon: () => h(EditOutlined)
}
),
h(
NButton,
{
size: 'small',
onClick: () => { handleDelete(row) }
},
{
icon: () => h(EditOutlined),
}
),
h(
NButton,
{
size: 'small',
onClick: () => {
handleDelete(row)
},
{
icon: () => h(DeleteOutlined)
}
)
]
)
}
}
},
{
icon: () => h(DeleteOutlined),
}
),
])
},
},
]
}
@ -102,16 +101,16 @@ export function useTable() {
pageSize: ref(10),
searchVal: ref(null),
totalPage: ref(1),
showModalRef: ref(false)
showModalRef: ref(false),
})
const getTableData = (params: any) => {
const { state } = useAsyncState(
queryTenantListPaging({...params}).then((res: any) => {
queryTenantListPaging({ ...params }).then((res: any) => {
variables.tableData = res.totalList.map((item: any, index: number) => {
return {
num: index + 1,
...item
...item,
}
})
variables.totalPage = res.totalPage
@ -124,6 +123,6 @@ export function useTable() {
return {
variables,
getTableData
getTableData,
}
}

Loading…
Cancel
Save