vap1 0.0.1
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/basetype.d.ts +62 -0
- package/basetype.js +2 -0
- package/components/Box/Box.d.ts +118 -0
- package/components/Box/Box.js +150 -0
- package/components/Box/SelectBar.d.ts +90 -0
- package/components/Box/SelectBar.js +93 -0
- package/components/Box/_register.d.ts +49 -0
- package/components/Box/_register.js +29 -0
- package/components/Box/index.d.ts +9 -0
- package/components/Box/index.js +6 -0
- package/components/Lists/SList.d.ts +58 -0
- package/components/Lists/SList.js +167 -0
- package/components/SearchBar/ActionButtons.d.ts +49 -0
- package/components/SearchBar/ActionButtons.js +96 -0
- package/components/SearchBar/ByField.d.ts +3 -0
- package/components/SearchBar/ByField.js +193 -0
- package/components/SearchBar/ByKeyword.d.ts +3 -0
- package/components/SearchBar/ByKeyword.js +34 -0
- package/components/SearchBar/SearchField.d.ts +15 -0
- package/components/SearchBar/SearchField.js +25 -0
- package/components/SearchBar/SearchTags.d.ts +2 -0
- package/components/SearchBar/SearchTags.js +18 -0
- package/components/SearchBar/_FieldType.d.ts +8 -0
- package/components/SearchBar/_FieldType.js +45 -0
- package/components/SearchBar/_register.d.ts +65 -0
- package/components/SearchBar/_register.js +29 -0
- package/components/SearchBar/index.d.ts +134 -0
- package/components/SearchBar/index.js +33 -0
- package/components/Tables/ApiTable.d.ts +18 -0
- package/components/Tables/ApiTable.js +48 -0
- package/components/Tables/ApiTableModal.d.ts +22 -0
- package/components/Tables/ApiTableModal.js +73 -0
- package/components/Tables/Components/ActionBar.d.ts +56 -0
- package/components/Tables/Components/ActionBar.js +100 -0
- package/components/Tables/Components/Actions.d.ts +47 -0
- package/components/Tables/Components/Actions.js +91 -0
- package/components/Tables/Components/Summary.d.ts +11 -0
- package/components/Tables/Components/Summary.js +11 -0
- package/components/Tables/Components/index.d.ts +17 -0
- package/components/Tables/Components/index.js +19 -0
- package/components/Tables/STable.d.ts +5 -0
- package/components/Tables/STable.js +37 -0
- package/components/Tables/TopTable.d.ts +24 -0
- package/components/Tables/TopTable.js +157 -0
- package/components/Tables/TopTableModal.d.ts +5 -0
- package/components/Tables/TopTableModal.js +20 -0
- package/components/Tables/Util.d.ts +3 -0
- package/components/Tables/Util.js +41 -0
- package/components/Tables/VTable.d.ts +11 -0
- package/components/Tables/VTable.js +237 -0
- package/components/Tables/index.d.ts +81 -0
- package/components/Tables/index.js +20 -0
- package/components/TreeSelect/BaseTreeSelect.d.ts +33 -0
- package/components/TreeSelect/BaseTreeSelect.js +190 -0
- package/components/TreeSelect/DTreeSelect.d.ts +24 -0
- package/components/TreeSelect/DTreeSelect.js +66 -0
- package/components/TreeSelect/FTreeSelect.d.ts +11 -0
- package/components/TreeSelect/FTreeSelect.js +39 -0
- package/components/TreeSelect/STreeSelect.d.ts +14 -0
- package/components/TreeSelect/STreeSelect.js +52 -0
- package/components/TreeSelect/index.d.ts +94 -0
- package/components/TreeSelect/index.js +9 -0
- package/components/Trees/ActionTree.d.ts +54 -0
- package/components/Trees/ActionTree.js +657 -0
- package/components/Trees/BaseTree.d.ts +31 -0
- package/components/Trees/BaseTree.js +185 -0
- package/components/Trees/DTree.d.ts +48 -0
- package/components/Trees/DTree.js +142 -0
- package/components/Trees/FTree.d.ts +33 -0
- package/components/Trees/FTree.js +79 -0
- package/components/Trees/STree.d.ts +21 -0
- package/components/Trees/STree.js +92 -0
- package/components/Trees/index.d.ts +134 -0
- package/components/Trees/index.js +9 -0
- package/components/UForm/FormWrapper.d.ts +22 -0
- package/components/UForm/FormWrapper.js +270 -0
- package/components/UForm/UDescriptions.d.ts +5 -0
- package/components/UForm/UDescriptions.js +134 -0
- package/components/UForm/UForm.d.ts +33 -0
- package/components/UForm/UForm.js +484 -0
- package/components/UForm/UFormModal.d.ts +3 -0
- package/components/UForm/UFormModal.js +149 -0
- package/components/UForm/UInfo.d.ts +10 -0
- package/components/UForm/UInfo.js +75 -0
- package/components/UForm/UInfoModal.d.ts +3 -0
- package/components/UForm/UInfoModal.js +50 -0
- package/components/UForm/UModal.d.ts +3 -0
- package/components/UForm/UModal.js +24 -0
- package/components/UForm/_FieldType.d.ts +8 -0
- package/components/UForm/_FieldType.js +100 -0
- package/components/UForm/_FormUtils.d.ts +5 -0
- package/components/UForm/_FormUtils.js +75 -0
- package/components/UForm/_input.d.ts +59 -0
- package/components/UForm/_input.js +147 -0
- package/components/UForm/_register.d.ts +87 -0
- package/components/UForm/_register.js +44 -0
- package/components/UForm/index.d.ts +387 -0
- package/components/UForm/index.js +15 -0
- package/components/Upload/UploadFile.d.ts +3 -0
- package/components/Upload/UploadFile.js +40 -0
- package/components/Upload/UploadImage.d.ts +24 -0
- package/components/Upload/UploadImage.js +93 -0
- package/components/Upload/UploadModal.d.ts +50 -0
- package/components/Upload/UploadModal.js +140 -0
- package/components/Upload/index.d.ts +77 -0
- package/components/Upload/index.js +9 -0
- package/components/Upload/useUpload.d.ts +15 -0
- package/components/Upload/useUpload.js +93 -0
- package/components/_RegisterUtil.d.ts +1 -0
- package/components/_RegisterUtil.js +25 -0
- package/components/_adapt/Alert.d.ts +11 -0
- package/components/_adapt/Alert.js +43 -0
- package/components/_adapt/Button.d.ts +20 -0
- package/components/_adapt/Button.js +26 -0
- package/components/_adapt/Col.d.ts +53 -0
- package/components/_adapt/Col.js +90 -0
- package/components/_adapt/Collapse.d.ts +30 -0
- package/components/_adapt/Collapse.js +33 -0
- package/components/_adapt/Drawer.d.ts +12 -0
- package/components/_adapt/Drawer.js +11 -0
- package/components/_adapt/Dropdown.d.ts +15 -0
- package/components/_adapt/Dropdown.js +38 -0
- package/components/_adapt/Icon.d.ts +14 -0
- package/components/_adapt/Icon.js +34 -0
- package/components/_adapt/Image.d.ts +4 -0
- package/components/_adapt/Image.js +11 -0
- package/components/_adapt/Menu.d.ts +32 -0
- package/components/_adapt/Menu.js +25 -0
- package/components/_adapt/Modal.d.ts +23 -0
- package/components/_adapt/Modal.js +69 -0
- package/components/_adapt/Popconfirm.d.ts +5 -0
- package/components/_adapt/Popconfirm.js +34 -0
- package/components/_adapt/Popover.d.ts +5 -0
- package/components/_adapt/Popover.js +34 -0
- package/components/_adapt/Progress.d.ts +14 -0
- package/components/_adapt/Progress.js +56 -0
- package/components/_adapt/Row.d.ts +10 -0
- package/components/_adapt/Row.js +23 -0
- package/components/_adapt/Select.d.ts +14 -0
- package/components/_adapt/Select.js +47 -0
- package/components/_adapt/Tag.d.ts +7 -0
- package/components/_adapt/Tag.js +12 -0
- package/components/_adapt/Tooltip.d.ts +5 -0
- package/components/_adapt/Tooltip.js +11 -0
- package/components/_adapt/todo/ColorPicker.d.ts +3 -0
- package/components/_adapt/todo/ColorPicker.js +42 -0
- package/components/_adapt/todo/FloatButton.d.ts +2 -0
- package/components/_adapt/todo/FloatButton.js +6 -0
- package/components/_adapt/todo/Image.d.ts +2 -0
- package/components/_adapt/todo/Image.js +6 -0
- package/components/_adapt/todo/Segmented.d.ts +2 -0
- package/components/_adapt/todo/Segmented.js +6 -0
- package/components/_adapt/todo/Space.d.ts +2 -0
- package/components/_adapt/todo/Space.js +6 -0
- package/components/_adapt/utils.d.ts +12 -0
- package/components/_adapt/utils.js +93 -0
- package/components/_common/AutoComplete.d.ts +32 -0
- package/components/_common/AutoComplete.js +87 -0
- package/components/_common/CountUp.d.ts +38 -0
- package/components/_common/CountUp.js +60 -0
- package/components/_common/DateRange.d.ts +52 -0
- package/components/_common/DateRange.js +108 -0
- package/components/_common/HighLight.d.ts +15 -0
- package/components/_common/HighLight.js +37 -0
- package/components/_common/I18N.d.ts +7 -0
- package/components/_common/I18N.js +6 -0
- package/components/_common/Loading.d.ts +9 -0
- package/components/_common/Loading.js +52 -0
- package/components/_common/MonthRange.d.ts +46 -0
- package/components/_common/MonthRange.js +130 -0
- package/components/_common/PromiseLabel.d.ts +11 -0
- package/components/_common/PromiseLabel.js +34 -0
- package/components/_common/Role.d.ts +5 -0
- package/components/_common/Role.js +11 -0
- package/components/_common/Upagination.d.ts +21 -0
- package/components/_common/Upagination.js +106 -0
- package/components/_setup/Const.d.ts +205 -0
- package/components/_setup/Const.js +112 -0
- package/components/_setup/I18N/enUS.d.ts +1 -0
- package/components/_setup/I18N/enUS.js +106 -0
- package/components/_setup/I18N/index.d.ts +3 -0
- package/components/_setup/I18N/index.js +5 -0
- package/components/_setup/I18N/zhCN.d.ts +3 -0
- package/components/_setup/I18N/zhCN.js +109 -0
- package/components/_setup/I18N/zhHK.d.ts +1 -0
- package/components/_setup/I18N/zhHK.js +107 -0
- package/components/_setup/ICON/IconTypes.d.ts +1 -0
- package/components/_setup/ICON/IconTypes.js +10 -0
- package/components/_setup/SearchField/SearchFieldAdvance.d.ts +1 -0
- package/components/_setup/SearchField/SearchFieldAdvance.js +57 -0
- package/components/_setup/SearchField/SearchFieldDate.d.ts +1 -0
- package/components/_setup/SearchField/SearchFieldDate.js +186 -0
- package/components/_setup/SearchField/SearchFieldInput.d.ts +3 -0
- package/components/_setup/SearchField/SearchFieldInput.js +20 -0
- package/components/_setup/SearchField/SearchFieldSelect.d.ts +1 -0
- package/components/_setup/SearchField/SearchFieldSelect.js +106 -0
- package/components/_setup/SearchField/SearchFieldTree.d.ts +1 -0
- package/components/_setup/SearchField/SearchFieldTree.js +191 -0
- package/components/_setup/SelectBar/SelectList.d.ts +1 -0
- package/components/_setup/SelectBar/SelectList.js +21 -0
- package/components/_setup/SelectBar/SelectTree.d.ts +1 -0
- package/components/_setup/SelectBar/SelectTree.js +11 -0
- package/components/_setup/UForm/UFormAdvanceInput.d.ts +1 -0
- package/components/_setup/UForm/UFormAdvanceInput.js +300 -0
- package/components/_setup/UForm/UFormAdvanceSelect.d.ts +0 -0
- package/components/_setup/UForm/UFormAdvanceSelect.js +26 -0
- package/components/_setup/UForm/UFormCrontab.d.ts +1 -0
- package/components/_setup/UForm/UFormCrontab.js +199 -0
- package/components/_setup/UForm/UFormDate.d.ts +1 -0
- package/components/_setup/UForm/UFormDate.js +313 -0
- package/components/_setup/UForm/UFormInput.d.ts +1 -0
- package/components/_setup/UForm/UFormInput.js +159 -0
- package/components/_setup/UForm/UFormJSON.d.ts +1 -0
- package/components/_setup/UForm/UFormJSON.js +219 -0
- package/components/_setup/UForm/UFormOrg.d.ts +1 -0
- package/components/_setup/UForm/UFormOrg.js +121 -0
- package/components/_setup/UForm/UFormRole.d.ts +1 -0
- package/components/_setup/UForm/UFormRole.js +47 -0
- package/components/_setup/UForm/UFormSearch.d.ts +0 -0
- package/components/_setup/UForm/UFormSearch.js +35 -0
- package/components/_setup/UForm/UFormSelect.d.ts +1 -0
- package/components/_setup/UForm/UFormSelect.js +179 -0
- package/components/_setup/UForm/UFormTree.d.ts +0 -0
- package/components/_setup/UForm/UFormTree.js +134 -0
- package/components/_setup/UForm/UFormUpload.d.ts +1 -0
- package/components/_setup/UForm/UFormUpload.js +173 -0
- package/components/_setup/UForm/_utils.d.ts +11 -0
- package/components/_setup/UForm/_utils.js +41 -0
- package/components/_setup/index.d.ts +21 -0
- package/components/_setup/index.js +25 -0
- package/components/index.d.ts +7 -0
- package/components/index.js +16 -0
- package/deps/JsonView.d.ts +6 -0
- package/deps/JsonView.js +57 -0
- package/deps/SpringBoot.d.ts +4 -0
- package/deps/SpringBoot.js +18 -0
- package/deps/SpringCloud.d.ts +14 -0
- package/deps/SpringCloud.js +29 -0
- package/deps/_editor/advance/_Audio.d.ts +0 -0
- package/deps/_editor/advance/_Audio.js +1 -0
- package/deps/_editor/advance/_Image.d.ts +2 -0
- package/deps/_editor/advance/_Image.js +89 -0
- package/deps/_editor/advance/_Table.d.ts +0 -0
- package/deps/_editor/advance/_Table.js +1 -0
- package/deps/_editor/advance/_Video.d.ts +0 -0
- package/deps/_editor/advance/_Video.js +1 -0
- package/deps/_editor/base/Element.d.ts +5 -0
- package/deps/_editor/base/Element.js +43 -0
- package/deps/_editor/base/Leaf.d.ts +3 -0
- package/deps/_editor/base/Leaf.js +36 -0
- package/deps/_editor/base/Support.d.ts +2 -0
- package/deps/_editor/base/Support.js +78 -0
- package/deps/_editor/base/types.d.ts +156 -0
- package/deps/_editor/base/types.js +10 -0
- package/deps/_editor/i18n.d.ts +1 -0
- package/deps/_editor/i18n.js +31 -0
- package/deps/_editor/tools/Button.d.ts +6 -0
- package/deps/_editor/tools/Button.js +86 -0
- package/deps/_editor/tools/ToolBar.d.ts +8 -0
- package/deps/_editor/tools/ToolBar.js +10 -0
- package/deps/_editor/tools/_BlockButton.d.ts +4 -0
- package/deps/_editor/tools/_BlockButton.js +77 -0
- package/deps/_editor/tools/_InsertButton.d.ts +6 -0
- package/deps/_editor/tools/_InsertButton.js +65 -0
- package/deps/_editor/tools/_MarkButton.d.ts +6 -0
- package/deps/_editor/tools/_MarkButton.js +45 -0
- package/deps/_editor/tools/_TxtButton.d.ts +7 -0
- package/deps/_editor/tools/_TxtButton.js +187 -0
- package/deps/_editor/utils/ParseHtml.d.ts +0 -0
- package/deps/_editor/utils/ParseHtml.js +220 -0
- package/deps/api-audit.d.ts +1 -0
- package/deps/api-audit.js +6 -0
- package/deps/api-data.d.ts +0 -0
- package/deps/api-data.js +1 -0
- package/deps/apis/useSource.d.ts +0 -0
- package/deps/apis/useSource.js +152 -0
- package/deps/echarts.d.ts +26 -0
- package/deps/echarts.js +71 -0
- package/deps/editor.d.ts +34 -0
- package/deps/editor.js +111 -0
- package/deps/registerEditor.d.ts +1 -0
- package/deps/registerEditor.js +15 -0
- package/hooks/_list.d.ts +87 -0
- package/hooks/_list.js +13 -0
- package/hooks/index.d.ts +14 -0
- package/hooks/index.js +49 -0
- package/hooks/useAjax.d.ts +14 -0
- package/hooks/useAjax.js +43 -0
- package/hooks/useAjaxAction.d.ts +13 -0
- package/hooks/useAjaxAction.js +42 -0
- package/hooks/useAjaxQuery.d.ts +40 -0
- package/hooks/useAjaxQuery.js +81 -0
- package/hooks/useApi.d.ts +69 -0
- package/hooks/useApi.js +352 -0
- package/hooks/useApiGlobal.d.ts +0 -0
- package/hooks/useApiGlobal.js +5 -0
- package/hooks/useApp.d.ts +243 -0
- package/hooks/useApp.js +17 -0
- package/hooks/useArray.d.ts +21 -0
- package/hooks/useArray.js +182 -0
- package/hooks/useCounter.d.ts +0 -0
- package/hooks/useCounter.js +82 -0
- package/hooks/useDefault.d.ts +6 -0
- package/hooks/useDefault.js +16 -0
- package/hooks/useDoLoad.d.ts +17 -0
- package/hooks/useDoLoad.js +44 -0
- package/hooks/useEffectFunction.d.ts +8 -0
- package/hooks/useEffectFunction.js +16 -0
- package/hooks/useEffectOnce.d.ts +5 -0
- package/hooks/useEffectOnce.js +23 -0
- package/hooks/useError.d.ts +5 -0
- package/hooks/useError.js +21 -0
- package/hooks/useFirstMountState.d.ts +6 -0
- package/hooks/useFirstMountState.js +18 -0
- package/hooks/useGenkey.d.ts +2 -0
- package/hooks/useGenkey.js +16 -0
- package/hooks/useGetSet.d.ts +11 -0
- package/hooks/useGetSet.js +27 -0
- package/hooks/useGlobal.d.ts +19 -0
- package/hooks/useGlobal.js +62 -0
- package/hooks/useGlobal_back.d.ts +1 -0
- package/hooks/useGlobal_back.js +11 -0
- package/hooks/useHover.d.ts +8 -0
- package/hooks/useHover.js +49 -0
- package/hooks/useMemoPromise.d.ts +6 -0
- package/hooks/useMemoPromise.js +42 -0
- package/hooks/useModals.d.ts +40 -0
- package/hooks/useModals.js +98 -0
- package/hooks/useMountedState.d.ts +5 -0
- package/hooks/useMountedState.js +20 -0
- package/hooks/useOpenState.d.ts +28 -0
- package/hooks/useOpenState.js +23 -0
- package/hooks/usePromise.d.ts +7 -0
- package/hooks/usePromise.js +22 -0
- package/hooks/useQueue.d.ts +12 -0
- package/hooks/useQueue.js +34 -0
- package/hooks/useSetState.d.ts +9 -0
- package/hooks/useSetState.js +26 -0
- package/hooks/useStateList.d.ts +13 -0
- package/hooks/useStateList.js +59 -0
- package/hooks/useToggle.d.ts +6 -0
- package/hooks/useToggle.js +12 -0
- package/hooks/useUnmountPromise.d.ts +6 -0
- package/hooks/useUnmountPromise.js +36 -0
- package/hooks/useUpdate.d.ts +7 -0
- package/hooks/useUpdate.js +15 -0
- package/hooks/useUpdateEffect.d.ts +6 -0
- package/hooks/useUpdateEffect.js +18 -0
- package/index.d.ts +139 -0
- package/index.js +161 -0
- package/login/Base65.d.ts +8 -0
- package/login/Base65.js +65 -0
- package/login/Password.d.ts +61 -0
- package/login/Password.js +124 -0
- package/login/SM4.d.ts +20 -0
- package/login/SM4.js +193 -0
- package/login/cems/index.d.ts +10 -0
- package/login/cems/index.js +17 -0
- package/login/jit/index.d.ts +32 -0
- package/login/jit/index.js +180 -0
- package/login/jit/pnxclient.d.ts +54 -0
- package/login/jit/pnxclient.js +575 -0
- package/login/sso/index.d.ts +0 -0
- package/login/sso/index.js +0 -0
- package/login/vap/index.d.ts +1 -0
- package/login/vap/index.js +6 -0
- package/login/xrtx/index.d.ts +2 -0
- package/login/xrtx/index.js +33 -0
- package/package.json +1 -0
- package/screen/Comment.d.ts +31 -0
- package/screen/Comment.js +29 -0
- package/screen/EchartContent.d.ts +0 -0
- package/screen/EchartContent.js +63 -0
- package/screen/Page.d.ts +13 -0
- package/screen/Page.js +74 -0
- package/screen/index.d.ts +3 -0
- package/screen/index.js +9 -0
- package/screen/render.d.ts +5 -0
- package/screen/render.js +10 -0
- package/utils/Ajax.d.ts +85 -0
- package/utils/Ajax.js +147 -0
- package/utils/ArrayUtil.d.ts +22 -0
- package/utils/ArrayUtil.js +51 -0
- package/utils/CacheUtil.d.ts +20 -0
- package/utils/CacheUtil.js +86 -0
- package/utils/Const.d.ts +14 -0
- package/utils/Const.js +37 -0
- package/utils/CustomApp.d.ts +242 -0
- package/utils/CustomApp.js +18 -0
- package/utils/EventUtil.d.ts +22 -0
- package/utils/EventUtil.js +63 -0
- package/utils/Format.d.ts +28 -0
- package/utils/Format.js +206 -0
- package/utils/Global.d.ts +276 -0
- package/utils/Global.js +125 -0
- package/utils/Logger.d.ts +5 -0
- package/utils/Logger.js +32 -0
- package/utils/PageUtil.d.ts +24 -0
- package/utils/PageUtil.js +87 -0
- package/utils/Renders/ApiGetRender.d.ts +23 -0
- package/utils/Renders/ApiGetRender.js +192 -0
- package/utils/Renders/ApiPostRender.d.ts +17 -0
- package/utils/Renders/ApiPostRender.js +161 -0
- package/utils/Renders/DateRender.d.ts +8 -0
- package/utils/Renders/DateRender.js +35 -0
- package/utils/Renders/DictRender.d.ts +23 -0
- package/utils/Renders/DictRender.js +258 -0
- package/utils/Renders/FileRender.d.ts +3 -0
- package/utils/Renders/FileRender.js +46 -0
- package/utils/Renders/ListRender.d.ts +23 -0
- package/utils/Renders/ListRender.js +111 -0
- package/utils/Renders/NumberRender.d.ts +19 -0
- package/utils/Renders/NumberRender.js +65 -0
- package/utils/Renders/StatusRender.d.ts +12 -0
- package/utils/Renders/StatusRender.js +68 -0
- package/utils/Renders/StringRender.d.ts +14 -0
- package/utils/Renders/StringRender.js +194 -0
- package/utils/Renders/_define.d.ts +26 -0
- package/utils/Renders/_define.js +64 -0
- package/utils/Renders/index.d.ts +9 -0
- package/utils/Renders/index.js +42 -0
- package/utils/StringUtil.d.ts +124 -0
- package/utils/StringUtil.js +352 -0
- package/utils/TreeUtil.d.ts +42 -0
- package/utils/TreeUtil.js +69 -0
- package/utils/VAP.d.ts +16 -0
- package/utils/VAP.js +78 -0
- package/utils/XHR.d.ts +9 -0
- package/utils/XHR.js +53 -0
- package/utils/_AjaxUtil.d.ts +11 -0
- package/utils/_AjaxUtil.js +45 -0
- package/utils/_Support.d.ts +22 -0
- package/utils/_Support.js +106 -0
- package/utils/i18n.d.ts +60 -0
- package/utils/i18n.js +184 -0
- package/utils/index.d.ts +19 -0
- package/utils/index.js +54 -0
- package/utils/screenful.d.ts +15 -0
- package/utils/screenful.js +64 -0
- package/widget/index.d.ts +39 -0
- package/widget/index.js +21 -0
|
@@ -0,0 +1,657 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.getResponseList = exports.renderRoot = exports.ActionTree = exports.useActionTree = void 0;
|
|
39
|
+
const react_1 = __importStar(require("react"));
|
|
40
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
41
|
+
const antd_1 = require("antd");
|
|
42
|
+
const Popconfirm_1 = require("../_adapt/Popconfirm");
|
|
43
|
+
const Dropdown_1 = require("../_adapt/Dropdown");
|
|
44
|
+
const BaseTree_1 = require("./BaseTree");
|
|
45
|
+
const Icon_1 = require("../_adapt/Icon");
|
|
46
|
+
const UFormModal_1 = require("../UForm/UFormModal");
|
|
47
|
+
const utils_1 = require("../../utils");
|
|
48
|
+
const Const_1 = require("../_setup/Const");
|
|
49
|
+
const useModals_1 = require("../../hooks/useModals");
|
|
50
|
+
const STEP = 16;
|
|
51
|
+
var INSER_POS;
|
|
52
|
+
(function (INSER_POS) {
|
|
53
|
+
INSER_POS[INSER_POS["BEFORE"] = 0] = "BEFORE";
|
|
54
|
+
INSER_POS[INSER_POS["AFTER"] = 1] = "AFTER";
|
|
55
|
+
INSER_POS[INSER_POS["INNER"] = 2] = "INNER";
|
|
56
|
+
INSER_POS[INSER_POS["TOP"] = 3] = "TOP";
|
|
57
|
+
INSER_POS[INSER_POS["BOTTOM"] = 4] = "BOTTOM";
|
|
58
|
+
})(INSER_POS || (INSER_POS = {}));
|
|
59
|
+
;
|
|
60
|
+
const { txt } = utils_1.i18n;
|
|
61
|
+
const ActionTreeContext = (0, react_1.createContext)(null);
|
|
62
|
+
const useActionTree = () => (0, react_1.useContext)(ActionTreeContext);
|
|
63
|
+
exports.useActionTree = useActionTree;
|
|
64
|
+
const _Actiontree = (0, react_1.forwardRef)((props, ref) => {
|
|
65
|
+
const { treeState, setTreeData } = (0, BaseTree_1.useBaseTree)();
|
|
66
|
+
const modals = (0, useModals_1.useModals)();
|
|
67
|
+
const FIELDS = (0, react_1.useRef)([]);
|
|
68
|
+
const getDefault = (0, react_1.useCallback)(() => {
|
|
69
|
+
if (props.formDefault == null)
|
|
70
|
+
return {};
|
|
71
|
+
if (lodash_1.default.isPlainObject(props.formDefault))
|
|
72
|
+
return props.formDefault;
|
|
73
|
+
if (lodash_1.default.isFunction(props.formDefault))
|
|
74
|
+
return props.formDefault(treeState.selectedNode);
|
|
75
|
+
return {};
|
|
76
|
+
}, [treeState.selectedNode]);
|
|
77
|
+
const action = {
|
|
78
|
+
objectName: '',
|
|
79
|
+
canAdd: false,
|
|
80
|
+
canAddRoot: false,
|
|
81
|
+
canUpdate: false,
|
|
82
|
+
canUpdateRoot: false,
|
|
83
|
+
canDelete: false,
|
|
84
|
+
canSort: false,
|
|
85
|
+
notCache: false,
|
|
86
|
+
};
|
|
87
|
+
if (props.notCache)
|
|
88
|
+
action.notCache = true;
|
|
89
|
+
action.objectName = utils_1.i18n.getText(props.ik, props.objectName, Const_1.V.TREE_NODE);
|
|
90
|
+
if (props.api) {
|
|
91
|
+
action.api = props.api;
|
|
92
|
+
if (props.canAdd) {
|
|
93
|
+
action.canAdd = true;
|
|
94
|
+
if (props.canAddRoot)
|
|
95
|
+
action.canAddRoot = true;
|
|
96
|
+
}
|
|
97
|
+
if (props.canUpdate) {
|
|
98
|
+
action.canUpdate = true;
|
|
99
|
+
if (props.canUpdateRoot)
|
|
100
|
+
action.canUpdateRoot = true;
|
|
101
|
+
}
|
|
102
|
+
if (props.canDelete)
|
|
103
|
+
action.canDelete = true;
|
|
104
|
+
if (props.canSort && treeState.sortField)
|
|
105
|
+
action.canSort = true;
|
|
106
|
+
}
|
|
107
|
+
(0, react_1.useLayoutEffect)(() => {
|
|
108
|
+
if (ref != null) {
|
|
109
|
+
ref.current = {
|
|
110
|
+
updateData, update, del, add: (data, position) => {
|
|
111
|
+
let nodePath = position.map(i => `[${i}]`).join('.children');
|
|
112
|
+
const { treeData } = treeState;
|
|
113
|
+
let node = lodash_1.default.get(treeData, nodePath);
|
|
114
|
+
if (node == null) {
|
|
115
|
+
antd_1.message.error('No parent found');
|
|
116
|
+
}
|
|
117
|
+
add(data, { pos: INSER_POS.INNER, node, position });
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
}, [treeState.treeData]);
|
|
122
|
+
(0, react_1.useLayoutEffect)(() => {
|
|
123
|
+
if (props.formFields) {
|
|
124
|
+
FIELDS.current = props.formFields;
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
let fields = [];
|
|
128
|
+
if (treeState.langs) {
|
|
129
|
+
treeState.langs.map(({ lang, field }) => {
|
|
130
|
+
fields.push({ title: `${action.objectName}(${lang})`, field: field });
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
fields.push({ title: action.objectName, field: treeState.titleField });
|
|
135
|
+
}
|
|
136
|
+
FIELDS.current = fields;
|
|
137
|
+
// ref.current
|
|
138
|
+
}, []);
|
|
139
|
+
const showAdd = (pos, node, position) => modals.showAdd({ pos, node, position });
|
|
140
|
+
const showEdit = (node, position) => modals.showEdit(node, { position });
|
|
141
|
+
// ref.
|
|
142
|
+
const addRoot = (data, extra) => __awaiter(void 0, void 0, void 0, function* () {
|
|
143
|
+
const { pos, position } = extra;
|
|
144
|
+
const { parentField, titleField, sortField, rootCode, treeData } = treeState;
|
|
145
|
+
if (position.length > 2)
|
|
146
|
+
return;
|
|
147
|
+
if (position.length == 2) {
|
|
148
|
+
if (treeData.length != 1)
|
|
149
|
+
return;
|
|
150
|
+
let child = treeData[0].children || [];
|
|
151
|
+
if (child.length == 0) {
|
|
152
|
+
addInner(data, { pos: INSER_POS.INNER, node: treeData[0], position: [0] });
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
if (pos == INSER_POS.TOP) {
|
|
156
|
+
add(data, { pos: INSER_POS.BEFORE, node: child[0], position: [0, 0] });
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
add(data, { pos: INSER_POS.AFTER, node: child[child.length - 1], position: [0, child.length - 1] });
|
|
160
|
+
}
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const { api, objectName, } = action;
|
|
164
|
+
let sort = 0;
|
|
165
|
+
if (treeData.length) {
|
|
166
|
+
if (pos == INSER_POS.TOP) {
|
|
167
|
+
sort = treeData[0][sortField] - STEP;
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
sort = treeData[treeData.length - 1][sortField] + STEP;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
var param = Object.assign(Object.assign({}, data), { [parentField]: rootCode, sort });
|
|
174
|
+
const result = yield utils_1.Ajax.PUT(api, param);
|
|
175
|
+
if (result.code != '0') {
|
|
176
|
+
antd_1.message.error(txt(Const_1.V.ACT_ADD_FAIL_NAMED, `${objectName} : ${data[titleField]}`));
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
antd_1.message.success(txt(Const_1.V.ACT_ADD_SUCCESS_NAMED, `${objectName} : ${data[titleField]}`));
|
|
180
|
+
props.clearCache(rootCode);
|
|
181
|
+
let tree = utils_1.ArrayUtil.add(treeData, result.data);
|
|
182
|
+
setTreeData(tree);
|
|
183
|
+
});
|
|
184
|
+
const addInner = (data, extra) => __awaiter(void 0, void 0, void 0, function* () {
|
|
185
|
+
const { node, position } = extra;
|
|
186
|
+
const { api, objectName, canSort, } = action;
|
|
187
|
+
const { parentField, titleField, sortField, keyField, treeData } = treeState;
|
|
188
|
+
const root = lodash_1.default.concat([], position);
|
|
189
|
+
let nodePath = root.map(i => `[${i}]`).join('.children');
|
|
190
|
+
// if(nodePath)
|
|
191
|
+
let rootPath = nodePath + '.children';
|
|
192
|
+
var tree = lodash_1.default.concat([], treeData);
|
|
193
|
+
let arr = lodash_1.default.get(tree, rootPath);
|
|
194
|
+
if (arr == null)
|
|
195
|
+
arr = [];
|
|
196
|
+
var param = Object.assign(Object.assign({}, data), { [parentField]: node[keyField] });
|
|
197
|
+
if (canSort) {
|
|
198
|
+
let sort = STEP;
|
|
199
|
+
if (arr == null) {
|
|
200
|
+
if (lodash_1.default.isFunction(props.getChildren)) {
|
|
201
|
+
arr = yield props.getChildren(node[keyField]);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
if (arr && arr.length) {
|
|
205
|
+
sort = arr[arr.length - 1][sortField] + STEP;
|
|
206
|
+
}
|
|
207
|
+
param[sortField] = sort;
|
|
208
|
+
}
|
|
209
|
+
const resp = yield utils_1.Ajax.PUT(api, param);
|
|
210
|
+
if (resp.code != '0') {
|
|
211
|
+
antd_1.message.error(txt(Const_1.V.ACT_ADD_FAIL_NAMED, `${objectName} : ${data[titleField]}`));
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
antd_1.message.success(txt(Const_1.V.ACT_ADD_SUCCESS_NAMED, `${objectName} : ${data[titleField]}`));
|
|
215
|
+
arr.push(resp.data);
|
|
216
|
+
props.clearCache(node[keyField]);
|
|
217
|
+
lodash_1.default.set(tree, rootPath, arr);
|
|
218
|
+
setTreeData(tree);
|
|
219
|
+
});
|
|
220
|
+
const add = (data, extra) => __awaiter(void 0, void 0, void 0, function* () {
|
|
221
|
+
const { pos, position } = extra;
|
|
222
|
+
if (position.length <= 0)
|
|
223
|
+
return;
|
|
224
|
+
if (pos == INSER_POS.TOP || pos == INSER_POS.BOTTOM) {
|
|
225
|
+
addRoot(data, extra);
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
let root = lodash_1.default.concat([], position);
|
|
229
|
+
if (pos == INSER_POS.INNER) {
|
|
230
|
+
addInner(data, extra);
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
const { idForApiField } = props;
|
|
234
|
+
const { api, objectName, canSort } = action;
|
|
235
|
+
const { parentField, titleField, sortField, keyField, treeData } = treeState;
|
|
236
|
+
const idField = idForApiField || keyField;
|
|
237
|
+
var tree = lodash_1.default.concat([], treeData);
|
|
238
|
+
let idx = root.pop();
|
|
239
|
+
let nodePath;
|
|
240
|
+
let arr;
|
|
241
|
+
if (root.length == 0) {
|
|
242
|
+
arr = tree;
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
nodePath = root.map(i => `[${i}].children`).join('');
|
|
246
|
+
arr = lodash_1.default.get(tree, nodePath);
|
|
247
|
+
}
|
|
248
|
+
const obj = arr[idx];
|
|
249
|
+
let promises = [];
|
|
250
|
+
let needLoop = false;
|
|
251
|
+
let lastSort = STEP;
|
|
252
|
+
let dataDefault = getDefault();
|
|
253
|
+
if (!canSort) {
|
|
254
|
+
promises.push(utils_1.Ajax.PUT(api, Object.assign(Object.assign(Object.assign({}, dataDefault), data), { [parentField]: obj[parentField] })));
|
|
255
|
+
}
|
|
256
|
+
else if (pos == INSER_POS.BEFORE) {
|
|
257
|
+
try {
|
|
258
|
+
lastSort = parseInt(obj[sortField]);
|
|
259
|
+
}
|
|
260
|
+
catch (_a) {
|
|
261
|
+
}
|
|
262
|
+
if (idx == 0) {
|
|
263
|
+
promises.push(utils_1.Ajax.PUT(api, Object.assign(Object.assign(Object.assign({}, dataDefault), data), { [sortField]: lastSort - STEP, [parentField]: obj[parentField] })));
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
let diff = Math.floor((lastSort - arr[idx - 1][sortField]) / 2);
|
|
267
|
+
if (diff > 0) {
|
|
268
|
+
promises.push(utils_1.Ajax.PUT(api, Object.assign(Object.assign(Object.assign({}, dataDefault), data), { [sortField]: lastSort - diff, [parentField]: obj[parentField] })));
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
promises.push(utils_1.Ajax.PUT(api, Object.assign(Object.assign(Object.assign({}, dataDefault), data), { [sortField]: lastSort - STEP, [parentField]: obj[parentField] })));
|
|
272
|
+
needLoop = true;
|
|
273
|
+
lastSort = lastSort - STEP;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
if (needLoop) {
|
|
277
|
+
for (let i = idx - 1; i >= 0; i--) {
|
|
278
|
+
let item = arr[i];
|
|
279
|
+
lastSort = lastSort - STEP;
|
|
280
|
+
promises.push(utils_1.Ajax.PATCH(api, {
|
|
281
|
+
[idField]: item[idField],
|
|
282
|
+
[sortField]: lastSort,
|
|
283
|
+
}));
|
|
284
|
+
arr = utils_1.ArrayUtil.update(arr, Object.assign(Object.assign({}, item), { [sortField]: lastSort }), keyField);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
else {
|
|
289
|
+
try {
|
|
290
|
+
lastSort = parseInt(obj[sortField]);
|
|
291
|
+
}
|
|
292
|
+
catch (_b) {
|
|
293
|
+
}
|
|
294
|
+
let len = arr.length;
|
|
295
|
+
if (idx == len - 1) {
|
|
296
|
+
promises.push(utils_1.Ajax.PUT(api, Object.assign(Object.assign(Object.assign({}, dataDefault), data), { [sortField]: lastSort + STEP, [parentField]: obj[parentField] })));
|
|
297
|
+
}
|
|
298
|
+
else {
|
|
299
|
+
let diff = Math.floor((arr[idx + 1][sortField] - lastSort) / 2);
|
|
300
|
+
if (diff > 0) {
|
|
301
|
+
promises.push(utils_1.Ajax.PUT(api, Object.assign(Object.assign(Object.assign({}, dataDefault), data), { [sortField]: lastSort + diff, [parentField]: obj[parentField] })));
|
|
302
|
+
}
|
|
303
|
+
else {
|
|
304
|
+
promises.push(utils_1.Ajax.PUT(api, Object.assign(Object.assign(Object.assign({}, dataDefault), data), { [sortField]: lastSort + STEP, [parentField]: obj[parentField] })));
|
|
305
|
+
needLoop = true;
|
|
306
|
+
lastSort = lastSort + STEP;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
if (needLoop) {
|
|
310
|
+
for (let i = idx + 1; i < len; i++) {
|
|
311
|
+
let item = arr[i];
|
|
312
|
+
lastSort = lastSort + STEP;
|
|
313
|
+
promises.push(utils_1.Ajax.PATCH(api, {
|
|
314
|
+
[keyField]: item[keyField],
|
|
315
|
+
[sortField]: lastSort,
|
|
316
|
+
}));
|
|
317
|
+
arr = utils_1.ArrayUtil.update(arr, Object.assign(Object.assign({}, item), { [sortField]: lastSort }), keyField);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
const resps = yield utils_1.Ajax.WHEN(...promises);
|
|
322
|
+
let resp = resps[0];
|
|
323
|
+
if (resp.code != '0') {
|
|
324
|
+
antd_1.message.error(txt(Const_1.V.ACT_ADD_FAIL_NAMED, `${objectName} : ${data[titleField]}`));
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
antd_1.message.success(txt(Const_1.V.ACT_ADD_SUCCESS_NAMED, `${objectName} : ${data[titleField]}`));
|
|
328
|
+
arr = utils_1.ArrayUtil.add(arr, resp.data);
|
|
329
|
+
if (canSort) {
|
|
330
|
+
arr = lodash_1.default.orderBy(arr, sortField, 'asc');
|
|
331
|
+
}
|
|
332
|
+
if (nodePath) {
|
|
333
|
+
lodash_1.default.set(tree, nodePath, arr);
|
|
334
|
+
}
|
|
335
|
+
else {
|
|
336
|
+
tree = arr;
|
|
337
|
+
}
|
|
338
|
+
props.clearCache(obj[keyField]);
|
|
339
|
+
setTreeData(tree);
|
|
340
|
+
});
|
|
341
|
+
const updateData = (0, react_1.useCallback)((data, position) => {
|
|
342
|
+
if (position.length == 0)
|
|
343
|
+
return;
|
|
344
|
+
const { parentField, treeData } = treeState;
|
|
345
|
+
const root = lodash_1.default.concat([], position);
|
|
346
|
+
let tree = lodash_1.default.concat([], treeData);
|
|
347
|
+
let idx = root.pop();
|
|
348
|
+
let rootPath = '';
|
|
349
|
+
if (root.length > 0) {
|
|
350
|
+
let nodePath = root.map(i => `[${i}]`).join('.children');
|
|
351
|
+
rootPath = nodePath + '.children';
|
|
352
|
+
}
|
|
353
|
+
let node = lodash_1.default.get(tree, `${rootPath}[${idx}]`);
|
|
354
|
+
props.clearCache(lodash_1.default.get(node, parentField));
|
|
355
|
+
lodash_1.default.set(tree, rootPath + `[${idx}]`, data);
|
|
356
|
+
setTreeData(tree);
|
|
357
|
+
}, [treeState.treeData]);
|
|
358
|
+
const update = (0, react_1.useCallback)((data, position) => __awaiter(void 0, void 0, void 0, function* () {
|
|
359
|
+
if (position.length == 0)
|
|
360
|
+
return;
|
|
361
|
+
const { api, objectName } = action;
|
|
362
|
+
const { parentField, titleField, treeData } = treeState;
|
|
363
|
+
const resp = yield utils_1.Ajax.PATCH(api, data);
|
|
364
|
+
if (resp.code != '0') {
|
|
365
|
+
antd_1.message.error(txt(Const_1.V.ACT_UPDATE_FAIL_NAMED, `${objectName} : ${data[titleField]}`));
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
const root = lodash_1.default.concat([], position);
|
|
369
|
+
let tree = lodash_1.default.concat([], treeData);
|
|
370
|
+
let idx = root.pop();
|
|
371
|
+
let rootPath = '';
|
|
372
|
+
if (root.length > 0) {
|
|
373
|
+
let nodePath = root.map(i => `[${i}]`).join('.children');
|
|
374
|
+
rootPath = nodePath + '.children';
|
|
375
|
+
}
|
|
376
|
+
antd_1.message.success(txt(Const_1.V.ACT_UPDATE_SUCCESS_NAMED, `${objectName} : ${data[titleField]}`));
|
|
377
|
+
let node = lodash_1.default.get(tree, `${rootPath}[${idx}]`);
|
|
378
|
+
if (node) {
|
|
379
|
+
props.clearCache(lodash_1.default.get(node, parentField));
|
|
380
|
+
// if (node && node.children) {
|
|
381
|
+
// _.set(tree, rootPath + `[${idx}]`, { ...data, children: node.children });
|
|
382
|
+
// } else {
|
|
383
|
+
lodash_1.default.set(tree, rootPath + `[${idx}]`, data);
|
|
384
|
+
// }
|
|
385
|
+
setTreeData(tree);
|
|
386
|
+
}
|
|
387
|
+
}), [treeState.treeData]);
|
|
388
|
+
const del = (0, react_1.useCallback)((node, position) => __awaiter(void 0, void 0, void 0, function* () {
|
|
389
|
+
if (position.length <= 0)
|
|
390
|
+
return;
|
|
391
|
+
const root = lodash_1.default.concat([], position);
|
|
392
|
+
root.pop();
|
|
393
|
+
let rootPath = '';
|
|
394
|
+
let arr;
|
|
395
|
+
const { idForApiField } = props;
|
|
396
|
+
const { keyField, parentField, titleField, treeData } = treeState;
|
|
397
|
+
const { api, objectName } = action;
|
|
398
|
+
const idField = idForApiField || keyField;
|
|
399
|
+
if (root.length == 0) {
|
|
400
|
+
arr = lodash_1.default.concat([], treeData);
|
|
401
|
+
}
|
|
402
|
+
else {
|
|
403
|
+
let nodePath = root.map(i => `[${i}]`).join('.children');
|
|
404
|
+
rootPath = nodePath + '.children';
|
|
405
|
+
arr = lodash_1.default.concat([], lodash_1.default.get(treeData, rootPath));
|
|
406
|
+
}
|
|
407
|
+
const delId = node[idField];
|
|
408
|
+
const resp = yield utils_1.Ajax.DELETE(api, { ids: delId });
|
|
409
|
+
if (resp.code != '0') {
|
|
410
|
+
antd_1.message.error(txt(Const_1.V.ACT_DELETE_FAIL_NAMED, `${objectName} : ${node[titleField]}`));
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
props.clearCache(node[parentField]);
|
|
414
|
+
let tree = lodash_1.default.concat([], treeData);
|
|
415
|
+
if (rootPath) {
|
|
416
|
+
lodash_1.default.set(tree, rootPath, utils_1.ArrayUtil.del(lodash_1.default.get(tree, rootPath), delId, keyField));
|
|
417
|
+
}
|
|
418
|
+
else {
|
|
419
|
+
tree = utils_1.ArrayUtil.del(tree, delId, keyField);
|
|
420
|
+
}
|
|
421
|
+
setTreeData(tree);
|
|
422
|
+
antd_1.message.success(txt(Const_1.V.ACT_DELETE_SUCCESS_NAMED, `${objectName} : ${node[titleField]}`));
|
|
423
|
+
}), [treeState]);
|
|
424
|
+
const up = (node, position) => __awaiter(void 0, void 0, void 0, function* () {
|
|
425
|
+
if (position.length <= 0)
|
|
426
|
+
return;
|
|
427
|
+
let root = lodash_1.default.concat([], position);
|
|
428
|
+
const { parentField, keyField, sortField, treeData } = treeState;
|
|
429
|
+
const { api, idForApiField } = props;
|
|
430
|
+
const idField = idForApiField || keyField;
|
|
431
|
+
let idx = root.pop();
|
|
432
|
+
if (idx <= 0)
|
|
433
|
+
return;
|
|
434
|
+
let rootPath = '';
|
|
435
|
+
let arr;
|
|
436
|
+
if (root.length == 0) {
|
|
437
|
+
arr = lodash_1.default.concat([], treeData);
|
|
438
|
+
}
|
|
439
|
+
else {
|
|
440
|
+
let nodePath = root.map(i => `[${i}]`).join('.children');
|
|
441
|
+
rootPath = nodePath + '.children';
|
|
442
|
+
arr = lodash_1.default.concat([], lodash_1.default.get(treeData, rootPath));
|
|
443
|
+
}
|
|
444
|
+
var current = arr[idx][sortField];
|
|
445
|
+
var swap = arr[idx - 1][sortField];
|
|
446
|
+
arr[idx][sortField] = swap;
|
|
447
|
+
arr[idx - 1][sortField] = current;
|
|
448
|
+
let tree = lodash_1.default.concat([], treeData);
|
|
449
|
+
const resp = yield utils_1.Ajax.WHEN(utils_1.Ajax.PATCH(api, { [idField]: arr[idx][idField], [sortField]: swap }), utils_1.Ajax.PATCH(api, { [idField]: arr[idx - 1][idField], [sortField]: current }));
|
|
450
|
+
if (resp[0].code != '0' || resp[1].code != '0') {
|
|
451
|
+
antd_1.message.error(txt(Const_1.V.TREE_SORT_FAIL));
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
props.clearCache(node[parentField]);
|
|
455
|
+
if (rootPath) {
|
|
456
|
+
lodash_1.default.set(tree, rootPath, lodash_1.default.orderBy(arr, sortField, 'asc'));
|
|
457
|
+
}
|
|
458
|
+
else {
|
|
459
|
+
tree = lodash_1.default.orderBy(tree, sortField, 'asc');
|
|
460
|
+
}
|
|
461
|
+
setTreeData(tree);
|
|
462
|
+
antd_1.message.success(txt(Const_1.V.TREE_SORT_SUCCESS));
|
|
463
|
+
});
|
|
464
|
+
const down = (node, position) => __awaiter(void 0, void 0, void 0, function* () {
|
|
465
|
+
if (position.length <= 0)
|
|
466
|
+
return;
|
|
467
|
+
const { parentField, keyField, sortField, treeData } = treeState;
|
|
468
|
+
const { api, idForApiField } = props;
|
|
469
|
+
const idField = idForApiField || keyField;
|
|
470
|
+
let root = lodash_1.default.concat([], position);
|
|
471
|
+
let idx = root.pop();
|
|
472
|
+
let rootPath = '';
|
|
473
|
+
let arr;
|
|
474
|
+
if (root.length == 0) {
|
|
475
|
+
arr = lodash_1.default.concat([], treeData);
|
|
476
|
+
}
|
|
477
|
+
else {
|
|
478
|
+
let nodePath = root.map(i => `[${i}]`).join('.children');
|
|
479
|
+
rootPath = nodePath + '.children';
|
|
480
|
+
arr = lodash_1.default.concat([], lodash_1.default.get(treeData, rootPath));
|
|
481
|
+
}
|
|
482
|
+
if (idx >= arr.length - 1)
|
|
483
|
+
return;
|
|
484
|
+
var current = arr[idx][sortField];
|
|
485
|
+
var swap = arr[idx + 1][sortField];
|
|
486
|
+
arr[idx][sortField] = swap;
|
|
487
|
+
arr[idx + 1][sortField] = current;
|
|
488
|
+
let tree = lodash_1.default.concat([], treeData);
|
|
489
|
+
const resp = yield utils_1.Ajax.WHEN(utils_1.Ajax.PATCH(api, { [idField]: arr[idx][idField], [sortField]: swap }), utils_1.Ajax.PATCH(api, { [idField]: arr[idx + 1][idField], [sortField]: current }));
|
|
490
|
+
if (resp[0].code != '0' || resp[1].code != '0') {
|
|
491
|
+
antd_1.message.error(txt(Const_1.V.TREE_SORT_FAIL));
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
494
|
+
props.clearCache(node[parentField]);
|
|
495
|
+
if (rootPath) {
|
|
496
|
+
lodash_1.default.set(tree, rootPath, lodash_1.default.orderBy(arr, sortField, 'asc'));
|
|
497
|
+
}
|
|
498
|
+
else {
|
|
499
|
+
tree = lodash_1.default.orderBy(tree, sortField, 'asc');
|
|
500
|
+
}
|
|
501
|
+
setTreeData(tree);
|
|
502
|
+
antd_1.message.success(txt(Const_1.V.TREE_SORT_SUCCESS));
|
|
503
|
+
});
|
|
504
|
+
return react_1.default.createElement(ActionTreeContext.Provider, { value: {
|
|
505
|
+
action,
|
|
506
|
+
showAdd, showEdit, del, up, down,
|
|
507
|
+
} },
|
|
508
|
+
props.children,
|
|
509
|
+
react_1.default.createElement(UFormModal_1.UFormModal, Object.assign({ autoTitle: { field: treeState.titleField, label: action.objectName } }, modals.modalState.modalProps, { fields: FIELDS.current, default: getDefault(), onOk: data => {
|
|
510
|
+
modals.hide();
|
|
511
|
+
if (modals.modalState.isEdit) {
|
|
512
|
+
update(data, modals.modalState.extra.position);
|
|
513
|
+
}
|
|
514
|
+
else {
|
|
515
|
+
add(data, modals.modalState.extra);
|
|
516
|
+
}
|
|
517
|
+
}, onCancel: modals.hide })));
|
|
518
|
+
});
|
|
519
|
+
/**
|
|
520
|
+
* ActionTree 可让一个树具备CRUD的能力
|
|
521
|
+
*/
|
|
522
|
+
exports.ActionTree = (0, react_1.forwardRef)((props, ref) => react_1.default.createElement(BaseTree_1.BaseTree, Object.assign({}, props),
|
|
523
|
+
react_1.default.createElement(_Actiontree, Object.assign({}, props, { ref: ref }))));
|
|
524
|
+
const getActionParam = (node, position, state, search, disabledNode, context, parentLen) => {
|
|
525
|
+
const param = (0, BaseTree_1.getNodeParam)(node, position, state, search, disabledNode);
|
|
526
|
+
const isRoot = position.length == 1;
|
|
527
|
+
if (param.disabled)
|
|
528
|
+
return param;
|
|
529
|
+
const { action: { canAdd, canAddRoot, canUpdate, canUpdateRoot, canDelete, canSort } } = context;
|
|
530
|
+
const actions = [];
|
|
531
|
+
if (canAdd) {
|
|
532
|
+
if (!canSort || !canAddRoot && isRoot) {
|
|
533
|
+
actions.push(react_1.default.createElement(Dropdown_1.Dropdown, { trigger: ["click"], menu: {
|
|
534
|
+
items: [
|
|
535
|
+
{ label: txt(Const_1.V.TREE_INSERT_INNER), onClick: (evt) => utils_1.PageUtil.stopEvent(evt.domEvent, () => context.showAdd(INSER_POS.INNER, node, position)), key: 'addInner' },
|
|
536
|
+
]
|
|
537
|
+
} },
|
|
538
|
+
react_1.default.createElement("span", { onClick: (e) => utils_1.PageUtil.stopEvent(e), className: "vicon vicon-plus vicon-clickable", title: txt(Const_1.V.ACT_ADD) + ' ' + txt(Const_1.V.TREE_NODE) })));
|
|
539
|
+
}
|
|
540
|
+
else {
|
|
541
|
+
actions.push(react_1.default.createElement(Dropdown_1.Dropdown, { trigger: ["click"], menu: {
|
|
542
|
+
items: [
|
|
543
|
+
{ label: txt(Const_1.V.TREE_INSERT_INNER), onClick: (evt) => utils_1.PageUtil.stopEvent(evt.domEvent, () => context.showAdd(INSER_POS.INNER, node, position)), key: 'addInner' },
|
|
544
|
+
{ label: txt(Const_1.V.TREE_INSERT_BEFORE), onClick: (evt) => utils_1.PageUtil.stopEvent(evt.domEvent, () => context.showAdd(INSER_POS.BEFORE, node, position)), key: 'addBefore' },
|
|
545
|
+
{ label: txt(Const_1.V.TREE_INSERT_AFTER), onClick: (evt) => utils_1.PageUtil.stopEvent(evt.domEvent, () => context.showAdd(INSER_POS.AFTER, node, position)), key: 'addAfter' },
|
|
546
|
+
]
|
|
547
|
+
} },
|
|
548
|
+
react_1.default.createElement("span", { onClick: (e) => utils_1.PageUtil.stopEvent(e), className: "vicon vicon-plus vicon-clickable", title: txt(Const_1.V.ACT_ADD) + ' ' + txt(Const_1.V.TREE_NODE) })));
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
if (canUpdateRoot || (canUpdate && !isRoot)) {
|
|
552
|
+
actions.push(react_1.default.createElement(Icon_1.Icon, { type: "edit", title: txt(Const_1.V.ACT_UPDATE_TITLE_NAMED, node[state.titleField]), onClick: () => context.showEdit(node, position) }));
|
|
553
|
+
}
|
|
554
|
+
if (canSort) {
|
|
555
|
+
let idx = position[position.length - 1];
|
|
556
|
+
if (idx > 0) {
|
|
557
|
+
actions.push(react_1.default.createElement(Icon_1.Icon, { type: "arrow-up", title: txt(Const_1.V.ACT_UPDATE_TITLE_NAMED, node[state.titleField]), onClick: () => context.up(node, position) }));
|
|
558
|
+
}
|
|
559
|
+
if (idx < (parentLen - 1)) {
|
|
560
|
+
actions.push(react_1.default.createElement(Icon_1.Icon, { type: "arrow-down", title: txt(Const_1.V.ACT_UPDATE_TITLE_NAMED, node[state.titleField]), onClick: () => context.down(node, position) }));
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
if (!isRoot && canDelete) {
|
|
564
|
+
actions.push(react_1.default.createElement(Popconfirm_1.Popconfirm, { onConfirm: () => context.del(node, position), title: txt(Const_1.V.ACT_DELETE_CONFIRM, node[state.titleField]) },
|
|
565
|
+
react_1.default.createElement("span", { onClick: (e) => utils_1.PageUtil.stopEvent(e), className: "vicon vicon-delete vicon-clickable", title: txt(Const_1.V.ACT_DELETE) + ' ' + node[state.titleField] })));
|
|
566
|
+
}
|
|
567
|
+
if (actions.length) {
|
|
568
|
+
param.title = [param.title, react_1.default.createElement("div", { className: 'c-tree-actions' },
|
|
569
|
+
" ",
|
|
570
|
+
actions,
|
|
571
|
+
" ")];
|
|
572
|
+
}
|
|
573
|
+
return param;
|
|
574
|
+
};
|
|
575
|
+
const renderNode = (props, node, position, state, search, context, parentLen) => {
|
|
576
|
+
if (search.keyword && !search.match.has(position.join('-')))
|
|
577
|
+
return utils_1.Const.NONE;
|
|
578
|
+
const param = getActionParam(node, position, state, search, props.disabledNode, context, parentLen);
|
|
579
|
+
if (lodash_1.default.isArray(node.children) && node.children.length) {
|
|
580
|
+
return react_1.default.createElement(antd_1.Tree.TreeNode, Object.assign({ isLeaf: false }, param), renderNodes(props, state, node.children, position, search, context));
|
|
581
|
+
}
|
|
582
|
+
// @ts-ignore
|
|
583
|
+
let checkField = props.checkField;
|
|
584
|
+
if (lodash_1.default.isString(checkField)) {
|
|
585
|
+
if (!node[checkField]) {
|
|
586
|
+
param.isLeaf = true;
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
return react_1.default.createElement(antd_1.Tree.TreeNode, Object.assign({}, param));
|
|
590
|
+
};
|
|
591
|
+
const renderNodes = (props, state, data, position, search, context) => data.map((item, idx) => renderNode(props, item, [...position, idx], state, search, context, data.length));
|
|
592
|
+
const renderRoot = (props, state, context) => {
|
|
593
|
+
const { search, treeData } = state;
|
|
594
|
+
if (search.keyword) {
|
|
595
|
+
if (search.match.size == 0)
|
|
596
|
+
return react_1.default.createElement(antd_1.Tree.TreeNode, { isLeaf: true, title: react_1.default.createElement(antd_1.Empty, { description: txt(Const_1.V.TXT_FIND_NULL, search.word) }), selectable: false, className: "c-tree-empty" });
|
|
597
|
+
return renderNodes(props, state, treeData, [], search, context);
|
|
598
|
+
}
|
|
599
|
+
const { action: { canAddRoot, canAdd, canSort, objectName } } = context;
|
|
600
|
+
if (canAddRoot) {
|
|
601
|
+
return react_1.default.createElement(react_1.Fragment, null,
|
|
602
|
+
react_1.default.createElement(antd_1.Tree.TreeNode, { isLeaf: true, className: 'c-tree-add-root', selectable: false, checkable: false, selected: false, title: react_1.default.createElement("a", { onClick: evt => {
|
|
603
|
+
utils_1.PageUtil.stopEvent(evt);
|
|
604
|
+
context.showAdd(INSER_POS.TOP, null, [0]);
|
|
605
|
+
} },
|
|
606
|
+
react_1.default.createElement(Icon_1.Icon, { type: 'plus' }),
|
|
607
|
+
canSort ? txt(Const_1.V.TREE_INSERT_TOP, objectName) : `${txt(Const_1.V.ACT_ADD)} ${objectName}`) }),
|
|
608
|
+
renderNodes(props, state, treeData, [], search, context),
|
|
609
|
+
canSort && treeData.length > 0 && react_1.default.createElement(antd_1.Tree.TreeNode, { isLeaf: true, className: 'c-tree-add-root', selectable: false, selected: false, checkable: false, expanded: true, title: react_1.default.createElement("a", { onClick: evt => {
|
|
610
|
+
utils_1.PageUtil.stopEvent(evt);
|
|
611
|
+
context.showAdd(INSER_POS.BOTTOM, null, [0]);
|
|
612
|
+
} },
|
|
613
|
+
react_1.default.createElement(Icon_1.Icon, { type: 'plus' }),
|
|
614
|
+
canSort ? txt(Const_1.V.TREE_INSERT_BOTTOM, objectName) : `${txt(Const_1.V.ACT_ADD)} ${objectName}`) }));
|
|
615
|
+
}
|
|
616
|
+
else if (canAdd && treeData.length == 1) {
|
|
617
|
+
// 说明 兼容树业务:有些项目技术上使用一个根节点,
|
|
618
|
+
// 当根节点只有一个时,则在业务上认为此节点为固定根节点
|
|
619
|
+
const param = getActionParam(treeData[0], [0], state, search, props.disabledNode, context, 1);
|
|
620
|
+
const childs = (treeData[0].children || []);
|
|
621
|
+
return react_1.default.createElement(antd_1.Tree.TreeNode, Object.assign({}, param),
|
|
622
|
+
react_1.default.createElement(antd_1.Tree.TreeNode, { isLeaf: true, className: 'c-tree-add-root', selectable: false, checkable: false, selected: false, title: react_1.default.createElement("a", { onClick: evt => {
|
|
623
|
+
utils_1.PageUtil.stopEvent(evt);
|
|
624
|
+
context.showAdd(INSER_POS.TOP, null, [0, 0]);
|
|
625
|
+
} },
|
|
626
|
+
react_1.default.createElement(Icon_1.Icon, { type: 'plus' }),
|
|
627
|
+
" ",
|
|
628
|
+
(canSort && childs.length > 0) ? txt(Const_1.V.TREE_INSERT_TOP, objectName) : `${txt(Const_1.V.ACT_ADD)} ${objectName}`) }),
|
|
629
|
+
renderNodes(props, state, childs, [0], search, context),
|
|
630
|
+
canSort && childs.length > 0 && react_1.default.createElement(antd_1.Tree.TreeNode, { isLeaf: true, className: 'c-tree-add-root', selectable: false, selected: false, checkable: false, expanded: true, title: react_1.default.createElement("a", { onClick: evt => {
|
|
631
|
+
utils_1.PageUtil.stopEvent(evt);
|
|
632
|
+
context.showAdd(INSER_POS.BOTTOM, null, [0, childs.length - 1]);
|
|
633
|
+
} }, canSort ? txt(Const_1.V.TREE_INSERT_BOTTOM, objectName) : `${txt(Const_1.V.ACT_ADD)} ${objectName}`) }));
|
|
634
|
+
}
|
|
635
|
+
return renderNodes(props, state, treeData, [], search, context);
|
|
636
|
+
};
|
|
637
|
+
exports.renderRoot = renderRoot;
|
|
638
|
+
const getResponseList = (resp, sortField) => {
|
|
639
|
+
let data;
|
|
640
|
+
if (lodash_1.default.has(resp, 'data')) {
|
|
641
|
+
data = resp.data;
|
|
642
|
+
}
|
|
643
|
+
else if (lodash_1.default.has(resp, 'list')) {
|
|
644
|
+
data = resp.list;
|
|
645
|
+
}
|
|
646
|
+
else {
|
|
647
|
+
data = [];
|
|
648
|
+
}
|
|
649
|
+
if (lodash_1.default.isArray(data)) {
|
|
650
|
+
if (sortField) {
|
|
651
|
+
return lodash_1.default.orderBy(data, sortField, 'asc');
|
|
652
|
+
}
|
|
653
|
+
return data;
|
|
654
|
+
}
|
|
655
|
+
return [data];
|
|
656
|
+
};
|
|
657
|
+
exports.getResponseList = getResponseList;
|