index.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. <template>
  2. <bgBox :tabChange="tabChange" class="bgBox" bgType="g-bg3">
  3. <div class="main">
  4. <div class="topBar">
  5. <div class="query">
  6. <img src="@/assets/img2/种植分析详情/编组 8.png" alt="" />
  7. <el-radio-group v-model="query.radio" class="radio-group">
  8. <el-radio class="date" :label="6">近一周</el-radio>
  9. <el-radio class="date" :label="30">近30天</el-radio>
  10. <el-radio class="date" :label="90">近90天</el-radio>
  11. </el-radio-group>
  12. <el-date-picker
  13. :pickerOptions="pickerOptions0"
  14. v-model="query.date[0]"
  15. type="date"
  16. placeholder="开始日期"
  17. class="mr-20px ml-20px date"
  18. >
  19. </el-date-picker>
  20. <el-date-picker
  21. class="date"
  22. :pickerOptions="pickerOptions1"
  23. v-model="query.date[1]"
  24. type="date"
  25. placeholder="结束日期"
  26. >
  27. </el-date-picker>
  28. </div>
  29. <img
  30. @click="backFn"
  31. src="@/assets/img2/种植分析详情/编组 16备份.png"
  32. alt=""
  33. />
  34. </div>
  35. <leftBox class="lefBox" />
  36. <leftBox2 class="lefBox2" />
  37. </div>
  38. </bgBox>
  39. </template>
  40. <script>
  41. import 'element-ui/lib/theme-chalk/index.css'
  42. import bgBox from '@/components/bgBox/index.vue'
  43. import leftBox from './leftBox.vue'
  44. import leftBox2 from './leftBox2.vue'
  45. import { Button, DatePicker, RadioGroup, Radio } from 'element-ui'
  46. import Vue from 'vue'
  47. import dayjs from 'dayjs'
  48. // 获取近一周的日期范围
  49. function getLastDay(day) {
  50. const end = dayjs() // 当前日期
  51. const start = end.subtract(day, `day`) // 前六天
  52. return { start: start.format(`YYYY-MM-DD`), end: end.format(`YYYY-MM-DD`) }
  53. }
  54. window.getLastDay = getLastDay
  55. window.dayjs = dayjs
  56. Vue.use(Button)
  57. Vue.use(RadioGroup)
  58. Vue.use(Radio)
  59. Vue.use(DatePicker)
  60. export default {
  61. components: {
  62. leftBox,
  63. leftBox2,
  64. bgBox,
  65. },
  66. data() {
  67. const vm = this
  68. return {
  69. pickerOptions0: {
  70. disabledDate(time) {
  71. return time.getTime() > Date.now()
  72. },
  73. },
  74. pickerOptions1: {
  75. disabledDate(time) {
  76. if (vm.query.date[0]) {
  77. return (
  78. time.getTime() < vm.query.date[0] || time.getTime() > Date.now()
  79. )
  80. } else {
  81. return time.getTime() > Date.now()
  82. }
  83. },
  84. },
  85. query: {
  86. radio: 6,
  87. date: [],
  88. },
  89. }
  90. },
  91. computed: {},
  92. async created() {},
  93. watch: {
  94. 'query.radio': {
  95. handler(val) {
  96. if (this.query.radio) {
  97. this.query.date = []
  98. const { start, end } = getLastDay(this.query.radio)
  99. this.getEchartData(start, end)
  100. }
  101. },
  102. immediate: true,
  103. },
  104. 'query.date'([a, b] = []) {
  105. if (a && b) {
  106. this.query.radio = 0
  107. const start = dayjs(a || Date.now()).format(`YYYY-MM-DD`)
  108. const end = dayjs(b || Date.now()).format(`YYYY-MM-DD`)
  109. this.getEchartData(start, end)
  110. } else if (!a && !b && !this.query.radio) {
  111. this.query.radio = 6
  112. }
  113. },
  114. },
  115. mounted() {},
  116. methods: {
  117. getEchartData(start, end) {
  118. console.log(`start, end`, start, end)
  119. },
  120. backFn() {
  121. console.log(`backFn`)
  122. },
  123. tabChange(val) {
  124. console.log(`val`, val)
  125. },
  126. },
  127. }
  128. </script>
  129. <style lang="less" scoped>
  130. .bgBox {
  131. .main {
  132. padding: 50px;
  133. padding-top: 45px;
  134. .topBar {
  135. display: flex;
  136. justify-content: space-between;
  137. align-items: center;
  138. }
  139. .lefBox,
  140. .lefBox2 {
  141. position: absolute;
  142. z-index: 10;
  143. top: 120px;
  144. }
  145. .lefBox {
  146. left: 458px;
  147. }
  148. .lefBox2 {
  149. left: 47px;
  150. }
  151. .query {
  152. font-size: 14px;
  153. display: flex;
  154. align-items: center;
  155. .radio-group {
  156. margin-top: -1px;
  157. margin-left: 20px;
  158. }
  159. .date {
  160. background: rgba(255, 255, 255, 0.2);
  161. border-radius: 10px;
  162. }
  163. ::v-deep {
  164. .el-radio__input.is-checked + .el-radio__label {
  165. color: rgba(255, 255, 255, 0.8);
  166. }
  167. .el-input__suffix {
  168. right: 0;
  169. }
  170. .el-radio {
  171. background: rgba(255, 255, 255, 0.2);
  172. box-sizing: border-box;
  173. height: 27px;
  174. padding: 0 10px;
  175. line-height: 27px;
  176. color: rgba(255, 255, 255, 0.8);
  177. margin-right: 5px;
  178. }
  179. .el-input--prefix .el-input__inner {
  180. padding: 0;
  181. }
  182. .el-input__prefix {
  183. display: none;
  184. }
  185. .el-date-editor.el-input {
  186. width: 120px;
  187. }
  188. .el-input__icon {
  189. line-height: 27px;
  190. height: 27px;
  191. }
  192. .el-input__inner {
  193. border-radius: 10px;
  194. width: 120px;
  195. height: 27px;
  196. box-sizing: border-box;
  197. line-height: 27px;
  198. color: rgba(255, 255, 255, 0.8);
  199. text-align: center;
  200. border-width: 0;
  201. }
  202. .el-input__inner,
  203. .el-radio__inner {
  204. background-color: transparent;
  205. }
  206. }
  207. }
  208. }
  209. ::v-deep {
  210. .top {
  211. display: none;
  212. }
  213. *[aria-hidden='true'] {
  214. display: none;
  215. }
  216. }
  217. }
  218. </style>