@fui-org/fui-cli 1.3.2 → 2.0.0

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.
Files changed (111) hide show
  1. package/README.md +19 -3
  2. package/dist/fui-bmg5pnmq.js +379 -0
  3. package/dist/fui.js +1 -1
  4. package/package.json +3 -6
  5. package/skills/fui/SKILL.md +9 -41
  6. package/skills/fui-skill/SKILL.md +95 -225
  7. package/skills/fui-skill/assets/projectdefaultstyle-3.0.css +555 -0
  8. package/skills/fui-skill/assets/projectdefaultstyle.css +207 -235
  9. package/skills/fui-skill/references/INDEX.md +105 -137
  10. package/skills/fui-skill/references/advanced-techniques.md +76 -68
  11. package/skills/fui-skill/references/coding-standards.md +56 -56
  12. package/skills/fui-skill/references/component-design.md +166 -173
  13. package/skills/fui-skill/references/component-quickref.md +61 -60
  14. package/skills/fui-skill/references/component-table.md +128 -117
  15. package/skills/fui-skill/references/components-dialog.md +55 -56
  16. package/skills/fui-skill/references/components-display.md +24 -30
  17. package/skills/fui-skill/references/components-echart.md +186 -261
  18. package/skills/fui-skill/references/components-input.md +72 -96
  19. package/skills/fui-skill/references/controls-patterns.md +196 -342
  20. package/skills/fui-skill/references/controls-styling-vocabulary.md +130 -97
  21. package/skills/fui-skill/references/db-table-design.md +24 -28
  22. package/skills/fui-skill/references/db-workflow.md +191 -390
  23. package/skills/fui-skill/references/default-function.md +169 -128
  24. package/skills/fui-skill/references/design-modes.md +35 -63
  25. package/skills/fui-skill/references/echart-templates.md +204 -196
  26. package/skills/fui-skill/references/fastproject.md +62 -60
  27. package/skills/fui-skill/references/fsheet.md +109 -124
  28. package/skills/fui-skill/references/fullstack-workflow.md +90 -128
  29. package/skills/fui-skill/references/module-data-patterns.md +31 -40
  30. package/skills/fui-skill/references/module-json-anatomy.md +47 -52
  31. package/skills/fui-skill/references/module-structure.md +80 -196
  32. package/skills/fui-skill/references/new-session.md +49 -51
  33. package/skills/fui-skill/references/pdfmake.md +17 -17
  34. package/skills/fui-skill/references/permission-system.md +89 -108
  35. package/skills/fui-skill/references/platform-architecture.md +128 -153
  36. package/skills/fui-skill/references/project-config.md +102 -134
  37. package/skills/fui-skill/references/project-provisioning.md +139 -244
  38. package/skills/fui-skill/references/script-map.md +208 -242
  39. package/skills/fui-skill/references/sql-clr-functions.md +98 -97
  40. package/skills/fui-skill/references/system-design.md +63 -88
  41. package/skills/fui-skill/references/tapi-file-api.md +46 -52
  42. package/skills/fui-skill/references/tapi-permission-patterns.md +51 -53
  43. package/skills/fui-skill/references/tapi-reference.md +132 -207
  44. package/skills/fui-skill/references/tools-registry.md +84 -460
  45. package/skills/fui-skill/references/ui-crosswindow-patterns.md +79 -75
  46. package/skills/fui-skill/references/ui-dialog-patterns.md +98 -72
  47. package/skills/fui-skill/references/ui-layout-patterns.md +26 -26
  48. package/skills/fui-skill/references/ui-patterns.md +71 -83
  49. package/skills/fui-skill/references/ui-screenshot-review.md +63 -62
  50. package/skills/fui-skill/references/ui-table-cell-patterns.md +61 -59
  51. package/skills/fui-skill/references/ui-templates.md +16 -23
  52. package/skills/fui-skill/references/verification.md +236 -246
  53. package/skills/fui-skill/references/watcher-patterns.md +30 -63
  54. package/skills/fui-skill/references/websocket-realtime.md +83 -66
  55. package/skills/fui-skill/scripts/component-3.0.js +298 -131
  56. package/skills/fui-skill/scripts/component.js +277 -271
  57. package/skills/fui-skill/scripts/componentTable-3.0.js +182 -53
  58. package/skills/fui-skill/scripts/componentTable.js +171 -49
  59. package/skills/fui-skill/scripts/defaultfunction-3.0.js +88 -3
  60. package/skills/fui-skill/scripts/defaultfunction.js +88 -3
  61. package/skills/fui-skill/scripts/fsheet.js +38 -0
  62. package/dist/fui-y8an39cn.js +0 -420
  63. package/skills/fui-skill/README.md +0 -112
  64. package/skills/fui-skill/metadata.json +0 -75
  65. package/skills/fui-skill-cli/SKILL.md +0 -139
  66. package/skills/fui-skill-cli/references/INDEX.md +0 -110
  67. package/skills/fui-skill-cli/references/advanced-techniques.md +0 -168
  68. package/skills/fui-skill-cli/references/coding-standards.md +0 -112
  69. package/skills/fui-skill-cli/references/component-design.md +0 -448
  70. package/skills/fui-skill-cli/references/component-quickref.md +0 -78
  71. package/skills/fui-skill-cli/references/component-table.md +0 -248
  72. package/skills/fui-skill-cli/references/components-dialog.md +0 -191
  73. package/skills/fui-skill-cli/references/components-display.md +0 -141
  74. package/skills/fui-skill-cli/references/components-echart.md +0 -316
  75. package/skills/fui-skill-cli/references/components-input.md +0 -335
  76. package/skills/fui-skill-cli/references/controls-patterns.md +0 -701
  77. package/skills/fui-skill-cli/references/controls-styling-vocabulary.md +0 -137
  78. package/skills/fui-skill-cli/references/db-table-design.md +0 -73
  79. package/skills/fui-skill-cli/references/db-workflow.md +0 -288
  80. package/skills/fui-skill-cli/references/default-function.md +0 -425
  81. package/skills/fui-skill-cli/references/design-modes.md +0 -57
  82. package/skills/fui-skill-cli/references/echart-templates.md +0 -489
  83. package/skills/fui-skill-cli/references/fastproject.md +0 -99
  84. package/skills/fui-skill-cli/references/fsheet.md +0 -203
  85. package/skills/fui-skill-cli/references/fullstack-workflow.md +0 -313
  86. package/skills/fui-skill-cli/references/module-data-patterns.md +0 -117
  87. package/skills/fui-skill-cli/references/module-json-anatomy.md +0 -132
  88. package/skills/fui-skill-cli/references/module-structure.md +0 -141
  89. package/skills/fui-skill-cli/references/new-session.md +0 -85
  90. package/skills/fui-skill-cli/references/pdfmake.md +0 -60
  91. package/skills/fui-skill-cli/references/permission-system.md +0 -150
  92. package/skills/fui-skill-cli/references/platform-architecture.md +0 -269
  93. package/skills/fui-skill-cli/references/project-config.md +0 -303
  94. package/skills/fui-skill-cli/references/project-provisioning.md +0 -278
  95. package/skills/fui-skill-cli/references/script-map.md +0 -262
  96. package/skills/fui-skill-cli/references/sql-clr-functions.md +0 -225
  97. package/skills/fui-skill-cli/references/system-design.md +0 -89
  98. package/skills/fui-skill-cli/references/tapi-file-api.md +0 -185
  99. package/skills/fui-skill-cli/references/tapi-permission-patterns.md +0 -156
  100. package/skills/fui-skill-cli/references/tapi-reference.md +0 -474
  101. package/skills/fui-skill-cli/references/tools-registry.md +0 -84
  102. package/skills/fui-skill-cli/references/ui-crosswindow-patterns.md +0 -321
  103. package/skills/fui-skill-cli/references/ui-dialog-patterns.md +0 -255
  104. package/skills/fui-skill-cli/references/ui-layout-patterns.md +0 -176
  105. package/skills/fui-skill-cli/references/ui-patterns.md +0 -303
  106. package/skills/fui-skill-cli/references/ui-screenshot-review.md +0 -95
  107. package/skills/fui-skill-cli/references/ui-table-cell-patterns.md +0 -318
  108. package/skills/fui-skill-cli/references/ui-templates.md +0 -22
  109. package/skills/fui-skill-cli/references/verification.md +0 -236
  110. package/skills/fui-skill-cli/references/watcher-patterns.md +0 -163
  111. package/skills/fui-skill-cli/references/websocket-realtime.md +0 -271
