condition-date-range.js 874 B

123456789101112131415161718192021222324252627282930313233343536
  1. import conditionObjectBase from '../condition-object-base.js'
  2. import * as ext from '@/utils'
  3. export default {
  4. ...conditionObjectBase,
  5. key: 'daterange',
  6. title: '时间',
  7. template: 'date-range',
  8. neverCache: true,
  9. modelAsParam: true,
  10. disableAllByForce: true,
  11. getList: function(param) {
  12. // 设置两个默认时间
  13. const current = param[this.key]
  14. if (current?.length == 2) {
  15. return Promise.resolve([current])
  16. } else {
  17. return Promise.resolve([ext.getDefaultDateRange()])
  18. }
  19. },
  20. getCode: function(item) {
  21. return item
  22. },
  23. getLabel: function(item) {
  24. return item
  25. },
  26. codeEquals(codeL, codeR) {
  27. if (Array.isArray(codeL) && Array.isArray(codeR)) {
  28. return JSON.stringify(codeL) == JSON.stringify(codeR)
  29. }
  30. return codeL == codeR
  31. },
  32. _valid(val) {
  33. return Array.isArray(val) && val.length == 2
  34. }
  35. }