odant-work 1.0.90 → 1.0.92

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 (326) hide show
  1. package/#system/package-manifest.json +275 -246
  2. package/$server/$folder/$class/$data/$catalog/$folder/$class/$data/$catalog/$virtual/class.js +4 -0
  3. package/$server/$folder/$class/$data/$catalog/$folder/$class/$data/$catalog/class.js +4 -0
  4. package/$server/$folder/$class/$data/$catalog/$virtual/$folder/$class/$data/$catalog/$virtual/class.js +4 -0
  5. package/$server/$folder/$class/$data/$catalog/$virtual/class.js +8 -0
  6. package/{MODULES/Register/CATALOGS/$catalog/$folder/$class → $server/$folder/$class/$data}/$catalog/class.js +1 -0
  7. package/$server/$folder/$class/$data/$operation/$folder/$class/$data/$operation/class.js +4 -0
  8. package/{MODULES/Register/OPERATIONS/$operation/$folder/$class → $server/$folder/$class/$data}/$operation/class.js +1 -0
  9. package/$server/$folder/$class/$data/$register/$account/$folder/$class/$data/$register/$account/class.js +4 -0
  10. package/$server/$folder/$class/$data/$register/$account/class.js +8 -0
  11. package/$server/$folder/$class/$data/$register/$folder/$class/$data/$register/$account/class.js +4 -0
  12. package/$server/$folder/$class/$data/$register/$folder/$class/$data/$register/class.js +4 -0
  13. package/$server/$folder/$class/$data/$register/class.js +8 -0
  14. package/$server/$folder/$class/$data/$struct/$folder/$class/$data/$struct/class.js +4 -0
  15. package/$server/$folder/$class/$data/$struct/class.js +5 -0
  16. package/$server/$folder/$class/$data/class.js +5 -0
  17. package/$server/$folder/$class/$data/handlers/pages/form/objects/$handler/class.js +2158 -0
  18. package/$server/$folder/$class/$data/handlers/pages/form/objects/object/$handler/class.js +1377 -0
  19. package/$server/$folder/$class/$domain/$folder/$class/$domain/class.js +4 -0
  20. package/$server/$folder/$class/$domain/handlers/methods/restore/$handler/class.js +5 -5
  21. package/$server/$folder/$class/$domain/readme.md +1 -1
  22. package/$server/$folder/$class/$handler/$method/class.js +4 -0
  23. package/$server/$folder/$class/$handler/$timer/class.js +4 -0
  24. package/$server/$folder/$class/$module/$folder/$class/$data/$catalog/class.js +4 -0
  25. package/$server/$folder/$class/$module/$folder/$class/$data/$operation/class.js +4 -0
  26. package/$server/$folder/$class/$module/$folder/$class/$data/$register/class.js +4 -0
  27. package/$server/$folder/$class/$module/$folder/$class/$data/$struct/class.js +4 -0
  28. package/$server/$folder/$class/$module/$folder/$class/$domain/class.js +4 -0
  29. package/$server/$folder/$class/$module/$folder/$class/$module/class.js +4 -0
  30. package/$server/$folder/$class/$module/class.js +418 -6
  31. package/$server/$folder/$class/{handlers/pages/form/system/$handler/tabs/mcp.js → $module/handlers/pages/form/system/mcp/$handler/class.js} +261 -220
  32. package/$server/$folder/$class/$module/handlers/pages/form/system/modules/$handler/class.js +7 -0
  33. package/$server/$folder/$class/$structure/$folder/$class/$structure/class.js +4 -0
  34. package/$server/$folder/$class/$structure/$organization/$folder/$class/$data/$catalog/class.js +4 -0
  35. package/$server/$folder/$class/$structure/$organization/$folder/$class/$data/$operation/class.js +4 -0
  36. package/$server/$folder/$class/$structure/$organization/$folder/$class/$data/$register/class.js +4 -0
  37. package/$server/$folder/$class/$structure/$organization/$folder/$class/$data/$struct/class.js +4 -0
  38. package/$server/$folder/$class/$structure/$organization/$folder/$class/$domain/class.js +4 -0
  39. package/$server/$folder/$class/$structure/$organization/$folder/$class/$module/class.js +4 -0
  40. package/{ORGANIZATIONS/$domain/$folder/$class/$base → $server/$folder/$class/$structure/$organization/$folder/$class/$structure/$organization}/class.js +4 -5
  41. package/$server/$folder/$class/$structure/$organization/$folder/$class/$structure/class.js +4 -0
  42. package/{ORGANIZATIONS/$domain/$folder/$class/$base/$folder/$class/$structure/$base → $server/$folder/$class/$structure/$organization}/class.js +19 -17
  43. package/$server/$folder/$class/$structure/$organization/handlers/pages/form/system/requisites/$handler/class.js +3 -0
  44. package/$server/$folder/$class/$structure/{$base/handlers/pages/site/$handler/site.js → $organization/handlers/pages/site/$handler/class.js} +352 -365
  45. package/$server/$folder/$class/$structure/$project/$folder/$class/$data/$catalog/class.js +4 -0
  46. package/$server/$folder/$class/$structure/$project/$folder/$class/$data/$operation/class.js +4 -0
  47. package/$server/$folder/$class/$structure/$project/$folder/$class/$data/$register/class.js +4 -0
  48. package/$server/$folder/$class/$structure/$project/$folder/$class/$data/$struct/class.js +4 -0
  49. package/$server/$folder/$class/$structure/$project/$folder/$class/$domain/class.js +4 -0
  50. package/$server/$folder/$class/$structure/$project/$folder/$class/$module/class.js +4 -0
  51. package/$server/$folder/$class/$structure/$project/class.js +1 -0
  52. package/$server/$folder/$class/$structure/$project/readme.md +1 -1
  53. package/$server/$folder/$class/$structure/$server/$folder/$class/$domain/class.js +4 -0
  54. package/$server/$folder/$class/$structure/$server/handlers/pages/form/system/database/$handler/class.js +3 -0
  55. package/$server/$folder/$class/{handlers/pages/form/system/$handler/tabs/license.js → $structure/$server/handlers/pages/form/system/license/$handler/class.js} +104 -103
  56. package/$server/$folder/$class/$structure/$server/handlers/pages/site/$handler/{site.js → class.js} +45 -30
  57. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/agent/$handler/class.js +3 -0
  58. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/messengers/$handler/class.js +3 -0
  59. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/modules/$handler/class.js +3 -0
  60. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/profile/$handler/class.js +18 -0
  61. package/$server/$folder/$class/$structure/ai/system.md +1 -1
  62. package/$server/$folder/$class/$structure/class.js +1 -1
  63. package/$server/$folder/$class/$structure/handlers/methods/archive/$handler/class.js +3 -3
  64. package/$server/$folder/$class/$structure/handlers/pages/data/$handler/class.js +309 -8
  65. package/$server/$folder/$class/$structure/handlers/pages/explorer/$handler/class.js +15 -4
  66. package/$server/$folder/$class/$structure/handlers/pages/form/calendar/$handler/class.js +1281 -7
  67. package/$server/$folder/$class/$structure/handlers/pages/form/chat/$handler/class.js +2216 -6
  68. package/$server/$folder/$class/$structure/handlers/pages/form/email/$handler/class.js +1304 -6
  69. package/$server/$folder/$class/$structure/handlers/pages/form/email/$handler/methods/refresh/$method/class.js +1 -1
  70. package/$server/$folder/$class/$structure/handlers/pages/form/search/$handler/class.js +305 -9
  71. package/$server/$folder/$class/{handlers/pages/form/system/$handler/tabs/agent.js → $structure/handlers/pages/form/system/agent/$handler/class.js} +329 -320
  72. package/$server/$folder/$class/{handlers/pages/form/system/$handler/tabs/database.js → $structure/handlers/pages/form/system/database/$handler/class.js} +510 -577
  73. package/$server/$folder/$class/{handlers/pages/form/system/$handler/tabs/messengers.js → $structure/handlers/pages/form/system/messengers/$handler/class.js} +143 -144
  74. package/$server/$folder/$class/$structure/handlers/pages/form/system/modules/$handler/class.js +270 -0
  75. package/$server/$folder/$class/$structure/handlers/pages/form/system/staff/$handler/class.js +2114 -0
  76. package/$server/$folder/$class/$structure/handlers/pages/site/$handler/class.js +229 -4
  77. package/$server/$folder/$class/$structure/handlers/pages/site/$handler/readme.md +1 -1
  78. package/$server/$folder/$class/$structure/readme.md +3 -3
  79. package/$server/$folder/$class/$users/$folder/$class/$structure/$user/class.js +4 -0
  80. package/$server/$folder/$class/$users/class.js +4 -0
  81. package/$server/$folder/$class/ai/agents/integrator-1c.md +1 -1
  82. package/$server/$folder/$class/ai/agents/it-admin.md +1 -1
  83. package/$server/$folder/$class/ai/agents/org-architect.md +4 -4
  84. package/$server/$folder/$class/ai/agents/readme.md +1 -1
  85. package/$server/$folder/$class/ai/agents/schema-validator.md +2 -2
  86. package/$server/$folder/$class/ai/skills/lan-inventory.md +2 -2
  87. package/$server/$folder/$class/ai/skills/org-structure.md +1 -1
  88. package/$server/$folder/$class/ai/skills/printer-setup.md +1 -1
  89. package/$server/$folder/$class/ai/skills/telegram-notify.md +2 -2
  90. package/$server/$folder/$class/ai/skills/work-scenarios.md +3 -3
  91. package/$server/$folder/$class/ai/system.md +14 -8
  92. package/$server/$folder/$class/class.js +2 -6
  93. package/$server/$folder/$class/handlers/pages/form/folder/$handler/class.js +3 -0
  94. package/$server/$folder/$class/handlers/pages/form/system/$handler/class.js +2 -4
  95. package/$server/$folder/$class/handlers/pages/form/system/files/$handler/class.js +7 -0
  96. package/$server/$folder/$class/handlers/pages/form/system/requisites/$handler/class.js +100 -0
  97. package/$server/$folder/$class/handlers/pages/storage/$handler/class.js +25 -6
  98. package/$server/$folder/$file/$data/handlers/pages/form/editor/$handler/class.js +32 -5
  99. package/$server/$folder/$file/$devs/handlers/pages/form/file/$handler/class.js +31 -3
  100. package/$server/$folder/$file/$ics/handlers/pages/form/file/$handler/class.js +11 -3
  101. package/$server/$folder/$file/$ipynb/handlers/pages/form/file/$handler/class.js +83 -3
  102. package/$server/$folder/$file/$md/handlers/pages/form/file/$handler/class.js +61 -3
  103. package/$server/$folder/$file/$office/handlers/pages/form/file/$handler/class.js +1699 -2
  104. package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/class.js +827 -2
  105. package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/readme.md +1 -1
  106. package/$server/$folder/$file/handlers/pages/form/file/$handler/class.js +33 -3
  107. package/$server/$folder/$file/handlers/pages/form/folder/$handler/class.js +3 -0
  108. package/$server/$folder/handlers/methods/create/$handler/class.js +5 -5
  109. package/$server/$folder/handlers/pages/form/$handler/class.js +2467 -3
  110. package/$server/$folder/handlers/pages/form/folder/$handler/class.js +22 -0
  111. package/$server/$folder/handlers/readme.md +1 -1
  112. package/$server/$folder/lib/chat-item/chat-item.js +5 -10
  113. package/$server/$folder/lib/consultant/consultant.js +7 -10
  114. package/$server/$folder/lib/explorer/explorer.js +1 -1
  115. package/$server/$folder/lib/icon/icon.js +1 -1
  116. package/$server/$folder/lib/menu/menu.js +3 -2
  117. package/$server/$folder/lib/messenger-settings/messenger-settings.js +4 -4
  118. package/$server/$folder/lib/node/node.js +3 -3
  119. package/$server/$folder/lib/prompt-bar/prompt-bar.js +2 -2
  120. package/$server/$folder/lib/role/role.js +1 -2
  121. package/$server/$folder/lib/security/admin/admin.js +3 -3
  122. package/$server/$folder/lib/security/security.js +4 -4
  123. package/$server/$folder/lib/security/users/users.js +2 -5
  124. package/$server/$folder/lib/site-loc/site-loc.js +3 -3
  125. package/$server/$folder/lib/tree/tree.js +14 -22
  126. package/$server/class.js +1 -0
  127. package/AGENTS.md +21 -13
  128. package/{$server/$folder/$class/handlers/pages/form/system/$handler/tabs/ai-model.js → MODELS/$ai/$folder/$class/$ai/handlers/pages/form/system/ai/$handler/class.js} +385 -425
  129. package/{$server/$folder/$class/handlers/pages/form/system/$handler/tabs/ai-provider.js → MODELS/$ai/$folder/$class/$provider/handlers/pages/form/system/ai/$handler/class.js} +157 -161
  130. package/{$server/$folder/$class/handlers/pages/form/system/$handler/tabs/ai-root.js → MODELS/$ai/handlers/pages/form/system/ai/$handler/class.js} +34 -33
  131. package/{$server/$folder/$class/handlers/pages/form/system/$handler/tabs/ai-local.js → MODELS/Local/$provider/handlers/pages/form/system/ai/$handler/class.js} +572 -622
  132. package/MODULES/$domain/class.js +85 -4
  133. package/MODULES/$domain/handlers/pages/form/system/mcp/$handler/class.js +7 -0
  134. package/MODULES/$domain/readme.md +7 -6
  135. package/{SERVICES/1C/$service → MODULES/1C/$module}/class.js +7 -1
  136. package/MODULES/2GIS/$module/class.js +32 -0
  137. package/MODULES/2GIS/$module/readme.md +57 -0
  138. package/{SERVICES/Bitrix24/$service → MODULES/Bitrix24/$module}/class.js +7 -2
  139. package/{SERVICES/CBR/$service → MODULES/CBR/$module}/class.js +5 -0
  140. package/{SERVICES/DaData/$service → MODULES/DaData/$module}/class.js +9 -3
  141. package/MODULES/Geo//320/232/320/260/321/200/321/202/320/260/$catalog/handlers/pages/form/map/$handler/class.js +648 -21
  142. package/MODULES/KLADR/$module/handlers/pages/form/kladr/$handler/class.js +140 -6
  143. package/{SERVICES/Marketplaces/$service → MODULES/Marketplaces/$domain}/class.js +1 -1
  144. package/{SERVICES/Marketplaces/Ozon/$service → MODULES/Marketplaces/Ozon/$module}/class.js +1 -1
  145. package/{SERVICES/Marketplaces/Wildberries/$service → MODULES/Marketplaces/Wildberries/$module}/class.js +1 -1
  146. package/{SERVICES/Marketplaces/YandexMarket/$service → MODULES/Marketplaces/YandexMarket/$module}/class.js +1 -1
  147. package/MODULES/Process/$module/readme.md +1 -1
  148. package/MODULES/Process//320/227/320/260/320/264/320/260/321/207/320/270 /320/270 /321/215/321/202/320/260/320/277/321/213/$catalog/handlers/pages/form/gantt/$handler/class.js" +305 -6
  149. package/MODULES/Process//320/227/320/260/320/264/320/260/321/207/320/270 /320/270 /321/215/321/202/320/260/320/277/321/213/$catalog/handlers/pages/form/scheduler/$handler/class.js" +241 -6
  150. package/MODULES/Process//320/241/321/205/320/265/320/274/321/213 /320/277/321/200/320/276/321/206/320/265/321/201/321/201/320/276/320/262/$catalog/handlers/pages/form/bpmn/$handler/class.js" +515 -16
  151. package/MODULES/Register/CATALOGS/$catalog/$folder/$class/{$virtual → $data/$catalog/$virtual}/class.js +3 -0
  152. package/MODULES/Register/CATALOGS/$catalog/$folder/$class/$data/$catalog/$virtual/handlers/pages/form/objects/$handler/class.js +3 -0
  153. package/MODULES/Register/CATALOGS/$catalog/$folder/$class/{$virtual/handlers/pages/form/virtual/$handler/virtual.js → $data/$catalog/$virtual/handlers/pages/form/virtual/$handler/class.js} +413 -390
  154. package/MODULES/Register/CATALOGS/$catalog/$folder/$class/$data/$catalog/class.js +14 -0
  155. package/MODULES/Register/CATALOGS/$catalog/class.js +7 -14
  156. package/MODULES/Register/CATALOGS//320/241/320/276/321/202/321/200/321/203/320/264/320/275/320/270/320/272/320/270/$virtual/$folder/$class/$data/$catalog/$virtual/class.js +9 -0
  157. package/MODULES/Register/CATALOGS//320/241/320/276/321/202/321/200/321/203/320/264/320/275/320/270/320/272/320/270/$virtual/class.js +0 -7
  158. package/MODULES/Register/CATALOGS//320/241/321/203/320/261/321/212/320/265/320/272/321/202/321/213/$catalog/$folder/$class/$data/$catalog/class.js +11 -0
  159. package/MODULES/Register/CATALOGS//320/241/321/203/320/261/321/212/320/265/320/272/321/202/321/213/$catalog/class.js +0 -9
  160. package/MODULES/Register/OPERATIONS/$operation/$folder/$class/$data/$operation/class.js +16 -0
  161. package/MODULES/Register/OPERATIONS/$operation/class.js +0 -9
  162. package/MODULES/Register/OPERATIONS//320/232/320/260/320/264/321/200/321/213/$operation/$folder/$class/$data/$operation/class.js +8 -0
  163. package/MODULES/Register/OPERATIONS//320/232/320/260/320/264/321/200/321/213/$operation/class.js +4 -10
  164. package/MODULES/Register/OPERATIONS//320/232/320/260/321/201/321/201/320/260/$operation/$folder/$class/$data/$operation/class.js +8 -0
  165. package/MODULES/Register/OPERATIONS//320/232/320/260/321/201/321/201/320/260/$operation/class.js +0 -6
  166. package/MODULES/Register/OPERATIONS//320/232/320/276/320/274/320/274/321/203/320/275/320/270/320/272/320/260/321/206/320/270/320/270/$operation/$folder/$class/$data/$operation/class.js +8 -0
  167. package/MODULES/Register/OPERATIONS//320/232/320/276/320/274/320/274/321/203/320/275/320/270/320/272/320/260/321/206/320/270/320/270/$operation/class.js +4 -10
  168. package/MODULES/Register/OPERATIONS//320/237/320/273/320/260/321/202/320/265/320/266/320/270 /321/201 /321/200/320/260/321/201/321/207/321/221/321/202/320/275/320/276/320/263/320/276 /321/201/321/207/321/221/321/202/320/260/$operation/$folder/$class/$data/$operation/class.js" +10 -0
  169. package/MODULES/Register/OPERATIONS//320/237/320/273/320/260/321/202/320/265/320/266/320/270 /321/201 /321/200/320/260/321/201/321/207/321/221/321/202/320/275/320/276/320/263/320/276 /321/201/321/207/321/221/321/202/320/260/$operation/class.js" +4 -12
  170. package/MODULES/Register/OPERATIONS//320/237/320/276/321/201/321/202/321/203/320/277/320/273/320/265/320/275/320/270/321/217 /320/275/320/260 /321/200/320/260/321/201/321/207/321/221/321/202/320/275/321/213/320/271 /321/201/321/207/321/221/321/202/$operation/$folder/$class/$data/$operation/class.js" +10 -0
  171. package/MODULES/Register/OPERATIONS//320/237/320/276/321/201/321/202/321/203/320/277/320/273/320/265/320/275/320/270/321/217 /320/275/320/260 /321/200/320/260/321/201/321/207/321/221/321/202/320/275/321/213/320/271 /321/201/321/207/321/221/321/202/$operation/class.js" +4 -12
  172. package/MODULES/Register/OPERATIONS//320/240/320/265/320/260/320/273/320/270/320/267/320/260/321/206/320/270/321/217/$operation/$folder/$class/$data/$operation/class.js +24 -0
  173. package/MODULES/Register/OPERATIONS//320/240/320/265/320/260/320/273/320/270/320/267/320/260/321/206/320/270/321/217/$operation/class.js +0 -22
  174. package/MODULES/Register/REGISTER/$register/$folder/$class/{$account/handlers/pages/form/analysis/$handler/analysis.js → $data/$register/$account/handlers/pages/form/analysis/$handler/class.js} +9 -4
  175. package/MODULES/Register/REGISTER/$register/$folder/$class/{$account/handlers/pages/form/postings/$handler/postings.js → $data/$register/$account/handlers/pages/form/postings/$handler/class.js} +845 -753
  176. package/MODULES/Register/REGISTER/$register/$folder/$class/{$account/handlers/pages/form/turnovers/$handler/turnovers.js → $data/$register/$account/handlers/pages/form/turnovers/$handler/class.js} +9 -4
  177. package/MODULES/Register/REGISTER/$register/{$folder/$class/$register/handlers/pages/form/journal/$handler/journal.js → handlers/pages/form/journal/$handler/class.js} +382 -329
  178. package/MODULES/Register/REGISTER/$register/handlers/pages/form/sheet/$handler/class.js +807 -0
  179. package/MODULES/Register/REGISTER/10/$account/$folder/$class/$data/$register/$account/class.js +21 -0
  180. package/MODULES/Register/REGISTER/10/$account/class.js +0 -19
  181. package/MODULES/Register/REGISTER//320/232/320/260/320/264/321/200/321/213/$account/$folder/$class/$data/$register/$account/class.js +14 -0
  182. package/MODULES/Register/REGISTER//320/232/320/260/320/264/321/200/321/213/$account/class.js +4 -16
  183. package/{SERVICES/SearXNG/$service → MODULES/SearXNG/$module}/class.js +5 -0
  184. package/{SERVICES/Yandex/$service → MODULES/Yandex/$module}/class.js +7 -0
  185. package/{SERVICES/YandexDisk/$service → MODULES/YandexDisk/$module}/class.js +8 -2
  186. package/NODES/$node/handlers/pages/form/network/$handler/class.js +122 -5
  187. package/ORGANIZATIONS/$domain/$folder/$class/$structure/$organization/class.js +5 -0
  188. package/ORGANIZATIONS/$domain/class.js +5 -5
  189. package/oda/components/inputs/link/link.js +1 -1
  190. package/package.json +1 -1
  191. package/readme.md +6 -7
  192. package/scripts/check-architecture.mjs +541 -0
  193. package/scripts/cleanup-storage.mjs +1 -1
  194. package/scripts/demo-seed.mjs +3 -3
  195. package/scripts/import-bis.mjs +33 -15
  196. package/scripts/import-delovaya.mjs +26 -14
  197. package/sources/client/class.js +19 -10
  198. package/sources/client/folder.js +10 -22
  199. package/sources/client/handler.js +75 -33
  200. package/sources/data/api.js +9 -10
  201. package/sources/data/classes.js +85 -9
  202. package/sources/data/db.js +10 -6
  203. package/sources/data/print.js +15 -41
  204. package/sources/data/readme.md +5 -5
  205. package/sources/data/schema.js +206 -118
  206. package/sources/data/sql-inspector.js +7 -7
  207. package/sources/host/auth-methods.js +2 -5
  208. package/sources/host/auto-updater.js +1 -2
  209. package/sources/host/babel-merge.js +174 -129
  210. package/sources/host/prewarm.js +1 -1
  211. package/sources/host/watch.js +1 -1
  212. package/sources/index.html +1 -1
  213. package/sources/modules/agent/extensions.js +48 -38
  214. package/sources/modules/agent/index.js +1 -1
  215. package/sources/modules/agent/node-rules.js +69 -41
  216. package/sources/modules/agent/permissions.js +1 -1
  217. package/sources/modules/agent/plugins.js +11 -11
  218. package/sources/modules/agent/resources.js +96 -52
  219. package/sources/modules/agent/tools/net.js +1 -1
  220. package/sources/modules/agent/tools/services.js +7 -7
  221. package/sources/modules/agent/tools/work/access.js +10 -8
  222. package/sources/modules/agent/tools/work/classes.js +26 -47
  223. package/sources/modules/agent/tools/work/common.js +8 -10
  224. package/sources/modules/agent/tools/work/data.js +4 -4
  225. package/sources/modules/agent/triggers.js +1 -1
  226. package/sources/modules/agent/twin-bus.js +4 -4
  227. package/sources/modules/agent/voice.js +1 -1
  228. package/sources/modules/call/call.js +4 -4
  229. package/sources/modules/kladr/index.js +3 -3
  230. package/sources/modules/lan/register.js +7 -7
  231. package/sources/modules/mcp-marketplaces/ozon.js +1 -1
  232. package/sources/modules/mcp-marketplaces/wildberries.js +1 -1
  233. package/sources/modules/mcp-marketplaces/yandex-market.js +1 -1
  234. package/sources/modules/nodes/mount.js +2 -4
  235. package/sources/modules/notify/index.js +18 -18
  236. package/sources/modules/rag/extract.js +9 -2
  237. package/sources/modules/rag/indexer.js +1 -1
  238. package/sources/modules/rag/scope.js +7 -33
  239. package/sources/modules/trainer/dataset.js +2 -2
  240. package/sources/modules/trainer/local-engine.js +1 -1
  241. package/sources/page.html +2 -2
  242. package/sources/readme.md +1 -1
  243. package/sources/server/access/gateway.js +19 -19
  244. package/sources/server/access/invites.js +4 -5
  245. package/sources/server/access/links.js +10 -8
  246. package/sources/server/access/policy.js +65 -39
  247. package/sources/server/access/workplaces.js +20 -14
  248. package/sources/server/chat-threads.js +4 -4
  249. package/sources/server/class/archive.js +15 -15
  250. package/sources/server/class/base-template.js +13 -9
  251. package/sources/server/class/distro.js +3 -4
  252. package/sources/server/class/feed.js +3 -3
  253. package/sources/server/class/mail-calendar.js +9 -8
  254. package/sources/server/class/scaffold.js +110 -60
  255. package/sources/server/class/search.js +2 -2
  256. package/sources/server/class/security.js +76 -94
  257. package/sources/server/class.js +181 -64
  258. package/sources/server/file.js +2 -2
  259. package/sources/server/folder.js +376 -191
  260. package/sources/server/handler.js +52 -13
  261. package/sources/server/logs.js +7 -7
  262. package/sources/server/node.js +12 -43
  263. package/sources/server/server.js +16 -17
  264. package/$server/$folder/$class/$device/class.js +0 -3
  265. package/$server/$folder/$class/$handler/$task/class.js +0 -3
  266. package/$server/$folder/$class/$service/$class/$service/class.js +0 -4
  267. package/$server/$folder/$class/$structure/$base/class.js +0 -10
  268. package/$server/$folder/$class/$structure/$base/roots_1/roots.test +0 -0
  269. package/$server/$folder/$class/$structure/handlers/pages/data/$handler/data.js +0 -313
  270. package/$server/$folder/$class/$structure/handlers/pages/explorer/$handler/explorer.js +0 -16
  271. package/$server/$folder/$class/$structure/handlers/pages/form/calendar/$handler/calendar.js +0 -1226
  272. package/$server/$folder/$class/$structure/handlers/pages/form/chat/$handler/chat.js +0 -2217
  273. package/$server/$folder/$class/$structure/handlers/pages/form/email/$handler/email.js +0 -1188
  274. package/$server/$folder/$class/$structure/handlers/pages/form/search/$handler/search.js +0 -289
  275. package/$server/$folder/$class/$structure/handlers/pages/site/$handler/site.js +0 -240
  276. package/$server/$folder/$class/handlers/pages/form/object/$handler/class.js +0 -33
  277. package/$server/$folder/$class/handlers/pages/form/object/$handler/object.js +0 -1371
  278. package/$server/$folder/$class/handlers/pages/form/objects/$handler/class.js +0 -33
  279. package/$server/$folder/$class/handlers/pages/form/objects/$handler/objects.js +0 -2130
  280. package/$server/$folder/$class/handlers/pages/form/system/$handler/system.js +0 -384
  281. package/$server/$folder/$class/handlers/pages/form/system/$handler/tabs/modules.js +0 -244
  282. package/$server/$folder/$class/handlers/pages/form/system/$handler/tabs/staff.js +0 -2126
  283. package/$server/$folder/$class/handlers/pages/storage/$handler/storage.js +0 -21
  284. package/$server/$folder/$file/$data/handlers/pages/form/editor/$handler/editor.js +0 -27
  285. package/$server/$folder/$file/$devs/handlers/pages/form/file/$handler/file.js +0 -31
  286. package/$server/$folder/$file/$ics/handlers/pages/form/file/$handler/file.js +0 -10
  287. package/$server/$folder/$file/$ipynb/handlers/pages/form/file/$handler/file.js +0 -72
  288. package/$server/$folder/$file/$md/handlers/pages/form/file/$handler/file.js +0 -63
  289. package/$server/$folder/$file/$office/handlers/pages/form/file/$handler/file.js +0 -1845
  290. package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/file.js +0 -785
  291. package/$server/$folder/$file/handlers/pages/form/file/$handler/file.js +0 -29
  292. package/$server/$folder/handlers/pages/form/$handler/form.js +0 -2122
  293. package/MODULES/Geo//320/232/320/260/321/200/321/202/320/260/$catalog/handlers/pages/form/map/$handler/map.js +0 -623
  294. package/MODULES/KLADR/$module/handlers/pages/form/kladr/$handler/kladr.js +0 -134
  295. package/MODULES/Process//320/227/320/260/320/264/320/260/321/207/320/270 /320/270 /321/215/321/202/320/260/320/277/321/213/$catalog/handlers/pages/form/gantt/$handler/gantt.js" +0 -293
  296. package/MODULES/Process//320/227/320/260/320/264/320/260/321/207/320/270 /320/270 /321/215/321/202/320/260/320/277/321/213/$catalog/handlers/pages/form/scheduler/$handler/scheduler.js" +0 -234
  297. package/MODULES/Process//320/241/321/205/320/265/320/274/321/213 /320/277/321/200/320/276/321/206/320/265/321/201/321/201/320/276/320/262/$catalog/handlers/pages/form/bpmn/$handler/bpmn.js" +0 -406
  298. package/MODULES/Register/CATALOGS/$catalog/$folder/$class/$virtual/handlers/pages/form/virtual/$handler/class.js +0 -6
  299. package/MODULES/Register/REGISTER/$register/$folder/$class/$account/handlers/pages/form/analysis/$handler/class.js +0 -9
  300. package/MODULES/Register/REGISTER/$register/$folder/$class/$account/handlers/pages/form/postings/$handler/class.js +0 -9
  301. package/MODULES/Register/REGISTER/$register/$folder/$class/$account/handlers/pages/form/turnovers/$handler/class.js +0 -9
  302. package/MODULES/Register/REGISTER/$register/$folder/$class/$register/handlers/pages/form/journal/$handler/class.js +0 -6
  303. package/MODULES/Register/REGISTER/$register/$folder/$class/$register/handlers/pages/form/sheet/$handler/class.js +0 -6
  304. package/MODULES/Register/REGISTER/$register/$folder/$class/$register/handlers/pages/form/sheet/$handler/sheet.js +0 -808
  305. package/NODES/$node/handlers/pages/form/network/$handler/network.js +0 -110
  306. package/SERVICES/$service/$folder/$storage/$service/class.js +0 -8
  307. package/SERVICES/$service/class.js +0 -442
  308. package/SERVICES/readme.md +0 -36
  309. /package/$server/$folder/$class/$structure/{$base → $organization}/icon.png +0 -0
  310. /package/{SERVICES/DuckDuckGo/$service → MODULES/DuckDuckGo/$module}/class.js +0 -0
  311. /package/MODULES/KLADR/$module/$folder/$class/{$catalog → $data/$catalog}/class.js +0 -0
  312. /package/MODULES/Process/$module/$folder/$class/{$catalog → $data/$catalog}/class.js +0 -0
  313. /package/MODULES/Register/$module/$folder/$class/{$catalog → $data/$catalog}/class.js +0 -0
  314. /package/MODULES/Register/$module/$folder/$class/{$operation → $data/$operation}/class.js +0 -0
  315. /package/MODULES/Register/$module/$folder/$class/{$register → $data/$register}/class.js +0 -0
  316. /package/MODULES/Register/$module/$folder/$class/{$struct → $data/$struct}/class.js +0 -0
  317. /package/MODULES/Register/CATALOGS/$catalog/$folder/$class/{$virtual/$folder/$class → $data/$catalog/$virtual/$folder/$class/$data/$catalog}/$virtual/class.js +0 -0
  318. /package/MODULES/Register/OPERATIONS//320/237/320/273/320/260/321/202/320/265/320/266/320/270 /321/201 /321/200/320/260/321/201/321/207/321/221/321/202/320/275/320/276/320/263/320/276 /321/201/321/207/321/221/321/202/320/260/$operation/{print → $folder/$class/$data/$operation/print}//320/237/320/273/320/260/321/202/321/221/320/266/320/275/320/276/320/265 /320/277/320/276/321/200/321/203/321/207/320/265/320/275/320/270/320/265.html" +0 -0
  319. /package/MODULES/Register/REGISTER/$register/$folder/$class/{$account → $data/$register/$account}/class.js +0 -0
  320. /package/MODULES/Register/REGISTER/$register/$folder/$class/{$account → $data/$register/$account}/readme.md +0 -0
  321. /package/MODULES/Register/REGISTER/$register/$folder/$class/{$register → $data/$register}/class.js +0 -0
  322. /package/MODULES/Register/STRUCTS/$struct/$folder/$class/{$struct → $data/$struct}/class.js +0 -0
  323. /package/{SERVICES/RuCalendar/$service → MODULES/RuCalendar/$module}/class.js +0 -0
  324. /package/{SERVICES/Telegram/$service → MODULES/Telegram/$module}/class.js +0 -0
  325. /package/{SERVICES/Weather/$service → MODULES/Weather/$module}/class.js +0 -0
  326. /package/PROJECTS/$domain/$folder/$class/{$project → $structure/$project}/class.js +0 -0
