diff --git a/src/flows/hookFlow/beforeDestroy/nodes/beforeDestroy.ts b/src/flows/hookFlow/beforeDestroy/nodes/beforeDestroy.ts index 75253fda..1f60d82a 100644 --- a/src/flows/hookFlow/beforeDestroy/nodes/beforeDestroy.ts +++ b/src/flows/hookFlow/beforeDestroy/nodes/beforeDestroy.ts @@ -1,10 +1,9 @@ -import { isTenantState } from '@/utils/get-page-state' -import { FunctionNode } from 'arkfbp/lib/functionNode' +import { StateNode } from '@/nodes/stateNode' -export class BeforeDestroy extends FunctionNode { +export class BeforeDestroy extends StateNode { async run() { // beforeDestory one page - const tempState = isTenantState() ? this.inputs.com.$store.state.tenant.tenantState : this.inputs.com.$store.state.admin.adminState + const tempState = this.getFirstState() if (tempState) { const path = this.inputs.com.path tempState.pages.splice(tempState.pages.indexOf(path), 1) diff --git a/src/flows/hookFlow/created/nodes/created.ts b/src/flows/hookFlow/created/nodes/created.ts index 4fc52a74..8b449d6a 100644 --- a/src/flows/hookFlow/created/nodes/created.ts +++ b/src/flows/hookFlow/created/nodes/created.ts @@ -1,10 +1,9 @@ -import { isTenantState } from '@/utils/get-page-state' -import { FunctionNode } from 'arkfbp/lib/functionNode' +import { StateNode } from '@/nodes/stateNode' -export class Created extends FunctionNode { +export class Created extends StateNode { async run() { // add current page - const tempState = isTenantState() ? this.inputs.com.$store.state.tenant.tenantState : this.inputs.com.$store.state.admin.adminState + const tempState = this.getFirstState() if (tempState) { const path = this.inputs.com.path tempState.pages.push(path) diff --git a/src/flows/tablePage/openCreateDialog/nodes/open.ts b/src/flows/tablePage/openCreateDialog/nodes/open.ts index f3da53e2..6d9930a3 100644 --- a/src/flows/tablePage/openCreateDialog/nodes/open.ts +++ b/src/flows/tablePage/openCreateDialog/nodes/open.ts @@ -1,11 +1,10 @@ import DialogState from '@/admin/common/Others/Dialog/DialogState' import TablePageState from '@/admin/TablePage/TablePageState' import OpenDialog from '@/nodes/openDialog' -import { isTenantState } from '@/utils/get-page-state' export class Open extends OpenDialog { get dialog():DialogState | null { - const tempState: TablePageState = isTenantState() ? this.inputs.com.$store.state.tenant.tenantState : this.inputs.com.$store.state.admin.adminState + const tempState: TablePageState = this.getState() if (tempState && tempState.dialogs) { return tempState.dialogs.create } else { diff --git a/src/flows/tablePage/openUpdateDialog/nodes/open.ts b/src/flows/tablePage/openUpdateDialog/nodes/open.ts index fb1c00ee..a9e6fe5b 100644 --- a/src/flows/tablePage/openUpdateDialog/nodes/open.ts +++ b/src/flows/tablePage/openUpdateDialog/nodes/open.ts @@ -1,11 +1,10 @@ import TablePageState from '@/admin/TablePage/TablePageState' import OpenDialog from '@/nodes/openDialog' import DialogState from '@/admin/common/Others/Dialog/DialogState' -import { isTenantState } from '@/utils/get-page-state' export class Open extends OpenDialog { get dialog():DialogState | null { - const tempState: TablePageState = isTenantState() ? this.inputs.com.$store.state.tenant.tenantState : this.inputs.com.$store.state.admin.adminState + const tempState: TablePageState = this.getState() if (tempState && tempState.dialogs) { return tempState.dialogs.update } else { diff --git a/src/flows/treePage/fetchTableList/nodes/fetch.ts b/src/flows/treePage/fetchTableList/nodes/fetch.ts index bdf3b170..8091874c 100644 --- a/src/flows/treePage/fetchTableList/nodes/fetch.ts +++ b/src/flows/treePage/fetchTableList/nodes/fetch.ts @@ -5,12 +5,9 @@ export class Fetch extends AuthApiNode { async run() { const tempState = this.getState() - this.url = getUrl(this.inputs.params.tableUrl) + this.url = getUrl(this.inputs.params.tableUrl, this.inputs.params.data) this.method = this.inputs.params.tableMethod || 'get' - this.params = { - group: this.inputs.params.data.uuid, - } - + this.$state.commit((state: any) => { state.client = tempState }) diff --git a/src/flows/treePage/init/nodes/initTableList.ts b/src/flows/treePage/init/nodes/initTableList.ts index a526ca51..cea4ec0e 100644 --- a/src/flows/treePage/init/nodes/initTableList.ts +++ b/src/flows/treePage/init/nodes/initTableList.ts @@ -10,7 +10,7 @@ export class InitTableList extends FunctionNode { // 对table表格机进行初始化操作 if (initContent.tableList) { - const tableListNodeOperationPath = initContent.tableList.path + const tableListNodeOperationPath = initContent.tableList.path.split('?')[0] const tableListNodeOperationMethod = initContent.tableList.method const tableListNodeOperation = OpenAPI.instance.getOperation(tableListNodeOperationPath, tableListNodeOperationMethod) if (tableListNodeOperation) { diff --git a/src/nodes/authApiNode.ts b/src/nodes/authApiNode.ts index e24449e9..304eb36b 100644 --- a/src/nodes/authApiNode.ts +++ b/src/nodes/authApiNode.ts @@ -1,6 +1,6 @@ import { APINode } from "arkfbp/lib/apiNode"; import { getToken } from '@/utils/auth' -import getPageState, { getPreviousPageState } from '@/utils/get-page-state' +import getPageState, { getPreviousPageState, getFirstPageState } from '@/utils/get-page-state' export class AuthApiNode extends APINode { async run() { @@ -20,4 +20,8 @@ export class AuthApiNode extends APINode { getPreviousState() { return getPreviousPageState() } + + getFirstState() { + return getFirstPageState() + } } diff --git a/src/nodes/stateNode.ts b/src/nodes/stateNode.ts index 27339d23..1d73a29e 100644 --- a/src/nodes/stateNode.ts +++ b/src/nodes/stateNode.ts @@ -1,5 +1,5 @@ import { FunctionNode } from 'arkfbp/lib/functionNode' -import getPageState, { getPreviousPageState } from '@/utils/get-page-state' +import getPageState, { getPreviousPageState, getFirstPageState } from '@/utils/get-page-state' export class StateNode extends FunctionNode { @@ -11,4 +11,8 @@ export class StateNode extends FunctionNode { return getPreviousPageState() } + getFirstState() { + return getFirstPageState() + } + } diff --git a/src/utils/get-page-state.ts b/src/utils/get-page-state.ts index bc919fd0..95f8bc57 100644 --- a/src/utils/get-page-state.ts +++ b/src/utils/get-page-state.ts @@ -21,19 +21,29 @@ function getStateByPath(tempState: any, path: string) { } export default function getPageState(specifiedPath = '') { - const tempState = isTenantState() ? TenantModule.tenantState : AdminModule.adminState - if (!tempState) return + const tempState = getCurrentRequiredState() const path = specifiedPath === '' ? tempState.pages[tempState.pages.length - 1] : specifiedPath return getStateByPath(tempState, path) } export function getPreviousPageState() { - const tempState = isTenantState() ? TenantModule.tenantState : AdminModule.adminState - if (!tempState) return + const tempState = getCurrentRequiredState() const path = tempState.pages.length === 1 ? tempState.pages[tempState.pages.length - 1] : tempState.pages[tempState.pages.length - 2] return getStateByPath(tempState, path) } +export function getFirstPageState() { + const tempState = getCurrentRequiredState() + const path = tempState.pages[0] + return getStateByPath(tempState, path) +} + +export function getCurrentRequiredState() { + const tempState = isTenantState() ? TenantModule.tenantState : AdminModule.adminState + if (!tempState) return + return tempState +} + export function isTenantState() { return (location.hash === '#/tenant' || location.pathname === '/tenant') }