@@ -1,40 +1,37 @@
1
- # FUI Platform Architecture — Cấu tạo & cơ chế phân cấp
1
+ # FUI Platform Architecture
2
2
 
3
- > File này sở hữu: **cấu tạo FUI và phân cấp Project→Module: import/component/set trộn thế nào, `vueData`/`v_Set`, vòng đời runtime**.
3
+ > Owns: **FUI structure and Project→Module hierarchy: how import/component/set merge, `vueData`/`v_Set`, runtime lifecycle**.
4
4
 
5
- Hiểu FUI vận hành thế nào **dưới nắp** để thiết kế đúng ngay từ đầu. Nội dung ở đây rút trực tiếp từ runtime `scripts/fastproject.js` (file chính của nền tảng), `defaultfunction.js` (hàm dùng chung), `component.js`/`componentTable.js` (V3: `componentTable-3.0.js`) — đăng ký component lõi có sẵn (`f-table`, `t-*`, dialog, editor...). `f-echart` (`fechart.js`) và `f-sheet` (`fsheet.js`) là hai component **tách file riêng, nạp qua import khai trong module/project**, không tự động load như phần lõi. Đây là **nguồn sự thật** — không suy từ training data.
5
+ Source of truth (not training data): runtime `scripts/fastproject.js` (main), `defaultfunction.js` (shared functions), `component.js`/`componentTable.js` (V3: `componentTable-3.0.js`) — core components (`f-table`, `t-*`, dialog, editor...). `f-echart` (`fechart.js`) and `f-sheet` (`fsheet.js`) are **separate files loaded via imports declared in module/project**, not auto-loaded.
6
6
 
