kpi-halfyear-picker.vue 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <div>
  3. <a-input
  4. v-model="showValue"
  5. placeholder="请选择半年"
  6. style="width:138px;"
  7. @focus="showSeason = true"
  8. >
  9. </a-input>
  10. <a-card
  11. v-show="showSeason"
  12. class="box-card"
  13. style="position:fixed;z-index:9999;width:322px;padding: 0 3px 20px;margin-top:10px"
  14. >
  15. <div class="ant-calendar-month-panel-header">
  16. <a
  17. role="button"
  18. title="上一年 (Control键加左方向键)"
  19. class="ant-calendar-month-panel-prev-year-btn"
  20. @click="prev"
  21. ></a>
  22. <a role="button" title="选择年份" class="ant-calendar-month-panel-year-select">
  23. <span class="ant-calendar-month-panel-year-select-content">{{ year }}年</span>
  24. </a>
  25. <a
  26. role="button"
  27. title="下一年 (Control键加右方向键)"
  28. class="ant-calendar-month-panel-next-year-btn"
  29. @click="next"
  30. ></a>
  31. </div>
  32. <div class="text item" style="text-align:center;">
  33. <a-button
  34. type="text"
  35. style="float:left;width:40%;margin-top: 30px;color: #606266"
  36. @click="selectSeason(0)"
  37. >上半年</a-button
  38. >
  39. <a-button
  40. type="text"
  41. style="float:right;width:40%;margin-top: 30px;color: #606266"
  42. @click="selectSeason(1)"
  43. >下半年</a-button
  44. >
  45. </div>
  46. </a-card>
  47. </div>
  48. </template>
  49. <script>
  50. import components from './_import-components/kpi-halfyear-picker-import'
  51. export default {
  52. name: 'KpiHalfyearPicker',
  53. components,
  54. data() {
  55. return {
  56. showSeason: false,
  57. season: '',
  58. year: new Date().getFullYear(),
  59. showValue: '',
  60. }
  61. },
  62. methods: {
  63. one() {
  64. this.showSeason = false
  65. },
  66. prev() {
  67. this.year = this.year * 1 - 1
  68. },
  69. next() {
  70. this.year = this.year * 1 + 1
  71. },
  72. selectSeason(i) {
  73. this.season = i + 1
  74. const quarter = ['上半年', '下半年']
  75. this.showSeason = false
  76. this.showValue = `${this.year}年${quarter[i]}`
  77. const value = JSON.stringify({
  78. year: this.year,
  79. quarter: quarter[i],
  80. full: this.year + '' + quarter[i],
  81. })
  82. this.$emit('setvalue', value)
  83. },
  84. },
  85. }
  86. </script>
  87. <style module lang="scss">
  88. @use '@/common/design' as *;
  89. </style>