statisticAnalysis.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <template>
  2. <div>
  3. <div class="block">
  4. <span class="demonstration">选择日期:</span>
  5. <el-date-picker
  6. size="medium"
  7. v-model="dateArea"
  8. type="daterange"
  9. :picker-options="pickerOptions"
  10. range-separator="至"
  11. start-placeholder="开始日期 "
  12. end-placeholder="结束日期 "
  13. align="right"
  14. >
  15. </el-date-picker>
  16. <button class="btn green" @click="search">搜索</button>
  17. </div>
  18. <div class="table1">
  19. <el-table
  20. max-height="86vh"
  21. height="1100"
  22. v-loading="loading"
  23. element-loading-background="rgba(0, 0, 0, 0.8)"
  24. :data="tableData"
  25. :header-cell-style="{
  26. height: '40px',
  27. background: 'rgba(83, 98, 104, 0.2)',
  28. color: '#b2bdc0',
  29. 'border-bottom': '0px solid red',
  30. }"
  31. :cell-style="{
  32. height: '40px',
  33. 'border-bottom': 'solid 0px #242424',
  34. }"
  35. stripe
  36. style="width: 100%; margin-bottom: 10px; overflow-y: auto"
  37. >
  38. <el-table-column prop="wpname" label="场站" align="center" width="360">
  39. </el-table-column>
  40. <el-table-column prop="theday" label="日期" align="center" width="360">
  41. </el-table-column>
  42. <el-table-column align="center" label="操作">
  43. <template #default="scope">
  44. <button @click="handleClickForm(scope.row)" class="btn">
  45. 表底
  46. </button>
  47. <button class="btn" @click="handleClickCZ(scope.row)">场站</button>
  48. </template>
  49. </el-table-column>
  50. <el-table-column align="center" label="操作">
  51. <template #default="scope">
  52. <el-button
  53. @click="handleClick3(scope.row)"
  54. :class="scope.row.isConfirm == 1 ? 'displayBtn' : 'btn'"
  55. :disabled="scope.row.isConfirm == 1"
  56. >
  57. 确认</el-button
  58. >
  59. </template>
  60. </el-table-column>
  61. </el-table>
  62. <!-- :class="scope.row.isConfirm == 1 ? 'active' : 'active:hover'" -->
  63. </div>
  64. </div>
  65. </template>
  66. <script>
  67. import api from "@api/economic/index.js";
  68. export default {
  69. created() {
  70. // 将查询的日期存入到routerData
  71. this.routerData.beginDate = this.$route.query.beginDate;
  72. this.routerData.endDate = this.$route.query.endDate;
  73. this.getList();
  74. },
  75. components: {},
  76. data() {
  77. return {
  78. dateArea: [
  79. this.fmtDate(
  80. new Date(
  81. new Date().setTime(new Date().getTime() - 3600 * 1000 * 24 * 30)
  82. )
  83. ),
  84. this.fmtDate(new Date()),
  85. ],
  86. tableData: [],
  87. loading: false,
  88. routerData: {},
  89. };
  90. },
  91. methods: {
  92. handleClickCZ(row) {
  93. this.$router.push({
  94. path: "/others/statisticAnalysis/station",
  95. query: {
  96. wpid: row.wpid,
  97. theday: row.theday,
  98. isConfirm: row.isConfirm,
  99. beginDate: this.routerData.beginDate,
  100. endDate: this.routerData.endDate,
  101. },
  102. });
  103. },
  104. handleClickForm(row) {
  105. this.$router.push({
  106. path: "/others/statisticAnalysis/form",
  107. query: {
  108. wpid: row.wpid,
  109. theday: row.theday,
  110. isConfirm: row.isConfirm,
  111. beginDate: this.routerData.beginDate,
  112. endDate: this.routerData.endDate,
  113. },
  114. });
  115. },
  116. handleClick3(row) {
  117. api.analysisplusCommit(row).then((res) => {
  118. this.getList();
  119. });
  120. },
  121. getList: function () {
  122. if (this.$route.query.beginDate != null) {
  123. this.dateArea[0] = this.$route.query.beginDate;
  124. this.dateArea[1] = this.$route.query.endDate;
  125. }
  126. api
  127. .statisticAnalysis({
  128. beginDate: new Date(this.dateArea[0]).formatDate("yyyy-MM-dd"),
  129. endDate: new Date(this.dateArea[1]).formatDate("yyyy-MM-dd"),
  130. })
  131. .then((res) => {
  132. this.tableData = res.data;
  133. this.loading = false;
  134. });
  135. },
  136. getTime(val) {
  137. //时间戳处理,val=1是默认开始时间(当前月第一天),val=2是默认结束时间(今天)
  138. var date = new Date();
  139. var year = date.getFullYear(),
  140. month = date.getMonth() + 1,
  141. day = date.getDate();
  142. month >= 1 && month <= 9 ? (month = "0" + month) : "";
  143. day >= 0 && day <= 9 ? (day = "0" + day) : "";
  144. var begin = year + "-" + month + "-01";
  145. var end = year + "-" + month + "-" + day;
  146. if (val == 1) {
  147. return begin;
  148. } else if (val == 2) {
  149. return end;
  150. }
  151. },
  152. // 格式化日期
  153. fmtDate(date) {
  154. let curDate = date || new Date();
  155. let year = curDate.getFullYear();
  156. let mouth = curDate.getUTCMonth() + 1;
  157. let day = curDate.getDate();
  158. let hour = curDate.getHours();
  159. let minutes = curDate.getMinutes();
  160. let seconds = curDate.getSeconds();
  161. return (
  162. year +
  163. "-" +
  164. (mouth < 10 ? "0" + mouth : mouth) +
  165. "-" +
  166. (day < 10 ? "0" + day : day) +
  167. " " +
  168. (hour < 10 ? "0" + hour : hour) +
  169. ":" +
  170. (minutes < 10 ? "0" + minutes : minutes) +
  171. ":" +
  172. (seconds < 10 ? "0" + seconds : seconds)
  173. );
  174. },
  175. search() {
  176. // 将查询的日期存入到routerData
  177. this.routerData.beginDate = new Date(this.dateArea[0]).formatDate(
  178. "yyyy-MM-dd"
  179. );
  180. this.routerData.endDate = new Date(this.dateArea[1]).formatDate(
  181. "yyyy-MM-dd"
  182. );
  183. this.loading = true;
  184. this.getList();
  185. },
  186. },
  187. };
  188. </script>
  189. <style lang="less" scoped>
  190. .btn {
  191. margin-left: 160px;
  192. border-radius: 5px;
  193. }
  194. .table1 {
  195. margin-top: 30px;
  196. }
  197. /deep/.el-date-editor {
  198. width: 490px;
  199. border-color: black;
  200. }
  201. .block {
  202. margin-left: 20px;
  203. }
  204. /deep/.el-date-editor .el-range-input {
  205. color: #fff;
  206. }
  207. .btn,
  208. .el-button {
  209. margin-left: 10px;
  210. height: 33px !important;
  211. line-height: 33px;
  212. flex: 0 0 auto;
  213. background: transparent;
  214. border: 1px solid #606769;
  215. padding: 0 1.481vh;
  216. color: #606769;
  217. font-size: 1.296vh;
  218. cursor: pointer;
  219. min-height: 0;
  220. }
  221. .el-button:hover {
  222. background-color: black;
  223. color: #05bb4c;
  224. border-color: #05bb4c;
  225. }
  226. .btn:hover {
  227. color: #05bb4c;
  228. border-color: #05bb4c;
  229. }
  230. .displayBtn {
  231. background-color: #4d4949;
  232. color: rgb(87 110 108);
  233. }
  234. .displayBtn:hover {
  235. border: #4d4949;
  236. background-color: #4d4949;
  237. color: rgb(87 110 108);
  238. }
  239. </style>