7
- > Đọc file này TRƯỚC khi thiết kế hệ thống/module. Sau đó: cấu hình từng phần → [module-json-anatomy.md](module-json-anatomy.md); project.json & set → [project-config.md](project-config.md); pattern UI thực tế → [ui-patterns.md](ui-patterns.md) (ưu tiên cao — đã tinh chỉnh qua thực chiến).
7
+ > Read BEFORE designing a system/module. Then: per-part config → [module-json-anatomy.md](module-json-anatomy.md); project.json & set → [project-config.md](project-config.md); UI patterns → [ui-patterns.md](ui-patterns.md) (high priority, battle-tested).
8
8
 
9
- ---
9
+ ## 1. What FUI is
10
10
 
11
- ## 1. FUI là gì
11
+ Metadata-driven low-code: each page (module) declares UI + logic in `module.json`; `fastproject.js` builds the Vue 2 + Vuetify DOM from it. Declare only — never hand-write a Vue component per page.
12
12
 
13
- FUI (Framework UI) là nền tảng low-code **metadata-driven**: mỗi trang (module) mô tả UI + logic bằng JSON (`module.json`), runtime `fastproject.js` đọc JSON đó và tự dựng DOM Vue 2 + Vuetify. Không viết Vue component thủ công cho từng trang — chỉ khai báo.
13
+ Page load order (pre-bundled, **never re-import**):
14
14
 
15
- Một trang FUI khi chạy nạp theo thứ tự (đã bundle sẵn, **không import lại**):
16
- 1. Thư viện nền: jQuery, Lodash (`_`), Moment, Numeral, Vuetify, vue-toast, jquery-confirm
17
- 2. `defaultfunction.js` — hàm tiện ích (`openWindow`, `CALL`, `confirm`, `showMessage`, `ajaxCALL`, `jsonToExcel`...)
18
- 3. `component.js` + `componentTable.js` — đăng ký toàn bộ component `f-*` / `t-*`
19
- 4. `fastproject.js` — engine: đọc `module.json`, merge config, dựng DOM, chạy action, gắn watch
20
- 5. Data của trang: `$projectData` (project.json), `$moduleUI` (module.json), `$projectGroupSetting`
15
+ 1. jQuery, Lodash (`_`), Moment, Numeral, Vuetify, vue-toast, jquery-confirm
16
+ 2. `defaultfunction.js` — utilities (`openWindow`, `CALL`, `confirm`, `showMessage`, `ajaxCALL`, `jsonToExcel`...)
17
+ 3. `component.js` + `componentTable.js` — register all `f-*` / `t-*`
18
+ 4. `fastproject.js` — read `module.json`, merge config, build DOM, run actions, attach watch
19
+ 5. Page data: `$projectData` (project.json), `$moduleUI` (module.json), `$projectGroupSetting`
21
20
 
22
- ---
21
+ ## 2. Project → Module hierarchy (merge rules — most important)
23
22
 
24
- ## 2. Phân cấp Project → Module (CƠ CHẾ TRỘN — quan trọng nhất)
23
+ **Project** (shared) parts auto-merge into every **Module** (one page); on conflict **Module wins**.
25
24
 
26
- FUI có hai cấp: **Project** (dùng chung) và **Module** (một trang). Ba thành phần của Project **tự động nhúng/trộn xuống** mọi Module; khi trùng, **Module chi phối (override)**.
25
+ ### 2.1 `set`
27
26
 
28
- ### 2.1 `set` — project.json trộn vào `set` của module
29
-
30
- Runtime tính config hiệu lực `v_Set` bằng (fastproject.js):
27
+ Effective config `v_Set` (fastproject.js):
31
28
 
32
29
  ```js
33
30
  $.extend(vueData.v_Set, $projectGroupSetting, $projectData, $moduleUI.set);
34
31
  // rồi nếu có: $.extend(v_Set, v_Set.domainSetting[domain hiện tại])
35
32
  ```
36
33
 
37
- Thứ tự ưu tiên (sau ghi đè trước):
34
+ Priority (later overrides earlier):
38
35
 
39
36
  ```
40
37
  $projectGroupSetting (cấu hình nhóm project — thấp nhất)
@@ -46,89 +43,79 @@ $moduleUI.set = "set" trong module.json ← ƯU TIÊN CAO NHẤT
46
43
  v_Set.domainSetting[domain] (nếu đang chạy trên domain đó)
47
44
  ```
48
45
 
49
- → Module **kế thừa toàn bộ** config project (menu, apiDomain, style, login...) và chỉ cần khai báo `set` cho những gì khác biệt. Đây là lý do `module.json` của một trang bình thường **không có `set`** (kế thừa hết từ project).
50
-
51
- Chi tiết các thuộc tính của `set`/`v_Set` và project.json: [project-config.md](project-config.md).
52
-
53
- ### 2.2 `imports` — project imports **nối** với module imports
46
+ → Module inherits all project config (menu, apiDomain, style, login...); declare `set` only for differences. A normal page has **no `set`**. Properties: [project-config.md](project-config.md).
54
47
 
55
- Import (JS/CSS) khai báo ở cấp project **và** cấp module đều được nạp — không thay thế nhau. Runtime (`addImport`): file `.css` → thêm `<link>`; file khác → nạp như `<script>`.
48
+ ### 2.2 `imports` — appended, not replaced
56
49
 
