Browse Source

[Fix][UI][V1.0.0-Beta]Fix data not update bug for workflow version switch (#9642)

3.0.0/version-upgrade
Devosend 3 years ago committed by GitHub
parent
commit
303ee1bf15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 34
      dolphinscheduler-ui-next/src/views/projects/workflow/definition/components/use-table.ts
  2. 11
      dolphinscheduler-ui-next/src/views/projects/workflow/definition/components/version-modal.tsx

34
dolphinscheduler-ui-next/src/views/projects/workflow/definition/components/use-table.ts

@ -35,7 +35,19 @@ export function useTable(
const { t } = useI18n() const { t } = useI18n()
const router: Router = useRouter() const router: Router = useRouter()
const columns: TableColumns<any> = [ const variables = reactive({
columns: [],
row: {} as any,
tableData: [],
page: ref(1),
totalPage: ref(1),
pageSize: ref(10),
projectCode: ref(Number(router.currentRoute.value.params.projectCode)),
loadingRef: ref(false)
})
const createColumns = (variables: any) => {
variables.columns = [
{ {
title: '#', title: '#',
key: 'id', key: 'id',
@ -143,18 +155,8 @@ export function useTable(
}) })
} }
} }
] ] as TableColumns<any>
}
const variables = reactive({
columns,
row: {} as any,
tableData: [],
page: ref(1),
totalPage: ref(1),
pageSize: ref(10),
projectCode: ref(Number(router.currentRoute.value.params.projectCode)),
loadingRef: ref(false)
})
const getTableData = (row: any) => { const getTableData = (row: any) => {
if (variables.loadingRef) return if (variables.loadingRef) return
@ -178,9 +180,9 @@ export function useTable(
const handleSwitchVersion = (version: number) => { const handleSwitchVersion = (version: number) => {
switchVersion(variables.projectCode, variables.row.code, version).then( switchVersion(variables.projectCode, variables.row.code, version).then(
() => { () => {
variables.row.version = version
window.$message.success(t('project.workflow.success')) window.$message.success(t('project.workflow.success'))
ctx.emit('updateList') ctx.emit('updateList')
getTableData(variables.row)
} }
) )
} }
@ -190,6 +192,9 @@ export function useTable(
() => { () => {
window.$message.success(t('project.workflow.success')) window.$message.success(t('project.workflow.success'))
ctx.emit('updateList') ctx.emit('updateList')
if (variables.tableData.length === 1 && variables.page > 1) {
variables.page -= 1
}
getTableData(variables.row) getTableData(variables.row)
} }
) )
@ -197,6 +202,7 @@ export function useTable(
return { return {
variables, variables,
createColumns,
getTableData getTableData
} }
} }

11
dolphinscheduler-ui-next/src/views/projects/workflow/definition/components/version-modal.tsx

@ -41,7 +41,7 @@ export default defineComponent({
props, props,
emits: ['update:show', 'update:row', 'updateList'], emits: ['update:show', 'update:row', 'updateList'],
setup(props, ctx) { setup(props, ctx) {
const { variables, getTableData } = useTable(ctx) const { variables, createColumns, getTableData } = useTable(ctx)
const { importState } = useForm() const { importState } = useForm()
const { handleImportDefinition } = useModal(importState, ctx) const { handleImportDefinition } = useModal(importState, ctx)
@ -66,9 +66,16 @@ export default defineComponent({
watch( watch(
() => props.show, () => props.show,
() => requestData() () => {
createColumns(variables)
requestData()
}
) )
watch(useI18n().locale, () => {
createColumns(variables)
})
return { return {
hideModal, hideModal,
handleImport, handleImport,

Loading…
Cancel
Save