time-select.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <template>
  2. <el-row class="timeSelect">
  3. <el-row class="wrap" v-if="!security">
  4. <el-row class="xj xj1"></el-row>
  5. <el-row class="xj xj2"></el-row>
  6. <el-row class="xj xj3"></el-row>
  7. <el-row class="xj xj4"></el-row>
  8. <el-button
  9. size="mini"
  10. @click="timeTypeClick('jinri')"
  11. :class="{ btnClick: timeArea === 'jinri' }"
  12. >今日</el-button
  13. >
  14. <el-button
  15. size="mini"
  16. @click="timeTypeClick('benzhou')"
  17. :class="{ btnClick: timeArea === 'benzhou' }"
  18. >本周</el-button
  19. >
  20. <el-button
  21. size="mini"
  22. @click="timeTypeClick('dangyue')"
  23. :class="{ btnClick: timeArea === 'dangyue' }"
  24. >当月</el-button
  25. >
  26. <!-- <el-button size="mini" @click="timeTypeClick('s')" :class="{ btnClick: timeArea === 's' }">当季度</el-button>
  27. <el-button size="mini" @click="timeTypeClick('by')" style="width: 0.5rem" :class="{ btnClick: timeArea === 'by' }">上半年</el-button> -->
  28. <el-button
  29. size="mini"
  30. @click="timeTypeClick('jinbannian')"
  31. :class="{ btnClick: timeArea === 'jinbannian' }"
  32. >近半年</el-button
  33. >
  34. <el-button
  35. size="mini"
  36. @click="timeTypeClick('jinyinian')"
  37. style="width: 0.5rem"
  38. :class="{ btnClick: timeArea === 'jinyinian' }"
  39. >近一年</el-button
  40. >
  41. <el-button
  42. size="mini"
  43. @click="timeTypeClick('jinsannian')"
  44. :class="{ btnClick: timeArea === 'jinsannian' }"
  45. >近三年</el-button
  46. >
  47. <el-date-picker
  48. v-model="valueTime"
  49. class="dataComponent"
  50. type="daterange"
  51. range-separator="~"
  52. size="small"
  53. prefix-icon
  54. :default-time="stores.timeList"
  55. format="YYYY-MM-DD"
  56. start-placeholder="开始日期"
  57. end-placeholder="结束日期"
  58. @change="dateTimeChange"
  59. >
  60. </el-date-picker>
  61. </el-row>
  62. <el-row class="wrap2" v-if="security">
  63. <el-row class="xj xj1"></el-row>
  64. <el-row class="xj xj2"></el-row>
  65. <el-row class="xj xj3"></el-row>
  66. <el-row class="xj xj4"></el-row>
  67. <p>安保阶段:2023年10月25日——11月15日</p>
  68. </el-row>
  69. </el-row>
  70. </template>
  71. <script>
  72. import {
  73. getWeekStartDate,
  74. getWeekEndDate,
  75. getMonthStartDate,
  76. getMonthEndDate,
  77. getQuarterStartDate,
  78. getQuarterEndDate,
  79. getHalfYearStartDate,
  80. getHalfYearEndDate,
  81. getThisYearStartDate,
  82. getThisYearEndDate,
  83. getYearMonthDateSFN,
  84. getLastHalfYear,
  85. } from "../assets/js/dataFormate";
  86. export default {
  87. props: {
  88. select: String,
  89. },
  90. data() {
  91. return {
  92. security:true,
  93. stores: this.$useStore(),
  94. timeArea: "dangyue",
  95. valueTime: [],
  96. defaultTime: [
  97. new Date(2000, 1, 1, 0, 0, 0),
  98. new Date(2000, 2, 1, 23, 59, 59),
  99. ], // '00:00:00', '23:59:59'
  100. };
  101. },
  102. created() {
  103. if(window.location.href.split("#")[1] == "/fire-data-analysis" ){
  104. setTimeout(()=>{
  105. this.timeArea = "jinbannian"
  106. timeTypeClick('jinbannian')
  107. },1000)
  108. }
  109. // this.timeTypeClick("dangyue");
  110. if(window.location.href.split("#")[1] == "/security" ){
  111. this.security = true
  112. }else{
  113. this.security = false
  114. }
  115. },
  116. watch: {
  117. "stores.timeList"(val) {
  118. this.valueTime = val.map((value) => {
  119. return value;
  120. });
  121. },
  122. select(val) {
  123. console.log(val)
  124. this.timeTypeClick(val);
  125. },
  126. },
  127. mounted() {},
  128. methods: {
  129. timeTypeClick(val) {
  130. if (val === "jinri") {
  131. this.stores.changTimeList([
  132. new Date().Format("yyyy-MM-dd") + " 00:00:00",
  133. new Date().Format("yyyy-MM-dd") + " 23:59:59",
  134. ]);
  135. } else if (val === "benzhou") {
  136. this.stores.changTimeList([
  137. getWeekStartDate(),
  138. getWeekEndDate(),
  139. ]);
  140. } else if (val === "dangyue") {
  141. this.stores.changTimeList([
  142. getMonthStartDate(),
  143. getMonthEndDate(),
  144. ]);
  145. } else if (val === "jinbannian") {
  146. this.stores.changTimeList([
  147. getLastHalfYear().split(",")[0] + " 00:00:00",
  148. getLastHalfYear().split(",")[1] + " 23:59:59",
  149. ]);
  150. } else if (val === "jinyinian") {
  151. let time = new Date().Format("yyyy-MM-dd");
  152. let arr = time.split("-");
  153. let y = arr[0] - 1;
  154. let jinyinian = `${y}-${arr[1]}-${arr[2]} 00:00:00`;
  155. this.stores.changTimeList([
  156. jinyinian,
  157. new Date().Format("yyyy-MM-dd") + " 23:59:59",
  158. ]);
  159. } else if (val === "jinsannian") {
  160. let time = new Date().Format("yyyy-MM-dd");
  161. let arr = time.split("-");
  162. let y = arr[0] - 3;
  163. let jinsanian = `${y}-${arr[1]}-${arr[2]} 00:00:00`;
  164. this.stores.changTimeList([
  165. jinsanian,
  166. new Date().Format("yyyy-MM-dd") + " 23:59:59",
  167. ]);
  168. }
  169. this.timeArea = val;
  170. },
  171. dateTimeChange(val) {
  172. stores.changTimeList((val) => val.Format("yyyy-MM-dd hh:mm:ss"));
  173. this.timeArea = "";
  174. },
  175. },
  176. };
  177. </script>
  178. <style lang="scss" scoped>
  179. @import "@/assets/scss/color.scss";
  180. .timeSelect {
  181. position: absolute;
  182. z-index: 100;
  183. width: 9.3375rem;
  184. height: 0.5rem;
  185. left: 7.33125rem;
  186. top: 0.9rem;
  187. color: #fff;
  188. border-left: none;
  189. .wrap {
  190. width: 100%;
  191. height: 100%;
  192. box-shadow: inset 0 0 0.1rem 0.0125rem #137bb8;
  193. padding-left: 0.53rem;
  194. border-radius: 2px;
  195. /deep/.dataComponent {
  196. height: 0.325rem;
  197. padding: 0.1rem 0.15rem;
  198. margin: 0.08rem 0 0 0;
  199. width: 3.65rem;
  200. background: #000707;
  201. color: #fff;
  202. border: 1px solid;
  203. box-shadow: inset 0 0 0.05rem 0.05rem rgba(27, 79, 144, 1);
  204. background: rgba(#132a5a, 0.8);
  205. padding: 0.0625rem 0.14rem;
  206. font-size: 0.175rem;
  207. border-radius: 0.04rem;
  208. border: none;
  209. i,
  210. span {
  211. line-height: 100%;
  212. color: #fff;
  213. font-size: 0.175rem;
  214. }
  215. input {
  216. width: 40%;
  217. font-size: 0.175rem;
  218. background: transparent;
  219. color: #fff;
  220. }
  221. }
  222. /* 时间选择按钮 */
  223. .el-button {
  224. font-family: syhtN;
  225. width: auto !important;
  226. height: 0.325rem;
  227. min-height: auto;
  228. margin: 0.08rem 0.08rem 0 0 !important;
  229. padding: 0.05rem 0.15rem !important;
  230. color: #fff !important;
  231. font-size: 0.1625rem;
  232. text-align: center;
  233. box-shadow: inset 0 0 0.05rem 0.05rem rgba(27, 79, 144, 1);
  234. background: rgba(#132a5a, 0.8) !important;
  235. // border-image: linear-gradient(0deg, #0461c2 0%, #0ecdf1 100%) 1 1;
  236. border: none;
  237. border-radius: 0.04rem;
  238. }
  239. .btnClick {
  240. box-shadow: inset 0 0 0.05rem 0.05rem rgba(115, 251, 253, 0.8);
  241. }
  242. }
  243. .wrap2{
  244. width: 50%;
  245. height: 100%;
  246. margin-left:25%;
  247. box-shadow: inset 0 0 0.1rem 0.0125rem #137bb8;
  248. padding-left: 0.53rem;
  249. border-radius: 2px;
  250. >p{
  251. line-height: 40px;
  252. font-size: 0.175rem;
  253. }
  254. }
  255. }
  256. </style>