57
- Thứ tự nạp **không phải** "framework rồi project rồi module": server (`spA_FUI_ModuleDataSelect`) UNION cả **ba** phạm vi — framework (theo V2/V3), project (`ModuleID IS NULL`), module — rồi sort **chung một lần** theo `FileSort, FileName`. Nên một import module-scope có `FileSort` nhỏ vẫn nạp **trước** import project-scope. Phụ thuộc thứ tự (vd `echarts.min.js` phải trước `fechart.js`) → phải thể hiện bằng `FileSort`, đừng trông vào phạm vi.
50
+ Project and module imports both load. `addImport`: `.css` → `<link>`; else `<script>`.
58
51
 
59
- Framework tự xưng `FileSort` thấp (~1-10). `file_import_new`/`file_import_update` tự bảo vệ ngưỡng này ở code level (`resolveImportSort`, `src/tools/module.ts`): `fileSort` bỏ trống → mặc định an toàn theo scope (project ≥ 20, module ≥ 50); truyền một giá trị thấp hơn ngưỡng đó → tự nâng lên, kèm ghi chú `ℹ️` trong kết quả tool. Không có cách nào truyền một `FileSort` đủ thấp để chen trước framework qua hai tool này — nếu thật sự cần thứ tự sát framework, phải deploy trực tiếp qua route khác ngoài MCP.
52
+ Order is **not** framework → project → module: server (`spA_FUI_ModuleDataSelect`) UNIONs framework (per V2/V3), project (`ModuleID IS NULL`) and module scopes, then sorts **once** by `FileSort, FileName`. A module import with small `FileSort` loads **before** a project import. Express order dependencies (e.g. `echarts.min.js` before `fechart.js`) with `FileSort`, never via scope.
60
53
 
61
- - Import project-scope: dùng chung cho mọi module (thư viện chung).
62
- - Import module-scope: chỉ trang đó (vd `echarts.min.js` + `fechart.js` cho trang có `f-echart`).
63
- - Module thật thường có `imports/_imports.json` = `[]` khi chỉ dùng thư viện bundle sẵn.
54
+ Framework uses `FileSort` ~1-10. `fui import new`/`fui import update` guard this in code (`resolveImportSort`, `src/tools/module.ts`): empty sort → scope default (project ≥ 20, module ≥ 50); lower value → raised, with an `ℹ️` note in output. They cannot place an import before the framework — if truly needed, deploy via a route outside fui.
64
55
 
65
- > Thêm/bỏ component cần import (f-echart, f-file-upload, f-editor...) → luôn `file_import_list` rồi `file_import_new`/`file_import_delete`. Bảng import: [component-quickref.md](component-quickref.md).
56
+ - Project-scope: shared libs for all modules.
57
+ - Module-scope: that page only (e.g. `echarts.min.js` + `fechart.js` for `f-echart`).
58
+ - `imports/_imports.json` = `[]` is normal when only bundled libs are used.
66
59
 
67
- #### Hai loại import: CDN/URL vs Nội dung upload (`ContentType`)
60
+ > Adding/removing a component that needs imports (f-echart, f-file-upload, f-editor...) → always `fui import list`, then `fui import new`/`fui import delete`. Import table: [component-quickref.md](component-quickref.md).
68
61
 
69
- Một import record trong FUI tồn tại dưới **một trong hai dạng** — phân biệt ngay ở `ContentType`:
62
+ #### Import kinds by `ContentType`
70
63
 
71
- | Dạng | `ContentType` | Nguồn | Tool chỉnh sửa nội dung |
72
- |---|---|---|---|
73
- | **Tham chiếu CDN / URL** | rỗng hoặc không phải JS/CSS | URL ngoài (jsdelivr, cdnjs, custom server...) — không có file local | `file_import_update` (chỉ sửa metadata: url, sort, tên) |
74
- | **Nội dung đã upload** | `text/javascript` / `text/css` | File lưu trên server FUI, có `fileID` và `filePath` local | `file_import_upload_content` (ghi đè nội dung) |
64
+ | Kind | `ContentType` | Source | Edit with |
65
+ | ----------------------- | ------------------------------ | --------------------------------------------------------- | ---------------------------------------------------- |
66
+ | **CDN / URL reference** | empty or not JS/CSS | External URL (jsdelivr, cdnjs, custom...) — no local file | `fui import update` (metadata only: url, sort, name) |
67
+ | **Uploaded content** | `text/javascript` / `text/css` | Stored on FUI server; has `fileID` and local `filePath` | `fui import upload` (overwrite content) |
75
68
 
76
- **Hệ quả thực tế — khi người dùng đính kèm file JS/CSS trong chat:**
69
+ User attaches a JS/CSS file and asks for an import:
77
70
 
78
71
  ```
79
- User đính kèm file.js → nhờ AI tạo import
72
+ ❌ WRONG: fui import new --content-type link --name "<some url>"
73
+ → creates a CDN reference; file.js is never stored on the server
80
74
 
81
- ❌ SAI: file_import_new({ url: "<url nào đó>" })
82
- → tạo CDN reference, file.js không được lưu lên server
83
-
84
- ✅ ĐÚNG:
85
- 1. file_import_new({ ... }) → tạo metadata (tên, sort, scope)
86
- 2. file_import_upload_content(fileId, nộidung) → upload nội dung file lên server FUI
75
+ ✅ RIGHT:
76
+ 1. fui import new ... --content-type text/javascript → metadata (name, sort, scope)
77
+ 2. fui import upload <fileId> -f file.js → upload content to FUI server
87
78
  ```
