nocobase-plugin-dictionary-field 0.2.3

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 (35) hide show
  1. package/README.md +29 -0
  2. package/dist/client/components/DictionaryFieldSettings.d.ts +15 -0
  3. package/dist/client/components/DictionaryManageModal.d.ts +13 -0
  4. package/dist/client/components/DictionarySelect.d.ts +28 -0
  5. package/dist/client/contexts/DictionaryDataProvider.d.ts +55 -0
  6. package/dist/client/index.d.ts +13 -0
  7. package/dist/client/index.js +10 -0
  8. package/dist/client/interfaces/dictionary-field-interface.d.ts +134 -0
  9. package/dist/client/settings/DictionaryItemList.d.ts +10 -0
  10. package/dist/client/settings/DictionaryManagementPage.d.ts +7 -0
  11. package/dist/client/settings/DictionaryTypeList.d.ts +11 -0
  12. package/dist/client/settings/components/DictionaryItemForm.d.ts +17 -0
  13. package/dist/client/settings/components/DictionaryTypeForm.d.ts +17 -0
  14. package/dist/externalVersion.js +20 -0
  15. package/dist/index.d.ts +1 -0
  16. package/dist/index.js +42 -0
  17. package/dist/locale/en-US.json +49 -0
  18. package/dist/locale/zh-CN.json +49 -0
  19. package/dist/server/collections/dictionary-items.d.ts +8 -0
  20. package/dist/server/collections/dictionary-items.js +155 -0
  21. package/dist/server/collections/dictionary-types.d.ts +8 -0
  22. package/dist/server/collections/dictionary-types.js +143 -0
  23. package/dist/server/collections/index.d.ts +7 -0
  24. package/dist/server/collections/index.js +49 -0
  25. package/dist/server/fields/dictionary-field.d.ts +35 -0
  26. package/dist/server/fields/dictionary-field.js +145 -0
  27. package/dist/server/index.d.ts +1 -0
  28. package/dist/server/index.js +42 -0
  29. package/dist/server/plugin.d.ts +72 -0
  30. package/dist/server/plugin.js +210 -0
  31. package/dist/server/resources/dictionary-items.d.ts +42 -0
  32. package/dist/server/resources/dictionary-items.js +172 -0
  33. package/dist/server/resources/dictionary-types.d.ts +36 -0
  34. package/dist/server/resources/dictionary-types.js +137 -0
  35. package/package.json +28 -0
