jobsys-explore 4.7.11 → 4.7.13

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 (206) hide show
  1. package/.changeset/config.json +11 -11
  2. package/.eslintignore +3 -3
  3. package/.eslintrc.cjs +37 -37
  4. package/.prettierrc.cjs +38 -38
  5. package/CHANGELOG.md +542 -542
  6. package/README.md +41 -41
  7. package/TODOs.md +8 -8
  8. package/business-components/index.js +1 -1
  9. package/business-components/survey/ExSurvey.jsx +193 -193
  10. package/business-components/survey/index.js +5 -5
  11. package/business-components/survey/index.less +36 -36
  12. package/components/button/ExButton.jsx +120 -120
  13. package/components/button/index.js +4 -4
  14. package/components/button/index.less +7 -7
  15. package/components/decorator/ExDecorator.jsx +31 -31
  16. package/components/decorator/index.js +5 -5
  17. package/components/decorator/index.less +76 -76
  18. package/components/form/ExAddress.jsx +195 -195
  19. package/components/form/ExCascader.jsx +171 -171
  20. package/components/form/ExCheckbox.jsx +59 -59
  21. package/components/form/ExDate.jsx +143 -143
  22. package/components/form/ExDatetime.jsx +166 -166
  23. package/components/form/ExField.jsx +138 -138
  24. package/components/form/ExFieldUploader.jsx +50 -50
  25. package/components/form/ExForm.jsx +549 -549
  26. package/components/form/ExMatrixCheckbox.jsx +99 -99
  27. package/components/form/ExMatrixRadio.jsx +86 -86
  28. package/components/form/ExMatrixScale.jsx +97 -97
  29. package/components/form/ExNumber.jsx +51 -51
  30. package/components/form/ExRadio.jsx +58 -58
  31. package/components/form/ExRate.jsx +51 -51
  32. package/components/form/ExSelect.jsx +251 -251
  33. package/components/form/ExSlider.jsx +55 -55
  34. package/components/form/ExSwitch.jsx +51 -51
  35. package/components/form/ExTime.jsx +99 -99
  36. package/components/form/FormItem.jsx +307 -307
  37. package/components/form/PickerWrapper.jsx +120 -120
  38. package/components/form/index.js +46 -46
  39. package/components/form/index.less +178 -178
  40. package/components/form/utils.js +62 -63
  41. package/components/grid/ExGrid.jsx +53 -53
  42. package/components/grid/index.js +4 -4
  43. package/components/grid/index.less +2 -2
  44. package/components/index.js +12 -12
  45. package/components/pagination/ExPagination.jsx +459 -457
  46. package/components/pagination/index.js +5 -5
  47. package/components/pagination/index.less +3 -3
  48. package/components/provider/ExProvider.jsx +173 -173
  49. package/components/provider/index.js +4 -4
  50. package/components/qrcode/ExQrcode.jsx +86 -86
  51. package/components/qrcode/index.js +5 -5
  52. package/components/qrcode/index.less +8 -8
  53. package/components/result/ExResult.jsx +122 -122
  54. package/components/result/index.js +5 -5
  55. package/components/result/index.less +59 -59
  56. package/components/search/ExSearch.jsx +375 -375
  57. package/components/search/components/Expand.jsx +77 -77
  58. package/components/search/components/Field.jsx +27 -27
  59. package/components/search/components/Quick.jsx +57 -57
  60. package/components/search/components/index.js +5 -5
  61. package/components/search/index.js +5 -5
  62. package/components/search/index.less +118 -118
  63. package/components/search/utils.js +30 -30
  64. package/components/sector/ExSector.jsx +52 -52
  65. package/components/sector/README.md +26 -26
  66. package/components/sector/index.js +5 -5
  67. package/components/sector/index.less +122 -122
  68. package/components/theme/ExTheme.jsx +10 -10
  69. package/components/theme/index.js +4 -4
  70. package/components/theme/index.less +98 -98
  71. package/components/uploader/ExUploader.jsx +303 -303
  72. package/components/uploader/index.js +5 -5
  73. package/components/utils.js +187 -187
  74. package/directives/auth.js +113 -113
  75. package/directives/index.js +4 -4
  76. package/dist/cipher-98df1050.cjs.map +1 -1
  77. package/dist/cipher-f2ed5ee6.js.map +1 -1
  78. package/dist/directives.cjs.map +1 -1
  79. package/dist/directives.js.map +1 -1
  80. package/dist/hooks.cjs.map +1 -1
  81. package/dist/hooks.js.map +1 -1
  82. package/dist/jobsys-explore.cjs +5 -5
  83. package/dist/jobsys-explore.cjs.map +1 -1
  84. package/dist/jobsys-explore.js +10 -3
  85. package/dist/jobsys-explore.js.map +1 -1
  86. package/docgen.config.js +15 -15
  87. package/docs/.vuepress/.cache/deps/@vue_devtools-api.js +11 -11
  88. package/docs/.vuepress/.cache/deps/@vue_devtools-api.js.map +7 -7
  89. package/docs/.vuepress/.cache/deps/@vuepress_shared.js +110 -110
  90. package/docs/.vuepress/.cache/deps/@vuepress_shared.js.map +7 -7
  91. package/docs/.vuepress/.cache/deps/@vueuse_core.js +8758 -8758
  92. package/docs/.vuepress/.cache/deps/@vueuse_core.js.map +7 -7
  93. package/docs/.vuepress/.cache/deps/_metadata.json +52 -52
  94. package/docs/.vuepress/.cache/deps/chunk-37RBVGNF.js +10577 -10577
  95. package/docs/.vuepress/.cache/deps/chunk-37RBVGNF.js.map +7 -7
  96. package/docs/.vuepress/.cache/deps/chunk-H2FJVFR5.js +163 -163
  97. package/docs/.vuepress/.cache/deps/chunk-H2FJVFR5.js.map +7 -7
  98. package/docs/.vuepress/.cache/deps/chunk-L7E56NPU.js +306 -306
  99. package/docs/.vuepress/.cache/deps/chunk-L7E56NPU.js.map +7 -7
  100. package/docs/.vuepress/.cache/deps/lodash-es.js +8442 -8442
  101. package/docs/.vuepress/.cache/deps/lodash-es.js.map +7 -7
  102. package/docs/.vuepress/.cache/deps/package.json +3 -3
  103. package/docs/.vuepress/.cache/deps/vue-router.js +2667 -2667
  104. package/docs/.vuepress/.cache/deps/vue-router.js.map +7 -7
  105. package/docs/.vuepress/.cache/deps/vue.js +315 -315
  106. package/docs/.vuepress/.cache/deps/vue.js.map +7 -7
  107. package/docs/.vuepress/.temp/internal/clientConfigs.js +17 -17
  108. package/docs/.vuepress/.temp/internal/pagesComponents.js +24 -24
  109. package/docs/.vuepress/.temp/internal/pagesData.js +22 -22
  110. package/docs/.vuepress/.temp/internal/pagesRoutes.js +12 -12
  111. package/docs/.vuepress/.temp/internal/siteData.js +1 -1
  112. package/docs/.vuepress/.temp/internal/themeData.js +1 -1
  113. package/docs/.vuepress/.temp/pages/404.html.js +1 -1
  114. package/docs/.vuepress/.temp/pages/404.html.vue +3 -3
  115. package/docs/.vuepress/.temp/pages/components/button/ExButton.html.js +1 -1
  116. package/docs/.vuepress/.temp/pages/components/button/ExButton.html.vue +111 -111
  117. package/docs/.vuepress/.temp/pages/components/decorator/ExDecorator.html.js +1 -1
  118. package/docs/.vuepress/.temp/pages/components/decorator/ExDecorator.html.vue +37 -37
  119. package/docs/.vuepress/.temp/pages/components/form/ExForm.html.js +1 -1
  120. package/docs/.vuepress/.temp/pages/components/form/ExForm.html.vue +187 -187
  121. package/docs/.vuepress/.temp/pages/components/provider/ExProvider.html.js +1 -1
  122. package/docs/.vuepress/.temp/pages/components/provider/ExProvider.html.vue +51 -51
  123. package/docs/.vuepress/.temp/pages/components/search/ExSearch.html.js +1 -1
  124. package/docs/.vuepress/.temp/pages/components/search/ExSearch.html.vue +108 -108
  125. package/docs/.vuepress/.temp/pages/components/sector/ExSector.html.js +1 -1
  126. package/docs/.vuepress/.temp/pages/components/sector/ExSector.html.vue +71 -71
  127. package/docs/.vuepress/.temp/pages/components/uploader/ExUploader.html.js +1 -1
  128. package/docs/.vuepress/.temp/pages/components/uploader/ExUploader.html.vue +162 -162
  129. package/docs/.vuepress/.temp/pages/hooks.html.js +1 -1
  130. package/docs/.vuepress/.temp/pages/hooks.html.vue +697 -697
  131. package/docs/.vuepress/.temp/pages/index.html.js +1 -1
  132. package/docs/.vuepress/.temp/pages/index.html.vue +56 -56
  133. package/docs/.vuepress/.temp/styles/index.scss +1 -1
  134. package/docs/.vuepress/.temp/vite-root/index.html +13 -13
  135. package/docs/.vuepress/config.js +61 -61
  136. package/docs/.vuepress/dist/404.html +33 -33
  137. package/docs/.vuepress/dist/assets/404.html-a0ce2184.js +1 -1
  138. package/docs/.vuepress/dist/assets/404.html-f9875e7b.js +1 -1
  139. package/docs/.vuepress/dist/assets/ExButton.html-ad283101.js +1 -1
  140. package/docs/.vuepress/dist/assets/ExButton.html-b975c5b2.js +1 -1
  141. package/docs/.vuepress/dist/assets/ExDecorator.html-42d09114.js +1 -1
  142. package/docs/.vuepress/dist/assets/ExDecorator.html-c82c5fe8.js +1 -1
  143. package/docs/.vuepress/dist/assets/ExForm.html-24f42bf7.js +1 -1
  144. package/docs/.vuepress/dist/assets/ExForm.html-9e3f8000.js +1 -1
  145. package/docs/.vuepress/dist/assets/ExProvider.html-50d01930.js +1 -1
  146. package/docs/.vuepress/dist/assets/ExProvider.html-78fdc6cd.js +1 -1
  147. package/docs/.vuepress/dist/assets/ExSearch.html-103f6f34.js +1 -1
  148. package/docs/.vuepress/dist/assets/ExSearch.html-635a618b.js +1 -1
  149. package/docs/.vuepress/dist/assets/ExSector.html-a1e24c3a.js +7 -7
  150. package/docs/.vuepress/dist/assets/ExSector.html-cff3fefd.js +1 -1
  151. package/docs/.vuepress/dist/assets/ExUploader.html-8310e424.js +1 -1
  152. package/docs/.vuepress/dist/assets/ExUploader.html-f059c617.js +1 -1
  153. package/docs/.vuepress/dist/assets/app-29fe8d1e.js +10 -10
  154. package/docs/.vuepress/dist/assets/hooks.html-90ccbc1a.js +1 -1
  155. package/docs/.vuepress/dist/assets/hooks.html-ddb4f378.js +1 -1
  156. package/docs/.vuepress/dist/assets/index.html-85b79c97.js +43 -43
  157. package/docs/.vuepress/dist/assets/index.html-e18a38b1.js +1 -1
  158. package/docs/.vuepress/dist/assets/style-46d7e227.css +1 -1
  159. package/docs/.vuepress/dist/components/button/ExButton.html +33 -33
  160. package/docs/.vuepress/dist/components/decorator/ExDecorator.html +33 -33
  161. package/docs/.vuepress/dist/components/form/ExForm.html +33 -33
  162. package/docs/.vuepress/dist/components/provider/ExProvider.html +33 -33
  163. package/docs/.vuepress/dist/components/search/ExSearch.html +33 -33
  164. package/docs/.vuepress/dist/components/sector/ExSector.html +39 -39
  165. package/docs/.vuepress/dist/components/uploader/ExUploader.html +33 -33
  166. package/docs/.vuepress/dist/hooks.html +33 -33
  167. package/docs/.vuepress/dist/index.html +75 -75
  168. package/docs/.vuepress/styles/index.scss +7 -7
  169. package/docs/components/button/ExButton.md +30 -30
  170. package/docs/components/decorator/ExDecorator.md +14 -14
  171. package/docs/components/form/ExForm.md +39 -39
  172. package/docs/components/provider/ExProvider.md +16 -16
  173. package/docs/components/search/ExSearch.md +28 -28
  174. package/docs/components/sector/ExSector.md +43 -43
  175. package/docs/components/uploader/ExUploader.md +36 -36
  176. package/docs/index.md +82 -82
  177. package/hooks/cipher.js +44 -44
  178. package/hooks/datetime.js +69 -69
  179. package/hooks/form.js +188 -188
  180. package/hooks/index.js +5 -5
  181. package/hooks/network.js +122 -122
  182. package/hooks/utils.js +282 -282
  183. package/index.html +17 -17
  184. package/index.js +31 -31
  185. package/package.json +5 -5
  186. package/playground/App.vue +191 -192
  187. package/playground/TestButton.vue +61 -61
  188. package/playground/TestCascader.vue +2442 -2442
  189. package/playground/TestDecorator.vue +14 -14
  190. package/playground/TestForm.vue +429 -466
  191. package/playground/TestFormItem.vue +110 -110
  192. package/playground/TestGrid.vue +22 -22
  193. package/playground/TestPagination.vue +1250 -1250
  194. package/playground/TestQrcode.vue +7 -7
  195. package/playground/TestResult.vue +12 -12
  196. package/playground/TestSearch.vue +115 -115
  197. package/playground/TestSector.vue +15 -15
  198. package/playground/TestSurvey.vue +27 -27
  199. package/playground/TestUploader.vue +14 -14
  200. package/playground/http.js +23 -23
  201. package/playground/main.js +22 -22
  202. package/postcss.config.cjs +8 -8
  203. package/utils/style.js +13 -13
  204. package/utils/withInstall.js +7 -7
  205. package/vite.config.js +54 -54
  206. package/.changeset/twelve-fans-fix.md +0 -5
