@lovrabet/rabetbase-cli 2.5.4 → 2.5.5-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/api-doc.js +1 -1
- package/lib/api/api-group.js +1 -1
- package/lib/api/fetch-model-list.js +1 -1
- package/lib/api/generate-api-file.js +1 -1
- package/lib/api/generate-sdk-config-file.js +1 -1
- package/lib/api/legacy-api-file.js +1 -1
- package/lib/api/model-registry-file.js +1 -1
- package/lib/api/model-registry-scaffold.js +1 -1
- package/lib/api/model-source.js +1 -1
- package/lib/auth/auth-server-ui.js +1 -1
- package/lib/auth/auth-server.js +1 -1
- package/lib/auth/constant.js +1 -1
- package/lib/auth/get-cookie.js +1 -1
- package/lib/auth/get-session-user.js +1 -1
- package/lib/auth/is-session-valid.js +1 -1
- package/lib/auth/login-success-html.js +1 -1
- package/lib/auth/logout.js +1 -1
- package/lib/cli-flags.js +1 -1
- package/lib/cli.js +1 -1
- package/lib/commands/api/generate.js +1 -1
- package/lib/commands/api/index.js +1 -1
- package/lib/commands/api/list.js +1 -1
- package/lib/commands/api/pull.js +1 -1
- package/lib/commands/api/shared.js +1 -1
- package/lib/commands/app/detail.js +1 -1
- package/lib/commands/app/index.js +1 -1
- package/lib/commands/app/list.js +1 -1
- package/lib/commands/app/members-list.js +1 -1
- package/lib/commands/app/remote-directory.js +1 -1
- package/lib/commands/app/shared.js +1 -1
- package/lib/commands/app-config/delete.js +1 -1
- package/lib/commands/app-config/get.js +1 -1
- package/lib/commands/app-config/index.js +1 -1
- package/lib/commands/app-config/list.js +1 -1
- package/lib/commands/app-config/set.js +1 -1
- package/lib/commands/app-config/shared.js +1 -1
- package/lib/commands/auth/index.js +1 -1
- package/lib/commands/bff/create.js +1 -1
- package/lib/commands/bff/delete.js +1 -1
- package/lib/commands/bff/detail.js +1 -1
- package/lib/commands/bff/index.js +1 -1
- package/lib/commands/bff/list.js +1 -1
- package/lib/commands/bff/logs.js +1 -1
- package/lib/commands/bff/pull.js +1 -1
- package/lib/commands/bff/push.js +1 -1
- package/lib/commands/bff/status.js +1 -1
- package/lib/commands/cli-skill/index.js +1 -1
- package/lib/commands/cli-update.js +1 -1
- package/lib/commands/codegen/index.js +1 -1
- package/lib/commands/codegen/sdk.js +1 -1
- package/lib/commands/codegen/sql.js +1 -1
- package/lib/commands/common/app-registry.js +1 -1
- package/lib/commands/common/app-selector.js +1 -1
- package/lib/commands/common/async-task.js +1 -1
- package/lib/commands/common/dry-run.js +1 -1
- package/lib/commands/common/flags.js +1 -1
- package/lib/commands/common/local-file.js +1 -1
- package/lib/commands/common/validate.js +1 -1
- package/lib/commands/config/delete.js +1 -1
- package/lib/commands/config/get.js +1 -1
- package/lib/commands/config/index.js +1 -1
- package/lib/commands/config/init.js +1 -1
- package/lib/commands/config/list.js +1 -1
- package/lib/commands/config/set.js +1 -1
- package/lib/commands/config/shared.js +1 -1
- package/lib/commands/dataset/batch-design.js +1 -1
- package/lib/commands/dataset/business-group-update.js +1 -1
- package/lib/commands/dataset/business-groups.js +1 -1
- package/lib/commands/dataset/capability.js +1 -1
- package/lib/commands/dataset/cross-relation-create.js +1 -1
- package/lib/commands/dataset/cross-relation-delete.js +1 -1
- package/lib/commands/dataset/cross-relation-list.js +1 -1
- package/lib/commands/dataset/cross-relation-shared.js +1 -1
- package/lib/commands/dataset/cross-relation-update.js +1 -1
- package/lib/commands/dataset/delete.js +1 -1
- package/lib/commands/dataset/detail.js +1 -1
- package/lib/commands/dataset/extend-update.js +1 -1
- package/lib/commands/dataset/field-restore.js +1 -1
- package/lib/commands/dataset/field-update.js +1 -1
- package/lib/commands/dataset/generate.js +1 -1
- package/lib/commands/dataset/index.js +1 -1
- package/lib/commands/dataset/list.js +1 -1
- package/lib/commands/dataset/operations.js +1 -1
- package/lib/commands/dataset/relation-audit.js +1 -1
- package/lib/commands/dataset/relation-create.js +1 -1
- package/lib/commands/dataset/relation-delete.js +1 -1
- package/lib/commands/dataset/relation-shared.js +1 -1
- package/lib/commands/dataset/relation-update.js +1 -1
- package/lib/commands/dataset/relations.js +1 -1
- package/lib/commands/dataset/rename.js +1 -1
- package/lib/commands/dataset/restore.js +1 -1
- package/lib/commands/dataset/user-deleted-field-list.js +1 -1
- package/lib/commands/db/analysis-batching.js +1 -1
- package/lib/commands/db/analyze-batch-plan.js +1 -1
- package/lib/commands/db/analyze-cancel.js +1 -1
- package/lib/commands/db/analyze-start.js +1 -1
- package/lib/commands/db/analyze-status.js +1 -1
- package/lib/commands/db/create.js +1 -1
- package/lib/commands/db/delete.js +1 -1
- package/lib/commands/db/detail.js +1 -1
- package/lib/commands/db/diff-refresh-start.js +1 -1
- package/lib/commands/db/diff-refresh-status.js +1 -1
- package/lib/commands/db/diff.js +1 -1
- package/lib/commands/db/index.js +1 -1
- package/lib/commands/db/list.js +1 -1
- package/lib/commands/db/shared.js +1 -1
- package/lib/commands/db/table-diff-shared.js +1 -1
- package/lib/commands/db/tables.js +1 -1
- package/lib/commands/db/test.js +1 -1
- package/lib/commands/db/update.js +1 -1
- package/lib/commands/deployment/index.js +1 -1
- package/lib/commands/deployment/sync-all.js +1 -1
- package/lib/commands/deployment/sync-jobs.js +1 -1
- package/lib/commands/deployment/sync-status.js +1 -1
- package/lib/commands/doctor.js +1 -1
- package/lib/commands/file/index.js +1 -1
- package/lib/commands/flow/create.js +1 -1
- package/lib/commands/flow/detail.js +1 -1
- package/lib/commands/flow/index.js +1 -1
- package/lib/commands/flow/list.js +1 -1
- package/lib/commands/flow/publish.js +1 -1
- package/lib/commands/flow/runtime-resources-shared.js +1 -1
- package/lib/commands/flow/runtime-role-list.js +1 -1
- package/lib/commands/flow/runtime-role-user-list.js +1 -1
- package/lib/commands/flow/runtime-user-search.js +1 -1
- package/lib/commands/flow/shared.js +1 -1
- package/lib/commands/flow/update.js +1 -1
- package/lib/commands/flow/validate.js +1 -1
- package/lib/commands/instant-api-policy/current.js +1 -1
- package/lib/commands/instant-api-policy/index.js +1 -1
- package/lib/commands/instant-api-policy/init.js +1 -1
- package/lib/commands/instant-api-policy/publish.js +1 -1
- package/lib/commands/instant-api-policy/pull.js +1 -1
- package/lib/commands/instant-api-policy/revision.js +1 -1
- package/lib/commands/instant-api-policy/revisions.js +1 -1
- package/lib/commands/instant-api-policy/rollback.js +1 -1
- package/lib/commands/instant-api-policy/shared.js +1 -1
- package/lib/commands/instant-api-policy/validate.js +1 -1
- package/lib/commands/issue/index.js +1 -1
- package/lib/commands/issue/nudge.js +1 -1
- package/lib/commands/issue/report.js +1 -1
- package/lib/commands/issue/shared.js +1 -1
- package/lib/commands/kb/create.js +1 -1
- package/lib/commands/kb/delete.js +1 -1
- package/lib/commands/kb/detail.js +1 -1
- package/lib/commands/kb/index.js +1 -1
- package/lib/commands/kb/list.js +1 -1
- package/lib/commands/kb/search.js +1 -1
- package/lib/commands/kb/shared.js +1 -1
- package/lib/commands/kb/update.js +1 -1
- package/lib/commands/logs/index.js +1 -1
- package/lib/commands/menu/asset-update.js +1 -1
- package/lib/commands/menu/delete.js +1 -1
- package/lib/commands/menu/external-link-create.js +1 -1
- package/lib/commands/menu/external-link-update.js +1 -1
- package/lib/commands/menu/group-create.js +1 -1
- package/lib/commands/menu/group-update.js +1 -1
- package/lib/commands/menu/index.js +1 -1
- package/lib/commands/menu/list.js +1 -1
- package/lib/commands/menu/move.js +1 -1
- package/lib/commands/menu/regroup-start.js +1 -1
- package/lib/commands/menu/rename.js +1 -1
- package/lib/commands/menu/shared/compare-table.js +1 -1
- package/lib/commands/menu/shared/delete-plan.js +1 -1
- package/lib/commands/menu/shared/facts.js +1 -1
- package/lib/commands/menu/shared/index.js +1 -1
- package/lib/commands/menu/shared/inquirer.js +1 -1
- package/lib/commands/menu/shared/local-pages.js +1 -1
- package/lib/commands/menu/shared/logic.js +1 -1
- package/lib/commands/menu/shared/mutations.js +1 -1
- package/lib/commands/menu/shared/path.js +1 -1
- package/lib/commands/menu/shared/service.js +1 -1
- package/lib/commands/menu/shared/subapp-assets.js +1 -1
- package/lib/commands/menu/shared/sync-core.js +1 -1
- package/lib/commands/menu/shared/update-core.js +1 -1
- package/lib/commands/menu/shared/valid-url.js +1 -1
- package/lib/commands/menu/subapp-assets-status.js +1 -1
- package/lib/commands/menu/subapp-assets-update.js +1 -1
- package/lib/commands/menu/sync.js +1 -1
- package/lib/commands/menu/visibility-update.js +1 -1
- package/lib/commands/notification/config-create.js +1 -1
- package/lib/commands/notification/config-delete.js +1 -1
- package/lib/commands/notification/config-list.js +1 -1
- package/lib/commands/notification/config-update.js +1 -1
- package/lib/commands/notification/index.js +1 -1
- package/lib/commands/notification/shared.js +1 -1
- package/lib/commands/ocr/index.js +1 -1
- package/lib/commands/page/create.js +1 -1
- package/lib/commands/page/custom/detail.js +1 -1
- package/lib/commands/page/custom/list.js +1 -1
- package/lib/commands/page/custom/publish.js +1 -1
- package/lib/commands/page/custom/shared.js +1 -1
- package/lib/commands/page/custom/syntax.js +1 -1
- package/lib/commands/page/custom/update.js +1 -1
- package/lib/commands/page/data-list-status.js +1 -1
- package/lib/commands/page/generate-start.js +1 -1
- package/lib/commands/page/generate-status.js +1 -1
- package/lib/commands/page/index.js +1 -1
- package/lib/commands/page/pull.js +1 -1
- package/lib/commands/page/push.js +1 -1
- package/lib/commands/page/relation-audit.js +1 -1
- package/lib/commands/page/restore.js +1 -1
- package/lib/commands/page/shared.js +1 -1
- package/lib/commands/page/sync.js +1 -1
- package/lib/commands/project/api-architecture-upgrade.js +1 -1
- package/lib/commands/project/create/enhanced-guided-create.js +1 -1
- package/lib/commands/project/create/format-elapsed.js +1 -1
- package/lib/commands/project/create/main.js +1 -1
- package/lib/commands/project/create/materialize-project-template.js +1 -1
- package/lib/commands/project/create/project-name.js +1 -1
- package/lib/commands/project/create/project-template-archive.js +1 -1
- package/lib/commands/project/create/project-template-path.js +1 -1
- package/lib/commands/project/create/use-copy-project-template.js +1 -1
- package/lib/commands/project/create/use-format-code.js +1 -1
- package/lib/commands/project/create/use-install-dependencies.js +1 -1
- package/lib/commands/project/domain-routing-sync.js +1 -1
- package/lib/commands/project/index.js +1 -1
- package/lib/commands/project/upgrade.js +1 -1
- package/lib/commands/registry.js +1 -1
- package/lib/commands/role/delete.js +1 -1
- package/lib/commands/role/detail.js +1 -1
- package/lib/commands/role/index.js +1 -1
- package/lib/commands/role/list.js +1 -1
- package/lib/commands/role/shared.js +1 -1
- package/lib/commands/role/update.js +1 -1
- package/lib/commands/role/user-add.js +1 -1
- package/lib/commands/role/user-remove.js +1 -1
- package/lib/commands/role/user-resolve.js +1 -1
- package/lib/commands/rule/get.js +1 -1
- package/lib/commands/rule/index.js +1 -1
- package/lib/commands/rule/list.js +1 -1
- package/lib/commands/rule/set.js +1 -1
- package/lib/commands/rule/shared.js +1 -1
- package/lib/commands/run/index.js +1 -1
- package/lib/commands/schema.js +1 -1
- package/lib/commands/sql/create.js +1 -1
- package/lib/commands/sql/delete.js +1 -1
- package/lib/commands/sql/detail.js +1 -1
- package/lib/commands/sql/exec.js +1 -1
- package/lib/commands/sql/index.js +1 -1
- package/lib/commands/sql/list.js +1 -1
- package/lib/commands/sql/pull.js +1 -1
- package/lib/commands/sql/push.js +1 -1
- package/lib/commands/sql/shared.js +1 -1
- package/lib/commands/sql/status.js +1 -1
- package/lib/commands/sql/validate.js +1 -1
- package/lib/commands/task/index.js +1 -1
- package/lib/commands/task/status.js +1 -1
- package/lib/commands/tenant/index.js +1 -1
- package/lib/commands/tenant/members-list.js +1 -1
- package/lib/commands/tenant/shared.js +1 -1
- package/lib/commands/user-account/dingding-sandbox-bind.js +1 -1
- package/lib/commands/user-account/feishu-bind.js +1 -1
- package/lib/commands/user-account/index.js +1 -1
- package/lib/commands/workspace/add.js +1 -1
- package/lib/commands/workspace/index.js +1 -1
- package/lib/commands/workspace/remove.js +1 -1
- package/lib/config/domain-config.js +1 -1
- package/lib/config/project-domain-routing.js +1 -1
- package/lib/config/region-config.js +1 -1
- package/lib/config/schema.js +1 -1
- package/lib/constant/cdn.js +1 -1
- package/lib/constant/cli.js +1 -1
- package/lib/constant/defaults.js +1 -1
- package/lib/constant/domain.js +1 -1
- package/lib/constant/env.js +1 -1
- package/lib/constant/output.js +1 -1
- package/lib/constant/paths.js +1 -1
- package/lib/constant/region.js +1 -1
- package/lib/constant/risk.js +1 -1
- package/lib/constant/routing-profile.js +1 -1
- package/lib/context/app-resolver.js +1 -1
- package/lib/context/auth-resolver.js +1 -1
- package/lib/context/config-loader.js +1 -1
- package/lib/context.js +1 -1
- package/lib/core/alias-resolver.js +1 -1
- package/lib/core/api-client.js +1 -1
- package/lib/core/bff/config.js +1 -1
- package/lib/core/bff/file-system.js +1 -1
- package/lib/core/bff/hash.js +1 -1
- package/lib/core/bff/hook-directory.js +1 -1
- package/lib/core/bff/lock.js +1 -1
- package/lib/core/bff/utils.js +1 -1
- package/lib/core/cross-db-relation.js +1 -1
- package/lib/core/db-resolver.js +1 -1
- package/lib/core/flow-config.js +1 -1
- package/lib/core/instant-api-policy/config.js +1 -1
- package/lib/core/kb-search-client.js +1 -1
- package/lib/core/page/file-system.js +1 -1
- package/lib/core/page/hash.js +1 -1
- package/lib/core/page/lock.js +1 -1
- package/lib/core/page/lr-smart-jsx.js +1 -1
- package/lib/core/sql-index-auditor.js +1 -1
- package/lib/core/sql-sync/config.js +1 -1
- package/lib/core/sql-sync/file-system.js +1 -1
- package/lib/core/sql-sync/hash.js +1 -1
- package/lib/core/sql-sync/lock.js +1 -1
- package/lib/core/sql-sync/utils.js +1 -1
- package/lib/core/sql-validator.js +1 -1
- package/lib/errors.js +1 -1
- package/lib/framework/build-all-flags.js +1 -1
- package/lib/framework/error-output.js +1 -1
- package/lib/framework/explicit-yes.js +1 -1
- package/lib/framework/flags.js +1 -1
- package/lib/framework/help.js +1 -1
- package/lib/framework/index.js +1 -1
- package/lib/framework/output.js +1 -1
- package/lib/framework/response.js +1 -1
- package/lib/framework/runner-alias.js +1 -1
- package/lib/framework/runner.js +1 -1
- package/lib/framework/schema-export.js +1 -1
- package/lib/framework/supported-flags.js +1 -1
- package/lib/framework/types.js +1 -1
- package/lib/generated/build-info.d.ts +4 -4
- package/lib/generated/build-info.js +1 -1
- package/lib/generated/official-routing.js +1 -1
- package/lib/generated/routing-contract.js +1 -1
- package/lib/help.js +1 -1
- package/lib/postinstall.js +1 -1
- package/lib/runtime/confirmation.js +1 -1
- package/lib/runtime/event.js +1 -1
- package/lib/runtime/index.js +1 -1
- package/lib/runtime/queue.js +1 -1
- package/lib/runtime/resolve.js +1 -1
- package/lib/skills/builtin-skill.js +1 -1
- package/lib/skills/main.js +1 -1
- package/lib/skills/npx-skills-add.js +1 -1
- package/lib/skills/skill-presence.js +1 -1
- package/lib/telemetry/cli-command-trace.js +1 -1
- package/lib/telemetry/cli-help-trace.js +1 -1
- package/lib/telemetry/ensure-cli-otel-config.js +1 -1
- package/lib/telemetry/register-otel-exit-shutdown.js +1 -1
- package/lib/telemetry/send-cli-trace-log.js +1 -1
- package/lib/telemetry/send-platform-issue-collect-log.js +1 -1
- package/lib/utils/ai_config.js +1 -1
- package/lib/utils/apply-jq-filter.js +1 -1
- package/lib/utils/cdn-config.js +1 -1
- package/lib/utils/check-sdk-version.js +1 -1
- package/lib/utils/cli-version-check.js +1 -1
- package/lib/utils/cli-version-policy.js +1 -1
- package/lib/utils/config.js +1 -1
- package/lib/utils/entity-with-id.js +1 -1
- package/lib/utils/file-utils.js +1 -1
- package/lib/utils/guides-cdn.js +1 -1
- package/lib/utils/http-client.js +1 -1
- package/lib/utils/is-non-interactive.js +1 -1
- package/lib/utils/logger.js +1 -1
- package/lib/utils/params.js +1 -1
- package/lib/utils/platform.js +1 -1
- package/lib/utils/sleep.js +1 -1
- package/lib/utils/template-replacer.js +1 -1
- package/lib/utils/update-notice.js +1 -1
- package/lib/utils/version.js +1 -1
- package/lib/utils/with-active-cookie.js +1 -1
- package/lib/utils/write-cli-side-channel.js +1 -1
- package/package.json +2 -1
- package/skills/rabetbase/SKILL.md +1 -1
- package/skills/rabetbase-page-generation/SKILL.md +39 -0
- package/skills/rabetbase-page-generation/references/component-baseline.md +18 -0
- package/skills/rabetbase-page-generation/references/generation.md +126 -0
- package/skills/rabetbase-page-generation/templates/onepage/build.mjs +48 -0
- package/skills/rabetbase-page-generation/templates/onepage/create/README.md +20 -0
- package/skills/rabetbase-page-generation/templates/onepage/create/index.jsx +4 -0
- package/skills/rabetbase-page-generation/templates/onepage/create/preview.png +0 -0
- package/skills/rabetbase-page-generation/templates/onepage/detail/README.md +20 -0
- package/skills/rabetbase-page-generation/templates/onepage/detail/index.jsx +194 -0
- package/skills/rabetbase-page-generation/templates/onepage/detail/preview.png +0 -0
- package/skills/rabetbase-page-generation/templates/onepage/list/README.md +20 -0
- package/skills/rabetbase-page-generation/templates/onepage/list/index.jsx +721 -0
- package/skills/rabetbase-page-generation/templates/onepage/list/preview.png +0 -0
- package/skills/rabetbase-page-generation/templates/onepage/shared/editor.jsx +395 -0
- package/skills/rabetbase-page-generation/templates/onepage/shared/model.js +141 -0
- package/skills/rabetbase-page-generation/templates/onepage/shared/page.css +377 -0
- package/skills/rabetbase-page-generation/templates/onepage/shared/record-layout.jsx +90 -0
- package/skills/rabetbase-page-generation/templates/onepage/shared/responsive.jsx +70 -0
- package/skills/rabetbase-page-generation/templates/onepage/update/README.md +21 -0
- package/skills/rabetbase-page-generation/templates/onepage/update/index.jsx +4 -0
- package/skills/rabetbase-page-generation/templates/onepage/update/preview.png +0 -0
- package/skills/rabetbase.manifest.json +3 -3
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from "react";
|
|
2
|
+
import {
|
|
3
|
+
Alert,
|
|
4
|
+
App,
|
|
5
|
+
Button,
|
|
6
|
+
ConfigProvider,
|
|
7
|
+
Form,
|
|
8
|
+
Input,
|
|
9
|
+
InputNumber,
|
|
10
|
+
Radio,
|
|
11
|
+
Space,
|
|
12
|
+
Spin,
|
|
13
|
+
theme,
|
|
14
|
+
} from "antd";
|
|
15
|
+
import dayjs from "dayjs";
|
|
16
|
+
import {
|
|
17
|
+
useAppContext,
|
|
18
|
+
useAppTheme,
|
|
19
|
+
useLocation,
|
|
20
|
+
useNavigate,
|
|
21
|
+
useSdkClient,
|
|
22
|
+
} from "@/context/app-context";
|
|
23
|
+
import {
|
|
24
|
+
DATASET_CODE,
|
|
25
|
+
LIST_PATH,
|
|
26
|
+
childPaths,
|
|
27
|
+
statusOptions,
|
|
28
|
+
typeOptions,
|
|
29
|
+
levelOptions,
|
|
30
|
+
} from "./model";
|
|
31
|
+
import { RecordGroups, RecordItem, recordTheme } from "./record-layout";
|
|
32
|
+
import { ResponsiveDateTime } from "./responsive";
|
|
33
|
+
import "./page.css";
|
|
34
|
+
|
|
35
|
+
function CustomerEditor({ mode }) {
|
|
36
|
+
const hostTheme = useAppTheme();
|
|
37
|
+
const client = useSdkClient(),
|
|
38
|
+
navigate = useNavigate(),
|
|
39
|
+
location = useLocation();
|
|
40
|
+
const { onePageInfo } = useAppContext();
|
|
41
|
+
const { message, modal } = App.useApp();
|
|
42
|
+
const continueAfterSave = useRef(false);
|
|
43
|
+
const focusNextRecord = useRef(false);
|
|
44
|
+
const customerNameInput = useRef(null);
|
|
45
|
+
const [dirty, setDirty] = useState(false);
|
|
46
|
+
const [form] = Form.useForm();
|
|
47
|
+
const updating = mode === "update";
|
|
48
|
+
const rawId =
|
|
49
|
+
onePageInfo?.innerSearchParams?.id ??
|
|
50
|
+
new URLSearchParams(location.search).get("id");
|
|
51
|
+
const id = rawId == null ? "" : String(rawId).trim();
|
|
52
|
+
const [loading, setLoading] = useState(updating),
|
|
53
|
+
[error, setError] = useState("");
|
|
54
|
+
const [saving, setSaving] = useState(false),
|
|
55
|
+
[revision, setRevision] = useState(0);
|
|
56
|
+
const original = useRef(null),
|
|
57
|
+
submitting = useRef(false);
|
|
58
|
+
const model = client.models[`dataset_${DATASET_CODE}`];
|
|
59
|
+
const params =
|
|
60
|
+
onePageInfo?.innerSearchParams ??
|
|
61
|
+
Object.fromEntries(new URLSearchParams(location.search));
|
|
62
|
+
const returnDetail = updating && params.returnDetail === "1";
|
|
63
|
+
const goBack = () =>
|
|
64
|
+
returnDetail
|
|
65
|
+
? navigate(
|
|
66
|
+
`${childPaths.detail}?${new URLSearchParams({ id, ids: String(params.ids || "") })}`,
|
|
67
|
+
{ replace: true },
|
|
68
|
+
)
|
|
69
|
+
: navigate(onePageInfo ? "../" : LIST_PATH);
|
|
70
|
+
const saveLabel = returnDetail ? "保存并返回详情" : "保存并返回";
|
|
71
|
+
function backToDetail() {
|
|
72
|
+
if (!dirty) return goBack();
|
|
73
|
+
modal.confirm({
|
|
74
|
+
title: "放弃未保存的修改?",
|
|
75
|
+
content: "返回后将显示上次保存的客户信息。",
|
|
76
|
+
okText: "放弃修改",
|
|
77
|
+
cancelText: "继续编辑",
|
|
78
|
+
onOk: goBack,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
let active = true;
|
|
84
|
+
original.current = null;
|
|
85
|
+
setError("");
|
|
86
|
+
form.resetFields();
|
|
87
|
+
if (!updating) {
|
|
88
|
+
setLoading(false);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
setLoading(true);
|
|
92
|
+
(async () => {
|
|
93
|
+
try {
|
|
94
|
+
if (!/^\d+$/.test(id))
|
|
95
|
+
throw Error("缺少或无效的客户主键,请从列表重新打开更新页");
|
|
96
|
+
const record = await model.getOne(id);
|
|
97
|
+
if (!record) throw Error("客户不存在或已被删除");
|
|
98
|
+
if (active) {
|
|
99
|
+
original.current = {
|
|
100
|
+
...record,
|
|
101
|
+
onboarding_date: record.onboarding_date
|
|
102
|
+
? dayjs(record.onboarding_date)
|
|
103
|
+
: null,
|
|
104
|
+
};
|
|
105
|
+
form.setFieldsValue(original.current);
|
|
106
|
+
}
|
|
107
|
+
} catch (cause) {
|
|
108
|
+
if (active) setError(cause.message || "加载失败,请重试");
|
|
109
|
+
} finally {
|
|
110
|
+
if (active) setLoading(false);
|
|
111
|
+
}
|
|
112
|
+
})();
|
|
113
|
+
return () => {
|
|
114
|
+
active = false;
|
|
115
|
+
};
|
|
116
|
+
}, [client, id, updating, revision, form]);
|
|
117
|
+
|
|
118
|
+
useEffect(() => {
|
|
119
|
+
if (!saving && focusNextRecord.current) {
|
|
120
|
+
focusNextRecord.current = false;
|
|
121
|
+
const frame = requestAnimationFrame(() =>
|
|
122
|
+
customerNameInput.current?.focus(),
|
|
123
|
+
);
|
|
124
|
+
return () => cancelAnimationFrame(frame);
|
|
125
|
+
}
|
|
126
|
+
}, [saving, form]);
|
|
127
|
+
const formName = `customer-${mode}`;
|
|
128
|
+
function submit(stay = false) {
|
|
129
|
+
if (submitting.current || saving || loading || error) return;
|
|
130
|
+
continueAfterSave.current = stay;
|
|
131
|
+
form.submit();
|
|
132
|
+
}
|
|
133
|
+
async function save(values) {
|
|
134
|
+
if (submitting.current || (updating && !original.current)) return;
|
|
135
|
+
submitting.current = true;
|
|
136
|
+
const stayOnCreate = !updating && continueAfterSave.current;
|
|
137
|
+
setSaving(true);
|
|
138
|
+
try {
|
|
139
|
+
const payload = {};
|
|
140
|
+
for (const key of [
|
|
141
|
+
"customer_name",
|
|
142
|
+
"status",
|
|
143
|
+
"customer_type",
|
|
144
|
+
"customer_level",
|
|
145
|
+
"contact_name",
|
|
146
|
+
"phone",
|
|
147
|
+
"email",
|
|
148
|
+
"region",
|
|
149
|
+
"annual_revenue",
|
|
150
|
+
"notes",
|
|
151
|
+
])
|
|
152
|
+
payload[key] = values[key] ?? null;
|
|
153
|
+
payload.customer_name = values.customer_name.trim();
|
|
154
|
+
payload.onboarding_date = values.onboarding_date
|
|
155
|
+
? values.onboarding_date.format("YYYY-MM-DD HH:mm:ss")
|
|
156
|
+
: null;
|
|
157
|
+
if (updating) await model.update(id, payload);
|
|
158
|
+
else await model.create(payload);
|
|
159
|
+
window.dispatchEvent(
|
|
160
|
+
new CustomEvent("lovrabet:page-generation:changed", {
|
|
161
|
+
detail: LIST_PATH,
|
|
162
|
+
}),
|
|
163
|
+
);
|
|
164
|
+
message.success("保存成功");
|
|
165
|
+
setDirty(false);
|
|
166
|
+
if (stayOnCreate) {
|
|
167
|
+
focusNextRecord.current = true;
|
|
168
|
+
form.resetFields();
|
|
169
|
+
} else goBack();
|
|
170
|
+
} catch (cause) {
|
|
171
|
+
message.error(cause.message || "保存失败,请重试");
|
|
172
|
+
} finally {
|
|
173
|
+
continueAfterSave.current = false;
|
|
174
|
+
submitting.current = false;
|
|
175
|
+
setSaving(false);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const controls = [
|
|
180
|
+
[
|
|
181
|
+
"customer_name",
|
|
182
|
+
"客户名称",
|
|
183
|
+
<Input allowClear />,
|
|
184
|
+
[{ required: true, whitespace: true, message: "请输入客户名称" }],
|
|
185
|
+
],
|
|
186
|
+
["status", "状态", <Radio.Group options={statusOptions} />],
|
|
187
|
+
["customer_type", "客户类型", <Radio.Group options={typeOptions} />],
|
|
188
|
+
["customer_level", "客户等级", <Radio.Group options={levelOptions} />],
|
|
189
|
+
["contact_name", "联系人", <Input allowClear />],
|
|
190
|
+
["phone", "电话", <Input allowClear />],
|
|
191
|
+
[
|
|
192
|
+
"email",
|
|
193
|
+
"邮箱",
|
|
194
|
+
<Input allowClear />,
|
|
195
|
+
[{ type: "email", message: "请输入有效邮箱" }],
|
|
196
|
+
],
|
|
197
|
+
["region", "区域", <Input allowClear />],
|
|
198
|
+
[
|
|
199
|
+
"annual_revenue",
|
|
200
|
+
"年营收",
|
|
201
|
+
<InputNumber precision={2} style={{ width: "100%" }} />,
|
|
202
|
+
],
|
|
203
|
+
[
|
|
204
|
+
"onboarding_date",
|
|
205
|
+
"入驻日期",
|
|
206
|
+
<ResponsiveDateTime
|
|
207
|
+
placeholder="请选择入驻日期"
|
|
208
|
+
style={{ width: "100%" }}
|
|
209
|
+
/>,
|
|
210
|
+
],
|
|
211
|
+
];
|
|
212
|
+
return (
|
|
213
|
+
<main
|
|
214
|
+
className="customer-record customer-editor"
|
|
215
|
+
onKeyDown={(event) => {
|
|
216
|
+
if (
|
|
217
|
+
(event.ctrlKey || event.metaKey) &&
|
|
218
|
+
event.key === "Enter" &&
|
|
219
|
+
!event.nativeEvent.isComposing
|
|
220
|
+
) {
|
|
221
|
+
event.preventDefault();
|
|
222
|
+
if (!saving && !loading && !error) submit();
|
|
223
|
+
}
|
|
224
|
+
}}
|
|
225
|
+
>
|
|
226
|
+
{!onePageInfo && !returnDetail && (
|
|
227
|
+
<Button className="record-back" disabled={saving} onClick={goBack}>
|
|
228
|
+
返回列表
|
|
229
|
+
</Button>
|
|
230
|
+
)}
|
|
231
|
+
<header className="record-heading">
|
|
232
|
+
<div className="record-heading-title">
|
|
233
|
+
<h1>{updating ? "编辑客户" : "新增客户"}</h1>
|
|
234
|
+
<span className="record-save-status" role="status">
|
|
235
|
+
{saving
|
|
236
|
+
? "正在保存…"
|
|
237
|
+
: dirty
|
|
238
|
+
? "有未保存的修改"
|
|
239
|
+
: updating
|
|
240
|
+
? `主键 ${id}`
|
|
241
|
+
: "填写客户信息"}
|
|
242
|
+
</span>
|
|
243
|
+
</div>
|
|
244
|
+
<Space wrap>
|
|
245
|
+
{returnDetail && (
|
|
246
|
+
<Button disabled={saving} onClick={backToDetail}>
|
|
247
|
+
返回详情
|
|
248
|
+
</Button>
|
|
249
|
+
)}
|
|
250
|
+
<Button
|
|
251
|
+
type="primary"
|
|
252
|
+
loading={saving}
|
|
253
|
+
disabled={loading || Boolean(error)}
|
|
254
|
+
onClick={() => submit()}
|
|
255
|
+
title="Ctrl / ⌘ + Enter 保存"
|
|
256
|
+
>
|
|
257
|
+
{saveLabel}
|
|
258
|
+
</Button>
|
|
259
|
+
</Space>
|
|
260
|
+
</header>
|
|
261
|
+
{loading ? (
|
|
262
|
+
<Spin />
|
|
263
|
+
) : error ? (
|
|
264
|
+
<Alert
|
|
265
|
+
type="error"
|
|
266
|
+
showIcon
|
|
267
|
+
message="加载失败"
|
|
268
|
+
description={error}
|
|
269
|
+
action={
|
|
270
|
+
<Button onClick={() => setRevision((v) => v + 1)}>重试</Button>
|
|
271
|
+
}
|
|
272
|
+
/>
|
|
273
|
+
) : (
|
|
274
|
+
<Form
|
|
275
|
+
name={formName}
|
|
276
|
+
form={form}
|
|
277
|
+
layout="vertical"
|
|
278
|
+
onFinish={save}
|
|
279
|
+
onValuesChange={() => setDirty(true)}
|
|
280
|
+
scrollToFirstError={{
|
|
281
|
+
behavior: "smooth",
|
|
282
|
+
block: "center",
|
|
283
|
+
focus: true,
|
|
284
|
+
}}
|
|
285
|
+
onFinishFailed={() => {
|
|
286
|
+
continueAfterSave.current = false;
|
|
287
|
+
}}
|
|
288
|
+
disabled={saving}
|
|
289
|
+
>
|
|
290
|
+
<RecordGroups includeId={updating}>
|
|
291
|
+
{(field) => {
|
|
292
|
+
if (field.key === "id")
|
|
293
|
+
return (
|
|
294
|
+
<RecordItem key={field.key} field={field}>
|
|
295
|
+
<InputNumber
|
|
296
|
+
stringMode
|
|
297
|
+
value={id}
|
|
298
|
+
disabled
|
|
299
|
+
style={{ width: "100%" }}
|
|
300
|
+
/>
|
|
301
|
+
</RecordItem>
|
|
302
|
+
);
|
|
303
|
+
if (field.key === "notes")
|
|
304
|
+
return (
|
|
305
|
+
<RecordItem key={field.key} field={field} name="notes">
|
|
306
|
+
<Input.TextArea
|
|
307
|
+
rows={2}
|
|
308
|
+
allowClear
|
|
309
|
+
placeholder="请输入备注"
|
|
310
|
+
/>
|
|
311
|
+
</RecordItem>
|
|
312
|
+
);
|
|
313
|
+
const [, , control, rules] = controls.find(
|
|
314
|
+
([name]) => name === field.key,
|
|
315
|
+
);
|
|
316
|
+
return (
|
|
317
|
+
<RecordItem
|
|
318
|
+
key={field.key}
|
|
319
|
+
field={field}
|
|
320
|
+
name={field.key}
|
|
321
|
+
rules={rules}
|
|
322
|
+
>
|
|
323
|
+
{field.type === "TEXT" ? (
|
|
324
|
+
<Input
|
|
325
|
+
ref={
|
|
326
|
+
field.key === "customer_name"
|
|
327
|
+
? customerNameInput
|
|
328
|
+
: undefined
|
|
329
|
+
}
|
|
330
|
+
allowClear
|
|
331
|
+
type={
|
|
332
|
+
field.key === "phone"
|
|
333
|
+
? "tel"
|
|
334
|
+
: field.key === "email"
|
|
335
|
+
? "email"
|
|
336
|
+
: "text"
|
|
337
|
+
}
|
|
338
|
+
placeholder={`请输入${field.label}`}
|
|
339
|
+
/>
|
|
340
|
+
) : (
|
|
341
|
+
control
|
|
342
|
+
)}
|
|
343
|
+
</RecordItem>
|
|
344
|
+
);
|
|
345
|
+
}}
|
|
346
|
+
</RecordGroups>
|
|
347
|
+
<footer
|
|
348
|
+
className="record-footer"
|
|
349
|
+
style={{
|
|
350
|
+
background: hostTheme?.mode === "dark" ? "#1f1f1f" : "#f5f5f5",
|
|
351
|
+
}}
|
|
352
|
+
>
|
|
353
|
+
<Space>
|
|
354
|
+
<Button
|
|
355
|
+
onClick={() => {
|
|
356
|
+
setDirty(false);
|
|
357
|
+
form.resetFields();
|
|
358
|
+
if (original.current) form.setFieldsValue(original.current);
|
|
359
|
+
}}
|
|
360
|
+
>
|
|
361
|
+
重置
|
|
362
|
+
</Button>
|
|
363
|
+
{!updating && (
|
|
364
|
+
<Button loading={saving} onClick={() => submit(true)}>
|
|
365
|
+
保存并继续新增
|
|
366
|
+
</Button>
|
|
367
|
+
)}
|
|
368
|
+
<Button type="primary" loading={saving} onClick={() => submit()}>
|
|
369
|
+
{saveLabel}
|
|
370
|
+
</Button>
|
|
371
|
+
</Space>
|
|
372
|
+
</footer>
|
|
373
|
+
</Form>
|
|
374
|
+
)}
|
|
375
|
+
</main>
|
|
376
|
+
);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
export default function EditorPage({ mode }) {
|
|
380
|
+
const hostTheme = useAppTheme();
|
|
381
|
+
return (
|
|
382
|
+
<ConfigProvider
|
|
383
|
+
theme={recordTheme(
|
|
384
|
+
hostTheme,
|
|
385
|
+
hostTheme?.mode === "dark"
|
|
386
|
+
? theme.darkAlgorithm
|
|
387
|
+
: theme.defaultAlgorithm,
|
|
388
|
+
)}
|
|
389
|
+
>
|
|
390
|
+
<App>
|
|
391
|
+
<CustomerEditor mode={mode} />
|
|
392
|
+
</App>
|
|
393
|
+
</ConfigProvider>
|
|
394
|
+
);
|
|
395
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
// 生成时按 Dataset 元信息改写字段、枚举、排序、筛选和页面路径;这些客户字段仅表示模板写法。
|
|
2
|
+
import dayjs from "dayjs";
|
|
3
|
+
export const APP_CODE = "__APP_CODE__";
|
|
4
|
+
export const DATASET_CODE = "__DATASET_CODE__";
|
|
5
|
+
export const DEFAULT_ORDER = [{ customer_name: "desc" }, { id: "desc" }];
|
|
6
|
+
export const LIST_PATH = "__LIST_PATH__";
|
|
7
|
+
export const childPaths = {
|
|
8
|
+
create: "__CREATE_PATH__",
|
|
9
|
+
update: "__UPDATE_PATH__",
|
|
10
|
+
detail: "__DETAIL_PATH__",
|
|
11
|
+
};
|
|
12
|
+
export const statusOptions = [
|
|
13
|
+
{ label: "活跃", value: "active" },
|
|
14
|
+
{ label: "非活跃", value: "inactive" },
|
|
15
|
+
];
|
|
16
|
+
export const typeOptions = [
|
|
17
|
+
{ label: "企业", value: "enterprise" },
|
|
18
|
+
{ label: "个人", value: "individual" },
|
|
19
|
+
];
|
|
20
|
+
export const levelOptions = ["a", "b", "c"].map((value) => ({
|
|
21
|
+
label: value.toUpperCase(),
|
|
22
|
+
value,
|
|
23
|
+
}));
|
|
24
|
+
export const fields = [
|
|
25
|
+
{ key: "id", label: "主键", type: "NUMBER", width: 56, align: "right" },
|
|
26
|
+
{ key: "customer_name", label: "客户名称", type: "TEXT", width: 212 },
|
|
27
|
+
{
|
|
28
|
+
key: "status",
|
|
29
|
+
label: "状态",
|
|
30
|
+
type: "SELECT",
|
|
31
|
+
width: 70,
|
|
32
|
+
options: statusOptions,
|
|
33
|
+
tag: true,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
key: "customer_type",
|
|
37
|
+
label: "客户类型",
|
|
38
|
+
type: "SELECT",
|
|
39
|
+
width: 64,
|
|
40
|
+
options: typeOptions,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
key: "customer_level",
|
|
44
|
+
label: "客户等级",
|
|
45
|
+
type: "SELECT",
|
|
46
|
+
width: 64,
|
|
47
|
+
options: levelOptions,
|
|
48
|
+
tag: true,
|
|
49
|
+
},
|
|
50
|
+
{ key: "contact_name", label: "联系人", type: "TEXT", width: 104 },
|
|
51
|
+
{ key: "phone", label: "电话", type: "TEXT", width: 64 },
|
|
52
|
+
{ key: "email", label: "邮箱", type: "TEXT", width: 188 },
|
|
53
|
+
{ key: "region", label: "区域", type: "TEXT", width: 60 },
|
|
54
|
+
{
|
|
55
|
+
key: "annual_revenue",
|
|
56
|
+
label: "年营收",
|
|
57
|
+
type: "NUMBER",
|
|
58
|
+
width: 104,
|
|
59
|
+
align: "right",
|
|
60
|
+
precision: 2,
|
|
61
|
+
},
|
|
62
|
+
{ key: "onboarding_date", label: "入驻日期", type: "DATETIME", width: 128 },
|
|
63
|
+
];
|
|
64
|
+
export function traditionalWhere(values) {
|
|
65
|
+
const where = {};
|
|
66
|
+
for (const key of ["customer_name", "region", "contact_name"]) {
|
|
67
|
+
const value = values[key]?.trim();
|
|
68
|
+
if (value) where[key] = { $contain: value };
|
|
69
|
+
}
|
|
70
|
+
for (const key of ["status", "customer_type", "customer_level"])
|
|
71
|
+
if (values[key] !== undefined) where[key] = { $eq: values[key] };
|
|
72
|
+
if (values.onboarding_date?.[0] && values.onboarding_date?.[1])
|
|
73
|
+
where.onboarding_date = {
|
|
74
|
+
$gte: values.onboarding_date[0]
|
|
75
|
+
.startOf("day")
|
|
76
|
+
.format("YYYY-MM-DD HH:mm:ss"),
|
|
77
|
+
$lte: values.onboarding_date[1]
|
|
78
|
+
.endOf("day")
|
|
79
|
+
.format("YYYY-MM-DD HH:mm:ss"),
|
|
80
|
+
};
|
|
81
|
+
return where;
|
|
82
|
+
}
|
|
83
|
+
// Uses the host SDK's public runtime address. No credentials or environment fallback in page files.
|
|
84
|
+
export async function smartWhere(client, query, { signal }) {
|
|
85
|
+
const properties = fields.map(
|
|
86
|
+
({ key: code, label: name, type, options }) => ({
|
|
87
|
+
code,
|
|
88
|
+
name,
|
|
89
|
+
type,
|
|
90
|
+
options,
|
|
91
|
+
}),
|
|
92
|
+
);
|
|
93
|
+
const response = await fetch(new URL("/api/search", client.getBaseUrl()), {
|
|
94
|
+
method: "POST",
|
|
95
|
+
credentials: "include",
|
|
96
|
+
signal,
|
|
97
|
+
headers: { "Content-Type": "application/json" },
|
|
98
|
+
body: JSON.stringify({
|
|
99
|
+
id: "TEXT_TO_FILTER_PARAM",
|
|
100
|
+
appCode: APP_CODE,
|
|
101
|
+
query: `**当前时间的 ISO 字符串**\n${new Date().toISOString()}\n**用户的查询需求(自然语言)**\n${query}\n**可用于 filter 的详细字段说明(含字段名和类型)**\n${JSON.stringify(properties)}`,
|
|
102
|
+
}),
|
|
103
|
+
});
|
|
104
|
+
if (!response.ok) throw Error(`智能搜索失败(${response.status}),请重试`);
|
|
105
|
+
const envelope = await response.json();
|
|
106
|
+
if (envelope.success === false)
|
|
107
|
+
throw Error(envelope.errorMsg || "智能搜索失败,请重试");
|
|
108
|
+
const result = JSON.parse((envelope.data ?? envelope).content);
|
|
109
|
+
if (
|
|
110
|
+
!result ||
|
|
111
|
+
typeof result !== "object" ||
|
|
112
|
+
Array.isArray(result) ||
|
|
113
|
+
!result.where ||
|
|
114
|
+
typeof result.where !== "object" ||
|
|
115
|
+
Array.isArray(result.where)
|
|
116
|
+
)
|
|
117
|
+
throw Error("智能搜索未返回有效筛选条件,请换一种描述");
|
|
118
|
+
return result.where;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export function formatField(value, field) {
|
|
122
|
+
if (value === undefined || value === null || value === "") return "--";
|
|
123
|
+
if (field.options)
|
|
124
|
+
return (
|
|
125
|
+
field.options.find((option) => option.value === value)?.label ??
|
|
126
|
+
String(value)
|
|
127
|
+
);
|
|
128
|
+
if (field.type === "NUMBER")
|
|
129
|
+
return Number.isFinite(Number(value))
|
|
130
|
+
? Number(value).toLocaleString("en-US", {
|
|
131
|
+
useGrouping: false,
|
|
132
|
+
minimumFractionDigits: field.precision ?? 0,
|
|
133
|
+
maximumFractionDigits: field.precision ?? 0,
|
|
134
|
+
})
|
|
135
|
+
: String(value);
|
|
136
|
+
if (field.type === "DATETIME")
|
|
137
|
+
return dayjs(value).isValid()
|
|
138
|
+
? dayjs(value).format("YYYY-MM-DD HH:mm")
|
|
139
|
+
: String(value);
|
|
140
|
+
return String(value);
|
|
141
|
+
}
|