cloud-web-corejs 1.0.258 → 1.0.259

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 (248) hide show
  1. package/package.json +32 -25
  2. package/src/components/VabUpload/fileLibraryDialog.vue +296 -0
  3. package/src/components/VabUpload/index.js +22 -2
  4. package/src/components/VabUpload/index.vue +242 -231
  5. package/src/components/VabUpload/mixins/fileLibraryDialog.js +1112 -0
  6. package/src/components/VabUpload/mixins.js +1971 -1829
  7. package/src/components/VabUpload/privateProfileDialog.vue +2 -2
  8. package/src/components/baseArea/index.vue +1628 -0
  9. package/src/components/baseInputExport/mixins.js +48 -31
  10. package/src/components/baseInputNumber/index.vue +9 -9
  11. package/src/components/baseTabs/index.vue +16 -8
  12. package/src/components/code-editor/async.js +29 -0
  13. package/src/components/code-editor/index.vue +93 -4
  14. package/src/components/errorMsg/index.js +10 -9
  15. package/src/components/errorMsg/mixins.js +25 -23
  16. package/src/components/excelExport/exportFieldDialog.vue +40 -18
  17. package/src/components/excelExport/index.js +62 -3
  18. package/src/components/excelExport/index.vue +2 -1
  19. package/src/components/excelExport/mixins.js +496 -340
  20. package/src/components/excelImport/index.js +69 -7
  21. package/src/components/excelImport/mixins.js +841 -9
  22. package/src/components/fileLibrary/categoryMoveDialog.vue +109 -109
  23. package/src/components/fileLibrary/fileHistoryDialog.vue +1 -1
  24. package/src/components/fileLibrary/fileObjAuthDialog.vue +297 -298
  25. package/src/components/fileLibrary/fileObjAuthEdit.vue +1 -1
  26. package/src/components/fileLibrary/filterDialog.vue +1 -1
  27. package/src/components/fileLibrary/index.vue +1109 -1110
  28. package/src/components/fileLibrary/mixins/indexMixins.js +10 -0
  29. package/src/components/fileLibrary/propertiesDialog.vue +190 -190
  30. package/src/components/fileLibrary/recycleBinDialog.vue +237 -236
  31. package/src/components/formOplog/mixins.js +85 -80
  32. package/src/components/hiprint/view/design/index.vue +7 -2
  33. package/src/components/jsonImport/exportUtil.js +106 -0
  34. package/src/components/jsonImport/index.js +75 -50
  35. package/src/components/jsonImport/mixins.js +350 -348
  36. package/src/components/langImport/mixins.js +502 -500
  37. package/src/components/micro-view-host/contract.js +66 -0
  38. package/src/components/micro-view-host/index.vue +148 -0
  39. package/src/components/mobile/file/index.vue +10 -0
  40. package/src/components/mobile/wf/mixins/wfModifyDialogMixin.js +51 -47
  41. package/src/components/obsUpload/index.vue +234 -231
  42. package/src/components/obsUpload/mixins.js +1542 -1476
  43. package/src/components/onlineTalk/talkUserDialog.vue +1 -1
  44. package/src/components/table/CellSlot.vue +12 -10
  45. package/src/components/table/config.js +74 -1
  46. package/src/components/table/index.js +1208 -1
  47. package/src/components/table/tableFormMixin.js +285 -1
  48. package/src/components/table/util/index.js +38 -40
  49. package/src/components/table/vxeFilter/index.js +153 -2
  50. package/src/components/table/vxeFilter/mixin.js +305 -3
  51. package/src/components/tempStorage/tempStorageDialog.vue +1 -1
  52. package/src/components/vb-tabs/x-tabs.vue +10 -5
  53. package/src/components/wf/addTaskUserdialog.vue +1 -1
  54. package/src/components/wf/mixins/setCandidateDialog.js +217 -217
  55. package/src/components/wf/mixins/setCandidateDialog2.js +252 -252
  56. package/src/components/wf/wf.js +2224 -2203
  57. package/src/components/wf/wfUtil.js +2 -1
  58. package/src/components/xform/docs/2026-08 /345/210/227/350/241/250/345/257/274/345/207/272/350/204/261/346/225/217/345/210/227/345/211/224/351/231/244/350/220/275/345/234/260/346/226/207/346/241/243.md" +173 -0
  59. package/src/components/xform/form-designer/designer.js +1 -0
  60. package/src/components/xform/form-designer/form-widget/container-widget/containerMixin.js +110 -1
  61. package/src/components/xform/form-designer/form-widget/container-widget/data-table-mixin.js +282 -1
  62. package/src/components/xform/form-designer/form-widget/field-widget/area-select-widget.vue +272 -0
  63. package/src/components/xform/form-designer/form-widget/field-widget/autocomplete-widget.vue +119 -0
  64. package/src/components/xform/form-designer/form-widget/field-widget/fieldMixin.js +14 -0
  65. package/src/components/xform/form-designer/form-widget/field-widget/form-item-wrapper.vue +18 -73
  66. package/src/components/xform/form-designer/form-widget/field-widget/mixins/autocomplete-mixin.js +451 -0
  67. package/src/components/xform/form-designer/form-widget/field-widget/mixins/date-limit-mixin.js +157 -0
  68. package/src/components/xform/form-designer/form-widget/field-widget/mixins/utc-transform-mixin.js +75 -0
  69. package/src/components/xform/form-designer/form-widget/field-widget/save_submit_wf_button-widget.vue +112 -0
  70. package/src/components/xform/form-designer/form-widget/field-widget/script-input-widget.vue +149 -0
  71. package/src/components/xform/form-designer/form-widget/indexMixin.js +179 -1
  72. package/src/components/xform/form-designer/indexMixin.js +823 -1
  73. package/src/components/xform/form-designer/refMixinDesign.js +27 -1
  74. package/src/components/xform/form-designer/setting-panel/action-button-config-dialog.vue +241 -0
  75. package/src/components/xform/form-designer/setting-panel/form-dynamicField-setting.vue +601 -0
  76. package/src/components/xform/form-designer/setting-panel/form-setting.vue +6 -0
  77. package/src/components/xform/form-designer/setting-panel/index.vue +314 -309
  78. package/src/components/xform/form-designer/setting-panel/indexMixin.js +324 -1
  79. package/src/components/xform/form-designer/setting-panel/property-editor/container-data-table/data-table-editor.vue +8 -7
  80. package/src/components/xform/form-designer/setting-panel/property-editor/container-list-h5/list-h5-editor.vue +8 -7
  81. package/src/components/xform/form-designer/setting-panel/property-editor/container-table/table-dynamicField-editor.vue +344 -0
  82. package/src/components/xform/form-designer/setting-panel/property-editor/dropdownFlag-editor.vue +2 -2
  83. package/src/components/xform/form-designer/setting-panel/property-editor/field-area-select/areaDataType-editor.vue +25 -0
  84. package/src/components/xform/form-designer/setting-panel/property-editor/field-area-select/areaMinLevel-editor.vue +50 -0
  85. package/src/components/xform/form-designer/setting-panel/property-editor/field-area-select/areaName-editor.vue +20 -0
  86. package/src/components/xform/form-designer/setting-panel/property-editor/field-autocomplete/autocomplete-vabSearchName-editor.vue +199 -0
  87. package/src/components/xform/form-designer/setting-panel/property-editor/field-baseAttachment/baseAttachment-fileTypes-editor.vue +23 -0
  88. package/src/components/xform/form-designer/setting-panel/property-editor/field-cascader/showAllLevels-editor.vue +21 -0
  89. package/src/components/xform/form-designer/setting-panel/property-editor/field-date/date-dateLimit-editor.vue +157 -0
  90. package/src/components/xform/form-designer/setting-panel/property-editor/field-script-input/script-input-editor.vue +55 -0
  91. package/src/components/xform/form-designer/setting-panel/property-editor/field-vabUpload/vabUpload-fileTypes-editor.vue +23 -0
  92. package/src/components/xform/form-designer/setting-panel/property-editor/fileTypesEditorMixin.js +116 -0
  93. package/src/components/xform/form-designer/setting-panel/property-editor/fileTypesSelect.vue +176 -0
  94. package/src/components/xform/form-designer/setting-panel/property-editor/textFlag-editor.vue +3 -3
  95. package/src/components/xform/form-designer/setting-panel/property-editor/utcTransformEnabled-editor.vue +19 -0
  96. package/src/components/xform/form-designer/setting-panel/widgetPropertyDialogMixin.js +186 -0
  97. package/src/components/xform/form-designer/toolbar-panel/indexMixin.js +566 -1
  98. package/src/components/xform/form-designer/widget-panel/indexMixin.js +290 -1
  99. package/src/components/xform/form-render/compareDelList.vue +83 -0
  100. package/src/components/xform/form-render/compareView.vue +76 -0
  101. package/src/components/xform/form-render/container-item/containerItemMixin.js +378 -1
  102. package/src/components/xform/form-render/container-item/data-table-mixin.js +35 -0
  103. package/src/components/xform/form-render/container-item/detail-item.vue +41 -0
  104. package/src/components/xform/form-render/container-item/dynamicFieldEngine.js +285 -0
  105. package/src/components/xform/form-render/container-item/dynamicFieldMixin.js +416 -0
  106. package/src/components/xform/form-render/container-item/list-h5-item.vue +12 -0
  107. package/src/components/xform/form-render/dynamicDialogRender.js +195 -1
  108. package/src/components/xform/form-render/dynamicDrawerRender.js +229 -0
  109. package/src/components/xform/form-render/formDynamicFieldMixin.js +131 -0
  110. package/src/components/xform/form-render/refMixin.js +29 -1
  111. package/src/components/xform/mixins/scriptHttp.js +172 -1
  112. package/src/components/xform/utils/dynamicSchemaUtil.js +361 -0
  113. package/src/components/xform/utils/tableCellValidateUtil.js +148 -0
  114. package/src/components/xform/utils/textMaskUtil.js +179 -0
  115. package/src/components/xform/utils/treeTableUtil.js +1265 -0
  116. package/src/components/xform/utils/util.js +1 -0
  117. package/src/components/xform/utils/validators.js +133 -1
  118. package/src/directive/LimitNumber/index.js +143 -124
  119. package/src/microRouter/index.js +447 -0
  120. package/src/mixins/tableTree/index.js +77 -14
  121. package/src/permission.js +132 -107
  122. package/src/public-path.js +38 -0
  123. package/src/router/index.js +3 -3
  124. package/src/store/modules/micro.js +57 -0
  125. package/src/store/modules/permission.js +535 -371
  126. package/src/store/modules/tagsView.js +38 -21
  127. package/src/store/modules/user.js +409 -370
  128. package/src/utils/aes.js +9 -3
  129. package/src/utils/auth.js +1 -1
  130. package/src/utils/componentDialog.js +162 -40
  131. package/src/utils/global.js +35 -34
  132. package/src/utils/index.js +579 -579
  133. package/src/utils/keepAlive.js +8 -4
  134. package/src/utils/lazyPlugin.js +66 -0
  135. package/src/utils/menuAdapter.js +277 -0
  136. package/src/utils/repeatOpen.js +48 -0
  137. package/src/utils/request.js +417 -395
  138. package/src/utils/resolveViewComponent.js +203 -0
  139. package/src/utils/vab.js +14 -3
  140. package/src/utils/validate.js +104 -106
  141. package/src/views/bd/setting/bd_attach_setting/dialog.vue +1 -1
  142. package/src/views/bd/setting/bd_attach_setting/list.vue +1 -1
  143. package/src/views/bd/setting/bd_company_env/dialog.vue +1 -1
  144. package/src/views/bd/setting/bd_company_env/list.vue +1 -1
  145. package/src/views/bd/setting/formVersion/ftHistoryDialog.vue +488 -489
  146. package/src/views/bd/setting/form_import_log/list.vue +1 -1
  147. package/src/views/bd/setting/form_script/dialog.vue +1 -1
  148. package/src/views/bd/setting/form_script/form_list.vue +174 -166
  149. package/src/views/bd/setting/form_script/list.vue +1 -1
  150. package/src/views/bd/setting/form_script/list1.vue +1 -1
  151. package/src/views/bd/setting/form_script/mixins/form_list.js +330 -322
  152. package/src/views/bd/setting/form_template/dialog.vue +1 -1
  153. package/src/views/bd/setting/form_template/formDesignerDialog.vue +172 -171
  154. package/src/views/bd/setting/form_template/ftHistoryDialog.vue +1 -1
  155. package/src/views/bd/setting/form_template/itemList.vue +1 -1
  156. package/src/views/bd/setting/form_template/list.vue +3 -3
  157. package/src/views/bd/setting/form_template/mixins/edit.js +3 -3
  158. package/src/views/bd/setting/form_template/mixins/list.js +3 -3
  159. package/src/views/bd/setting/form_template/mixins/list2.js +3 -3
  160. package/src/views/bd/setting/form_template/mixins/wf_list.js +3 -3
  161. package/src/views/bd/setting/form_template/wfObjConfigDialog.vue +253 -254
  162. package/src/views/bd/setting/form_template/wf_list.vue +3 -3
  163. package/src/views/bd/setting/logic_param/edit.vue +20 -20
  164. package/src/views/bd/setting/logic_param/list.vue +1 -1
  165. package/src/views/bd/setting/menu_kind/dialog.vue +1 -1
  166. package/src/views/bd/setting/menu_kind/list.vue +1 -1
  167. package/src/views/bd/setting/push_data/list.vue +1 -1
  168. package/src/views/bd/setting/push_data_h/list.vue +1 -1
  169. package/src/views/bd/setting/request_async_setting/list.vue +1 -1
  170. package/src/views/bd/setting/request_setting/list.vue +1 -1
  171. package/src/views/bd/setting/table_model/dialog.vue +1 -1
  172. package/src/views/bd/setting/table_model/list.vue +1 -1
  173. package/src/views/bd/setting/table_model/zdDialog.vue +1 -1
  174. package/src/views/user/access_log/list.vue +1 -1
  175. package/src/views/user/access_log/list2.vue +1 -1
  176. package/src/views/user/api_request/list.vue +1 -1
  177. package/src/views/user/area/dialog.vue +1 -1
  178. package/src/views/user/area/list.vue +1 -1
  179. package/src/views/user/bill_setting/list.vue +1 -1
  180. package/src/views/user/bill_setting/userDialog.vue +1 -1
  181. package/src/views/user/code_rules/list.vue +1 -1
  182. package/src/views/user/commMenu/index.vue +2 -2
  183. package/src/views/user/common_attribute/list.vue +2 -2
  184. package/src/views/user/common_script/list.vue +1 -1
  185. package/src/views/user/company_info/dialog.vue +1 -1
  186. package/src/views/user/country/dialog.vue +1 -1
  187. package/src/views/user/country/list.vue +1 -1
  188. package/src/views/user/data_type_setting/dialog.vue +1 -1
  189. package/src/views/user/extend_datasource/dialog.vue +4 -1
  190. package/src/views/user/extend_datasource/edit.vue +2 -1
  191. package/src/views/user/extend_datasource/list.vue +4 -1
  192. package/src/views/user/fieldTranslation/list.vue +1 -1
  193. package/src/views/user/field_values_invisible/list.vue +1 -1
  194. package/src/views/user/file_type/list.vue +1 -1
  195. package/src/views/user/file_view_area/list.vue +1 -1
  196. package/src/views/user/file_view_ins/list.vue +22 -1
  197. package/src/views/user/form/view/list.vue +64 -1
  198. package/src/views/user/groups/dialog.vue +1 -1
  199. package/src/views/user/groups/list.vue +1 -1
  200. package/src/views/user/home/default.vue +2 -2
  201. package/src/views/user/home/default2.vue +1158 -1148
  202. package/src/views/user/home/index.vue +3 -10
  203. package/src/views/user/lang_tag/dialog.vue +1 -1
  204. package/src/views/user/lang_tag/list.vue +1 -1
  205. package/src/views/user/language_setting/list.vue +1 -1
  206. package/src/views/user/login/default.vue +0 -8
  207. package/src/views/user/login/indexMixin.js +547 -556
  208. package/src/views/user/menu/list.vue +25 -2
  209. package/src/views/user/menuFallback/index.vue +123 -0
  210. package/src/views/user/mobile_menu/list.vue +1 -1
  211. package/src/views/user/notify_message/dialog.vue +22 -1
  212. package/src/views/user/notify_message/list.vue +1 -1
  213. package/src/views/user/notify_template/list.vue +1 -1
  214. package/src/views/user/notify_template/list2.vue +1 -1
  215. package/src/views/user/oplog/list.vue +1 -1
  216. package/src/views/user/outLink/form_view.vue +5 -14
  217. package/src/views/user/outLink/index.vue +6 -1
  218. package/src/views/user/outLink/view.vue +5 -13
  219. package/src/views/user/position/dialog.vue +1 -1
  220. package/src/views/user/position/list.vue +1 -1
  221. package/src/views/user/project_tag/dialog.vue +1 -1
  222. package/src/views/user/project_tag/list.vue +1 -1
  223. package/src/views/user/push_setting/list.vue +1 -1
  224. package/src/views/user/request_setting/list.vue +1 -1
  225. package/src/views/user/role/dialog.vue +1 -1
  226. package/src/views/user/role/list.vue +1 -1
  227. package/src/views/user/sale_org/dialog.vue +1 -1
  228. package/src/views/user/sale_org/list.vue +1 -1
  229. package/src/views/user/system_notice/list.vue +1 -1
  230. package/src/views/user/system_parameter/list.vue +1 -1
  231. package/src/views/user/user/dialog.vue +1 -1
  232. package/src/views/user/user/edit.vue +306 -159
  233. package/src/views/user/user/form_dialog.vue +1 -1
  234. package/src/views/user/user/form_list.vue +1 -1
  235. package/src/views/user/user/list.vue +2 -2
  236. package/src/views/user/user_log_classify/list.vue +1 -1
  237. package/src/views/user/wf/iframe/index.vue +6 -1
  238. package/src/views/user/wf/iframe/index2.vue +6 -1
  239. package/src/views/user/wf/wfReport/index.vue +12 -6
  240. package/src/views/user/wf/wf_auto_submit_data/list.vue +2 -2
  241. package/src/views/user/wf/wf_manage/list.vue +97 -24
  242. package/src/views/user/wf/wf_manage/list2.vue +875 -0
  243. package/src/views/user/wf/wf_manage/wfContentDialog.vue +23 -1
  244. package/src/views/user/wf/wf_obj_config/dialog.vue +1 -1
  245. package/src/views/user/wf/wf_obj_config/list.vue +1 -1
  246. package/src/views/user/wf/wf_obj_config/list_form.vue +1 -1
  247. package/src/views/user/wf/wf_transfer_setting/list.vue +1 -1
  248. package/src/views/user/workbench_menu/list.vue +1 -1
