zy-react-library 1.1.1 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/README.md +5 -1
  2. package/components/Cascader/Area/index.js +1 -20
  3. package/components/Cascader/Basic/index.js +1 -64
  4. package/components/Cascader/Dictionary/index.js +1 -42
  5. package/components/Cascader/Industry/index.js +1 -20
  6. package/components/Editor/index.js +1 -102
  7. package/components/FormBuilder/FormBuilder.js +1 -87
  8. package/components/FormBuilder/FormItemsRenderer.js +1 -591
  9. package/components/FormBuilder/index.js +1 -3
  10. package/components/HeaderBack/index.js +1 -37
  11. package/components/HiddenInfo/gwj/index.js +1 -518
  12. package/components/Icon/AddIcon/index.js +1 -9
  13. package/components/Icon/BackIcon/index.js +1 -9
  14. package/components/Icon/DeleteIcon/index.js +1 -9
  15. package/components/Icon/DownloadIcon/index.js +1 -9
  16. package/components/Icon/EditIcon/index.js +1 -9
  17. package/components/Icon/ExportIcon/index.js +1 -9
  18. package/components/Icon/ImportIcon/index.js +1 -9
  19. package/components/Icon/LocationIcon/index.js +1 -9
  20. package/components/Icon/PrintIcon/index.js +1 -9
  21. package/components/Icon/ResetIcon/index.js +1 -9
  22. package/components/Icon/SearchIcon/index.js +1 -9
  23. package/components/Icon/VideoIcon/index.js +1 -9
  24. package/components/Icon/ViewIcon/index.js +1 -9
  25. package/components/ImportFile/index.js +1 -91
  26. package/components/LeftTree/Area/index.js +1 -15
  27. package/components/LeftTree/Basic/index.js +1 -171
  28. package/components/LeftTree/Department/Gwj/index.js +1 -32
  29. package/components/LeftTree/Dictionary/index.js +1 -42
  30. package/components/Map/MapSelector.js +1 -254
  31. package/components/Map/index.js +1 -77
  32. package/components/Page/index.js +1 -50
  33. package/components/Pdf/index.js +1 -134
  34. package/components/PreviewImg/index.js +1 -32
  35. package/components/PreviewPdf/index.js +1 -86
  36. package/components/Search/index.js +1 -141
  37. package/components/Select/Basic/index.js +1 -76
  38. package/components/Select/Dictionary/index.js +1 -42
  39. package/components/Select/Personnel/Gwj/index.js +1 -49
  40. package/components/SelectCreate/index.js +1 -55
  41. package/components/SelectTree/Area/index.js +1 -26
  42. package/components/SelectTree/Basic/index.js +1 -102
  43. package/components/SelectTree/Department/Gwj/index.js +1 -46
  44. package/components/SelectTree/Dictionary/index.js +1 -42
  45. package/components/SelectTree/HiddenLevel/Gwj/index.js +1 -72
  46. package/components/SelectTree/HiddenPart/Gwj/index.js +1 -39
  47. package/components/SelectTree/Industry/index.js +1 -27
  48. package/components/Signature/index.js +1 -94
  49. package/components/Table/index.js +1 -73
  50. package/components/Table/index.less +7 -1
  51. package/components/TooltipPreviewImg/index.js +1 -27
  52. package/components/Upload/index.js +1 -275
  53. package/components/Video/AliPlayer.js +1 -160
  54. package/components/Video/index.js +1 -90
  55. package/css/common.less +4 -0
  56. package/enum/dictionary/index.js +1 -7
  57. package/enum/formItemRender/index.js +1 -37
  58. package/enum/hidden/gwj/index.js +1 -31
  59. package/enum/uploadFile/gwj/index.js +1 -176
  60. package/hooks/useDeleteFile/index.js +1 -101
  61. package/hooks/useDictionary/index.js +1 -66
  62. package/hooks/useDownloadBlob/index.js +1 -79
  63. package/hooks/useDownloadFile/index.js +1 -81
  64. package/hooks/useGetFile/index.js +1 -74
  65. package/hooks/useGetUrlQuery/index.js +1 -16
  66. package/hooks/useGetUserInfo/index.js +1 -49
  67. package/hooks/useIdle/index.js +1 -67
  68. package/hooks/useImportFile/index.js +1 -59
  69. package/hooks/useIsExistenceDuplicateSelection/index.js +1 -20
  70. package/hooks/useTable/index.js +1 -113
  71. package/hooks/useUploadFile/index.js +1 -149
  72. package/hooks/useUrlQueryCriteria/index.js +1 -77
  73. package/package.json +18 -1
  74. package/regular/index.js +1 -61
  75. package/utils/index.js +1 -587
