80bc6fec20e1525cbb2bc33dd630e59de160ce34.svn-base 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <div class="config-list">
  3. <a-radio-group v-model="type">
  4. <div class="item">
  5. <a-radio value="TYPE_NOT_SET" class="choice" :disabled="disableChoice">不设置</a-radio>
  6. <span class="tip-info">日和周只能设置其中之一</span>
  7. </div>
  8. <div class="item">
  9. <a-radio value="TYPE_RANGE" class="choice" :disabled="disableChoice">区间</a-radio>
  10. 从
  11. <a-select v-model="valueRange.start" class="w80" :disabled="type!==TYPE_RANGE || disableChoice">
  12. <template v-for="(v, k) of WEEK_MAP">
  13. <a-select-option :value="v">{{k}}</a-select-option>
  14. </template>
  15. </a-select>
  16. 至
  17. <a-select v-model="valueRange.end" class="w80" :disabled="type!==TYPE_RANGE || disableChoice">
  18. <template v-for="(v, k) of WEEK_MAP">
  19. <a-select-option :value="v">{{k}}</a-select-option>
  20. </template>
  21. </a-select>
  22. </div>
  23. <div class="item">
  24. <a-radio value="TYPE_LOOP" class="choice" :disabled="disableChoice">循环</a-radio>
  25. 从
  26. <a-select v-model="valueLoop.start" class="w80" :disabled="type!==TYPE_LOOP || disableChoice">
  27. <template v-for="(v, k) of WEEK_MAP">
  28. <a-select-option :value="v">{{k}}</a-select-option>
  29. </template>
  30. </a-select>
  31. 开始,间隔
  32. <a-input-number :disabled="type!==TYPE_LOOP || disableChoice" :max="maxValue" :min="minValue" :precision="0" class="w60" v-model="valueLoop.interval"/>
  33. 天
  34. </div>
  35. <div class="item">
  36. <a-radio value="TYPE_SPECIFY" class="choice" :disabled="disableChoice">指定</a-radio>
  37. <div class="list">
  38. <a-checkbox-group v-model="valueList">
  39. <template v-for="i in specifyRange">
  40. <a-checkbox class="list-check-item" :key="`key-${i}`" :value="i" :disabled="type!==TYPE_SPECIFY || disabled">{{i}}</a-checkbox>
  41. </template>
  42. </a-checkbox-group>
  43. </div>
  44. </div>
  45. </a-radio-group>
  46. </div>
  47. </template>
  48. <script>
  49. import mixin from './mixin'
  50. import { replaceWeekName, WEEK_MAP_EN } from './const.js'
  51. const WEEK_MAP = {
  52. '周一': 1,
  53. '周二': 2,
  54. '周三': 3,
  55. '周四': 4,
  56. '周五': 5,
  57. '周六': 6,
  58. // 按照国人习惯,将周日放到每周的最后一天
  59. '周日': 7,
  60. }
  61. export default {
  62. name: 'week',
  63. mixins: [mixin],
  64. props: {
  65. day: {
  66. type: String,
  67. default: '*'
  68. }
  69. },
  70. data() {
  71. return {
  72. WEEK_MAP,
  73. WEEK_MAP_EN
  74. }
  75. },
  76. computed: {
  77. disableChoice() {
  78. return (this.day && this.day !== '?') || this.disabled
  79. }
  80. },
  81. watch: {
  82. value_c(newVal, oldVal) {
  83. // 如果设置日,那么星期就直接不设置
  84. this.updateValue()
  85. },
  86. day(newVal) {
  87. // console.info('new day: ' + newVal)
  88. this.updateValue()
  89. }
  90. },
  91. methods: {
  92. updateValue() {
  93. this.$emit('change', this.disableChoice ? '?' : this.value_c)
  94. },
  95. preProcessProp(c) {
  96. return replaceWeekName(c)
  97. }
  98. },
  99. created() {
  100. this.DEFAULT_VALUE = '*'
  101. // 0,7表示周日 1表示周一
  102. this.minValue = 1
  103. this.maxValue = 7
  104. this.valueRange.start = 1
  105. this.valueRange.end = 7
  106. this.valueLoop.start = 2
  107. this.valueLoop.interval = 1
  108. this.parseProp(this.prop)
  109. }
  110. }
  111. </script>
  112. <style lang="less" scoped>
  113. @import "mixin.less";
  114. </style>