ztzhl.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. <template>
  2. <div>
  3. <div class="query mg-b-8">
  4. <div class="query-items">
  5. <div class="query-item">
  6. <div class="lable">开始日期:</div>
  7. <div class="search-input">
  8. <el-date-picker
  9. v-model="value1"
  10. @change="BeginChange(value1)"
  11. type="date"
  12. value-format="YYYY-MM-DD"
  13. placeholder="选择日期"
  14. popper-class="date-select"
  15. >
  16. </el-date-picker>
  17. </div>
  18. </div>
  19. <div class="query-item">
  20. <div class="lable">结束日期:</div>
  21. <div class="search-input">
  22. <el-date-picker
  23. v-model="value2"
  24. @change="EndChange(value2)"
  25. type="date"
  26. value-format="YYYY-MM-DD"
  27. placeholder="选择日期"
  28. popper-class="date-select"
  29. >
  30. </el-date-picker>
  31. <div class="unit svg-icon svg-icon-gray">
  32. <svg-icon :svgid="''" />
  33. </div>
  34. </div>
  35. </div>
  36. <div class="query-item">
  37. <div class="lable">风速:</div>
  38. <div
  39. class="newspan"
  40. v-for="(item, index) of optionData"
  41. :key="index"
  42. :class="{ active: cur == index }"
  43. @click="handleOpen(item, index)"
  44. >
  45. {{ item }}
  46. </div>
  47. </div>
  48. </div>
  49. <div class="query-actions">
  50. <el-button class="btn green" @click="handleSubmit">计算</el-button>
  51. </div>
  52. </div>
  53. <div class="table-box">
  54. <div class="title">{{ vshows }}</div>
  55. <ComTable
  56. :data="tableData"
  57. :pageSize="20"
  58. height="84vh"
  59. v-loading="tableLoading"
  60. element-loading-text="拼命加载中"
  61. element-loading-background="rgba(0, 0, 0, 0.8)"
  62. ></ComTable>
  63. </div>
  64. </div>
  65. </template>
  66. <script>
  67. import ComTable from "@/components/coms/table/table.vue";
  68. import api from "@api/economic/index.js";
  69. export default {
  70. name: "ztzhl",
  71. components: { ComTable },
  72. data() {
  73. return {
  74. value1: "",
  75. value2: "",
  76. value3: "",
  77. tableLoading: true,
  78. optionData: ["小于3米风速", "大于3米风速", "大于4米风速"],
  79. cur: 0,
  80. vshows: "小于3米风速",
  81. tableData: {
  82. column: [
  83. {
  84. name: "单位",
  85. field: "wpid",
  86. is_num: false,
  87. is_light: false,
  88. sortable: true
  89. },
  90. {
  91. name: "5分钟(次)",
  92. field: "wfz",
  93. is_num: false,
  94. is_light: false,
  95. sortable: true
  96. },
  97. {
  98. name: "5分钟(次)",
  99. field: "wfzfwl",
  100. is_num: false,
  101. is_light: false,
  102. sortable: true
  103. },
  104. {
  105. name: "10分钟(次)",
  106. field: "sfz",
  107. is_num: false,
  108. is_light: false,
  109. sortable: true
  110. },
  111. {
  112. name: "10分钟(次)",
  113. field: "sfzfwl",
  114. is_num: false,
  115. is_light: false,
  116. sortable: true
  117. },
  118. {
  119. name: "15分钟(次)",
  120. field: "swfz",
  121. is_num: false,
  122. is_light: false,
  123. sortable: true
  124. },
  125. {
  126. name: "15分钟(次)",
  127. field: "swfzfwl",
  128. is_num: false,
  129. is_light: false,
  130. sortable: true
  131. },
  132. {
  133. name: "20分钟(次)",
  134. field: "esfz",
  135. is_num: false,
  136. is_light: false,
  137. sortable: true
  138. },
  139. {
  140. name: "20分钟(次)",
  141. field: "esfzfwl",
  142. is_num: false,
  143. is_light: false,
  144. sortable: true
  145. }
  146. ],
  147. data: []
  148. }
  149. };
  150. },
  151. mounted() {
  152. // 获取表格数据
  153. this.getTable();
  154. },
  155. created() {
  156. this.value1 = this.getTime(1);
  157. this.value2 = this.getTime(2);
  158. },
  159. methods: {
  160. // 获取表格数据
  161. getTable() {
  162. let that = this;
  163. that.tableLoading = true;
  164. api.threerateZtzhl({
  165. beginDate: this.value1,
  166. endDate: this.value2
  167. }).then((res) => {
  168. this.tableLoading = false;
  169. const vs = this.vshows;
  170. if (res.code === 200) {
  171. if (vs == "小于3米风速") {
  172. this.tableData.data = res.data.小于3米风速;
  173. } else if (vs == "大于3米风速") {
  174. this.tableData.data = res.data.大于3米风速;
  175. } else {
  176. this.tableData.data = res.data.大于4米风速;
  177. }
  178. }
  179. });
  180. // that.API.requestData({
  181. // method: "GET",
  182. // baseURL: "http://10.155.32.4:8034/",
  183. // subUrl: "/threerate/ztzhl",
  184. // data: {
  185. // beginDate: this.value1,
  186. // endDate: this.value2
  187. // },
  188. // success(res) {
  189. // that.tableLoading = false;
  190. // const vs = that.vshows;
  191. // if (res.code === 200) {
  192. // if (vs == "小于3米风速") {
  193. // that.tableData.data = res.data.小于3米风速;
  194. // } else if (vs == "大于3米风速") {
  195. // that.tableData.data = res.data.大于3米风速;
  196. // } else {
  197. // that.tableData.data = res.data.大于4米风速;
  198. // }
  199. // }
  200. // }
  201. // });
  202. },
  203. BeginChange(vl) {
  204. this.value1 = vl;
  205. },
  206. EndChange(vl) {
  207. this.value2 = vl;
  208. },
  209. // 计算事件
  210. handleSubmit() {
  211. this.vshows = "小于3米风速";
  212. this.cur = 0;
  213. if (this.value1 == "" || this.value1 == null) {
  214. this.$message.error("请选择开始时间");
  215. } else if (this.value2 == "" || this.value2 == null) {
  216. this.$message.error("请选择结束时间");
  217. } else {
  218. this.getTable();
  219. }
  220. },
  221. // 默认开始时间
  222. getTime(val) {
  223. //时间戳处理,val=1是默认开始时间(当前月第一天),val=2是默认结束时间(今天)
  224. var date = new Date();
  225. var year = date.getFullYear(),
  226. month = date.getMonth() + 1,
  227. day = date.getDate();
  228. month >= 1 && month <= 9 ? (month = "0" + month) : "";
  229. day >= 0 && day <= 9 ? (day = "0" + day) : "";
  230. var begin = year + "-" + month + "-01";
  231. var end = year + "-" + month + "-" + day;
  232. if (val == 1) {
  233. return begin;
  234. } else if (val == 2) {
  235. return end;
  236. }
  237. },
  238. handleOpen(vl, index) {
  239. this.vshows = "小于3米风速";
  240. this.$nextTick(() => {
  241. this.cur = index;
  242. this.vshows = vl;
  243. this.getTable();
  244. });
  245. }
  246. }
  247. };
  248. </script>
  249. <style scoped>
  250. .newsDiv {
  251. color: rgba(255, 255, 255, 0.75);
  252. background-color: rgba(255, 255, 255, 0.1);
  253. margin-bottom: 8px;
  254. line-height: 3.4259vh;
  255. padding: 0 15px;
  256. }
  257. .newspan {
  258. line-height: 30px;
  259. cursor: pointer;
  260. padding: 0 1vw;
  261. margin: 0 2px;
  262. color: #9ca5a8;
  263. transition: color 0.2s ease-in-out;
  264. position: relative;
  265. }
  266. .newspan:hover {
  267. background: linear-gradient(
  268. to top,
  269. rgba(5, 187, 76, 0.5),
  270. rgba(5, 187, 76, 0)
  271. );
  272. color: white;
  273. position: relative;
  274. }
  275. .newspan:hover::after {
  276. content: "";
  277. position: absolute;
  278. width: 100%;
  279. height: 0.463vh;
  280. border: 0.093vh solid #05bb4c;
  281. border-top: 0;
  282. left: 0;
  283. bottom: 0;
  284. box-sizing: border-box;
  285. }
  286. .active {
  287. background: linear-gradient(
  288. to top,
  289. rgba(5, 187, 76, 0.5),
  290. rgba(5, 187, 76, 0)
  291. );
  292. color: white;
  293. position: relative;
  294. }
  295. .active::after {
  296. content: "";
  297. position: absolute;
  298. width: 100%;
  299. height: 0.463vh;
  300. border: 0.093vh solid #05bb4c;
  301. border-top: 0;
  302. left: 0;
  303. bottom: 0;
  304. box-sizing: border-box;
  305. }
  306. .title {
  307. background: rgba(255, 255, 255, 0.1);
  308. margin-bottom: 8px;
  309. padding: 1vh;
  310. }
  311. </style>