index.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <!--
  2. - Copyright (c) 2018-2025, lengleng All rights reserved.
  3. -
  4. - Redistribution and use in source and binary forms, with or without
  5. - modification, are permitted provided that the following conditions are met:
  6. -
  7. - Redistributions of source code must retain the above copyright notice,
  8. - this list of conditions and the following disclaimer.
  9. - Redistributions in binary form must reproduce the above copyright
  10. - notice, this list of conditions and the following disclaimer in the
  11. - documentation and/or other materials provided with the distribution.
  12. - Neither the name of the pig4cloud.com developer nor the names of its
  13. - contributors may be used to endorse or promote products derived from
  14. - this software without specific prior written permission.
  15. - Author: lengleng (wangiegie@gmail.com)
  16. -->
  17. <template>
  18. <div class="execution">
  19. <div class="filter">
  20. <div class="startTime" style="display: inline-block">
  21. <span class="timeText" style="font-weight: bold;font-size: 14px">&#12288;预测起始时间:</span>
  22. <el-date-picker
  23. v-model="startTime"
  24. :clearable="false"
  25. type="datetime"
  26. value-format="timestamp"
  27. placeholder="选择日期">
  28. </el-date-picker>
  29. </div>
  30. <div class="endTime" style="display: inline-block">
  31. <span class="timeText" style="font-weight: bold;font-size: 14px">&#12288;预测截止时间:</span>
  32. <el-date-picker
  33. v-model="endTime"
  34. :clearable="false"
  35. type="datetime"
  36. value-format="timestamp"
  37. placeholder="选择日期">
  38. </el-date-picker>
  39. </div>
  40. <div style="display: inline-block">
  41. <span style="font-weight: bold;font-size: 14px">&#12288;场站名称:</span>
  42. <el-select style="width:250px" v-model="stationCode"
  43. size="small" @change="getManufactor">
  44. <el-option
  45. v-for="item in stationList"
  46. :key="item.value"
  47. :label="item.label"
  48. :value="item.value">
  49. <span style="float: left">{{ item.label }}</span>
  50. <span style="float: right; color: #8492a6;font-size: 13px">{{ item.value }}</span>
  51. </el-option>
  52. </el-select>
  53. </div>
  54. <div style="display: none">
  55. <span style="font-weight: bold;font-size: 14px">&#12288;预测厂家:</span>
  56. <el-select style="width:250px" v-model="forecastManufactor" size="small">
  57. <el-option
  58. v-for="item in forecastManufactorList"
  59. :key="item.sign"
  60. :label="item.name"
  61. :value="item.sign">
  62. <span style="float: left">{{ item.name }}</span>
  63. <span style="float: right; color: #8492a6;font-size: 13px">{{ item.sign }}</span>
  64. </el-option>
  65. </el-select>
  66. </div>
  67. &nbsp;
  68. <div class="timeQuery" style="display: inline-block">
  69. <el-button size="small" :loading="tableLoading" @click="queryNWPDataByStationCode">查询</el-button>
  70. </div>
  71. </div>
  72. <basic-container>
  73. <avue-crud ref="crud"
  74. :page.sync="page"
  75. :data="tableData"
  76. :table-loading="tableLoading"
  77. :option="tableOption"
  78. @on-load="queryNWPDataByStationCode"
  79. >
  80. </avue-crud>
  81. </basic-container>
  82. </div>
  83. </template>
  84. <script>
  85. import {fetchList, getObj, addObj, putObj, delObj, getStation, queryTableData} from '@/api/nwp'
  86. import {tableOption} from '@/const/crud/nwp'
  87. import {mapGetters} from 'vuex'
  88. import {getManufactorByStationCode} from '@/api/forecastmanufactor'
  89. export default {
  90. name: 'nwp',
  91. data() {
  92. return {
  93. searchForm: {},
  94. tableData: [],
  95. page: {
  96. total: 0, // 总页数
  97. currentPage: 1, // 当前页数
  98. pageSize: 10 // 每页显示多少条
  99. },
  100. startTime: new Date(new Date().toLocaleDateString()).getTime() + 60 * 60 * 24 * 1000,
  101. endTime: new Date(new Date().toLocaleDateString()).getTime() + 60 * 60 * 24 * 1000 * 4 - 1,
  102. stationCode: '',
  103. stationList: [],
  104. tableLoading: false,
  105. tableOption: tableOption,
  106. forecastManufactor: '',
  107. forecastManufactorList: [],
  108. }
  109. },
  110. mounted() {
  111. this.getStationCode();
  112. // this.getForecastManufactor(this.page)
  113. },
  114. computed: {
  115. ...mapGetters(['permissions']),
  116. permissionList() {
  117. return {
  118. addBtn: this.vaildData(this.permissions.idp_nwp_add, false),
  119. delBtn: this.vaildData(this.permissions.idp_nwp_del, false),
  120. editBtn: this.vaildData(this.permissions.idp_nwp_edit, false)
  121. };
  122. }
  123. },
  124. methods: {
  125. getManufactor(val) {
  126. this.forecastManufactorList = []
  127. this.forecastManufactor = []
  128. getManufactorByStationCode(val).then(response => {
  129. this.forecastManufactorList = response.data.data
  130. if (this.forecastManufactorList != '') {
  131. this.forecastManufactor = this.forecastManufactorList[0].sign;
  132. }
  133. this.tableLoading = false
  134. })
  135. },
  136. queryNWPDataByStationCode() {
  137. if (this.stationCode=='' || this.stationCode==null){
  138. return
  139. }
  140. const param = new URLSearchParams()
  141. param.append('currentPage', this.page.currentPage)
  142. param.append('pageSize', this.page.pageSize)
  143. param.append('stationCode', this.stationCode)
  144. param.append('startTime', this.startTime)
  145. param.append('endTime', this.endTime)
  146. // param.append('forecastManufactor', this.forecastManufactor)
  147. param.append('forecastManufactor', 'SYJY')
  148. queryTableData(param).then((res) => {
  149. console.log(res.data.data.records)
  150. this.tableData = res.data.data.records
  151. this.page.pageSize = res.data.data.size
  152. this.page.total = res.data.data.total
  153. })
  154. },
  155. getForecastManufactor(page, params) {
  156. this.tableLoading = true
  157. getForecastManufactor(Object.assign({
  158. // current: page.currentPage,
  159. // size: page.pageSize
  160. }, params, this.searchForm)).then(response => {
  161. console.log(response)
  162. this.forecastManufactorList = response.data.data.records
  163. if (this.forecastManufactorList.length > 0) {
  164. this.forecastManufactor = this.forecastManufactorList[0].sign
  165. }
  166. })
  167. },
  168. //获取所有场站
  169. getStationCode() {
  170. this.tableLoading = true
  171. getStation().then(response => {
  172. this.stationList = response.data.data
  173. if (this.stationList.length > 0) {
  174. this.stationCode = this.stationList[0].value
  175. this.getManufactor(this.stationCode)
  176. }
  177. this.tableLoading = false
  178. })
  179. },
  180. getList(page, params) {
  181. this.tableLoading = true
  182. fetchList(Object.assign({
  183. current: page.currentPage,
  184. size: page.pageSize
  185. }, params, this.searchForm)).then(response => {
  186. this.tableData = response.data.data.records
  187. this.page.total = response.data.data.total
  188. this.tableLoading = false
  189. }).catch(() => {
  190. this.tableLoading = false
  191. })
  192. },
  193. rowDel: function (row, index) {
  194. this.$confirm('是否确认删除ID为' + row.id, '提示', {
  195. confirmButtonText: '确定',
  196. cancelButtonText: '取消',
  197. type: 'warning'
  198. }).then(function () {
  199. return delObj(row.id)
  200. }).then(data => {
  201. this.$message.success('删除成功')
  202. this.getList(this.page)
  203. })
  204. },
  205. handleUpdate: function (row, index, done, loading) {
  206. putObj(row).then(data => {
  207. this.$message.success('修改成功')
  208. done()
  209. this.getList(this.page)
  210. }).catch(() => {
  211. loading();
  212. });
  213. },
  214. handleSave: function (row, done, loading) {
  215. addObj(row).then(data => {
  216. this.$message.success('添加成功')
  217. done()
  218. this.getList(this.page)
  219. }).catch(() => {
  220. loading();
  221. });
  222. },
  223. sizeChange(pageSize) {
  224. this.page.pageSize = pageSize
  225. },
  226. currentChange(current) {
  227. this.page.currentPage = current
  228. },
  229. searchChange(form, done) {
  230. this.searchForm = form
  231. this.page.currentPage = 1
  232. this.getList(this.page, form)
  233. done()
  234. },
  235. refreshChange() {
  236. this.getList(this.page)
  237. }
  238. }
  239. }
  240. </script>