88
79
 
89
- - `file_import_upload_content` đồng bộ nội dung tới **mọi thư mục `imports/` local** đang khai `fileID` đó — không cần gọi lại tool cho từng scope.
90
- - Import dạng CDN (URL ngoài): dùng `file_import_update` nếu muốn đổi URL, sort, hay tên — **không thể** upload content vào record này.
91
- - Dùng `file_import_get` để biết một import đang ở dạng nào (xem trường `ContentType` và `FilePath` trong kết quả).
92
-
93
- > Kiểm tra trước khi thao tác: `file_import_list` liệt kê mọi import kèm `ContentType` — nhìn vào đó là biết ngay nên gọi tool nào tiếp theo.
80
+ (Flags: `fui import new --help`.)
94
81
 
95
- ### 2.3 `components` — component **dùng chung toàn project**
82
+ - `fui import upload` syncs to **every local `imports/`** declaring that `fileID` — no per-scope repeat.
83
+ - CDN imports: change URL/sort/name via `fui import update`; content **cannot** be uploaded into them.
84
+ - `fui import get` shows the kind (`ContentType`, `FilePath`); `fui import list` shows `ContentType` for all — check it first to pick the next command.
96
85
 
97
- - `component.js` đăng ký sẵn mọi component `f-*`/`t-*` **global**.
98
- - Custom `uc-*.vue` **project-scope** (`{projectId}/components/`) → FUI tự load **global ở MỌI module**, gọi thẳng bằng tên (không khai báo `components:{}`).
99
- - `uc-*.vue` **module-scope** (`{moduleId}/components/`) → chỉ dùng trong module đó.
100
- - Trùng tên → bản module-scope chi phối trong phạm vi module đó.
86
+ ### 2.3 `components`
101
87
 
102
- > Component design & scope: [component-design.md](component-design.md).
88
+ - `component.js` registers all `f-*`/`t-*` **globally**.
89
+ - Project-scope `uc-*.vue` (`{projectId}/components/`) → auto-loaded globally in **every** module, used by name (no `components:{}`).
90
+ - Module-scope `uc-*.vue` (`{moduleId}/components/`) → that module only.
91
+ - Same name → module-scope wins in that module.
103
92
 
104
- ### 2.4 Bảng tóm tắt phân cấp
93
+ > Design & scope: [component-design.md](component-design.md).
105
94
 
106
- | Thành phần | Project cung cấp | Trộn vào module thế nào | Khi trùng |
107
- |---|---|---|---|
108
- | **set / config** | `project.json` (khối `data`) | Trộn vào `v_Set`, rồi `module.set` | **Module.set thắng** |
109
- | **imports** | project `_imports.json` | **Nối thêm** vào import module | Cả hai đều nạp |
110
- | **components** | `uc-*.vue` project-scope + `f-*`/`t-*` global | Auto-load global mọi module | Module-scope thắng |
95
+ ### 2.4 Summary
111
96
 
112
- ---
97
+ | Part | Project provides | Merge | On conflict |
98
+ | ---------------- | --------------------------------------------- | ------------------------------- | ------------------- |
99
+ | **set / config** | `project.json` (`data`) | Into `v_Set`, then `module.set` | **Module.set wins** |
100
+ | **imports** | project `_imports.json` | **Appended** to module imports | Both load |
101
+ | **components** | project-scope `uc-*.vue` + global `f-*`/`t-*` | Global in every module | Module-scope wins |
113
102
 
114
- ## 3. Runtime state có sẵn (`vueData`)
103
+ ## 3. Built-in state (`vueData`)
115
104
 
116
- `fastproject.js` khởi tạo sẵn các biến này trong `vueData` — dùng được ngay trong `module.json`/`script.js`, không cần khai báo:
105
+ Pre-initialized; use directly in `module.json`/`script.js`:
117
106
 
118
- | Biến | Ý nghĩa |
119
- |---|---|
120
- | `user` | Thông tin user đăng nhập (fetch từ `v_Set.userInfo`) — xem cấu trúc bên dưới |
121
- | `v_Set` | Config hiệu lực của trang (mục 2.1) — xem [project-config.md](project-config.md) |
122
- | `p_domain` | Hostname hiện tại (vd `tsa.example.vn`) |
123
- | `p_router` / `p_routers` | Path hiện tại (`/manager/schedule-assignment`) / mảng segment (`["manager","schedule-assignment"]`) |
124
- | `p_params` | Query string (`?...`) |
125
- | `p_urlReferrer` | URL trang giới thiệu |
126
- | `v_Loading` / `v_LoadingOverlay` | Trạng thái loading khi gọi API (tự quản lý) |
127
- | `v_containerOn` | Bật/tắt vùng nội dung chính |
107
+ | Variable | Meaning |
108
+ | -------------------------------- | -------------------------------------------------------------------------------------- |
109
+ | `user` | Logged-in user (from `v_Set.userInfo`) |
110
+ | `v_Set` | Effective page config (§2.1) — [project-config.md](project-config.md) |
111
+ | `p_domain` | Hostname (e.g. `tsa.example.vn`) |
112
+ | `p_router` / `p_routers` | Path (`/manager/schedule-assignment`) / segments (`["manager","schedule-assignment"]`) |
113
+ | `p_params` | Query string (`?...`) |
114
+ | `p_urlReferrer` | Referrer URL |
115
+ | `v_Loading` / `v_LoadingOverlay` | API loading state (self-managed) |
116
+ | `v_containerOn` | Toggle main content area |
128
117
 
