@bit-sun/business-component 4.0.0-alpha.3 → 4.0.2
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/.editorconfig +16 -0
- package/.fatherrc.ts +5 -0
- package/.gitlab-ci.yml +179 -0
- package/.prettierignore +7 -0
- package/.prettierrc +11 -0
- package/.umirc.ts +74 -0
- package/dist/components/Business/BsSulaQueryTable/setting.d.ts +1 -1
- package/dist/components/Business/BsSulaQueryTable/utils.d.ts +1 -1
- package/dist/components/Business/columnSettingTable/columnSetting.d.ts +1 -1
- package/dist/components/Business/columnSettingTable/index.d.ts +1 -0
- package/dist/components/Common/ParagraphCopier/index.d.ts +8 -0
- package/dist/components/Solution/RuleComponent/CustomPlugin/CustomSelector/CustomSelectorModal.d.ts +3 -0
- package/dist/components/Solution/RuleComponent/CustomPlugin/CustomSelector/helps.d.ts +2 -0
- package/dist/components/Solution/RuleComponent/CustomPlugin/CustomSelector/index.d.ts +3 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +1901 -639
- package/dist/index.js +1903 -636
- package/dist/utils/requestUtils.d.ts +1 -0
- package/dist/utils/utils.d.ts +3 -0
- package/docs/index.md +21 -0
- package/package.json +9 -14
- package/src/assets/32.svg +28 -0
- package/src/assets/addIcon.svg +18 -0
- package/src/assets/allfunc.svg +28 -0
- package/src/assets/arrowRight.svg +25 -0
- package/src/assets/arrow_top.png +0 -0
- package/src/assets/arrow_top.svg +18 -0
- package/src/assets/btn-delete.svg +30 -0
- package/src/assets/btn-edit.svg +20 -0
- package/src/assets/btn-more.svg +18 -0
- package/src/assets/btn-submit.svg +20 -0
- package/src/assets/caidan.svg +12 -0
- package/src/assets/close.svg +26 -0
- package/src/assets/closeicon.png +0 -0
- package/src/assets/drag.svg +17 -0
- package/src/assets/exportFail.svg +38 -0
- package/src/assets/exportProcessing.svg +29 -0
- package/src/assets/exportSuccess.svg +35 -0
- package/src/assets/exportlogo.png +0 -0
- package/src/assets/fixed-left-active.svg +12 -0
- package/src/assets/fixed-left.svg +16 -0
- package/src/assets/fixed-right-active.svg +12 -0
- package/src/assets/fixed-right.svg +16 -0
- package/src/assets/guanbi.svg +16 -0
- package/src/assets/icon-quanping.svg +16 -0
- package/src/assets/icon-shezhi.svg +18 -0
- package/src/assets/label_icon_bottom.svg +26 -0
- package/src/assets/list-no-img.svg +22 -0
- package/src/assets/morentouxiang-32.svg +24 -0
- package/src/assets/right.png +0 -0
- package/src/assets/scanning.svg +25 -0
- package/src/assets/upExport.svg +23 -0
- package/src/assets/xinglan-icon-out.png +0 -0
- package/src/common/ENUM.ts +41 -0
- package/src/components/Business/AddSelectBusiness/index.md +398 -0
- package/src/components/Business/AddSelectBusiness/index.tsx +1116 -0
- package/src/components/Business/BsLayouts/Components/AllFunc/drawContent.tsx +112 -0
- package/src/components/Business/BsLayouts/Components/AllFunc/index.less +153 -0
- package/src/components/Business/BsLayouts/Components/AllFunc/index.tsx +70 -0
- package/src/components/Business/BsLayouts/Components/ChooseStore/index.less +0 -0
- package/src/components/Business/BsLayouts/Components/ChooseStore/index.tsx +193 -0
- package/src/components/Business/BsLayouts/Components/ChooseStore/services.ts +10 -0
- package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.less +90 -0
- package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.tsx +38 -0
- package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/leftTree.tsx +243 -0
- package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/rightTree.tsx +385 -0
- package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/DrawContent.tsx +286 -0
- package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/customMenuHeader.tsx +75 -0
- package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/drawContent.less +171 -0
- package/src/components/Business/BsLayouts/Components/CustomerMenu/index.less +65 -0
- package/src/components/Business/BsLayouts/Components/CustomerMenu/index.tsx +154 -0
- package/src/components/Business/BsLayouts/Components/GlobalHeader/index.less +73 -0
- package/src/components/Business/BsLayouts/Components/GlobalHeader/index.tsx +163 -0
- package/src/components/Business/BsLayouts/Components/RightContent/LoginModal.tsx +85 -0
- package/src/components/Business/BsLayouts/Components/RightContent/home.less +218 -0
- package/src/components/Business/BsLayouts/Components/RightContent/i18n.ts +9 -0
- package/src/components/Business/BsLayouts/Components/RightContent/index.tsx +172 -0
- package/src/components/Business/BsLayouts/Components/SearchFunc/index.less +161 -0
- package/src/components/Business/BsLayouts/Components/SearchFunc/index.tsx +76 -0
- package/src/components/Business/BsLayouts/index.less +80 -0
- package/src/components/Business/BsLayouts/index.tsx +1602 -0
- package/src/components/Business/BsLayouts/service.ts +11 -0
- package/src/components/Business/BsLayouts/utils.tsx +205 -0
- package/src/components/Business/BsSulaQueryTable/SearchItemSetting.tsx +566 -0
- package/src/components/Business/BsSulaQueryTable/bssulaquerytable.less +5 -0
- package/src/components/Business/BsSulaQueryTable/index.less +228 -0
- package/src/components/Business/BsSulaQueryTable/index.tsx +817 -0
- package/src/components/Business/BsSulaQueryTable/setting.tsx +937 -0
- package/src/components/Business/BsSulaQueryTable/utils.less +65 -0
- package/src/components/Business/BsSulaQueryTable/utils.tsx +709 -0
- package/src/components/Business/CommodityEntry/index.md +84 -0
- package/src/components/Business/CommodityEntry/index.tsx +82 -0
- package/src/components/Business/CommonAlert/index.less +0 -0
- package/src/components/Business/CommonAlert/index.tsx +23 -0
- package/src/components/Business/CommonGuideWrapper/index.less +156 -0
- package/src/components/Business/CommonGuideWrapper/index.md +61 -0
- package/src/components/Business/CommonGuideWrapper/index.tsx +108 -0
- package/src/components/Business/DetailPageWrapper/index.less +89 -0
- package/src/components/Business/DetailPageWrapper/index.tsx +306 -0
- package/src/components/Business/DetailPageWrapper/utils.tsx +166 -0
- package/src/components/Business/HomePageWrapper/index.less +36 -0
- package/src/components/Business/HomePageWrapper/index.md +45 -0
- package/src/components/Business/HomePageWrapper/index.tsx +130 -0
- package/src/components/Business/JsonQueryTable/components/FieldsModifyModal.tsx +823 -0
- package/src/components/Business/JsonQueryTable/components/FieldsSettingsTable.tsx +206 -0
- package/src/components/Business/JsonQueryTable/components/Formula.tsx +205 -0
- package/src/components/Business/JsonQueryTable/components/MaintainOptions.tsx +127 -0
- package/src/components/Business/JsonQueryTable/configButton/index.js +20 -0
- package/src/components/Business/JsonQueryTable/configTree/component/compactArrayView.js +25 -0
- package/src/components/Business/JsonQueryTable/configTree/component/compactObjectView.js +30 -0
- package/src/components/Business/JsonQueryTable/configTree/index.js +82 -0
- package/src/components/Business/JsonQueryTable/configTree/index.less +44 -0
- package/src/components/Business/JsonQueryTable/configTree/parser/highlight.js +57 -0
- package/src/components/Business/JsonQueryTable/configTree/parser/index.js +124 -0
- package/src/components/Business/JsonQueryTable/configTree/render/iconRender.js +29 -0
- package/src/components/Business/JsonQueryTable/configTree/render/nameRender.js +22 -0
- package/src/components/Business/JsonQueryTable/configTree/treeNode.js +116 -0
- package/src/components/Business/JsonQueryTable/drawer/index.tsx +12 -0
- package/src/components/Business/JsonQueryTable/function.ts +62 -0
- package/src/components/Business/JsonQueryTable/index.less +17 -0
- package/src/components/Business/JsonQueryTable/index.md +328 -0
- package/src/components/Business/JsonQueryTable/index.tsx +534 -0
- package/src/components/Business/JsonQueryTable/jsonEditor/index.js +346 -0
- package/src/components/Business/JsonQueryTable/jsonEditor/index.less +22 -0
- package/src/components/Business/JsonQueryTable/jsonEditor/lint/basicType.js +147 -0
- package/src/components/Business/JsonQueryTable/jsonEditor/lint/index.js +389 -0
- package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/actions.js +118 -0
- package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/dependency.js +22 -0
- package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/index.js +21 -0
- package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/request.js +65 -0
- package/src/components/Business/JsonQueryTable/static.ts +450 -0
- package/src/components/Business/SearchSelect/BusinessUtils.tsx +2207 -0
- package/src/components/Business/SearchSelect/common.ts +134 -0
- package/src/components/Business/SearchSelect/index.md +1570 -0
- package/src/components/Business/SearchSelect/index.tsx +55 -0
- package/src/components/Business/SearchSelect/utils.ts +125 -0
- package/src/components/Business/StateFlow/index.less +131 -0
- package/src/components/Business/StateFlow/index.md +60 -0
- package/src/components/Business/StateFlow/index.tsx +30 -0
- package/src/components/Business/TreeSearchSelect/index.md +239 -0
- package/src/components/Business/TreeSearchSelect/index.tsx +33 -0
- package/src/components/Business/TreeSearchSelect/utils.ts +115 -0
- package/src/components/Business/columnSettingTable/columnSetting.tsx +869 -0
- package/src/components/Business/columnSettingTable/index.less +253 -0
- package/src/components/Business/columnSettingTable/index.md +373 -0
- package/src/components/Business/columnSettingTable/index.tsx +235 -0
- package/src/components/Business/columnSettingTable/sulaSettingTable.tsx +232 -0
- package/src/components/Business/columnSettingTable/utils.tsx +88 -0
- package/src/components/Business/moreTreeTable/FixedScrollBar.tsx +87 -0
- package/src/components/Business/moreTreeTable/hooks/useSticky.ts +21 -0
- package/src/components/Business/moreTreeTable/index.less +100 -0
- package/src/components/Business/moreTreeTable/index.md +448 -0
- package/src/components/Business/moreTreeTable/index.tsx +387 -0
- package/src/components/Business/moreTreeTable/utils.ts +127 -0
- package/src/components/Common/ExtendedCollapse/ExtendedPanel.tsx +51 -0
- package/src/components/Common/ExtendedCollapse/index.less +33 -0
- package/src/components/Common/ExtendedCollapse/index.md +136 -0
- package/src/components/Common/ExtendedCollapse/index.tsx +25 -0
- package/src/components/Common/ParagraphCopier/index.md +81 -0
- package/src/components/Common/ParagraphCopier/index.tsx +56 -0
- package/src/components/Common/Section/index.md +120 -0
- package/src/components/Common/Section/index.module.less +16 -0
- package/src/components/Common/Section/index.tsx +70 -0
- package/src/components/Functional/AccessWrapper/index.tsx +34 -0
- package/src/components/Functional/AddSelect/helps.ts +81 -0
- package/src/components/Functional/AddSelect/index.less +367 -0
- package/src/components/Functional/AddSelect/index.md +155 -0
- package/src/components/Functional/AddSelect/index.tsx +1072 -0
- package/src/components/Functional/AuthButton/index.tsx +15 -0
- package/src/components/Functional/BillEntry/index.less +371 -0
- package/src/components/Functional/BillEntry/index.md +39 -0
- package/src/components/Functional/BillEntry/index.tsx +771 -0
- package/src/components/Functional/BsAntdSula/BsCascader/index.md +62 -0
- package/src/components/Functional/BsAntdSula/BsCascader/index.tsx +178 -0
- package/src/components/Functional/BsAntdSula/index.ts +2 -0
- package/src/components/Functional/DataImport/index.less +63 -0
- package/src/components/Functional/DataImport/index.md +44 -0
- package/src/components/Functional/DataImport/index.tsx +782 -0
- package/src/components/Functional/DataValidation/index.less +63 -0
- package/src/components/Functional/DataValidation/index.md +52 -0
- package/src/components/Functional/DataValidation/index.tsx +788 -0
- package/src/components/Functional/EllipsisTooltip/index.d.ts +5 -0
- package/src/components/Functional/EllipsisTooltip/index.js +36 -0
- package/src/components/Functional/EllipsisTooltip/index.md +30 -0
- package/src/components/Functional/ExportFunctions/ExportIcon/index.md +37 -0
- package/src/components/Functional/ExportFunctions/ExportIcon/index.tsx +65 -0
- package/src/components/Functional/QueryMutipleInput/index.less +37 -0
- package/src/components/Functional/QueryMutipleInput/index.md +33 -0
- package/src/components/Functional/QueryMutipleInput/index.tsx +129 -0
- package/src/components/Functional/SearchSelect/index.less +121 -0
- package/src/components/Functional/SearchSelect/index.md +141 -0
- package/src/components/Functional/SearchSelect/index.tsx +1041 -0
- package/src/components/Functional/SearchSelect/utils.ts +3 -0
- package/src/components/Functional/TreeSearchSelect/index.md +47 -0
- package/src/components/Functional/TreeSearchSelect/index.tsx +224 -0
- package/src/components/Solution/RuleComponent/CustomPlugin/CustomSelector/CustomSelectorModal.tsx +358 -0
- package/src/components/Solution/RuleComponent/CustomPlugin/CustomSelector/function.js +255 -0
- package/src/components/Solution/RuleComponent/CustomPlugin/CustomSelector/helps.tsx +58 -0
- package/src/components/Solution/RuleComponent/CustomPlugin/CustomSelector/index.tsx +129 -0
- package/src/components/Solution/RuleComponent/Formula.tsx +335 -0
- package/src/components/Solution/RuleComponent/InnerSelect.tsx +62 -0
- package/src/components/Solution/RuleComponent/RenderCompItem.tsx +743 -0
- package/src/components/Solution/RuleComponent/index.d.ts +29 -0
- package/src/components/Solution/RuleComponent/index.js +1614 -0
- package/src/components/Solution/RuleComponent/index.less +247 -0
- package/src/components/Solution/RuleComponent/renderSpecificAction.js +99 -0
- package/src/components/Solution/RuleComponent/ruleFiled.js +2587 -0
- package/src/components/Solution/RuleComponent/services.ts +13 -0
- package/src/components/Solution/RuleComponent/util.js +143 -0
- package/src/components/Solution/RuleSetter/RuleInstance.tsx +6 -0
- package/src/components/Solution/RuleSetter/baseRule.tsx +394 -0
- package/src/components/Solution/RuleSetter/function.ts +437 -0
- package/src/components/Solution/RuleSetter/index.less +221 -0
- package/src/components/Solution/RuleSetter/index.tsx +208 -0
- package/src/components/Solution/RuleSetter/service.js +276 -0
- package/src/index.ts +46 -0
- package/src/plugin/TableColumnSetting/index.less +247 -0
- package/src/plugin/TableColumnSetting/index.md +50 -0
- package/src/plugin/TableColumnSetting/index.tsx +725 -0
- package/src/plugin/TableColumnSetting/utils.ts +19 -0
- package/src/styles/bsDefault.less +32 -12
- package/src/utils/CheckOneUser/index.md +39 -0
- package/src/utils/CheckOneUser/index.ts +52 -0
- package/src/utils/CustomLoginInfo.ts +55 -0
- package/src/utils/LocalstorageUtils.ts +134 -0
- package/src/utils/TableUtils.less +52 -0
- package/src/utils/TableUtils.tsx +691 -0
- package/src/utils/auth.ts +39 -0
- package/src/utils/businessUtils.ts +434 -0
- package/src/utils/checkUtils.ts +39 -0
- package/src/utils/constant.ts +38 -0
- package/src/utils/enumConfig.ts +17 -0
- package/src/utils/getFormMode.js +12 -0
- package/src/utils/index.ts +19 -0
- package/src/utils/request.ts +53 -0
- package/src/utils/requestUtils.ts +197 -0
- package/src/utils/serialize.js +7 -0
- package/src/utils/utils.ts +267 -0
- package/src/utils/xlsxUtil.tsx +146 -0
- package/tsconfig.json +29 -0
- package/typings.d.ts +5 -0
|
@@ -0,0 +1,691 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Tooltip,
|
|
4
|
+
Badge,
|
|
5
|
+
Image,
|
|
6
|
+
Space,
|
|
7
|
+
Menu,
|
|
8
|
+
Dropdown,
|
|
9
|
+
Input,
|
|
10
|
+
Button,
|
|
11
|
+
InputNumber,
|
|
12
|
+
Popover,
|
|
13
|
+
Card,
|
|
14
|
+
Avatar,
|
|
15
|
+
} from 'antd';
|
|
16
|
+
import moment from 'moment';
|
|
17
|
+
import { FORMAT_TIME_STR, FORMAT_DAY_STR } from '@/utils/constant';
|
|
18
|
+
import noImg from '../assets/list-no-img.svg';
|
|
19
|
+
import { request } from 'bssula';
|
|
20
|
+
import styles from './TableUtils.less';
|
|
21
|
+
|
|
22
|
+
import {
|
|
23
|
+
CloseSquareOutlined,
|
|
24
|
+
CopyOutlined,
|
|
25
|
+
DeleteOutlined,
|
|
26
|
+
EditOutlined,
|
|
27
|
+
EyeOutlined,
|
|
28
|
+
SendOutlined,
|
|
29
|
+
WarningOutlined,
|
|
30
|
+
} from '@ant-design/icons';
|
|
31
|
+
type mediaListType = {
|
|
32
|
+
type: number,
|
|
33
|
+
url: string,
|
|
34
|
+
[key: string]: any;
|
|
35
|
+
}
|
|
36
|
+
type recordType = {
|
|
37
|
+
mediaList?: mediaListType;
|
|
38
|
+
[key: string]: any;
|
|
39
|
+
};
|
|
40
|
+
const getSkuImg = (
|
|
41
|
+
record: recordType,
|
|
42
|
+
) => {
|
|
43
|
+
// 默认取sku图片、当没有设置时取商品图片,商品图片也没有返回空
|
|
44
|
+
const ImgList = record.mediaList?.length && record.mediaList.filter((i: any) => i.type == 1) || [] // 获取SKU、SPU图片数组集合
|
|
45
|
+
const imgShow = ImgList?.length && ImgList[0].url || null
|
|
46
|
+
return imgShow;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const updateGuanDate = (requestParams: any, dateKeyParams: any = {}) => {
|
|
50
|
+
return {
|
|
51
|
+
type: 'modalForm',
|
|
52
|
+
width: 800,
|
|
53
|
+
props: {
|
|
54
|
+
maskClosable: false,
|
|
55
|
+
},
|
|
56
|
+
title: '修改单据日期',
|
|
57
|
+
mode: 'create', // 新建/编辑/查看
|
|
58
|
+
initialValues: (ctx: any) => {
|
|
59
|
+
if (!ctx.record) return;
|
|
60
|
+
return {
|
|
61
|
+
...ctx.record,
|
|
62
|
+
date: dateKeyParams.initDate
|
|
63
|
+
? ctx.record[dateKeyParams.initDate]
|
|
64
|
+
: ctx.record.orderDate,
|
|
65
|
+
};
|
|
66
|
+
},
|
|
67
|
+
fields: [
|
|
68
|
+
{
|
|
69
|
+
name: dateKeyParams.outDate || `date`,
|
|
70
|
+
label: '单据日期',
|
|
71
|
+
field: {
|
|
72
|
+
type: 'datepicker',
|
|
73
|
+
props: {
|
|
74
|
+
autoSize: true,
|
|
75
|
+
placeholder: '请选择',
|
|
76
|
+
disabledDate: (currentDate: any) =>
|
|
77
|
+
currentDate.valueOf() <
|
|
78
|
+
moment().subtract(Number(moment().format('D')), 'days'),
|
|
79
|
+
style: { width: '100%' },
|
|
80
|
+
format: 'YYYY-MM-DD',
|
|
81
|
+
valueFormat: true,
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
initialValue: moment().utcOffset(8),
|
|
85
|
+
rules: [{ required: true, message: '请选择单据日期' }],
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
submitButtonProps: {
|
|
89
|
+
children: '确认',
|
|
90
|
+
},
|
|
91
|
+
backButtonProps: {
|
|
92
|
+
children: '取消',
|
|
93
|
+
},
|
|
94
|
+
submit: requestParams,
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const textIcon = (type: string | number, text?: string) => {
|
|
99
|
+
if (!type) return;
|
|
100
|
+
if (type == 1) {
|
|
101
|
+
return (
|
|
102
|
+
<a className="cloumnsIconA">
|
|
103
|
+
<EyeOutlined />
|
|
104
|
+
<span>详情</span>
|
|
105
|
+
</a>
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
if (type == 2) {
|
|
109
|
+
return (
|
|
110
|
+
<a className="cloumnsIconA">
|
|
111
|
+
<EyeOutlined />
|
|
112
|
+
<span>查看</span>
|
|
113
|
+
</a>
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
if (type == 3) {
|
|
117
|
+
return (
|
|
118
|
+
<a className="cloumnsIconA">
|
|
119
|
+
<DeleteOutlined />
|
|
120
|
+
<span>删除</span>
|
|
121
|
+
</a>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
if (type == 4) {
|
|
125
|
+
return (
|
|
126
|
+
<a className="cloumnsIconA">
|
|
127
|
+
<EditOutlined />
|
|
128
|
+
<span>编辑</span>
|
|
129
|
+
</a>
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
if (type == 5) {
|
|
133
|
+
return (
|
|
134
|
+
<a className="cloumnsIconA">
|
|
135
|
+
<CopyOutlined />
|
|
136
|
+
<span>复制</span>
|
|
137
|
+
</a>
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
if (type == 6) {
|
|
141
|
+
return (
|
|
142
|
+
<a className="cloumnsIconA">
|
|
143
|
+
<CloseSquareOutlined />
|
|
144
|
+
<span>作废</span>
|
|
145
|
+
</a>
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
if (type == 7) {
|
|
149
|
+
return (
|
|
150
|
+
<a className="cloumnsIconA">
|
|
151
|
+
<WarningOutlined />
|
|
152
|
+
<span>终止</span>
|
|
153
|
+
</a>
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
if (type == 8) {
|
|
157
|
+
return (
|
|
158
|
+
<a className="cloumnsIconA">
|
|
159
|
+
<SendOutlined />
|
|
160
|
+
<span>{text}</span>
|
|
161
|
+
</a>
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
const handleTextDoubleOrId = (
|
|
167
|
+
textOne: string | undefined,
|
|
168
|
+
textTwo: string | undefined,
|
|
169
|
+
) => {
|
|
170
|
+
return (
|
|
171
|
+
<>
|
|
172
|
+
<div style={{ color: '#000', marginBottom: -8 }}>{textOne}</div>
|
|
173
|
+
<span style={{ color: '#848484' }}>ID : {textTwo}</span>
|
|
174
|
+
</>
|
|
175
|
+
);
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
const handleTextDouble = (
|
|
179
|
+
textOne: string | undefined,
|
|
180
|
+
textTwo: string | undefined,
|
|
181
|
+
) => {
|
|
182
|
+
return (
|
|
183
|
+
<>
|
|
184
|
+
<div style={{ marginBottom: -8 }}>{textOne}</div>
|
|
185
|
+
<div>{textTwo}</div>
|
|
186
|
+
</>
|
|
187
|
+
);
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
const handleTextOverflow = (text: string | undefined, width: number = 130) => {
|
|
191
|
+
return (
|
|
192
|
+
<Tooltip title={text || '--'}>
|
|
193
|
+
<span
|
|
194
|
+
style={{
|
|
195
|
+
width: width ? width + 'px' : '130px',
|
|
196
|
+
display: 'inline-block',
|
|
197
|
+
textOverflow: 'ellipsis',
|
|
198
|
+
overflow: 'hidden',
|
|
199
|
+
whiteSpace: 'nowrap',
|
|
200
|
+
position: 'relative',
|
|
201
|
+
top: '5px',
|
|
202
|
+
}}
|
|
203
|
+
>
|
|
204
|
+
{text || '--'}
|
|
205
|
+
</span>
|
|
206
|
+
</Tooltip>
|
|
207
|
+
);
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
const handleTextLineFeed = (text: string | undefined, width: number = 130) => {
|
|
211
|
+
return (
|
|
212
|
+
<Tooltip title={text || '--'}>
|
|
213
|
+
<span
|
|
214
|
+
style={{
|
|
215
|
+
width: width ? width + 'px' : '130px',
|
|
216
|
+
display: 'inline-block',
|
|
217
|
+
position: 'relative',
|
|
218
|
+
whiteSpace: 'pre-line',
|
|
219
|
+
top: '5px',
|
|
220
|
+
}}
|
|
221
|
+
>
|
|
222
|
+
{text || '--'}
|
|
223
|
+
</span>
|
|
224
|
+
</Tooltip>
|
|
225
|
+
);
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
const handleTextTooltip = (text: any) => {
|
|
229
|
+
return <Tooltip title={text || '--'}>{text || '--'}</Tooltip>;
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
const handleTextBreakSpaces = (text: any) => {
|
|
233
|
+
return (
|
|
234
|
+
<Tooltip title={text || '--'}>
|
|
235
|
+
<span
|
|
236
|
+
style={{
|
|
237
|
+
width: '130px',
|
|
238
|
+
display: 'inline-block',
|
|
239
|
+
textOverflow: 'ellipsis',
|
|
240
|
+
overflow: 'hidden',
|
|
241
|
+
whiteSpace: 'break-spaces',
|
|
242
|
+
position: 'relative',
|
|
243
|
+
top: '5px',
|
|
244
|
+
}}
|
|
245
|
+
>
|
|
246
|
+
{text || '--'}
|
|
247
|
+
</span>
|
|
248
|
+
</Tooltip>
|
|
249
|
+
);
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
const handleStatusBadge = (text: any, color: any) => {
|
|
253
|
+
return (
|
|
254
|
+
<Badge
|
|
255
|
+
style={{
|
|
256
|
+
width: '150px',
|
|
257
|
+
display: 'inline-block',
|
|
258
|
+
textOverflow: 'ellipsis',
|
|
259
|
+
overflow: 'hidden',
|
|
260
|
+
whiteSpace: 'nowrap',
|
|
261
|
+
}}
|
|
262
|
+
text={text}
|
|
263
|
+
color={color}
|
|
264
|
+
/>
|
|
265
|
+
);
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
const HandleTotalCount = (totalParams: any) => {
|
|
269
|
+
const { total = {}, totalLeft, totalRight } = totalParams;
|
|
270
|
+
return (
|
|
271
|
+
<div className="total_warp">
|
|
272
|
+
<div className="total_warp_left">
|
|
273
|
+
{totalLeft.map((d: any) => (
|
|
274
|
+
<div>
|
|
275
|
+
<span className="total_warp_num">{total[d.value] || 0}</span>
|
|
276
|
+
<span className="total_warp_title">{d.key}</span>
|
|
277
|
+
</div>
|
|
278
|
+
))}
|
|
279
|
+
</div>
|
|
280
|
+
<div className="total_warp_right">
|
|
281
|
+
{totalRight.map((d: any) => (
|
|
282
|
+
<div>
|
|
283
|
+
<span className="total_warp_num">{total[d.value] || 0}</span>
|
|
284
|
+
<span className="total_warp_title">{d.key}</span>
|
|
285
|
+
</div>
|
|
286
|
+
))}
|
|
287
|
+
</div>
|
|
288
|
+
</div>
|
|
289
|
+
);
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
const handleCommonTimeRender = (text: any, format?: any) => {
|
|
293
|
+
const formatType = format || FORMAT_TIME_STR;
|
|
294
|
+
return (text && moment(text).format(formatType)) || '--';
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
const handleCommonTimeRenderHours = (text: any, format?: any) => {
|
|
298
|
+
const formatType = format || FORMAT_DAY_STR;
|
|
299
|
+
return (text && moment(text).format(formatType)) || '--';
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
const handleTooltip = (text: any, timeTrue?: boolean) => {
|
|
303
|
+
return (
|
|
304
|
+
<Tooltip title={timeTrue ? handleCommonTimeRender(text) : text}>
|
|
305
|
+
{timeTrue ? handleCommonTimeRender(text) : text}
|
|
306
|
+
</Tooltip>
|
|
307
|
+
);
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
const handleTooltipHours = (text: any, timeTrue?: boolean) => {
|
|
311
|
+
return (
|
|
312
|
+
<Tooltip title={timeTrue ? handleCommonTimeRenderHours(text) : text}>
|
|
313
|
+
{timeTrue ? handleCommonTimeRenderHours(text) : text}
|
|
314
|
+
</Tooltip>
|
|
315
|
+
);
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
/*
|
|
319
|
+
列表展示缩略图片
|
|
320
|
+
url 图片 url
|
|
321
|
+
{
|
|
322
|
+
width: 图片宽度
|
|
323
|
+
height: 图片高度
|
|
324
|
+
}
|
|
325
|
+
*/
|
|
326
|
+
type tableColumnsImageType = {
|
|
327
|
+
width?: number | string;
|
|
328
|
+
height?: number | string;
|
|
329
|
+
[key: string]: any;
|
|
330
|
+
};
|
|
331
|
+
const tableColumnsImage = (url?: string, paramsObj?: tableColumnsImageType) => {
|
|
332
|
+
// 测试使用 测试类型缩小 随时可删除 start
|
|
333
|
+
const imgHtml = document.querySelector('.ant-image-mask-info')!;
|
|
334
|
+
if (imgHtml) {
|
|
335
|
+
let str = imgHtml?.innerHTML;
|
|
336
|
+
str = str?.replace('预览', '');
|
|
337
|
+
imgHtml.innerHTML = str;
|
|
338
|
+
}
|
|
339
|
+
// 测试使用 测试类型缩小 end
|
|
340
|
+
|
|
341
|
+
return (
|
|
342
|
+
<>
|
|
343
|
+
{url ? (
|
|
344
|
+
<div className={`clomnsImg`}>
|
|
345
|
+
<Image src={url} width="44px" height="44px" {...paramsObj}></Image>
|
|
346
|
+
</div>
|
|
347
|
+
) : (
|
|
348
|
+
<img {...paramsObj} src={noImg}></img>
|
|
349
|
+
)}
|
|
350
|
+
</>
|
|
351
|
+
);
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
interface ColumnsEditInterfave {
|
|
355
|
+
text?: string;
|
|
356
|
+
record?: any;
|
|
357
|
+
type?: string;
|
|
358
|
+
reqName: string;
|
|
359
|
+
successMessage?: string;
|
|
360
|
+
urlPathId?: boolean;
|
|
361
|
+
disabled: boolean;
|
|
362
|
+
requestProps: {
|
|
363
|
+
url: string;
|
|
364
|
+
converter?: Function;
|
|
365
|
+
method?: string;
|
|
366
|
+
};
|
|
367
|
+
[key: string]: any;
|
|
368
|
+
}
|
|
369
|
+
/*
|
|
370
|
+
text 当前项
|
|
371
|
+
record 当前行
|
|
372
|
+
table sula table 的实例
|
|
373
|
+
type 默认 input 可选 number 输入框类型
|
|
374
|
+
inpProps 输入框透传 props
|
|
375
|
+
requestProps {} bssula 的 request
|
|
376
|
+
reqName 修改数据传给后端的key
|
|
377
|
+
urlPathId 默认 true 会在 requestProps.url 上面 拼接 /:id
|
|
378
|
+
successMessage 默认提示操作成功 可传入 string
|
|
379
|
+
disabled 什么时候禁用 boolean 类型
|
|
380
|
+
*/
|
|
381
|
+
const ColumnsEdit = (props: ColumnsEditInterfave) => {
|
|
382
|
+
const {
|
|
383
|
+
text = '',
|
|
384
|
+
record,
|
|
385
|
+
table,
|
|
386
|
+
type = 'input',
|
|
387
|
+
inpProps = {},
|
|
388
|
+
requestProps = {
|
|
389
|
+
url: '',
|
|
390
|
+
},
|
|
391
|
+
reqName,
|
|
392
|
+
urlPathId = true,
|
|
393
|
+
successMessage = '操作成功',
|
|
394
|
+
disabled,
|
|
395
|
+
}: ColumnsEditInterfave = props;
|
|
396
|
+
const [visible, setvisible] = useState(false);
|
|
397
|
+
const [inputValue, setInputValue]: [
|
|
398
|
+
inputValue: string | number,
|
|
399
|
+
setInputValue: Function,
|
|
400
|
+
] = useState(text);
|
|
401
|
+
|
|
402
|
+
const onSubmit = () => {
|
|
403
|
+
const url = urlPathId
|
|
404
|
+
? requestProps.url + `/${record.id}`
|
|
405
|
+
: requestProps.url;
|
|
406
|
+
request({
|
|
407
|
+
url: url,
|
|
408
|
+
method: requestProps.method || 'patch',
|
|
409
|
+
convertParams: () => {
|
|
410
|
+
return {
|
|
411
|
+
...record,
|
|
412
|
+
[reqName]: inputValue,
|
|
413
|
+
};
|
|
414
|
+
},
|
|
415
|
+
successMessage,
|
|
416
|
+
converter(ctx: any) {
|
|
417
|
+
if (
|
|
418
|
+
requestProps.converter &&
|
|
419
|
+
typeof requestProps.converter === 'function'
|
|
420
|
+
) {
|
|
421
|
+
requestProps.converter(ctx);
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
setvisible(false);
|
|
425
|
+
table.resetTable();
|
|
426
|
+
},
|
|
427
|
+
});
|
|
428
|
+
};
|
|
429
|
+
|
|
430
|
+
const menu = (
|
|
431
|
+
<Menu>
|
|
432
|
+
<Menu.Item>
|
|
433
|
+
{type === 'input' && (
|
|
434
|
+
<Input
|
|
435
|
+
disabled={disabled}
|
|
436
|
+
onChange={(e: any) => {
|
|
437
|
+
const v = e.target.value;
|
|
438
|
+
setInputValue(v);
|
|
439
|
+
}}
|
|
440
|
+
style={{ width: 170 }}
|
|
441
|
+
value={inputValue}
|
|
442
|
+
{...inpProps}
|
|
443
|
+
></Input>
|
|
444
|
+
)}
|
|
445
|
+
{type === 'number' && (
|
|
446
|
+
<InputNumber
|
|
447
|
+
disabled={disabled}
|
|
448
|
+
onBlur={(e: any) => {
|
|
449
|
+
const v = parseFloat(e.target.value);
|
|
450
|
+
if (!isNaN(v)) {
|
|
451
|
+
setInputValue(v);
|
|
452
|
+
}
|
|
453
|
+
}}
|
|
454
|
+
style={{ width: 170 }}
|
|
455
|
+
value={inputValue}
|
|
456
|
+
{...inpProps}
|
|
457
|
+
></InputNumber>
|
|
458
|
+
)}
|
|
459
|
+
</Menu.Item>
|
|
460
|
+
<Menu.Divider />
|
|
461
|
+
<Menu.Item>
|
|
462
|
+
<div style={{ textAlign: 'right' }}>
|
|
463
|
+
<Space>
|
|
464
|
+
<Button
|
|
465
|
+
onClick={() => {
|
|
466
|
+
setvisible(false);
|
|
467
|
+
}}
|
|
468
|
+
>
|
|
469
|
+
取消
|
|
470
|
+
</Button>
|
|
471
|
+
<Button
|
|
472
|
+
type="primary"
|
|
473
|
+
disabled={disabled}
|
|
474
|
+
onClick={() => onSubmit()}
|
|
475
|
+
>
|
|
476
|
+
确定
|
|
477
|
+
</Button>
|
|
478
|
+
</Space>
|
|
479
|
+
</div>
|
|
480
|
+
</Menu.Item>
|
|
481
|
+
</Menu>
|
|
482
|
+
);
|
|
483
|
+
return (
|
|
484
|
+
<div key={record.id}>
|
|
485
|
+
<Space>
|
|
486
|
+
{text}
|
|
487
|
+
<Dropdown
|
|
488
|
+
visible={visible}
|
|
489
|
+
overlay={menu}
|
|
490
|
+
trigger={['click']}
|
|
491
|
+
placement="bottomLeft"
|
|
492
|
+
>
|
|
493
|
+
<EditOutlined
|
|
494
|
+
style={{ color: '#B0B4B7' }}
|
|
495
|
+
onClick={() => {
|
|
496
|
+
setvisible(!visible);
|
|
497
|
+
}}
|
|
498
|
+
className="cur"
|
|
499
|
+
/>
|
|
500
|
+
</Dropdown>
|
|
501
|
+
</Space>
|
|
502
|
+
</div>
|
|
503
|
+
);
|
|
504
|
+
};
|
|
505
|
+
|
|
506
|
+
type UserColumnsType = {
|
|
507
|
+
name: string; //用户名
|
|
508
|
+
department?: string; //部门
|
|
509
|
+
position?: string; //职位
|
|
510
|
+
company?: string; //公司
|
|
511
|
+
avatar?: string; //头像
|
|
512
|
+
};
|
|
513
|
+
const userColumns = (props: UserColumnsType) => {
|
|
514
|
+
const {
|
|
515
|
+
name = '',
|
|
516
|
+
department,
|
|
517
|
+
position,
|
|
518
|
+
company,
|
|
519
|
+
avatar = '',
|
|
520
|
+
}: UserColumnsType = props;
|
|
521
|
+
return (
|
|
522
|
+
<Popover
|
|
523
|
+
overlayClassName={styles.user_info_card}
|
|
524
|
+
overlayInnerStyle={{ padding: '0px' }}
|
|
525
|
+
placement="bottom"
|
|
526
|
+
title={null}
|
|
527
|
+
content={userInfoCard(props)}
|
|
528
|
+
>
|
|
529
|
+
<div className="user_columns_warp">
|
|
530
|
+
<img
|
|
531
|
+
style={{ borderRadius: '50%' }}
|
|
532
|
+
src={
|
|
533
|
+
avatar ||
|
|
534
|
+
'https://gw.alipayobjects.com/zos/rmsportal/JiqGstEfoWAOHiTxclqi.png'
|
|
535
|
+
}
|
|
536
|
+
></img>
|
|
537
|
+
<span>{name}</span>
|
|
538
|
+
</div>
|
|
539
|
+
</Popover>
|
|
540
|
+
);
|
|
541
|
+
};
|
|
542
|
+
|
|
543
|
+
const userInfoCard = (props: any) => {
|
|
544
|
+
return (
|
|
545
|
+
<Card
|
|
546
|
+
style={{ width: 200 }}
|
|
547
|
+
cover={
|
|
548
|
+
<img
|
|
549
|
+
alt="example"
|
|
550
|
+
height={90}
|
|
551
|
+
src={
|
|
552
|
+
props.avatar ||
|
|
553
|
+
'https://gw.alipayobjects.com/zos/rmsportal/JiqGstEfoWAOHiTxclqi.png'
|
|
554
|
+
}
|
|
555
|
+
/>
|
|
556
|
+
}
|
|
557
|
+
>
|
|
558
|
+
<div className={styles.cardContent} style={{ padding: '0 15px' }}>
|
|
559
|
+
<div className={styles.user_card_header}>
|
|
560
|
+
<Avatar
|
|
561
|
+
style={{ border: '2px solid #ffffff' }}
|
|
562
|
+
size={64}
|
|
563
|
+
src={
|
|
564
|
+
props.avatar ||
|
|
565
|
+
'https://gw.alipayobjects.com/zos/rmsportal/JiqGstEfoWAOHiTxclqi.png'
|
|
566
|
+
}
|
|
567
|
+
/>
|
|
568
|
+
<div className={styles.card_name}>{props.name}</div>
|
|
569
|
+
<div className={styles.card_company}>{props.company || 'XXXXX'}</div>
|
|
570
|
+
</div>
|
|
571
|
+
<p className={styles.card_detailInfo}>
|
|
572
|
+
部门:{' '}
|
|
573
|
+
<span className={styles.card_department}>
|
|
574
|
+
{props.department || 'XXXXX'}
|
|
575
|
+
</span>
|
|
576
|
+
</p>
|
|
577
|
+
<p className={styles.card_detailInfo}>
|
|
578
|
+
职位: {props.position || 'XXXXX'}
|
|
579
|
+
</p>
|
|
580
|
+
</div>
|
|
581
|
+
</Card>
|
|
582
|
+
);
|
|
583
|
+
};
|
|
584
|
+
|
|
585
|
+
//设置queryTable默认列宽
|
|
586
|
+
const getItemDefaultWidth = (item: any) => {
|
|
587
|
+
let defaultWidth = 200;
|
|
588
|
+
let lowerCaseKey = (item.key || item.dataIndex).toLowerCase();
|
|
589
|
+
switch (true) {
|
|
590
|
+
case lowerCaseKey.indexOf('number') > -1:
|
|
591
|
+
case lowerCaseKey.indexOf('quantity') > -1:
|
|
592
|
+
case lowerCaseKey.indexOf('amount') > -1:
|
|
593
|
+
defaultWidth = 90;
|
|
594
|
+
break;
|
|
595
|
+
case lowerCaseKey.indexOf('no') > -1:
|
|
596
|
+
defaultWidth = 180;
|
|
597
|
+
break;
|
|
598
|
+
case lowerCaseKey.indexOf('code') > -1:
|
|
599
|
+
defaultWidth = 170;
|
|
600
|
+
break;
|
|
601
|
+
case lowerCaseKey.indexOf('time') > -1:
|
|
602
|
+
defaultWidth = 130;
|
|
603
|
+
break;
|
|
604
|
+
case lowerCaseKey.indexOf('status') > -1:
|
|
605
|
+
defaultWidth = 100;
|
|
606
|
+
break;
|
|
607
|
+
case lowerCaseKey.indexOf('user') > -1:
|
|
608
|
+
defaultWidth = 130;
|
|
609
|
+
break;
|
|
610
|
+
default:
|
|
611
|
+
break;
|
|
612
|
+
}
|
|
613
|
+
console.log(defaultWidth);
|
|
614
|
+
return defaultWidth;
|
|
615
|
+
};
|
|
616
|
+
|
|
617
|
+
const sulaTableRenderTooltip = ({ text }: any) => {
|
|
618
|
+
return (
|
|
619
|
+
<Tooltip placement="topLeft" title={text}>
|
|
620
|
+
<span>{text}</span>
|
|
621
|
+
</Tooltip>
|
|
622
|
+
);
|
|
623
|
+
};
|
|
624
|
+
|
|
625
|
+
//处理数字0不显示问题
|
|
626
|
+
const renderNumberText = ({ text }: any) => {
|
|
627
|
+
if (text == 0) {
|
|
628
|
+
return text;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
if (!text) {
|
|
632
|
+
return '--';
|
|
633
|
+
} else {
|
|
634
|
+
return text;
|
|
635
|
+
}
|
|
636
|
+
};
|
|
637
|
+
|
|
638
|
+
const renderFixed2 = (text: any) =>
|
|
639
|
+
(text + '').indexOf('.') !== -1 ? parseFloat(text).toFixed(2) : text;
|
|
640
|
+
|
|
641
|
+
// 自定义标签
|
|
642
|
+
const handleTextWarpCustom = (text: any, style = {}) => {
|
|
643
|
+
return (
|
|
644
|
+
<div
|
|
645
|
+
style={{
|
|
646
|
+
width: '100%',
|
|
647
|
+
position: 'relative',
|
|
648
|
+
whiteSpace: 'initial',
|
|
649
|
+
...style,
|
|
650
|
+
}}
|
|
651
|
+
>
|
|
652
|
+
{text}
|
|
653
|
+
</div>
|
|
654
|
+
);
|
|
655
|
+
};
|
|
656
|
+
|
|
657
|
+
const calculateValidPeriod = (start: any, end: any) => {
|
|
658
|
+
return `${moment(end).diff(start, 'days')} 天` || '--';
|
|
659
|
+
};
|
|
660
|
+
|
|
661
|
+
const handleTextWarp = (text: any) => {
|
|
662
|
+
return handleTextWarpCustom(text, { width: '150%' });
|
|
663
|
+
};
|
|
664
|
+
|
|
665
|
+
export {
|
|
666
|
+
getSkuImg,
|
|
667
|
+
updateGuanDate,
|
|
668
|
+
textIcon,
|
|
669
|
+
handleTextDoubleOrId,
|
|
670
|
+
handleTextDouble,
|
|
671
|
+
handleTextOverflow,
|
|
672
|
+
handleTextLineFeed,
|
|
673
|
+
handleTextTooltip,
|
|
674
|
+
handleTextBreakSpaces,
|
|
675
|
+
handleStatusBadge,
|
|
676
|
+
HandleTotalCount,
|
|
677
|
+
handleTooltip,
|
|
678
|
+
handleCommonTimeRender,
|
|
679
|
+
handleTooltipHours,
|
|
680
|
+
tableColumnsImage,
|
|
681
|
+
ColumnsEdit,
|
|
682
|
+
userColumns,
|
|
683
|
+
userInfoCard,
|
|
684
|
+
getItemDefaultWidth,
|
|
685
|
+
renderNumberText,
|
|
686
|
+
sulaTableRenderTooltip,
|
|
687
|
+
renderFixed2,
|
|
688
|
+
handleTextWarpCustom,
|
|
689
|
+
handleTextWarp,
|
|
690
|
+
calculateValidPeriod
|
|
691
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { getMenuAuthDataKey } from '@/utils/LocalstorageUtils';
|
|
2
|
+
|
|
3
|
+
// 判断某个按钮/菜单 是否有权限,返回布尔值
|
|
4
|
+
export const authFunc = (code: string) => {
|
|
5
|
+
if (!shouldUseAuth() || !code) return true;
|
|
6
|
+
return JSON.parse(localStorage.getItem(getMenuAuthDataKey()) || '[]')?.find(
|
|
7
|
+
(d: any) => d === code,
|
|
8
|
+
);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// 判断一群按钮是否有权限,返回数组-数组每项为布尔值,通过集合index映射按钮权限关系
|
|
12
|
+
export const handleJudgeAuthButtons = (buttonCodeArray: any[]) => {
|
|
13
|
+
// 处理单按钮 和 多个按钮
|
|
14
|
+
let result =
|
|
15
|
+
buttonCodeArray.length > 1 ? buttonCodeArray.map(() => true) : true;
|
|
16
|
+
const authButton = localStorage.getItem(getMenuAuthDataKey())
|
|
17
|
+
? JSON.parse(localStorage.getItem(getMenuAuthDataKey()) as string)
|
|
18
|
+
: [];
|
|
19
|
+
buttonCodeArray.forEach((item: any, index: number) => {
|
|
20
|
+
if (
|
|
21
|
+
!authButton.filter((itemInner: any) => item?.indexOf?.(itemInner) >= 0)
|
|
22
|
+
.length
|
|
23
|
+
) {
|
|
24
|
+
if (buttonCodeArray.length > 1) {
|
|
25
|
+
// @ts-ignore
|
|
26
|
+
result[index] = false;
|
|
27
|
+
} else {
|
|
28
|
+
result = false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// 判断何时菜单权限和表格权限生效
|
|
36
|
+
export const shouldUseAuth = () => {
|
|
37
|
+
// @ts-ignore
|
|
38
|
+
return window.__POWERED_BY_WUJIE__ ? true : false;
|
|
39
|
+
};
|