@utogether/udp-core 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.ts +90 -0
- package/build/plugins.ts +26 -0
- package/dist/403-B1R-4vXw.js +64 -0
- package/dist/404-fXPl8csw.js +64 -0
- package/dist/500-eI5842YB.js +66 -0
- package/dist/AuthorityInfo-CfVH6PaB.js +4 -0
- package/dist/AuthorityInfo.vue_vue_type_style_index_0_lang-DbK-f8jH.js +102 -0
- package/dist/AuthorityPanel-BaLMwMgW.js +4 -0
- package/dist/AuthorityPanel.vue_vue_type_style_index_0_lang-C_bkqLD9.js +107 -0
- package/dist/Company-CYC9Avfz.js +25 -0
- package/dist/CompanyPanel-B4MzoqN_.js +206 -0
- package/dist/DataSet-DT-rGICv.js +147 -0
- package/dist/Department-B4BNSiYx.js +25 -0
- package/dist/DepartmentPanel-zJO89L2O.js +224 -0
- package/dist/DesignPanel-S8P0J97f.js +4 -0
- package/dist/DesignPanel.vue_vue_type_style_index_0_lang-DW-_Vqrr.js +1015 -0
- package/dist/DictView-bIS5-rK-.js +95 -0
- package/dist/InvOrganization-MuM2jtsG.js +66 -0
- package/dist/Org-kXHSjsgJ.js +35 -0
- package/dist/Preview-CRyiwUIR.js +48 -0
- package/dist/ReportDefine-WZYIx8Sm.js +10 -0
- package/dist/ReportDesign-D-7GKgpb.js +165 -0
- package/dist/ReportQuery-BIIJny6w.js +75 -0
- package/dist/ReportQueryFrom-OoUl7N2O.js +4 -0
- package/dist/ReportQueryFrom.vue_vue_type_style_index_0_lang-B878fgj8.js +177 -0
- package/dist/ReportTemplate-Cfeq9US-.js +161 -0
- package/dist/Role-BwTV2QMH.js +25 -0
- package/dist/RoleAssign-De1JjOun.js +26 -0
- package/dist/RolePanel-E3RcdByM.js +4 -0
- package/dist/RolePanel-pUBXsqCM.js +4 -0
- package/dist/RolePanel.vue_vue_type_script_setup_true_lang-B2pQwHb0.js +148 -0
- package/dist/RolePanel.vue_vue_type_script_setup_true_lang-CTIad9_Q.js +126 -0
- package/dist/ScrollPanel.vue_vue_type_style_index_0_lang-vMR1fBi0.js +100 -0
- package/dist/Staff-Czm7A8vI.js +25 -0
- package/dist/StaffInfo-DJzvBuxy.js +4 -0
- package/dist/StaffInfo.vue_vue_type_style_index_0_lang-DMTL7KCh.js +108 -0
- package/dist/StaffPanel-CHk60LEz.js +4 -0
- package/dist/StaffPanel.vue_vue_type_script_setup_true_lang-iPKLb5wG.js +114 -0
- package/dist/SysUser-BGwbttRn.js +15 -0
- package/dist/SysUserPanel-BCbKoLKt.js +4 -0
- package/dist/SysUserPanel.vue_vue_type_script_setup_true_lang-0QUjnhjF.js +289 -0
- package/dist/SystemMenu-BkqZSDKl.js +151 -0
- package/dist/UserInfo-BsyAcT2d.js +4 -0
- package/dist/UserInfo.vue_vue_type_style_index_0_lang-D0-KDxAh.js +158 -0
- package/dist/await-to-js.es5-BtRbN2QH.js +10 -0
- package/dist/childView-CF83nhxb.js +4 -0
- package/dist/childView-CyuLTUqC.js +4 -0
- package/dist/childView.vue_vue_type_style_index_0_lang-CNSgGda3.js +187 -0
- package/dist/childView.vue_vue_type_style_index_0_lang-Cch4lE-i.js +144 -0
- package/dist/code-rule-Bz-gnktN.js +147 -0
- package/dist/core.es.js +13 -0
- package/dist/core.umd.js +173 -0
- package/dist/cron-task-CIifSUdW.js +135 -0
- package/dist/frameView-_d2mqjjQ.js +43 -0
- package/dist/img/l_img.svg +1 -0
- package/dist/img/minicolors.png +0 -0
- package/dist/img/v_img.svg +1 -0
- package/dist/index-BKIw8tSn.js +9195 -0
- package/dist/layoutView-DLKVepB8.js +3317 -0
- package/dist/log-in-e7D5Ss1P.js +110 -0
- package/dist/log-out--RRncZhN.js +120 -0
- package/dist/login-LREiDfFU.js +251 -0
- package/dist/login-log-CvVnyGi3.js +68 -0
- package/dist/lov-view-DDrIVILB.js +97 -0
- package/dist/menuInfo-B1FUV-Sk.js +4 -0
- package/dist/menuInfo.vue_vue_type_style_index_0_lang-Cnk3vdtD.js +338 -0
- package/dist/pda-app-CRhVGijN.js +2209 -0
- package/dist/redirect-DiaNDu8F.js +15 -0
- package/dist/resource-BCwx9fEv.js +97 -0
- package/dist/su-welcome-189A7N4r.js +526 -0
- package/dist/sys-config-BZ3sejow.js +277 -0
- package/dist/udp-core.css +9 -0
- package/dist/utogether-r08LNiIZ.js +182 -0
- package/index.ts +36 -0
- package/package.json +16 -0
- package/public/img/l_img.svg +1 -0
- package/public/img/minicolors.png +0 -0
- package/public/img/v_img.svg +1 -0
- package/src/App.vue +70 -0
- package/src/api/http.ts +50 -0
- package/src/api/index.ts +31 -0
- package/src/api/mock.ts +20 -0
- package/src/api/user.ts +43 -0
- package/src/assets/images/avatars.jpg +0 -0
- package/src/assets/images/empty.png +0 -0
- package/src/assets/images/login.png +0 -0
- package/src/assets/images/logo.png +0 -0
- package/src/assets/images/mask-text.jpg +0 -0
- package/src/assets/images/minicolors.png +0 -0
- package/src/assets/images/utogether.png +0 -0
- package/src/assets/images/welcome.png +0 -0
- package/src/assets/status/403.svg +1 -0
- package/src/assets/status/404.svg +1 -0
- package/src/assets/status/500.svg +1 -0
- package/src/assets/svg/back_top.svg +1 -0
- package/src/assets/svg/bg.svg +1 -0
- package/src/assets/svg/close.svg +1 -0
- package/src/assets/svg/close_all.svg +1 -0
- package/src/assets/svg/close_left.svg +1 -0
- package/src/assets/svg/close_other.svg +1 -0
- package/src/assets/svg/close_right.svg +1 -0
- package/src/assets/svg/dark.svg +1 -0
- package/src/assets/svg/day.svg +1 -0
- package/src/assets/svg/enter_outlined.svg +1 -0
- package/src/assets/svg/exit_screen.svg +1 -0
- package/src/assets/svg/full_screen.svg +1 -0
- package/src/assets/svg/globalization.svg +1 -0
- package/src/assets/svg/loading.svg +17 -0
- package/src/assets/svg/mdi_keyboard_esc.svg +1 -0
- package/src/assets/svg/refresh.svg +1 -0
- package/src/assets/svg/system.svg +1 -0
- package/src/components/ReCountTo/README.md +2 -0
- package/src/components/ReCountTo/index.ts +18 -0
- package/src/components/ReCountTo/src/normal/index.tsx +165 -0
- package/src/components/ReCountTo/src/normal/props.ts +37 -0
- package/src/components/ReCountTo/src/rebound/index.tsx +67 -0
- package/src/components/ReCountTo/src/rebound/props.ts +14 -0
- package/src/components/ReCountTo/src/rebound/rebound.css +77 -0
- package/src/components/ReCropper/index.ts +14 -0
- package/src/components/ReCropper/src/index.tsx +141 -0
- package/src/components/ReFlicker/index.css +39 -0
- package/src/components/ReFlicker/index.ts +50 -0
- package/src/components/ReFlop/index.ts +14 -0
- package/src/components/ReFlop/src/Filpper.tsx +99 -0
- package/src/components/ReFlop/src/filpper.css +184 -0
- package/src/components/ReFlop/src/index.vue +126 -0
- package/src/components/ReFlowChart/index.ts +24 -0
- package/src/components/ReFlowChart/src/Control.vue +139 -0
- package/src/components/ReFlowChart/src/DataDialog.vue +12 -0
- package/src/components/ReFlowChart/src/NodePanel.vue +151 -0
- package/src/components/ReFlowChart/src/adpterForTurbo.ts +160 -0
- package/src/components/ReFlowChart/src/assets/iconfont/iconfont.css +49 -0
- package/src/components/ReFlowChart/src/assets/iconfont/iconfont.eot +0 -0
- package/src/components/ReFlowChart/src/assets/iconfont/iconfont.js +61 -0
- package/src/components/ReFlowChart/src/assets/iconfont/iconfont.json +58 -0
- package/src/components/ReFlowChart/src/assets/iconfont/iconfont.svg +47 -0
- package/src/components/ReFlowChart/src/assets/iconfont/iconfont.ttf +0 -0
- package/src/components/ReFlowChart/src/assets/iconfont/iconfont.woff +0 -0
- package/src/components/ReFlowChart/src/assets/iconfont/iconfont.woff2 +0 -0
- package/src/components/ReFlowChart/src/config.ts +62 -0
- package/src/components/ReIcon/index.ts +12 -0
- package/src/components/ReIcon/src/Icon.vue +81 -0
- package/src/components/ReIcon/src/hooks.ts +63 -0
- package/src/components/ReIcon/src/iconfont.ts +45 -0
- package/src/components/ReIcon/src/iconifyIconOffline.ts +36 -0
- package/src/components/ReIcon/src/iconifyIconOnline.ts +28 -0
- package/src/components/ReIcon/src/offlineIcon.ts +64 -0
- package/src/components/ReIcon/src/types.ts +20 -0
- package/src/components/ReSplitPane/index.css +49 -0
- package/src/components/ReSplitPane/index.tsx +119 -0
- package/src/components/ReSplitPane/resizer.css +45 -0
- package/src/components/ReSplitPane/resizer.tsx +30 -0
- package/src/components/SuCharts/index.ts +36 -0
- package/src/components/SuCharts/src/EchartBar.vue +134 -0
- package/src/components/SuCharts/src/UserInfo.vue +78 -0
- package/src/components/SuCharts/src/echart-line.vue +85 -0
- package/src/components/SuCharts/src/echart-pie.vue +95 -0
- package/src/components/SuCommon/card/components/Card.vue +148 -0
- package/src/components/SuCommon/card/components/DialogForm.vue +127 -0
- package/src/components/SuCommon/card/index.vue +142 -0
- package/src/components/SuCommon/icon-select/index.vue +241 -0
- package/src/components/SuCommon/table/index.vue +208 -0
- package/src/components/SuCommon/utils/index.ts +103 -0
- package/src/components/SuCommon/utils/slot.tsx +50 -0
- package/src/components/SuFloatButton/index.vue +159 -0
- package/src/components/SuQrcode/index.ts +14 -0
- package/src/components/SuQrcode/src/index.scss +9 -0
- package/src/components/SuQrcode/src/index.tsx +236 -0
- package/src/components/SuScrollTree/ScrollPanel.vue +175 -0
- package/src/components/SuTable/SuTable.vue +334 -0
- package/src/components/SuTypeit/index.ts +51 -0
- package/src/config/index.ts +35 -0
- package/src/contant/index.ts +20 -0
- package/src/directives/elResizeDetector/index.ts +33 -0
- package/src/directives/index.ts +11 -0
- package/src/directives/permission/index.ts +29 -0
- package/src/layout/components/lay-chrome/index.vue +30 -0
- package/src/layout/components/lay-content/index.vue +143 -0
- package/src/layout/components/lay-navbar/index.vue +237 -0
- package/src/layout/components/lay-notice/data.ts +59 -0
- package/src/layout/components/lay-notice/index.vue +83 -0
- package/src/layout/components/lay-notice/noticeItem.vue +160 -0
- package/src/layout/components/lay-notice/noticeList.vue +19 -0
- package/src/layout/components/lay-panel/index.vue +150 -0
- package/src/layout/components/lay-search/components/SearchFooter.vue +67 -0
- package/src/layout/components/lay-search/components/SearchModal.vue +189 -0
- package/src/layout/components/lay-search/components/SearchResult.vue +132 -0
- package/src/layout/components/lay-search/components/index.ts +10 -0
- package/src/layout/components/lay-search/index.vue +25 -0
- package/src/layout/components/lay-select-org/index.vue +69 -0
- package/src/layout/components/lay-setting/index.vue +510 -0
- package/src/layout/components/lay-sidebar/breadCrumb.vue +131 -0
- package/src/layout/components/lay-sidebar/extraIcon.vue +25 -0
- package/src/layout/components/lay-sidebar/hamBurger.vue +72 -0
- package/src/layout/components/lay-sidebar/horizontal.vue +191 -0
- package/src/layout/components/lay-sidebar/mixNav.vue +258 -0
- package/src/layout/components/lay-sidebar/sidebar-logo.vue +98 -0
- package/src/layout/components/lay-sidebar/sidebarItem.vue +205 -0
- package/src/layout/components/lay-sidebar/vertical.vue +94 -0
- package/src/layout/components/lay-tag/index.scss +375 -0
- package/src/layout/components/lay-tag/index.vue +625 -0
- package/src/layout/frameView.vue +71 -0
- package/src/layout/hooks/useBoolean.ts +33 -0
- package/src/layout/hooks/useDataThemeChange.ts +142 -0
- package/src/layout/hooks/useLayout.ts +65 -0
- package/src/layout/hooks/useNav.ts +173 -0
- package/src/layout/hooks/useTag.ts +233 -0
- package/src/layout/hooks/useTranslationLang.ts +51 -0
- package/src/layout/layoutView.vue +215 -0
- package/src/layout/redirect.vue +30 -0
- package/src/layout/routerView/parent.vue +23 -0
- package/src/layout/types.ts +92 -0
- package/src/main.ts +108 -0
- package/src/plugins/echarts/index.ts +58 -0
- package/src/plugins/echarts/theme.json +394 -0
- package/src/plugins/i18n/en.ts +289 -0
- package/src/plugins/i18n/index.ts +76 -0
- package/src/plugins/i18n/module/u-report.ts +64 -0
- package/src/plugins/i18n/module/u-workflow.ts +71 -0
- package/src/plugins/i18n/module/umsg.ts +28 -0
- package/src/plugins/i18n/zh.ts +337 -0
- package/src/plugins/vxe-table/index.ts +46 -0
- package/src/plugins/vxe-table/render.tsx +397 -0
- package/src/router/createComponent.tsx +25 -0
- package/src/router/index.ts +183 -0
- package/src/router/modules/error.ts +32 -0
- package/src/router/modules/home.ts +32 -0
- package/src/router/modules/nested.ts +93 -0
- package/src/router/modules/remaining.ts +83 -0
- package/src/router/modules/tabs.ts +55 -0
- package/src/router/utils.ts +377 -0
- package/src/store/index.ts +9 -0
- package/src/store/modules/app.ts +69 -0
- package/src/store/modules/epTheme.ts +49 -0
- package/src/store/modules/multiTags.ts +109 -0
- package/src/store/modules/permission.ts +103 -0
- package/src/store/modules/settings.ts +40 -0
- package/src/store/modules/system.ts +180 -0
- package/src/store/modules/types.ts +49 -0
- package/src/style/button.scss +78 -0
- package/src/style/clear-mixin.scss +28 -0
- package/src/style/dark.scss +218 -0
- package/src/style/element-plus.scss +206 -0
- package/src/style/index.scss +76 -0
- package/src/style/login.css +336 -0
- package/src/style/login2.css +106 -0
- package/src/style/print-lock.css +375 -0
- package/src/style/reset.scss +272 -0
- package/src/style/sidebar.scss +770 -0
- package/src/style/suprint.css +985 -0
- package/src/style/tailwind.css +68 -0
- package/src/style/theme.scss +143 -0
- package/src/style/transition.scss +42 -0
- package/src/style/vxetable.scss +256 -0
- package/src/utils/authority/index.ts +29 -0
- package/src/utils/browers.ts +59 -0
- package/src/utils/dataFormat/index.ts +223 -0
- package/src/utils/http/index.ts +297 -0
- package/src/utils/http/types.d.ts +46 -0
- package/src/utils/index.ts +47 -0
- package/src/utils/lifecycle.ts +20 -0
- package/src/utils/mitt.ts +19 -0
- package/src/utils/propTypes.ts +47 -0
- package/src/utils/storage/index.ts +51 -0
- package/src/views/components/contextmenu/basic.vue +74 -0
- package/src/views/components/contextmenu/context-menu.vue +40 -0
- package/src/views/components/contextmenu/menuDynamic.vue +99 -0
- package/src/views/components/contextmenu/menuGroup.vue +71 -0
- package/src/views/components/count-to/index.vue +43 -0
- package/src/views/components/cropping/index.vue +59 -0
- package/src/views/components/cropping/picture.jpeg +0 -0
- package/src/views/components/split-pane/index.vue +82 -0
- package/src/views/components/video/index.vue +57 -0
- package/src/views/error/403.vue +50 -0
- package/src/views/error/404.vue +50 -0
- package/src/views/error/500.vue +52 -0
- package/src/views/login/login-view.vue +314 -0
- package/src/views/login/utils/motion.ts +47 -0
- package/src/views/login/utils/rule.ts +70 -0
- package/src/views/login/utils/verifyCode.ts +52 -0
- package/src/views/organization/company/Company.vue +56 -0
- package/src/views/organization/company/CompanyPanel.vue +259 -0
- package/src/views/organization/department/Department.vue +58 -0
- package/src/views/organization/department/DepartmentPanel.vue +283 -0
- package/src/views/organization/inv-org/InvOrganization.vue +53 -0
- package/src/views/organization/org/Org.vue +43 -0
- package/src/views/organization/staff/Staff.vue +58 -0
- package/src/views/organization/staff/StaffInfo.vue +163 -0
- package/src/views/organization/staff/StaffPanel.vue +144 -0
- package/src/views/system/cron/cron-task.vue +157 -0
- package/src/views/system/menu/AuthorityPanel.vue +140 -0
- package/src/views/system/menu/SystemMenu.vue +191 -0
- package/src/views/system/menu/menuInfo.vue +368 -0
- package/src/views/system/role/AuthorityInfo.vue +147 -0
- package/src/views/system/role/Role.vue +57 -0
- package/src/views/system/role/RolePanel.vue +191 -0
- package/src/views/system/role/UserInfo.vue +193 -0
- package/src/views/system/role-assign/RoleAssign.vue +57 -0
- package/src/views/system/role-assign/RolePanel.vue +136 -0
- package/src/views/system/sys/sys-config.vue +291 -0
- package/src/views/system/sysUser/SysUser.vue +45 -0
- package/src/views/system/sysUser/SysUserPanel.vue +278 -0
- package/src/views/uapp/pda/pda-app.vue +176 -0
- package/src/views/udev/coderule/code-rule.vue +121 -0
- package/src/views/udev/dict/DictView.vue +106 -0
- package/src/views/udev/dict/childView.vue +222 -0
- package/src/views/udev/lov/childView.vue +180 -0
- package/src/views/udev/lov/lov-view.vue +91 -0
- package/src/views/ufile/aggregation/File.vue +87 -0
- package/src/views/ufile/file/water-mark.vue +103 -0
- package/src/views/uhome/components/menu-favorite.vue +331 -0
- package/src/views/uhome/su-welcome.vue +339 -0
- package/src/views/ulogin/login.vue +316 -0
- package/src/views/umsg/monitor/msg-monitor.vue +36 -0
- package/src/views/umsg/msg/TemplateContent.vue +103 -0
- package/src/views/umsg/msg/msg-template.vue +66 -0
- package/src/views/umsg/send/childView.vue +142 -0
- package/src/views/umsg/send/msg-send.vue +95 -0
- package/src/views/upms/interface/log-in.vue +106 -0
- package/src/views/upms/interface/log-out.vue +107 -0
- package/src/views/upms/user/login-log.vue +60 -0
- package/src/views/urpt/dataSet/DataSet.vue +139 -0
- package/src/views/urpt/design/DesignPanel.vue +526 -0
- package/src/views/urpt/design/Preview.vue +65 -0
- package/src/views/urpt/design/ReportDesign.vue +249 -0
- package/src/views/urpt/design/bg.png +0 -0
- package/src/views/urpt/design/panel.ts +841 -0
- package/src/views/urpt/design/print-data.ts +59 -0
- package/src/views/urpt/query/ReportQuery.vue +122 -0
- package/src/views/urpt/query/ReportQueryFrom.vue +252 -0
- package/src/views/urpt/report-request/ReportDefine.vue +10 -0
- package/src/views/urpt/static-resource/resource.vue +116 -0
- package/src/views/urpt/template/ReportTemplate.vue +198 -0
- package/tsconfig.json +30 -0
- package/types/env.d.ts +1 -0
- package/types/global-components.d.ts +12 -0
- package/types/global.d.ts +236 -0
- package/types/image.d.ts +7 -0
- package/types/index.d.ts +73 -0
- package/types/router.d.ts +107 -0
- package/types/shims-tsx.d.ts +22 -0
- package/types/shims-vue.d.ts +20 -0
- package/vite.config.ts +73 -0
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: wei.li
|
|
3
|
+
* @Date: 2022-06-23 17:29:11
|
|
4
|
+
* @LastEditors: levi7754 levi7754@163.com
|
|
5
|
+
* @LastEditTime: 2024-07-04 21:06:05
|
|
6
|
+
* @Description: file content
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { clone, isArray, isString, isEmpty, toDateString } from 'xe-utils';
|
|
10
|
+
import { useRender } from '@utogether/utils';
|
|
11
|
+
|
|
12
|
+
const renderHook = useRender();
|
|
13
|
+
|
|
14
|
+
export const rulesFormat = (records, rule, t) => {
|
|
15
|
+
records
|
|
16
|
+
.filter(colunm => colunm.required)
|
|
17
|
+
.forEach(colunm => {
|
|
18
|
+
const { field, title } = colunm;
|
|
19
|
+
rule[field] = [
|
|
20
|
+
{
|
|
21
|
+
required: true,
|
|
22
|
+
message: `${t('message.required')}${title ? t(title) : t(`message.${field}`)}`
|
|
23
|
+
}
|
|
24
|
+
];
|
|
25
|
+
});
|
|
26
|
+
return rule;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const columnFormat = columns => {
|
|
30
|
+
return columns.map(m => {
|
|
31
|
+
if (m.type) return m;
|
|
32
|
+
m.title = m.title || `message.${m.field}`;
|
|
33
|
+
return m;
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const searchBtn: IFormItemProps = {
|
|
38
|
+
span: 6,
|
|
39
|
+
align: 'right',
|
|
40
|
+
collapseNode: false,
|
|
41
|
+
itemRender: {
|
|
42
|
+
name: '$buttons',
|
|
43
|
+
children: [
|
|
44
|
+
{
|
|
45
|
+
props: {
|
|
46
|
+
type: 'submit',
|
|
47
|
+
content: 'message.btn.search',
|
|
48
|
+
status: 'primary',
|
|
49
|
+
icon: 'vxe-icon-search'
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
props: {
|
|
54
|
+
type: 'reset',
|
|
55
|
+
content: 'message.btn.reset',
|
|
56
|
+
status: 'info',
|
|
57
|
+
icon: 'ri-refresh-line ri-1x'
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export const formatGridItems = (records, favorite) => {
|
|
65
|
+
const formItems = records.filter(f => !f.isHidden);
|
|
66
|
+
const len = formItems.length;
|
|
67
|
+
// 前3个存在时间范围 或者 存在span = 12
|
|
68
|
+
const isDateRange = len > 2 && formItems.some((f, idx) => idx < 3 && (f.span > 6 || getDateRange(f)));
|
|
69
|
+
// 需要展示折叠按钮
|
|
70
|
+
const isCollapse = isDateRange || len > 3;
|
|
71
|
+
const defaultCollapse = { collapseTags: true, collapseTagsTooltip: true };
|
|
72
|
+
const items = formItems.map((item, idx) => {
|
|
73
|
+
item.folding = isDateRange ? isCollapse && idx > 1 : isCollapse && idx > 2;
|
|
74
|
+
item.span = getDateRange(item) ? 12 : item.span || 6;
|
|
75
|
+
if (item.code && !item.itemRender) {
|
|
76
|
+
item.itemRender = renderHook.renderDict(item.code);
|
|
77
|
+
}
|
|
78
|
+
item.itemRender = item.itemRender || { name: '$input' };
|
|
79
|
+
item.title = item.title || `message.${item.field}`;
|
|
80
|
+
if (item.multiple || item.itemRender?.props?.multiple) {
|
|
81
|
+
item.itemRender.props = Object.assign(defaultCollapse, item.itemRender?.props || {});
|
|
82
|
+
}
|
|
83
|
+
return item;
|
|
84
|
+
});
|
|
85
|
+
const btn = clone(searchBtn, true);
|
|
86
|
+
btn.collapseNode = isCollapse;
|
|
87
|
+
favorite && btn.itemRender.children.length < 3 && btn.itemRender.children.push(favorite);
|
|
88
|
+
|
|
89
|
+
if (isCollapse) {
|
|
90
|
+
// 按钮设置为 折叠节点
|
|
91
|
+
// 折叠时将搜索按钮插入到第一列的最后
|
|
92
|
+
const idx = isDateRange ? 2 : 3;
|
|
93
|
+
items.splice(idx, 0, btn);
|
|
94
|
+
} else {
|
|
95
|
+
items.push(btn);
|
|
96
|
+
}
|
|
97
|
+
return items;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const getDateRange = item => {
|
|
101
|
+
if (item.itemRender?.name === '#SuDateRange') {
|
|
102
|
+
return item.itemRender?.props?.type === 'daterange' || !item.itemRender?.props?.type;
|
|
103
|
+
}
|
|
104
|
+
return false;
|
|
105
|
+
};
|
|
106
|
+
export const formatButton = (buttons, auth?) => {
|
|
107
|
+
buttons.forEach(btn => {
|
|
108
|
+
btn.auth = auth ? auth[btn.code] || btn.auth : btn.auth;
|
|
109
|
+
if (!btn.name) {
|
|
110
|
+
btn.name = `message.${btn.name || btn.code}`;
|
|
111
|
+
} else if (!btn.name.includes('message.')) {
|
|
112
|
+
btn.name = `message.${btn.name}`;
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
return buttons;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export const queryAll = (props, http, form, fetchParam) => {
|
|
119
|
+
const params = { pageNum: 1, pageSize: 100000 };
|
|
120
|
+
Object.assign(params, form, fetchParam || {});
|
|
121
|
+
const query = formatDateRange(params, props.formItems);
|
|
122
|
+
const ajax = props.version === 'v2' ? http.get : http.post;
|
|
123
|
+
return new Promise((resolve, reject) => {
|
|
124
|
+
ajax(props.serviceCode.fetch, query)
|
|
125
|
+
.then((response: IResponseData) => {
|
|
126
|
+
resolve(response.list);
|
|
127
|
+
})
|
|
128
|
+
.catch((e: any) => {
|
|
129
|
+
reject(e);
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
/** 查询服务 */
|
|
135
|
+
export const query = (props, form, page, http, fetchParam) => {
|
|
136
|
+
for (const i in form) {
|
|
137
|
+
if (form[i] && isString(form[i])) {
|
|
138
|
+
form[i] = form[i].trim();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
const params = {
|
|
142
|
+
pageNum: page.currentPage,
|
|
143
|
+
pageSize: page.pageSize
|
|
144
|
+
};
|
|
145
|
+
Object.assign(params, form, fetchParam || {});
|
|
146
|
+
const query = formatDateRange(params, props.formItems);
|
|
147
|
+
const {
|
|
148
|
+
version,
|
|
149
|
+
serviceCode: { fetch }
|
|
150
|
+
} = props;
|
|
151
|
+
if (!fetch) return null;
|
|
152
|
+
if (version === 'v2') {
|
|
153
|
+
return http.get(fetch, query);
|
|
154
|
+
}
|
|
155
|
+
return http.post(fetch, query);
|
|
156
|
+
};
|
|
157
|
+
/** 删除服务 */
|
|
158
|
+
export const del = (http, removeRecords, props) => {
|
|
159
|
+
const { serviceCode, version, isSingleSubmit } = props;
|
|
160
|
+
const { del } = serviceCode;
|
|
161
|
+
if (!del) return null;
|
|
162
|
+
if (version === 'v2') {
|
|
163
|
+
return http.delete(del, !isSingleSubmit ? removeRecords : removeRecords[0]);
|
|
164
|
+
}
|
|
165
|
+
return http.post(del, !isSingleSubmit ? removeRecords : removeRecords[0]);
|
|
166
|
+
};
|
|
167
|
+
/** 更新服务 */
|
|
168
|
+
export const save = (http, body, props, confirmParam) => {
|
|
169
|
+
const allService = [];
|
|
170
|
+
const { serviceCode, isSingleSubmit, version, multiField } = props;
|
|
171
|
+
const { add, update } = serviceCode;
|
|
172
|
+
const { insertRecords, updateRecords } = body;
|
|
173
|
+
|
|
174
|
+
if (!isEmpty(insertRecords) && add) {
|
|
175
|
+
insertRecords.forEach(m => {
|
|
176
|
+
!isEmpty(confirmParam) && Object.assign(m, confirmParam);
|
|
177
|
+
m = !isEmpty(multiField) ? setMultiField(props, m, confirmParam) : m;
|
|
178
|
+
});
|
|
179
|
+
const service = http.post(add, !isSingleSubmit ? insertRecords : insertRecords[0]);
|
|
180
|
+
allService.push(service);
|
|
181
|
+
}
|
|
182
|
+
if (!isEmpty(updateRecords) && update) {
|
|
183
|
+
const records = !isEmpty(multiField)
|
|
184
|
+
? updateRecords.map(m => setMultiField(props, m, confirmParam))
|
|
185
|
+
: updateRecords;
|
|
186
|
+
let service = null;
|
|
187
|
+
if (version === 'v2') {
|
|
188
|
+
service = http.put(update, !isSingleSubmit ? records : records[0]);
|
|
189
|
+
} else {
|
|
190
|
+
service = http.post(update, !isSingleSubmit ? records : records[0]);
|
|
191
|
+
}
|
|
192
|
+
allService.push(service);
|
|
193
|
+
}
|
|
194
|
+
return allService;
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
const formatDateRange = (listQuery: any, formItems) => {
|
|
198
|
+
const dateRanges = formItems.filter(f => f.itemRender?.name === '#SuDateRange');
|
|
199
|
+
if (isEmpty(dateRanges)) return listQuery;
|
|
200
|
+
const query = clone(listQuery, true);
|
|
201
|
+
dateRanges.forEach((element: any) => {
|
|
202
|
+
const val = query[element.field];
|
|
203
|
+
if (val && element.toField) {
|
|
204
|
+
query[element.fromField] = toDateString(val[0], 'yyyy-MM-dd 00:00:00');
|
|
205
|
+
query[element.toField] = toDateString(val[1], 'yyyy-MM-dd 23:59:59');
|
|
206
|
+
delete query[element.field];
|
|
207
|
+
} else if (val) {
|
|
208
|
+
query[`${element.field}From`] = toDateString(val[0], 'yyyy-MM-dd 00:00:00');
|
|
209
|
+
query[`${element.field}To`] = toDateString(val[1], 'yyyy-MM-dd 23:59:59');
|
|
210
|
+
delete query[element.field];
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
return query;
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
const setMultiField = (props, source: any, confirmParam) => {
|
|
217
|
+
const { multiField } = props;
|
|
218
|
+
multiField.forEach(field => {
|
|
219
|
+
source[field] = isArray(source[field]) ? source[field].join(',') : source[field];
|
|
220
|
+
});
|
|
221
|
+
Object.assign(source, confirmParam || {});
|
|
222
|
+
return source;
|
|
223
|
+
};
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import Axios, { type AxiosInstance, type AxiosRequestConfig } from 'axios';
|
|
2
|
+
import type { SuHttpError, RequestMethods, SuHttpResponse, SuHttpRequestConfig } from './types.d';
|
|
3
|
+
import { has } from 'xe-utils';
|
|
4
|
+
import { NProgress, cookies, errorMessage } from '@utogether/utils';
|
|
5
|
+
import { isRef } from 'vue';
|
|
6
|
+
|
|
7
|
+
const kTOKENKEY = 'authorized-token';
|
|
8
|
+
const defaultConfig: AxiosRequestConfig = {
|
|
9
|
+
timeout: 180000,
|
|
10
|
+
headers: {
|
|
11
|
+
Accept: 'application/json, text/plain, */*',
|
|
12
|
+
'Content-Type': 'application/json',
|
|
13
|
+
'X-Requested-With': 'XMLHttpRequest'
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
class SuHttp {
|
|
17
|
+
constructor() {
|
|
18
|
+
this.httpInterceptorsRequest();
|
|
19
|
+
this.httpInterceptorsResponse();
|
|
20
|
+
}
|
|
21
|
+
baseUrl = null;
|
|
22
|
+
router = null;
|
|
23
|
+
/** token过期后,暂存待执行的请求 */
|
|
24
|
+
private static requests = [];
|
|
25
|
+
|
|
26
|
+
/** 防止重复刷新token */
|
|
27
|
+
private static isRefreshing = false;
|
|
28
|
+
|
|
29
|
+
/** 设置router调整 */
|
|
30
|
+
setRouter(router) {
|
|
31
|
+
this.router = router;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
setBaseUrl(baseUrl) {
|
|
35
|
+
this.baseUrl = baseUrl;
|
|
36
|
+
}
|
|
37
|
+
// 初始化配置对象
|
|
38
|
+
private static initConfig: SuHttpRequestConfig = {};
|
|
39
|
+
|
|
40
|
+
// 保存当前Axios实例对象
|
|
41
|
+
private static axiosInstance: AxiosInstance = Axios.create(defaultConfig);
|
|
42
|
+
|
|
43
|
+
/** 重连原始请求 */
|
|
44
|
+
private static retryOriginalRequest(config: SuHttpRequestConfig) {
|
|
45
|
+
return new Promise(resolve => {
|
|
46
|
+
// @ts-ignore
|
|
47
|
+
SuHttp.requests.push((token: string) => {
|
|
48
|
+
config.headers!['Authorization'] = 'Bearer ' + token;
|
|
49
|
+
resolve(config);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// 请求拦截
|
|
55
|
+
private httpInterceptorsRequest(): void {
|
|
56
|
+
SuHttp.axiosInstance.interceptors.request.use(
|
|
57
|
+
(config: any) => {
|
|
58
|
+
if (has(config, 'loading') && isRef(config.loading)) {
|
|
59
|
+
config.loading.value = true;
|
|
60
|
+
}
|
|
61
|
+
// 开启进度条动画
|
|
62
|
+
NProgress.start();
|
|
63
|
+
// 优先判断post/get等方法是否传入回掉,否则执行初始化设置等回掉
|
|
64
|
+
if (typeof config.beforeRequestCallback === 'function') {
|
|
65
|
+
config.beforeRequestCallback(config);
|
|
66
|
+
return config;
|
|
67
|
+
}
|
|
68
|
+
if (SuHttp.initConfig.beforeRequestCallback) {
|
|
69
|
+
SuHttp.initConfig.beforeRequestCallback(config);
|
|
70
|
+
return config;
|
|
71
|
+
}
|
|
72
|
+
const whiteList = ['/refreshToken', '/login'];
|
|
73
|
+
if (whiteList.some(v => config.url.indexOf(v) > -1)) return config;
|
|
74
|
+
return new Promise(resolve => {
|
|
75
|
+
const token = cookies.get(kTOKENKEY);
|
|
76
|
+
if (token) {
|
|
77
|
+
const data = JSON.parse(token);
|
|
78
|
+
const now = new Date().getTime();
|
|
79
|
+
const expired = data.expires - now <= 0;
|
|
80
|
+
if (expired) {
|
|
81
|
+
if (!SuHttp.isRefreshing) {
|
|
82
|
+
SuHttp.isRefreshing = true;
|
|
83
|
+
// requests.push(() => SuHttp.axiosInstance(config));
|
|
84
|
+
|
|
85
|
+
this.get(this.baseUrl + '/uath/refreshToken', {
|
|
86
|
+
refreshToken: data.refreshToken
|
|
87
|
+
})
|
|
88
|
+
.then((res: any) => {
|
|
89
|
+
// 替换token
|
|
90
|
+
this.setToken(res);
|
|
91
|
+
config.headers['Authorization'] = 'Bearer ' + res.access_token;
|
|
92
|
+
// token 刷新后将数组的方法重新执行
|
|
93
|
+
// @ts-ignore
|
|
94
|
+
SuHttp.requests.forEach(cb => cb(res.access_token));
|
|
95
|
+
SuHttp.requests = []; // 重新请求完清空
|
|
96
|
+
})
|
|
97
|
+
.finally(() => {
|
|
98
|
+
SuHttp.isRefreshing = false;
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
// @ts-ignore
|
|
102
|
+
resolve(SuHttp.retryOriginalRequest(config));
|
|
103
|
+
} else {
|
|
104
|
+
config.headers['Authorization'] = 'Bearer ' + data.accessToken;
|
|
105
|
+
resolve(config);
|
|
106
|
+
}
|
|
107
|
+
} else {
|
|
108
|
+
const sessionKey = cookies.get('kCookies_token') as string;
|
|
109
|
+
if (sessionKey) {
|
|
110
|
+
config.headers['X-Token'] = sessionKey;
|
|
111
|
+
}
|
|
112
|
+
resolve(config);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
},
|
|
116
|
+
error => {
|
|
117
|
+
return Promise.reject(error);
|
|
118
|
+
}
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
private setToken(token) {
|
|
123
|
+
const { access_token, expires_in, refresh_token } = token;
|
|
124
|
+
const cache = {
|
|
125
|
+
accessToken: access_token,
|
|
126
|
+
refreshToken: refresh_token,
|
|
127
|
+
expires: Date.now() + expires_in * 1000
|
|
128
|
+
};
|
|
129
|
+
cookies.set(kTOKENKEY, JSON.stringify(cache));
|
|
130
|
+
// cookies.set(kTOKENKEY, JSON.stringify(cache), { expires: expires_in });
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// 响应拦截
|
|
134
|
+
private httpInterceptorsResponse(): void {
|
|
135
|
+
const instance = SuHttp.axiosInstance;
|
|
136
|
+
instance.interceptors.response.use(
|
|
137
|
+
(response: SuHttpResponse) => {
|
|
138
|
+
const $config = response.config;
|
|
139
|
+
if (has($config, 'loading') && isRef($config.loading)) {
|
|
140
|
+
$config.loading.value = false;
|
|
141
|
+
}
|
|
142
|
+
// 关闭进度条动画
|
|
143
|
+
NProgress.done();
|
|
144
|
+
// 优先判断post/get等方法是否传入回掉,否则执行初始化设置等回掉
|
|
145
|
+
if (typeof $config.beforeResponseCallback === 'function') {
|
|
146
|
+
$config.beforeResponseCallback(response);
|
|
147
|
+
return response.data;
|
|
148
|
+
}
|
|
149
|
+
if (SuHttp.initConfig.beforeResponseCallback) {
|
|
150
|
+
SuHttp.initConfig.beforeResponseCallback(response);
|
|
151
|
+
return response.data;
|
|
152
|
+
}
|
|
153
|
+
return response.data;
|
|
154
|
+
},
|
|
155
|
+
(error: SuHttpError) => {
|
|
156
|
+
// @ts-ignore
|
|
157
|
+
if (has(error.config, 'loading') && isRef(error.config.loading)) {
|
|
158
|
+
// @ts-ignore
|
|
159
|
+
error.config.loading.value = false;
|
|
160
|
+
}
|
|
161
|
+
const $error = error;
|
|
162
|
+
$error.isCancelRequest = Axios.isCancel($error);
|
|
163
|
+
// 关闭进度条动画
|
|
164
|
+
NProgress.done();
|
|
165
|
+
// 所有的响应异常 区分来源为取消请求/非取消请求
|
|
166
|
+
return Promise.reject($error);
|
|
167
|
+
}
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
private transformConfigByMethod(params: any, config: SuHttpRequestConfig): SuHttpRequestConfig {
|
|
172
|
+
const { method } = config;
|
|
173
|
+
const methods = ['get'];
|
|
174
|
+
const m = method!.toLocaleLowerCase();
|
|
175
|
+
const props = methods.includes(m) ? 'params' : 'data';
|
|
176
|
+
return {
|
|
177
|
+
...config,
|
|
178
|
+
[props]: params
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// 通用请求工具函数
|
|
183
|
+
public request<T>(
|
|
184
|
+
method: RequestMethods,
|
|
185
|
+
url: string,
|
|
186
|
+
param?: AxiosRequestConfig,
|
|
187
|
+
axiosConfig?: SuHttpRequestConfig
|
|
188
|
+
): Promise<T> {
|
|
189
|
+
const config = this.transformConfigByMethod(param, {
|
|
190
|
+
method,
|
|
191
|
+
url,
|
|
192
|
+
...axiosConfig
|
|
193
|
+
} as SuHttpRequestConfig);
|
|
194
|
+
// 单独处理自定义请求/响应回掉
|
|
195
|
+
return new Promise((resolve, reject) => {
|
|
196
|
+
SuHttp.axiosInstance
|
|
197
|
+
.request(config)
|
|
198
|
+
.then((res: any) => {
|
|
199
|
+
if (res && res?.code === '0') {
|
|
200
|
+
resolve(res.data);
|
|
201
|
+
} else if (res.code === '500') {
|
|
202
|
+
errorMessage(res.msg, { duration: 8000 });
|
|
203
|
+
if (config.method === 'get') {
|
|
204
|
+
resolve(res);
|
|
205
|
+
} else {
|
|
206
|
+
reject(res.msg);
|
|
207
|
+
}
|
|
208
|
+
} else if (res?.code !== '-1') {
|
|
209
|
+
resolve(res);
|
|
210
|
+
} else {
|
|
211
|
+
const msg = res?.msg || '服务异常';
|
|
212
|
+
errorMessage(msg, { duration: 8000 });
|
|
213
|
+
// const code = res.code;
|
|
214
|
+
// if (
|
|
215
|
+
// code === "000001" ||
|
|
216
|
+
// (code === "-1" && msg.includes("请重新登陆"))
|
|
217
|
+
// ) {
|
|
218
|
+
// // session过期
|
|
219
|
+
// cookies.remove("kCookies_token");
|
|
220
|
+
// // @ts-ignore
|
|
221
|
+
// this.router?.push({
|
|
222
|
+
// path: "/login",
|
|
223
|
+
// query: { tokenExpire: "Y" },
|
|
224
|
+
// });
|
|
225
|
+
// }
|
|
226
|
+
reject(msg);
|
|
227
|
+
}
|
|
228
|
+
})
|
|
229
|
+
.catch(e => {
|
|
230
|
+
debugger;
|
|
231
|
+
if (e?.response?.data?.path === '/refreshToken') {
|
|
232
|
+
this.router?.push('/login');
|
|
233
|
+
} else if (e?.code) {
|
|
234
|
+
if (e?.response?.status === 401) {
|
|
235
|
+
// @ts-ignore
|
|
236
|
+
return this.router?.push({ path: '/login' });
|
|
237
|
+
}
|
|
238
|
+
errorMessage(this.getNetworkError(e?.response?.status) || e?.message, { duration: 8000 });
|
|
239
|
+
}
|
|
240
|
+
if (e.config.method === 'get') {
|
|
241
|
+
resolve(e);
|
|
242
|
+
} else {
|
|
243
|
+
reject(e);
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
getNetworkError = code => {
|
|
250
|
+
if (!code) return null;
|
|
251
|
+
const msgMap = {
|
|
252
|
+
400: '错误的请求',
|
|
253
|
+
401: '服务未授权,请重新登录',
|
|
254
|
+
403: '拒绝访问',
|
|
255
|
+
404: '请求错误,未找到该资源',
|
|
256
|
+
408: '请求超时',
|
|
257
|
+
500: '服务器端出差',
|
|
258
|
+
502: '网络超时',
|
|
259
|
+
503: '服务不可用',
|
|
260
|
+
504: '网络超时'
|
|
261
|
+
};
|
|
262
|
+
return msgMap[code];
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
// 单独抽离的post工具函数
|
|
266
|
+
public post<T, P>(url: string, params?: T, config?: SuHttpRequestConfig): Promise<P> {
|
|
267
|
+
// @ts-ignore
|
|
268
|
+
return this.request<P>('post', url, params, config);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// 单独抽离的delete工具函数
|
|
272
|
+
public delete<T, P>(url: string, params?: T, config?: SuHttpRequestConfig): Promise<P> {
|
|
273
|
+
// @ts-ignore
|
|
274
|
+
return this.request<P>('delete', url, params, config);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// 单独抽离的put工具函数
|
|
278
|
+
public put<T, P>(url: string, params?: T, config?: SuHttpRequestConfig): Promise<P> {
|
|
279
|
+
// @ts-ignore
|
|
280
|
+
return this.request<P>('put', url, params, config);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
// 单独抽离的get工具函数
|
|
284
|
+
public get<T, P>(url: string, params?: T, config?: SuHttpRequestConfig): Promise<P> {
|
|
285
|
+
for (const key in params) {
|
|
286
|
+
if (!params[key]) delete params[key];
|
|
287
|
+
}
|
|
288
|
+
// @ts-ignore
|
|
289
|
+
return this.request<P>('get', url, params, config);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
public postRouter<T>(params?: any): Promise<T> {
|
|
293
|
+
return this.request<T>('post', 'route/service', params);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
export const http = new SuHttp();
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: wei.li
|
|
3
|
+
* @Date: 2022-03-08 15:17:39
|
|
4
|
+
* @LastEditors: levi7754 levi7754@163.com
|
|
5
|
+
* @LastEditTime: 2023-12-01 11:59:12
|
|
6
|
+
* @Description: SuHttp Axios 类型定义文件
|
|
7
|
+
*/
|
|
8
|
+
import type { Method, AxiosError, AxiosResponse, AxiosRequestConfig } from 'axios';
|
|
9
|
+
|
|
10
|
+
export type resultType = {
|
|
11
|
+
access_token: string;
|
|
12
|
+
refresh_token: string;
|
|
13
|
+
expires_in: number;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type RequestMethods = Extract<
|
|
17
|
+
Method,
|
|
18
|
+
'get' | 'post' | 'put' | 'delete' | 'patch' | 'option' | 'head'
|
|
19
|
+
>;
|
|
20
|
+
|
|
21
|
+
export interface SuHttpError extends AxiosError {
|
|
22
|
+
isCancelRequest?: boolean;
|
|
23
|
+
loading?: boolean;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface SuHttpResponse extends AxiosResponse {
|
|
27
|
+
config: SuHttpRequestConfig;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface SuHttpRequestConfig extends AxiosRequestConfig {
|
|
31
|
+
beforeRequestCallback?: (request: SuHttpRequestConfig) => void;
|
|
32
|
+
beforeResponseCallback?: (response: SuHttpResponse) => void;
|
|
33
|
+
loading?: any;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export default class SuHttp {
|
|
37
|
+
request<T>(
|
|
38
|
+
method: RequestMethods,
|
|
39
|
+
url: string,
|
|
40
|
+
param?: AxiosRequestConfig,
|
|
41
|
+
axiosConfig?: SuHttpRequestConfig
|
|
42
|
+
): Promise<T>;
|
|
43
|
+
post<T, P>(url: string, params?: T, config?: SuHttpRequestConfig): Promise<P>;
|
|
44
|
+
postRouter<T, P>(url: string, params?: T, config?: SuHttpRequestConfig): Promise<P>;
|
|
45
|
+
get<T, P>(url: string, params?: T, config?: SuHttpRequestConfig): Promise<P>;
|
|
46
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: wei.li
|
|
3
|
+
* @Date: 2022-07-07 14:43:20
|
|
4
|
+
* @LastEditors: levi7754 levi7754@163.com
|
|
5
|
+
* @LastEditTime: 2025-06-03 09:26:49
|
|
6
|
+
* @Description: file content
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
// export * from './udp/useRender';
|
|
10
|
+
|
|
11
|
+
export const getKeyList = (data, key) => {
|
|
12
|
+
const array = [];
|
|
13
|
+
for (const obj of data) {
|
|
14
|
+
obj[key] && array.push(obj[key]);
|
|
15
|
+
}
|
|
16
|
+
return Array.from(new Set(array));
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/** hex转rgb */
|
|
20
|
+
const hexToRgb = str => {
|
|
21
|
+
const hxs = str.replace('#', '').match(/../g);
|
|
22
|
+
for (let i = 0; i < 3; i++) hxs[i] = parseInt(hxs[i], 16);
|
|
23
|
+
return hxs;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/** rgb转hex */
|
|
27
|
+
const rgbToHex = (a, b, c) => {
|
|
28
|
+
const hexs = [a.toString(16), b.toString(16), c.toString(16)];
|
|
29
|
+
for (let i = 0; i < 3; i++) {
|
|
30
|
+
if (hexs[i].length == 1) hexs[i] = `0${hexs[i]}`;
|
|
31
|
+
}
|
|
32
|
+
return `#${hexs.join('')}`;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/** 加深颜色值 */
|
|
36
|
+
export const darken = (color, level) => {
|
|
37
|
+
const rgbc = hexToRgb(color);
|
|
38
|
+
for (let i = 0; i < 3; i++) rgbc[i] = Math.floor(rgbc[i] * (1 - level));
|
|
39
|
+
return rgbToHex(rgbc[0], rgbc[1], rgbc[2]);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/** 变浅颜色值 */
|
|
43
|
+
export const lighten = (color, level) => {
|
|
44
|
+
const rgbc = hexToRgb(color);
|
|
45
|
+
for (let i = 0; i < 3; i++) rgbc[i] = Math.floor((255 - rgbc[i]) * level + rgbc[i]);
|
|
46
|
+
return rgbToHex(rgbc[0], rgbc[1], rgbc[2]);
|
|
47
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: wei.li
|
|
3
|
+
* @Date: 2024-06-26 16:30:54
|
|
4
|
+
* @LastEditors: wei.li
|
|
5
|
+
* @LastEditTime: 2024-06-26 17:11:58
|
|
6
|
+
* @Description: file content
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export const lifeCycleEvent = {
|
|
10
|
+
onLogined: () => {},
|
|
11
|
+
onBeforeLogout: () => {}
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const onLogined = () => {
|
|
15
|
+
lifeCycleEvent.onLogined();
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const onBeforeLogout = () => {
|
|
19
|
+
lifeCycleEvent.onBeforeLogout();
|
|
20
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Emitter } from 'mitt';
|
|
2
|
+
import mitt from 'mitt';
|
|
3
|
+
|
|
4
|
+
type Events = {
|
|
5
|
+
resize: {
|
|
6
|
+
detail: {
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
openPanel: string;
|
|
12
|
+
tagOnClick: string;
|
|
13
|
+
tagViewsChange: string;
|
|
14
|
+
tagViewsShowModel: string;
|
|
15
|
+
logoChange: string;
|
|
16
|
+
changLayoutRoute: string;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const emitter: Emitter<Events> = mitt<Events>();
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: levi7754 levi7754@163.com
|
|
3
|
+
* @Date: 2023-06-19 09:14:18
|
|
4
|
+
* @LastEditors: wei.li
|
|
5
|
+
* @LastEditTime: 2024-07-02 08:57:49
|
|
6
|
+
* @FilePath: /sitzone-mes/src/utils/propTypes.ts
|
|
7
|
+
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
|
8
|
+
*/
|
|
9
|
+
import type { CSSProperties, VNodeChild } from 'vue';
|
|
10
|
+
import {
|
|
11
|
+
createTypes,
|
|
12
|
+
toValidableType,
|
|
13
|
+
type VueTypesInterface,
|
|
14
|
+
type VueTypeValidableDef
|
|
15
|
+
} from 'vue-types';
|
|
16
|
+
|
|
17
|
+
export type VueNode = VNodeChild | JSX.Element;
|
|
18
|
+
|
|
19
|
+
type PropTypes = VueTypesInterface & {
|
|
20
|
+
readonly style: VueTypeValidableDef<CSSProperties>;
|
|
21
|
+
readonly VNodeChild: VueTypeValidableDef<VueNode>;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const newPropTypes = createTypes({
|
|
25
|
+
func: undefined,
|
|
26
|
+
bool: undefined,
|
|
27
|
+
string: undefined,
|
|
28
|
+
number: undefined,
|
|
29
|
+
object: undefined,
|
|
30
|
+
integer: undefined
|
|
31
|
+
}) as PropTypes;
|
|
32
|
+
|
|
33
|
+
// 从 vue-types v5.0 开始,extend()方法已经废弃,当前已改为官方推荐的ES6+方法 https://dwightjack.github.io/vue-types/advanced/extending-vue-types.html#the-extend-method
|
|
34
|
+
export default class propTypes extends newPropTypes {
|
|
35
|
+
// a native-like validator that supports the `.validable` method
|
|
36
|
+
static get style() {
|
|
37
|
+
return toValidableType('style', {
|
|
38
|
+
type: [String, Object]
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
static get VNodeChild() {
|
|
43
|
+
return toValidableType('VNodeChild', {
|
|
44
|
+
type: undefined
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|