129
- ### Cấu trúc `vueData` thực tế (mẫu)
130
-
131
- Runtime khởi tạo sẵn `p_*`, `user`, `v_Set`. Đây là một `vueData` thật (đã rút gọn) — dùng để biết chính xác đường dẫn khi tham chiếu:
118
+ Real `vueData` (trimmed) — use for exact paths:
132
119
 
133
120
  ```json
134
121
  {
@@ -165,24 +152,24 @@ Runtime khởi tạo sẵn `p_*`, `user`, `v_Set`. Đây là một `vueData` th
165
152
  }
166
153
  ```
167
154
 
168
- **Trường của `user`** (thay đổi tùy `userInfo` endpoint, nhưng thường gồm): `UserID`, `UserName`, `LastName`, `FirstName`, `Phone`, `Email`, `GroupID`, `DepartmentID`, `ClassID`, `SystemRight` (int), `FunctionRight` (**mảng string**, vd `["10","14"]`), `LastLogin`. Một số hệ thống có thêm `Sex`.
155
+ `user` fields depend on the `userInfo` endpoint; usually `UserID`, `UserName`, `LastName`, `FirstName`, `Phone`, `Email`, `GroupID`, `DepartmentID`, `ClassID`, `SystemRight` (int), `FunctionRight` (**string array**, e.g. `["10","14"]`), `LastLogin`; some systems add `Sex`.
169
156
 
170
- > **Lưu ý dùng:** `user.SystemRight` là **số** (so sánh `>= 2`); `user.FunctionRight` là **mảng chuỗi** (kiểm tra bằng `.includes('10')` hoặc `rightTest`). Tham chiếu trong controls: `vueData.user.UserID`, `vueData.user.SystemRight`, `vueData.v_Set.apiDomain`...
157
+ > `user.SystemRight` is a **number** (compare `>= 2`); `user.FunctionRight` is a **string array** (`.includes('10')` or `rightTest`). In controls: `vueData.user.UserID`, `vueData.user.SystemRight`, `vueData.v_Set.apiDomain`...
171
158
 
172
- ### API lấy thông tin user (userInfo endpoint)
159
+ ### userInfo endpoint
173
160
 
174
- FUI dùng database phân quyền riêng, truy cập qua **apiName/Alias `acc`**. Endpoint lấy thông tin user và quyền hạn trên một project có cấu trúc:
161
+ Permission DB is reached via **apiName/Alias `acc`**:
175
162
 
176
163
  ```
177
164
  {apiDomain}/acc/userinfo/{project_apiName}
178
165
  ```
179
166
 
180
- - `{apiDomain}` — domain tAPI của hệ thống (lấy từ `vueData.v_Set.apiDomain`)
181
- - `acc` — alias cố định cho database phân quyền (không đổi)
182
- - `userinfo` — tên API lấy thông tin user
183
- - `{project_apiName}` — apiName/code của project (do admin cấu hình, ví dụ: `quansinh`, `ts`, `qlsv`)
167
+ - `{apiDomain}` — tAPI domain (`vueData.v_Set.apiDomain`)
168
+ - `acc` — fixed permission-DB alias
169
+ - `userinfo` — API name
170
+ - `{project_apiName}` — project apiName/code (admin-set, e.g. `quansinh`, `ts`, `qlsv`)
184
171
 
185
- **Cách dùng:** khai báo `userInfo` trong `project.json` (field `set`) hoặc `module.json` (field `set`). FUI tự fetch khi trang load và gán kết quả vào `vueData.user`.
172
+ Declare `userInfo` in `set` of `project.json` or `module.json`; FUI fetches it on load into `vueData.user`.
186
173
 
187
174
  ```json
188
175
  // project.json → set
@@ -191,44 +178,40 @@ FUI dùng database phân quyền riêng, truy cập qua **apiName/Alias `acc`**.
191
178
  }
192
179
  ```
193
180
 
194
- Sau khi khai báo, toàn bộ thông tin user có sẵn trong `vueData.user`:
195
-
196
181
  ```js
197
- vueData.user.UserID // mã nhân viên/sinh viên
198
- vueData.user.UserName // tên đăng nhập
199
- vueData.user.SystemRight // quyền hệ thống (int 0–9)
200
- vueData.user.FunctionRight // mảng quyền chức năng ["1","2","10",...]
201
- vueData.user.DepartmentID // mã đơn vị
182
+ vueData.user.UserID; // mã nhân viên/sinh viên
183
+ vueData.user.UserName; // tên đăng nhập
184
+ vueData.user.SystemRight; // quyền hệ thống (int 0–9)
185
+ vueData.user.FunctionRight; // mảng quyền chức năng ["1","2","10",...]
186
+ vueData.user.DepartmentID; // mã đơn vị
202
187
  ```
203
188
 
204
- **Dùng trong controls (v-if ẩn/hiện theo quyền):**
189
+ In controls (`v-if` by right):
205
190
 
