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