@@ -1,176 +1 @@
1
- /**
2
- * 文件上传类型枚举
3
- */
4
- /**
5
- * 文件上传类型枚举
6
- */
7
- export const UPLOAD_FILE_TYPE_ENUM = {
8
- 10: 10, // labor_contract_image - 劳动合同图片
9
- 11: 11, // commercial_insurance_image - 商业保险图片
10
- 12: 12, // certificate_information - 证书信息
11
- 13: 13, // user_avatar - 用户头像
12
- 14: 14, // id_card_photo - 身份证照片
13
- 15: 15, // social_security_card_photo - 社保卡照片
14
- 16: 16, // work_related_injury_insurance_certificate - 工伤保险凭证
15
- 19: 19, // three_level_safety_education_training - 三级教育培训
16
- 601: 601, // gate_access_vehicle_license_photo - 门口门禁车辆行驶证照片
17
- 602: 602, // gate_access_vehicle_photo - 门口门禁车辆车辆照片
18
- 603: 603, // gate_access_vehicle_attachment - 门口门禁车辆附件
19
- 604: 604, // emission_standard_certificate - 排放标准证明
20
- 605: 605, // motor_vehicle_registration_certificate_green_book - 机动车登记证书(绿本)
21
- 3: 3, // hidden_danger_photo - 隐患照片
22
- 4: 4, // hidden_danger_rectification_photo - 隐患整改照片
23
- 5: 5, // hidden_danger_verification_photo - 隐患验证照片
24
- 6: 6, // certificate_photo - 证书照片
25
- 7: 7, // confined_space_plan - 受限空间平面图
26
- 8: 8, // hidden_danger_rectification_plan - 隐患整改方案图
27
- 9: 9, // confined_space_confirmation_signature - 有限空间确认人签字
28
- 17: 17, // special_equipment_inspection_photo - 特种设备巡检照片
29
- 18: 18, // personnel_certificate - 人员证书
30
- 20: 20, // major_hazard_source_alarm_before_handling_photo - 重大危险源报警处置前照片
31
- 21: 21, // major_hazard_source_alarm_after_handling_photo - 重大危险源报警处置后照片
32
- 22: 22, // smart_access_control_external_vehicle_driver_license_photo - 智能门禁外来车辆驾驶证照片
33
- 23: 23, // smart_access_control_external_vehicle_registration_photo - 智能门禁外来车辆行驶证照片
34
- 50: 50, // safety_and_environmental_inspection_final_acceptance_image - 安全环保检查终验图片
35
- 101: 101, // hidden_danger_extension_temporary_measures_attachment - 隐患延期临时措施附件
36
- 102: 102, // hidden_danger_video - 隐患视频
37
- 105: 105, // blind_plate_position_map - 盲板位置图
38
- 106: 106, // temporary_disposal_information - 临时处置信息
39
- 107: 107, // rectification_suggestions_and_plan - 整改建议及方案
40
- 108: 108, // major_hidden_danger_investigation_report - 重大隐患上传隐患调查报告
41
- 109: 109, // major_hidden_danger_safety_committee_or_party_committee_resolution_record - 重大隐患安委会或党委会决议记录
42
- 110: 110, // significant_hidden_danger_rectification_temporary_disposal_measures - 较大隐患整改-临时处置措施
43
- 111: 111, // significant_hidden_danger_rectification_hidden_danger_rectification_process_record - 较大隐患整改-隐患整改过程记录
44
- 112: 112, // supplement_major_hidden_danger_information - 补充重大隐患信息
45
- 113: 113, // safety_committee_office_meeting_record - 安委会办公室会议记录
46
- 114: 114, // alarm_photo - 报警图片
47
- 115: 115, // fire_equipment_type_qualification_photo - 消防器材类型合格表中照片
48
- 116: 116, // hot_work_personnel_photo - 动火人图片
49
- 117: 117, // safety_pledge_signature - 安全承诺书签名
50
- 118: 118, // hot_work_unit_responsible_person_confirmation_signature - 动火单位负责人确认签字
51
- 119: 119, // on_site_jurisdiction_unit_responsible_person_signature - 现场管辖单位负责人签字
52
- 120: 120, // hot_work_permit_issuing_unit_signature - 动火许可证签发单位签字
53
- 121: 121, // hot_work_permit_signature - 动火许可证签字
54
- 122: 122, // pre_hot_work_jurisdiction_unit_confirmation_signature - 动火前管辖单位确认签字
55
- 123: 123, // on_site_responsible_person_confirmation_signature - 现场负责人确实签字
56
- 124: 124, // post_hot_work_site_jurisdiction_unit_confirmation - 动火后现场管辖单位确认
57
- 125: 125, // delayed_fire_monitoring_pictures - 延迟监火图片
58
- 126: 126, // safety_and_environmental_inspection_initiation_signature - 安全环保检查发起签字(弃用)
59
- 127: 127, // inspector_confirmation_signature - 检查人确认签字(弃用)
60
- 128: 128, // inspected_person_confirmation_signature - 被检查人确认签字(弃用)
61
- 129: 129, // safety_and_environmental_inspection_appeal_signature - 安全环保检查申辩签字(弃用)
62
- 130: 130, // hk_safety_committee_office_director_safety_director_issuance - (港股安委办主任)安全总监签发
63
- 131: 131, // hot_work_contracting_unit_signature - 动火发包单位签字
64
- 132: 132, // safety_director_approval - 安全总监审批
65
- 133: 133, // branch_safety_director_approval - 分公司安全总监审批
66
- 134: 134, // project_authority_review_signature - 项目主管部门负责人审核
67
- 135: 135, // branch_manager_approval_signature - 分公司主要负责人签批
68
- 136: 136, // accident_incident - 事故/事件
69
- 137: 137, // accident_incident - 事故/事件
70
- 138: 138, // hidden_disposal_plan - 隐患处置方案
71
- 139: 139, // safety_environmental_inspection_inspection_signature - 安全环保检查-检查签字
72
- 140: 140, // safety_environmental_inspection_inspection_situation - 安全环保检查-检查情况
73
- 141: 141, // safety_environmental_inspection_inspector_signature - 安全环保检查-检查人签字
74
- 142: 142, // safety_environmental_inspection_inspected_signature - 安全环保检查-被检查人签字
75
- 143: 143, // safety_environmental_inspection_inspected_file - 安全环保检查-被检查文件
76
- 144: 144, // safety_environmental_inspection_defense_signature - 安全环保检查-申辩签字
77
- 146: 146, // safety_environmental_inspection_acceptance - 安全环保检查-验收
78
- 145: 145, // qualified_list_inspection - 清单检查合格
79
- 147: 147, // hidden_qualified_listInspection_signature - 隐患清单排查签字
80
- 148: 148, // special_qualification - 相关方-专项资质
81
- 149: 149, // safety_qualification - 相关方-安全资质(弃用,全部改成使用148)
82
- 150: 150, // promise_bookmark_photo - 安全承诺签字
83
- 151: 151, // project_related_materials - 相关方-项目相关资料
84
- 152: 152, // legal_and_regulatory_database - 法律法规库
85
- 153: 153, // regulations_resource_library - 安全生产操作规程资源库
86
- 154: 154, // responsibility_based_resource_library - 安全生产责任制资源库
87
- 155: 155, // institutional_resource_library - 安全生产管理制度资源库
88
- 156: 156, // security_management_agreement - 相关方-安全管理协议
89
- };
90
-
91
- /**
92
- * 文件上传类型对应的 path 枚举
93
- */
94
- export const UPLOAD_FILE_PATH_ENUM = {
95
- 10: "labor_contract_image",
96
- 11: "commercial_insurance_image",
97
- 12: "certificate_information",
98
- 13: "user_avatar",
99
- 14: "id_card_photo",
100
- 15: "social_security_card_photo",
101
- 16: "work_related_injury_insurance_certificate",
102
- 19: "three_level_safety_education_training",
103
- 601: "gate_access_vehicle_license_photo",
104
- 602: "gate_access_vehicle_photo",
105
- 603: "gate_access_vehicle_attachment",
106
- 604: "emission_standard_certificate",
107
- 605: "motor_vehicle_registration_certificate_green_book",
108
- 3: "hidden_danger_photo",
109
- 4: "hidden_danger_rectification_photo",
110
- 5: "hidden_danger_verification_photo",
111
- 6: "certificate_photo",
112
- 7: "confined_space_plan",
113
- 8: "hidden_danger_rectification_plan",
114
- 9: "confined_space_confirmation_signature",
115
- 17: "special_equipment_inspection_photo",
116
- 18: "personnel_certificate",
117
- 20: "major_hazard_source_alarm_before_handling_photo",
118
- 21: "major_hazard_source_alarm_after_handling_photo",
119
- 22: "smart_access_control_external_vehicle_driver_license_photo",
120
- 23: "smart_access_control_external_vehicle_registration_photo",
121
- 50: "safety_and_environmental_inspection_final_acceptance_image",
122
- 101: "hidden_danger_extension_temporary_measures_attachment",
123
- 102: "hidden_danger_video",
124
- 105: "blind_plate_position_map",
125
- 106: "temporary_disposal_information",
126
- 107: "rectification_suggestions_and_plan",
127
- 108: "major_hidden_danger_investigation_report",
128
- 109: "major_hidden_danger_safety_committee_or_party_committee_resolution_record",
129
- 110: "significant_hidden_danger_rectification_temporary_disposal_measures",
130
- 111: "significant_hidden_danger_rectification_hidden_danger_rectification_process_record",
131
- 112: "supplement_major_hidden_danger_information",
132
- 113: "safety_committee_office_meeting_record",
133
- 114: "alarm_photo",
134
- 115: "fire_equipment_type_qualification_photo",
135
- 116: "hot_work_personnel_photo",
136
- 117: "safety_pledge_signature",
137
- 118: "hot_work_unit_responsible_person_confirmation_signature",
138
- 119: "on_site_jurisdiction_unit_responsible_person_signature",
139
- 120: "hot_work_permit_issuing_unit_signature",
140
- 121: "hot_work_permit_signature",
141
- 122: "pre_hot_work_jurisdiction_unit_confirmation_signature",
142
- 123: "on_site_responsible_person_confirmation_signature",
143
- 124: "post_hot_work_site_jurisdiction_unit_confirmation",
144
- 125: "delayed_fire_monitoring_pictures",
145
- 126: "safety_and_environmental_inspection_initiation_signature",
146
- 127: "inspector_confirmation_signature",
147
- 128: "inspected_person_confirmation_signature",
148
- 129: "safety_and_environmental_inspection_appeal_signature",
149
- 130: "hk_safety_committee_office_director_safety_director_issuance",
150
- 131: "hot_work_contracting_unit_signature",
151
- 132: "safety_director_approval",
152
- 133: "branch_safety_director_approval",
153
- 134: "project_authority_review_signature",
154
- 135: "branch_manager_approval_signature",
155
- 136: "accident_incident",
156
- 137: "accident_incident",
157
- 138: "hidden_disposal_plan",
158
- 139: "safety_environmental_inspection_inspection_signature",
159
- 140: "safety_environmental_inspection_inspection_situation",
160
- 141: "safety_environmental_inspection_inspector_signature",
161
- 142: "safety_environmental_inspection_inspected_signature",
162
- 143: "safety_environmental_inspection_inspected_file",
163
- 144: "safety_environmental_inspection_defense_signature",
164
- 145: "qualified_list_inspection",
165
- 146: "safety_environmental_inspection_acceptance",
166
- 147: "hidden_qualified_listInspection_signature",
167
- 148: "special_qualification",
168
- 149: "safety_qualification",
169
- 150: "promise_bookmark_photo",
170
- 151: "project_related_materials",
171
- 152: "legal_and_regulatory_database",
172
- 153: "regulations_resource_library",
173
- 154: "responsibility_based_resource_library",
174
- 155: "institutional_resource_library",
175
- 156: "security_management_agreement",
176
- };
1
+ const e={10:10,11:11,12:12,13:13,14:14,15:15,16:16,19:19,601:601,602:602,603:603,604:604,605:605,3:3,4:4,5:5,6:6,7:7,8:8,9:9,17:17,18:18,20:20,21:21,22:22,23:23,50:50,101:101,102:102,105:105,106:106,107:107,108:108,109:109,110:110,111:111,112:112,113:113,114:114,115:115,116:116,117:117,118:118,119:119,120:120,121:121,122:122,123:123,124:124,125:125,126:126,127:127,128:128,129:129,130:130,131:131,132:132,133:133,134:134,135:135,136:136,137:137,138:138,139:139,140:140,141:141,142:142,143:143,144:144,146:146,145:145,147:147,148:148,149:149,150:150,151:151,152:152,153:153,154:154,155:155,156:156},_={10:"labor_contract_image",11:"commercial_insurance_image",12:"certificate_information",13:"user_avatar",14:"id_card_photo",15:"social_security_card_photo",16:"work_related_injury_insurance_certificate",19:"three_level_safety_education_training",601:"gate_access_vehicle_license_photo",602:"gate_access_vehicle_photo",603:"gate_access_vehicle_attachment",604:"emission_standard_certificate",605:"motor_vehicle_registration_certificate_green_book",3:"hidden_danger_photo",4:"hidden_danger_rectification_photo",5:"hidden_danger_verification_photo",6:"certificate_photo",7:"confined_space_plan",8:"hidden_danger_rectification_plan",9:"confined_space_confirmation_signature",17:"special_equipment_inspection_photo",18:"personnel_certificate",20:"major_hazard_source_alarm_before_handling_photo",21:"major_hazard_source_alarm_after_handling_photo",22:"smart_access_control_external_vehicle_driver_license_photo",23:"smart_access_control_external_vehicle_registration_photo",50:"safety_and_environmental_inspection_final_acceptance_image",101:"hidden_danger_extension_temporary_measures_attachment",102:"hidden_danger_video",105:"blind_plate_position_map",106:"temporary_disposal_information",107:"rectification_suggestions_and_plan",108:"major_hidden_danger_investigation_report",109:"major_hidden_danger_safety_committee_or_party_committee_resolution_record",110:"significant_hidden_danger_rectification_temporary_disposal_measures",111:"significant_hidden_danger_rectification_hidden_danger_rectification_process_record",112:"supplement_major_hidden_danger_information",113:"safety_committee_office_meeting_record",114:"alarm_photo",115:"fire_equipment_type_qualification_photo",116:"hot_work_personnel_photo",117:"safety_pledge_signature",118:"hot_work_unit_responsible_person_confirmation_signature",119:"on_site_jurisdiction_unit_responsible_person_signature",120:"hot_work_permit_issuing_unit_signature",121:"hot_work_permit_signature",122:"pre_hot_work_jurisdiction_unit_confirmation_signature",123:"on_site_responsible_person_confirmation_signature",124:"post_hot_work_site_jurisdiction_unit_confirmation",125:"delayed_fire_monitoring_pictures",126:"safety_and_environmental_inspection_initiation_signature",127:"inspector_confirmation_signature",128:"inspected_person_confirmation_signature",129:"safety_and_environmental_inspection_appeal_signature",130:"hk_safety_committee_office_director_safety_director_issuance",131:"hot_work_contracting_unit_signature",132:"safety_director_approval",133:"branch_safety_director_approval",134:"project_authority_review_signature",135:"branch_manager_approval_signature",136:"accident_incident",137:"accident_incident",138:"hidden_disposal_plan",139:"safety_environmental_inspection_inspection_signature",140:"safety_environmental_inspection_inspection_situation",141:"safety_environmental_inspection_inspector_signature",142:"safety_environmental_inspection_inspected_signature",143:"safety_environmental_inspection_inspected_file",144:"safety_environmental_inspection_defense_signature",145:"qualified_list_inspection",146:"safety_environmental_inspection_acceptance",147:"hidden_qualified_listInspection_signature",148:"special_qualification",149:"safety_qualification",150:"promise_bookmark_photo",151:"project_related_materials",152:"legal_and_regulatory_database",153:"regulations_resource_library",154:"responsibility_based_resource_library",155:"institutional_resource_library",156:"security_management_agreement"};export{_ as UPLOAD_FILE_PATH_ENUM,e as UPLOAD_FILE_TYPE_ENUM};
@@ -1,101 +1 @@
1
- import { request } from "@cqsjjb/jjb-common-lib/http";
2
- import { useState } from "react";
3
-
4
- /**
5
- * 删除文件
6
- */
7
- function useDeleteFile(returnType = "object") {
8
- // loading状态
9
- const [loading, setLoading] = useState(false);
10
- // 用于跟踪进行中的请求数量(不暴露给外部)
11
- let requestCount = 0;
12
-
13
- // 删除文件
14
- const deleteFile = (options) => {
15
- if (!options) {
16
- console.error("请传入 options");
17
- return;
18
- }
19
-
20
- // 增加请求数量并设置loading状态
21
- requestCount++;
22
- if (requestCount > 0) {
23
- setLoading(true);
24
- }
25
-
26
- return new Promise((resolve, reject) => {
27
- const { files = [], single = true } = options;
28
-
29
- if (!files) {
30
- console.error("请传入 files");
31
- return;
32
- }
33
- if (!Array.isArray(files)) {
34
- console.error("请传入有效的 files");
35
- return;
36
- }
37
-
38
- // 如果没有文件则直接返回
39
- if (files.length === 0) {
40
- requestCount--;
41
- if (requestCount <= 0) {
42
- setLoading(false);
43
- }
44
- resolve();
45
- return;
46
- }
47
-
48
- // 单文件并且没有文件路径则直接返回
49
- if (single) {
50
- const firstFile = files[0];
51
- if (!firstFile.filePath) {
52
- requestCount--;
53
- if (requestCount <= 0) {
54
- setLoading(false);
55
- }
56
- resolve();
57
- return;
58
- }
59
- }
60
- // 多文件并且没有文件id则直接返回
61
- else {
62
- const validFiles = files.filter(f => f.id);
63
- if (validFiles.length === 0) {
64
- requestCount--;
65
- if (requestCount <= 0) {
66
- setLoading(false);
67
- }
68
- resolve();
69
- return;
70
- }
71
- }
72
-
73
- // 发送请求
74
- request(
75
- single
76
- ? `/basicInfo/imgFiles/delete?filePath=${files[0].filePath}`
77
- : `/basicInfo/imgFiles/ids?ids=${files.filter(f => f.id).map(f => f.id)}`,
78
- "delete",
79
- )
80
- .then((res) => {
81
- resolve(res.data);
82
- })
83
- .catch((err) => {
84
- reject(err);
85
- })
86
- .finally(() => {
87
- // 减少请求数量并在没有进行中的请求时设置loading为false
88
- requestCount--;
89
- if (requestCount <= 0) {
90
- setLoading(false);
91
- }
92
- });
93
- });
94
- };
95
-
96
- if (returnType === "array")
97
- return [loading, deleteFile];
98
- return { loading, deleteFile };
99
- }
100
-
101
- export default useDeleteFile;
1
+ import{request as e}from"@cqsjjb/jjb-common-lib/http";import{useState as i}from"react";function r(r="object"){const[t,o]=i(!1);let l=0;const n=i=>{if(i)return l++,l>0&&o(!0),new Promise((r,t)=>{const{files:n=[],single:s=!0}=i;if(n)if(Array.isArray(n)){if(0===n.length)return l--,l<=0&&o(!1),void r();if(s){if(!n[0].filePath)return l--,l<=0&&o(!1),void r()}else if(0===n.filter(e=>e.id).length)return l--,l<=0&&o(!1),void r();e(s?`/basicInfo/imgFiles/delete?filePath=${n[0].filePath}`:`/basicInfo/imgFiles/ids?ids=${n.filter(e=>e.id).map(e=>e.id)}`,"delete").then(e=>{r(e.data)}).catch(e=>{t(e)}).finally(()=>{l--,l<=0&&o(!1)})}else console.error("请传入有效的 files");else console.error("请传入 files")});console.error("请传入 options")};return"array"===r?[t,n]:{loading:t,deleteFile:n}}export{r as default};
@@ -1,66 +1 @@
1
- import { request } from "@cqsjjb/jjb-common-lib/http";
2
- import { useState } from "react";
3
- import { DICTIONARY_APP_KEY_ENUM } from "../../enum/dictionary";
4
-
5
- /**
6
- * 获取数据字典
7
- */
8
- function useDictionary(returnType = "object") {
9
- // loading状态
10
- const [loading, setLoading] = useState(false);
11
- // 用于跟踪进行中的请求数量(不暴露给外部)
12
- let requestCount = 0;
13
-
14
- // 获取数据字典
15
- const getDictionary = (options) => {
16
- if (!options) {
17
- console.error("请传入 options");
18
- return;
19
- }
20
-
21
- // 增加请求数量并设置loading状态
22
- requestCount++;
23
- if (requestCount > 0) {
24
- setLoading(true);
25
- }
26
-
27
- return new Promise((resolve, reject) => {
28
- const { appKey = DICTIONARY_APP_KEY_ENUM.DEFAULT, dictValue } = options;
29
-
30
- if (!Object.values(DICTIONARY_APP_KEY_ENUM).includes(appKey)) {
31
- console.error("传入的 options.appKey 不在 DICTIONARY_APP_KEY_ENUM 中");
32
- return;
33
- }
34
- if (!dictValue) {
35
- console.error("请传入 options.dictValue");
36
- return;
37
- }
38
-
39
- // 发送请求
40
- request(
41
- "/config/dict-trees/list/by/dictValues",
42
- "get",
43
- { appKey, dictValue },
44
- )
45
- .then((res) => {
46
- resolve(res.data);
47
- })
48
- .catch((err) => {
49
- reject(err);
50
- })
51
- .finally(() => {
52
- // 减少请求数量并在没有进行中的请求时设置loading为false
53
- requestCount--;
54
- if (requestCount <= 0) {
55
- setLoading(false);
56
- }
57
- });
58
- });
59
- };
60
-
61
- if (returnType === "array")
62
- return [loading, getDictionary];
63
- return { loading, getDictionary };
64
- }
65
-
66
- export default useDictionary;
1
+ import{request as o}from"@cqsjjb/jjb-common-lib/http";import{useState as t}from"react";import{DICTIONARY_APP_KEY_ENUM as e}from"../../enum/dictionary/index.js";function r(r="object"){const[i,n]=t(!1);let c=0;const a=t=>{if(t)return c++,c>0&&n(!0),new Promise((r,i)=>{const{appKey:a=e.DEFAULT,dictValue:s}=t;Object.values(e).includes(a)?s?o("/config/dict-trees/list/by/dictValues","get",{appKey:a,dictValue:s}).then(o=>{r(o.data)}).catch(o=>{i(o)}).finally(()=>{c--,c<=0&&n(!1)}):console.error("请传入 options.dictValue"):console.error("传入的 options.appKey 不在 DICTIONARY_APP_KEY_ENUM 中")});console.error("请传入 options")};return"array"===r?[i,a]:{loading:i,getDictionary:a}}export{r as default};
@@ -1,79 +1 @@
1
- import { message } from "antd";
2
- import dayjs from "dayjs";
3
- import { useState } from "react";
4
-
5
- /**
6
- * 下载Blob流文件
7
- */
8
- export default function useDownloadBlob(returnType = "object") {
9
- // loading状态
10
- const [loading, setLoading] = useState(false);
11
- // 用于跟踪进行中的请求数量(不暴露给外部)
12
- let requestCount = 0;
13
-
14
- // 下载Blob流文件
15
- const downloadBlob = (url, options) => {
16
- // 增加请求数量并设置loading状态
17
- requestCount++;
18
- if (requestCount > 0) {
19
- setLoading(true);
20
- }
21
-
22
- return new Promise((resolve, reject) => {
23
- if (!url)
24
- return reject(new Error("请传入 url"));
25
-
26
- const { name = "", type = "", params = {} } = options;
27
- const finalUrl = new URL((process.env.app.API_HOST || window.__JJB_ENVIRONMENT__.API_HOST) + url);
28
- Object.entries(params).forEach(([key, value]) => {
29
- finalUrl.searchParams.append(key, value);
30
- });
31
- fetch(finalUrl, {
32
- method: "GET",
33
- mode: "cors",
34
- headers: {
35
- "Content-Type": "application/json",
36
- "token": window.sessionStorage["token"],
37
- },
38
- })
39
- .then((response) => {
40
- if (!response.ok) {
41
- console.error("网络响应异常");
42
- return;
43
- }
44
- return response.blob();
45
- })
46
- .then((blob) => {
47
- const finalBlob = new Blob([blob], {
48
- type: type || "application/vnd.ms-excel",
49
- });
50
- const downloadElement = document.createElement("a");
51
- const href = window.URL.createObjectURL(finalBlob);
52
- downloadElement.style.display = "none";
53
- downloadElement.href = href;
54
- downloadElement.download
55
- = name || dayjs().format("YYYY-MM-DD HH:mm:ss");
56
- document.body.appendChild(downloadElement);
57
- downloadElement.click();
58
- document.body.removeChild(downloadElement);
59
- window.URL.revokeObjectURL(href);
60
- resolve({ data: finalBlob });
61
- })
62
- .catch((err) => {
63
- message.error("导出失败");
64
- reject(err);
65
- })
66
- .finally(() => {
67
- // 减少请求数量并在没有进行中的请求时设置loading为false
68
- requestCount--;
69
- if (requestCount <= 0) {
70
- setLoading(false);
71
- }
72
- });
73
- });
74
- };
75
-
76
- if (returnType === "array")
77
- return [loading, downloadBlob];
78
- return { loading, downloadBlob };
79
- }
1
+ import{message as e}from"antd";import o from"dayjs";import{useState as n}from"react";function t(t="object"){const[r,a]=n(!1);let c=0;const d=(n,t)=>(c++,c>0&&a(!0),new Promise((r,d)=>{if(!n)return d(new Error("请传入 url"));const{name:s="",type:i="",params:l={}}=t,m=new URL((process.env.app.API_HOST||window.__JJB_ENVIRONMENT__.API_HOST)+n);Object.entries(l).forEach(([e,o])=>{m.searchParams.append(e,o)}),fetch(m,{method:"GET",mode:"cors",headers:{"Content-Type":"application/json",token:window.sessionStorage.token}}).then(e=>{if(e.ok)return e.blob();console.error("网络响应异常")}).then(e=>{const n=new Blob([e],{type:i||"application/vnd.ms-excel"}),t=document.createElement("a"),a=window.URL.createObjectURL(n);t.style.display="none",t.href=a,t.download=s||o().format("YYYY-MM-DD HH:mm:ss"),document.body.appendChild(t),t.click(),document.body.removeChild(t),window.URL.revokeObjectURL(a),r({data:n})}).catch(o=>{e.error("导出失败"),d(o)}).finally(()=>{c--,c<=0&&a(!1)})}));return"array"===t?[r,d]:{loading:r,downloadBlob:d}}export{t as default};
@@ -1,81 +1 @@
1
- import { message, Modal } from "antd";
2
- import { useState } from "react";
3
- import { getFileName, getFileSuffix, getFileUrl } from "../../utils";
4
-
5
- /**
6
- * 下载文件
7
- */
8
- export default function useDownloadFile(returnType = "object") {
9
- // loading状态
10
- const [loading, setLoading] = useState(false);
11
- // 用于跟踪进行中的请求数量(不暴露给外部)
12
- let requestCount = 0;
13
-
14
- // 下载文件
15
- const downloadFile = (options) => {
16
- // 增加请求数量并设置loading状态
17
- requestCount++;
18
- if (requestCount > 0) {
19
- setLoading(true);
20
- }
21
-
22
- const { url, name: fileName } = options;
23
- if (!url) {
24
- console.error("请传入 url");
25
- return;
26
- }
27
-
28
- Modal.confirm({
29
- title: "提示",
30
- content: "确定要下载此文件吗?",
31
- onOk: () => {
32
- const fileUrl = getFileUrl();
33
- let name = fileName;
34
-
35
- if (name) {
36
- if (!getFileSuffix(name) && getFileSuffix(url)) {
37
- name = `${name}.${getFileSuffix(url)}`;
38
- }
39
- }
40
- else {
41
- name = getFileName(url);
42
- }
43
-
44
- fetch(!url.includes(fileUrl) ? fileUrl + url : url)
45
- .then(res => res.blob())
46
- .then((blob) => {
47
- const a = document.createElement("a");
48
- document.body.appendChild(a);
49
- a.style.display = "none";
50
- const urlObject = window.URL.createObjectURL(blob);
51
- a.href = urlObject;
52
- a.download = `${name}`;
53
- a.click();
54
- document.body.removeChild(a);
55
- window.URL.revokeObjectURL(urlObject);
56
- })
57
- .catch(() => {
58
- message.error("下载失败");
59
- })
60
- .finally(() => {
61
- // 减少请求数量并在没有进行中的请求时设置loading为false
62
- requestCount--;
63
- if (requestCount <= 0) {
64
- setLoading(false);
65
- }
66
- });
67
- },
68
- onCancel: () => {
69
- // 减少请求数量并在没有进行中的请求时设置loading为false
70
- requestCount--;
71
- if (requestCount <= 0) {
72
- setLoading(false);
73
- }
74
- },
75
- });
76
- };
77
-
78
- if (returnType === "array")
79
- return [loading, downloadFile];
80
- return { loading, downloadFile };
81
- }
1
+ import{Modal as e,message as o}from"antd";import{useState as t}from"react";import{getFileUrl as n,getFileSuffix as c,getFileName as r}from"../../utils/index.js";function l(l="object"){const[d,a]=t(!1);let i=0;const m=t=>{i++,i>0&&a(!0);const{url:l,name:d}=t;l?e.confirm({title:"提示",content:"确定要下载此文件吗?",onOk:()=>{const e=n();let t=d;t?!c(t)&&c(l)&&(t=`${t}.${c(l)}`):t=r(l),fetch(l.includes(e)?l:e+l).then(e=>e.blob()).then(e=>{const o=document.createElement("a");document.body.appendChild(o),o.style.display="none";const n=window.URL.createObjectURL(e);o.href=n,o.download=`${t}`,o.click(),document.body.removeChild(o),window.URL.revokeObjectURL(n)}).catch(()=>{o.error("下载失败")}).finally(()=>{i--,i<=0&&a(!1)})},onCancel:()=>{i--,i<=0&&a(!1)}}):console.error("请传入 url")};return"array"===l?[d,m]:{loading:d,downloadFile:m}}export{l as default};
@@ -1,74 +1 @@
1
- import { request } from "@cqsjjb/jjb-common-lib/http";
2
- import { useState } from "react";
3
- import { UPLOAD_FILE_TYPE_ENUM } from "../../enum/uploadFile/gwj";
4
- import { addingPrefixToFile } from "../../utils";
5
-
6
- /**
7
- * 获取文件
8
- */
9
- function useGetFile(returnType = "object") {
10
- // loading状态
11
- const [loading, setLoading] = useState(false);
12
- // 用于跟踪进行中的请求数量(不暴露给外部)
13
- let requestCount = 0;
14
-
15
- // 获取文件
16
- const getFile = (options) => {
17
- if (!options) {
18
- console.error("请传入 options");
19
- return;
20
- }
21
-
22
- // 增加请求数量并设置loading状态
23
- requestCount++;
24
- if (requestCount > 0) {
25
- setLoading(true);
26
- }
27
-
28
- return new Promise((resolve, reject) => {
29
- const { eqType, eqForeignKey } = options;
30
-
31
- if (!eqType) {
32
- console.error("请传入 options.eqType");
33
- return;
34
- }
35
-
36
- // 检查eqType是否在UPLOAD_FILE_TYPE_ENUM中
37
- if (!Object.values(UPLOAD_FILE_TYPE_ENUM).includes(eqType)) {
38
- console.error("传入的 eqType 不在 UPLOAD_FILE_TYPE_ENUM 中");
39
- return;
40
- }
41
-
42
- if (eqForeignKey === undefined || eqForeignKey === null) {
43
- console.error("请传入 options.eqForeignKey");
44
- return;
45
- }
46
-
47
- // 发送请求
48
- request(
49
- "/basicInfo/imgFiles/listAll",
50
- "get",
51
- { eqType, eqForeignKey },
52
- )
53
- .then((res) => {
54
- resolve(addingPrefixToFile(res.data).map(item => ({ ...item, type: undefined })));
55
- })
56
- .catch((err) => {
57
- reject(err);
58
- })
59
- .finally(() => {
60
- // 减少请求数量并在没有进行中的请求时设置loading为false
61
- requestCount--;
62
- if (requestCount <= 0) {
63
- setLoading(false);
64
- }
65
- });
66
- });
67
- };
68
-
69
- if (returnType === "array")
70
- return [loading, getFile];
71
- return { loading, getFile };
72
- }
73
-
74
- export default useGetFile;
1
+ import{request as e}from"@cqsjjb/jjb-common-lib/http";import{useState as o}from"react";import{UPLOAD_FILE_TYPE_ENUM as r}from"../../enum/uploadFile/gwj/index.js";import{addingPrefixToFile as t}from"../../utils/index.js";function n(n="object"){const[i,l]=o(!1);let s=0;const c=o=>{if(o)return s++,s>0&&l(!0),new Promise((n,i)=>{const{eqType:c,eqForeignKey:p}=o;c?Object.values(r).includes(c)?null!=p?e("/basicInfo/imgFiles/listAll","get",{eqType:c,eqForeignKey:p}).then(e=>{n(t(e.data).map(e=>({...e,type:void 0})))}).catch(e=>{i(e)}).finally(()=>{s--,s<=0&&l(!1)}):console.error("请传入 options.eqForeignKey"):console.error("传入的 eqType 不在 UPLOAD_FILE_TYPE_ENUM 中"):console.error("请传入 options.eqType")});console.error("请传入 options")};return"array"===n?[i,c]:{loading:i,getFile:c}}export{n as default};
@@ -1,16 +1 @@
1
- /**
2
- * 获取路由参数
3
- */
4
- function useGetUrlQuery() {
5
- const urlQuery = new URLSearchParams(window.location.search);
6
-
7
- // 直接返回包含所有参数的对象
8
- const queryParams = {};
9
- for (const [key, value] of urlQuery.entries()) {
10
- queryParams[key] = value;
11
- }
12
-
13
- return queryParams;
14
- }
15
-
16
- export default useGetUrlQuery;
1
+ function n(){const n=new URLSearchParams(window.location.search),o={};for(const[e,r]of n.entries())o[e]=r;return o}export{n as default};
@@ -1,49 +1 @@
1
- import { request } from "@cqsjjb/jjb-common-lib/http";
2
- import { useState } from "react";
3
-
4
- /**
5
- * 获取用户信息
6
- */
7
- function useGetUserInfo(returnType = "object") {
8
- // loading状态
9
- const [loading, setLoading] = useState(false);
10
- // 用于跟踪进行中的请求数量(不暴露给外部)
11
- let requestCount = 0;
12
-
13
- // 获取用户信息
14
- const getUserInfo = () => {
15
- // 增加请求数量并设置loading状态
16
- requestCount++;
17
- if (requestCount > 0) {
18
- setLoading(true);
19
- }
20
-
21
- return new Promise((resolve, reject) => {
22
- // 发送请求
23
- request(
24
- "/basicInfo/user/getInfo",
25
- "get",
26
- {},
27
- )
28
- .then((res) => {
29
- resolve(res.data);
30
- })
31
- .catch((err) => {
32
- reject(err);
33
- })
34
- .finally(() => {
35
- // 减少请求数量并在没有进行中的请求时设置loading为false
36
- requestCount--;
37
- if (requestCount <= 0) {
38
- setLoading(false);
39
- }
40
- });
41
- });
42
- };
43
-
44
- if (returnType === "array")
45
- return [loading, getUserInfo];
46
- return { loading, getUserInfo };
47
- }
48
-
49
- export default useGetUserInfo;
1
+ import{request as t}from"@cqsjjb/jjb-common-lib/http";import{useState as o}from"react";function e(e="object"){const[n,r]=o(!1);let a=0;const c=()=>(a++,a>0&&r(!0),new Promise((o,e)=>{t("/basicInfo/user/getInfo","get",{}).then(t=>{o(t.data)}).catch(t=>{e(t)}).finally(()=>{a--,a<=0&&r(!1)})}));return"array"===e?[n,c]:{loading:n,getUserInfo:c}}export{e as default};