doum
7 天以前 e46bfa3ff94a8a1b4daf37c7fcb79c2fab22a72c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<template>
  <TableLayout :permissions="['business:ywelectricalparam:query']">
    <el-form ref="searchForm" slot="search-form" :model="searchForm" label-width="100px" inline>
      <el-form-item label="配置名称" prop="nameKeyword">
        <el-input v-model="searchForm.nameKeyword" placeholder="请输入配置名称" clearable @keypress.enter.native="search"/>
      </el-form-item>
      <section>
        <el-button type="primary" icon="el-icon-search" @click="search">查询</el-button>
        <el-button icon="el-icon-refresh" @click="reset">重置</el-button>
      </section>
    </el-form>
    <template v-slot:table-wrap>
      <ul class="toolbar">
        <li>
          <el-button type="primary" icon="el-icon-plus" @click="$refs.editWindow.open('新建电表参数')" v-permissions="['business:ywelectricalparam:create']">新建</el-button>
        </li>
        <li>
          <el-button @click="exportExcel" :loading="isWorking.export" v-permissions="['business:ywelectricalparam:exportExcel']">导出</el-button>
        </li>
      </ul>
      <el-table v-loading="isWorking.search" :data="tableData.list" stripe @selection-change="handleSelectionChange">
        <el-table-column type="selection" width="55"/>
        <el-table-column prop="name" label="配置名称" min-width="180" align="center" show-overflow-tooltip/>
        <el-table-column label="电价" min-width="120" align="center">
          <template slot-scope="{ row }">{{ formatPrice(row.price) }}</template>
        </el-table-column>
        <el-table-column label="透支金额" min-width="100" align="center">
          <template slot-scope="{ row }">{{ formatYuan(row.tzMoney) }}</template>
        </el-table-column>
        <el-table-column label="一级报警金额" min-width="120" align="center">
          <template slot-scope="{ row }">{{ formatYuan(row.yjbjMoney) }}</template>
        </el-table-column>
        <el-table-column label="二级报警金额" min-width="120" align="center">
          <template slot-scope="{ row }">{{ formatYuan(row.ejbjMoney) }}</template>
        </el-table-column>
        <el-table-column label="负荷限制功率" min-width="120" align="center">
          <template slot-scope="{ row }">{{ formatPower(row.limitFhgl) }}</template>
        </el-table-column>
        <el-table-column label="超负荷时间" min-width="110" align="center">
          <template slot-scope="{ row }">{{ formatMinutes(row.limitFhTime) }}</template>
        </el-table-column>
        <el-table-column prop="editDate" label="更新时间" min-width="160" align="center"/>
        <el-table-column label="操作" align="center" min-width="140" fixed="right">
          <template slot-scope="{ row }">
            <el-button type="text" @click="$refs.editWindow.open('编辑电表参数', row)" v-permissions="['business:ywelectricalparam:update']">编辑</el-button>
            <el-button type="text" class="red" @click="deleteById(row)" v-permissions="['business:ywelectricalparam:delete']">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination @size-change="handleSizeChange" @current-change="handlePageChange" :pagination="tableData.pagination"/>
    </template>
    <YwElectricalParamEdit ref="editWindow" @success="handlePageChange"/>
  </TableLayout>
</template>
 
<script>
import BaseTable from '@/components/base/BaseTable'
import TableLayout from '@/layouts/TableLayout'
import Pagination from '@/components/common/Pagination'
import YwElectricalParamEdit from './components/YwElectricalParamEdit'
 
export default {
  name: 'YwElectricalParam',
  extends: BaseTable,
  components: { TableLayout, Pagination, YwElectricalParamEdit },
  data () {
    return {
      searchForm: {
        nameKeyword: ''
      }
    }
  },
  created () {
    this.config({
      module: '电表参数设置',
      api: '/business/ywelectricalparam',
      'field.id': 'id',
      'field.main': 'name'
    })
    this.search()
  },
  methods: {
    formatYuan (val) {
      if (val === null || val === undefined || val === '') return '-'
      const n = Number(val)
      if (isNaN(n)) return val
      return `${n.toFixed(2)}元`
    },
    formatPrice (val) {
      if (val === null || val === undefined || val === '') return '-'
      const n = Number(val)
      if (isNaN(n)) return val
      return `${n.toFixed(2)} 元/KWH`
    },
    formatPower (val) {
      if (val === null || val === undefined || val === '') return '-'
      const n = Number(val)
      if (isNaN(n)) return val
      return `${n.toFixed(2)}KW`
    },
    formatMinutes (val) {
      if (val === null || val === undefined || val === '') return '-'
      return `${val}分钟`
    },
    buildSearchModel () {
      const model = {}
      if (this.searchForm.nameKeyword) model.nameKeyword = this.searchForm.nameKeyword
      return model
    },
    handlePageChange (pageIndex) {
      this.tableData.pagination.pageIndex = pageIndex || this.tableData.pagination.pageIndex
      this.isWorking.search = true
      this.api.fetchList({
        page: this.tableData.pagination.pageIndex,
        capacity: this.tableData.pagination.pageSize,
        model: this.buildSearchModel(),
        sorts: this.tableData.sorts
      })
        .then(data => {
          this.tableData.list = data.records
          this.tableData.pagination.total = data.total
        })
        .catch(() => {})
        .finally(() => { this.isWorking.search = false })
    },
    reset () {
      this.searchForm = { nameKeyword: '' }
      this.search()
    }
  }
}
</script>
 
<style scoped>
.red { color: #f56c6c; }
</style>