jobsys-explore 4.6.21 → 4.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (180) hide show
  1. package/.eslintignore +3 -3
  2. package/CHANGELOG.md +542 -542
  3. package/README.md +41 -41
  4. package/TODOs.md +8 -8
  5. package/business-components/survey/ExSurvey.jsx +193 -193
  6. package/business-components/survey/index.js +5 -5
  7. package/business-components/survey/index.less +36 -36
  8. package/components/button/ExButton.jsx +120 -120
  9. package/components/button/index.js +4 -4
  10. package/components/button/index.less +7 -7
  11. package/components/decorator/ExDecorator.jsx +31 -31
  12. package/components/decorator/index.js +5 -5
  13. package/components/decorator/index.less +76 -76
  14. package/components/form/ExAddress.jsx +195 -195
  15. package/components/form/ExCascader.jsx +171 -171
  16. package/components/form/ExCheckbox.jsx +59 -59
  17. package/components/form/ExDate.jsx +143 -143
  18. package/components/form/ExDatetime.jsx +166 -166
  19. package/components/form/ExField.jsx +138 -138
  20. package/components/form/ExFieldUploader.jsx +50 -50
  21. package/components/form/ExForm.jsx +544 -544
  22. package/components/form/ExMatrixCheckbox.jsx +99 -99
  23. package/components/form/ExMatrixRadio.jsx +86 -86
  24. package/components/form/ExMatrixScale.jsx +97 -97
  25. package/components/form/ExNumber.jsx +51 -51
  26. package/components/form/ExRadio.jsx +58 -58
  27. package/components/form/ExRate.jsx +51 -51
  28. package/components/form/ExSelect.jsx +251 -251
  29. package/components/form/ExSlider.jsx +55 -55
  30. package/components/form/ExSwitch.jsx +51 -51
  31. package/components/form/ExTime.jsx +99 -99
  32. package/components/form/FormItem.jsx +307 -307
  33. package/components/form/PickerWrapper.jsx +120 -120
  34. package/components/form/index.js +46 -46
  35. package/components/form/index.less +178 -178
  36. package/components/form/utils.js +62 -62
  37. package/components/grid/ExGrid.jsx +53 -53
  38. package/components/grid/index.js +4 -4
  39. package/components/grid/index.less +2 -2
  40. package/components/index.js +12 -12
  41. package/components/pagination/ExPagination.jsx +457 -440
  42. package/components/pagination/index.js +5 -5
  43. package/components/pagination/index.less +3 -3
  44. package/components/provider/ExProvider.jsx +173 -173
  45. package/components/qrcode/ExQrcode.jsx +86 -86
  46. package/components/qrcode/index.js +5 -5
  47. package/components/qrcode/index.less +8 -8
  48. package/components/result/ExResult.jsx +122 -122
  49. package/components/result/index.js +5 -5
  50. package/components/result/index.less +59 -59
  51. package/components/search/ExSearch.jsx +370 -326
  52. package/components/search/components/Expand.jsx +77 -77
  53. package/components/search/components/Field.jsx +27 -27
  54. package/components/search/components/Quick.jsx +57 -57
  55. package/components/search/components/index.js +5 -5
  56. package/components/search/index.js +5 -5
  57. package/components/search/index.less +118 -118
  58. package/components/search/utils.js +30 -30
  59. package/components/sector/ExSector.jsx +52 -52
  60. package/components/sector/README.md +26 -26
  61. package/components/sector/index.js +5 -5
  62. package/components/sector/index.less +122 -122
  63. package/components/theme/ExTheme.jsx +10 -10
  64. package/components/theme/index.js +4 -4
  65. package/components/theme/index.less +98 -98
  66. package/components/uploader/ExUploader.jsx +293 -293
  67. package/components/uploader/index.js +5 -5
  68. package/components/utils.js +187 -187
  69. package/directives/auth.js +113 -113
  70. package/directives/index.js +4 -4
  71. package/dist/cipher-98df1050.cjs.map +1 -1
  72. package/dist/cipher-f2ed5ee6.js.map +1 -1
  73. package/dist/directives.cjs.map +1 -1
  74. package/dist/directives.js.map +1 -1
  75. package/dist/hooks.cjs.map +1 -1
  76. package/dist/hooks.js.map +1 -1
  77. package/dist/jobsys-explore.cjs +6 -6
  78. package/dist/jobsys-explore.cjs.map +1 -1
  79. package/dist/jobsys-explore.js +464 -407
  80. package/dist/jobsys-explore.js.map +1 -1
  81. package/docgen.config.js +15 -15
  82. package/docs/.vuepress/.cache/deps/_metadata.json +52 -52
  83. package/docs/.vuepress/.cache/deps/lodash-es.js +8442 -8442
  84. package/docs/.vuepress/.cache/deps/lodash-es.js.map +7 -7
  85. package/docs/.vuepress/.temp/internal/clientConfigs.js +17 -17
  86. package/docs/.vuepress/.temp/internal/pagesComponents.js +24 -24
  87. package/docs/.vuepress/.temp/internal/pagesData.js +22 -22
  88. package/docs/.vuepress/.temp/internal/pagesRoutes.js +12 -12
  89. package/docs/.vuepress/.temp/internal/themeData.js +1 -1
  90. package/docs/.vuepress/.temp/pages/components/decorator/ExDecorator.html.js +1 -1
  91. package/docs/.vuepress/.temp/pages/components/decorator/ExDecorator.html.vue +37 -37
  92. package/docs/.vuepress/.temp/pages/components/sector/ExSector.html.js +1 -1
  93. package/docs/.vuepress/.temp/pages/components/sector/ExSector.html.vue +71 -71
  94. package/docs/.vuepress/.temp/styles/index.scss +1 -1
  95. package/docs/.vuepress/config.js +61 -61
  96. package/docs/.vuepress/dist/404.html +33 -33
  97. package/docs/.vuepress/dist/assets/404.html-a0ce2184.js +1 -1
  98. package/docs/.vuepress/dist/assets/ExButton.html-ad283101.js +1 -1
  99. package/docs/.vuepress/dist/assets/ExDecorator.html-42d09114.js +1 -1
  100. package/docs/.vuepress/dist/assets/ExDecorator.html-c82c5fe8.js +1 -1
  101. package/docs/.vuepress/dist/assets/ExForm.html-9e3f8000.js +1 -1
  102. package/docs/.vuepress/dist/assets/ExProvider.html-78fdc6cd.js +1 -1
  103. package/docs/.vuepress/dist/assets/ExSearch.html-103f6f34.js +1 -1
  104. package/docs/.vuepress/dist/assets/ExSector.html-a1e24c3a.js +7 -7
  105. package/docs/.vuepress/dist/assets/ExSector.html-cff3fefd.js +1 -1
  106. package/docs/.vuepress/dist/assets/ExUploader.html-8310e424.js +1 -1
  107. package/docs/.vuepress/dist/assets/app-29fe8d1e.js +10 -10
  108. package/docs/.vuepress/dist/assets/hooks.html-90ccbc1a.js +1 -1
  109. package/docs/.vuepress/dist/assets/index.html-85b79c97.js +43 -43
  110. package/docs/.vuepress/dist/assets/style-46d7e227.css +1 -1
  111. package/docs/.vuepress/dist/components/button/ExButton.html +33 -33
  112. package/docs/.vuepress/dist/components/decorator/ExDecorator.html +33 -33
  113. package/docs/.vuepress/dist/components/form/ExForm.html +33 -33
  114. package/docs/.vuepress/dist/components/provider/ExProvider.html +33 -33
  115. package/docs/.vuepress/dist/components/search/ExSearch.html +33 -33
  116. package/docs/.vuepress/dist/components/sector/ExSector.html +39 -39
  117. package/docs/.vuepress/dist/components/uploader/ExUploader.html +33 -33
  118. package/docs/.vuepress/dist/hooks.html +33 -33
  119. package/docs/.vuepress/dist/index.html +75 -75
  120. package/docs/.vuepress/styles/index.scss +7 -7
  121. package/docs/components/decorator/ExDecorator.md +14 -14
  122. package/docs/components/sector/ExSector.md +43 -43
  123. package/docs/index.md +82 -82
  124. package/hooks/cipher.js +44 -44
  125. package/hooks/datetime.js +69 -69
  126. package/hooks/form.js +188 -188
  127. package/hooks/utils.js +282 -282
  128. package/index.html +17 -17
  129. package/package.json +1 -1
  130. package/playground/App.vue +191 -191
  131. package/playground/TestButton.vue +61 -61
  132. package/playground/TestCascader.vue +2442 -2442
  133. package/playground/TestDecorator.vue +14 -14
  134. package/playground/TestForm.vue +429 -429
  135. package/playground/TestFormItem.vue +110 -110
  136. package/playground/TestGrid.vue +22 -22
  137. package/playground/TestPagination.vue +1250 -1248
  138. package/playground/TestQrcode.vue +7 -7
  139. package/playground/TestResult.vue +12 -12
  140. package/playground/TestSearch.vue +115 -115
  141. package/playground/TestSector.vue +15 -15
  142. package/playground/TestSurvey.vue +27 -27
  143. package/playground/TestUploader.vue +14 -14
  144. package/playground/main.js +22 -22
  145. package/utils/style.js +13 -13
  146. package/vite.config.js +54 -54
  147. package/.changeset/blue-spiders-roll.md +0 -5
  148. package/.changeset/cyan-monkeys-draw.md +0 -5
  149. package/.changeset/dry-feet-float.md +0 -5
  150. package/.changeset/empty-mice-share.md +0 -5
  151. package/.changeset/famous-yaks-doubt.md +0 -5
  152. package/.changeset/five-fans-type.md +0 -5
  153. package/.changeset/funny-hats-drop.md +0 -5
  154. package/.changeset/khaki-cobras-bathe.md +0 -5
  155. package/.changeset/khaki-forks-shave.md +0 -5
  156. package/.changeset/lazy-yaks-crash.md +0 -5
  157. package/.changeset/light-cycles-flow.md +0 -5
  158. package/.changeset/loud-mirrors-explain.md +0 -5
  159. package/.changeset/lovely-balloons-protect.md +0 -5
  160. package/.changeset/mean-pens-travel.md +0 -5
  161. package/.changeset/moody-doors-grow.md +0 -5
  162. package/.changeset/moody-laws-change.md +0 -5
  163. package/.changeset/nasty-goats-joke.md +0 -5
  164. package/.changeset/odd-forks-drop.md +0 -5
  165. package/.changeset/olive-windows-suffer.md +0 -5
  166. package/.changeset/popular-carpets-jog.md +0 -5
  167. package/.changeset/popular-planets-play.md +0 -5
  168. package/.changeset/rare-gorillas-boil.md +0 -5
  169. package/.changeset/rare-moose-teach.md +0 -5
  170. package/.changeset/sharp-tools-hope.md +0 -5
  171. package/.changeset/slimy-sloths-refuse.md +0 -5
  172. package/.changeset/slow-boats-search.md +0 -5
  173. package/.changeset/small-experts-bake.md +0 -5
  174. package/.changeset/smooth-horses-tie.md +0 -5
  175. package/.changeset/tame-feet-reply.md +0 -5
  176. package/.changeset/tidy-items-reflect.md +0 -5
  177. package/.changeset/weak-chicken-admire.md +0 -5
  178. package/.changeset/weak-rockets-compare.md +0 -5
  179. package/.changeset/wild-glasses-bathe.md +0 -5
  180. package/.changeset/wise-ears-turn.md +0 -5
