time-select.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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月23日——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. // this.timeTypeClick("dangyue");
  104. if(window.location.href.split("#")[1] == "/security" ){
  105. this.security = true
  106. }else{
  107. this.security = false
  108. }
  109. },
  110. watch: {
  111. "stores.timeList"(val) {
  112. this.valueTime = val.map((value) => {
  113. return value;
  114. });
  115. },
  116. select(val) {
  117. console.log(val)
  118. this.timeTypeClick(val);
  119. },
  120. },
  121. mounted() {},
  122. methods: {
  123. timeTypeClick(val) {
  124. if (val === "jinri") {
  125. this.stores.changTimeList([
  126. new Date().Format("yyyy-MM-dd") + " 00:00:00",
  127. new Date().Format("yyyy-MM-dd") + " 23:59:59",
  128. ]);
  129. } else if (val === "benzhou") {
  130. this.stores.changTimeList([
  131. getWeekStartDate(),
  132. getWeekEndDate(),
  133. ]);
  134. } else if (val === "dangyue") {
  135. this.stores.changTimeList([
  136. getMonthStartDate(),
  137. getMonthEndDate(),
  138. ]);
  139. } else if (val === "jinbannian") {
  140. this.stores.changTimeList([
  141. getLastHalfYear().split(",")[0] + " 00:00:00",
  142. getLastHalfYear().split(",")[1] + " 23:59:59",
  143. ]);
  144. } else if (val === "jinyinian") {
  145. let time = new Date().Format("yyyy-MM-dd");
  146. let arr = time.split("-");
  147. let y = arr[0] - 1;
  148. let jinyinian = `${y}-${arr[1]}-${arr[2]} 00:00:00`;
  149. this.stores.changTimeList([
  150. jinyinian,
  151. new Date().Format("yyyy-MM-dd") + " 23:59:59",
  152. ]);
  153. } else if (val === "jinsannian") {
  154. let time = new Date().Format("yyyy-MM-dd");
  155. let arr = time.split("-");
  156. let y = arr[0] - 3;
  157. let jinsanian = `${y}-${arr[1]}-${arr[2]} 00:00:00`;
  158. this.stores.changTimeList([
  159. jinsanian,
  160. new Date().Format("yyyy-MM-dd") + " 23:59:59",
  161. ]);
  162. }
  163. this.timeArea = val;
  164. },
  165. dateTimeChange(val) {
  166. stores.changTimeList((val) => val.Format("yyyy-MM-dd hh:mm:ss"));
  167. this.timeArea = "";
  168. },
  169. },
  170. };
  171. </script>
  172. <style lang="scss" scoped>
  173. @import "@/assets/scss/color.scss";
  174. .timeSelect {
  175. position: absolute;
  176. z-index: 100;
  177. width: 9.3375rem;
  178. height: 0.5rem;
  179. left: 7.33125rem;
  180. top: 0.9rem;
  181. color: #fff;
  182. border-left: none;
  183. .wrap {
  184. width: 100%;
  185. height: 100%;
  186. box-shadow: inset 0 0 0.1rem 0.0125rem #137bb8;
  187. padding-left: 0.53rem;
  188. border-radius: 2px;
  189. /deep/.dataComponent {
  190. height: 0.325rem;
  191. padding: 0.1rem 0.15rem;
  192. margin: 0.08rem 0 0 0;
  193. width: 3.65rem;
  194. background: #000707;
  195. color: #fff;
  196. border: 1px solid;
  197. box-shadow: inset 0 0 0.05rem 0.05rem rgba(27, 79, 144, 1);
  198. background: rgba(#132a5a, 0.8);
  199. padding: 0.0625rem 0.14rem;
  200. font-size: 0.175rem;
  201. border-radius: 0.04rem;
  202. border: none;
  203. i,
  204. span {
  205. line-height: 100%;
  206. color: #fff;
  207. font-size: 0.175rem;
  208. }
  209. input {
  210. width: 40%;
  211. font-size: 0.175rem;
  212. background: transparent;
  213. color: #fff;
  214. }
  215. }
  216. /* 时间选择按钮 */
  217. .el-button {
  218. font-family: syhtN;
  219. width: auto !important;
  220. height: 0.325rem;
  221. min-height: auto;
  222. margin: 0.08rem 0.08rem 0 0 !important;
  223. padding: 0.05rem 0.15rem !important;
  224. color: #fff !important;
  225. font-size: 0.1625rem;
  226. text-align: center;
  227. box-shadow: inset 0 0 0.05rem 0.05rem rgba(27, 79, 144, 1);
  228. background: rgba(#132a5a, 0.8) !important;
  229. // border-image: linear-gradient(0deg, #0461c2 0%, #0ecdf1 100%) 1 1;
  230. border: none;
  231. border-radius: 0.04rem;
  232. }
  233. .btnClick {
  234. box-shadow: inset 0 0 0.05rem 0.05rem rgba(115, 251, 253, 0.8);
  235. }
  236. }
  237. .wrap2{
  238. width: 50%;
  239. height: 100%;
  240. margin-left:25%;
  241. box-shadow: inset 0 0 0.1rem 0.0125rem #137bb8;
  242. padding-left: 0.53rem;
  243. border-radius: 2px;
  244. >p{
  245. line-height: 40px;
  246. font-size: 0.175rem;
  247. }
  248. }
  249. }
  250. </style>