nocobase-plugin-dictionary-field 0.2.3 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/components/DictionaryTreeSelect.d.ts +28 -0
- package/dist/client/hooks/useTreeStructure.d.ts +21 -0
- package/dist/client/index.d.ts +4 -0
- package/dist/client/index.js +1 -1
- package/dist/client/interfaces/dictionary-field-interface.d.ts +1 -0
- package/dist/client/settings/DictionaryManagementContainer.d.ts +7 -0
- package/dist/client/settings/DictionaryManagementPage.d.ts +1 -0
- package/dist/client/settings/DictionaryTreeItemList.d.ts +11 -0
- package/dist/client/settings/DictionaryTypeList.d.ts +8 -1
- package/dist/client/settings/components/DictionaryTypeForm.d.ts +1 -0
- package/dist/client/settings/components/TreeItemForm.d.ts +23 -0
- package/dist/client/util/tree.d.ts +14 -0
- package/dist/locale/en-US.json +2 -1
- package/dist/locale/zh-CN.json +2 -1
- package/dist/server/collections/dictionary-items.js +90 -1
- package/dist/server/collections/dictionary-types.js +12 -0
- package/dist/server/fields/dictionary-field.js +1 -3
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.js +9 -0
- package/dist/server/migrations/001-add-tree-structure.d.ts +21 -0
- package/dist/server/migrations/001-add-tree-structure.js +298 -0
- package/dist/server/migrations/002-add-is-tree-field.d.ts +12 -0
- package/dist/server/migrations/002-add-is-tree-field.js +101 -0
- package/dist/server/plugin.d.ts +4 -0
- package/dist/server/plugin.js +110 -4
- package/dist/server/resources/dictionary-items.d.ts +21 -1
- package/dist/server/resources/dictionary-items.js +130 -0
- package/dist/server/services/tree-service.d.ts +77 -0
- package/dist/server/services/tree-service.js +287 -0
- package/package.json +1 -1
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 字典树选择器组件
|
|
3
|
+
* 使用 Ant Design Tree 组件展示树形结构的字典项
|
|
4
|
+
* 支持单选、多选、搜索、展开/折叠等功能
|
|
5
|
+
*/
|
|
6
|
+
import React from 'react';
|
|
7
|
+
interface DictionaryTreeSelectProps {
|
|
8
|
+
style?: React.CSSProperties;
|
|
9
|
+
value?: string | string[];
|
|
10
|
+
onChange?: (value: string | string[]) => void;
|
|
11
|
+
dictionaryTypeId?: string;
|
|
12
|
+
dictItems?: any[];
|
|
13
|
+
multiple?: boolean;
|
|
14
|
+
allowClear?: boolean;
|
|
15
|
+
placeholder?: string;
|
|
16
|
+
loading?: boolean;
|
|
17
|
+
allowManageItems?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* 字典树选择器组件 - 只读模式
|
|
21
|
+
*/
|
|
22
|
+
export declare const DictionaryTreeSelectReadPretty: React.FC<{
|
|
23
|
+
value?: string | string[];
|
|
24
|
+
dictionaryTypeId?: string;
|
|
25
|
+
multiple?: boolean;
|
|
26
|
+
}>;
|
|
27
|
+
export declare const DictionaryTreeSelect: React.ForwardRefExoticComponent<Partial<DictionaryTreeSelectProps> & React.RefAttributes<unknown>>;
|
|
28
|
+
export default DictionaryTreeSelect;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useTreeStructure Hook
|
|
3
|
+
*
|
|
4
|
+
* 用于加载和管理字典树结构,包含缓存机制
|
|
5
|
+
*
|
|
6
|
+
* @param dictionaryTypeId 字典类型 ID
|
|
7
|
+
* @param dictItems 已有的数据
|
|
8
|
+
* @param enableCache 是否启用缓存(默认关闭)
|
|
9
|
+
* @returns 树数据、加载状态、错误信息
|
|
10
|
+
*/
|
|
11
|
+
export declare function useTreeStructure(dictionaryTypeId?: string, dictItems?: any[], enableCache?: boolean): {
|
|
12
|
+
treeData: any[];
|
|
13
|
+
flattenedTree: any[];
|
|
14
|
+
loading: boolean;
|
|
15
|
+
error: Error;
|
|
16
|
+
searchInTree: (text: string) => Promise<any>;
|
|
17
|
+
moveItem: (itemId: number, parentId: number | null, sortOrder?: number) => Promise<boolean>;
|
|
18
|
+
refresh: () => void;
|
|
19
|
+
clearCache: (id?: string) => void;
|
|
20
|
+
};
|
|
21
|
+
export default useTreeStructure;
|
package/dist/client/index.d.ts
CHANGED
|
@@ -10,4 +10,8 @@ import { Plugin } from '@nocobase/client';
|
|
|
10
10
|
export declare class PluginDictionaryFieldClient extends Plugin {
|
|
11
11
|
load(): Promise<void>;
|
|
12
12
|
}
|
|
13
|
+
export { DictionaryTreeSelect, DictionaryTreeSelectReadPretty } from './components/DictionaryTreeSelect';
|
|
14
|
+
export { useTreeStructure } from './hooks/useTreeStructure';
|
|
15
|
+
export { DictionaryTreeItemList } from './settings/DictionaryTreeItemList';
|
|
16
|
+
export { TreeItemForm } from './settings/components/TreeItemForm';
|
|
13
17
|
export default PluginDictionaryFieldClient;
|
package/dist/client/index.js
CHANGED
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
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}()});
|
|
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}},l={};function i(e){var t=l[e];if(void 0!==t)return t.exports;var r=l[e]={exports:{}};return o[e](r,r.exports,i),r.exports}i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,{a:t}),t},i.d=function(e,t){for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.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(){i.r(c),i.d(c,{TreeItemForm:function(){return U},DictionaryTreeItemList:function(){return W},default:function(){return eG},useTreeStructure:function(){return B},DictionaryTreeSelect:function(){return ej},DictionaryTreeSelectReadPretty:function(){return eP},PluginDictionaryFieldClient:function(){return eU}});var e=i(772),t=i(156),r=i.n(t),n=i(721),a=i(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 l(e,t,r,n,a,o,l){try{var i=e[o](l),c=i.value}catch(e){r(e);return}i.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=[],l=!0,i=!1;try{for(a=a.call(e);!(l=(r=a.next()).done)&&(o.push(r.value),!t||o.length!==t);l=!0);}catch(e){i=!0,n=e}finally{try{l||null==a.return||a.return()}finally{if(i)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,i=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,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function i(o){return function(i){var c=[o,i];if(r)throw TypeError("Generator is already executing.");for(;l;)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 l.label++,{value:c[1],done:!1};case 5:l.label++,n=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===c[0]||2===c[0])){l=0;continue}if(3===c[0]&&(!a||c[1]>a[0]&&c[1]<a[3])){l.label=c[1];break}if(6===c[0]&&l.label<a[1]){l.label=a[1],a=c;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(c);break}a[2]&&l.ops.pop(),l.trys.pop();continue}c=t.call(e,l)}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,i(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 i(e){l(o,n,a,i,c,"next",e)}function c(e){l(o,n,a,i,c,"throw",e)}i(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:"isTree",initialValue:(null==o?void 0:o.isTree)||!1,tooltip:"树形字典支持多级层级结构,普通字典为平面结构"},r().createElement(n.Radio.Group,null,r().createElement(n.Radio,{value:!1},"普通字典"),r().createElement(n.Radio,{value:!0},"树形字典"))),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,l){try{var i=e[o](l),c=i.value}catch(e){r(e);return}i.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 l(e){d(o,n,a,l,i,"next",e)}function i(e){d(o,n,a,l,i,"throw",e)}l(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=[],l=!0,i=!1;try{for(a=a.call(e);!(l=(r=a.next()).done)&&(o.push(r.value),!t||o.length!==t);l=!0);}catch(e){i=!0,n=e}finally{try{l||null==a.return||a.return()}finally{if(i)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,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function i(o){return function(i){var c=[o,i];if(r)throw TypeError("Generator is already executing.");for(;l;)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 l.label++,{value:c[1],done:!1};case 5:l.label++,n=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===c[0]||2===c[0])){l=0;continue}if(3===c[0]&&(!a||c[1]>a[0]&&c[1]<a[3])){l.label=c[1];break}if(6===c[0]&&l.label<a[1]){l.label=a[1],a=c;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(c);break}a[2]&&l.ops.pop(),l.trys.pop();continue}c=t.call(e,l)}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 l,i,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],P=k[1],j=(l=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 l.apply(this,arguments)});(0,t.useEffect)(function(){j()},[]);var D=function(e){P(e),I(!0)},C=(i=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),j(),[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 i.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),j(),[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(){P(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)},actions:[r().createElement(n.Button,{key:"edit",type:"link",size:"small",icon:r().createElement(a.EditOutlined,null),onClick:function(t){t.stopPropagation(),D(e)}}),r().createElement(n.Button,{key:"delete",type:"link",danger:!0,size:"small",icon:r().createElement(a.DeleteOutlined,null),onClick:function(t){t.stopPropagation(),C(e.id)}})]},r().createElement(n.List.Item.Meta,{title:r().createElement(n.Space,null,r().createElement(n.Tag,{color:e.isTree?"blue":"default"},e.isTree?"树形":"普通"),r().createElement("span",null,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,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,l){try{var i=e[o](l),c=i.value}catch(e){r(e);return}i.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=[],l=!0,i=!1;try{for(a=a.call(e);!(l=(r=a.next()).done)&&(o.push(r.value),!t||o.length!==t);l=!0);}catch(e){i=!0,n=e}finally{try{l||null==a.return||a.return()}finally{if(i)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,l=e.onSubmit,i=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,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function i(o){return function(i){var c=[o,i];if(r)throw TypeError("Generator is already executing.");for(;l;)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 l.label++,{value:c[1],done:!1};case 5:l.label++,n=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===c[0]||2===c[0])){l=0;continue}if(3===c[0]&&(!a||c[1]>a[0]&&c[1]<a[3])){l.label=c[1];break}if(6===c[0]&&l.label<a[1]){l.label=a[1],a=c;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(c);break}a[2]&&l.ops.pop(),l.trys.pop();continue}c=t.call(e,l)}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,l(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 l(e){v(o,n,a,l,i,"next",e)}function i(e){v(o,n,a,l,i,"throw",e)}l(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:i},"取消"),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,l){try{var i=e[o](l),c=i.value}catch(e){r(e);return}i.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 l(e){E(o,n,a,l,i,"next",e)}function i(e){E(o,n,a,l,i,"throw",e)}l(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=[],l=!0,i=!1;try{for(a=a.call(e);!(l=(r=a.next()).done)&&(o.push(r.value),!t||o.length!==t);l=!0);}catch(e){i=!0,n=e}finally{try{l||null==a.return||a.return()}finally{if(i)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,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function i(o){return function(i){var c=[o,i];if(r)throw TypeError("Generator is already executing.");for(;l;)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 l.label++,{value:c[1],done:!1};case 5:l.label++,n=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===c[0]||2===c[0])){l=0;continue}if(3===c[0]&&(!a||c[1]>a[0]&&c[1]<a[3])){l.label=c[1];break}if(6===c[0]&&l.label<a[1]){l.label=a[1],a=c;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(c);break}a[2]&&l.ops.pop(),l.trys.pop();continue}c=t.call(e,l)}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 l,i,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],P=(l=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 l.apply(this,arguments)});(0,t.useEffect)(function(){P()},[u]);var j=function(e){x(e),g(!0)},D=(i=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("删除成功"),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 i.apply(this,arguments)}),C=(c=O(function(e){var t,r,a,o;return k(this,function(l){switch(l.label){case 0:var i,c;if(l.trys.push([0,5,,6]),i=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(i,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(i,e,Object.getOwnPropertyDescriptor(c,e))}),t=i,!E)return[3,2];return[4,s.request({url:"rbDataDictionaryItems:update/".concat(E.id),method:"post",data:t})];case 1:return l.sent(),n.message.success("更新成功"),[3,4];case 2:return[4,s.request({url:"rbDataDictionaryItems:create",method:"post",data:t})];case 3:l.sent(),n.message.success("创建成功"),l.label=4;case 4:return g(!1),P(),[3,6];case 5:return r=l.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 j(t)}}),r().createElement(n.Button,{type:"link",danger:!0,size:"small",icon:r().createElement(a.DeleteOutlined,null),onClick:function(){return D(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:C,onCancel:function(){return g(!1)}})))};function P(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 j(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 D(e){var t=new Map;e.forEach(function(e){t.set(e.id,j(P({},e),{children:[]}))});var r=[];e.forEach(function(e){if(null===e.parentId||void 0===e.parentId)r.push(t.get(e.id));else{var n=t.get(e.parentId);n&&n.children.push(t.get(e.id))}});var n=function(e){e.children&&e.children.length>0&&(e.children.sort(function(e,t){return e.sortOrder-t.sortOrder}),e.children.forEach(n))};return r.forEach(n),r.sort(function(e,t){return e.sortOrder-t.sortOrder}),r}function C(e){return e.map(function(e){return j(P({},e),{title:e.dictLabel,key:e.dictValue,value:e.dictValue,id:e.id,children:e.children&&e.children.length>0?C(e.children):[]})})}function T(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 A(e,t,r,n,a,o,l){try{var i=e[o](l),c=i.value}catch(e){r(e);return}i.done?t(c):Promise.resolve(c).then(n,a)}function F(e){return function(){var t=this,r=arguments;return new Promise(function(n,a){var o=e.apply(t,r);function l(e){A(o,n,a,l,i,"next",e)}function i(e){A(o,n,a,l,i,"throw",e)}l(void 0)})}}function M(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=[],l=!0,i=!1;try{for(a=a.call(e);!(l=(r=a.next()).done)&&(o.push(r.value),!t||o.length!==t);l=!0);}catch(e){i=!0,n=e}finally{try{l||null==a.return||a.return()}finally{if(i)throw n}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return T(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 T(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 V(e,t){var r,n,a,o,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function i(o){return function(i){var c=[o,i];if(r)throw TypeError("Generator is already executing.");for(;l;)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 l.label++,{value:c[1],done:!1};case 5:l.label++,n=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===c[0]||2===c[0])){l=0;continue}if(3===c[0]&&(!a||c[1]>a[0]&&c[1]<a[3])){l.label=c[1];break}if(6===c[0]&&l.label<a[1]){l.label=a[1],a=c;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(c);break}a[2]&&l.ops.pop(),l.trys.pop();continue}c=t.call(e,l)}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 q=new Map;function B(r,n){var a,o,l=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=(0,e.useAPIClient)(),c=M((0,t.useState)([]),2),u=c[0],s=c[1],f=M((0,t.useState)(!1),2),d=f[0],p=f[1],y=M((0,t.useState)(null),2),m=y[0],b=y[1],h=(0,t.useCallback)(function(e){if(!l)return null;var t=q.get(e);return t?Date.now()-t.timestamp>3e5?(q.delete(e),null):t.data:null},[l]),v=(0,t.useCallback)(function(e,t){l&&q.set(e,{data:t,timestamp:Date.now()})},[l]),g=(0,t.useCallback)(function(e){e?q.delete(e):q.clear()},[]),w=(0,t.useCallback)(F(function(){var e,t,n,a,o;return V(this,function(l){switch(l.label){case 0:if(!r)return s([]),[2];if(e=h(r))return s(e),p(!1),[2];p(!0),b(null),l.label=1;case 1:return l.trys.push([1,3,4,5]),[4,i.request({url:"rbDataDictionaryItems:list",method:"get",params:{filter:{dictionaryTypeId:r},pageSize:1e3}})];case 2:return s(a=C(D((null==(n=l.sent())||null==(t=n.data)?void 0:t.data)||[]))),v(r,a),[3,5];case 3:var c;return console.error("[useTreeStructure] 加载树数据失败:",o=l.sent()),b((null!=(c=Error)&&"undefined"!=typeof Symbol&&c[Symbol.hasInstance]?!!c[Symbol.hasInstance](o):o instanceof c)?o:Error("Failed to load tree")),s([]),[3,5];case 4:return p(!1),[7];case 5:return[2]}})}),[r,i,h,v]);(0,t.useEffect)(function(){n&&n.length>0&&s(C(D(n)))},[n]),(0,t.useEffect)(function(){w()},[w]);var S=(0,t.useCallback)((a=F(function(e){var t,n;return V(this,function(a){switch(a.label){case 0:if(!r||!e)return[2,[]];a.label=1;case 1:return a.trys.push([1,3,,4]),[4,i.request({url:"rbDataDictionaryItems:search",method:"get",params:{dictionaryTypeId:r,text:e}})];case 2:return[2,(null==(n=a.sent())||null==(t=n.data)?void 0:t.data)||[]];case 3:return console.error("[useTreeStructure] 搜索失败:",a.sent()),[2,[]];case 4:return[2]}})}),function(e){return a.apply(this,arguments)}),[r,i]),E=(0,t.useCallback)((o=F(function(e,t,n){return V(this,function(e){switch(e.label){case 0:if(!r)return[2,!1];e.label=1;case 1:return e.trys.push([1,4,,5]),[4,i.request({url:"rbDataDictionaryItems:move",method:"post",data: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}({parentId:t},void 0!==n&&{sortOrder:n})})];case 2:return e.sent(),g(r),[4,w()];case 3:return e.sent(),[2,!0];case 4:return console.error("[useTreeStructure] 移动项失败:",e.sent()),[2,!1];case 5:return[2]}})}),function(e,t,r){return o.apply(this,arguments)}),[r,i,g,w]),O=(0,t.useCallback)(function(){g(r),w()},[r,g,w]),I=(0,t.useMemo)(function(){var e=[],t=function(r){null==r||r.forEach(function(r){var n=r.children,a=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}(r,["children"]);e.push(a),n&&n.length>0&&t(n)})};return t(u),e},[u]);return{treeData:u,flattenedTree:I,loading:d,error:m,searchInTree:S,moveItem:E,refresh:O,clearCache:g}}var L=B;function z(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 R(e,t,r,n,a,o,l){try{var i=e[o](l),c=i.value}catch(e){r(e);return}i.done?t(c):Promise.resolve(c).then(n,a)}function N(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 _(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 $(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=[],l=!0,i=!1;try{for(a=a.call(e);!(l=(r=a.next()).done)&&(o.push(r.value),!t||o.length!==t);l=!0);}catch(e){i=!0,n=e}finally{try{l||null==a.return||a.return()}finally{if(i)throw n}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return z(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 z(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 U=function(e){var a,o,l=e.initialValues,i=e.dictionaryTypeId,c=e.onSubmit,u=e.onCancel,s=$(n.Form.useForm(),1)[0],f=$(r().useState(!1),2),d=f[0],p=f[1],y=$((0,t.useState)((null==l?void 0:l.parentId)||null),2),m=y[0],b=y[1],h=$((0,t.useState)([]),2),v=h[0],g=h[1],w=L(i).flattenedTree,S=r().useMemo(function(){if(!w||0===w.length)return[];var e=(null==l?void 0:l.id)?[l.id]:[];return w.filter(function(t){return!e.includes(t.id)}).map(function(e){return{label:"".concat(e.dictLabel," (").concat(e.dictValue,")").concat(e.depth?" [深度: ".concat(e.depth,"]"):""),value:e.id,depth:e.depth||0,parentId:e.parentId}}).sort(function(e,t){return e.depth-t.depth||e.value-t.value})},[w,null==l?void 0:l.id]),E=r().useCallback(function(){if(!m||!w||0===w.length)return void g([]);for(var e=[],t=m;null!=t;){var r=w.find(function(e){return e.id===t});if(!r)break;e.unshift({id:r.id,label:r.dictLabel,value:r.dictValue}),t=r.parentId||null}g(e)},[m,w]);(0,t.useEffect)(function(){E()},[E]);var O=r().useCallback(function(){if(!m)return 0;var e=null==w?void 0:w.find(function(e){return e.id===m});return e?(e.depth||0)+1:0},[m,w]),I=(a=function(){var e;return function(e,t){var r,n,a,o,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function i(o){return function(i){var c=[o,i];if(r)throw TypeError("Generator is already executing.");for(;l;)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 l.label++,{value:c[1],done:!1};case 5:l.label++,n=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===c[0]||2===c[0])){l=0;continue}if(3===c[0]&&(!a||c[1]>a[0]&&c[1]<a[3])){l.label=c[1];break}if(6===c[0]&&l.label<a[1]){l.label=a[1],a=c;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(c);break}a[2]&&l.ops.pop(),l.trys.pop();continue}c=t.call(e,l)}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,c(_(N({},e),{parentId:m||null,depth:O()}))];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]}})},o=function(){var e=this,t=arguments;return new Promise(function(r,n){var o=a.apply(e,t);function l(e){R(o,r,n,l,i,"next",e)}function i(e){R(o,r,n,l,i,"throw",e)}l(void 0)})},function(){return o.apply(this,arguments)}),k=O();return r().createElement(r().Fragment,null,k>0&&r().createElement(n.Alert,{message:"该项将作为子项,深度级别: ".concat(k),type:"info",showIcon:!0,style:{marginBottom:16}}),r().createElement(n.Form,{form:s,layout:"vertical",initialValues:_(N({},l),{sortOrder:(null==l?void 0:l.sortOrder)||0})},r().createElement(n.Form.Item,{label:"父项",name:"parentId",tooltip:"选择一个父项可将此项作为子项组织到树结构中。留空表示此项为根级项。"},r().createElement(n.Select,{allowClear:!0,placeholder:"选择父项(留空表示为根项)",options:S,onChange:function(e){b(e||null),s.setFieldValue("parentId",e)},value:m,optionLabelProp:"label"})),v.length>0&&r().createElement("div",{style:{marginBottom:16,padding:"8px",backgroundColor:"#f5f5f5",borderRadius:"2px"}},r().createElement("div",{style:{fontSize:"12px",color:"#666",marginBottom:"4px"}},"父项路径:"),r().createElement(n.Breadcrumb,{items:v.map(function(e){return{title:"".concat(e.label," (").concat(e.value,")")}}),style:{fontSize:"12px"}})),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 或 优质客户",disabled:!!(null==l?void 0:l.id)})),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:"sortOrder",rules:[{required:!0,message:"请输入排序序号"}],tooltip:"在同一父项下的排序位置,数字越小越靠前"},r().createElement(n.InputNumber,{style:{width:"100%"},placeholder:"数字越小越靠前",min:-0x80000000,max:0x7fffffff})),k>0&&r().createElement(n.Form.Item,{label:"深度级别"},r().createElement(n.Input,{value:"".concat(k),disabled:!0,style:{color:"#999"}})),r().createElement(n.Form.Item,{style:{marginBottom:0}},r().createElement(n.Space,{style:{width:"100%",justifyContent:"flex-end"}},r().createElement(n.Button,{onClick:u},"取消"),r().createElement(n.Button,{type:"primary",loading:d,onClick:I},"保存")))))};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,l){try{var i=e[o](l),c=i.value}catch(e){r(e);return}i.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 l(e){K(o,n,a,l,i,"next",e)}function i(e){K(o,n,a,l,i,"throw",e)}l(void 0)})}}function H(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 J(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 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=[],l=!0,i=!1;try{for(a=a.call(e);!(l=(r=a.next()).done)&&(o.push(r.value),!t||o.length!==t);l=!0);}catch(e){i=!0,n=e}finally{try{l||null==a.return||a.return()}finally{if(i)throw n}}return o}}(e,t)||function(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)}}(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 Z(e,t){var r,n,a,o,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function i(o){return function(i){var c=[o,i];if(r)throw TypeError("Generator is already executing.");for(;l;)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 l.label++,{value:c[1],done:!1};case 5:l.label++,n=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===c[0]||2===c[0])){l=0;continue}if(3===c[0]&&(!a||c[1]>a[0]&&c[1]<a[3])){l.label=c[1];break}if(6===c[0]&&l.label<a[1]){l.label=a[1],a=c;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(c);break}a[2]&&l.ops.pop(),l.trys.pop();continue}c=t.call(e,l)}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 W=function(o){var l,i,c=o.dictionaryTypeId,u=o.onItemsChange,s=(0,e.useAPIClient)(),f=Y((0,t.useState)(""),2),d=f[0],p=f[1],y=Y((0,t.useState)([]),2),m=y[0],b=y[1],h=Y((0,t.useState)([]),2),v=h[0],g=h[1],w=Y((0,t.useState)(!1),2),S=w[0],E=w[1],O=Y((0,t.useState)(null),2),I=O[0],k=O[1],x=Y((0,t.useState)(!1),2),P=x[0],j=x[1],D=Y((0,t.useState)(!1),2),C=D[0],T=D[1],A=L(c),F=A.treeData,M=A.loading,V=A.refresh,q=(0,t.useMemo)(function(){var e=function(t){return t.map(function(t){return{key:t.id,title:r().createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",width:"100%"}},r().createElement("span",null,t.title||t.dictLabel,r().createElement("span",{style:{marginLeft:"8px",color:"#999",fontSize:"12px"}},"(",t.key||t.dictValue,")")),r().createElement(n.Space,{size:"small",onClick:function(e){return e.stopPropagation()}},r().createElement(n.Tooltip,{title:"编辑"},r().createElement(n.Button,{size:"small",type:"text",icon:r().createElement(a.EditOutlined,null),onClick:function(){return z(t)}})),r().createElement(n.Tooltip,{title:"添加子项"},r().createElement(n.Button,{size:"small",type:"text",icon:r().createElement(a.PlusOutlined,null),onClick:function(){return R(t)}})),r().createElement(n.Popconfirm,{title:"删除项目",description:"确认要删除此项及其所有子项吗?此操作不可撤销。",onConfirm:function(){return N(t.id)},okText:"确认",cancelText:"取消"},r().createElement(n.Tooltip,{title:"删除"},r().createElement(n.Button,{size:"small",type:"text",danger:!0,icon:r().createElement(a.DeleteOutlined,null),onClick:function(e){return e.stopPropagation()}}))))),children:t.children&&t.children.length>0?e(t.children):[],data:t}})};return e(F)},[F]),B=(0,t.useMemo)(function(){if(!d)return q;var e=d.toLowerCase(),t=function(r){return r.map(function(r){var n,a,o="".concat((null==(n=r.data)?void 0:n.dictLabel)||""," ").concat((null==(a=r.data)?void 0:a.dictValue)||"").toLowerCase().includes(e),l=r.children?t(r.children):[];return o||l.length>0?J(H({},r),{children:l.length>0?l:r.children}):null}).filter(Boolean)},r=new Set,n=function(t){t.forEach(function(t){var a,o;("".concat((null==(a=t.data)?void 0:a.dictLabel)||""," ").concat((null==(o=t.data)?void 0:o.dictValue)||"").toLowerCase().includes(e)||t.children&&t.children.length>0)&&r.add(t.key),t.children&&n(t.children)})};return n(q),b(Array.from(r)),E(!0),t(q)},[q,d]),z=function(e){k(e),j(!1),T(!0)},R=function(e){k({parentId:e.id,dictionaryTypeId:c}),j(!0),T(!0)},N=(l=Q(function(e){var t;return Z(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,s.request({url:"rbDataDictionaryItems:destroy/".concat(e),method:"delete"})];case 1:return r.sent(),n.message.success("删除成功"),V(),null==u||u(),[3,3];case 2:return t=r.sent(),n.message.error("删除失败"),console.error("Delete failed:",t),[3,3];case 3:return[2]}})}),function(e){return l.apply(this,arguments)}),_=(i=Q(function(e){var t,r,a;return Z(this,function(o){switch(o.label){case 0:if(o.trys.push([0,5,,6]),!(P||!(null==I?void 0:I.id)))return[3,2];return[4,s.request({url:"rbDataDictionaryItems:create",method:"post",data:J(H({},e),{dictionaryTypeId:c})})];case 1:return o.sent(),n.message.success("添加成功"),[3,4];case 2:return[4,s.request({url:"rbDataDictionaryItems:update/".concat(I.id),method:"post",data:e})];case 3:o.sent(),n.message.success("保存成功"),o.label=4;case 4:return T(!1),V(),null==u||u(),[3,6];case 5:return t=o.sent(),n.message.error((null==t||null==(a=t.response)||null==(r=a.data)?void 0:r.message)||"操作失败"),console.error("Save failed:",t),[3,6];case 6:return[2]}})}),function(e){return i.apply(this,arguments)});return r().createElement("div",{style:{padding:"16px"}},r().createElement(n.Space,{style:{marginBottom:"16px",width:"100%",justifyContent:"space-between"}},r().createElement(n.Space,null,r().createElement(n.Input,{placeholder:"搜索字典项...",prefix:r().createElement(a.SearchOutlined,null),value:d,onChange:function(e){return p(e.target.value)},allowClear:!0,style:{width:"200px"}}),r().createElement(n.Button,{type:"primary",icon:r().createElement(a.PlusOutlined,null),onClick:function(){k({dictionaryTypeId:c}),j(!0),T(!0)}},"添加根项")),r().createElement(n.Button,{icon:r().createElement(a.ReloadOutlined,null),onClick:V},"刷新")),M?r().createElement(n.Spin,null):0===B.length?r().createElement(n.Empty,{description:"暂无字典项"}):r().createElement(n.Tree,{expandedKeys:m,onExpand:function(e){b(e),E(!1)},selectedKeys:v,onSelect:g,autoExpandParent:S,treeData:B,blockNode:!0,showIcon:!1,style:{border:"1px solid #d9d9d9",borderRadius:"2px",padding:"8px",minHeight:"300px",maxHeight:"600px",overflowY:"auto"}}),r().createElement(n.Modal,{title:P?"添加字典项":"编辑字典项",open:C,onCancel:function(){return T(!1)},footer:null,width:500,destroyOnClose:!0},r().createElement(U,{initialValues:I,dictionaryTypeId:c,onSubmit:_,onCancel:function(){return T(!1)}})))};function X(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 ee=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=[],l=!0,i=!1;try{for(a=a.call(e);!(l=(r=a.next()).done)&&(o.push(r.value),o.length!==t);l=!0);}catch(e){i=!0,n=e}finally{try{l||null==a.return||a.return()}finally{if(i)throw n}}return o}}(e,2)||function(e,t){if(e){if("string"==typeof e)return X(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 X(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],l=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:l,selectedId:null==o?void 0:o.id}))),r().createElement(n.Col,{span:16},r().createElement(n.Card,{title:o?"字典项".concat(o.isTree?" (树形)":" (平面)"):"请选择字典类型",bordered:!1},o?o.isTree?r().createElement(W,{dictionaryTypeId:o.id}):r().createElement(x,{dictionaryTypeId:o.id}):r().createElement("div",{style:{textAlign:"center",padding:48,color:"#999"}},"请先在左侧选择一个字典类型")))))};function et(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function er(e){return(er=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function en(e,t){return(en=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ea(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(ea=function(){return!!e})()}var eo=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,l;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return r=n,a=arguments,r=er(r),et(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,ea()?Reflect.construct(r,a||[],er(this).constructor):r.apply(this,a)),"name","dictionary"),et(t,"type","object"),et(t,"group","choices"),et(t,"order",2),et(t,"title",'{{t("Dictionary Field", { ns: "dictionary-field" })}}'),et(t,"description",'{{t("Dictionary field with key-value pairs", { ns: "dictionary-field" })}}'),et(t,"sortable",!0),et(t,"default",{type:"dictionary",uiSchema:{type:"string","x-component":"DictionarySelect"}}),et(t,"availableTypes",["dictionary"]),et(t,"hasDefaultValue",!0),et(t,"filterable",{operators:e.operators.string}),et(t,"titleUsable",!0),et(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){et(e,t,r[t])})}return e}({},e.defaultProps),l=l={"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(l)):(function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r.push.apply(r,n)}return r})(Object(l)).forEach(function(e){Object.defineProperty(o,e,Object.getOwnPropertyDescriptor(l,e))}),o)),t}return n.prototype=Object.create(t&&t.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),t&&en(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:{allowManageItems:!0,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 el(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 ei(e,t,r,n,a,o,l){try{var i=e[o](l),c=i.value}catch(e){r(e);return}i.done?t(c):Promise.resolve(c).then(n,a)}function ec(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=[],l=!0,i=!1;try{for(a=a.call(e);!(l=(r=a.next()).done)&&(o.push(r.value),!t||o.length!==t);l=!0);}catch(e){i=!0,n=e}finally{try{l||null==a.return||a.return()}finally{if(i)throw n}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return el(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 el(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 eu=function(a){var o=a.value,l=a.onChange,i=(0,e.useAPIClient)(),c=(0,e.useCompile)(),u=ec((0,t.useState)([]),2),s=u[0],f=u[1],d=ec((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,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function i(o){return function(i){var c=[o,i];if(r)throw TypeError("Generator is already executing.");for(;l;)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 l.label++,{value:c[1],done:!1};case 5:l.label++,n=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===c[0]||2===c[0])){l=0;continue}if(3===c[0]&&(!a||c[1]>a[0]&&c[1]<a[3])){l.label=c[1];break}if(6===c[0]&&l.label<a[1]){l.label=a[1],a=c;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(c);break}a[2]&&l.ops.pop(),l.trys.pop();continue}c=t.call(e,l)}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,i.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 l(e){ei(o,n,a,l,i,"next",e)}function i(e){ei(o,n,a,l,i,"throw",e)}l(void 0)})},function(){return t.apply(this,arguments)})()},[i]),r().createElement(n.Select,{value:o,onChange:l,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,")"))}))},es=i(505);function ef(e,t,r,n,a,o,l){try{var i=e[o](l),c=i.value}catch(e){r(e);return}i.done?t(c):Promise.resolve(c).then(n,a)}function ed(e){return function(){var t=this,r=arguments;return new Promise(function(n,a){var o=e.apply(t,r);function l(e){ef(o,n,a,l,i,"next",e)}function i(e){ef(o,n,a,l,i,"throw",e)}l(void 0)})}}function ep(e,t){var r,n,a,o,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function i(o){return function(i){var c=[o,i];if(r)throw TypeError("Generator is already executing.");for(;l;)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 l.label++,{value:c[1],done:!1};case 5:l.label++,n=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===c[0]||2===c[0])){l=0;continue}if(3===c[0]&&(!a||c[1]>a[0]&&c[1]<a[3])){l.label=c[1];break}if(6===c[0]&&l.label<a[1]){l.label=a[1],a=c;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(c);break}a[2]&&l.ops.pop(),l.trys.pop();continue}c=t.call(e,l)}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 ey=(0,t.createContext)(null),em=function(n){var a,o,l,i=n.children,c=(0,e.useAPIClient)(),u=(0,t.useRef)(new Map),s=(0,t.useRef)(new Map),f=(0,t.useCallback)((a=ed(function(e){var t,r;return ep(this,function(n){return(t=s.current.get(e))?[2,t]:u.current.has(e)?[2]:(r=ed(function(){var t,r,n,a,o;return ep(this,function(l){switch(l.label){case 0:return l.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=l.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=l.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=ed(function(e,t){var r;return ep(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)((l=ed(function(e,t){var r;return ep(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 l.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(ey.Provider,{value:{getDictionaryLabel:p,getDictionaryItem:d,clearCache:y}},i)},eb=function(){var e=(0,t.useContext)(ey);if(!e)throw Error("useDictionaryData must be used within DictionaryDataProvider");return e};function eh(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 ev(e,t,r,n,a,o,l){try{var i=e[o](l),c=i.value}catch(e){r(e);return}i.done?t(c):Promise.resolve(c).then(n,a)}function eg(e){return function(){var t=this,r=arguments;return new Promise(function(n,a){var o=e.apply(t,r);function l(e){ev(o,n,a,l,i,"next",e)}function i(e){ev(o,n,a,l,i,"throw",e)}l(void 0)})}}function ew(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 eS(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 eE(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=[],l=!0,i=!1;try{for(a=a.call(e);!(l=(r=a.next()).done)&&(o.push(r.value),!t||o.length!==t);l=!0);}catch(e){i=!0,n=e}finally{try{l||null==a.return||a.return()}finally{if(i)throw n}}return o}}(e,t)||eO(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 eO(e,t){if(e){if("string"==typeof e)return eh(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 eh(e,t)}}function eI(e,t){var r,n,a,o,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function i(o){return function(i){var c=[o,i];if(r)throw TypeError("Generator is already executing.");for(;l;)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 l.label++,{value:c[1],done:!1};case 5:l.label++,n=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===c[0]||2===c[0])){l=0;continue}if(3===c[0]&&(!a||c[1]>a[0]&&c[1]<a[3])){l.label=c[1];break}if(6===c[0]&&l.label<a[1]){l.label=a[1],a=c;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(c);break}a[2]&&l.ops.pop(),l.trys.pop();continue}c=t.call(e,l)}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 ek=function(o){var l,i,c,u=o.visible,s=o.onClose,f=o.dictionaryTypeId,d=o.onItemsChange,p=(0,e.useAPIClient)(),y=(0,e.useCompile)(),m=eE((0,t.useState)([]),2),b=m[0],h=m[1],v=eE((0,t.useState)(!1),2),g=v[0],w=v[1],S=eE((0,t.useState)(null),2),E=S[0],O=S[1],I=eE((0,t.useState)(!1),2),k=I[0],x=I[1],P=eE(n.Form.useForm(),1)[0],j=(l=eg(function(){var e,t;return eI(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 l.apply(this,arguments)});(0,t.useEffect)(function(){u&&f&&j()},[u,f]);var D=function(e){if(e)O(e),P.setFieldsValue(e);else{O(null),P.resetFields();var t,r,n=b.length>0?(r=Math).max.apply(r,function(e){if(Array.isArray(e))return eh(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)||eO(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;P.setFieldsValue({dictSort:n+10})}x(!0)},C=(i=eg(function(){var e;return eI(this,function(t){switch(t.label){case 0:return t.trys.push([0,7,,8]),[4,P.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:eS(ew({},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:eS(ew({},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,j()];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 i.apply(this,arguments)}),T=(c=eg(function(e){return eI(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,j()];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)}),A=[{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 D(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 D()}},y('{{t("Add Item", { ns: "dictionary-field" })}}'))),r().createElement(n.Table,{dataSource:b,columns:A,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:C,onCancel:function(){return x(!1)},okText:y('{{t("Save")}}'),cancelText:y('{{t("Cancel")}}')},r().createElement(n.Form,{form:P,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 ex(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 eP=function(e){var t,a,o,l=e.value,i=e.dictionaryTypeId;e.multiple;var c=L(i),u=c.treeData;if(c.loading)return r().createElement(n.Spin,{size:"small"});if(!l)return r().createElement("span",null,"-");var s=Array.isArray(l)?l:[l],f=(t=[],a=new Set(s),(o=function(e){e.forEach(function(e){a.has(e.key)&&t.push(e.title),e.children&&o(e.children)})})(u),t);return r().createElement("span",null,f.length>0?f.join(", "):s.join(", "))},ej=(0,es.connect)(function(o){var l,i=o.value,c=o.dictItems,u=o.onChange,s=o.dictionaryTypeId,f=o.multiple,d=void 0!==f&&f,p=o.allowClear,y=o.placeholder,m=o.loading,b=o.allowManageItems,h=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","dictItems","onChange","dictionaryTypeId","multiple","allowClear","placeholder","loading","allowManageItems"]),v=(0,e.useCompile)(),g=(l=(0,t.useState)(!1),function(e){if(Array.isArray(e))return e}(l)||function(e,t){var r,n,a=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var o=[],l=!0,i=!1;try{for(a=a.call(e);!(l=(r=a.next()).done)&&(o.push(r.value),o.length!==t);l=!0);}catch(e){i=!0,n=e}finally{try{l||null==a.return||a.return()}finally{if(i)throw n}}return o}}(l,2)||function(e,t){if(e){if("string"==typeof e)return ex(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 ex(e,t)}}(l,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.")}()),w=g[0],S=g[1],E=L(s,c),O=E.treeData,I=E.loading,k=E.refresh,x=(0,t.useMemo)(function(){return function e(t){return t.map(function(t){return{title:t.title||t.dictLabel,key:t.key||t.dictValue,value:t.key||t.dictValue,children:t.children&&t.children.length>0?e(t.children):[]}})}(O)},[O]),P=function(){S(!1),k()};return r().createElement("div",null,r().createElement(n.Space.Compact,{style:{width:"100%"}},r().createElement(n.TreeSelect,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}({style:{width:"100%"},placeholder:y||v('{{t("Select dictionary item", { ns: "dictionary-field" })}}'),value:i,onChange:function(e){null==u||u(e)},treeData:x,multiple:d,allowClear:void 0===p||p,showSearch:!0,treeNodeFilterProp:"title",treeCheckable:d,loading:I||m,treeDefaultExpandAll:!1},h)),void 0!==b&&b&&r().createElement(n.Tooltip,{title:v('{{t("Manage items", { ns: "dictionary-field" })}}')},r().createElement(n.Button,{icon:r().createElement(a.SettingOutlined,null),onClick:function(){return S(!0)},title:v('{{t("Manage items", { ns: "dictionary-field" })}}')}))),r().createElement(n.Modal,{title:v('{{t("Manage Dictionary Items", { ns: "dictionary-field" })}}'),open:w,onCancel:P,footer:[r().createElement(n.Button,{key:"close",onClick:P},v('{{t("Close")}}'))],width:800,destroyOnClose:!0},r().createElement(W,{dictionaryTypeId:s||""})))},(0,es.mapReadPretty)(eP));function eD(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 eC(e,t,r,n,a,o,l){try{var i=e[o](l),c=i.value}catch(e){r(e);return}i.done?t(c):Promise.resolve(c).then(n,a)}function eT(e){return function(){var t=this,r=arguments;return new Promise(function(n,a){var o=e.apply(t,r);function l(e){eC(o,n,a,l,i,"next",e)}function i(e){eC(o,n,a,l,i,"throw",e)}l(void 0)})}}function eA(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=[],l=!0,i=!1;try{for(a=a.call(e);!(l=(r=a.next()).done)&&(o.push(r.value),!t||o.length!==t);l=!0);}catch(e){i=!0,n=e}finally{try{l||null==a.return||a.return()}finally{if(i)throw n}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return eD(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 eD(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 eF(e,t){var r,n,a,o,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function i(o){return function(i){var c=[o,i];if(r)throw TypeError("Generator is already executing.");for(;l;)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 l.label++,{value:c[1],done:!1};case 5:l.label++,n=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===c[0]||2===c[0])){l=0;continue}if(3===c[0]&&(!a||c[1]>a[0]&&c[1]<a[3])){l.label=c[1];break}if(6===c[0]&&l.label<a[1]){l.label=a[1],a=c;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(c);break}a[2]&&l.ops.pop(),l.trys.pop();continue}c=t.call(e,l)}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 eM=function(o){var l,i,c,u,s,f,d,p,y=o.value,m=o.dictionaryTypeId,b=o.multiple,h=(0,es.useField)(),v=(0,es.useFieldSchema)(),g=(0,e.useCollectionField)(),w=eb().getDictionaryItem,S=eA((0,t.useState)([]),2),E=S[0],O=S[1];(0,e.useFieldTitle)();var I=m||(null==g||null==(i=g.uiSchema)||null==(l=i["x-component-props"])?void 0:l.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=eT(function(){var e,r;return eF(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)},eV=(0,es.connect)(function(o){var l,i,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)(),P=(0,es.useField)(),j=(0,es.useFieldSchema)(),D=(0,e.useCollectionField)(),C=eA((0,t.useState)([]),2),T=C[0],A=C[1],F=eA((0,t.useState)(!1),2),M=F[0],V=F[1],q=eA((0,t.useState)(!1),2),B=q[0],L=q[1],z=eA((0,t.useState)(!1),2),R=z[0],N=z[1],_=(0,e.useACLRoleContext)(),$=_.allowAll,U=_.parseAction;(0,e.useFieldTitle)();var G=S||(null==D||null==(c=D.uiSchema)||null==(i=c["x-component-props"])?void 0:i.dictionaryTypeId)||(null==P||null==(u=P.componentProps)?void 0:u.dictionaryTypeId)||(null==j||null==(s=j["x-component-props"])?void 0:s.dictionaryTypeId)||(null==I?void 0:I.dictionaryTypeId),K=O||(null==D||null==(d=D.uiSchema)||null==(f=d["x-component-props"])?void 0:f.multiple)||(null==P||null==(p=P.componentProps)?void 0:p.multiple)||(null==j||null==(y=j["x-component-props"])?void 0:y.multiple)||!1,Q=E||(null==D||null==(b=D.uiSchema)||null==(m=b["x-component-props"])?void 0:m.allowManageItems)||(null==P||null==(h=P.componentProps)?void 0:h.allowManageItems)||(null==j||null==(v=j["x-component-props"])?void 0:v.allowManageItems)||!1,H=$||U("rbDataDictionaryItems:create"),J=Q&&H,Y=(l=eT(function(){var e,t;return eF(this,function(r){switch(r.label){case 0:if(!G)return A([]),[2];V(!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:G},sort:["dictSort","createdAt"],pageSize:1e3}})];case 2:return Array.isArray(t=null==(e=r.sent())?void 0:e.data.data)?A(t):A([]),[3,5];case 3:return console.error("Failed to load dictionary items:",r.sent()),A([]),[3,5];case 4:return V(!1),[7];case 5:return[2]}})}),function(){return l.apply(this,arguments)});return((0,t.useEffect)(function(){N(T.some(function(e){return null!==e.parentId&&void 0!==e.parentId}))},[T]),(0,t.useEffect)(function(){Y()},[G,k]),R)?r().createElement(ej,{value:g,dictItems:T,onChange:w,dictionaryTypeId:G,multiple:K,allowManageItems:J,placeholder:x(K?'{{t("Select dictionary items", { ns: "dictionary-field" })}}':'{{t("Select dictionary item", { ns: "dictionary-field" })}}')}):r().createElement(r().Fragment,null,r().createElement(n.Space.Compact,{style:{width:"100%"}},r().createElement(n.Select,{mode:K?"multiple":void 0,value:g,onChange:w,loading:M,placeholder:x(K?'{{t("Select dictionary items", { ns: "dictionary-field" })}}':'{{t("Select dictionary item", { ns: "dictionary-field" })}}'),style:{width:J?"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}}))))})),J&&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:!G}))),J&&G&&r().createElement(ek,{visible:B,onClose:function(){return L(!1)},dictionaryTypeId:G,onItemsChange:function(){Y()}}))},(0,es.mapReadPretty)(eM)),eq=JSON.parse('{"Dictionary Type":"字典类型","Dictionary Item":"字典项","Dictionary Field":"数据字典","Dictionary Management":"字典管理","Name":"名称","Title":"标题","Description":"描述","Key":"键值","Value":"键值","Label":"显示值","Remark":"备注","Sort Order":"排序序号","Sort":"排序","Selected":"已选择","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":"可选备注"}'),eB=JSON.parse('{"Dictionary Type":"Dictionary Type","Dictionary Item":"Dictionary Item","Dictionary Field":"Data Dictionary","Dictionary Management":"Dictionary Management","Name":"Name","Title":"Title","Description":"Description","Key":"Key","Value":"Value","Label":"Label","Remark":"Remark","Sort Order":"Sort Order","Sort":"Sort","Selected":"Selected","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 eL(e,t,r,n,a,o,l){try{var i=e[o](l),c=i.value}catch(e){r(e);return}i.done?t(c):Promise.resolve(c).then(n,a)}function ez(e,t,r){return(ez=e$()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var a=new(Function.bind.apply(e,n));return r&&eN(a,r.prototype),a}).apply(null,arguments)}function eR(e){return(eR=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function eN(e,t){return(eN=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function e_(e){var t="function"==typeof Map?new Map:void 0;return(e_=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 ez(e,arguments,eR(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),eN(r,e)})(e)}function e$(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(e$=function(){return!!e})()}var eU=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=eR(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,e$()?Reflect.construct(e,t||[],eR(this).constructor):e.apply(this,t))}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&eN(r,e),t=[{key:"load",value:function(){var e,t=this;return(e=function(){return function(e,t){var r,n,a,o,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function i(o){return function(i){var c=[o,i];if(r)throw TypeError("Generator is already executing.");for(;l;)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 l.label++,{value:c[1],done:!1};case 5:l.label++,n=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===c[0]||2===c[0])){l=0;continue}if(3===c[0]&&(!a||c[1]>a[0]&&c[1]<a[3])){l.label=c[1];break}if(6===c[0]&&l.label<a[1]){l.label=a[1],a=c;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(c);break}a[2]&&l.ops.pop(),l.trys.pop();continue}c=t.call(e,l)}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(em),t.app.pluginSettingsManager.add("dictionary-field",{title:'{{t("Dictionary Management", { ns: "dictionary-field" })}}',icon:"UnorderedListOutlined",Component:ee,aclSnippet:"ui.dictionaryManagement"}),t.app.i18n.addResources("zh-CN","dictionary-field",eq),t.app.i18n.addResources("en-US","dictionary-field",eB),t.app.addComponents({DictionaryTypeSelect:eu,DictionarySelect:eV,"DictionarySelect.ReadPretty":eM}),t.app.dataSourceManager.addFieldInterfaces([eo]),[2]})},function(){var t=this,r=arguments;return new Promise(function(n,a){var o=e.apply(t,r);function l(e){eL(o,n,a,l,i,"next",e)}function i(e){eL(o,n,a,l,i,"throw",e)}l(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}(e_(e.Plugin)),eG=eU}(),c}()});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 字典树项列表组件
|
|
3
|
+
* 显示树形结构的字典项,支持展开/折叠、搜索、编辑、删除等操作
|
|
4
|
+
*/
|
|
5
|
+
import React from 'react';
|
|
6
|
+
interface DictionaryTreeItemListProps {
|
|
7
|
+
dictionaryTypeId: string;
|
|
8
|
+
onItemsChange?: () => void;
|
|
9
|
+
}
|
|
10
|
+
export declare const DictionaryTreeItemList: React.FC<DictionaryTreeItemListProps>;
|
|
11
|
+
export default DictionaryTreeItemList;
|
|
@@ -3,8 +3,15 @@
|
|
|
3
3
|
* T024: 显示所有字典类型,支持增删改查
|
|
4
4
|
*/
|
|
5
5
|
import React from 'react';
|
|
6
|
+
export interface DictionaryType {
|
|
7
|
+
id: string;
|
|
8
|
+
dictName: string;
|
|
9
|
+
status: number;
|
|
10
|
+
isTree?: boolean;
|
|
11
|
+
remark?: string;
|
|
12
|
+
}
|
|
6
13
|
interface DictionaryTypeListProps {
|
|
7
|
-
onSelect: (
|
|
14
|
+
onSelect: (type: DictionaryType | null) => void;
|
|
8
15
|
selectedId: string | null;
|
|
9
16
|
}
|
|
10
17
|
export declare const DictionaryTypeList: React.FC<DictionaryTypeListProps>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 树项表单组件
|
|
3
|
+
* 在 DictionaryItemForm 的基础上添加树结构支持
|
|
4
|
+
* 支持父项选择、深度显示等功能
|
|
5
|
+
*/
|
|
6
|
+
import React from 'react';
|
|
7
|
+
interface TreeItemFormProps {
|
|
8
|
+
initialValues?: {
|
|
9
|
+
id?: number;
|
|
10
|
+
dictValue: string;
|
|
11
|
+
dictLabel: string;
|
|
12
|
+
remark?: string;
|
|
13
|
+
sortOrder?: number;
|
|
14
|
+
parentId?: number | null;
|
|
15
|
+
depth?: number;
|
|
16
|
+
dictionaryTypeId: string;
|
|
17
|
+
};
|
|
18
|
+
dictionaryTypeId: string;
|
|
19
|
+
onSubmit: (values: any) => Promise<void>;
|
|
20
|
+
onCancel: () => void;
|
|
21
|
+
}
|
|
22
|
+
export declare const TreeItemForm: React.FC<TreeItemFormProps>;
|
|
23
|
+
export default TreeItemForm;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 从扁平列表构建树结构
|
|
3
|
+
*
|
|
4
|
+
* @param items 扁平的项列表
|
|
5
|
+
* @returns 树结构(嵌套的项数组)
|
|
6
|
+
*/
|
|
7
|
+
export declare function buildTreeStructure(items: any[]): any[];
|
|
8
|
+
/**
|
|
9
|
+
* 转换树结构为 TreeSelect 格式
|
|
10
|
+
*
|
|
11
|
+
* @param treeItems 树结构项
|
|
12
|
+
* @returns TreeSelect 格式的数据
|
|
13
|
+
*/
|
|
14
|
+
export declare function convertToTreeSelectFormat(treeItems: any[]): any[];
|
package/dist/locale/en-US.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"Dictionary Type": "Dictionary Type",
|
|
3
3
|
"Dictionary Item": "Dictionary Item",
|
|
4
|
-
"Dictionary Field": "Dictionary
|
|
4
|
+
"Dictionary Field": "Data Dictionary",
|
|
5
5
|
"Dictionary Management": "Dictionary Management",
|
|
6
6
|
"Name": "Name",
|
|
7
7
|
"Title": "Title",
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"Remark": "Remark",
|
|
13
13
|
"Sort Order": "Sort Order",
|
|
14
14
|
"Sort": "Sort",
|
|
15
|
+
"Selected": "Selected",
|
|
15
16
|
"Dictionary type not found": "Dictionary type not found",
|
|
16
17
|
"Dictionary item not found": "Dictionary item not found",
|
|
17
18
|
"Dictionary type name already exists": "Dictionary type name already exists",
|
package/dist/locale/zh-CN.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"Dictionary Type": "字典类型",
|
|
3
3
|
"Dictionary Item": "字典项",
|
|
4
|
-
"Dictionary Field": "
|
|
4
|
+
"Dictionary Field": "数据字典",
|
|
5
5
|
"Dictionary Management": "字典管理",
|
|
6
6
|
"Name": "名称",
|
|
7
7
|
"Title": "标题",
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"Remark": "备注",
|
|
13
13
|
"Sort Order": "排序序号",
|
|
14
14
|
"Sort": "排序",
|
|
15
|
+
"Selected": "已选择",
|
|
15
16
|
"Dictionary type not found": "字典类型不存在",
|
|
16
17
|
"Dictionary item not found": "字典项不存在",
|
|
17
18
|
"Dictionary type name already exists": "字典类型名称已存在",
|