@@ -1,579 +1,579 @@
1
- /**version-1.0*/
2
- import settingConfig from "@/settings";
3
- import { getToken } from "@base/utils/auth"; // get token from cookie
4
- let indexUtil = {};
5
-
6
- indexUtil = {
7
- parseTime: function (time, cFormat) {},
8
- formatTime: function (time, option) {},
9
- getQueryObject: function (url) {},
10
- byteLength: function (str) {},
11
- cleanArray: function (actual) {},
12
- param: function (json) {},
13
- param2Obj: function (url) {},
14
- html2Text: function (val) {},
15
- objectMerge: function (target, source) {},
16
- toggleClass: function (element, className) {},
17
- getTime: function (type) {},
18
- debounce: function (func, wait, immediate) {},
19
- deepClone: function (source) {},
20
- uniqueArr: function (arr) {},
21
- createUniqueString: function () {},
22
- hasClass: function (ele, cls) {},
23
- addClass: function (ele, cls) {},
24
- removeClass: function (ele, cls) {},
25
- extendDeeply: function (parent, child, result) {},
26
- };
27
-
28
- /**
29
- * Parse the time to string
30
- * @param {(Object|string|number)} time
31
- * @param {string} cFormat
32
- * @returns {string | null}
33
- */
34
- export function parseTime(time, cFormat) {
35
- if (arguments.length === 0 || !time) {
36
- return null;
37
- }
38
- const format = cFormat || "{y}-{m}-{d} {h}:{i}:{s}";
39
- let date;
40
- if (typeof time === "object") {
41
- date = time;
42
- } else {
43
- if (typeof time === "string") {
44
- if (/^[0-9]+$/.test(time)) {
45
- // support "1548221490638"
46
- time = parseInt(time);
47
- } else {
48
- // support safari
49
- // https://stackoverflow.com/questions/4310953/invalid-date-in-safari
50
- time = time.replace(new RegExp(/-/gm), "/");
51
- }
52
- }
53
-
54
- if (typeof time === "number" && time.toString().length === 10) {
55
- time = time * 1000;
56
- }
57
- date = new Date(time);
58
- }
59
- const formatObj = {
60
- y: date.getFullYear(),
61
- m: date.getMonth() + 1,
62
- d: date.getDate(),
63
- h: date.getHours(),
64
- i: date.getMinutes(),
65
- s: date.getSeconds(),
66
- a: date.getDay(),
67
- };
68
- const time_str = format.replace(/{([ymdhisa])+}/g, (result, key) => {
69
- const value = formatObj[key];
70
- // Note: getDay() returns 0 on Sunday
71
- if (key === "a") {
72
- return ["日", "一", "二", "三", "四", "五", "六"][value];
73
- }
74
- return value.toString().padStart(2, "0");
75
- });
76
- return time_str;
77
- }
78
-
79
- /**
80
- * @param {number} time
81
- * @param {string} option
82
- * @returns {string}
83
- */
84
- export function formatTime(time, option) {
85
- if (("" + time).length === 10) {
86
- time = parseInt(time) * 1000;
87
- } else {
88
- time = +time;
89
- }
90
- const d = new Date(time);
91
- const now = Date.now();
92
-
93
- const diff = (now - d) / 1000;
94
-
95
- if (diff < 30) {
96
- return "刚刚";
97
- } else if (diff < 3600) {
98
- // less 1 hour
99
- return Math.ceil(diff / 60) + "分钟前";
100
- } else if (diff < 3600 * 24) {
101
- return Math.ceil(diff / 3600) + "小时前";
102
- } else if (diff < 3600 * 24 * 2) {
103
- return "1天前";
104
- }
105
- if (option) {
106
- return parseTime(time, option);
107
- } else {
108
- return (
109
- d.getMonth() +
110
- 1 +
111
- "月" +
112
- d.getDate() +
113
- "日" +
114
- d.getHours() +
115
- "时" +
116
- d.getMinutes() +
117
- "分"
118
- );
119
- }
120
- }
121
-
122
- /**
123
- * @param {string} url
124
- * @returns {Object}
125
- */
126
- export function getQueryObject(url) {
127
- url = url == null ? window.location.href : url;
128
- const search = url.substring(url.lastIndexOf("?") + 1);
129
- const obj = {};
130
- const reg = /([^?&=]+)=([^?&=]*)/g;
131
- search.replace(reg, (rs, $1, $2) => {
132
- const name = decodeURIComponent($1);
133
- let val = decodeURIComponent($2);
134
- val = String(val);
135
- obj[name] = val;
136
- return rs;
137
- });
138
- return obj;
139
- }
140
-
141
- /**
142
- * @param {string} input value
143
- * @returns {number} output value
144
- */
145
- export function byteLength(str) {
146
- // returns the byte length of an utf8 string
147
- let s = str.length;
148
- for (var i = str.length - 1; i >= 0; i--) {
149
- const code = str.charCodeAt(i);
150
- if (code > 0x7f && code <= 0x7ff) s++;
151
- else if (code > 0x7ff && code <= 0xffff) s += 2;
152
- if (code >= 0xdc00 && code <= 0xdfff) i--;
153
- }
154
- return s;
155
- }
156
-
157
- /**
158
- * @param {Array} actual
159
- * @returns {Array}
160
- */
161
- export function cleanArray(actual) {
162
- const newArray = [];
163
- for (let i = 0; i < actual.length; i++) {
164
- if (actual[i]) {
165
- newArray.push(actual[i]);
166
- }
167
- }
168
- return newArray;
169
- }
170
-
171
- /**
172
- * @param {Object} json
173
- * @returns {Array}
174
- */
175
- function param(json) {
176
- if (!json) return "";
177
- return cleanArray(
178
- Object.keys(json).map((key) => {
179
- if (json[key] === undefined) return "";
180
- return encodeURIComponent(key) + "=" + encodeURIComponent(json[key]);
181
- })
182
- ).join("&");
183
- }
184
-
185
- /**
186
- * @param {string} url
187
- * @returns {Object}
188
- */
189
- function param2Obj(url) {
190
- const search = decodeURIComponent(url.split("?")[1]).replace(/\+/g, " ");
191
- if (!search) {
192
- return {};
193
- }
194
- const obj = {};
195
- const searchArr = search.split("&");
196
- searchArr.forEach((v) => {
197
- const index = v.indexOf("=");
198
- if (index !== -1) {
199
- const name = v.substring(0, index);
200
- const val = v.substring(index + 1, v.length);
201
- obj[name] = val;
202
- }
203
- });
204
- return obj;
205
- }
206
-
207
- /**
208
- * @param {string} val
209
- * @returns {string}
210
- */
211
- export function html2Text(val) {
212
- const div = document.createElement("div");
213
- div.innerHTML = val;
214
- return div.textContent || div.innerText;
215
- }
216
-
217
- /**
218
- * Merges two objects, giving the last one precedence
219
- * @param {Object} target
220
- * @param {(Object|Array)} source
221
- * @returns {Object}
222
- */
223
- export function objectMerge(target, source) {
224
- if (typeof target !== "object") {
225
- target = {};
226
- }
227
- if (Array.isArray(source)) {
228
- return source.slice();
229
- }
230
- Object.keys(source).forEach((property) => {
231
- const sourceProperty = source[property];
232
- if (typeof sourceProperty === "object") {
233
- target[property] = objectMerge(target[property], sourceProperty);
234
- } else {
235
- target[property] = sourceProperty;
236
- }
237
- });
238
- return target;
239
- }
240
-
241
- /**
242
- * @param {HTMLElement} element
243
- * @param {string} className
244
- */
245
- export function toggleClass(element, className) {
246
- if (!element || !className) {
247
- return;
248
- }
249
- let classString = element.className;
250
- const nameIndex = classString.indexOf(className);
251
- if (nameIndex === -1) {
252
- classString += "" + className;
253
- } else {
254
- classString =
255
- classString.substr(0, nameIndex) +
256
- classString.substr(nameIndex + className.length);
257
- }
258
- element.className = classString;
259
- }
260
-
261
- /**
262
- * @param {string} type
263
- * @returns {Date}
264
- */
265
- export function getTime(type) {
266
- if (type === "start") {
267
- return new Date().getTime() - 3600 * 1000 * 24 * 90;
268
- } else {
269
- return new Date(new Date().toDateString());
270
- }
271
- }
272
-
273
- /**
274
- * @param {Function} func
275
- * @param {number} wait
276
- * @param {boolean} immediate
277
- * @return {*}
278
- */
279
- export function debounce(func, wait, immediate) {
280
- let timeout, args, context, timestamp, result;
281
-
282
- const later = function () {
283
- // 据上一次触发时间间隔
284
- const last = +new Date() - timestamp;
285
-
286
- // 上次被包装函数被调用时间间隔 last 小于设定时间间隔 wait
287
- if (last < wait && last > 0) {
288
- timeout = setTimeout(later, wait - last);
289
- } else {
290
- timeout = null;
291
- // 如果设定为immediate===true,因为开始边界已经调用过了此处无需调用
292
- if (!immediate) {
293
- result = func.apply(context, args);
294
- if (!timeout) context = args = null;
295
- }
296
- }
297
- };
298
-
299
- return function (...args) {
300
- context = this;
301
- timestamp = +new Date();
302
- const callNow = immediate && !timeout;
303
- // 如果延时不存在,重新设定延时
304
- if (!timeout) timeout = setTimeout(later, wait);
305
- if (callNow) {
306
- result = func.apply(context, args);
307
- context = args = null;
308
- }
309
-
310
- return result;
311
- };
312
- }
313
-
314
- /**
315
- * This is just a simple version of deep copy
316
- * Has a lot of edge cases bug
317
- * If you want to use a perfect deep copy, use lodash's _.cloneDeep
318
- * @param {Object} source
319
- * @returns {Object}
320
- */
321
- export function deepClone(source) {
322
- if (!source && typeof source !== "object") {
323
- throw new Error("error arguments", "deepClone");
324
- }
325
- const targetObj = source.constructor === Array ? [] : {};
326
- Object.keys(source).forEach((keys) => {
327
- if (source[keys] && typeof source[keys] === "object") {
328
- targetObj[keys] = deepClone(source[keys]);
329
- } else {
330
- targetObj[keys] = source[keys];
331
- }
332
- });
333
- return targetObj;
334
- }
335
-
336
- /**
337
- * @param {Array} arr
338
- * @returns {Array}
339
- */
340
- export function uniqueArr(arr) {
341
- return Array.from(new Set(arr));
342
- }
343
-
344
- /**
345
- * @returns {string}
346
- */
347
- export function createUniqueString() {
348
- const timestamp = +new Date() + "";
349
- const randomNum = parseInt((1 + Math.random()) * 65536) + "";
350
- return (+(randomNum + timestamp)).toString(32);
351
- }
352
-
353
- /**
354
- * Check if an element has a class
355
- * @param {HTMLElement} elm
356
- * @param {string} cls
357
- * @returns {boolean}
358
- */
359
- export function hasClass(ele, cls) {
360
- return !!ele.className.match(new RegExp("(\\s|^)" + cls + "(\\s|$)"));
361
- }
362
-
363
- /**
364
- * Add class to element
365
- * @param {HTMLElement} elm
366
- * @param {string} cls
367
- */
368
- export function addClass(ele, cls) {
369
- if (!hasClass(ele, cls)) ele.className += " " + cls;
370
- }
371
-
372
- /**
373
- * Remove class from element
374
- * @param {HTMLElement} elm
375
- * @param {string} cls
376
- */
377
- export function removeClass(ele, cls) {
378
- if (hasClass(ele, cls)) {
379
- const reg = new RegExp("(\\s|^)" + cls + "(\\s|$)");
380
- ele.className = ele.className.replace(reg, " ");
381
- }
382
- }
383
-
384
- //DOM没有提供insertAfter()方法
385
- export function insertAfter(newElement, targetElement) {
386
- var parent = targetElement.parentNode;
387
- if (parent.lastChild == targetElement) {
388
- // 如果最后的节点是目标元素,则直接添加。因为默认是最后
389
- parent.appendChild(newElement);
390
- } else {
391
- parent.insertBefore(newElement, targetElement.nextSibling);
392
- //如果不是,则插入在目标元素的下一个兄弟节点 的前面。也就是目标元素的后面
393
- }
394
- }
395
-
396
- //最前面插入子节点
397
- export function prependChild(parentDom, newDom) {
398
- if (parentDom.hasChildNodes()) {
399
- let currentDom = parentDom.children[0];
400
- parentDom.insertBefore(newDom, currentDom);
401
- } else {
402
- parentDom.append(newDom);
403
- }
404
- }
405
-
406
- /**
407
- * 实现json对象的深层拷贝
408
- * @parent 需要拷贝的原对象
409
- * @child 返回的拷贝完成的对象(参数可省略)
410
- */
411
- export function copyDeeply(parent, child) {
412
- child = child || {};
413
- for (var prop in parent) {
414
- // 如果属性本身,就是一个数组或者Json对象,进行深拷贝
415
- if (
416
- parent[prop] !== null &&
417
- parent[prop] !== undefined &&
418
- typeof parent[prop] === "object"
419
- ) {
420
- // 确定子对象的属性类型,[]或者{}对象
421
- child[prop] = parent[prop].constructor === Array ? [] : {};
422
- // 实现深拷贝
423
- copyDeeply(parent[prop], child[prop]);
424
- } else {
425
- child[prop] = parent[prop];
426
- }
427
- }
428
- return child;
429
- }
430
-
431
- /**
432
- * 实现json对象的深层继承
433
- * @parent 被继承原对象
434
- * @child 继承对象(把child对象继承到parent)
435
- * @result 最终生成的结果对象(参数可省略)
436
- */
437
- export function extendDeeply(parent, child, result) {
438
- result = result || copyDeeply(parent);
439
- for (var prop in child) {
440
- // 如果属性本身,就是一个数组或者Json对象,进行深拷贝
441
- if (child[prop]?.constructor === Object) {
442
- result[prop] = result[prop] || {};
443
- parent[prop] = parent[prop] || {};
444
- // 实现深拷贝
445
- extendDeeply(parent[prop], child[prop], result[prop]);
446
- } else {
447
- result[prop] = child[prop];
448
- }
449
- }
450
- return result;
451
- }
452
-
453
- function isDef(value) {
454
- return value !== undefined && value !== null;
455
- }
456
-
457
- // 是否是对象
458
- function isObj(x) {
459
- const type = typeof x;
460
- return x !== null && (type === "object" || type === "function");
461
- }
462
-
463
- // 深拷贝
464
- const { hasOwnProperty } = Object.prototype;
465
-
466
- function assignKey(to, from, key) {
467
- const val = from[key];
468
-
469
- if (!isDef(val)) {
470
- return;
471
- }
472
-
473
- if (!hasOwnProperty.call(to, key) || !isObj(val)) {
474
- to[key] = val;
475
- } else {
476
- to[key] = deepAssign(Object(to[key]), from[key]);
477
- }
478
- }
479
-
480
- export function deepAssign(to, from) {
481
- Object.keys(from).forEach((key) => {
482
- assignKey(to, from, key);
483
- });
484
-
485
- return to;
486
- }
487
-
488
- export function initI18nMessage(dataTypeCode, languageCode, flag) {
489
- if (settingConfig.i18nEnabled === true && getToken()) {
490
- let language =
491
- window.$root?.$i18n?.locale ||
492
- localStorage.getItem("i18n-lang") ||
493
- settingConfig.languageCode ||
494
- "zh";
495
- languageCode = languageCode || language;
496
- dataTypeCode = dataTypeCode || "business";
497
- if (window._i18nMap && window._i18nMap[dataTypeCode] && flag !== true)
498
- return;
499
- return window.$vueRoot.$http({
500
- url: USER_PREFIX + "/language_translation/getMessages",
501
- method: `post`,
502
- data: {
503
- languageCode: languageCode,
504
- dataTypeCode: dataTypeCode,
505
- },
506
- success: (res) => {
507
- if (res.objx) {
508
- setTimeout(() => {
509
- // debugger
510
- window?.$vueRoot?.$i18n.mergeLocaleMessage(languageCode, res.objx);
511
- /*let langMap = {[languageCode]:res.objx};
512
- let messages = window?.$vueRoot?.$i18n?.messages;
513
- if (messages) {
514
- messages = deepAssign(messages, langMap);
515
- window.$vueRoot.$i18n.messages = messages
516
- }*/
517
- }, 20);
518
- }
519
- let map = {};
520
- let _i18nMap = window._i18nMap || {};
521
- _i18nMap[dataTypeCode] = true;
522
- window._i18nMap = _i18nMap;
523
- },
524
- });
525
- }
526
- }
527
-
528
- export function getErrorMsg(value) {
529
- if (value === undefined || value === null) return value;
530
- let content = value ? value.trim() : value;
531
- if (content) {
532
- let index = content.indexOf("[*sf-cloud");
533
- if (index === 0) {
534
- var index0 = content.lastIndexOf("*]");
535
- if (index0 >= 0) {
536
- let text = content.substr(index0);
537
- if (text) {
538
- text = text.trim();
539
- var index1 = text.indexOf("Exception:");
540
- if (index1 >= 0) {
541
- text = text.substr(index1 + 10).trim();
542
- }
543
- }
544
- content = text;
545
- }
546
- } else if (index > 0) {
547
- content = content.substring(0, index);
548
- }
549
- }
550
- return content;
551
- }
552
-
553
- indexUtil = {
554
- parseTime,
555
- formatTime,
556
- getQueryObject,
557
- byteLength,
558
- cleanArray,
559
- param,
560
- param2Obj,
561
- html2Text,
562
- objectMerge,
563
- toggleClass,
564
- getTime,
565
- debounce,
566
- deepClone,
567
- uniqueArr,
568
- createUniqueString,
569
- hasClass,
570
- addClass,
571
- removeClass,
572
- insertAfter,
573
- prependChild,
574
- extendDeeply,
575
- initI18nMessage,
576
- getErrorMsg,
577
- };
578
-
579
- export default indexUtil;
1
+ /**version-1.0*/
2
+ import settingConfig from "@/settings";
3
+ import { getToken } from "@base/utils/auth"; // get token from cookie
4
+ let indexUtil = {};
5
+
6
+ indexUtil = {
7
+ parseTime: function (time, cFormat) {},
8
+ formatTime: function (time, option) {},
9
+ getQueryObject: function (url) {},
10
+ byteLength: function (str) {},
11
+ cleanArray: function (actual) {},
12
+ param: function (json) {},
13
+ param2Obj: function (url) {},
14
+ html2Text: function (val) {},
15
+ objectMerge: function (target, source) {},
16
+ toggleClass: function (element, className) {},
17
+ getTime: function (type) {},
18
+ debounce: function (func, wait, immediate) {},
19
+ deepClone: function (source) {},
20
+ uniqueArr: function (arr) {},
21
+ createUniqueString: function () {},
22
+ hasClass: function (ele, cls) {},
23
+ addClass: function (ele, cls) {},
24
+ removeClass: function (ele, cls) {},
25
+ extendDeeply: function (parent, child, result) {},
26
+ };
27
+
28
+ /**
29
+ * Parse the time to string
30
+ * @param {(Object|string|number)} time
31
+ * @param {string} cFormat
32
+ * @returns {string | null}
33
+ */
34
+ export function parseTime(time, cFormat) {
35
+ if (arguments.length === 0 || !time) {
36
+ return null;
37
+ }
38
+ const format = cFormat || "{y}-{m}-{d} {h}:{i}:{s}";
39
+ let date;
40
+ if (typeof time === "object") {
41
+ date = time;
42
+ } else {
43
+ if (typeof time === "string") {
44
+ if (/^[0-9]+$/.test(time)) {
45
+ // support "1548221490638"
46
+ time = parseInt(time);
47
+ } else {
48
+ // support safari
49
+ // https://stackoverflow.com/questions/4310953/invalid-date-in-safari
50
+ time = time.replace(new RegExp(/-/gm), "/");
51
+ }
52
+ }
53
+
54
+ if (typeof time === "number" && time.toString().length === 10) {
55
+ time = time * 1000;
56
+ }
57
+ date = new Date(time);
58
+ }
59
+ const formatObj = {
60
+ y: date.getFullYear(),
61
+ m: date.getMonth() + 1,
62
+ d: date.getDate(),
63
+ h: date.getHours(),
64
+ i: date.getMinutes(),
65
+ s: date.getSeconds(),
66
+ a: date.getDay(),
67
+ };
68
+ const time_str = format.replace(/{([ymdhisa])+}/g, (result, key) => {
69
+ const value = formatObj[key];
70
+ // Note: getDay() returns 0 on Sunday
71
+ if (key === "a") {
72
+ return ["日", "一", "二", "三", "四", "五", "六"][value];
73
+ }
74
+ return value.toString().padStart(2, "0");
75
+ });
76
+ return time_str;
77
+ }
78
+
79
+ /**
80
+ * @param {number} time
81
+ * @param {string} option
82
+ * @returns {string}
83
+ */
84
+ export function formatTime(time, option) {
85
+ if (("" + time).length === 10) {
86
+ time = parseInt(time) * 1000;
87
+ } else {
88
+ time = +time;
89
+ }
90
+ const d = new Date(time);
91
+ const now = Date.now();
92
+
93
+ const diff = (now - d) / 1000;
94
+
95
+ if (diff < 30) {
96
+ return "刚刚";
97
+ } else if (diff < 3600) {
98
+ // less 1 hour
99
+ return Math.ceil(diff / 60) + "分钟前";
100
+ } else if (diff < 3600 * 24) {
101
+ return Math.ceil(diff / 3600) + "小时前";
102
+ } else if (diff < 3600 * 24 * 2) {
103
+ return "1天前";
104
+ }
105
+ if (option) {
106
+ return parseTime(time, option);
107
+ } else {
108
+ return (
109
+ d.getMonth() +
110
+ 1 +
111
+ "月" +
112
+ d.getDate() +
113
+ "日" +
114
+ d.getHours() +
115
+ "时" +
116
+ d.getMinutes() +
117
+ "分"
118
+ );
119
+ }
120
+ }
121
+
122
+ /**
123
+ * @param {string} url
124
+ * @returns {Object}
125
+ */
126
+ export function getQueryObject(url) {
127
+ url = url == null ? window.location.href : url;
128
+ const search = url.substring(url.lastIndexOf("?") + 1);
129
+ const obj = {};
130
+ const reg = /([^?&=]+)=([^?&=]*)/g;
131
+ search.replace(reg, (rs, $1, $2) => {
132
+ const name = decodeURIComponent($1);
133
+ let val = decodeURIComponent($2);
134
+ val = String(val);
135
+ obj[name] = val;
136
+ return rs;
137
+ });
138
+ return obj;
139
+ }
140
+
141
+ /**
142
+ * @param {string} input value
143
+ * @returns {number} output value
144
+ */
145
+ export function byteLength(str) {
146
+ // returns the byte length of an utf8 string
147
+ let s = str.length;
148
+ for (var i = str.length - 1; i >= 0; i--) {
149
+ const code = str.charCodeAt(i);
150
+ if (code > 0x7f && code <= 0x7ff) s++;
151
+ else if (code > 0x7ff && code <= 0xffff) s += 2;
152
+ if (code >= 0xdc00 && code <= 0xdfff) i--;
153
+ }
154
+ return s;
155
+ }
156
+
157
+ /**
158
+ * @param {Array} actual
159
+ * @returns {Array}
160
+ */
161
+ export function cleanArray(actual) {
162
+ const newArray = [];
163
+ for (let i = 0; i < actual.length; i++) {
164
+ if (actual[i]) {
165
+ newArray.push(actual[i]);
166
+ }
167
+ }
168
+ return newArray;
169
+ }
170
+
171
+ /**
172
+ * @param {Object} json
173
+ * @returns {Array}
174
+ */
175
+ function param(json) {
176
+ if (!json) return "";
177
+ return cleanArray(
178
+ Object.keys(json).map((key) => {
179
+ if (json[key] === undefined) return "";
180
+ return encodeURIComponent(key) + "=" + encodeURIComponent(json[key]);
181
+ })
182
+ ).join("&");
183
+ }
184
+
185
+ /**
186
+ * @param {string} url
187
+ * @returns {Object}
188
+ */
189
+ function param2Obj(url) {
190
+ const search = decodeURIComponent(url.split("?")[1]).replace(/\+/g, " ");
191
+ if (!search) {
192
+ return {};
193
+ }
194
+ const obj = {};
195
+ const searchArr = search.split("&");
196
+ searchArr.forEach((v) => {
197
+ const index = v.indexOf("=");
198
+ if (index !== -1) {
199
+ const name = v.substring(0, index);
200
+ const val = v.substring(index + 1, v.length);
201
+ obj[name] = val;
202
+ }
203
+ });
204
+ return obj;
205
+ }
206
+
207
+ /**
208
+ * @param {string} val
209
+ * @returns {string}
210
+ */
211
+ export function html2Text(val) {
212
+ const div = document.createElement("div");
213
+ div.innerHTML = val;
214
+ return div.textContent || div.innerText;
215
+ }
216
+
217
+ /**
218
+ * Merges two objects, giving the last one precedence
219
+ * @param {Object} target
220
+ * @param {(Object|Array)} source
221
+ * @returns {Object}
222
+ */
223
+ export function objectMerge(target, source) {
224
+ if (typeof target !== "object") {
225
+ target = {};
226
+ }
227
+ if (Array.isArray(source)) {
228
+ return source.slice();
229
+ }
230
+ Object.keys(source).forEach((property) => {
231
+ const sourceProperty = source[property];
232
+ if (typeof sourceProperty === "object") {
233
+ target[property] = objectMerge(target[property], sourceProperty);
234
+ } else {
235
+ target[property] = sourceProperty;
236
+ }
237
+ });
238
+ return target;
239
+ }
240
+
241
+ /**
242
+ * @param {HTMLElement} element
243
+ * @param {string} className
244
+ */
245
+ export function toggleClass(element, className) {
246
+ if (!element || !className) {
247
+ return;
248
+ }
249
+ let classString = element.className;
250
+ const nameIndex = classString.indexOf(className);
251
+ if (nameIndex === -1) {
252
+ classString += "" + className;
253
+ } else {
254
+ classString =
255
+ classString.substr(0, nameIndex) +
256
+ classString.substr(nameIndex + className.length);
257
+ }
258
+ element.className = classString;
259
+ }
260
+
261
+ /**
262
+ * @param {string} type
263
+ * @returns {Date}
264
+ */
265
+ export function getTime(type) {
266
+ if (type === "start") {
267
+ return new Date().getTime() - 3600 * 1000 * 24 * 90;
268
+ } else {
269
+ return new Date(new Date().toDateString());
270
+ }
271
+ }
272
+
273
+ /**
274
+ * @param {Function} func
275
+ * @param {number} wait
276
+ * @param {boolean} immediate
277
+ * @return {*}
278
+ */
279
+ export function debounce(func, wait, immediate) {
280
+ let timeout, args, context, timestamp, result;
281
+
282
+ const later = function () {
283
+ // 据上一次触发时间间隔
284
+ const last = +new Date() - timestamp;
285
+
286
+ // 上次被包装函数被调用时间间隔 last 小于设定时间间隔 wait
287
+ if (last < wait && last > 0) {
288
+ timeout = setTimeout(later, wait - last);
289
+ } else {
290
+ timeout = null;
291
+ // 如果设定为immediate===true,因为开始边界已经调用过了此处无需调用
292
+ if (!immediate) {
293
+ result = func.apply(context, args);
294
+ if (!timeout) context = args = null;
295
+ }
296
+ }
297
+ };
298
+
299
+ return function (...args) {
300
+ context = this;
301
+ timestamp = +new Date();
302
+ const callNow = immediate && !timeout;
303
+ // 如果延时不存在,重新设定延时
304
+ if (!timeout) timeout = setTimeout(later, wait);
305
+ if (callNow) {
306
+ result = func.apply(context, args);
307
+ context = args = null;
308
+ }
309
+
310
+ return result;
311
+ };
312
+ }
313
+
314
+ /**
315
+ * This is just a simple version of deep copy
316
+ * Has a lot of edge cases bug
317
+ * If you want to use a perfect deep copy, use lodash's _.cloneDeep
318
+ * @param {Object} source
319
+ * @returns {Object}
320
+ */
321
+ export function deepClone(source) {
322
+ if (!source && typeof source !== "object") {
323
+ throw new Error("error arguments", "deepClone");
324
+ }
325
+ const targetObj = source.constructor === Array ? [] : {};
326
+ Object.keys(source).forEach((keys) => {
327
+ if (source[keys] && typeof source[keys] === "object") {
328
+ targetObj[keys] = deepClone(source[keys]);
329
+ } else {
330
+ targetObj[keys] = source[keys];
331
+ }
332
+ });
333
+ return targetObj;
334
+ }
335
+
336
+ /**
337
+ * @param {Array} arr
338
+ * @returns {Array}
339
+ */
340
+ export function uniqueArr(arr) {
341
+ return Array.from(new Set(arr));
342
+ }
343
+
344
+ /**
345
+ * @returns {string}
346
+ */
347
+ export function createUniqueString() {
348
+ const timestamp = +new Date() + "";
349
+ const randomNum = parseInt((1 + Math.random()) * 65536) + "";
350
+ return (+(randomNum + timestamp)).toString(32);
351
+ }
352
+
353
+ /**
354
+ * Check if an element has a class
355
+ * @param {HTMLElement} elm
356
+ * @param {string} cls
357
+ * @returns {boolean}
358
+ */
359
+ export function hasClass(ele, cls) {
360
+ return !!ele.className.match(new RegExp("(\\s|^)" + cls + "(\\s|$)"));
361
+ }
362
+
363
+ /**
364
+ * Add class to element
365
+ * @param {HTMLElement} elm
366
+ * @param {string} cls
367
+ */
368
+ export function addClass(ele, cls) {
369
+ if (!hasClass(ele, cls)) ele.className += " " + cls;
370
+ }
371
+
372
+ /**
373
+ * Remove class from element
374
+ * @param {HTMLElement} elm
375
+ * @param {string} cls
376
+ */
377
+ export function removeClass(ele, cls) {
378
+ if (hasClass(ele, cls)) {
379
+ const reg = new RegExp("(\\s|^)" + cls + "(\\s|$)");
380
+ ele.className = ele.className.replace(reg, " ");
381
+ }
382
+ }
383
+
384
+ //DOM没有提供insertAfter()方法
385
+ export function insertAfter(newElement, targetElement) {
386
+ var parent = targetElement.parentNode;
387
+ if (parent.lastChild == targetElement) {
388
+ // 如果最后的节点是目标元素,则直接添加。因为默认是最后
389
+ parent.appendChild(newElement);
390
+ } else {
391
+ parent.insertBefore(newElement, targetElement.nextSibling);
392
+ //如果不是,则插入在目标元素的下一个兄弟节点 的前面。也就是目标元素的后面
393
+ }
394
+ }
395
+
396
+ //最前面插入子节点
397
+ export function prependChild(parentDom, newDom) {
398
+ if (parentDom.hasChildNodes()) {
399
+ let currentDom = parentDom.children[0];
400
+ parentDom.insertBefore(newDom, currentDom);
401
+ } else {
402
+ parentDom.append(newDom);
403
+ }
404
+ }
405
+
406
+ /**
407
+ * 实现json对象的深层拷贝
408
+ * @parent 需要拷贝的原对象
409
+ * @child 返回的拷贝完成的对象(参数可省略)
410
+ */
411
+ export function copyDeeply(parent, child) {
412
+ child = child || {};
413
+ for (var prop in parent) {
414
+ // 如果属性本身,就是一个数组或者Json对象,进行深拷贝
415
+ if (
416
+ parent[prop] !== null &&
417
+ parent[prop] !== undefined &&
418
+ typeof parent[prop] === "object"
419
+ ) {
420
+ // 确定子对象的属性类型,[]或者{}对象
421
+ child[prop] = parent[prop].constructor === Array ? [] : {};
422
+ // 实现深拷贝
423
+ copyDeeply(parent[prop], child[prop]);
424
+ } else {
425
+ child[prop] = parent[prop];
426
+ }
427
+ }
428
+ return child;
429
+ }
430
+
431
+ /**
432
+ * 实现json对象的深层继承
433
+ * @parent 被继承原对象
434
+ * @child 继承对象(把child对象继承到parent)
435
+ * @result 最终生成的结果对象(参数可省略)
436
+ */
437
+ export function extendDeeply(parent, child, result) {
438
+ result = result || copyDeeply(parent);
439
+ for (var prop in child) {
440
+ // 如果属性本身,就是一个数组或者Json对象,进行深拷贝
441
+ if (child[prop]?.constructor === Object) {
442
+ result[prop] = result[prop] || {};
443
+ parent[prop] = parent[prop] || {};
444
+ // 实现深拷贝
445
+ extendDeeply(parent[prop], child[prop], result[prop]);
446
+ } else {
447
+ result[prop] = child[prop];
448
+ }
449
+ }
450
+ return result;
451
+ }
452
+
453
+ function isDef(value) {
454
+ return value !== undefined && value !== null;
455
+ }
456
+
457
+ // 是否是对象
458
+ function isObj(x) {
459
+ const type = typeof x;
460
+ return x !== null && (type === "object" || type === "function");
461
+ }
462
+
463
+ // 深拷贝
464
+ const { hasOwnProperty } = Object.prototype;
465
+
466
+ function assignKey(to, from, key) {
467
+ const val = from[key];
468
+
469
+ if (!isDef(val)) {
470
+ return;
471
+ }
472
+
473
+ if (!hasOwnProperty.call(to, key) || !isObj(val)) {
474
+ to[key] = val;
475
+ } else {
476
+ to[key] = deepAssign(Object(to[key]), from[key]);
477
+ }
478
+ }
479
+
480
+ export function deepAssign(to, from) {
481
+ Object.keys(from).forEach((key) => {
482
+ assignKey(to, from, key);
483
+ });
484
+
485
+ return to;
486
+ }
487
+
488
+ export function initI18nMessage(dataTypeCode, languageCode, flag) {
489
+ if (settingConfig.i18nEnabled === true && getToken()) {
490
+ let language =
491
+ window.$root?.$i18n?.locale ||
492
+ localStorage.getItem("i18n-lang") ||
493
+ settingConfig.languageCode ||
494
+ "zh";
495
+ languageCode = languageCode || language;
496
+ dataTypeCode = dataTypeCode || "business";
497
+ if (window._i18nMap && window._i18nMap[dataTypeCode] && flag !== true)
498
+ return;
499
+ return window.$vueRoot.$http({
500
+ url: USER_PREFIX + "/language_translation/getMessages",
501
+ method: `post`,
502
+ data: {
503
+ languageCode: languageCode,
504
+ dataTypeCode: dataTypeCode,
505
+ },
506
+ success: (res) => {
507
+ if (res.objx) {
508
+ setTimeout(() => {
509
+ // debugger
510
+ window?.$vueRoot?.$i18n.mergeLocaleMessage(languageCode, res.objx);
511
+ /*let langMap = {[languageCode]:res.objx};
512
+ let messages = window?.$vueRoot?.$i18n?.messages;
513
+ if (messages) {
514
+ messages = deepAssign(messages, langMap);
515
+ window.$vueRoot.$i18n.messages = messages
516
+ }*/
517
+ }, 20);
518
+ }
519
+ let map = {};
520
+ let _i18nMap = window._i18nMap || {};
521
+ _i18nMap[dataTypeCode] = true;
522
+ window._i18nMap = _i18nMap;
523
+ },
524
+ });
525
+ }
526
+ }
527
+
528
+ export function getErrorMsg(value) {
529
+ if (value === undefined || value === null) return value;
530
+ let content = value ? value.trim() : value;
531
+ if (content) {
532
+ let index = content.indexOf("[*sf-cloud");
533
+ if (index === 0) {
534
+ var index0 = content.lastIndexOf("*]");
535
+ if (index0 >= 0) {
536
+ let text = content.substr(index0);
537
+ if (text) {
538
+ text = text.trim();
539
+ var index1 = text.indexOf("Exception:");
540
+ if (index1 >= 0) {
541
+ text = text.substr(index1 + 10).trim();
542
+ }
543
+ }
544
+ content = text;
545
+ }
546
+ } else if (index > 0) {
547
+ content = content.substring(0, index);
548
+ }
549
+ }
550
+ return content;
551
+ }
552
+
553
+ indexUtil = {
554
+ parseTime,
555
+ formatTime,
556
+ getQueryObject,
557
+ byteLength,
558
+ cleanArray,
559
+ param,
560
+ param2Obj,
561
+ html2Text,
562
+ objectMerge,
563
+ toggleClass,
564
+ getTime,
565
+ debounce,
566
+ deepClone,
567
+ uniqueArr,
568
+ createUniqueString,
569
+ hasClass,
570
+ addClass,
571
+ removeClass,
572
+ insertAfter,
573
+ prependChild,
574
+ extendDeeply,
575
+ initI18nMessage,
576
+ getErrorMsg,
577
+ };
578
+
579
+ export default indexUtil;