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
@@ -1,251 +1,251 @@
1
- import { computed, defineComponent, ref, watch } from "vue"
2
- import PickerWrapper, { pickerSlots } from "./PickerWrapper.jsx"
3
- import { Button, Form, Picker, Search } from "vant"
4
- import { defaultFieldProps, defaultOptionsProps } from "../utils"
5
- import { useFetch } from "../../hooks"
6
- import { cloneDeep, find, isArray, isFunction, isNumber, isString } from "lodash-es"
7
-
8
- /**
9
- * ExSelect 下拉选择
10
- * @version 1.0.0
11
- */
12
- export default defineComponent({
13
- name: "ExSelect",
14
- props: {
15
- ...defaultOptionsProps,
16
- ...defaultFieldProps,
17
-
18
- modelValue: { type: [Array, String, Number, Object], default: "" },
19
-
20
- /**
21
- * 标题
22
- */
23
- title: { type: String, default: "" },
24
-
25
- /**
26
- * 是否显示清除按钮
27
- */
28
- clearable: { type: Boolean, default: false },
29
-
30
- /**
31
- * 是否把选项的值返回到modelValue
32
- */
33
- textInValue: { type: Boolean, default: false },
34
-
35
- /**
36
- * 是否可以搜索
37
- */
38
- filterable: { type: Boolean, default: false },
39
-
40
- /**
41
- * 搜索链接
42
- */
43
- filterUrl: { type: String, default: "" },
44
-
45
- /**
46
- * 自定义渲染选项
47
- */
48
- optionRender: { type: Function, default: null },
49
- },
50
- emits: ["update:modelValue", "change"],
51
- setup(props, { emit, slots, expose }) {
52
- const componentValue = ref([])
53
- const options = ref([])
54
- const recordOptions = ref([]) // 缓存 options
55
- let columns = 1 //根据子项的数组数来确定 Picker 的列数,默认为1列
56
- const pickerRef = ref()
57
- const keyword = ref("")
58
- const fetcher = ref({ loading: false })
59
-
60
- const setModelValue = () => {
61
- let value = isArray(props.modelValue) ? props.modelValue : [props.modelValue]
62
- if (props.textInValue && value.length) {
63
- value = value.map((item) => item.value)
64
- }
65
- componentValue.value = value
66
- }
67
- setModelValue()
68
-
69
- watch(
70
- () => props.modelValue,
71
- () => setModelValue(),
72
- )
73
-
74
- const displayText = computed(() => {
75
- if (!props.modelValue || (isArray(props.modelValue) && !props.modelValue.length)) {
76
- return ""
77
- }
78
- let modelValue = isArray(props.modelValue) ? props.modelValue : [props.modelValue]
79
- return modelValue
80
- .map((value, index) => {
81
- if (props.textInValue) {
82
- value = value.value
83
- }
84
- if (columns === 1) {
85
- return find(options.value, { value })?.text
86
- } else {
87
- return find(options.value[index], { value })?.text
88
- }
89
- })
90
- ?.join("/")
91
- })
92
-
93
- const fetchData = () =>
94
- new Promise((resolve) => {
95
- useFetch()
96
- .get(props.url)
97
- .then((items) => {
98
- if (props.afterFetched) {
99
- items = props.afterFetched(items)
100
- }
101
- resolve(items)
102
- })
103
- })
104
-
105
- const prepareOptions = async (options) => {
106
- options = isFunction(options) ? options() : options
107
- if (options && options.length) {
108
- columns = options.filter((option) => isArray(option)).length || 1
109
- } else if (props.url) {
110
- options = await fetchData()
111
- }
112
-
113
- options = options.map((option) => {
114
- if (isArray(option)) {
115
- return option.map((op) => {
116
- return isString(op) || isNumber(op) ? { value: op, label: op, text: op } : { text: op.label, ...op }
117
- })
118
- }
119
-
120
- return isString(option) ? { value: option, label: option, text: option } : { text: option.label, ...option }
121
- })
122
-
123
- recordOptions.value = cloneDeep(options)
124
-
125
- return options
126
- }
127
-
128
- prepareOptions(props.options).then((opts) => {
129
- options.value = opts
130
- })
131
-
132
- watch(
133
- () => props.options,
134
- () => prepareOptions(props.options).then((opts) => (options.value = opts)),
135
- )
136
-
137
- const filterOnlineDataByKeyword = async () => {
138
- let res = await useFetch(fetcher.value).get(props.filterUrl, { params: { keyword: keyword.value } })
139
- if (props.afterFetched) {
140
- res = props.afterFetched(res)
141
- }
142
- prepareOptions(res).then((opts) => (options.value = opts))
143
- }
144
-
145
- const filterLocalDataByKeyword = () => {
146
- options.value = recordOptions.value.filter((item) => item.text.includes(keyword.value))
147
- }
148
-
149
- // @hack
150
- // 由于在 Picker 清除 model value 后再次打开 Picker 在不重新选择新选项的情况下无法选中之前的选项
151
- // 所以这里手动重新赋一次值给 model value
152
- const onOpenWrapper = () => {
153
- if (columns === 1 && !componentValue.value?.[0]) {
154
- componentValue.value = [options.value[0]?.value]
155
- }
156
- }
157
-
158
- const onConfirm = ({ selectedOptions }) => {
159
- let value = props.textInValue ? selectedOptions : selectedOptions.map((item) => item.value)
160
- value = columns === 1 ? value[0] : value
161
- emit("change", value)
162
- emit("update:modelValue", value)
163
- pickerRef.value.close()
164
- }
165
-
166
- const onSearch = () => {
167
- if (keyword.value) {
168
- if (props.filterUrl) {
169
- filterOnlineDataByKeyword()
170
- } else {
171
- filterLocalDataByKeyword()
172
- }
173
- } else {
174
- if (props.filterUrl) {
175
- filterOnlineDataByKeyword()
176
- } else {
177
- filterLocalDataByKeyword()
178
- }
179
- }
180
- }
181
-
182
- const onSearchClear = () => {
183
- if (props.filterUrl) {
184
- filterOnlineDataByKeyword()
185
- } else {
186
- filterLocalDataByKeyword()
187
- }
188
- }
189
-
190
- const onClear = () => {
191
- const value = columns === 1 ? null : []
192
- emit("change", value)
193
- emit("update:modelValue", value)
194
- pickerRef.value.close()
195
- }
196
-
197
- expose({ displayText })
198
-
199
- /********** render **********/
200
-
201
- const pickerSlotElem = () => {
202
- const elem = {}
203
- if (props.filterable) {
204
- elem["columns-top"] = () => (
205
- <Form action="/">
206
- <Search
207
- shape={"round"}
208
- placeholder={"搜索"}
209
- v-model={keyword.value}
210
- onSearch={onSearch}
211
- onUpdate:modelValue={onSearch}
212
- onClear={onSearchClear}
213
- style={{ width: "100%" }}
214
- ></Search>
215
- </Form>
216
- )
217
- }
218
- if (props.optionRender) {
219
- elem["option"] = (option, index) => props.optionRender(option, index)
220
- }
221
- return elem
222
- }
223
-
224
- return () => (
225
- <PickerWrapper ref={pickerRef} closeable={false} onOpen={onOpenWrapper} disabled={props.readonly || props.disabled}>
226
- {{
227
- ...pickerSlots(slots, props),
228
- default: () => [
229
- <Picker
230
- v-model={componentValue.value}
231
- columns={options.value}
232
- onConfirm={onConfirm}
233
- loading={fetcher.value.loading}
234
- onCancel={() => pickerRef.value.close()}
235
- {...props.defaultProps}
236
- >
237
- {pickerSlotElem()}
238
- </Picker>,
239
- props.clearable ? (
240
- <div class={"ex-field-popup__clear-btn"}>
241
- <Button block type={"primary"} plain={true} round={true} onClick={onClear}>
242
- 清除
243
- </Button>
244
- </div>
245
- ) : null,
246
- ],
247
- }}
248
- </PickerWrapper>
249
- )
250
- },
251
- })
1
+ import { computed, defineComponent, ref, watch } from "vue"
2
+ import PickerWrapper, { pickerSlots } from "./PickerWrapper.jsx"
3
+ import { Button, Form, Picker, Search } from "vant"
4
+ import { defaultFieldProps, defaultOptionsProps } from "../utils"
5
+ import { useFetch } from "../../hooks"
6
+ import { cloneDeep, find, isArray, isFunction, isNumber, isString } from "lodash-es"
7
+
8
+ /**
9
+ * ExSelect 下拉选择
10
+ * @version 1.0.0
11
+ */
12
+ export default defineComponent({
13
+ name: "ExSelect",
14
+ props: {
15
+ ...defaultOptionsProps,
16
+ ...defaultFieldProps,
17
+
18
+ modelValue: { type: [Array, String, Number, Object], default: "" },
19
+
20
+ /**
21
+ * 标题
22
+ */
23
+ title: { type: String, default: "" },
24
+
25
+ /**
26
+ * 是否显示清除按钮
27
+ */
28
+ clearable: { type: Boolean, default: false },
29
+
30
+ /**
31
+ * 是否把选项的值返回到modelValue
32
+ */
33
+ textInValue: { type: Boolean, default: false },
34
+
35
+ /**
36
+ * 是否可以搜索
37
+ */
38
+ filterable: { type: Boolean, default: false },
39
+
40
+ /**
41
+ * 搜索链接
42
+ */
43
+ filterUrl: { type: String, default: "" },
44
+
45
+ /**
46
+ * 自定义渲染选项
47
+ */
48
+ optionRender: { type: Function, default: null },
49
+ },
50
+ emits: ["update:modelValue", "change"],
51
+ setup(props, { emit, slots, expose }) {
52
+ const componentValue = ref([])
53
+ const options = ref([])
54
+ const recordOptions = ref([]) // 缓存 options
55
+ let columns = 1 //根据子项的数组数来确定 Picker 的列数,默认为1列
56
+ const pickerRef = ref()
57
+ const keyword = ref("")
58
+ const fetcher = ref({ loading: false })
59
+
60
+ const setModelValue = () => {
61
+ let value = isArray(props.modelValue) ? props.modelValue : [props.modelValue]
62
+ if (props.textInValue && value.length) {
63
+ value = value.map((item) => item.value)
64
+ }
65
+ componentValue.value = value
66
+ }
67
+ setModelValue()
68
+
69
+ watch(
70
+ () => props.modelValue,
71
+ () => setModelValue(),
72
+ )
73
+
74
+ const displayText = computed(() => {
75
+ if (!props.modelValue || (isArray(props.modelValue) && !props.modelValue.length)) {
76
+ return ""
77
+ }
78
+ let modelValue = isArray(props.modelValue) ? props.modelValue : [props.modelValue]
79
+ return modelValue
80
+ .map((value, index) => {
81
+ if (props.textInValue) {
82
+ value = value.value
83
+ }
84
+ if (columns === 1) {
85
+ return find(options.value, { value })?.text
86
+ } else {
87
+ return find(options.value[index], { value })?.text
88
+ }
89
+ })
90
+ ?.join("/")
91
+ })
92
+
93
+ const fetchData = () =>
94
+ new Promise((resolve) => {
95
+ useFetch()
96
+ .get(props.url)
97
+ .then((items) => {
98
+ if (props.afterFetched) {
99
+ items = props.afterFetched(items)
100
+ }
101
+ resolve(items)
102
+ })
103
+ })
104
+
105
+ const prepareOptions = async (options) => {
106
+ options = isFunction(options) ? options() : options
107
+ if (options && options.length) {
108
+ columns = options.filter((option) => isArray(option)).length || 1
109
+ } else if (props.url) {
110
+ options = await fetchData()
111
+ }
112
+
113
+ options = options.map((option) => {
114
+ if (isArray(option)) {
115
+ return option.map((op) => {
116
+ return isString(op) || isNumber(op) ? { value: op, label: op, text: op } : { text: op.label, ...op }
117
+ })
118
+ }
119
+
120
+ return isString(option) ? { value: option, label: option, text: option } : { text: option.label, ...option }
121
+ })
122
+
123
+ recordOptions.value = cloneDeep(options)
124
+
125
+ return options
126
+ }
127
+
128
+ prepareOptions(props.options).then((opts) => {
129
+ options.value = opts
130
+ })
131
+
132
+ watch(
133
+ () => props.options,
134
+ () => prepareOptions(props.options).then((opts) => (options.value = opts)),
135
+ )
136
+
137
+ const filterOnlineDataByKeyword = async () => {
138
+ let res = await useFetch(fetcher.value).get(props.filterUrl, { params: { keyword: keyword.value } })
139
+ if (props.afterFetched) {
140
+ res = props.afterFetched(res)
141
+ }
142
+ prepareOptions(res).then((opts) => (options.value = opts))
143
+ }
144
+
145
+ const filterLocalDataByKeyword = () => {
146
+ options.value = recordOptions.value.filter((item) => item.text.includes(keyword.value))
147
+ }
148
+
149
+ // @hack
150
+ // 由于在 Picker 清除 model value 后再次打开 Picker 在不重新选择新选项的情况下无法选中之前的选项
151
+ // 所以这里手动重新赋一次值给 model value
152
+ const onOpenWrapper = () => {
153
+ if (columns === 1 && !componentValue.value?.[0]) {
154
+ componentValue.value = [options.value[0]?.value]
155
+ }
156
+ }
157
+
158
+ const onConfirm = ({ selectedOptions }) => {
159
+ let value = props.textInValue ? selectedOptions : selectedOptions.map((item) => item.value)
160
+ value = columns === 1 ? value[0] : value
161
+ emit("change", value)
162
+ emit("update:modelValue", value)
163
+ pickerRef.value.close()
164
+ }
165
+
166
+ const onSearch = () => {
167
+ if (keyword.value) {
168
+ if (props.filterUrl) {
169
+ filterOnlineDataByKeyword()
170
+ } else {
171
+ filterLocalDataByKeyword()
172
+ }
173
+ } else {
174
+ if (props.filterUrl) {
175
+ filterOnlineDataByKeyword()
176
+ } else {
177
+ filterLocalDataByKeyword()
178
+ }
179
+ }
180
+ }
181
+
182
+ const onSearchClear = () => {
183
+ if (props.filterUrl) {
184
+ filterOnlineDataByKeyword()
185
+ } else {
186
+ filterLocalDataByKeyword()
187
+ }
188
+ }
189
+
190
+ const onClear = () => {
191
+ const value = columns === 1 ? null : []
192
+ emit("change", value)
193
+ emit("update:modelValue", value)
194
+ pickerRef.value.close()
195
+ }
196
+
197
+ expose({ displayText })
198
+
199
+ /********** render **********/
200
+
201
+ const pickerSlotElem = () => {
202
+ const elem = {}
203
+ if (props.filterable) {
204
+ elem["columns-top"] = () => (
205
+ <Form action="/">
206
+ <Search
207
+ shape={"round"}
208
+ placeholder={"搜索"}
209
+ v-model={keyword.value}
210
+ onSearch={onSearch}
211
+ onUpdate:modelValue={onSearch}
212
+ onClear={onSearchClear}
213
+ style={{ width: "100%" }}
214
+ ></Search>
215
+ </Form>
216
+ )
217
+ }
218
+ if (props.optionRender) {
219
+ elem["option"] = (option, index) => props.optionRender(option, index)
220
+ }
221
+ return elem
222
+ }
223
+
224
+ return () => (
225
+ <PickerWrapper ref={pickerRef} closeable={false} onOpen={onOpenWrapper} disabled={props.readonly || props.disabled}>
226
+ {{
227
+ ...pickerSlots(slots, props),
228
+ default: () => [
229
+ <Picker
230
+ v-model={componentValue.value}
231
+ columns={options.value}
232
+ onConfirm={onConfirm}
233
+ loading={fetcher.value.loading}
234
+ onCancel={() => pickerRef.value.close()}
235
+ {...props.defaultProps}
236
+ >
237
+ {pickerSlotElem()}
238
+ </Picker>,
239
+ props.clearable ? (
240
+ <div class={"ex-field-popup__clear-btn"}>
241
+ <Button block type={"primary"} plain={true} round={true} onClick={onClear}>
242
+ 清除
243
+ </Button>
244
+ </div>
245
+ ) : null,
246
+ ],
247
+ }}
248
+ </PickerWrapper>
249
+ )
250
+ },
251
+ })
@@ -1,55 +1,55 @@
1
- import { defineComponent, ref, watch } from "vue"
2
- import { defaultFieldProps } from "../utils"
3
- import { Slider } from "vant"
4
- import ExField from "./ExField.jsx"
5
- import { pick } from "lodash-es"
6
-
7
- /**
8
- * ExSlider 评分
9
- * @version 1.0.0
10
- */
11
- export default defineComponent({
12
- name: "ExSlider",
13
- props: {
14
- ...defaultFieldProps,
15
-
16
- modelValue: { type: [Number, Array], default: 2 },
17
- },
18
- emits: ["update:modelValue"],
19
- setup(props, { emit, slots }) {
20
- const componentValue = ref(props.modelValue)
21
-
22
- watch(
23
- () => props.modelValue,
24
- () => (componentValue.value = props.modelValue),
25
- )
26
-
27
- const onChange = (value) => {
28
- emit("update:modelValue", value)
29
- }
30
-
31
- const fieldProps = pick(props, Object.keys(defaultFieldProps))
32
-
33
- return () => (
34
- <ExField {...fieldProps}>
35
- {{
36
- ...slots,
37
- input: () => (
38
- <Slider
39
- v-model={componentValue.value}
40
- readonly={props.readonly}
41
- disabled={props.disabled}
42
- clearable={true}
43
- {...props.defaultProps}
44
- onChange={onChange}
45
- >
46
- {{
47
- button: () => <div class="ex-slider-button">{componentValue.value}</div>,
48
- }}
49
- </Slider>
50
- ),
51
- }}
52
- </ExField>
53
- )
54
- },
55
- })
1
+ import { defineComponent, ref, watch } from "vue"
2
+ import { defaultFieldProps } from "../utils"
3
+ import { Slider } from "vant"
4
+ import ExField from "./ExField.jsx"
5
+ import { pick } from "lodash-es"
6
+
7
+ /**
8
+ * ExSlider 评分
9
+ * @version 1.0.0
10
+ */
11
+ export default defineComponent({
12
+ name: "ExSlider",
13
+ props: {
14
+ ...defaultFieldProps,
15
+
16
+ modelValue: { type: [Number, Array], default: 2 },
17
+ },
18
+ emits: ["update:modelValue"],
19
+ setup(props, { emit, slots }) {
20
+ const componentValue = ref(props.modelValue)
21
+
22
+ watch(
23
+ () => props.modelValue,
24
+ () => (componentValue.value = props.modelValue),
25
+ )
26
+
27
+ const onChange = (value) => {
28
+ emit("update:modelValue", value)
29
+ }
30
+
31
+ const fieldProps = pick(props, Object.keys(defaultFieldProps))
32
+
33
+ return () => (
34
+ <ExField {...fieldProps}>
35
+ {{
36
+ ...slots,
37
+ input: () => (
38
+ <Slider
39
+ v-model={componentValue.value}
40
+ readonly={props.readonly}
41
+ disabled={props.disabled}
42
+ clearable={true}
43
+ {...props.defaultProps}
44
+ onChange={onChange}
45
+ >
46
+ {{
47
+ button: () => <div class="ex-slider-button">{componentValue.value}</div>,
48
+ }}
49
+ </Slider>
50
+ ),
51
+ }}
52
+ </ExField>
53
+ )
54
+ },
55
+ })