@@ -1,1371 +0,0 @@
1
- /**
2
- * form/object — стандартная вьюха редактора объекта/документа на стандартной форме work-form (Скрин 6).
3
- * Верхний тулбар хендлеров отключён через allowTools: false у хендлера.
4
- * Сервисные действия (Провести / Проведен / Отменить, Печать, Удалить / Восстановить) выводятся
5
- * в левой части подвала формы (#focusedTools), а кнопки OK / Сохранить / Закрыть и вкладки — в правой.
6
- */
7
- import objectsProto from '../../objects/$handler/objects.js';
8
-
9
- function _day(d) {
10
- return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
11
- }
12
- const _today = () => _day(new Date());
13
-
14
- const proto = Object.defineProperties({}, Object.getOwnPropertyDescriptors(objectsProto));
15
-
16
- Object.defineProperties(proto, Object.getOwnPropertyDescriptors({
17
- imports: 'oda//button, oda//icon, ~/lib//editor-form, ~/lib//class-picker',
18
- isObjectView: true,
19
- allowSave: true,
20
- hasSettings: true,
21
- designMode: false,
22
- binderParents: null,
23
- binderChildren: null,
24
- _basisId: '',
25
- _basisTitle: '',
26
- _dirtyTick: 0,
27
- get isReadonly() {
28
- void this._dirtyTick;
29
- if (!this.editing)
30
- return true;
31
- if (this.status === 'deleted')
32
- return true;
33
- if (this.isOperation && this.status === 'registered')
34
- return true;
35
- return false;
36
- },
37
- get canSave() {
38
- return Boolean(this.editing && !this.isReadonly);
39
- },
40
- get canRemove() {
41
- return Boolean(this.editing?.id && (!this.isOperation || this.status === 'draft' || this.status === 'cancelled') && this.status !== 'deleted');
42
- },
43
- get canRegister() {
44
- return Boolean(this.isOperation && this.editing && (!this.editing.id || this.status === 'draft' || this.status === 'cancelled'));
45
- },
46
- get canCancel() {
47
- return Boolean(this.isOperation && this.status === 'registered');
48
- },
49
- get isChanged() {
50
- void this._dirtyTick;
51
- return Boolean(this.canSave && (!this.editing?.id || this.isDirty()));
52
- },
53
- snapshot() {
54
- objectsProto.snapshot.call(this);
55
- this._dirtyTick++;
56
- this._notifyForm();
57
- },
58
- get layoutKey() {
59
- return this.activeSchema?.path || this.schema?.path || this.$item?.short || this.$item?.path || this.activeSchema?.cid || '';
60
- },
61
- get documentTitle() {
62
- void this._dirtyTick;
63
- const clsTitle = this.activeSchema?.title || this.schema?.title || this.$item?.DATA?.label || this.$item?.label || '';
64
- const fields = typeof this.fieldList === 'function' ? this.fieldList() : [];
65
- const nameField = fields.find(f => ['name', 'label', 'title'].includes(f.id));
66
- const explicitName = nameField ? String(this.editing?.[nameField.id] ?? '').trim() : '';
67
- if (explicitName) {
68
- if (!clsTitle || explicitName === clsTitle || explicitName.startsWith(clsTitle))
69
- return explicitName;
70
- return `${clsTitle} · ${explicitName}`;
71
- }
72
- if (this.isOperation && this.editing) {
73
- const num = String(this.editing?.num ?? this.editing?.doc_number ?? this.editing?.order_number ?? this.editing?.number ?? this.editing?.doc_num ?? '').trim();
74
- const hasManualNum = Boolean(num && num !== this._autoGeneratedNum);
75
- const rawTime = String(this.editing?.time ?? '').trim();
76
- let dateStr = rawTime;
77
- if (/^\d{4}-\d{2}-\d{2}$/.test(rawTime)) {
78
- const [y, m, d] = rawTime.split('-');
79
- dateStr = `${d}.${m}.${y}`;
80
- }
81
- let partyName = '';
82
- const partyKeys = ['recipient_name', 'payer_name', 'counterparty_name', 'recipient', 'payer', 'counterparty', 'client', 'supplier', 'customer', 'employee', 'person', 'agent'];
83
- for (const pk of partyKeys) {
84
- const val = String(this.editing?.[pk] ?? '').trim();
85
- if (!val)
86
- continue;
87
- const resolved = this.names?.[val] || this.entryNames?.objects?.[val] || (!/^\d+\.[A-Za-z0-9]+$/.test(val) ? val : '');
88
- if (resolved) {
89
- partyName = resolved;
90
- break;
91
- }
92
- }
93
- if (!partyName) {
94
- for (const f of fields) {
95
- if (f.type === 'Link') {
96
- const val = String(this.editing?.[f.id] ?? '').trim();
97
- if (!val)
98
- continue;
99
- const resolved = this.names?.[val] || this.entryNames?.objects?.[val];
100
- if (resolved) {
101
- partyName = resolved;
102
- break;
103
- }
104
- }
105
- }
106
- }
107
- if (this.editing?.id || hasManualNum || partyName || (rawTime && rawTime !== _today())) {
108
- const numPart = num ? ` №${num}` : '';
109
- const datePart = dateStr ? ` от ${dateStr}` : '';
110
- const partyPart = partyName ? ` - ${partyName}` : '';
111
- if (numPart || datePart || partyPart)
112
- return `${clsTitle}${numPart}${datePart}${partyPart}`;
113
- }
114
- }
115
- if (!this.editing?.id) {
116
- const fmtNew = globalThis.__workClassPicker?.formatNewObjectLabel || globalThis.WORK?.formatNewObjectLabel;
117
- if (typeof fmtNew === 'function' && clsTitle)
118
- return fmtNew(clsTitle);
119
- }
120
- return this.editorTitle;
121
- },
122
- toggleDesignMode() {
123
- this.designMode = !this.designMode;
124
- },
125
- showSettings() {
126
- this.designMode = !this.designMode;
127
- },
128
- template: /*html*/`
129
- <style>
130
- :host {
131
- @apply --vertical;
132
- @apply --flex;
133
- background: var(--content-background, #fff);
134
- color: var(--content-color, #222);
135
- overflow: hidden;
136
- font-size: 13px;
137
- }
138
- .obj-header {
139
- @apply --horizontal;
140
- align-items: center;
141
- justify-content: space-between;
142
- gap: 12px;
143
- padding: 8px 16px 4px;
144
- flex-shrink: 0;
145
- }
146
- .obj-title {
147
- font-size: 16px;
148
- font-weight: 700;
149
- color: var(--accent-color);
150
- overflow: hidden;
151
- text-overflow: ellipsis;
152
- white-space: nowrap;
153
- }
154
- .obj-header-right {
155
- display: inline-flex;
156
- flex-direction: row;
157
- align-items: center;
158
- gap: 8px;
159
- flex-shrink: 0;
160
- }
161
- .design-toggle-btn {
162
- display: inline-flex;
163
- align-items: center;
164
- gap: 4px;
165
- padding: 3px 9px;
166
- font-size: 12px;
167
- font-weight: 600;
168
- border: 1px solid var(--border-color);
169
- border-radius: var(--radius-xs, 4px);
170
- background: var(--subtle-background);
171
- color: var(--content-color);
172
- cursor: pointer;
173
- user-select: none;
174
- }
175
- .design-toggle-btn.active, .design-toggle-btn:hover {
176
- border-color: var(--accent-color);
177
- background: var(--accent-soft);
178
- color: var(--accent-color);
179
- }
180
- .context {
181
- @apply --horizontal;
182
- align-items: center;
183
- gap: 6px;
184
- font-size: 12px;
185
- flex-shrink: 0;
186
- }
187
- .context select {
188
- padding: 2px 6px;
189
- font-size: 12px;
190
- border: 1px solid var(--border-color);
191
- border-radius: 3px;
192
- background: var(--content-background);
193
- color: var(--content-color);
194
- }
195
- .obj-scroll {
196
- @apply --vertical;
197
- flex: 1;
198
- min-height: 0;
199
- overflow-y: auto;
200
- padding-bottom: 8px;
201
- }
202
- oda-editor-form {
203
- flex-shrink: 0;
204
- }
205
- .error {
206
- padding: 6px 16px;
207
- color: var(--error-color);
208
- background: var(--error-soft);
209
- border-top: 1px solid var(--error-color);
210
- border-bottom: 1px solid var(--error-color);
211
- white-space: break-spaces;
212
- font-size: 12.5px;
213
- }
214
- .entries {
215
- @apply --vertical;
216
- gap: 3px;
217
- margin: 6px 16px 0;
218
- padding: 8px 10px;
219
- font-size: 12px;
220
- background: var(--subtle-background);
221
- border: 1px solid var(--border-color);
222
- border-radius: var(--radius-xs, 4px);
223
- }
224
- .entries-title {
225
- font-weight: 700;
226
- color: var(--content-color);
227
- margin-bottom: 2px;
228
- }
229
- .trajectory {
230
- @apply --vertical;
231
- gap: 4px;
232
- margin: 6px 16px 0;
233
- padding: 8px 10px;
234
- font-size: 12px;
235
- background: var(--subtle-background);
236
- border: 1px solid var(--border-color);
237
- border-radius: var(--radius-xs, 4px);
238
- }
239
- .trajectory-title {
240
- font-weight: 700;
241
- color: var(--content-color);
242
- }
243
- .traj-row {
244
- @apply --horizontal;
245
- gap: 8px;
246
- align-items: center;
247
- }
248
- .traj-link {
249
- cursor: pointer;
250
- text-decoration: underline;
251
- color: var(--accent-color);
252
- }
253
- .traj-num {
254
- margin-left: auto;
255
- text-align: right;
256
- font-variant-numeric: tabular-nums;
257
- }
258
- </style>
259
- <div class="obj-header">
260
- <div class="obj-title" :title="documentTitle">{{documentTitle}}</div>
261
- <div class="obj-header-right">
262
- <label class="context" ~if="showContext && !editing?.id">От места:
263
- <select @change="contextKey = $this.value">
264
- <option ~for="contexts" :value="contextKeyOf($for.item)"
265
- :selected="contextKeyOf($for.item) === contextKeyOf(context)">{{contextTitle($for.item)}}</option>
266
- </select>
267
- </label>
268
- <button type="button" class="design-toggle-btn" ~class="{active: designMode}" title="Дизайн расположения и кастомизация полей формы" @tap="toggleDesignMode()">
269
- <oda-icon icon="icons:settings" icon-size="15"></oda-icon>
270
- <span>{{designMode ? 'Готово' : 'Поля'}}</span>
271
- </button>
272
- </div>
273
- </div>
274
- <div class="error" ~if="error">{{error}}</div>
275
- <div class="obj-scroll">
276
- <oda-editor-form ~if="editing" hide-title ::design-mode="designMode" :layout-key="layoutKey" :readonly="isReadonly"
277
- :metadata="activeSchema" :data="editing" :field-errors="fieldErrors"
278
- @input="onFormInput" @change="onFormInput" @cell-changed="onFormInput"></oda-editor-form>
279
- <div class="entries" ~if="entries?.length">
280
- <div class="entries-title">Проводки:</div>
281
- <div class="entry" ~for="entries">{{entryText($for.item)}}</div>
282
- </div>
283
- <div class="entries" ~if="binderParents?.length || binderChildren?.length || _basisTitle">
284
- <div class="entries-title" style="display:flex; align-items:center; justify-content:space-between;">
285
- <span>Подшивка документов:</span>
286
- <span class="traj-link" style="font-weight:500;" ~if="editing?.id" @tap="openBinderDialog()">Управление подшивкой…</span>
287
- </div>
288
- <div class="traj-row" ~if="_basisTitle && !editing?.id">
289
- <span style="color:var(--muted-color);">На основании:</span>
290
- <span style="font-weight:600;">{{_basisTitle}}</span>
291
- </div>
292
- <div class="traj-row" ~for="binderParents">
293
- <span style="color:var(--muted-color); min-width:82px;">Основание:</span>
294
- <span class="traj-link" @tap="openBinderItem($for.item)">{{$for.item.title}}</span>
295
- <span style="color:var(--muted-color);">{{formatBinderDate($for.item.date)}}</span>
296
- <span class="traj-num" ~if="$for.item.sum">{{formatBinderMoney($for.item.sum)}} ₽</span>
297
- </div>
298
- <div class="traj-row" ~for="binderChildren">
299
- <span style="color:var(--muted-color); min-width:82px;">Следствие:</span>
300
- <span class="traj-link" @tap="openBinderItem($for.item)">{{$for.item.title}}</span>
301
- <span style="color:var(--muted-color);">{{formatBinderDate($for.item.date)}}</span>
302
- <span class="traj-num" ~if="$for.item.sum">{{formatBinderMoney($for.item.sum)}} ₽</span>
303
- </div>
304
- </div>
305
- <div class="trajectory" ~if="objectBalances?.length || trajectory?.length">
306
- <div class="trajectory-title" ~if="objectBalances?.length">Остатки по счетам</div>
307
- <div class="traj-row" ~for="objectBalances">
308
- <span class="traj-link" @tap="openBalanceAccount($for.item)">{{$for.item.label}}</span>
309
- <span class="traj-num">{{$for.item.balance}}{{$for.item.qty ? ' (' + $for.item.qty + ')' : ''}}</span>
310
- </div>
311
- <div class="trajectory-title" ~if="trajectory?.length">Движения ({{trajectory.length}})</div>
312
- <div class="traj-row" ~for="trajectory">
313
- <span>{{$for.item.date}}</span>
314
- <span class="traj-link" @tap="openTrajectoryOp($for.item)">{{$for.item.op}}</span>
315
- <span>{{$for.item.account}}</span>
316
- <span class="traj-num">{{$for.item.debit ? '+' + $for.item.debit : ($for.item.credit ? '−' + $for.item.credit : $for.item.qty)}} → {{$for.item.balance}}</span>
317
- </div>
318
- </div>
319
- </div>
320
- `,
321
- mountToolbarSlots() {
322
- // У формы объекта верхнего тулбара нет (allowTools: false)
323
- },
324
- getItemButtons() {
325
- return [];
326
- },
327
- getFocusedButtons() {
328
- return [];
329
- },
330
- getFocusedServices() {
331
- const list = [];
332
- if (this.isOperation) {
333
- if (this.canRegister) {
334
- list.push({
335
- id: 'post',
336
- label: 'Провести',
337
- icon: 'icons:settings',
338
- isService: true,
339
- service: true,
340
- order: 1,
341
- disabled: this.busy,
342
- execute: async () => {
343
- await this.post();
344
- this._notifyForm();
345
- },
346
- });
347
- }
348
- else if (this.canCancel) {
349
- list.push({
350
- id: 'cancel',
351
- label: 'Проведен (Отменить)',
352
- icon: 'icons:settings',
353
- isService: true,
354
- service: true,
355
- order: 1,
356
- disabled: this.busy,
357
- execute: async () => {
358
- await this.cancelOperation();
359
- this._notifyForm();
360
- },
361
- });
362
- }
363
- if (this.editing?.id) {
364
- const binderCount = (this.binderParents?.length || 0) + (this.binderChildren?.length || 0);
365
- list.push({
366
- id: 'binder',
367
- label: binderCount > 0 ? `Подшивка (${binderCount})` : 'Подшивка',
368
- icon: 'icons:folder-open',
369
- isService: true,
370
- service: true,
371
- order: 2,
372
- disabled: this.busy,
373
- execute: () => this.openBinderDialog(),
374
- });
375
- const singlePrint = (this.printForms || []).length === 1 ? this.printForms[0] : null;
376
- list.push({
377
- id: 'print',
378
- label: 'Печать',
379
- icon: 'icons:print',
380
- isService: true,
381
- service: true,
382
- order: 3,
383
- disabled: this.busy,
384
- execute: () => this.openPrintDialog(singlePrint?.name || ''),
385
- });
386
- }
387
- }
388
- if (this.canRemove) {
389
- list.push({
390
- id: 'remove',
391
- label: 'Удалить',
392
- icon: 'icons:delete',
393
- isService: true,
394
- service: true,
395
- order: 10,
396
- disabled: this.busy,
397
- execute: async () => {
398
- if (await this.removeObject()) {
399
- this._findFormHost()?.closeActiveTab?.(true);
400
- }
401
- },
402
- });
403
- }
404
- if (this.canRestore) {
405
- list.push({
406
- id: 'restore',
407
- label: 'Восстановить',
408
- icon: 'icons:restore',
409
- isService: true,
410
- service: true,
411
- order: 11,
412
- disabled: this.busy,
413
- execute: async () => {
414
- await this.restoreObject();
415
- this._notifyForm();
416
- },
417
- });
418
- }
419
- return list;
420
- },
421
- onFormInput(e) {
422
- const rawDetail = e?.detail;
423
- const d = (rawDetail && typeof rawDetail.value === 'object' && rawDetail.value !== null) ? rawDetail.value : rawDetail;
424
- if (d && typeof d === 'object' && d.value && d.label && d.label !== d.value) {
425
- this.names = { ...(this.names || {}), [d.value]: d.label };
426
- }
427
- if (d && typeof d === 'object' && d.id === 'time' && this.isOperation && !this.editing?.id) {
428
- const nextPeriodKey = this._periodKeyForNumerator?.(this.editing?.time);
429
- if (nextPeriodKey && nextPeriodKey !== this._autoNumPeriodKey) {
430
- this._assignAutoNumber?.(false);
431
- }
432
- }
433
- if (this.fieldErrors && Object.keys(this.fieldErrors).length)
434
- this.fieldErrors = {};
435
- this._dirtyTick++;
436
- this.schedulePreview?.();
437
- const host = this._findFormHost();
438
- host?.updateActiveTabLabel?.(this.documentTitle);
439
- this._notifyForm();
440
- },
441
- async attached() {
442
- if (this._attachedDone && !this._initialNav && !this._pendingNav)
443
- return;
444
- const initNav = this._initialNav || this._pendingNav;
445
- this._initialNav = null;
446
- this._pendingNav = null;
447
- try {
448
- await Promise.all([this.loadSchema(), this.loadScope()]);
449
- }
450
- catch (e) {
451
- this.error = String(e?.message || e);
452
- return;
453
- }
454
- if (initNav) {
455
- await this.initFromNav(initNav);
456
- }
457
- else if (!this.editing) {
458
- await this.initFromNav({});
459
- }
460
- this._attachedDone = true;
461
- },
462
- async applyNav(nav = {}) {
463
- if (!this.schema) {
464
- this._pendingNav = nav;
465
- return;
466
- }
467
- await this.initFromNav(nav);
468
- },
469
- async initFromNav(nav = {}) {
470
- this.clearError();
471
- this._basisId = String(nav.basisId || '');
472
- this._basisTitle = String(nav.basisTitle || '');
473
- this.binderParents = [];
474
- this.binderChildren = [];
475
- if (nav.leafCid) {
476
- await this.loadLeafSchema(nav.leafCid);
477
- }
478
- else {
479
- this.leafCid = '';
480
- this.leafSchema = null;
481
- }
482
- if (nav.id) {
483
- await this.select({ id: String(nav.id), cid: nav.leafCid || '' });
484
- }
485
- else if (nav.copyFrom) {
486
- const found = await this.$item.fetch('db_read', { id: String(nav.copyFrom) });
487
- if (found?.names && typeof found.names === 'object')
488
- this.names = { ...(this.names || {}), ...found.names };
489
- await this.loadLeafSchema(found?.cid || nav.leafCid || '');
490
- const baseBody = { ...(found?.body || {}) };
491
- delete baseBody.id;
492
- delete baseBody.version;
493
- delete baseBody.status;
494
- const nf = this._numeratorFieldId?.() || '';
495
- if (nf)
496
- delete baseBody[nf];
497
- this.editing = this.isOperation ? { ...baseBody, time: _today() } : baseBody;
498
- await this._assignAutoNumber?.(true);
499
- this.entries = [];
500
- this.entryNames = { objects: {}, classes: {} };
501
- this.objectBalances = [];
502
- this.trajectory = [];
503
- this.printForms = [];
504
- if (this.isOperation)
505
- this.schedulePreview();
506
- }
507
- else {
508
- if (nav.names && typeof nav.names === 'object')
509
- this.names = { ...(this.names || {}), ...nav.names };
510
- if (nav.unit && Array.isArray(this.contexts) && this.contexts.length) {
511
- const match = this.contexts.find(c => c.unit === nav.unit);
512
- if (match)
513
- this.contextKey = `${match.unit}|${match.place ?? ''}`;
514
- }
515
- this.editing = this.isOperation ? { time: _today(), ...(nav.initialData || {}) } : { ...(nav.initialData || {}) };
516
- await this._assignAutoNumber?.(true);
517
- this.entries = [];
518
- this.entryNames = { objects: {}, classes: {} };
519
- this.objectBalances = [];
520
- this.trajectory = [];
521
- this.printForms = [];
522
- if (this.isOperation)
523
- this.schedulePreview();
524
- }
525
- this.focusedItem = this.editing || { id: nav.id || 'new' };
526
- this.snapshot();
527
- this.async?.(() => {
528
- if (this.isConnected)
529
- this.snapshot();
530
- });
531
- const host = this._findFormHost();
532
- host?.updateActiveTabLabel?.(this.documentTitle);
533
- this._notifyForm();
534
- },
535
- async select(row) {
536
- await objectsProto.select.call(this, row);
537
- if (this.isOperation && this.editing?.id) {
538
- await this.loadBinder();
539
- }
540
- },
541
- writeParams(extra = {}) {
542
- const p = objectsProto.writeParams.call(this, extra);
543
- if (!this.editing?.id && this._basisId) {
544
- p.basis_id = this._basisId;
545
- }
546
- return p;
547
- },
548
- formatBinderDate(d) {
549
- const s = String(d || '').slice(0, 10);
550
- const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(s);
551
- return m ? `${m[3]}.${m[2]}.${m[1]}` : s;
552
- },
553
- formatBinderMoney(v) {
554
- return (Number(v) || 0).toLocaleString('ru-RU', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
555
- },
556
- async loadBinder() {
557
- this.binderParents = [];
558
- this.binderChildren = [];
559
- if (!this.isOperation || !this.editing?.id)
560
- return;
561
- try {
562
- const target = await this.targetItem();
563
- const res = await target.fetch('db_binder', { id: this.editing.id });
564
- this.binderParents = Array.isArray(res?.parents) ? res.parents : [];
565
- this.binderChildren = Array.isArray(res?.children) ? res.children : [];
566
- this._notifyForm();
567
- }
568
- catch {
569
- this.binderParents = [];
570
- this.binderChildren = [];
571
- }
572
- },
573
- async openBinderItem(item) {
574
- if (!item?.id)
575
- return;
576
- const path = item.path || item.cid || '';
577
- if (!path || typeof WORK?.get_item !== 'function')
578
- return;
579
- try {
580
- const target = await WORK.get_item(path);
581
- if (!target)
582
- return;
583
- const nav = { view: 'object', id: item.id, leafCid: item.cid || '', label: item.title || item.id };
584
- const formHost = this._findFormHost();
585
- if (formHost && typeof formHost.openInForm === 'function')
586
- await formHost.openInForm(target, nav);
587
- else if (typeof window !== 'undefined' && typeof window.execute === 'function')
588
- window.execute(target, nav);
589
- }
590
- catch (e) {
591
- this.error = String(e?.message || e);
592
- }
593
- },
594
- async openBinderDialog() {
595
- if (!this.editing?.id || typeof WORK?.showModal !== 'function' || typeof document === 'undefined')
596
- return;
597
- const dlg = ODA.createComponent('oda-doc-binder', {
598
- owner: this,
599
- docId: this.editing.id,
600
- docTitle: this.documentTitle,
601
- });
602
- try {
603
- await WORK.showModal(dlg, {
604
- TITLE: { label: `Подшивка · ${this.documentTitle}` },
605
- allowClose: true,
606
- width: Math.min(760, (window.innerWidth || 800) - 32),
607
- });
608
- }
609
- catch { /* ignore */ }
610
- await this.loadBinder();
611
- },
612
- async createBasedOnOperation() {
613
- if (!this.editing?.id)
614
- return;
615
- const curPath = String(this.$item?.short || this.$item?.path || '');
616
- const rootMatch = curPath.match(/^(\/(?:ORGANIZATIONS|PROJECTS)\/[^/]+\/MODULES\/[^/]+\/OPERATIONS|\/MODULES\/[^/]+\/OPERATIONS)/);
617
- const opRootPath = rootMatch ? rootMatch[1] : curPath;
618
- let rootItem = this.$item;
619
- if (opRootPath && typeof WORK?.get_item === 'function') {
620
- rootItem = (await WORK.get_item(opRootPath).catch(() => null)) || this.$item;
621
- }
622
- let classesMap = this.classes;
623
- let leavesList = this.leaves;
624
- try {
625
- const schemaRes = await rootItem.fetch('db_schema');
626
- if (schemaRes?.classes)
627
- classesMap = schemaRes.classes;
628
- if (Array.isArray(schemaRes?.leaves) && schemaRes.leaves.length)
629
- leavesList = schemaRes.leaves;
630
- }
631
- catch { /* ignore */ }
632
-
633
- const pickFn = globalThis.__workClassPicker?.pickClassFromTree || globalThis.WORK?.pickClassFromTree;
634
- let chosen = null;
635
- if (typeof pickFn === 'function' && Array.isArray(leavesList) && leavesList.length > 1) {
636
- chosen = await pickFn({
637
- classes: classesMap,
638
- leaves: leavesList,
639
- rootCid: opRootPath,
640
- rootLabel: 'Операции',
641
- title: `Создать на основании «${this.documentTitle}»`,
642
- defaultIcon: 'carbon:task-complete',
643
- defaultType: '$operation',
644
- });
645
- if (!chosen)
646
- return;
647
- }
648
- else if (Array.isArray(leavesList) && leavesList.length === 1) {
649
- chosen = leavesList[0];
650
- }
651
- const targetPath = chosen?.path || chosen?.cid || curPath;
652
- const targetItem = (typeof WORK?.get_item === 'function' ? await WORK.get_item(targetPath).catch(() => null) : null) || this.$item;
653
- let targetFields = [];
654
- try {
655
- const ts = await targetItem.fetch('db_schema');
656
- targetFields = Array.isArray(ts?.schema?.fields) ? ts.schema.fields : [];
657
- }
658
- catch { /* ignore */ }
659
-
660
- const src = this.editing || {};
661
- const initialData = {};
662
- const targetFieldIds = new Set(targetFields.map(f => f.id));
663
- const copyDirect = ['sum', 'amount', 'total', 'nds', 'sum_n', 'nds_sum', 'vat_sum', 'recipient', 'recipient_name', 'payer', 'payer_name', 'counterparty', 'counterparty_name', 'client', 'supplier', 'customer', 'employee', 'person', 'contract', 'acct', 'acct_r'];
664
- for (const k of copyDirect) {
665
- if (src[k] !== undefined && src[k] !== null && src[k] !== '' && (!targetFieldIds.size || targetFieldIds.has(k))) {
666
- initialData[k] = src[k];
667
- }
668
- }
669
- // Если в исходном документе контрагент в client/supplier/counterparty, а в целевом — в recipient/payer
670
- const srcPartyId = src.recipient || src.payer || src.counterparty || src.client || src.supplier || src.customer || src.employee || '';
671
- const srcPartyName = src.recipient_name || src.payer_name || src.counterparty_name || (srcPartyId && this.names?.[srcPartyId]) || '';
672
- if (srcPartyId) {
673
- for (const pk of ['recipient', 'payer', 'counterparty', 'client', 'supplier', 'customer', 'employee']) {
674
- if (targetFieldIds.has(pk) && !initialData[pk])
675
- initialData[pk] = srcPartyId;
676
- }
677
- }
678
- if (srcPartyName) {
679
- for (const nk of ['recipient_name', 'payer_name', 'counterparty_name']) {
680
- if (targetFieldIds.has(nk) && !initialData[nk])
681
- initialData[nk] = srcPartyName;
682
- }
683
- }
684
- const basisText = `По документу: ${this.documentTitle}`;
685
- for (const dk of ['descript', 'purpose', 'base', 'comment']) {
686
- if (targetFieldIds.has(dk) && !initialData[dk]) {
687
- initialData[dk] = src.descript || src.purpose || basisText;
688
- }
689
- }
690
-
691
- const nav = {
692
- view: 'object',
693
- create: true,
694
- leafCid: chosen?.cid || targetPath,
695
- basisId: this.editing.id,
696
- basisTitle: this.documentTitle,
697
- initialData,
698
- names: { ...(this.names || {}) },
699
- };
700
- const formHost = this._findFormHost();
701
- if (formHost && typeof formHost.openInForm === 'function') {
702
- await formHost.openInForm(targetItem, nav);
703
- }
704
- },
705
- async openPrintDialog(name = '') {
706
- if (!this.editing?.id)
707
- return;
708
- if (typeof WORK?.showModal !== 'function' || typeof document === 'undefined') {
709
- return this.printForm(name);
710
- }
711
- const target = await this.targetItem();
712
- const dlg = ODA.createComponent('oda-print-dialog', {
713
- owner: this,
714
- targetItem: target,
715
- docId: this.editing.id,
716
- docTitle: this.documentTitle,
717
- selectedName: name || (this.printForms?.[0]?.name ?? ''),
718
- forms: Array.isArray(this.printForms) ? [...this.printForms] : [],
719
- });
720
- try {
721
- await WORK.showModal(dlg, {
722
- TITLE: { label: `Печать · ${this.documentTitle}` },
723
- allowClose: true,
724
- width: Math.min(880, (window.innerWidth || 920) - 24),
725
- });
726
- }
727
- catch { /* ignore */ }
728
- await this.loadPrints();
729
- this._notifyForm();
730
- },
731
- async save() {
732
- const ok = await objectsProto.save.call(this);
733
- if (ok) {
734
- this._basisId = '';
735
- this._basisTitle = '';
736
- this.focusedItem = this.editing || this.focusedItem;
737
- this._dirtyTick++;
738
- if (this.editing?.id) {
739
- await this.loadEntries();
740
- await this.loadPrints();
741
- await this.loadBinder();
742
- await this.loadTrajectory();
743
- }
744
- const host = this._findFormHost();
745
- host?.updateActiveTabLabel?.(this.documentTitle);
746
- await host?.reloadSiblingLists?.();
747
- this._notifyForm();
748
- }
749
- return ok;
750
- },
751
- async saveAndStay() {
752
- return this.save();
753
- },
754
- async saveAndClose() {
755
- if (this.canSave && (this.isDirty() || !this.editing?.id)) {
756
- const ok = await this.save();
757
- if (!ok)
758
- return false;
759
- }
760
- this._findFormHost()?.closeActiveTab?.(true);
761
- return true;
762
- },
763
- }));
764
-
765
- if (typeof ODA === 'function') {
766
- ODA({
767
- is: 'oda-doc-binder',
768
- template: /*html*/`
769
- <style>
770
- :host {
771
- @apply --vertical;
772
- min-width: min(680px, calc(100vw - 24px));
773
- max-width: 100%;
774
- max-height: 78dvh;
775
- background: var(--content-background, #fff);
776
- color: var(--content-color, #1f2937);
777
- font-size: 13px;
778
- box-sizing: border-box;
779
- }
780
- .binder-body {
781
- @apply --vertical;
782
- flex: 1 1 auto;
783
- min-height: min(200px, 32dvh);
784
- max-height: 64dvh;
785
- overflow-y: auto;
786
- padding: 10px 14px;
787
- gap: 12px;
788
- }
789
- .sec-box {
790
- @apply --vertical;
791
- border: 1px solid var(--border-color);
792
- border-radius: 4px;
793
- overflow: hidden;
794
- }
795
- .sec-head {
796
- @apply --horizontal;
797
- align-items: center;
798
- justify-content: space-between;
799
- padding: 6px 10px;
800
- background: var(--header-background, #f3f4f6);
801
- font-weight: 700;
802
- font-size: 12.5px;
803
- border-bottom: 1px solid var(--border-color);
804
- }
805
- .doc-row {
806
- @apply --horizontal;
807
- flex-wrap: wrap;
808
- align-items: center;
809
- gap: 6px 10px;
810
- padding: 6px 10px;
811
- border-bottom: 1px solid var(--subtle-border, #e5e7eb);
812
- }
813
- .doc-row:last-child {
814
- border-bottom: none;
815
- }
816
- .doc-link {
817
- color: var(--accent-color, #2563eb);
818
- text-decoration: underline;
819
- cursor: pointer;
820
- font-weight: 600;
821
- flex: 1;
822
- min-width: 0;
823
- overflow: hidden;
824
- text-overflow: ellipsis;
825
- white-space: nowrap;
826
- }
827
- .doc-meta {
828
- font-size: 12px;
829
- color: var(--muted-color, #6b7280);
830
- white-space: nowrap;
831
- }
832
- .doc-sum {
833
- font-weight: 600;
834
- font-variant-numeric: tabular-nums;
835
- white-space: nowrap;
836
- }
837
- .empty-sec {
838
- padding: 10px;
839
- color: var(--muted-color, #6b7280);
840
- font-size: 12px;
841
- }
842
- .add-panel {
843
- @apply --vertical;
844
- gap: 8px;
845
- padding: 10px;
846
- border: 1px solid var(--border-color);
847
- border-radius: 4px;
848
- background: var(--subtle-background, #f9fafb);
849
- }
850
- .add-controls {
851
- @apply --horizontal;
852
- align-items: center;
853
- gap: 8px;
854
- flex-wrap: wrap;
855
- }
856
- .search-box {
857
- flex: 1;
858
- min-width: 180px;
859
- padding: 4px 8px;
860
- font-size: 13px;
861
- border: 1px solid var(--border-color);
862
- border-radius: 3px;
863
- background: var(--content-background, #fff);
864
- color: var(--content-color, #111);
865
- }
866
- .cand-list {
867
- @apply --vertical;
868
- max-height: 210px;
869
- overflow-y: auto;
870
- border: 1px solid var(--border-color);
871
- border-radius: 3px;
872
- background: var(--content-background, #fff);
873
- }
874
- .cand-row {
875
- @apply --horizontal;
876
- align-items: center;
877
- gap: 8px;
878
- padding: 5px 8px;
879
- border-bottom: 1px solid var(--subtle-border, #e5e7eb);
880
- cursor: pointer;
881
- }
882
- .cand-row:hover {
883
- background: var(--hover-background, rgba(37, 99, 235, 0.06));
884
- }
885
- .btn {
886
- padding: 4px 10px;
887
- font-size: 12.5px;
888
- font-weight: 600;
889
- border: 1px solid var(--border-color);
890
- border-radius: 3px;
891
- background: var(--content-background, #fff);
892
- color: var(--content-color, #222);
893
- cursor: pointer;
894
- white-space: nowrap;
895
- }
896
- .btn:hover:not(:disabled) {
897
- border-color: var(--accent-color);
898
- color: var(--accent-color);
899
- }
900
- .btn.primary {
901
- background: var(--accent-color, #2563eb);
902
- border-color: var(--accent-color, #2563eb);
903
- color: #fff;
904
- }
905
- .binder-footer {
906
- @apply --horizontal;
907
- align-items: center;
908
- justify-content: space-between;
909
- gap: 8px;
910
- padding: 8px 14px;
911
- border-top: 1px solid var(--border-color);
912
- background: var(--header-background, #f3f4f6);
913
- }
914
- </style>
915
- <div class="binder-body">
916
- <div class="sec-box">
917
- <div class="sec-head">
918
- <span>Документы-основания (исходные документы, например Счёт или Договор)</span>
919
- <span>{{parents.length}}</span>
920
- </div>
921
- <div class="empty-sec" ~if="!parents.length">Нет подшитых документов-оснований</div>
922
- <div class="doc-row" ~for="parents">
923
- <span class="doc-meta">{{fmtDate($for.item.date)}}</span>
924
- <span class="doc-link" @tap="openDoc($for.item)" :title="$for.item.title">{{$for.item.title}}</span>
925
- <span class="doc-meta" ~if="$for.item.party">{{$for.item.party}}</span>
926
- <span class="doc-sum" ~if="$for.item.sum">{{fmtMoney($for.item.sum)}} ₽</span>
927
- <button type="button" class="btn" ~if="!$for.item.viaRef" title="Открепить из подшивки" @tap="unlinkDoc($for.item.id)">✕</button>
928
- </div>
929
- </div>
930
-
931
- <div class="sec-box">
932
- <div class="sec-head">
933
- <span>Документы-следствия (порождённые на основании текущего документа)</span>
934
- <span>{{children.length}}</span>
935
- </div>
936
- <div class="empty-sec" ~if="!children.length">Нет подшитых документов-следствий</div>
937
- <div class="doc-row" ~for="children">
938
- <span class="doc-meta">{{fmtDate($for.item.date)}}</span>
939
- <span class="doc-link" @tap="openDoc($for.item)" :title="$for.item.title">{{$for.item.title}}</span>
940
- <span class="doc-meta" ~if="$for.item.party">{{$for.item.party}}</span>
941
- <span class="doc-sum" ~if="$for.item.sum">{{fmtMoney($for.item.sum)}} ₽</span>
942
- <button type="button" class="btn" ~if="!$for.item.viaRef" title="Открепить из подшивки" @tap="unlinkDoc($for.item.id)">✕</button>
943
- </div>
944
- </div>
945
-
946
- <div class="add-panel" ~if="addingExisting">
947
- <div class="add-controls">
948
- <label style="font-weight:600; display:inline-flex; align-items:center; gap:6px;">
949
- Подшить как:
950
- <select :value="linkDirection" @change="linkDirection = $event.target.value" style="padding:3px 6px; font-size:12.5px;">
951
- <option value="parent">Документ-основание (причина)</option>
952
- <option value="child">Документ-следствие</option>
953
- </select>
954
- </label>
955
- <label ~if="partyName" style="display:inline-flex; align-items:center; gap:4px; font-size:12px; cursor:pointer;">
956
- <input type="checkbox" :checked="samePartyOnly" @change="toggleSameParty($event.target.checked)">
957
- <span>Только по «{{partyName}}»</span>
958
- </label>
959
- <input class="search-box" type="search" placeholder="Поиск по номеру, классу, контрагенту, сумме…" :value="searchQuery" @input="onSearchInput($event.target.value)">
960
- </div>
961
- <div class="cand-list">
962
- <div class="empty-sec" ~if="!candidates.length">Подходящие операции не найдены</div>
963
- <div class="cand-row" ~for="candidates" @dblclick="linkCandidate($for.item)">
964
- <span class="doc-meta">{{fmtDate($for.item.date)}}</span>
965
- <span style="flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-weight:500;">{{$for.item.title}}</span>
966
- <span class="doc-meta" ~if="$for.item.party">{{$for.item.party}}</span>
967
- <span class="doc-sum" ~if="$for.item.sum">{{fmtMoney($for.item.sum)}} ₽</span>
968
- <button type="button" class="btn primary" @tap.stop="linkCandidate($for.item)">Подшить</button>
969
- </div>
970
- </div>
971
- </div>
972
- </div>
973
- <div class="binder-footer">
974
- <div style="display:flex; gap:6px; flex-wrap:wrap;">
975
- <button type="button" class="btn" @tap="toggleAddExisting()">{{addingExisting ? 'Скрыть подбор' : '+ Подшить существующий документ…'}}</button>
976
- <button type="button" class="btn primary" @tap="createOnBasis()">+ Создать на основании…</button>
977
- </div>
978
- <button type="button" class="btn" @tap="closeModal()">Закрыть</button>
979
- </div>
980
- `,
981
- owner: null,
982
- docId: '',
983
- docTitle: '',
984
- parents: [],
985
- children: [],
986
- addingExisting: false,
987
- linkDirection: 'parent',
988
- samePartyOnly: true,
989
- partyName: '',
990
- searchQuery: '',
991
- candidates: [],
992
- attached() {
993
- this.reloadBinder();
994
- },
995
- fmtDate(d) {
996
- return this.owner?.formatBinderDate ? this.owner.formatBinderDate(d) : String(d || '');
997
- },
998
- fmtMoney(v) {
999
- return this.owner?.formatBinderMoney ? this.owner.formatBinderMoney(v) : String(v || 0);
1000
- },
1001
- async reloadBinder() {
1002
- if (!this.owner || !this.docId)
1003
- return;
1004
- const target = await this.owner.targetItem();
1005
- const res = await target.fetch('db_binder', { id: this.docId }).catch(() => null);
1006
- this.parents = Array.isArray(res?.parents) ? res.parents : [];
1007
- this.children = Array.isArray(res?.children) ? res.children : [];
1008
- if (this.addingExisting)
1009
- await this.loadCandidates();
1010
- },
1011
- async toggleAddExisting() {
1012
- this.addingExisting = !this.addingExisting;
1013
- if (this.addingExisting)
1014
- await this.loadCandidates();
1015
- },
1016
- async toggleSameParty(checked) {
1017
- this.samePartyOnly = Boolean(checked);
1018
- await this.loadCandidates();
1019
- },
1020
- onSearchInput(v) {
1021
- this.searchQuery = v;
1022
- this.debounce('binder-cand-search', () => this.loadCandidates(), 220);
1023
- },
1024
- async loadCandidates() {
1025
- if (!this.owner || !this.docId)
1026
- return;
1027
- const target = await this.owner.targetItem();
1028
- let res = await target.fetch('db_binder_candidates', {
1029
- id: this.docId,
1030
- search: this.searchQuery,
1031
- samePartyOnly: this.samePartyOnly,
1032
- limit: 60,
1033
- }).catch(() => null);
1034
- if (this.samePartyOnly && (!res?.items || !res.items.length) && !this.searchQuery) {
1035
- this.samePartyOnly = false;
1036
- res = await target.fetch('db_binder_candidates', {
1037
- id: this.docId,
1038
- search: this.searchQuery,
1039
- samePartyOnly: false,
1040
- limit: 60,
1041
- }).catch(() => null);
1042
- }
1043
- this.partyName = String(res?.partyName || '');
1044
- this.candidates = Array.isArray(res?.items) ? res.items : [];
1045
- },
1046
- async linkCandidate(item) {
1047
- if (!item?.id || !this.owner || !this.docId)
1048
- return;
1049
- const target = await this.owner.targetItem();
1050
- const res = await target.fetch('db_binder_link', {
1051
- id: this.docId,
1052
- targetId: item.id,
1053
- direction: this.linkDirection,
1054
- });
1055
- this.parents = Array.isArray(res?.parents) ? res.parents : [];
1056
- this.children = Array.isArray(res?.children) ? res.children : [];
1057
- await this.loadCandidates();
1058
- },
1059
- async unlinkDoc(targetId) {
1060
- if (!targetId || !this.owner || !this.docId)
1061
- return;
1062
- const target = await this.owner.targetItem();
1063
- const res = await target.fetch('db_binder_unlink', {
1064
- id: this.docId,
1065
- targetId,
1066
- });
1067
- this.parents = Array.isArray(res?.parents) ? res.parents : [];
1068
- this.children = Array.isArray(res?.children) ? res.children : [];
1069
- if (this.addingExisting)
1070
- await this.loadCandidates();
1071
- },
1072
- async openDoc(item) {
1073
- if (!item?.id || !this.owner)
1074
- return;
1075
- this.closeModal();
1076
- await this.owner.openBinderItem(item);
1077
- },
1078
- async createOnBasis() {
1079
- if (!this.owner)
1080
- return;
1081
- this.closeModal();
1082
- await this.owner.createBasedOnOperation();
1083
- },
1084
- closeModal() {
1085
- for (let p = this.parentElement || this.domHost; p; p = p.parentElement || p.domHost) {
1086
- if (typeof p.close === 'function') {
1087
- p.close('ok');
1088
- return;
1089
- }
1090
- }
1091
- },
1092
- });
1093
-
1094
- ODA({
1095
- is: 'oda-print-dialog',
1096
- template: /*html*/`
1097
- <style>
1098
- :host {
1099
- @apply --vertical;
1100
- min-width: min(840px, 95vw);
1101
- height: min(82vh, 780px);
1102
- background: var(--content-background, #fff);
1103
- color: var(--content-color, #1f2937);
1104
- font-size: 13px;
1105
- box-sizing: border-box;
1106
- }
1107
- .print-toolbar {
1108
- @apply --horizontal;
1109
- align-items: center;
1110
- gap: 8px;
1111
- padding: 8px 12px;
1112
- border-bottom: 1px solid var(--border-color);
1113
- background: var(--header-background, #f3f4f6);
1114
- flex-shrink: 0;
1115
- flex-wrap: wrap;
1116
- }
1117
- .print-select {
1118
- padding: 4px 8px;
1119
- font-size: 13px;
1120
- border: 1px solid var(--border-color);
1121
- border-radius: 3px;
1122
- background: var(--content-background, #fff);
1123
- color: var(--content-color, #111);
1124
- }
1125
- .btn {
1126
- display: inline-flex;
1127
- align-items: center;
1128
- gap: 5px;
1129
- padding: 4px 11px;
1130
- font-size: 12.5px;
1131
- font-weight: 600;
1132
- border: 1px solid var(--border-color);
1133
- border-radius: 3px;
1134
- background: var(--content-background, #fff);
1135
- color: var(--content-color, #222);
1136
- cursor: pointer;
1137
- white-space: nowrap;
1138
- }
1139
- .btn:hover:not(:disabled) {
1140
- border-color: var(--accent-color);
1141
- color: var(--accent-color);
1142
- }
1143
- .btn.primary {
1144
- background: var(--accent-color, #2563eb);
1145
- border-color: var(--accent-color, #2563eb);
1146
- color: #fff;
1147
- }
1148
- .print-main {
1149
- @apply --horizontal;
1150
- flex: 1;
1151
- min-height: 0;
1152
- overflow: hidden;
1153
- background: #e5e7eb;
1154
- }
1155
- .preview-pane {
1156
- @apply --vertical;
1157
- flex: 1;
1158
- min-width: 0;
1159
- height: 100%;
1160
- padding: 12px;
1161
- overflow: auto;
1162
- align-items: center;
1163
- box-sizing: border-box;
1164
- }
1165
- iframe.sheet-frame {
1166
- width: 100%;
1167
- max-width: 210mm;
1168
- height: 100%;
1169
- min-height: 520px;
1170
- border: 1px solid #9ca3af;
1171
- background: #ffffff;
1172
- box-shadow: 0 4px 14px rgba(0, 0, 0, 0.14);
1173
- }
1174
- .editor-pane {
1175
- @apply --vertical;
1176
- width: 46%;
1177
- min-width: 320px;
1178
- height: 100%;
1179
- border-right: 1px solid var(--border-color);
1180
- background: var(--content-background, #fff);
1181
- padding: 8px 10px;
1182
- gap: 6px;
1183
- box-sizing: border-box;
1184
- }
1185
- .tpl-textarea {
1186
- flex: 1;
1187
- width: 100%;
1188
- resize: none;
1189
- font: 12px/1.4 Consolas, "Courier New", monospace;
1190
- padding: 8px;
1191
- border: 1px solid var(--border-color);
1192
- border-radius: 3px;
1193
- background: var(--content-background, #fff);
1194
- color: var(--content-color, #111);
1195
- box-sizing: border-box;
1196
- }
1197
- .hint-bar {
1198
- font-size: 11px;
1199
- color: var(--muted-color, #6b7280);
1200
- line-height: 1.35;
1201
- }
1202
- .err-bar {
1203
- padding: 6px 12px;
1204
- font-size: 12px;
1205
- color: var(--error-color, #dc2626);
1206
- background: var(--error-soft, #fef2f2);
1207
- border-bottom: 1px solid var(--error-color, #dc2626);
1208
- }
1209
- .print-footer {
1210
- @apply --horizontal;
1211
- align-items: center;
1212
- justify-content: flex-end;
1213
- gap: 8px;
1214
- padding: 6px 12px;
1215
- border-top: 1px solid var(--border-color);
1216
- background: var(--header-background, #f3f4f6);
1217
- flex-shrink: 0;
1218
- }
1219
- </style>
1220
- <div class="print-toolbar">
1221
- <span style="font-weight:600;">Форма:</span>
1222
- <select class="print-select" ~if="forms.length > 1" :value="selectedName" @change="onSelectForm($event.target.value)">
1223
- <option ~for="forms" :value="$for.item.name" :selected="$for.item.name === selectedName">{{$for.item.label || $for.item.name}}</option>
1224
- </select>
1225
- <span ~if="forms.length <= 1" style="font-weight:700; color:var(--accent-color);">{{currentLabel}}</span>
1226
- <button type="button" class="btn primary" @tap="printNow()">
1227
- <oda-icon icon="icons:print" icon-size="16" style="fill:currentColor;"></oda-icon>
1228
- <span>Печать</span>
1229
- </button>
1230
- <button type="button" class="btn" @tap="openInNewTab()">Открыть в отдельном окне</button>
1231
- <div style="flex:1;"></div>
1232
- <button type="button" class="btn" @tap="toggleEditTemplate()">
1233
- <oda-icon icon="icons:settings" icon-size="15"></oda-icon>
1234
- <span>{{editingTemplate ? 'Скрыть шаблон' : 'Настроить шаблон'}}</span>
1235
- </button>
1236
- </div>
1237
- <div class="err-bar" ~if="errorMsg">{{errorMsg}}</div>
1238
- <div class="print-main">
1239
- <div class="editor-pane" ~if="editingTemplate">
1240
- <div style="display:flex; align-items:center; gap:6px;">
1241
- <span style="font-weight:600; font-size:12px;">Имя шаблона:</span>
1242
- <input type="text" :value="templateName" @input="templateName = $event.target.value" style="flex:1; padding:3px 6px; font-size:12.5px; border:1px solid var(--border-color); border-radius:3px;">
1243
- <button type="button" class="btn" @tap="previewCustomTemplate()">Обновить</button>
1244
- <button type="button" class="btn primary" @tap="saveTemplate()">Сохранить</button>
1245
- </div>
1246
- <div class="hint-bar">
1247
- Переменные: <code>{{doc.number}}</code>, <code>{{doc.date}}</code>, <code>{{org.name}}</code>, <code>{{org.inn}}</code>, <code>{{party.name}}</code>, <code>{{party.inn}}</code>, <code>{{money(sum)}}</code>, <code>{{words(sum)}}</code>
1248
- </div>
1249
- <textarea class="tpl-textarea" :value="templateHtml" @input="onTemplateInput($event.target.value)"></textarea>
1250
- </div>
1251
- <div class="preview-pane">
1252
- <iframe id="printFrame" class="sheet-frame" :srcdoc="renderedHtml"></iframe>
1253
- </div>
1254
- </div>
1255
- <div class="print-footer">
1256
- <button type="button" class="btn" @tap="closeModal()">Закрыть</button>
1257
- </div>
1258
- `,
1259
- owner: null,
1260
- targetItem: null,
1261
- docId: '',
1262
- docTitle: '',
1263
- selectedName: '',
1264
- forms: [],
1265
- currentLabel: '',
1266
- renderedHtml: '',
1267
- templateHtml: '',
1268
- templateName: '',
1269
- editingTemplate: false,
1270
- errorMsg: '',
1271
- attached() {
1272
- this.loadForm(this.selectedName);
1273
- },
1274
- async loadForm(name = '') {
1275
- if (!this.targetItem || !this.docId)
1276
- return;
1277
- this.errorMsg = '';
1278
- try {
1279
- const res = await this.targetItem.fetch('db_print', {
1280
- id: this.docId,
1281
- name: name || '',
1282
- fallback: true,
1283
- });
1284
- this.selectedName = res?.name || name || '';
1285
- this.currentLabel = res?.label || res?.name || 'Печатная форма';
1286
- this.templateName = res?.name || 'Печатная форма';
1287
- this.renderedHtml = res?.html || '';
1288
- this.templateHtml = res?.templateHtml || res?.html || '';
1289
- }
1290
- catch (e) {
1291
- this.errorMsg = String(e?.message || e);
1292
- }
1293
- },
1294
- onSelectForm(val) {
1295
- this.selectedName = val;
1296
- this.loadForm(val);
1297
- },
1298
- toggleEditTemplate() {
1299
- this.editingTemplate = !this.editingTemplate;
1300
- },
1301
- onTemplateInput(val) {
1302
- this.templateHtml = val;
1303
- this.debounce('tpl-live-preview', () => this.previewCustomTemplate(), 400);
1304
- },
1305
- async previewCustomTemplate() {
1306
- if (!this.targetItem || !this.docId || !this.templateHtml.trim())
1307
- return;
1308
- this.errorMsg = '';
1309
- try {
1310
- const res = await this.targetItem.fetch('db_print', {
1311
- id: this.docId,
1312
- name: this.templateName || this.selectedName,
1313
- fallback: true,
1314
- }, { customHtml: this.templateHtml });
1315
- if (res?.html)
1316
- this.renderedHtml = res.html;
1317
- }
1318
- catch (e) {
1319
- this.errorMsg = String(e?.message || e);
1320
- }
1321
- },
1322
- async saveTemplate() {
1323
- if (!this.targetItem || !this.templateHtml.trim())
1324
- return;
1325
- this.errorMsg = '';
1326
- try {
1327
- const saved = await this.targetItem.fetch('db_print_save', {
1328
- name: this.templateName || this.selectedName || 'Документ',
1329
- }, {
1330
- name: this.templateName || this.selectedName || 'Документ',
1331
- html: this.templateHtml,
1332
- });
1333
- const list = await this.targetItem.fetch('db_print_list', { id: this.docId }).catch(() => []);
1334
- if (Array.isArray(list) && list.length)
1335
- this.forms = list;
1336
- await this.loadForm(saved?.name || this.templateName);
1337
- this.editingTemplate = false;
1338
- }
1339
- catch (e) {
1340
- this.errorMsg = String(e?.message || e);
1341
- }
1342
- },
1343
- printNow() {
1344
- const frame = this.$?.('#printFrame');
1345
- const win = frame?.contentWindow;
1346
- if (win) {
1347
- win.focus();
1348
- win.print();
1349
- }
1350
- },
1351
- openInNewTab() {
1352
- const win = window.open('', '_blank');
1353
- if (!win)
1354
- return;
1355
- win.document.open();
1356
- win.document.write(this.renderedHtml || '');
1357
- win.document.close();
1358
- win.focus();
1359
- },
1360
- closeModal() {
1361
- for (let p = this.parentElement || this.domHost; p; p = p.parentElement || p.domHost) {
1362
- if (typeof p.close === 'function') {
1363
- p.close('ok');
1364
- return;
1365
- }
1366
- }
1367
- },
1368
- });
1369
- }
1370
-
1371
- export default proto;