package/hooks/utils.js CHANGED
@@ -1,282 +1,282 @@
1
- import { find, flatMapDeep, isNull, isUndefined, reduce } from "lodash-es"
2
-
3
- /**
4
- * 从 options 中根据 value 获取 text
5
- * @param value
6
- * @param options
7
- * * @param {Object} [adapter={value: "value",label: "label",children: "children"}] - 选项适配器
8
- * @param adapter
9
- * @return {*|string|string}
10
- */
11
- export function useTextFromOptionsValue(value, options, adapter) {
12
- if (!options) {
13
- return ""
14
- }
15
- adapter = adapter || {
16
- value: "value",
17
- label: "text",
18
- }
19
- const option = options.find((option) => option[adapter.value] === value)
20
- return option ? option[adapter.label] : ""
21
- }
22
-
23
- /**
24
- * 从嵌套的 options 中根据 value 获取 text, 如 [1, 3] => ["东", "南"]
25
- *
26
- * @param {Array} options - 嵌套的选项
27
- * @param {Array} values - 需要查找的值
28
- * @param {Object} [adapter={value: "value",label: "label",children: "children"}] - 选项适配器
29
- * @return Array
30
- */
31
- export function useFindTextsInValues(options, values, adapter) {
32
- adapter = adapter || {
33
- value: "value",
34
- label: "text",
35
- children: "children",
36
- }
37
-
38
- const labels = []
39
-
40
- function recursiveSearch(node) {
41
- if (values.includes(node[adapter.value])) {
42
- labels.push(node[adapter.label])
43
- }
44
-
45
- if (node[adapter.children]?.length) {
46
- node[adapter.children].forEach((child) => {
47
- recursiveSearch(child)
48
- })
49
- }
50
- }
51
-
52
- options.forEach((item) => {
53
- recursiveSearch(item)
54
- })
55
-
56
- return labels
57
- }
58
-
59
- /**
60
- * 从嵌套的 options 中根据 value 获取 label, 如地区路径: [440000, 440100, 440113] => ['广东省', '广州市', '番禺区']
61
- * @param {Array} options
62
- * @param {Array} path
63
- * @param {Object} [adapter]
64
- * @return Array
65
- */
66
- export function useFindLabelsFromPath(options, path, adapter) {
67
- adapter = adapter || {
68
- value: "value",
69
- label: "text",
70
- children: "children",
71
- }
72
-
73
- let labels = []
74
- reduce(
75
- path,
76
- (acc, value) => {
77
- const item = find(acc, { [adapter.value]: value })
78
- if (item) {
79
- labels.push(item[adapter.label])
80
- return item[adapter.children]
81
- }
82
- },
83
- options,
84
- )
85
- return labels
86
- }
87
-
88
- /**
89
- * 从 options 为 [{text: "", value: "", children: []] 样式的多层数组中,根据所给的 value 递归找出该 option
90
- * @param {Array} options
91
- * @param {Number|String} value
92
- * @param {Object} [adapter]
93
- * @return {Object|null}
94
- */
95
- export function useFindOptionByValue(options, value, adapter) {
96
- adapter = adapter || {
97
- value: "value",
98
- label: "text",
99
- children: "children",
100
- }
101
-
102
- // 遍历 options 数组
103
- for (let option of options) {
104
- // 如果当前 option 的 value 匹配目标值,则返回当前 option
105
- if (option[adapter.value] === value) {
106
- return option
107
- }
108
- // 如果当前 option 有子选项
109
- if (option[adapter.children] && option[adapter.children].length) {
110
- // 递归搜索子选项数组
111
- const foundOption = useFindOptionByValue(option[adapter.children], value, adapter)
112
- // 如果找到了匹配的子选项,则返回
113
- if (foundOption) {
114
- return foundOption
115
- }
116
- }
117
- }
118
- // 如果未找到匹配的选项,则返回 null
119
- return null
120
- }
121
-
122
- /**
123
- * [移动端适配]
124
- * 从嵌套的 options 中根据 value 获取 text
125
- * @param {Array} options
126
- * @param {Array} path
127
- * @param {Object} [adapter]
128
- * @return Array
129
- */
130
- export function useFindTextsFromPath(options, path, adapter) {
131
- adapter = adapter || {
132
- value: "value",
133
- label: "text",
134
- children: "children",
135
- }
136
- return useFindLabelsFromPath(options, path, adapter)
137
- }
138
-
139
- /**
140
- * let obj = {
141
- * "name": "西学楼1号",
142
- * "parent": {
143
- * "name": "学生宿舍",
144
- * "parent": {
145
- * "name": "宿舍区域",
146
- * }
147
- * }
148
- * }
149
- * useFindPropertyRecursive(obj, 'name', 'parent') // ["西学楼1号", "学生宿舍", "宿舍区域"]
150
- *
151
- * 从嵌套的对象中递归获取某个属性
152
- * @param {Object} item 获取对象
153
- * @param {String} propertyKey 想获取的属性名称
154
- * @param {String} nestedKey 嵌套的属性
155
- * @return Array
156
- */
157
- export function useFindPropertyRecursive(item, propertyKey, nestedKey) {
158
- return flatMapDeep(item, (value, key) => {
159
- if (key === propertyKey) {
160
- return value
161
- }
162
- if (key === nestedKey) {
163
- return useFindPropertyRecursive(value, propertyKey, nestedKey)
164
- }
165
- return []
166
- })
167
- }
168
-
169
- /**
170
- * 从嵌套的 options 中根据 value 获取 text 路径, 如地区路径: 440113 => ["广东省", "广州市", " 番禺区"]
171
- * @param options
172
- * @param value
173
- * @param adapter
174
- * @return {*}
175
- */
176
- export function useFindParentLabels(options, value, adapter) {
177
- adapter = adapter || {
178
- value: "value",
179
- label: "text",
180
- children: "children",
181
- }
182
-
183
- const labels = []
184
-
185
- function findParentLabels(options, value, labels) {
186
- for (const option of options) {
187
- if (option[adapter.value] === value) {
188
- labels.unshift(option[adapter.label])
189
- break
190
- } else if (option[adapter.children]) {
191
- const childResult = findParentLabels(option[adapter.children], value, labels)
192
- if (childResult.length > 0) {
193
- labels.unshift(option[adapter.label])
194
- break
195
- }
196
- }
197
- }
198
-
199
- return labels
200
- }
201
-
202
- return findParentLabels(options, value, labels)
203
- }
204
-
205
- /**
206
- * 从嵌套的 options 中根据 value 获取整个 values 路径, 如地区路径: 440113 => [440000, 440100, 440113]
207
- * @param options
208
- * @param value
209
- * @param adapter
210
- * @return Array
211
- */
212
- export function useFindParentValues(options, value, adapter) {
213
- adapter = adapter || {
214
- value: "value",
215
- label: "text",
216
- children: "children",
217
- }
218
-
219
- const values = []
220
-
221
- function findParentValues(options, value, values) {
222
- for (const option of options) {
223
- if (option[adapter.value] === value) {
224
- values.unshift(option[adapter.value])
225
- break
226
- } else if (option[adapter.children]) {
227
- const childResult = findParentValues(option[adapter.children], value, values)
228
- if (childResult.length > 0) {
229
- values.unshift(option[adapter.value])
230
- break
231
- }
232
- }
233
- }
234
-
235
- return values
236
- }
237
-
238
- return findParentValues(options, value, values)
239
- }
240
-
241
- const localCacheSession = {}
242
- const localSession = {
243
- setItem(key, value) {
244
- localCacheSession[key] = value
245
- },
246
- getItem(key) {
247
- return localCacheSession[key]
248
- },
249
- removeItem(key) {
250
- delete localCacheSession[key]
251
- },
252
- }
253
-
254
- window._printCache = () => {
255
- console.log(JSON.parse(JSON.stringify(localCacheSession, null, 2)))
256
- }
257
-
258
- /**
259
- * 用于储存缓存的值
260
- * @param {*} key 缓存的 key
261
- * @param {*} [sessionType] 缓存的类型,默认为内存缓存
262
- * @returns get(默认值) 获取缓存的值,set(键, 值) 设置缓存的值
263
- */
264
- export function useCache(key, sessionType) {
265
- const cacheSession = sessionType || localSession
266
- const shouldTransform = !!sessionType // 如果是 localStorage 之类的,则需要转换一下
267
- return {
268
- get(defaultValue) {
269
- const value = cacheSession.getItem(key)
270
- if (isNull(value) || isUndefined(value)) {
271
- return defaultValue
272
- }
273
- return shouldTransform ? JSON.parse(value) : value
274
- },
275
- set(value) {
276
- cacheSession.setItem(key, shouldTransform ? JSON.stringify(value) : value)
277
- },
278
- remove() {
279
- cacheSession.removeItem(key)
280
- },
281
- }
282
- }
1
+ import { find, flatMapDeep, isNull, isUndefined, reduce } from "lodash-es"
2
+
3
+ /**
4
+ * 从 options 中根据 value 获取 text
5
+ * @param value
6
+ * @param options
7
+ * * @param {Object} [adapter={value: "value",label: "label",children: "children"}] - 选项适配器
8
+ * @param adapter
9
+ * @return {*|string|string}
10
+ */
11
+ export function useTextFromOptionsValue(value, options, adapter) {
12
+ if (!options) {
13
+ return ""
14
+ }
15
+ adapter = adapter || {
16
+ value: "value",
17
+ label: "text",
18
+ }
19
+ const option = options.find((option) => option[adapter.value] === value)
20
+ return option ? option[adapter.label] : ""
21
+ }
22
+
23
+ /**
24
+ * 从嵌套的 options 中根据 value 获取 text, 如 [1, 3] => ["东", "南"]
25
+ *
26
+ * @param {Array} options - 嵌套的选项
27
+ * @param {Array} values - 需要查找的值
28
+ * @param {Object} [adapter={value: "value",label: "label",children: "children"}] - 选项适配器
29
+ * @return Array
30
+ */
31
+ export function useFindTextsInValues(options, values, adapter) {
32
+ adapter = adapter || {
33
+ value: "value",
34
+ label: "text",
35
+ children: "children",
36
+ }
37
+
38
+ const labels = []
39
+
40
+ function recursiveSearch(node) {
41
+ if (values.includes(node[adapter.value])) {
42
+ labels.push(node[adapter.label])
43
+ }
44
+
45
+ if (node[adapter.children]?.length) {
46
+ node[adapter.children].forEach((child) => {
47
+ recursiveSearch(child)
48
+ })
49
+ }
50
+ }
51
+
52
+ options.forEach((item) => {
53
+ recursiveSearch(item)
54
+ })
55
+
56
+ return labels
57
+ }
58
+
59
+ /**
60
+ * 从嵌套的 options 中根据 value 获取 label, 如地区路径: [440000, 440100, 440113] => ['广东省', '广州市', '番禺区']
61
+ * @param {Array} options
62
+ * @param {Array} path
63
+ * @param {Object} [adapter]
64
+ * @return Array
65
+ */
66
+ export function useFindLabelsFromPath(options, path, adapter) {
67
+ adapter = adapter || {
68
+ value: "value",
69
+ label: "text",
70
+ children: "children",
71
+ }
72
+
73
+ let labels = []
74
+ reduce(
75
+ path,
76
+ (acc, value) => {
77
+ const item = find(acc, { [adapter.value]: value })
78
+ if (item) {
79
+ labels.push(item[adapter.label])
80
+ return item[adapter.children]
81
+ }
82
+ },
83
+ options,
84
+ )
85
+ return labels
86
+ }
87
+
88
+ /**
89
+ * 从 options 为 [{text: "", value: "", children: []] 样式的多层数组中,根据所给的 value 递归找出该 option
90
+ * @param {Array} options
91
+ * @param {Number|String} value
92
+ * @param {Object} [adapter]
93
+ * @return {Object|null}
94
+ */
95
+ export function useFindOptionByValue(options, value, adapter) {
96
+ adapter = adapter || {
97
+ value: "value",
98
+ label: "text",
99
+ children: "children",
100
+ }
101
+
102
+ // 遍历 options 数组
103
+ for (let option of options) {
104
+ // 如果当前 option 的 value 匹配目标值,则返回当前 option
105
+ if (option[adapter.value] === value) {
106
+ return option
107
+ }
108
+ // 如果当前 option 有子选项
109
+ if (option[adapter.children] && option[adapter.children].length) {
110
+ // 递归搜索子选项数组
111
+ const foundOption = useFindOptionByValue(option[adapter.children], value, adapter)
112
+ // 如果找到了匹配的子选项,则返回
113
+ if (foundOption) {
114
+ return foundOption
115
+ }
116
+ }
117
+ }
118
+ // 如果未找到匹配的选项,则返回 null
119
+ return null
120
+ }
121
+
122
+ /**
123
+ * [移动端适配]
124
+ * 从嵌套的 options 中根据 value 获取 text
125
+ * @param {Array} options
126
+ * @param {Array} path
127
+ * @param {Object} [adapter]
128
+ * @return Array
129
+ */
130
+ export function useFindTextsFromPath(options, path, adapter) {
131
+ adapter = adapter || {
132
+ value: "value",
133
+ label: "text",
134
+ children: "children",
135
+ }
136
+ return useFindLabelsFromPath(options, path, adapter)
137
+ }
138
+
139
+ /**
140
+ * let obj = {
141
+ * "name": "西学楼1号",
142
+ * "parent": {
143
+ * "name": "学生宿舍",
144
+ * "parent": {
145
+ * "name": "宿舍区域",
146
+ * }
147
+ * }
148
+ * }
149
+ * useFindPropertyRecursive(obj, 'name', 'parent') // ["西学楼1号", "学生宿舍", "宿舍区域"]
150
+ *
151
+ * 从嵌套的对象中递归获取某个属性
152
+ * @param {Object} item 获取对象
153
+ * @param {String} propertyKey 想获取的属性名称
154
+ * @param {String} nestedKey 嵌套的属性
155
+ * @return Array
156
+ */
157
+ export function useFindPropertyRecursive(item, propertyKey, nestedKey) {
158
+ return flatMapDeep(item, (value, key) => {
159
+ if (key === propertyKey) {
160
+ return value
161
+ }
162
+ if (key === nestedKey) {
163
+ return useFindPropertyRecursive(value, propertyKey, nestedKey)
164
+ }
165
+ return []
166
+ })
167
+ }
168
+
169
+ /**
170
+ * 从嵌套的 options 中根据 value 获取 text 路径, 如地区路径: 440113 => ["广东省", "广州市", " 番禺区"]
171
+ * @param options
172
+ * @param value
173
+ * @param adapter
174
+ * @return {*}
175
+ */
176
+ export function useFindParentLabels(options, value, adapter) {
177
+ adapter = adapter || {
178
+ value: "value",
179
+ label: "text",
180
+ children: "children",
181
+ }
182
+
183
+ const labels = []
184
+
185
+ function findParentLabels(options, value, labels) {
186
+ for (const option of options) {
187
+ if (option[adapter.value] === value) {
188
+ labels.unshift(option[adapter.label])
189
+ break
190
+ } else if (option[adapter.children]) {
191
+ const childResult = findParentLabels(option[adapter.children], value, labels)
192
+ if (childResult.length > 0) {
193
+ labels.unshift(option[adapter.label])
194
+ break
195
+ }
196
+ }
197
+ }
198
+
199
+ return labels
200
+ }
201
+
202
+ return findParentLabels(options, value, labels)
203
+ }
204
+
205
+ /**
206
+ * 从嵌套的 options 中根据 value 获取整个 values 路径, 如地区路径: 440113 => [440000, 440100, 440113]
207
+ * @param options
208
+ * @param value
209
+ * @param adapter
210
+ * @return Array
211
+ */
212
+ export function useFindParentValues(options, value, adapter) {
213
+ adapter = adapter || {
214
+ value: "value",
215
+ label: "text",
216
+ children: "children",
217
+ }
218
+
219
+ const values = []
220
+
221
+ function findParentValues(options, value, values) {
222
+ for (const option of options) {
223
+ if (option[adapter.value] === value) {
224
+ values.unshift(option[adapter.value])
225
+ break
226
+ } else if (option[adapter.children]) {
227
+ const childResult = findParentValues(option[adapter.children], value, values)
228
+ if (childResult.length > 0) {
229
+ values.unshift(option[adapter.value])
230
+ break
231
+ }
232
+ }
233
+ }
234
+
235
+ return values
236
+ }
237
+
238
+ return findParentValues(options, value, values)
239
+ }
240
+
241
+ const localCacheSession = {}
242
+ const localSession = {
243
+ setItem(key, value) {
244
+ localCacheSession[key] = value
245
+ },
246
+ getItem(key) {
247
+ return localCacheSession[key]
248
+ },
249
+ removeItem(key) {
250
+ delete localCacheSession[key]
251
+ },
252
+ }
253
+
254
+ window._printCache = () => {
255
+ console.log(JSON.parse(JSON.stringify(localCacheSession, null, 2)))
256
+ }
257
+
258
+ /**
259
+ * 用于储存缓存的值
260
+ * @param {*} key 缓存的 key
261
+ * @param {*} [sessionType] 缓存的类型,默认为内存缓存
262
+ * @returns get(默认值) 获取缓存的值,set(键, 值) 设置缓存的值
263
+ */
264
+ export function useCache(key, sessionType) {
265
+ const cacheSession = sessionType || localSession
266
+ const shouldTransform = !!sessionType // 如果是 localStorage 之类的,则需要转换一下
267
+ return {
268
+ get(defaultValue) {
269
+ const value = cacheSession.getItem(key)
270
+ if (isNull(value) || isUndefined(value)) {
271
+ return defaultValue
272
+ }
273
+ return shouldTransform ? JSON.parse(value) : value
274
+ },
275
+ set(value) {
276
+ cacheSession.setItem(key, shouldTransform ? JSON.stringify(value) : value)
277
+ },
278
+ remove() {
279
+ cacheSession.removeItem(key)
280
+ },
281
+ }
282
+ }
package/index.html CHANGED
@@ -1,17 +1,17 @@
1
- <!doctype html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="utf-8">
5
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
- <meta name="viewport"
7
- content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui, viewport-fit=cover">
8
- <meta name="apple-mobile/src-web-app-capable" content="yes">
9
- <meta name="apple-mobile/src-web-app-status-bar-style" content="black">
10
- <meta name="author" content="广州职迅信息科技有限公司(https://jobsys.cn)">
11
- <title>Explore UI Playground</title>
12
- </head>
13
- <body>
14
- <div id="app"></div>
15
- <script type="module" src="./playground/main.js"></script>
16
- </body>
17
- </html>
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
+ <meta name="viewport"
7
+ content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui, viewport-fit=cover">
8
+ <meta name="apple-mobile/src-web-app-capable" content="yes">
9
+ <meta name="apple-mobile/src-web-app-status-bar-style" content="black">
10
+ <meta name="author" content="广州职迅信息科技有限公司(https://jobsys.cn)">
11
+ <title>Explore UI Playground</title>
12
+ </head>
13
+ <body>
14
+ <div id="app"></div>
15
+ <script type="module" src="./playground/main.js"></script>
16
+ </body>
17
+ </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jobsys-explore",
3
- "version": "4.6.21",
3
+ "version": "4.7.0",
4
4
  "description": "Enhanced component based on vant",
5
5
  "type": "module",
6
6
  "main": "./dist/jobsys-explore.cjs",