statischart.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <template>
  2. <div id="statischart">
  3. <div class="time">
  4. <span @click="changeTime(1)">
  5. {{bt}}
  6. </span>
  7. <span @click="changeTime(2)">
  8. {{et}}
  9. </span>
  10. <mu-select label="" v-model="selectVal">
  11. <mu-option v-for="option in options" :key="option.optionsVal" :label="option.name"
  12. :value="option.optionsVal"></mu-option>
  13. </mu-select>
  14. <mu-button color="warning" @click="getNewChart" small>{{$t('search')}}</mu-button>
  15. </div>
  16. <Line-example
  17. :width="390"
  18. :height="200"
  19. :dataLabels="dataLabels"
  20. :datadatasets="datadatasets"
  21. />
  22. <mu-bottom-sheet :open.sync="open">
  23. <mu-flex justify-content="between" align-items="end" wrap="wrap">
  24. <mu-paper :z-depth="1" class="demo-date-picker">
  25. <mu-date-picker :date.sync="date" color="#FFA200" :date-time-format="enDateFormat"
  26. @change="confirmDay"></mu-date-picker>
  27. </mu-paper>
  28. </mu-flex>
  29. </mu-bottom-sheet>
  30. </div>
  31. </template>
  32. <script>
  33. import Global from '../Global'
  34. import Vue from 'vue'
  35. import LineExample from './LineExample'
  36. let qs = require('qs');
  37. import axios from 'axios';
  38. const enDateFormat = {
  39. formatDisplay(date) {
  40. return `${dayList[date.getDay()]}, ${monthList[date.getMonth()]} ${date.getDate()}`;
  41. },
  42. formatMonth(date) {
  43. return `${monthLongList[date.getMonth()]} ${date.getFullYear()}`;
  44. },
  45. getWeekDayArray(firstDayOfWeek) {
  46. let beforeArray = [];
  47. let afterArray = [];
  48. for (let i = 0; i < dayAbbreviation.length; i++) {
  49. if (i < firstDayOfWeek) {
  50. afterArray.push(dayAbbreviation[i]);
  51. } else {
  52. beforeArray.push(dayAbbreviation[i]);
  53. }
  54. }
  55. return beforeArray.concat(afterArray);
  56. },
  57. getMonthList() {
  58. return monthList;
  59. }
  60. };
  61. export default {
  62. data() {
  63. return {
  64. enDateFormat,
  65. bt: globaltime2StringNoMin(new Date() - 3 * 24 * 3600 * 1000),//test
  66. et: globaltime2StringNoMin(new Date()),
  67. date: new Date(),
  68. pickerValue: '',
  69. open: false,
  70. selectTime: 0,
  71. selectVal: 1,
  72. pickerItem: 0,
  73. dataLabels: [],
  74. datadatasets: [],
  75. options: [
  76. {name: this.$t('Total detection record'), optionsVal: 1},
  77. ]
  78. }
  79. },
  80. mounted() {
  81. this.getNewChart()
  82. },
  83. methods: {
  84. changeTime(val) {
  85. this.open = true;
  86. let curVal = val == 1 ? new Date(this.bt) : new Date(this.et);
  87. this.selectTime = val;
  88. this.date = curVal;
  89. },
  90. confirmDay(date) {
  91. if (this.selectTime == 1) {
  92. this.bt = globaltime2StringNoMin(date);
  93. } else {
  94. this.et = globaltime2StringNoMin(date);
  95. }
  96. this.open = false;
  97. },
  98. getNewChart() {
  99. const that = this;
  100. let url = headapi + 'v1/Detector/GetCtNumStatisticByday';
  101. let param = {
  102. token: localStorage.token,
  103. bt: that.bt + ' 00:00:00',
  104. et: that.et + ' 23:59:59',
  105. dailytype: that.selectVal,
  106. };
  107. let postdata = qs.stringify(param);
  108. axios.post(url, postdata).then(function (data) {
  109. let json = data.data;
  110. if (json.Code == 0) {
  111. let detectorArr = json.Rs;
  112. that.dataLabels = detectorArr.RsX;
  113. that.datadatasets = detectorArr.RsY;
  114. } else {
  115. if (!localStorage.token) { //未登录状态
  116. console.log(json.Memo);
  117. } else { //已登录状态
  118. that.Toast(that.TransMemo(json.Memo));
  119. }
  120. }
  121. }, function (response) {
  122. console.info(response);
  123. });
  124. },
  125. },
  126. components: {
  127. LineExample
  128. },
  129. }
  130. </script>
  131. <style scoped>
  132. .container {
  133. width: 100%;
  134. height: 230px;
  135. overflow: hidden;
  136. display: block;
  137. margin: 0 auto;
  138. }
  139. #statischart {
  140. width: 100%;
  141. overflow: hidden;
  142. display: block;
  143. margin: 0 auto;
  144. margin-bottom: 10px;
  145. }
  146. .time {
  147. width: 100%;
  148. height: 48px;
  149. overflow: hidden;
  150. display: block;
  151. margin: 0 auto;
  152. padding-left: 2%;
  153. padding-right: 2%;
  154. padding-top: 15px;
  155. margin-bottom: 15px;
  156. border-bottom: 1px solid #f2f2f2;
  157. }
  158. .time span {
  159. width: 80px;
  160. height: 27px;
  161. float: left;
  162. border: 1px solid #DEDEDE;
  163. text-align: center;
  164. line-height: 27px;
  165. font-size: 12px;
  166. margin-right: 10px;
  167. }
  168. .time select {
  169. width: 96px;
  170. height: 27px;
  171. float: left;
  172. border: 1px solid #DEDEDE;
  173. text-align: center;
  174. line-height: 27px;
  175. font-size: 12px;
  176. margin-right: 10px;
  177. }
  178. .time .mint-button {
  179. height: 27px;
  180. border-radius: 0;
  181. }
  182. .mu-input {
  183. width: 100px;
  184. float: left;
  185. padding: 0;
  186. margin: 0;
  187. }
  188. /deep/ .mu-select-input {
  189. font-size: 12px !important;
  190. }
  191. .mu-button {
  192. float: left;
  193. min-width: 66px;
  194. }
  195. .demo-date-picker {
  196. overflow: hidden;
  197. display: block;
  198. margin: 0 auto;
  199. }
  200. /deep/ .mu-button-wrapper {
  201. color: #000 !important;
  202. }
  203. </style>