index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  1. <template>
  2. <div class="chart-container">
  3. <div class="filter" >
  4. <div style="margin-left:-10px;">
  5. <!-- <el-button size="small" type="primary" @click="insertEvent"> 新增</el-button>-->
  6. <el-upload
  7. ref="upload"
  8. name="file"
  9. :http-request="this.readWindTurbinePowerCurve"
  10. class="link-block"
  11. action=""
  12. :show-file-list = false
  13. >
  14. <el-button size="small" type="primary" >导入</el-button>
  15. </el-upload>
  16. <el-button size="small" type="primary" @click="exportToExcel">导出</el-button>
  17. </div>
  18. <div class="toolbar" v-show="this.showToolBar">
  19. <div class="toolMenu">
  20. <el-row>
  21. <el-col :span="6">
  22. 风速
  23. <el-input type="text"
  24. v-model="speed"
  25. placeholder="请输入风速值"
  26. prefix-icon="el-icon-search"
  27. clearable
  28. style="max-width: 180px;"
  29. size="small"
  30. ></el-input>
  31. </el-col>
  32. <el-col :span="6">
  33. 功率
  34. <el-input type="text"
  35. v-model="power"
  36. placeholder="请输入功率值"
  37. prefix-icon="el-icon-search"
  38. clearable
  39. style="max-width: 180px;"
  40. size="small"
  41. ></el-input>
  42. </el-col>
  43. <el-col :span="6">
  44. 机组
  45. <el-input type="text"
  46. v-model="fanId"
  47. placeholder="请输入机组id"
  48. prefix-icon="el-icon-search"
  49. clearable
  50. style="max-width: 200px;"
  51. size="small"
  52. ></el-input>
  53. </el-col>
  54. <el-col :span="6">
  55. <el-button type="primary" size="small" :loading="loading" @click="findBySomeConditions">查询</el-button>
  56. <el-button type="primary" size="small" :loading="loading" @click="clearInput">清空</el-button>
  57. </el-col>
  58. </el-row>
  59. </div>
  60. <!-- <vxe-toolbar ref="fstToolBar" custom >-->
  61. <!-- <template v-slot:buttons>-->
  62. <!-- <vxe-button class="downloadButton" style="border:none;" @click="exportDataEvent"><i class="vxe-icon&#45;&#45;download" ></i></vxe-button>-->
  63. <!-- </template>-->
  64. <!-- </vxe-toolbar>-->
  65. </div>
  66. <!-- <div class="toolbar" v-show="this.showToolBar"> <vxe-toolbar ref="nwpToolBar" custom></vxe-toolbar></div>-->
  67. </div>
  68. <div class="content">
  69. <el-tabs type="card" v-model="activeName" @tab-click="Byresize">
  70. <el-tab-pane label="图表" name="first">
  71. <chart :drawData = this.drawData :resizeKey=this.resizeKey />
  72. </el-tab-pane>
  73. <el-tab-pane label="表格" name="second">
  74. <div class="tableContent">
  75. <vxe-grid
  76. id="nwpTable"
  77. ref="windRef"
  78. border
  79. export-config
  80. :loading="loading"
  81. resizable
  82. keep-source
  83. :auto-resize="true"
  84. :header-cell-style="styleStr"
  85. max-height="90%"
  86. :cell-style="styleTableStr"
  87. align="center"
  88. :data="tableData"
  89. :columns="tableColumn"
  90. :edit-config="{trigger: 'manual', mode: 'row', showStatus: true, }"
  91. >
  92. <template v-slot:operate="{ row }">
  93. <template v-if="$refs.windRef.isActiveByRow(row)">
  94. <vxe-button content="保存" circle @click="saveRowEvent(row)"></vxe-button>
  95. </template>
  96. <template v-else>
  97. <vxe-button content="编辑" circle @click="editRowEvent(row)"></vxe-button>
  98. </template>
  99. <!-- <vxe-button content="删除" circle @click="removeRowEvent(row)"></vxe-button>-->
  100. </template>
  101. </vxe-grid>
  102. <div class="rtPageturning">
  103. <vxe-pager
  104. background
  105. :loading="loading"
  106. :current-page.sync="currentPage"
  107. :page-size.sync="pageSize"
  108. :page-sizes="pageSizes"
  109. :total="total"
  110. @page-change="handlePageChange"
  111. :layouts="['PrevJump', 'PrevPage', 'JumpNumber', 'NextPage', 'NextJump', 'Sizes', 'FullJump', 'Total']">
  112. </vxe-pager>
  113. </div>
  114. </div>
  115. </el-tab-pane>
  116. </el-tabs>
  117. </div>
  118. <el-dialog
  119. title="风机曲线"
  120. :visible.sync="dialogVisible"
  121. width="30%"
  122. >
  123. <el-form ref="form" :model="form" label-width="120px" :rules="rules">
  124. <el-form-item label="风速(m/s)" prop="speed">
  125. <el-input v-model="form.speed" style="width: 70%"></el-input>
  126. </el-form-item>
  127. <el-form-item label="功率(Kw)" prop="power">
  128. <el-input v-model="form.power" style="width: 70%"></el-input>
  129. </el-form-item>
  130. <el-form-item label="所属机组" prop="fanId">
  131. <el-select v-model="form.fanId" style="width: 70%">
  132. <el-option v-for="item in fanIdData"
  133. :key="item.value"
  134. :label="item.fanIdStr"
  135. :value="item.fanId"></el-option>
  136. </el-select>
  137. </el-form-item>
  138. </el-form>
  139. <template #footer>
  140. <span class="dialog-footer">
  141. <el-button @click="dialogVisible = false" style="color: #000000; border: 1px solid #000000">取 消</el-button>
  142. <el-button type="primary" @click="saveRowEvent1"
  143. style="color: #000000; border: 1px solid #000000">确 定</el-button>
  144. </span>
  145. </template>
  146. </el-dialog>
  147. </div>
  148. </template>
  149. <script>
  150. import Chart from './charts'
  151. import resize from '../../../components/Charts/mixins/resize'
  152. export default {
  153. components: { Chart},
  154. mixins: [resize],
  155. data(){
  156. return {
  157. fanIdStr: '',
  158. value: '',
  159. fanIdData: [],
  160. styleStr: {},
  161. styleTableStr: {},
  162. tableToolbar: {
  163. export: true,
  164. custom: true
  165. },
  166. tableColumn: [],
  167. chart: null,
  168. loading: true,
  169. drawLoading: true,
  170. tableLoading: true,
  171. resizeKey: 1,
  172. activeName: 'first',
  173. drawData: {},
  174. tableData: [],
  175. total: 0,
  176. pageSize: 10,
  177. pageSizes: [10, 50, 100, {label: '大量数据', value: 1000},],
  178. currentPage: 1,
  179. showToolBar: false,
  180. dialogVisible: false,
  181. form: {},
  182. rules: {
  183. fanId: [
  184. {required: true, message: '此处为必填项'},
  185. {pattern: /^[+-]?(0|([1-9]\d*))(\.\d+)?$/, message: "填写数字", trigger: 'blur'},
  186. ],
  187. speed: [
  188. {required: true, message: '此处为必填项'},
  189. {pattern: /^[+-]?(0|([1-9]\d*))(\.\d+)?$/, message: "填写数字", trigger: 'blur'}
  190. ],
  191. power: [
  192. {required: true, message: '此处为必填项'},
  193. {pattern: /^[+-]?(0|([1-9]\d*))(\.\d+)?$/, message: "填写数字", trigger: 'blur'}
  194. ],
  195. },
  196. speed: '',
  197. power: '',
  198. fanId: '',
  199. }
  200. },
  201. created () {
  202. if(sessionStorage.getItem('styleSwitch') === 'blue'){
  203. this.styleStr = {background:'black',color:'white',border:'white'}
  204. this.styleTableStr = {background:'black',color:'white'}
  205. }
  206. this.$nextTick(() => {
  207. // 手动将表格和工具栏进行关联
  208. this.$refs.nwpRef.connect(this.$refs.nwpToolBar)
  209. })
  210. },
  211. mounted() {
  212. this.init()
  213. this.$axios.get("/windTurbinePowerCurve/getFanId").then(res =>{
  214. this.fanIdData = res.data
  215. })
  216. },
  217. methods:{
  218. exportDataEvent() {
  219. this.loading = true
  220. this.$axios.get('export/powerStationStatus/'+this.startTime+'/'+this.endTime, {
  221. responseType: 'blob'// 用于解决中文乱码
  222. }).then((response) => {
  223. this.loading = false
  224. }).catch((error) => {
  225. this.loading = false
  226. this.$message.error('导出失败' + error)
  227. })
  228. },
  229. init(){
  230. this.loading = true
  231. this.getDraw()
  232. this.getTable()
  233. },
  234. getDraw(){
  235. this.drawLoading = true
  236. this.$axios.get('/windTurbinePowerCurve/new/').then((res) => {
  237. this.drawData = res.data
  238. this.drawLoading = false
  239. if(!this.drawLoading && !this.tableLoading){
  240. this.loading = false
  241. }
  242. }).catch((error) => {
  243. this.drawLoading = false
  244. if(!this.drawLoading && !this.tableLoading){
  245. this.loading = false
  246. }
  247. this.$message.error('查询出错' + error)
  248. })
  249. },
  250. getTable(){
  251. this.findBySomeConditions()
  252. // this.tableLoading = true
  253. // this.$axios.get('/windTurbinePowerCurve/'+this.currentPage+'/'+this.pageSize).then((res) => {
  254. // this.tableData = res.data.content
  255. // // 表分页格数据总条数
  256. // this.total = res.data.count
  257. // this.tableColumn = []
  258. // this.tableColumn = [
  259. // { field: 'id', title: 'id',minWidth:"150",width:"180"},
  260. // { field: 'speed', title: '风速',minWidth:"60",editRender: { name: 'input' }},
  261. // { field: 'power', title: '功率',minWidth:"60",editRender: { name: 'input' }},
  262. // { field: 'fanId', title: '机组',minWidth:"60",editRender: { name: 'input' }},
  263. // { title: '操作', width: 200, slots: { default: 'operate' } }
  264. // ]
  265. //
  266. // this.tableLoading = false
  267. // if(!this.drawLoading && !this.tableLoading){
  268. // this.loading = false
  269. // }
  270. // }).catch((error) => {
  271. // this.tableLoading = false
  272. // if(!this.drawLoading && !this.tableLoading){
  273. // this.loading = false
  274. // }
  275. // this.$message.error('查询table出错' + error)
  276. // })
  277. },
  278. handlePageChange ({ currentPage, pageSize }) {
  279. this.currentPage = currentPage
  280. this.pageSize = pageSize
  281. this.loading = true
  282. this.getTable();
  283. },
  284. readWindTurbinePowerCurve(obj) {
  285. this.$XModal.confirm('是否从Excel读取数据?').then(type => {
  286. if (type === 'confirm') {
  287. const formData = new FormData()
  288. formData.append("multipartFile",obj.file)
  289. this.loading = true
  290. this.$axios.post("/readToMysql/readWindTurbinePowerCurveMap",formData).then(res=>{
  291. this.$message.success(
  292. res.message
  293. )
  294. this.loading = false
  295. this.init()
  296. })
  297. }
  298. })
  299. },
  300. Byresize(tab){
  301. if(tab.name =='first'){
  302. this.resizeKey++
  303. this.showToolBar = false
  304. }else{
  305. this.showToolBar = true
  306. }
  307. },
  308. editRowEvent (row) {
  309. this.$refs.windRef.setActiveRow(row)
  310. },
  311. saveRowEvent (row) {
  312. this.$refs.windRef.clearActived().then(() => {
  313. this.loading = true
  314. this.$axios.put('/windTurbinePowerCurve/',row).then((res) => {
  315. this.$message.success(
  316. res.message
  317. )
  318. this.loading = false
  319. }).catch((error) => {
  320. this.$message.error('修改失败' + error)
  321. this.loading = false
  322. })
  323. })
  324. },
  325. removeRowEvent (row) {
  326. this.$XModal.confirm('您确定要删除该数据?').then(type => {
  327. if (type === 'confirm') {
  328. this.$axios.delete('/windTurbinePowerCurve/',{data:row}).then((res) => {
  329. this.$message.success(
  330. res.message
  331. )
  332. this.loading = false
  333. this.getTable()
  334. this.init()
  335. }).catch((error) => {
  336. this.$message.error('删除' + error)
  337. this.loading = false
  338. })
  339. }
  340. })
  341. },
  342. insertEvent() {
  343. this.form = {};
  344. this.dialogVisible = true;
  345. },
  346. saveRowEvent1() {
  347. this.$axios.post('/windTurbinePowerCurve', this.form).then(res => {
  348. this.$message.success(res.message)
  349. this.findBySomeConditions()
  350. }).catch(e => {
  351. this.$message.error(e)
  352. })
  353. this.dialogVisible = false;
  354. this.findBySomeConditions()
  355. },
  356. exportToExcel(){
  357. this.dialogVisible = true;
  358. this.$axios.get('/exportToExcel/windTurbinePowerCurveExport').then(res => {
  359. this.$XModal.message({status: 'success', message: res.message})
  360. })
  361. this.dialogVisible = false;
  362. },
  363. findBySomeConditions() {
  364. if (this.speed == '') {
  365. this.speed = null
  366. }
  367. if (this.power == '') {
  368. this.power = null
  369. }
  370. if (this.fanId == '') {
  371. this.fanId = null
  372. }
  373. // this.$axios.get("/windTurbinePowerCurve/bySomeConditions/" + this.currentPage + "/" + this.pageSize + "/" + this.speed + '/' + this.power + '/' + this.fanId).then(res => {
  374. // this.tableData = res.data.content
  375. // this.total = res.data.totalElements
  376. // })
  377. this.$axios.get("/windTurbinePowerCurve/bySomeConditions/" + this.currentPage + "/" + this.pageSize + "/" + this.speed + '/' + this.power + '/' + this.fanId).then(res => {
  378. this.tableData = res.data.content
  379. // 表分页格数据总条数
  380. this.total = res.data.totalElements
  381. this.tableColumn = []
  382. this.tableColumn = [
  383. { field: 'id', title: 'id',minWidth:"150",width:"180"},
  384. { field: 'speed', title: '风速',minWidth:"60",editRender: { name: 'input' }},
  385. { field: 'power', title: '功率',minWidth:"60",editRender: { name: 'input' }},
  386. { field: 'fanId', title: '机组',minWidth:"60",editRender: { name: 'input' }},
  387. { title: '操作', width: 200, slots: { default: 'operate' } }
  388. ]
  389. this.tableLoading = false
  390. if(!this.drawLoading && !this.tableLoading){
  391. this.loading = false
  392. }
  393. }).catch((error) => {
  394. this.tableLoading = false
  395. if(!this.drawLoading && !this.tableLoading){
  396. this.loading = false
  397. }
  398. this.$message.error('查询table出错' + error)
  399. })
  400. },
  401. clearInput(){
  402. this.speed = ''
  403. this.power = ''
  404. this.fanId = ''
  405. }
  406. }
  407. }
  408. </script>
  409. <style scoped>
  410. .link-block{
  411. display: inline-block;
  412. }
  413. </style>