vue2-client 1.19.1 → 1.19.2

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.
@@ -199,6 +199,80 @@ export default {
199
199
  }
200
200
  }
201
201
  return {}
202
+ },
203
+ // 日期范围限制函数
204
+ disabledDate () {
205
+ // 查询模式下不进行范围限制
206
+ if (this.mode === '查询') {
207
+ return undefined
208
+ }
209
+
210
+ const dateRangeOption = this.attr.dateRangeOption
211
+ if (!dateRangeOption || !dateRangeOption.type) {
212
+ return undefined
213
+ }
214
+
215
+ const { type, beforeDays, afterDays } = dateRangeOption
216
+ const today = moment().startOf('day')
217
+
218
+ return (current) => {
219
+ // 根据组件类型处理不同的时间粒度
220
+ let currentDate, comparisonDate
221
+
222
+ if (['monthPicker', 'monthRangePicker'].includes(this.attr.type)) {
223
+ // 月份选择器:比较月份
224
+ currentDate = moment(current).startOf('month')
225
+ comparisonDate = moment(today).startOf('month')
226
+ } else if (['yearPicker', 'yearRangePicker'].includes(this.attr.type)) {
227
+ // 年份选择器:比较年份
228
+ currentDate = moment(current).startOf('year')
229
+ comparisonDate = moment(today).startOf('year')
230
+ } else {
231
+ // 日期选择器:比较日期
232
+ currentDate = moment(current).startOf('day')
233
+ comparisonDate = today
234
+ }
235
+
236
+ switch (type) {
237
+ case 'afterToday':
238
+ // 只能选择今天及以后的日期/月份/年份
239
+ return currentDate.isBefore(comparisonDate)
240
+ case 'beforeToday':
241
+ // 只能选择今天及以前的日期/月份/年份
242
+ return currentDate.isAfter(comparisonDate)
243
+ case 'custom':
244
+ // 自定义范围:beforeDays(今天前多少天)、afterDays(今天后多少天)
245
+ if (beforeDays && beforeDays > 0) {
246
+ let minDate
247
+ if (['monthPicker', 'monthRangePicker'].includes(this.attr.type)) {
248
+ minDate = moment(comparisonDate).subtract(beforeDays, 'months')
249
+ } else if (['yearPicker', 'yearRangePicker'].includes(this.attr.type)) {
250
+ minDate = moment(comparisonDate).subtract(beforeDays, 'years')
251
+ } else {
252
+ minDate = moment(comparisonDate).subtract(beforeDays, 'days')
253
+ }
254
+ if (currentDate.isBefore(minDate)) {
255
+ return true
256
+ }
257
+ }
258
+ if (afterDays && afterDays > 0) {
259
+ let maxDate
260
+ if (['monthPicker', 'monthRangePicker'].includes(this.attr.type)) {
261
+ maxDate = moment(comparisonDate).add(afterDays, 'months')
262
+ } else if (['yearPicker', 'yearRangePicker'].includes(this.attr.type)) {
263
+ maxDate = moment(comparisonDate).add(afterDays, 'years')
264
+ } else {
265
+ maxDate = moment(comparisonDate).add(afterDays, 'days')
266
+ }
267
+ if (currentDate.isAfter(maxDate)) {
268
+ return true
269
+ }
270
+ }
271
+ return false
272
+ default:
273
+ return false
274
+ }
275
+ }
202
276
  }
203
277
  },
204
278
  methods: {
@@ -234,6 +308,7 @@ export default {
234
308
  :getPopupContainer="enablePopupToBody? getBodyContainer : undefined"
235
309
  v-model="localValue"
236
310
  :disabled="disabled || readOnly"
311
+ :disabledDate="disabledDate"
237
312
  style="width: 100%"
238
313
  :showToday="true"
239
314
  placeholder="请选择日期"
@@ -251,6 +326,7 @@ export default {
251
326
  :getPopupContainer="enablePopupToBody? getBodyContainer : undefined"
252
327
  v-model="localValue"
253
328
  :disabled="disabled || readOnly"
329
+ :disabledDate="disabledDate"
254
330
  :show-time="true"
255
331
  placeholder="请选择月份"
256
332
  :valueFormat="formatType"
@@ -266,6 +342,7 @@ export default {
266
342
  :getPopupContainer="enablePopupToBody? getBodyContainer : undefined"
267
343
  v-model="localValue"
268
344
  :disabled="disabled || readOnly"
345
+ :disabledDate="disabledDate"
269
346
  format="YYYY"
270
347
  :valueFormat="formatType"
271
348
  :open="yearShowOne"
@@ -328,6 +405,7 @@ export default {
328
405
  "
329
406
  v-model="localValue"
330
407
  :disabled="disabled"
408
+ :disabledDate="disabledDate"
331
409
  :placeholder="placeholder"
332
410
  :show-time="
333
411
  ['yearRangePicker', 'monthRangePicker'].includes(attr.type)
@@ -1,3 +1,3 @@
1
- import XDetailsView from './XDetailsView'
2
-
3
- export default XDetailsView
1
+ import XDetailsView from './XDetailsView'
2
+
3
+ export default XDetailsView
@@ -1,3 +1,3 @@
1
- import XFormGroupDetails from './XFormGroupDetails'
2
-
3
- export default XFormGroupDetails
1
+ import XFormGroupDetails from './XFormGroupDetails'
2
+
3
+ export default XFormGroupDetails