@@ -1,143 +1,143 @@
1
- import { computed, defineComponent, ref, watch } from "vue"
2
- import PickerWrapper, { pickerSlots } from "./PickerWrapper.jsx"
3
- import { DatePicker } from "vant"
4
- import { padZero } from "vant/es/utils"
5
- import { defaultFieldProps } from "../utils"
6
- import { isUndefined } from "lodash-es"
7
- import { isDayjs } from "dayjs"
8
-
9
- /**
10
- * ExDate 日期选择
11
- * @version 1.0.0
12
- */
13
- export default defineComponent({
14
- name: "ExDate",
15
- props: {
16
- ...defaultFieldProps,
17
-
18
- modelValue: { type: [Date, String, Object], default: () => null },
19
-
20
- /**
21
- * 标题
22
- */
23
- title: { type: String, default: "选择日期" },
24
- },
25
- emits: ["update:modelValue"],
26
- setup(props, { emit, slots, expose }) {
27
- const columnsType = props.defaultProps?.columnsType || ["year", "month", "day"]
28
-
29
- const getYear = (value) => {
30
- return isDayjs(value) ? value.year() : value.getFullYear()
31
- }
32
- const getMonth = (value) => {
33
- return isDayjs(value) ? value.month() + 1 : value.getMonth() + 1
34
- }
35
- const getDate = (value) => {
36
- return isDayjs(value) ? value.date() : value.getDate()
37
- }
38
-
39
- const _setValueByColumns = (columnsType, value, date) => {
40
- columnsType.forEach((column) => {
41
- if (column === "year") {
42
- value.push(getYear(date))
43
- } else if (column === "month") {
44
- value.push(getMonth(date))
45
- } else if (column === "day") {
46
- value.push(getDate(date))
47
- }
48
- })
49
- return value
50
- }
51
- const prepareDate = (date) => {
52
- const value = []
53
-
54
- if (!date) {
55
- return value
56
- }
57
-
58
- return _setValueByColumns(columnsType, value, date)
59
- }
60
-
61
- let defaultValue = prepareDate(props.modelValue)
62
-
63
- if (!defaultValue.length) {
64
- const now = new Date()
65
- defaultValue = _setValueByColumns(columnsType, defaultValue, now)
66
- }
67
-
68
- const componentValue = ref(defaultValue)
69
-
70
- watch(
71
- () => props.modelValue,
72
- () => {
73
- componentValue.value = prepareDate(props.modelValue)
74
- },
75
- )
76
-
77
- const pickerRef = ref(null)
78
-
79
- const displayText = computed(() => {
80
- if (props.modelValue) {
81
- let text = ""
82
- columnsType.forEach((column) => {
83
- if (column === "year") {
84
- text += getYear(props.modelValue)
85
- } else if (column === "month") {
86
- if (text) {
87
- text += "/"
88
- }
89
- text += padZero(getMonth(props.modelValue), 2)
90
- } else if (column === "day") {
91
- if (text) {
92
- text += "/"
93
- }
94
- text += padZero(getDate(props.modelValue), 2)
95
- }
96
- })
97
- return text
98
- }
99
-
100
- return ""
101
- })
102
-
103
- expose({ displayText })
104
-
105
- const onConfirm = ({ selectedValues }) => {
106
- pickerRef.value.close()
107
-
108
- const now = new Date()
109
- let date = {}
110
- columnsType.forEach((column, index) => {
111
- if (column === "year") {
112
- date.year = selectedValues[index]
113
- } else if (column === "month") {
114
- date.month = selectedValues[index] - 1
115
- } else if (column === "day") {
116
- date.date = selectedValues[index]
117
- }
118
- })
119
-
120
- emit(
121
- "update:modelValue",
122
- new Date(date.year || now.getFullYear(), isUndefined(date.month) ? now.getMonth() : date.month, date.date || now.getDate()),
123
- )
124
- }
125
-
126
- return () => (
127
- <PickerWrapper ref={pickerRef} closeable={false} disabled={props.disabled || props.readonly}>
128
- {{
129
- ...pickerSlots(slots, props),
130
- default: () => (
131
- <DatePicker
132
- v-model={componentValue.value}
133
- onConfirm={onConfirm}
134
- onCancel={() => pickerRef.value.close()}
135
- title={props.title}
136
- {...props.defaultProps}
137
- />
138
- ),
139
- }}
140
- </PickerWrapper>
141
- )
142
- },
143
- })
1
+ import { computed, defineComponent, ref, watch } from "vue"
2
+ import PickerWrapper, { pickerSlots } from "./PickerWrapper.jsx"
3
+ import { DatePicker } from "vant"
4
+ import { padZero } from "vant/es/utils"
5
+ import { defaultFieldProps } from "../utils"
6
+ import { isUndefined } from "lodash-es"
7
+ import { isDayjs } from "dayjs"
8
+
9
+ /**
10
+ * ExDate 日期选择
11
+ * @version 1.0.0
12
+ */
13
+ export default defineComponent({
14
+ name: "ExDate",
15
+ props: {
16
+ ...defaultFieldProps,
17
+
18
+ modelValue: { type: [Date, String, Object], default: () => null },
19
+
20
+ /**
21
+ * 标题
22
+ */
23
+ title: { type: String, default: "选择日期" },
24
+ },
25
+ emits: ["update:modelValue"],
26
+ setup(props, { emit, slots, expose }) {
27
+ const columnsType = props.defaultProps?.columnsType || ["year", "month", "day"]
28
+
29
+ const getYear = (value) => {
30
+ return isDayjs(value) ? value.year() : value.getFullYear()
31
+ }
32
+ const getMonth = (value) => {
33
+ return isDayjs(value) ? value.month() + 1 : value.getMonth() + 1
34
+ }
35
+ const getDate = (value) => {
36
+ return isDayjs(value) ? value.date() : value.getDate()
37
+ }
38
+
39
+ const _setValueByColumns = (columnsType, value, date) => {
40
+ columnsType.forEach((column) => {
41
+ if (column === "year") {
42
+ value.push(getYear(date))
43
+ } else if (column === "month") {
44
+ value.push(getMonth(date))
45
+ } else if (column === "day") {
46
+ value.push(getDate(date))
47
+ }
48
+ })
49
+ return value
50
+ }
51
+ const prepareDate = (date) => {
52
+ const value = []
53
+
54
+ if (!date) {
55
+ return value
56
+ }
57
+
58
+ return _setValueByColumns(columnsType, value, date)
59
+ }
60
+
61
+ let defaultValue = prepareDate(props.modelValue)
62
+
63
+ if (!defaultValue.length) {
64
+ const now = new Date()
65
+ defaultValue = _setValueByColumns(columnsType, defaultValue, now)
66
+ }
67
+
68
+ const componentValue = ref(defaultValue)
69
+
70
+ watch(
71
+ () => props.modelValue,
72
+ () => {
73
+ componentValue.value = prepareDate(props.modelValue)
74
+ },
75
+ )
76
+
77
+ const pickerRef = ref(null)
78
+
79
+ const displayText = computed(() => {
80
+ if (props.modelValue) {
81
+ let text = ""
82
+ columnsType.forEach((column) => {
83
+ if (column === "year") {
84
+ text += getYear(props.modelValue)
85
+ } else if (column === "month") {
86
+ if (text) {
87
+ text += "/"
88
+ }
89
+ text += padZero(getMonth(props.modelValue), 2)
90
+ } else if (column === "day") {
91
+ if (text) {
92
+ text += "/"
93
+ }
94
+ text += padZero(getDate(props.modelValue), 2)
95
+ }
96
+ })
97
+ return text
98
+ }
99
+
100
+ return ""
101
+ })
102
+
103
+ expose({ displayText })
104
+
105
+ const onConfirm = ({ selectedValues }) => {
106
+ pickerRef.value.close()
107
+
108
+ const now = new Date()
109
+ let date = {}
110
+ columnsType.forEach((column, index) => {
111
+ if (column === "year") {
112
+ date.year = selectedValues[index]
113
+ } else if (column === "month") {
114
+ date.month = selectedValues[index] - 1
115
+ } else if (column === "day") {
116
+ date.date = selectedValues[index]
117
+ }
118
+ })
119
+
120
+ emit(
121
+ "update:modelValue",
122
+ new Date(date.year || now.getFullYear(), isUndefined(date.month) ? now.getMonth() : date.month, date.date || now.getDate()),
123
+ )
124
+ }
125
+
126
+ return () => (
127
+ <PickerWrapper ref={pickerRef} closeable={false} disabled={props.disabled || props.readonly}>
128
+ {{
129
+ ...pickerSlots(slots, props),
130
+ default: () => (
131
+ <DatePicker
132
+ v-model={componentValue.value}
133
+ onConfirm={onConfirm}
134
+ onCancel={() => pickerRef.value.close()}
135
+ title={props.title}
136
+ {...props.defaultProps}
137
+ />
138
+ ),
139
+ }}
140
+ </PickerWrapper>
141
+ )
142
+ },
143
+ })
@@ -1,166 +1,166 @@
1
- import PickerWrapper, { pickerSlots } from "./PickerWrapper.jsx"
2
- import { ref, defineComponent, computed, watch } from "vue"
3
- import { Calendar, Collapse, CollapseItem, TimePicker } from "vant"
4
- import ExButton from "../button/ExButton.jsx"
5
- import { padZero } from "vant/es/utils"
6
- import { defaultFieldProps } from "../utils"
7
- import { cloneDeep } from "lodash-es"
8
-
9
- /**
10
- * ExDatetime 日期时间选择器
11
- * @version 1.0.0
12
- */
13
- export default defineComponent({
14
- name: "ExDatetime",
15
- props: {
16
- ...defaultFieldProps,
17
-
18
- modelValue: { type: Date, default: () => null },
19
- },
20
- emits: ["update:modelValue"],
21
- setup(props, { slots, emit, expose }) {
22
- const dateValue = ref(null)
23
- const timeValue = ref(null)
24
- const displayText = ref(null)
25
- const pickerRef = ref()
26
-
27
- const activeName = ref("date")
28
-
29
- const minDate = new Date(2010, 0, 1)
30
- const maxDate = new Date(2045, 11, 31)
31
-
32
- const weekdays = ["日", "一", "二", "三", "四", "五", "六"]
33
-
34
- const dateText = computed(() => {
35
- if (dateValue.value) {
36
- return `${dateValue.value.getFullYear()}/${dateValue.value.getMonth() + 1}/${dateValue.value.getDate()} 星期${
37
- weekdays[dateValue.value.getDay()]
38
- }`
39
- }
40
- return "请选择日期"
41
- })
42
- const timeText = computed(() => {
43
- if (timeValue.value) {
44
- return timeValue.value
45
- }
46
- return "请选择时间"
47
- })
48
- const timeModel = computed(() => {
49
- if (timeValue.value) {
50
- const [hours, minutes] = timeValue.value.split(":")
51
- return [hours, minutes]
52
- }
53
- return []
54
- })
55
-
56
- const defaultDate = ref(props.modelValue || new Date())
57
-
58
- const setDisplayText = () => {
59
- displayText.value = dateValue.value && timeValue.value ? `${dateText.value} ${timeText.value}` : ""
60
- }
61
- /**
62
- *
63
- * @param {Date|null} date
64
- */
65
- const prepareDate = (date) => {
66
- if (date) {
67
- dateValue.value = cloneDeep(date)
68
- timeValue.value = `${padZero(date.getHours(), 2)}:${padZero(date.getMinutes(), 2)}`
69
- }
70
- setDisplayText()
71
- }
72
-
73
- prepareDate(props.modelValue)
74
-
75
- watch(
76
- () => props.modelValue,
77
- () => prepareDate(props.modelValue),
78
- )
79
-
80
- expose({ displayText })
81
-
82
- const onSelectDate = (date) => {
83
- dateValue.value = date
84
- }
85
-
86
- const onTimeChange = ({ selectedValues }) => {
87
- timeValue.value = selectedValues.join(":")
88
- }
89
-
90
- const onConfirm = () => {
91
- if (!dateValue.value) {
92
- dateValue.value = new Date()
93
- }
94
- let dateString = `${dateValue.value.getFullYear()}/${dateValue.value.getMonth() + 1}/${dateValue.value.getDate()}`
95
-
96
- if (!timeValue.value) {
97
- dateString += ` 00:00:00`
98
- } else {
99
- dateString += ` ${timeValue.value}`
100
- }
101
-
102
- pickerRef.value.close()
103
- setDisplayText()
104
-
105
- emit("update:modelValue", new Date(dateString))
106
- }
107
-
108
- return () => {
109
- return (
110
- <PickerWrapper ref={pickerRef} inset={true} disabled={props.disabled || props.readonly}>
111
- {{
112
- ...pickerSlots(slots, props),
113
- default: () => [
114
- <Collapse accordion={true} v-model={activeName.value} border={false} class={"ex-datetime_collapse"}>
115
- {{
116
- default: () => [
117
- <CollapseItem name={"date"} icon={"calendar-o"} value={dateText.value} isLink={false}>
118
- {{
119
- title: () => <span style={{ fontWeight: "bold" }}>日期</span>,
120
- default: () => (
121
- <div style={{ height: "300px" }}>
122
- <Calendar
123
- minDate={minDate}
124
- maxDate={maxDate}
125
- showSubtitle={false}
126
- showConfirm={false}
127
- defaultDate={defaultDate.value}
128
- poppable={false}
129
- showTitle={false}
130
- lazyRender={true}
131
- rowHeight={36}
132
- onSelect={onSelectDate}
133
- {...props.defaultProps.calendarProps}
134
- ></Calendar>
135
- </div>
136
- ),
137
- }}
138
- </CollapseItem>,
139
- <CollapseItem name={"time"} icon={"clock-o"} isLink={false} value={timeText.value}>
140
- {{
141
- title: () => <span style={{ fontWeight: "bold" }}>时间</span>,
142
- default: () => (
143
- <div>
144
- <TimePicker
145
- modelValue={timeModel.value}
146
- showToolbar={false}
147
- onChange={onTimeChange}
148
- {...props.defaultProps.timeProps}
149
- ></TimePicker>
150
- </div>
151
- ),
152
- }}
153
- </CollapseItem>,
154
- ],
155
- }}
156
- </Collapse>,
157
- <ExButton type={"primary"} style={{ margin: "20px 0" }} onClick={onConfirm}>
158
- 确定
159
- </ExButton>,
160
- ],
161
- }}
162
- </PickerWrapper>
163
- )
164
- }
165
- },
166
- })
1
+ import PickerWrapper, { pickerSlots } from "./PickerWrapper.jsx"
2
+ import { ref, defineComponent, computed, watch } from "vue"
3
+ import { Calendar, Collapse, CollapseItem, TimePicker } from "vant"
4
+ import ExButton from "../button/ExButton.jsx"
5
+ import { padZero } from "vant/es/utils"
6
+ import { defaultFieldProps } from "../utils"
7
+ import { cloneDeep } from "lodash-es"
8
+
9
+ /**
10
+ * ExDatetime 日期时间选择器
11
+ * @version 1.0.0
12
+ */
13
+ export default defineComponent({
14
+ name: "ExDatetime",
15
+ props: {
16
+ ...defaultFieldProps,
17
+
18
+ modelValue: { type: Date, default: () => null },
19
+ },
20
+ emits: ["update:modelValue"],
21
+ setup(props, { slots, emit, expose }) {
22
+ const dateValue = ref(null)
23
+ const timeValue = ref(null)
24
+ const displayText = ref(null)
25
+ const pickerRef = ref()
26
+
27
+ const activeName = ref("date")
28
+
29
+ const minDate = new Date(2010, 0, 1)
30
+ const maxDate = new Date(2045, 11, 31)
31
+
32
+ const weekdays = ["日", "一", "二", "三", "四", "五", "六"]
33
+
34
+ const dateText = computed(() => {
35
+ if (dateValue.value) {
36
+ return `${dateValue.value.getFullYear()}/${dateValue.value.getMonth() + 1}/${dateValue.value.getDate()} 星期${
37
+ weekdays[dateValue.value.getDay()]
38
+ }`
39
+ }
40
+ return "请选择日期"
41
+ })
42
+ const timeText = computed(() => {
43
+ if (timeValue.value) {
44
+ return timeValue.value
45
+ }
46
+ return "请选择时间"
47
+ })
48
+ const timeModel = computed(() => {
49
+ if (timeValue.value) {
50
+ const [hours, minutes] = timeValue.value.split(":")
51
+ return [hours, minutes]
52
+ }
53
+ return []
54
+ })
55
+
56
+ const defaultDate = ref(props.modelValue || new Date())
57
+
58
+ const setDisplayText = () => {
59
+ displayText.value = dateValue.value && timeValue.value ? `${dateText.value} ${timeText.value}` : ""
60
+ }
61
+ /**
62
+ *
63
+ * @param {Date|null} date
64
+ */
65
+ const prepareDate = (date) => {
66
+ if (date) {
67
+ dateValue.value = cloneDeep(date)
68
+ timeValue.value = `${padZero(date.getHours(), 2)}:${padZero(date.getMinutes(), 2)}`
69
+ }
70
+ setDisplayText()
71
+ }
72
+
73
+ prepareDate(props.modelValue)
74
+
75
+ watch(
76
+ () => props.modelValue,
77
+ () => prepareDate(props.modelValue),
78
+ )
79
+
80
+ expose({ displayText })
81
+
82
+ const onSelectDate = (date) => {
83
+ dateValue.value = date
84
+ }
85
+
86
+ const onTimeChange = ({ selectedValues }) => {
87
+ timeValue.value = selectedValues.join(":")
88
+ }
89
+
90
+ const onConfirm = () => {
91
+ if (!dateValue.value) {
92
+ dateValue.value = new Date()
93
+ }
94
+ let dateString = `${dateValue.value.getFullYear()}/${dateValue.value.getMonth() + 1}/${dateValue.value.getDate()}`
95
+
96
+ if (!timeValue.value) {
97
+ dateString += ` 00:00:00`
98
+ } else {
99
+ dateString += ` ${timeValue.value}`
100
+ }
101
+
102
+ pickerRef.value.close()
103
+ setDisplayText()
104
+
105
+ emit("update:modelValue", new Date(dateString))
106
+ }
107
+
108
+ return () => {
109
+ return (
110
+ <PickerWrapper ref={pickerRef} inset={true} disabled={props.disabled || props.readonly}>
111
+ {{
112
+ ...pickerSlots(slots, props),
113
+ default: () => [
114
+ <Collapse accordion={true} v-model={activeName.value} border={false} class={"ex-datetime_collapse"}>
115
+ {{
116
+ default: () => [
117
+ <CollapseItem name={"date"} icon={"calendar-o"} value={dateText.value} isLink={false}>
118
+ {{
119
+ title: () => <span style={{ fontWeight: "bold" }}>日期</span>,
120
+ default: () => (
121
+ <div style={{ height: "300px" }}>
122
+ <Calendar
123
+ minDate={minDate}
124
+ maxDate={maxDate}
125
+ showSubtitle={false}
126
+ showConfirm={false}
127
+ defaultDate={defaultDate.value}
128
+ poppable={false}
129
+ showTitle={false}
130
+ lazyRender={true}
131
+ rowHeight={36}
132
+ onSelect={onSelectDate}
133
+ {...props.defaultProps.calendarProps}
134
+ ></Calendar>
135
+ </div>
136
+ ),
137
+ }}
138
+ </CollapseItem>,
139
+ <CollapseItem name={"time"} icon={"clock-o"} isLink={false} value={timeText.value}>
140
+ {{
141
+ title: () => <span style={{ fontWeight: "bold" }}>时间</span>,
142
+ default: () => (
143
+ <div>
144
+ <TimePicker
145
+ modelValue={timeModel.value}
146
+ showToolbar={false}
147
+ onChange={onTimeChange}
148
+ {...props.defaultProps.timeProps}
149
+ ></TimePicker>
150
+ </div>
151
+ ),
152
+ }}
153
+ </CollapseItem>,
154
+ ],
155
+ }}
156
+ </Collapse>,
157
+ <ExButton type={"primary"} style={{ margin: "20px 0" }} onClick={onConfirm}>
158
+ 确定
159
+ </ExButton>,
160
+ ],
161
+ }}
162
+ </PickerWrapper>
163
+ )
164
+ }
165
+ },
166
+ })