206
191
  ```json
207
192
  { "col": { "v-if": "vueData.user.SystemRight >= 5" } }
208
193
  { "col": { "v-if": "vueData.user.FunctionRight.includes('10')" } }
209
194
  ```
210
195
 
211
- **Dùng trong action IN (truyền vào API):**
196
+ In action `IN`:
212
197
 
213
198
  ```json
214
199
  { "API": "SP_GetDuLieu", "IN": { "UserID": "vueData.user.UserID", "DeptID": "vueData.user.DepartmentID" } }
215
200
  ```
216
201
 
217
- > **Lưu ý:** `@sys_UserID`, `@sys_UserName`, `@sys_GroupID`... được tAPI tự inject vào mọi SP — không cần truyền thủ công qua `IN`. Chỉ tham chiếu `vueData.user.*` khi cần dùng trong logic JS/Vue phía client.
218
-
219
- ### Tham số URL tự inject vào `vueData`
202
+ > tAPI auto-injects `@sys_UserID`, `@sys_UserName`, `@sys_GroupID`... into every SP — never pass them via `IN`. Use `vueData.user.*` only for client-side JS/Vue logic.
220
203
 
221
- `buildParamURL()` đọc mọi query param `?key=value` và gán `vueData[key] = value` **trước khi** `data[]` chạy. → Module con mở qua `openWindow`/`redirect` chỉ cần khai báo biến trùng tên param rồi `{ "CALL": "apiLoad" }` ở cuối `data[]`. (Xem [ui-crosswindow-patterns.md](ui-crosswindow-patterns.md).)
204
+ ### URL params → `vueData`
222
205
 
223
- ### Quyền của user
206
+ `buildParamURL()` sets `vueData[key] = value` for each `?key=value` **before** `data[]` runs. A child module opened via `openWindow`/`redirect` just declares same-named variables and ends `data[]` with `{ "CALL": "apiLoad" }` ([ui-crosswindow-patterns.md](ui-crosswindow-patterns.md)).
224
207
 
225
- FUI có 2 loại quyền độc lập — `SystemRight` (cấp bậc trên project) và `FunctionRight` (quyền theo từng chức năng cụ thể), cả hai định nghĩa trong database phân quyền trung tâm (alias `acc`, `{project_apiName}` = APIName của project trong `tblModules`). Runtime: `vueData.user.SystemRight` (int)/`vueData.user.FunctionRight` (mảng string) dùng cho `v-if` và `right` trong menu; hàm `rightTest({ SystemRight:[...], FunctionRight:[...] })` kiểm tra giao quyền.
208
+ ### User rights
226
209
 
227
- **Khái niệm đầy đủ (SystemRight vs FunctionRight), cấu trúc `tblSysRight`/`tblFunction`, và 4 MCP tool quản lý định nghĩa quyền (`right_system_list/set`, `right_function_list/set`):** xem [permission-system.md](permission-system.md).
210
+ Two independent kinds, both in the central permission DB (alias `acc`, `{project_apiName}` = project APIName in `tblModules`): `SystemRight` (rank on project, int) and `FunctionRight` (per function, string array). Use in `v-if` and menu `right`; `rightTest({ SystemRight:[...], FunctionRight:[...] })` checks intersection.
228
211
 
229
- ---
212
+ Concepts, `tblSysRight`/`tblFunction`, managing definitions (`fui right system|function list|new|update|delete`): [permission-system.md](permission-system.md).
230
213
 
231
- ## 4. Vòng đời khởi tạo một trang (fastproject.js)
214
+ ## 4. Page init lifecycle (fastproject.js)
232
215
 
233
216
  ```
234
217
  $(document).ready → loadModuleInfo()
@@ -245,50 +228,42 @@ $(document).ready → loadModuleInfo()
245
228
  - Kiểm tra đăng nhập (v_Set.login)
246
229
  ```
247
230
 