package/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # nocobase-plugin-dictionary-field
2
+
3
+ 字典类型字段插件 / Dictionary Field Type Plugin
4
+
5
+ ## 功能特性 / Features
6
+
7
+ - 创建和管理字典类型及字典项
8
+ - 在数据表字段配置中使用字典类型字段
9
+ - 支持字典项的备注和排序功能
10
+ - 数据录入时使用下拉选择器选择字典项
11
+
12
+ ## 安装 / Installation
13
+
14
+ ```bash
15
+ yarn add nocobase-plugin-dictionary-field
16
+ ```
17
+
18
+ ## 使用说明 / Usage
19
+
20
+ 1. 启用插件后,在"插件设置"中找到"字典管理"
21
+ 2. 创建字典类型(如"客户类型")
22
+ 3. 为字典类型添加字典项(key、value、备注、排序)
23
+ 4. 在数据表字段配置中选择"字典类型字段"
24
+ 5. 绑定对应的字典类型
25
+ 6. 数据录入时通过下拉选择器选择字典项
26
+
27
+ ## 许可证 / License
28
+
29
+ Apache-2.0
@@ -0,0 +1,15 @@
1
+ /**
2
+ * 字典字段配置组件
3
+ * T035: 在字段配置界面中选择字典类型
4
+ */
5
+ import React from 'react';
6
+ interface DictionaryTypeSelectProps {
7
+ value?: string;
8
+ onChange?: (value: string) => void;
9
+ }
10
+ /**
11
+ * 字典类型选择器
12
+ * T038: 实现字典类型选择器,调用 dictionaryTypes API
13
+ */
14
+ export declare const DictionaryTypeSelect: React.FC<DictionaryTypeSelectProps>;
15
+ export default DictionaryTypeSelect;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * 字典项管理模态框
3
+ * 用于在表单中快速管理字典项(增删改)
4
+ */
5
+ import React from 'react';
6
+ interface DictionaryManageModalProps {
7
+ visible: boolean;
8
+ onClose: () => void;
9
+ dictionaryTypeId: string;
10
+ onItemsChange?: () => void;
11
+ }
12
+ export declare const DictionaryManageModal: React.FC<DictionaryManageModalProps>;
13
+ export default DictionaryManageModal;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * 字典选择器组件
3
+ * 用于在数据录入表单中显示和选择字典项(用户故事 3)
4
+ *
5
+ * T042-T050: 实现字典项加载、排序、备注显示和 key-value 转换
6
+ */
7
+ import React from 'react';
8
+ interface DictionarySelectProps {
9
+ value?: string | string[];
10
+ onChange?: (value: string | string[]) => void;
11
+ dictionaryTypeId?: string;
12
+ allowManageItems?: boolean;
13
+ multiple?: boolean;
14
+ }
15
+ /**
16
+ * 字典选择器 - 只读模式
17
+ * T050: 实现 key 到 value 的转换显示
18
+ * 使用缓存优化性能,避免重复 API 请求
19
+ * 显示备注信息(如果有)
20
+ * 支持多选模式的数组显示
21
+ */
22
+ export declare const DictionarySelectReadPretty: React.FC<{
23
+ value?: string | string[];
24
+ dictionaryTypeId?: string;
25
+ multiple?: boolean;
26
+ }>;
27
+ export declare const DictionarySelect: React.ForwardRefExoticComponent<Partial<DictionarySelectProps> & React.RefAttributes<unknown>>;
28
+ export default DictionarySelect;
@@ -0,0 +1,55 @@
1
+ /**
2
+ * 字典数据缓存 Provider
3
+ *
4
+ * 功能:
5
+ * 1. 缓存字典类型的所有字典项数据
6
+ * 2. 避免重复的 API 请求
7
+ * 3. 提供统一的数据获取接口
8
+ */
9
+ import React from 'react';
10
+ interface DictionaryItem {
11
+ id: number;
12
+ dictValue: string;
13
+ dictLabel: string;
14
+ remark?: string;
15
+ dictSort: number;
16
+ dictionaryTypeId: string;
17
+ }
18
+ interface DictionaryDataContextValue {
19
+ /**
20
+ * 获取字典值
21
+ * @param dictionaryTypeId 字典类型ID
22
+ * @param dictValue 字典项的值(存储的值)
23
+ * @returns 字典项的显示值(显示的值),如果未找到返回 dictValue 本身
24
+ */
25
+ getDictionaryLabel: (dictionaryTypeId: string | undefined, dictValue: string | undefined) => Promise<string>;
26
+ /**
27
+ * 获取字典项完整信息
28
+ * @param dictionaryTypeId 字典类型ID
29
+ * @param dictValue 字典项的值(存储的值)
30
+ * @returns 字典项完整对象,如果未找到返回 null
31
+ */
32
+ getDictionaryItem: (dictionaryTypeId: string | undefined, dictValue: string | undefined) => Promise<DictionaryItem | null>;
33
+ /**
34
+ * 清除指定字典类型的缓存
35
+ */
36
+ clearCache: (dictionaryTypeId?: string) => void;
37
+ }
38
+ /**
39
+ * 字典数据 Provider 组件
40
+ */
41
+ export declare const DictionaryDataProvider: React.FC<{
42
+ children: React.ReactNode;
43
+ }>;
44
+ /**
45
+ * 使用字典数据的 Hook
46
+ */
47
+ export declare const useDictionaryData: () => DictionaryDataContextValue;
48
+ /**
49
+ * 使用字典显示值的 Hook
50
+ * @param dictionaryTypeId 字典类型ID
51
+ * @param dictValue 字典项的值(存储的值)
52
+ * @returns 字典项的显示值(显示的值)
53
+ */
54
+ export declare const useDictionaryValue: (dictionaryTypeId: string | undefined, dictValue: string | undefined) => string;
55
+ export {};
@@ -0,0 +1,13 @@
1
+ import { Plugin } from '@nocobase/client';
2
+ /**
3
+ * 字典类型字段插件 - 客户端
4
+ *
5
+ * 功能:
6
+ * 1. 注册字典字段类型
7
+ * 2. 注册字典管理配置页面
8
+ * 3. 加载国际化资源
9
+ */
10
+ export declare class PluginDictionaryFieldClient extends Plugin {
11
+ load(): Promise<void>;
12
+ }
13
+ export default PluginDictionaryFieldClient;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@nocobase/client"),require("react"),require("@formily/react"),require("@ant-design/icons"),require("antd")):"function"==typeof define&&define.amd?define("nocobase-plugin-dictionary-field",["@nocobase/client","react","@formily/react","@ant-design/icons","antd"],t):"object"==typeof exports?exports["nocobase-plugin-dictionary-field"]=t(require("@nocobase/client"),require("react"),require("@formily/react"),require("@ant-design/icons"),require("antd")):e["nocobase-plugin-dictionary-field"]=t(e["@nocobase/client"],e.react,e["@formily/react"],e["@ant-design/icons"],e.antd)}(self,function(e,t,r,n,a){return function(){"use strict";var o={482:function(e){e.exports=n},505:function(e){e.exports=r},772:function(t){t.exports=e},721:function(e){e.exports=a},156:function(e){e.exports=t}},i={};function l(e){var t=i[e];if(void 0!==t)return t.exports;var r=i[e]={exports:{}};return o[e](r,r.exports,l),r.exports}l.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return l.d(t,{a:t}),t},l.d=function(e,t){for(var r in t)l.o(t,r)&&!l.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},l.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},l.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var c={};return!function(){l.r(c),l.d(c,{default:function(){return eb},PluginDictionaryFieldClient:function(){return em}});var e=l(772),t=l(156),r=l.n(t),n=l(721),a=l(482);function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function i(e,t,r,n,a,o,i){try{var l=e[o](i),c=l.value}catch(e){r(e);return}l.done?t(c):Promise.resolve(c).then(n,a)}function u(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,a=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var o=[],i=!0,l=!1;try{for(a=a.call(e);!(i=(r=a.next()).done)&&(o.push(r.value),!t||o.length!==t);i=!0);}catch(e){l=!0,n=e}finally{try{i||null==a.return||a.return()}finally{if(l)throw n}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return o(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return o(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var s=function(e){var t,a,o=e.initialValues,l=e.onSubmit,c=e.onCancel,s=u(n.Form.useForm(),1)[0],f=u(r().useState(!1),2),d=f[0],p=f[1],y=(t=function(){var e;return function(e,t){var r,n,a,o,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function l(o){return function(l){var c=[o,l];if(r)throw TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(a=2&c[0]?n.return:c[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,c[1])).done)return a;switch(n=0,a&&(c=[2&c[0],a.value]),c[0]){case 0:case 1:a=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,n=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(a=(a=i.trys).length>0&&a[a.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!a||c[1]>a[0]&&c[1]<a[3])){i.label=c[1];break}if(6===c[0]&&i.label<a[1]){i.label=a[1],a=c;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(c);break}a[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],n=0}finally{r=a=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}(this,function(t){switch(t.label){case 0:return t.trys.push([0,3,4,5]),[4,s.validateFields()];case 1:return e=t.sent(),p(!0),[4,l(e)];case 2:return t.sent(),[3,5];case 3:return console.error("Validation failed:",t.sent()),[3,5];case 4:return p(!1),[7];case 5:return[2]}})},a=function(){var e=this,r=arguments;return new Promise(function(n,a){var o=t.apply(e,r);function l(e){i(o,n,a,l,c,"next",e)}function c(e){i(o,n,a,l,c,"throw",e)}l(void 0)})},function(){return a.apply(this,arguments)});return r().createElement(n.Form,{form:s,layout:"vertical",initialValues:o||{status:1}},r().createElement(n.Form.Item,{label:"ID(字典标识)",name:"id",rules:[{required:!0,message:"请输入字典标识"},{pattern:/^[a-zA-Z0-9_-]{1,100}$/,message:"标识必须为字母、数字、下划线或连字符,长度1-100个字符"}]},r().createElement(n.Input,{placeholder:"例如:customer_type",disabled:!!(null==o?void 0:o.id)})),r().createElement(n.Form.Item,{label:"字典名称",name:"dictName",rules:[{required:!0,message:"请输入字典名称"},{max:200,message:"名称长度不能超过200个字符"}]},r().createElement(n.Input,{placeholder:"例如:客户类型"})),r().createElement(n.Form.Item,{label:"备注",name:"remark",rules:[{max:1e3,message:"备注长度不能超过1000个字符"}]},r().createElement(n.Input.TextArea,{rows:4,placeholder:"描述此字典类型的用途"})),r().createElement(n.Form.Item,{style:{marginBottom:0}},r().createElement(n.Space,{style:{width:"100%",justifyContent:"flex-end"}},r().createElement(n.Button,{onClick:c},"取消"),r().createElement(n.Button,{type:"primary",loading:d,onClick:y},"保存"))))};function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function d(e,t,r,n,a,o,i){try{var l=e[o](i),c=l.value}catch(e){r(e);return}l.done?t(c):Promise.resolve(c).then(n,a)}function p(e){return function(){var t=this,r=arguments;return new Promise(function(n,a){var o=e.apply(t,r);function i(e){d(o,n,a,i,l,"next",e)}function l(e){d(o,n,a,i,l,"throw",e)}i(void 0)})}}function y(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,a=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var o=[],i=!0,l=!1;try{for(a=a.call(e);!(i=(r=a.next()).done)&&(o.push(r.value),!t||o.length!==t);i=!0);}catch(e){l=!0,n=e}finally{try{i||null==a.return||a.return()}finally{if(l)throw n}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return f(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return f(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function m(e,t){var r,n,a,o,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function l(o){return function(l){var c=[o,l];if(r)throw TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(a=2&c[0]?n.return:c[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,c[1])).done)return a;switch(n=0,a&&(c=[2&c[0],a.value]),c[0]){case 0:case 1:a=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,n=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(a=(a=i.trys).length>0&&a[a.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!a||c[1]>a[0]&&c[1]<a[3])){i.label=c[1];break}if(6===c[0]&&i.label<a[1]){i.label=a[1],a=c;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(c);break}a[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],n=0}finally{r=a=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}var b=function(o){var i,l,c,u=o.onSelect,f=o.selectedId,d=(0,e.useAPIClient)(),b=y((0,t.useState)([]),2),h=b[0],v=b[1],g=y((0,t.useState)(!1),2),w=g[0],S=g[1],E=y((0,t.useState)(!1),2),O=E[0],I=E[1],k=y((0,t.useState)(null),2),x=k[0],D=k[1],P=(i=p(function(){var e,t,r,a;return m(this,function(o){switch(o.label){case 0:S(!0),o.label=1;case 1:return o.trys.push([1,3,4,5]),[4,d.request({url:"rbDataDictionaryTypes:list",method:"get",params:{pageSize:1e3,sort:["createdAt"]}})];case 2:return Array.isArray(r=null==(t=o.sent())||null==(e=t.data)?void 0:e.data)?v(r):(console.error("Expected array but got:",r),v([])),[3,5];case 3:return a=o.sent(),n.message.error("加载字典类型失败"),console.error(a),v([]),[3,5];case 4:return S(!1),[7];case 5:return[2]}})}),function(){return i.apply(this,arguments)});(0,t.useEffect)(function(){P()},[]);var A=function(e){D(e),I(!0)},j=(l=p(function(e){return m(this,function(t){return n.Modal.confirm({title:"确认删除",content:"确定要删除这个字典类型吗?",okText:"删除",okType:"danger",cancelText:"取消",onOk:p(function(){var t,r,a;return m(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,d.request({url:"rbDataDictionaryTypes:destroy/".concat(e),method:"post"})];case 1:return o.sent(),n.message.success("删除成功"),f===e&&u(null),P(),[3,3];case 2:return t=o.sent(),n.message.error((null==t||null==(a=t.response)||null==(r=a.data)?void 0:r.error)||"删除失败"),[3,3];case 3:return[2]}})})}),[2]})}),function(e){return l.apply(this,arguments)}),T=(c=p(function(e){var t,r,a;return m(this,function(o){switch(o.label){case 0:if(o.trys.push([0,5,,6]),!x)return[3,2];return[4,d.request({url:"rbDataDictionaryTypes:update/".concat(x.id),method:"post",data:e})];case 1:return o.sent(),n.message.success("更新成功"),[3,4];case 2:return[4,d.request({url:"rbDataDictionaryTypes:create",method:"post",data:e})];case 3:o.sent(),n.message.success("创建成功"),o.label=4;case 4:return I(!1),P(),[3,6];case 5:return t=o.sent(),n.message.error((null==t||null==(a=t.response)||null==(r=a.data)?void 0:r.error)||"保存失败"),[3,6];case 6:return[2]}})}),function(e){return c.apply(this,arguments)});return r().createElement(r().Fragment,null,r().createElement("div",{style:{marginBottom:16}},r().createElement(n.Button,{type:"primary",icon:r().createElement(a.PlusOutlined,null),onClick:function(){D(null),I(!0)},block:!0},"新建字典类型")),r().createElement(n.List,{loading:w,dataSource:h,renderItem:function(e){return r().createElement(n.List.Item,{style:{cursor:"pointer",background:f===e.id?"#e6f7ff":"transparent"},onClick:function(){return u(e.id)},actions:[r().createElement(n.Button,{key:"edit",type:"link",size:"small",icon:r().createElement(a.EditOutlined,null),onClick:function(t){t.stopPropagation(),A(e)}}),r().createElement(n.Button,{key:"delete",type:"link",danger:!0,size:"small",icon:r().createElement(a.DeleteOutlined,null),onClick:function(t){t.stopPropagation(),j(e.id)}})]},r().createElement(n.List.Item.Meta,{title:e.dictName,description:e.remark}))}}),r().createElement(n.Modal,{title:x?"编辑字典类型":"新建字典类型",open:O,onCancel:function(){return I(!1)},footer:null,destroyOnClose:!0},r().createElement(s,{initialValues:x||void 0,onSubmit:T,onCancel:function(){return I(!1)}})))};function h(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function v(e,t,r,n,a,o,i){try{var l=e[o](i),c=l.value}catch(e){r(e);return}l.done?t(c):Promise.resolve(c).then(n,a)}function g(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,a=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var o=[],i=!0,l=!1;try{for(a=a.call(e);!(i=(r=a.next()).done)&&(o.push(r.value),!t||o.length!==t);i=!0);}catch(e){l=!0,n=e}finally{try{i||null==a.return||a.return()}finally{if(l)throw n}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return h(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return h(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var w=function(e){var t,a,o=e.initialValues,i=e.onSubmit,l=e.onCancel,c=g(n.Form.useForm(),1)[0],u=g(r().useState(!1),2),s=u[0],f=u[1],d=(t=function(){var e;return function(e,t){var r,n,a,o,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function l(o){return function(l){var c=[o,l];if(r)throw TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(a=2&c[0]?n.return:c[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,c[1])).done)return a;switch(n=0,a&&(c=[2&c[0],a.value]),c[0]){case 0:case 1:a=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,n=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(a=(a=i.trys).length>0&&a[a.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!a||c[1]>a[0]&&c[1]<a[3])){i.label=c[1];break}if(6===c[0]&&i.label<a[1]){i.label=a[1],a=c;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(c);break}a[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],n=0}finally{r=a=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}(this,function(t){switch(t.label){case 0:return t.trys.push([0,3,4,5]),[4,c.validateFields()];case 1:return e=t.sent(),f(!0),[4,i(e)];case 2:return t.sent(),[3,5];case 3:return console.error("Validation failed:",t.sent()),[3,5];case 4:return f(!1),[7];case 5:return[2]}})},a=function(){var e=this,r=arguments;return new Promise(function(n,a){var o=t.apply(e,r);function i(e){v(o,n,a,i,l,"next",e)}function l(e){v(o,n,a,i,l,"throw",e)}i(void 0)})},function(){return a.apply(this,arguments)});return r().createElement(n.Form,{form:c,layout:"vertical",initialValues:o||{dictSort:0}},r().createElement(n.Form.Item,{label:"键值",name:"dictValue",rules:[{required:!0,message:"请输入键值"},{pattern:/^[^\s]{1,100}$/,message:"键值不能包含空格,长度1-100个字符"}]},r().createElement(n.Input,{placeholder:"例如:vip 或 优质客户"})),r().createElement(n.Form.Item,{label:"显示值",name:"dictLabel",rules:[{required:!0,message:"请输入显示值"},{max:200,message:"显示值长度不能超过200个字符"}]},r().createElement(n.Input,{placeholder:"例如:VIP客户"})),r().createElement(n.Form.Item,{label:"备注",name:"remark",rules:[{max:500,message:"备注长度不能超过500个字符"}]},r().createElement(n.Input.TextArea,{rows:3,placeholder:"例如:年消费10万以上"})),r().createElement(n.Form.Item,{label:"排序序号",name:"dictSort",rules:[{required:!0,message:"请输入排序序号"}]},r().createElement(n.InputNumber,{style:{width:"100%"},placeholder:"数字越小越靠前",min:-0x80000000,max:0x7fffffff})),r().createElement(n.Form.Item,{style:{marginBottom:0}},r().createElement(n.Space,{style:{width:"100%",justifyContent:"flex-end"}},r().createElement(n.Button,{onClick:l},"取消"),r().createElement(n.Button,{type:"primary",loading:s,onClick:d},"保存"))))};function S(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function E(e,t,r,n,a,o,i){try{var l=e[o](i),c=l.value}catch(e){r(e);return}l.done?t(c):Promise.resolve(c).then(n,a)}function O(e){return function(){var t=this,r=arguments;return new Promise(function(n,a){var o=e.apply(t,r);function i(e){E(o,n,a,i,l,"next",e)}function l(e){E(o,n,a,i,l,"throw",e)}i(void 0)})}}function I(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,a=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var o=[],i=!0,l=!1;try{for(a=a.call(e);!(i=(r=a.next()).done)&&(o.push(r.value),!t||o.length!==t);i=!0);}catch(e){l=!0,n=e}finally{try{i||null==a.return||a.return()}finally{if(l)throw n}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return S(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return S(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function k(e,t){var r,n,a,o,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function l(o){return function(l){var c=[o,l];if(r)throw TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(a=2&c[0]?n.return:c[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,c[1])).done)return a;switch(n=0,a&&(c=[2&c[0],a.value]),c[0]){case 0:case 1:a=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,n=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(a=(a=i.trys).length>0&&a[a.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!a||c[1]>a[0]&&c[1]<a[3])){i.label=c[1];break}if(6===c[0]&&i.label<a[1]){i.label=a[1],a=c;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(c);break}a[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],n=0}finally{r=a=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}var x=function(o){var i,l,c,u=o.dictionaryTypeId,s=(0,e.useAPIClient)(),f=I((0,t.useState)([]),2),d=f[0],p=f[1],y=I((0,t.useState)(!1),2),m=y[0],b=y[1],h=I((0,t.useState)(!1),2),v=h[0],g=h[1],S=I((0,t.useState)(null),2),E=S[0],x=S[1],D=(i=O(function(){var e,t,r,a;return k(this,function(o){switch(o.label){case 0:if(!u)return[2];b(!0),o.label=1;case 1:return o.trys.push([1,3,4,5]),[4,s.request({url:"rbDataDictionaryItems:list",method:"get",params:{filter:{dictionaryTypeId:u},pageSize:1e3,sort:["dictSort","createdAt"]}})];case 2:return Array.isArray(r=null==(t=o.sent())||null==(e=t.data)?void 0:e.data)?p(r):(console.error("Expected array but got:",r),p([])),[3,5];case 3:return a=o.sent(),n.message.error("加载字典项失败"),console.error(a),p([]),[3,5];case 4:return b(!1),[7];case 5:return[2]}})}),function(){return i.apply(this,arguments)});(0,t.useEffect)(function(){D()},[u]);var P=function(e){x(e),g(!0)},A=(l=O(function(e){return k(this,function(t){return n.Modal.confirm({title:"确认删除",content:"确定要删除这个字典项吗?",okText:"删除",okType:"danger",cancelText:"取消",onOk:O(function(){var t,r,a;return k(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,s.request({url:"rbDataDictionaryItems:destroy/".concat(e),method:"post"})];case 1:return o.sent(),n.message.success("删除成功"),D(),[3,3];case 2:return t=o.sent(),n.message.error((null==t||null==(a=t.response)||null==(r=a.data)?void 0:r.error)||"删除失败"),[3,3];case 3:return[2]}})})}),[2]})}),function(e){return l.apply(this,arguments)}),j=(c=O(function(e){var t,r,a,o;return k(this,function(i){switch(i.label){case 0:var l,c;if(i.trys.push([0,5,,6]),l=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({},e),c=c={dictionaryTypeId:u},Object.getOwnPropertyDescriptors?Object.defineProperties(l,Object.getOwnPropertyDescriptors(c)):(function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r.push.apply(r,n)}return r})(Object(c)).forEach(function(e){Object.defineProperty(l,e,Object.getOwnPropertyDescriptor(c,e))}),t=l,!E)return[3,2];return[4,s.request({url:"rbDataDictionaryItems:update/".concat(E.id),method:"post",data:t})];case 1:return i.sent(),n.message.success("更新成功"),[3,4];case 2:return[4,s.request({url:"rbDataDictionaryItems:create",method:"post",data:t})];case 3:i.sent(),n.message.success("创建成功"),i.label=4;case 4:return g(!1),D(),[3,6];case 5:return r=i.sent(),n.message.error((null==r||null==(o=r.response)||null==(a=o.data)?void 0:a.error)||"保存失败"),[3,6];case 6:return[2]}})}),function(e){return c.apply(this,arguments)}),T=[{title:"键值",dataIndex:"dictValue",key:"dictValue",width:150},{title:"显示值",dataIndex:"dictLabel",key:"dictLabel",width:200},{title:"备注",dataIndex:"remark",key:"remark",width:300,render:function(e){return e?r().createElement(n.Tooltip,{title:e},r().createElement("span",null,e.substring(0,50),e.length>50&&"..."," ",r().createElement(a.InfoCircleOutlined,null))):"-"}},{title:"排序序号",dataIndex:"dictSort",key:"dictSort",width:100},{title:"操作",key:"actions",width:120,render:function(e,t){return r().createElement(n.Space,null,r().createElement(n.Button,{type:"link",size:"small",icon:r().createElement(a.EditOutlined,null),onClick:function(){return P(t)}}),r().createElement(n.Button,{type:"link",danger:!0,size:"small",icon:r().createElement(a.DeleteOutlined,null),onClick:function(){return A(t.id)}}))}}];return r().createElement(r().Fragment,null,r().createElement("div",{style:{marginBottom:16}},r().createElement(n.Button,{type:"primary",icon:r().createElement(a.PlusOutlined,null),onClick:function(){x(null),g(!0)}},"新建字典项")),r().createElement(n.Table,{loading:m,dataSource:d,columns:T,rowKey:"id",pagination:{pageSize:20,showTotal:function(e){return"共 ".concat(e," 条")}}}),r().createElement(n.Modal,{title:E?"编辑字典项":"新建字典项",open:v,onCancel:function(){return g(!1)},footer:null,destroyOnClose:!0},r().createElement(w,{initialValues:E||void 0,onSubmit:j,onCancel:function(){return g(!1)}})))};function D(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var P=function(){var e,a=(e=(0,t.useState)(null),function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,a=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var o=[],i=!0,l=!1;try{for(a=a.call(e);!(i=(r=a.next()).done)&&(o.push(r.value),o.length!==t);i=!0);}catch(e){l=!0,n=e}finally{try{i||null==a.return||a.return()}finally{if(l)throw n}}return o}}(e,2)||function(e,t){if(e){if("string"==typeof e)return D(e,2);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return D(e,t)}}(e,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),o=a[0],i=a[1];return r().createElement("div",{style:{padding:24}},r().createElement(n.Row,{gutter:16},r().createElement(n.Col,{span:8},r().createElement(n.Card,{title:"字典类型",bordered:!1},r().createElement(b,{onSelect:i,selectedId:o}))),r().createElement(n.Col,{span:16},r().createElement(n.Card,{title:o?"字典项":"请选择字典类型",bordered:!1},o?r().createElement(x,{dictionaryTypeId:o}):r().createElement("div",{style:{textAlign:"center",padding:48,color:"#999"}},"请先在左侧选择一个字典类型")))))};function A(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function j(e){return(j=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function T(e,t){return(T=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function C(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(C=function(){return!!e})()}var F=function(t){var r;if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");function n(){var t,r,a,o,i;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return r=n,a=arguments,r=j(r),A(t=function(e,t){var r;if(t&&("object"==((r=t)&&"undefined"!=typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,C()?Reflect.construct(r,a||[],j(this).constructor):r.apply(this,a)),"name","dictionary"),A(t,"type","object"),A(t,"group","choices"),A(t,"order",2),A(t,"title",'{{t("Dictionary Field", { ns: "dictionary-field" })}}'),A(t,"description",'{{t("Dictionary field with key-value pairs", { ns: "dictionary-field" })}}'),A(t,"sortable",!0),A(t,"default",{type:"dictionary",uiSchema:{type:"string","x-component":"DictionarySelect"}}),A(t,"availableTypes",["dictionary"]),A(t,"hasDefaultValue",!0),A(t,"filterable",{operators:e.operators.string}),A(t,"titleUsable",!0),A(t,"properties",(o=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){A(e,t,r[t])})}return e}({},e.defaultProps),i=i={"uiSchema.x-component-props.dictionaryTypeId":{type:"number",title:'{{t("Dictionary Type", { ns: "dictionary-field" })}}',"x-decorator":"FormItem","x-component":"DictionaryTypeSelect",required:!0},"uiSchema.x-component-props.multiple":{type:"boolean",title:'{{t("Allow multiple selection", { ns: "dictionary-field" })}}',"x-decorator":"FormItem","x-component":"Checkbox","x-content":'{{t("Enable multi-select mode for this field", { ns: "dictionary-field" })}}',default:!1},"uiSchema.x-component-props.allowManageItems":{type:"boolean",title:'{{t("Allow managing items", { ns: "dictionary-field" })}}',"x-decorator":"FormItem","x-component":"Checkbox","x-content":'{{t("Allow users to add, edit, or delete dictionary items in forms", { ns: "dictionary-field" })}}',default:!1}},Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(i)):(function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r.push.apply(r,n)}return r})(Object(i)).forEach(function(e){Object.defineProperty(o,e,Object.getOwnPropertyDescriptor(i,e))}),o)),t}return n.prototype=Object.create(t&&t.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),t&&T(n,t),r=[{key:"getDefaultValueProperty",value:function(){return{defaultValue:{type:"string",title:'{{t("Default value")}}',"x-decorator":"FormItem","x-component":"DictionarySelect",required:!1,"x-reactions":[{dependencies:["uiSchema.x-component-props.dictionaryTypeId","uiSchema.x-component-props.multiple"],fulfill:{state:{visible:"{{!!$deps[0]}}",componentProps:{dictionaryTypeId:"{{$deps[0]}}",multiple:"{{$deps[1]}}"}}}},{dependencies:["primaryKey","unique","autoIncrement"],when:"{{$deps[0]||$deps[1]||$deps[2]}}",fulfill:{state:{hidden:!0,value:null}},otherwise:{state:{hidden:!1}}}]}}}},{key:"schemaInitialize",value:function(e,t){var r=t.block,n=e["x-component-props"]=e["x-component-props"]||{};["Table","Kanban"].includes(r)&&(n.ellipsis=!0)}}],function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(n.prototype,r),n}(e.CollectionFieldInterface);function M(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function q(e,t,r,n,a,o,i){try{var l=e[o](i),c=l.value}catch(e){r(e);return}l.done?t(c):Promise.resolve(c).then(n,a)}function V(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,a=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var o=[],i=!0,l=!1;try{for(a=a.call(e);!(i=(r=a.next()).done)&&(o.push(r.value),!t||o.length!==t);i=!0);}catch(e){l=!0,n=e}finally{try{i||null==a.return||a.return()}finally{if(l)throw n}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return M(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return M(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var B=function(a){var o=a.value,i=a.onChange,l=(0,e.useAPIClient)(),c=(0,e.useCompile)(),u=V((0,t.useState)([]),2),s=u[0],f=u[1],d=V((0,t.useState)(!1),2),p=d[0],y=d[1];return(0,t.useEffect)(function(){var e,t;(e=function(){var e,t,r;return function(e,t){var r,n,a,o,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function l(o){return function(l){var c=[o,l];if(r)throw TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(a=2&c[0]?n.return:c[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,c[1])).done)return a;switch(n=0,a&&(c=[2&c[0],a.value]),c[0]){case 0:case 1:a=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,n=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(a=(a=i.trys).length>0&&a[a.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!a||c[1]>a[0]&&c[1]<a[3])){i.label=c[1];break}if(6===c[0]&&i.label<a[1]){i.label=a[1],a=c;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(c);break}a[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],n=0}finally{r=a=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}(this,function(n){switch(n.label){case 0:y(!0),n.label=1;case 1:return n.trys.push([1,3,4,5]),[4,l.request({url:"rbDataDictionaryTypes:list",method:"get",params:{pageSize:1e3,sort:["createdAt"]}})];case 2:return Array.isArray(r=null==(t=n.sent())||null==(e=t.data)?void 0:e.data)?f(r):f([]),[3,5];case 3:return console.error("Failed to load dictionary types:",n.sent()),f([]),[3,5];case 4:return y(!1),[7];case 5:return[2]}})},t=function(){var t=this,r=arguments;return new Promise(function(n,a){var o=e.apply(t,r);function i(e){q(o,n,a,i,l,"next",e)}function l(e){q(o,n,a,i,l,"throw",e)}i(void 0)})},function(){return t.apply(this,arguments)})()},[l]),r().createElement(n.Select,{value:o,onChange:i,loading:p,placeholder:c('{{t("Select Dictionary Type", { ns: "dictionary-field" })}}'),style:{width:"100%"},notFoundContent:p?r().createElement(n.Spin,{size:"small"}):c('{{t("No dictionary types available", { ns: "dictionary-field" })}}')},s.map(function(e){return r().createElement(n.Select.Option,{key:e.id,value:e.id},e.dictName,e.remark&&r().createElement("span",{style:{color:"#999",marginLeft:8}},"(",e.remark,")"))}))},z=l(505);function L(e,t,r,n,a,o,i){try{var l=e[o](i),c=l.value}catch(e){r(e);return}l.done?t(c):Promise.resolve(c).then(n,a)}function _(e){return function(){var t=this,r=arguments;return new Promise(function(n,a){var o=e.apply(t,r);function i(e){L(o,n,a,i,l,"next",e)}function l(e){L(o,n,a,i,l,"throw",e)}i(void 0)})}}function N(e,t){var r,n,a,o,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function l(o){return function(l){var c=[o,l];if(r)throw TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(a=2&c[0]?n.return:c[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,c[1])).done)return a;switch(n=0,a&&(c=[2&c[0],a.value]),c[0]){case 0:case 1:a=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,n=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(a=(a=i.trys).length>0&&a[a.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!a||c[1]>a[0]&&c[1]<a[3])){i.label=c[1];break}if(6===c[0]&&i.label<a[1]){i.label=a[1],a=c;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(c);break}a[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],n=0}finally{r=a=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}var R=(0,t.createContext)(null),$=function(n){var a,o,i,l=n.children,c=(0,e.useAPIClient)(),u=(0,t.useRef)(new Map),s=(0,t.useRef)(new Map),f=(0,t.useCallback)((a=_(function(e){var t,r;return N(this,function(n){return(t=s.current.get(e))?[2,t]:u.current.has(e)?[2]:(r=_(function(){var t,r,n,a,o;return N(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,3,4]),[4,c.request({url:"rbDataDictionaryItems:list",method:"get",params:{filter:{dictionaryTypeId:e},pageSize:1e3,sort:["dictSort","createdAt"]}})];case 1:return n=(null==(r=i.sent())||null==(t=r.data)?void 0:t.data)||[],a=new Map,n.forEach(function(e){a.set(e.dictValue,e)}),u.current.set(e,a),console.log("[DictionaryData] Loaded ".concat(n.length," items for type ").concat(e)),[3,4];case 2:return o=i.sent(),console.error("[DictionaryData] Failed to load dictionary type ".concat(e,":"),o),u.current.set(e,new Map),[3,4];case 3:return s.current.delete(e),[7];case 4:return[2]}})})(),s.current.set(e,r),[2,r])})}),function(e){return a.apply(this,arguments)}),[c]),d=(0,t.useCallback)((o=_(function(e,t){var r;return N(this,function(n){switch(n.label){case 0:if(!e||!t)return[2,null];return[4,f(e)];case 1:if(n.sent(),!(r=u.current.get(e)))return[2,null];return[2,r.get(t)||null]}})}),function(e,t){return o.apply(this,arguments)}),[f]),p=(0,t.useCallback)((i=_(function(e,t){var r;return N(this,function(n){switch(n.label){case 0:if(!e||!t)return[2,t||"-"];return[4,d(e,t)];case 1:return[2,(null==(r=n.sent())?void 0:r.dictLabel)||t]}})}),function(e,t){return i.apply(this,arguments)}),[d]),y=(0,t.useCallback)(function(e){void 0!==e?(u.current.delete(e),s.current.delete(e),console.log("[DictionaryData] Cleared cache for type ".concat(e))):(u.current.clear(),s.current.clear(),console.log("[DictionaryData] Cleared all cache"))},[]);return r().createElement(R.Provider,{value:{getDictionaryLabel:p,getDictionaryItem:d,clearCache:y}},l)},U=function(){var e=(0,t.useContext)(R);if(!e)throw Error("useDictionaryData must be used within DictionaryDataProvider");return e};function G(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function K(e,t,r,n,a,o,i){try{var l=e[o](i),c=l.value}catch(e){r(e);return}l.done?t(c):Promise.resolve(c).then(n,a)}function Q(e){return function(){var t=this,r=arguments;return new Promise(function(n,a){var o=e.apply(t,r);function i(e){K(o,n,a,i,l,"next",e)}function l(e){K(o,n,a,i,l,"throw",e)}i(void 0)})}}function J(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}function Y(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r.push.apply(r,n)}return r})(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function Z(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,a=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var o=[],i=!0,l=!1;try{for(a=a.call(e);!(i=(r=a.next()).done)&&(o.push(r.value),!t||o.length!==t);i=!0);}catch(e){l=!0,n=e}finally{try{i||null==a.return||a.return()}finally{if(l)throw n}}return o}}(e,t)||H(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function H(e,t){if(e){if("string"==typeof e)return G(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return G(e,t)}}function W(e,t){var r,n,a,o,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function l(o){return function(l){var c=[o,l];if(r)throw TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(a=2&c[0]?n.return:c[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,c[1])).done)return a;switch(n=0,a&&(c=[2&c[0],a.value]),c[0]){case 0:case 1:a=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,n=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(a=(a=i.trys).length>0&&a[a.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!a||c[1]>a[0]&&c[1]<a[3])){i.label=c[1];break}if(6===c[0]&&i.label<a[1]){i.label=a[1],a=c;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(c);break}a[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],n=0}finally{r=a=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}var X=function(o){var i,l,c,u=o.visible,s=o.onClose,f=o.dictionaryTypeId,d=o.onItemsChange,p=(0,e.useAPIClient)(),y=(0,e.useCompile)(),m=Z((0,t.useState)([]),2),b=m[0],h=m[1],v=Z((0,t.useState)(!1),2),g=v[0],w=v[1],S=Z((0,t.useState)(null),2),E=S[0],O=S[1],I=Z((0,t.useState)(!1),2),k=I[0],x=I[1],D=Z(n.Form.useForm(),1)[0],P=(i=Q(function(){var e,t;return W(this,function(r){switch(r.label){case 0:if(!f)return[2];w(!0),r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,p.request({url:"rbDataDictionaryItems:list",method:"get",params:{filter:{dictionaryTypeId:f},sort:["dictSort","createdAt"],pageSize:1e3}})];case 2:return h((null==(t=r.sent())||null==(e=t.data)?void 0:e.data)||[]),[3,5];case 3:return console.error("Failed to load dictionary items:",r.sent()),n.message.error(y('{{t("Failed to load items", { ns: "dictionary-field" })}}')),[3,5];case 4:return w(!1),[7];case 5:return[2]}})}),function(){return i.apply(this,arguments)});(0,t.useEffect)(function(){u&&f&&P()},[u,f]);var A=function(e){if(e)O(e),D.setFieldsValue(e);else{O(null),D.resetFields();var t,r,n=b.length>0?(r=Math).max.apply(r,function(e){if(Array.isArray(e))return G(e)}(t=b.map(function(e){return e.dictSort||0}))||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||H(t)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()):0;D.setFieldsValue({dictSort:n+10})}x(!0)},j=(l=Q(function(){var e;return W(this,function(t){switch(t.label){case 0:return t.trys.push([0,7,,8]),[4,D.validateFields()];case 1:if(e=t.sent(),!(null==E?void 0:E.id))return[3,3];return[4,p.request({url:"rbDataDictionaryItems:update",method:"post",params:{filterByTk:E.id},data:Y(J({},e),{dictionaryTypeId:f})})];case 2:return t.sent(),n.message.success(y('{{t("Updated successfully", { ns: "dictionary-field" })}}')),[3,5];case 3:return[4,p.request({url:"rbDataDictionaryItems:create",method:"post",data:Y(J({},e),{dictionaryTypeId:f})})];case 4:t.sent(),n.message.success(y('{{t("Created successfully", { ns: "dictionary-field" })}}')),t.label=5;case 5:return x(!1),[4,P()];case 6:return t.sent(),null==d||d(),[3,8];case 7:return console.error("Failed to save dictionary item:",t.sent()),n.message.error(y('{{t("Failed to save", { ns: "dictionary-field" })}}')),[3,8];case 8:return[2]}})}),function(){return l.apply(this,arguments)}),T=(c=Q(function(e){return W(this,function(t){switch(t.label){case 0:return t.trys.push([0,3,,4]),[4,p.request({url:"rbDataDictionaryItems:destroy",method:"post",params:{filterByTk:e}})];case 1:return t.sent(),n.message.success(y('{{t("Deleted successfully", { ns: "dictionary-field" })}}')),[4,P()];case 2:return t.sent(),null==d||d(),[3,4];case 3:return console.error("Failed to delete dictionary item:",t.sent()),n.message.error(y('{{t("Failed to delete", { ns: "dictionary-field" })}}')),[3,4];case 4:return[2]}})}),function(e){return c.apply(this,arguments)}),C=[{title:y('{{t("Label", { ns: "dictionary-field" })}}'),dataIndex:"dictLabel",key:"dictLabel"},{title:y('{{t("Value", { ns: "dictionary-field" })}}'),dataIndex:"dictValue",key:"dictValue"},{title:y('{{t("Sort", { ns: "dictionary-field" })}}'),dataIndex:"dictSort",key:"dictSort",width:80},{title:y('{{t("Remark", { ns: "dictionary-field" })}}'),dataIndex:"remark",key:"remark",ellipsis:!0},{title:y('{{t("Actions")}}'),key:"actions",width:120,render:function(e,t){return r().createElement(n.Space,{size:"small"},r().createElement(n.Button,{type:"link",size:"small",icon:r().createElement(a.EditOutlined,null),onClick:function(){return A(t)}},y('{{t("Edit")}}')),r().createElement(n.Popconfirm,{title:y('{{t("Are you sure you want to delete this item?", { ns: "dictionary-field" })}}'),onConfirm:function(){return T(t.id)},okText:y('{{t("Yes")}}'),cancelText:y('{{t("No")}}')},r().createElement(n.Button,{type:"link",size:"small",danger:!0,icon:r().createElement(a.DeleteOutlined,null)},y('{{t("Delete")}}'))))}}];return r().createElement(r().Fragment,null,r().createElement(n.Modal,{title:y('{{t("Manage Dictionary Items", { ns: "dictionary-field" })}}'),open:u,onCancel:s,width:800,footer:[r().createElement(n.Button,{key:"close",onClick:s},y('{{t("Close")}}'))]},r().createElement("div",{style:{marginBottom:16}},r().createElement(n.Button,{type:"primary",icon:r().createElement(a.PlusOutlined,null),onClick:function(){return A()}},y('{{t("Add Item", { ns: "dictionary-field" })}}'))),r().createElement(n.Table,{dataSource:b,columns:C,rowKey:"id",loading:g,pagination:!1,size:"small",scroll:{y:400}})),r().createElement(n.Modal,{title:E?y('{{t("Edit Item", { ns: "dictionary-field" })}}'):y('{{t("Add Item", { ns: "dictionary-field" })}}'),open:k,onOk:j,onCancel:function(){return x(!1)},okText:y('{{t("Save")}}'),cancelText:y('{{t("Cancel")}}')},r().createElement(n.Form,{form:D,layout:"vertical"},r().createElement(n.Form.Item,{name:"dictLabel",label:y('{{t("Label", { ns: "dictionary-field" })}}'),rules:[{required:!0,message:y('{{t("Please input label", { ns: "dictionary-field" })}}')}]},r().createElement(n.Input,{placeholder:y('{{t("Display text", { ns: "dictionary-field" })}}')})),r().createElement(n.Form.Item,{name:"dictValue",label:y('{{t("Value", { ns: "dictionary-field" })}}'),rules:[{required:!0,message:y('{{t("Please input value", { ns: "dictionary-field" })}}')}]},r().createElement(n.Input,{placeholder:y('{{t("Stored value", { ns: "dictionary-field" })}}')})),r().createElement(n.Form.Item,{name:"dictSort",label:y('{{t("Sort", { ns: "dictionary-field" })}}'),rules:[{required:!0,message:y('{{t("Please input sort order", { ns: "dictionary-field" })}}')}]},r().createElement(n.InputNumber,{style:{width:"100%"},min:0})),r().createElement(n.Form.Item,{name:"remark",label:y('{{t("Remark", { ns: "dictionary-field" })}}')},r().createElement(n.Input.TextArea,{rows:3,placeholder:y('{{t("Optional remark", { ns: "dictionary-field" })}}')})))))};function ee(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function et(e,t,r,n,a,o,i){try{var l=e[o](i),c=l.value}catch(e){r(e);return}l.done?t(c):Promise.resolve(c).then(n,a)}function er(e){return function(){var t=this,r=arguments;return new Promise(function(n,a){var o=e.apply(t,r);function i(e){et(o,n,a,i,l,"next",e)}function l(e){et(o,n,a,i,l,"throw",e)}i(void 0)})}}function en(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,a=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var o=[],i=!0,l=!1;try{for(a=a.call(e);!(i=(r=a.next()).done)&&(o.push(r.value),!t||o.length!==t);i=!0);}catch(e){l=!0,n=e}finally{try{i||null==a.return||a.return()}finally{if(l)throw n}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return ee(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return ee(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ea(e,t){var r,n,a,o,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function l(o){return function(l){var c=[o,l];if(r)throw TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(a=2&c[0]?n.return:c[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,c[1])).done)return a;switch(n=0,a&&(c=[2&c[0],a.value]),c[0]){case 0:case 1:a=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,n=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(a=(a=i.trys).length>0&&a[a.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!a||c[1]>a[0]&&c[1]<a[3])){i.label=c[1];break}if(6===c[0]&&i.label<a[1]){i.label=a[1],a=c;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(c);break}a[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],n=0}finally{r=a=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}var eo=function(o){var i,l,c,u,s,f,d,p,y=o.value,m=o.dictionaryTypeId,b=o.multiple,h=(0,z.useField)(),v=(0,z.useFieldSchema)(),g=(0,e.useCollectionField)(),w=U().getDictionaryItem,S=en((0,t.useState)([]),2),E=S[0],O=S[1];(0,e.useFieldTitle)();var I=m||(null==g||null==(l=g.uiSchema)||null==(i=l["x-component-props"])?void 0:i.dictionaryTypeId)||(null==h||null==(c=h.componentProps)?void 0:c.dictionaryTypeId)||(null==v||null==(u=v["x-component-props"])?void 0:u.dictionaryTypeId),k=b||(null==g||null==(f=g.uiSchema)||null==(s=f["x-component-props"])?void 0:s.multiple)||(null==h||null==(d=h.componentProps)?void 0:d.multiple)||(null==v||null==(p=v["x-component-props"])?void 0:p.multiple)||!1;if((0,t.useEffect)(function(){var e,t=!0;return I&&y?((e=er(function(){var e,r;return ea(this,function(n){switch(n.label){case 0:if(!(k&&Array.isArray(y)))return[3,2];return[4,Promise.all(y.map(function(e){return w(I,e)}))];case 1:return e=n.sent(),t&&O(e.filter(Boolean)),[3,4];case 2:if(!(!k&&"string"==typeof y))return[3,4];return[4,w(I,y)];case 3:r=n.sent(),t&&O(r?[r]:[]),n.label=4;case 4:return[2]}})}),function(){return e.apply(this,arguments)})(),function(){t=!1}):void O([])},[I,y,w,k]),0===E.length)return r().createElement("span",null,Array.isArray(y)?y.join(", "):y||"-");if(k&&E.length>1)return r().createElement(n.Space,{size:4,wrap:!0},E.map(function(e,t){return r().createElement(r().Fragment,{key:e.dictValue},t>0&&r().createElement("span",null,","),r().createElement(n.Space,{size:4},r().createElement("span",null,e.dictLabel),e.remark&&r().createElement(n.Tooltip,{title:e.remark,placement:"top"},r().createElement(a.QuestionCircleOutlined,{style:{color:"#999",fontSize:12}}))))}));var x=E[0];return x.remark?r().createElement(n.Space,{size:4},r().createElement("span",null,x.dictLabel),r().createElement(n.Tooltip,{title:x.remark,placement:"top"},r().createElement(a.QuestionCircleOutlined,{style:{color:"#999",fontSize:12}}))):r().createElement("span",null,x.dictLabel)},ei=(0,z.connect)(function(o){var i,l,c,u,s,f,d,p,y,m,b,h,v,g=o.value,w=o.onChange,S=o.dictionaryTypeId,E=o.allowManageItems,O=o.multiple,I=function(e,t){if(null==e)return{};var r,n,a=function(e,t){if(null==e)return{};var r,n,a={},o=Object.keys(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||(a[r]=e[r]);return a}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n<o.length;n++)r=o[n],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}(o,["value","onChange","dictionaryTypeId","allowManageItems","multiple"]),k=(0,e.useAPIClient)(),x=(0,e.useCompile)(),D=(0,z.useField)(),P=(0,z.useFieldSchema)(),A=(0,e.useCollectionField)(),j=en((0,t.useState)([]),2),T=j[0],C=j[1],F=en((0,t.useState)(!1),2),M=F[0],q=F[1],V=en((0,t.useState)(!1),2),B=V[0],L=V[1],_=(0,e.useACLRoleContext)(),N=_.allowAll,R=_.parseAction;(0,e.useFieldTitle)();var $=S||(null==A||null==(c=A.uiSchema)||null==(l=c["x-component-props"])?void 0:l.dictionaryTypeId)||(null==D||null==(u=D.componentProps)?void 0:u.dictionaryTypeId)||(null==P||null==(s=P["x-component-props"])?void 0:s.dictionaryTypeId)||(null==I?void 0:I.dictionaryTypeId),U=O||(null==A||null==(d=A.uiSchema)||null==(f=d["x-component-props"])?void 0:f.multiple)||(null==D||null==(p=D.componentProps)?void 0:p.multiple)||(null==P||null==(y=P["x-component-props"])?void 0:y.multiple)||!1,G=E||(null==A||null==(b=A.uiSchema)||null==(m=b["x-component-props"])?void 0:m.allowManageItems)||(null==D||null==(h=D.componentProps)?void 0:h.allowManageItems)||(null==P||null==(v=P["x-component-props"])?void 0:v.allowManageItems)||!1,K=N||R("rbDataDictionaryItems:create"),Q=G&&K,J=(i=er(function(){var e,t;return ea(this,function(r){switch(r.label){case 0:if(!$)return C([]),[2];q(!0),r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,k.request({url:"rbDataDictionaryItems:list",method:"get",params:{filter:{dictionaryTypeId:$},sort:["dictSort","createdAt"],pageSize:1e3}})];case 2:return Array.isArray(t=null==(e=r.sent())?void 0:e.data.data)?C(t):C([]),[3,5];case 3:return console.error("Failed to load dictionary items:",r.sent()),C([]),[3,5];case 4:return q(!1),[7];case 5:return[2]}})}),function(){return i.apply(this,arguments)});return(0,t.useEffect)(function(){J()},[$,k]),r().createElement(r().Fragment,null,r().createElement(n.Space.Compact,{style:{width:"100%"}},r().createElement(n.Select,{mode:U?"multiple":void 0,value:g,onChange:w,loading:M,placeholder:x(U?'{{t("Select dictionary items", { ns: "dictionary-field" })}}':'{{t("Select dictionary item", { ns: "dictionary-field" })}}'),style:{width:Q?"calc(100% - 32px)":"100%"},showSearch:!0,optionFilterProp:"label",notFoundContent:x('{{t("No available options", { ns: "dictionary-field" })}}')},T.map(function(e){return r().createElement(n.Select.Option,{key:e.dictValue,value:e.dictValue,label:e.dictLabel},r().createElement(n.Space,{size:4},r().createElement("span",null,e.dictLabel),e.remark&&r().createElement(n.Tooltip,{title:e.remark,placement:"right"},r().createElement(a.QuestionCircleOutlined,{style:{color:"#999",fontSize:12}}))))})),Q&&r().createElement(n.Tooltip,{title:x('{{t("Manage items", { ns: "dictionary-field" })}}')},r().createElement(n.Button,{icon:r().createElement(a.SettingOutlined,null),onClick:function(){return L(!0)},disabled:!$}))),Q&&$&&r().createElement(X,{visible:B,onClose:function(){return L(!1)},dictionaryTypeId:$,onItemsChange:function(){J()}}))},(0,z.mapReadPretty)(eo)),el=JSON.parse('{"Dictionary Type":"字典类型","Dictionary Item":"字典项","Dictionary Field":"字典字段","Dictionary Management":"字典管理","Name":"名称","Title":"标题","Description":"描述","Key":"键值","Value":"键值","Label":"显示值","Remark":"备注","Sort Order":"排序序号","Sort":"排序","Dictionary type not found":"字典类型不存在","Dictionary item not found":"字典项不存在","Dictionary type name already exists":"字典类型名称已存在","Dictionary item key already exists in this dictionary type":"该键值在此字典类型中已存在","Dictionary type name must be alphanumeric with underscores, 1-100 characters":"字典类型名称必须为字母、数字和下划线,长度1-100个字符","Dictionary item key must be alphanumeric with underscores and hyphens, 1-100 characters":"字典项键值必须为字母、数字、下划线和连字符,长度1-100个字符","Dictionary field with key-value pairs":"带键值对的字典字段","Select Dictionary Type":"选择字典类型","No dictionary types available":"没有可用的字典类型","Please create dictionary types first":"请先创建字典类型","Select dictionary item":"选择字典项","Select dictionary items":"选择字典项","No available options":"无可用选项","Allow multiple selection":"允许多选","Enable multi-select mode for this field":"为此字段启用多选模式","Allow managing items":"允许管理选项","Allow users to add, edit, or delete dictionary items in forms":"允许用户在表单中添加、编辑或删除字典项","Manage Dictionary Items":"管理字典项","Manage items":"管理选项","Add Item":"添加选项","Edit Item":"编辑选项","Failed to load items":"加载选项失败","Updated successfully":"更新成功","Created successfully":"创建成功","Failed to save":"保存失败","Deleted successfully":"删除成功","Failed to delete":"删除失败","Are you sure you want to delete this item?":"确定要删除此选项吗?","Please input label":"请输入显示值","Please input value":"请输入值","Please input sort order":"请输入排序序号","Display text":"显示文本","Stored value":"存储值","Optional remark":"可选备注"}'),ec=JSON.parse('{"Dictionary Type":"Dictionary Type","Dictionary Item":"Dictionary Item","Dictionary Field":"Dictionary Field","Dictionary Management":"Dictionary Management","Name":"Name","Title":"Title","Description":"Description","Key":"Key","Value":"Value","Label":"Label","Remark":"Remark","Sort Order":"Sort Order","Sort":"Sort","Dictionary type not found":"Dictionary type not found","Dictionary item not found":"Dictionary item not found","Dictionary type name already exists":"Dictionary type name already exists","Dictionary item key already exists in this dictionary type":"Dictionary item key already exists in this dictionary type","Dictionary type name must be alphanumeric with underscores, 1-100 characters":"Dictionary type name must be alphanumeric with underscores, 1-100 characters","Dictionary item key must be alphanumeric with underscores and hyphens, 1-100 characters":"Dictionary item key must be alphanumeric with underscores and hyphens, 1-100 characters","Dictionary field with key-value pairs":"Dictionary field with key-value pairs","Select Dictionary Type":"Select Dictionary Type","No dictionary types available":"No dictionary types available","Please create dictionary types first":"Please create dictionary types first","Select dictionary item":"Select dictionary item","Select dictionary items":"Select dictionary items","No available options":"No available options","Allow multiple selection":"Allow multiple selection","Enable multi-select mode for this field":"Enable multi-select mode for this field","Allow managing items":"Allow managing items","Allow users to add, edit, or delete dictionary items in forms":"Allow users to add, edit, or delete dictionary items in forms","Manage Dictionary Items":"Manage Dictionary Items","Manage items":"Manage items","Add Item":"Add Item","Edit Item":"Edit Item","Failed to load items":"Failed to load items","Updated successfully":"Updated successfully","Created successfully":"Created successfully","Failed to save":"Failed to save","Deleted successfully":"Deleted successfully","Failed to delete":"Failed to delete","Are you sure you want to delete this item?":"Are you sure you want to delete this item?","Please input label":"Please input label","Please input value":"Please input value","Please input sort order":"Please input sort order","Display text":"Display text","Stored value":"Stored value","Optional remark":"Optional remark"}');function eu(e,t,r,n,a,o,i){try{var l=e[o](i),c=l.value}catch(e){r(e);return}l.done?t(c):Promise.resolve(c).then(n,a)}function es(e,t,r){return(es=ey()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var a=new(Function.bind.apply(e,n));return r&&ed(a,r.prototype),a}).apply(null,arguments)}function ef(e){return(ef=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ed(e,t){return(ed=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ep(e){var t="function"==typeof Map?new Map:void 0;return(ep=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return es(e,arguments,ef(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),ed(r,e)})(e)}function ey(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(ey=function(){return!!e})()}var em=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function r(){var e,t;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return e=r,t=arguments,e=ef(e),function(e,t){var r;if(t&&("object"==((r=t)&&"undefined"!=typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,ey()?Reflect.construct(e,t||[],ef(this).constructor):e.apply(this,t))}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&ed(r,e),t=[{key:"load",value:function(){var e,t=this;return(e=function(){return function(e,t){var r,n,a,o,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function l(o){return function(l){var c=[o,l];if(r)throw TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(a=2&c[0]?n.return:c[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,c[1])).done)return a;switch(n=0,a&&(c=[2&c[0],a.value]),c[0]){case 0:case 1:a=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,n=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(a=(a=i.trys).length>0&&a[a.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!a||c[1]>a[0]&&c[1]<a[3])){i.label=c[1];break}if(6===c[0]&&i.label<a[1]){i.label=a[1],a=c;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(c);break}a[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],n=0}finally{r=a=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}(this,function(e){return console.log("3333333333333","加载字典插件"),t.app.addProvider($),t.app.pluginSettingsManager.add("dictionary-field",{title:'{{t("Dictionary Management", { ns: "dictionary-field" })}}',icon:"UnorderedListOutlined",Component:P,aclSnippet:"ui.dictionaryManagement"}),t.app.i18n.addResources("zh-CN","dictionary-field",el),t.app.i18n.addResources("en-US","dictionary-field",ec),t.app.addComponents({DictionaryTypeSelect:B,DictionarySelect:ei,"DictionarySelect.ReadPretty":eo}),t.app.dataSourceManager.addFieldInterfaces([F]),[2]})},function(){var t=this,r=arguments;return new Promise(function(n,a){var o=e.apply(t,r);function i(e){eu(o,n,a,i,l,"next",e)}function l(e){eu(o,n,a,i,l,"throw",e)}i(void 0)})})()}}],function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(r.prototype,t),r}(ep(e.Plugin)),eb=em}(),c}()});
@@ -0,0 +1,134 @@
1
+ /**
2
+ * 字典字段接口配置
3
+ * T034: 定义字典字段在 NocoBase 字段类型列表中的配置
4
+ */
5
+ import { ISchema } from '@formily/react';
6
+ import { CollectionFieldInterface } from '@nocobase/client';
7
+ /**
8
+ * 字典字段接口类
9
+ *
10
+ * 这个类定义了字典字段在字段配置界面中的显示方式和行为
11
+ */
12
+ export declare class DictionaryFieldInterface extends CollectionFieldInterface {
13
+ name: string;
14
+ type: string;
15
+ group: string;
16
+ order: number;
17
+ title: string;
18
+ description: string;
19
+ sortable: boolean;
20
+ default: {
21
+ type: string;
22
+ uiSchema: {
23
+ type: string;
24
+ 'x-component': string;
25
+ };
26
+ };
27
+ availableTypes: string[];
28
+ hasDefaultValue: boolean;
29
+ filterable: {
30
+ operators: ({
31
+ label: string;
32
+ value: string;
33
+ selected: boolean;
34
+ noValue?: undefined;
35
+ } | {
36
+ label: string;
37
+ value: string;
38
+ selected?: undefined;
39
+ noValue?: undefined;
40
+ } | {
41
+ label: string;
42
+ value: string;
43
+ noValue: boolean;
44
+ selected?: undefined;
45
+ })[];
46
+ };
47
+ titleUsable: boolean;
48
+ properties: {
49
+ 'uiSchema.x-component-props.dictionaryTypeId': {
50
+ type: string;
51
+ title: string;
52
+ 'x-decorator': string;
53
+ 'x-component': string;
54
+ required: boolean;
55
+ };
56
+ 'uiSchema.x-component-props.multiple': {
57
+ type: string;
58
+ title: string;
59
+ 'x-decorator': string;
60
+ 'x-component': string;
61
+ 'x-content': string;
62
+ default: boolean;
63
+ };
64
+ 'uiSchema.x-component-props.allowManageItems': {
65
+ type: string;
66
+ title: string;
67
+ 'x-decorator': string;
68
+ 'x-component': string;
69
+ 'x-content': string;
70
+ default: boolean;
71
+ };
72
+ 'uiSchema.title': {
73
+ type: string;
74
+ title: string;
75
+ required: boolean;
76
+ 'x-decorator': string;
77
+ 'x-component': string;
78
+ };
79
+ name: {
80
+ type: string;
81
+ title: string;
82
+ required: boolean;
83
+ 'x-disabled': string;
84
+ 'x-decorator': string;
85
+ 'x-component': string;
86
+ 'x-validator': string;
87
+ description: string;
88
+ };
89
+ };
90
+ getDefaultValueProperty(): {
91
+ defaultValue: {
92
+ type: string;
93
+ title: string;
94
+ 'x-decorator': string;
95
+ 'x-component': string;
96
+ required: boolean;
97
+ 'x-reactions': ({
98
+ dependencies: string[];
99
+ fulfill: {
100
+ state: {
101
+ visible: string;
102
+ componentProps: {
103
+ dictionaryTypeId: string;
104
+ multiple: string;
105
+ };
106
+ hidden?: undefined;
107
+ value?: undefined;
108
+ };
109
+ };
110
+ when?: undefined;
111
+ otherwise?: undefined;
112
+ } | {
113
+ dependencies: string[];
114
+ when: string;
115
+ fulfill: {
116
+ state: {
117
+ hidden: boolean;
118
+ value: any;
119
+ visible?: undefined;
120
+ componentProps?: undefined;
121
+ };
122
+ };
123
+ otherwise: {
124
+ state: {
125
+ hidden: boolean;
126
+ };
127
+ };
128
+ })[];
129
+ };
130
+ };
131
+ schemaInitialize(schema: ISchema, { block }: {
132
+ block?: string;
133
+ }): void;
134
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * 字典项列表组件
3
+ * T025: 显示指定字典类型的所有字典项,支持排序和备注显示
4
+ */
5
+ import React from 'react';
6
+ interface DictionaryItemListProps {
7
+ dictionaryTypeId: string;
8
+ }
9
+ export declare const DictionaryItemList: React.FC<DictionaryItemListProps>;
10
+ export default DictionaryItemList;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 字典管理主页面
3
+ * T023: 字典管理的主容器页面
4
+ */
5
+ import React from 'react';
6
+ export declare const DictionaryManagementPage: React.FC;
7
+ export default DictionaryManagementPage;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * 字典类型列表组件
3
+ * T024: 显示所有字典类型,支持增删改查
4
+ */
5
+ import React from 'react';
6
+ interface DictionaryTypeListProps {
7
+ onSelect: (id: string | null) => void;
8
+ selectedId: string | null;
9
+ }
10
+ export declare const DictionaryTypeList: React.FC<DictionaryTypeListProps>;
11
+ export default DictionaryTypeList;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * 字典项表单组件
3
+ * T027: 创建/编辑字典项,含 key, value, 备注, 排序
4
+ */
5
+ import React from 'react';
6
+ interface DictionaryItemFormProps {
7
+ initialValues?: {
8
+ dictValue: string;
9
+ dictLabel: string;
10
+ remark?: string;
11
+ dictSort?: number;
12
+ };
13
+ onSubmit: (values: any) => Promise<void>;
14
+ onCancel: () => void;
15
+ }
16
+ export declare const DictionaryItemForm: React.FC<DictionaryItemFormProps>;
17
+ export default DictionaryItemForm;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * 字典类型表单组件
3
+ * T026: 创建/编辑字典类型
4
+ */
5
+ import React from 'react';
6
+ interface DictionaryTypeFormProps {
7
+ initialValues?: {
8
+ id?: string;
9
+ dictName: string;
10
+ status?: number;
11
+ remark?: string;
12
+ };
13
+ onSubmit: (values: any) => Promise<void>;
14
+ onCancel: () => void;
15
+ }
16
+ export declare const DictionaryTypeForm: React.FC<DictionaryTypeFormProps>;
17
+ export default DictionaryTypeForm;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ module.exports = {
11
+ "@nocobase/client": "2.0.0-alpha.48",
12
+ "@nocobase/server": "2.0.0-alpha.48",
13
+ "react": "18.3.1",
14
+ "antd": "5.12.8",
15
+ "@ant-design/icons": "5.3.7",
16
+ "@formily/react": "2.3.1",
17
+ "@nocobase/database": "2.0.0-alpha.48",
18
+ "sequelize": "6.37.3",
19
+ "@nocobase/actions": "2.0.0-alpha.48"
20
+ };
@@ -0,0 +1 @@
1
+ export { default } from './server';
package/dist/index.js ADDED
@@ -0,0 +1,42 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __create = Object.create;
11
+ var __defProp = Object.defineProperty;
12
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
13
+ var __getOwnPropNames = Object.getOwnPropertyNames;
14
+ var __getProtoOf = Object.getPrototypeOf;
15
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
16
+ var __export = (target, all) => {
17
+ for (var name in all)
18
+ __defProp(target, name, { get: all[name], enumerable: true });
19
+ };
20
+ var __copyProps = (to, from, except, desc) => {
21
+ if (from && typeof from === "object" || typeof from === "function") {
22
+ for (let key of __getOwnPropNames(from))
23
+ if (!__hasOwnProp.call(to, key) && key !== except)
24
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
25
+ }
26
+ return to;
27
+ };
28
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
+ // If the importer is in node compatibility mode or this is not an ESM
30
+ // file that has been converted to a CommonJS file using a Babel-
31
+ // compatible transform (i.e. "__esModule" has not been set), then set
32
+ // "default" to the CommonJS "module.exports" for node compatibility.
33
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
+ mod
35
+ ));
36
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
37
+ var src_exports = {};
38
+ __export(src_exports, {
39
+ default: () => import_server.default
40
+ });
41
+ module.exports = __toCommonJS(src_exports);
42
+ var import_server = __toESM(require("./server"));
@@ -0,0 +1,49 @@
1
+ {
2
+ "Dictionary Type": "Dictionary Type",
3
+ "Dictionary Item": "Dictionary Item",
4
+ "Dictionary Field": "Dictionary Field",
5
+ "Dictionary Management": "Dictionary Management",
6
+ "Name": "Name",
7
+ "Title": "Title",
8
+ "Description": "Description",
9
+ "Key": "Key",
10
+ "Value": "Value",
11
+ "Label": "Label",
12
+ "Remark": "Remark",
13
+ "Sort Order": "Sort Order",
14
+ "Sort": "Sort",
15
+ "Dictionary type not found": "Dictionary type not found",
16
+ "Dictionary item not found": "Dictionary item not found",
17
+ "Dictionary type name already exists": "Dictionary type name already exists",
18
+ "Dictionary item key already exists in this dictionary type": "Dictionary item key already exists in this dictionary type",
19
+ "Dictionary type name must be alphanumeric with underscores, 1-100 characters": "Dictionary type name must be alphanumeric with underscores, 1-100 characters",
20
+ "Dictionary item key must be alphanumeric with underscores and hyphens, 1-100 characters": "Dictionary item key must be alphanumeric with underscores and hyphens, 1-100 characters",
21
+ "Dictionary field with key-value pairs": "Dictionary field with key-value pairs",
22
+ "Select Dictionary Type": "Select Dictionary Type",
23
+ "No dictionary types available": "No dictionary types available",
24
+ "Please create dictionary types first": "Please create dictionary types first",
25
+ "Select dictionary item": "Select dictionary item",
26
+ "Select dictionary items": "Select dictionary items",
27
+ "No available options": "No available options",
28
+ "Allow multiple selection": "Allow multiple selection",
29
+ "Enable multi-select mode for this field": "Enable multi-select mode for this field",
30
+ "Allow managing items": "Allow managing items",
31
+ "Allow users to add, edit, or delete dictionary items in forms": "Allow users to add, edit, or delete dictionary items in forms",
32
+ "Manage Dictionary Items": "Manage Dictionary Items",
33
+ "Manage items": "Manage items",
34
+ "Add Item": "Add Item",
35
+ "Edit Item": "Edit Item",
36
+ "Failed to load items": "Failed to load items",
37
+ "Updated successfully": "Updated successfully",
38
+ "Created successfully": "Created successfully",
39
+ "Failed to save": "Failed to save",
40
+ "Deleted successfully": "Deleted successfully",
41
+ "Failed to delete": "Failed to delete",
42
+ "Are you sure you want to delete this item?": "Are you sure you want to delete this item?",
43
+ "Please input label": "Please input label",
44
+ "Please input value": "Please input value",
45
+ "Please input sort order": "Please input sort order",
46
+ "Display text": "Display text",
47
+ "Stored value": "Stored value",
48
+ "Optional remark": "Optional remark"
49
+ }