248
- Hệ quả thiết kế:
249
- - `data[]` chạy tuần tự trên xuống; đặt khởi tạo state trước, `{ "CALL": ... }` auto-startup ở cuối.
250
- - Đặt các gán `#PARENT.*` / biến từ URL **trước** các CALL fetch để dữ liệu sẵn sàng.
251
-
252
- ---
253
-
254
- ## 5. Action engine — các key trong một action (tham chiếu nhanh)
255
-
256
- `runAction`/`vueAction` xử lý một object action theo các key sau (nguồn: fastproject.js). Pattern chi tiết + value resolution: **[controls-patterns.md](controls-patterns.md)**.
257
-
258
- | Key | Tác dụng |
259
- |---|---|
260
- | `API` | Gọi endpoint (POST mặc định). Đường dẫn không `http` → tự prepend `v_Set.apiDomain` (`fixURL`) |
261
- | `IN` | Tham số gửi lên (map từ `vueData`) |
262
- | `OUT` | Nơi lưu kết quả. Nếu response chỉ có key `data` và `OUT` là string → tự unwrap `d.data` |
263
- | `METHOD` | Override HTTP method (mặc định POST) |
264
- | `HEADER` | Override header (mặc định `authorization: Bearer awt`) |
265
- | `MESS` | Toast thành công |
266
- | `MESSBOX` | Hộp thoại thông báo (`showMessage`) |
267
- | `CALLBACK` | Action chạy sau khi API/FUN xong |
268
- | `ERROROUT` / `ERRORCALLBACK` | Xử lý nhánh lỗi |
269
- | `CALL` | Gọi action đã đặt tên khác |
270
- | `CONFIRM` / `CANCEL` | Hỏi xác nhận trước, nhánh hủy |
271
- | `IF` / `THEN` / `ELSE` | Rẽ nhánh (điều kiện là JS expression trên vueData) |
272
- | `FUN` (+`IN`/`OUT`/`CALLBACK`) | Gọi hàm global (`openWindow`, `jsonToExcel`, `printPDF`...) |
273
- | `EXE` | Chạy JS thô (dùng dè xẻn) |
274
- | *(object thường)* | Gán trực tiếp vào `vueData` (state set) |
275
-
276
- `json_data_parse` tự parse cột `json_data:Field` trong response thành object (xem [tapi-reference.md](tapi-reference.md)).
277
-
278
- ---
279
-
280
- ## 6. Component & hàm dựng sẵn (điểm vào)
281
-
282
- - **Component `f-*` / `t-*`**: danh mục đầy đủ + import cần thiết → [component-quickref.md](component-quickref.md).
283
- - **Hàm tiện ích global** (`openWindow`, `CALL`, `confirm`, `showMessage`, `ajaxCALL`, `jsonToExcel`, `groupBy`, `pushRouter`, `rightTest`, `printPDF`, `webSocket_Send`...) → [default-function.md](default-function.md).
284
- - **Thư viện toàn cục** (`$`, `_`, `moment`, `numeral`, `Vue.$toast`) → [script-map.md](script-map.md) §0 "Thư viện đã bundled sẵn" — đọc trước khi định thêm CDN.
285
-
286
- ---
287
-
288
- ## 7. Ghi nhớ thiết kế
289
-
290
- - Project cung cấp khung (menu, apiDomain, style, component chung); Module chỉ khai báo phần khác biệt.
291
- - Đừng lặp lại config đã có ở project trong từng module.
292
- - Component dùng >1 module → đặt project-scope (global), không copy vào từng module.
293
- - Import chỉ khai báo ở nơi thực sự dùng; component dùng chung → import project-scope.
294
- - Mọi thứ chạy trên `vueData`; tham chiếu state bằng tiền tố `vueData.` trong controls/attr.
231
+ - `data[]` runs top to bottom: state init first, auto-startup `{ "CALL": ... }` last.
232
+ - Put `#PARENT.*` / URL variable assignments **before** fetch CALLs.
233
+
234
+ ## 5. Action keys (quick ref)
235
+
236
+ Handled by `runAction`/`vueAction`. Patterns + value resolution: **[controls-patterns.md](controls-patterns.md)**.
237
+
238
+ | Key | Effect |
239
+ | ------------------------------ | ------------------------------------------------------------------------------------------ |
240
+ | `API` | Call endpoint (POST default). Path without `http` → `v_Set.apiDomain` prepended (`fixURL`) |
241
+ | `IN` | Params (mapped from `vueData`) |
242
+ | `OUT` | Result target. Response with only key `data` + string `OUT` → auto-unwrap `d.data` |
243
+ | `METHOD` | Override HTTP method (default POST) |
244
+ | `HEADER` | Override header (default `authorization: Bearer awt`) |
245
+ | `MESS` | Success toast |
246
+ | `MESSBOX` | Message dialog (`showMessage`) |
247
+ | `CALLBACK` | Runs after API/FUN finishes |
248
+ | `ERROROUT` / `ERRORCALLBACK` | Error branch |
249
+ | `CALL` | Call another named action |
250
+ | `CONFIRM` / `CANCEL` | Confirm first; cancel branch |
251
+ | `IF` / `THEN` / `ELSE` | Branch (JS expression on vueData) |
252
+ | `FUN` (+`IN`/`OUT`/`CALLBACK`) | Global function (`openWindow`, `jsonToExcel`, `printPDF`...) |
253
+ | `EXE` | Raw JS (sparingly) |
254
+ | _(plain object)_ | Assigned into `vueData` |
255
+
256
+ `json_data_parse` auto-parses `json_data:Field` response columns into objects ([tapi-reference.md](tapi-reference.md)).
257
+
258
+ ## 6. Entry points
259
+
260
+ - `f-*` / `t-*` list + required imports → [component-quickref.md](component-quickref.md).
261
+ - Global utilities (`openWindow`, `CALL`, `confirm`, `showMessage`, `ajaxCALL`, `jsonToExcel`, `groupBy`, `pushRouter`, `rightTest`, `printPDF`, `webSocket_Send`...) → [default-function.md](default-function.md).
262
+ - Global libs (`$`, `_`, `moment`, `numeral`, `Vue.$toast`) → [script-map.md](script-map.md) §0 — read before adding any CDN.
263
+
264
+ ## 7. Design rules
265
+
266
+ - Project provides the frame (menu, apiDomain, style, shared components); Module declares only differences — never repeat project config per module.
267
+ - Component used by >1 module → project-scope, never copied per module.
268
+ - Declare imports only where used; shared component → project-scope import.
269
+ - Everything runs on `vueData`; reference state with the `vueData.` prefix in controls/attrs.